PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/src/sqlite/test/pragma.test

#
Unknown | 1480 lines | 1401 code | 79 blank | 0 comment | 0 complexity | 0fc82fedfb84fe26016ae96a22b05346 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. # 2002 March 6
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library.
  12. #
  13. # This file implements tests for the PRAGMA command.
  14. #
  15. # $Id: pragma.test,v 1.73 2009/01/12 14:01:45 danielk1977 Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. # Do not use a codec for tests in this file, as the database file is
  19. # manipulated directly using tcl scripts (using the [hexio_write] command).
  20. #
  21. do_not_use_codec
  22. # Test organization:
  23. #
  24. # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
  25. # pragma-2.*: Test synchronous on attached db.
  26. # pragma-3.*: Test detection of table/index inconsistency by integrity_check.
  27. # pragma-4.*: Test cache_size and default_cache_size on attached db.
  28. # pragma-5.*: Test that pragma synchronous may not be used inside of a
  29. # transaction.
  30. # pragma-6.*: Test schema-query pragmas.
  31. # pragma-7.*: Miscellaneous tests.
  32. # pragma-8.*: Test user_version and schema_version pragmas.
  33. # pragma-9.*: Test temp_store and temp_store_directory.
  34. # pragma-10.*: Test the count_changes pragma in the presence of triggers.
  35. # pragma-11.*: Test the collation_list pragma.
  36. # pragma-14.*: Test the page_count pragma.
  37. # pragma-15.*: Test that the value set using the cache_size pragma is not
  38. # reset when the schema is reloaded.
  39. # pragma-16.*: Test proxy locking
  40. #
  41. ifcapable !pragma {
  42. finish_test
  43. return
  44. }
  45. # Delete the preexisting database to avoid the special setup
  46. # that the "all.test" script does.
  47. #
  48. db close
  49. file delete test.db test.db-journal
  50. file delete test3.db test3.db-journal
  51. sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
  52. ifcapable pager_pragmas {
  53. set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}]
  54. set TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}]
  55. do_test pragma-1.1 {
  56. execsql {
  57. PRAGMA cache_size;
  58. PRAGMA default_cache_size;
  59. PRAGMA synchronous;
  60. }
  61. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
  62. do_test pragma-1.2 {
  63. execsql {
  64. PRAGMA synchronous=OFF;
  65. PRAGMA cache_size=1234;
  66. PRAGMA cache_size;
  67. PRAGMA default_cache_size;
  68. PRAGMA synchronous;
  69. }
  70. } [list 1234 $DFLT_CACHE_SZ 0]
  71. do_test pragma-1.3 {
  72. db close
  73. sqlite3 db test.db
  74. execsql {
  75. PRAGMA cache_size;
  76. PRAGMA default_cache_size;
  77. PRAGMA synchronous;
  78. }
  79. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
  80. do_test pragma-1.4 {
  81. execsql {
  82. PRAGMA synchronous=OFF;
  83. PRAGMA cache_size;
  84. PRAGMA default_cache_size;
  85. PRAGMA synchronous;
  86. }
  87. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0]
  88. do_test pragma-1.5 {
  89. execsql {
  90. PRAGMA cache_size=-4321;
  91. PRAGMA cache_size;
  92. PRAGMA default_cache_size;
  93. PRAGMA synchronous;
  94. }
  95. } [list 4321 $DFLT_CACHE_SZ 0]
  96. do_test pragma-1.6 {
  97. execsql {
  98. PRAGMA synchronous=ON;
  99. PRAGMA cache_size;
  100. PRAGMA default_cache_size;
  101. PRAGMA synchronous;
  102. }
  103. } [list 4321 $DFLT_CACHE_SZ 1]
  104. do_test pragma-1.7 {
  105. db close
  106. sqlite3 db test.db
  107. execsql {
  108. PRAGMA cache_size;
  109. PRAGMA default_cache_size;
  110. PRAGMA synchronous;
  111. }
  112. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
  113. do_test pragma-1.8 {
  114. execsql {
  115. PRAGMA default_cache_size=-123;
  116. PRAGMA cache_size;
  117. PRAGMA default_cache_size;
  118. PRAGMA synchronous;
  119. }
  120. } {123 123 2}
  121. do_test pragma-1.9.1 {
  122. db close
  123. sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
  124. execsql {
  125. PRAGMA cache_size;
  126. PRAGMA default_cache_size;
  127. PRAGMA synchronous;
  128. }
  129. } {123 123 2}
  130. ifcapable vacuum {
  131. do_test pragma-1.9.2 {
  132. execsql {
  133. VACUUM;
  134. PRAGMA cache_size;
  135. PRAGMA default_cache_size;
  136. PRAGMA synchronous;
  137. }
  138. } {123 123 2}
  139. }
  140. do_test pragma-1.10 {
  141. execsql {
  142. PRAGMA synchronous=NORMAL;
  143. PRAGMA cache_size;
  144. PRAGMA default_cache_size;
  145. PRAGMA synchronous;
  146. }
  147. } {123 123 1}
  148. do_test pragma-1.11 {
  149. execsql {
  150. PRAGMA synchronous=FULL;
  151. PRAGMA cache_size;
  152. PRAGMA default_cache_size;
  153. PRAGMA synchronous;
  154. }
  155. } {123 123 2}
  156. do_test pragma-1.12 {
  157. db close
  158. sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]
  159. execsql {
  160. PRAGMA cache_size;
  161. PRAGMA default_cache_size;
  162. PRAGMA synchronous;
  163. }
  164. } {123 123 2}
  165. # Make sure the pragma handler understands numeric values in addition
  166. # to keywords like "off" and "full".
  167. #
  168. do_test pragma-1.13 {
  169. execsql {
  170. PRAGMA synchronous=0;
  171. PRAGMA synchronous;
  172. }
  173. } {0}
  174. do_test pragma-1.14 {
  175. execsql {
  176. PRAGMA synchronous=2;
  177. PRAGMA synchronous;
  178. }
  179. } {2}
  180. } ;# ifcapable pager_pragmas
  181. # Test turning "flag" pragmas on and off.
  182. #
  183. ifcapable debug {
  184. # Pragma "vdbe_listing" is only available if compiled with SQLITE_DEBUG
  185. #
  186. do_test pragma-1.15 {
  187. execsql {
  188. PRAGMA vdbe_listing=YES;
  189. PRAGMA vdbe_listing;
  190. }
  191. } {1}
  192. do_test pragma-1.16 {
  193. execsql {
  194. PRAGMA vdbe_listing=NO;
  195. PRAGMA vdbe_listing;
  196. }
  197. } {0}
  198. }
  199. do_test pragma-1.17 {
  200. execsql {
  201. PRAGMA parser_trace=ON;
  202. PRAGMA parser_trace=OFF;
  203. }
  204. } {}
  205. do_test pragma-1.18 {
  206. execsql {
  207. PRAGMA bogus = -1234; -- Parsing of negative values
  208. }
  209. } {}
  210. # Test modifying the safety_level of an attached database.
  211. ifcapable pager_pragmas&&attach {
  212. do_test pragma-2.1 {
  213. file delete -force test2.db
  214. file delete -force test2.db-journal
  215. execsql {
  216. ATTACH 'test2.db' AS aux;
  217. }
  218. } {}
  219. do_test pragma-2.2 {
  220. execsql {
  221. pragma aux.synchronous;
  222. }
  223. } {2}
  224. do_test pragma-2.3 {
  225. execsql {
  226. pragma aux.synchronous = OFF;
  227. pragma aux.synchronous;
  228. pragma synchronous;
  229. }
  230. } {0 2}
  231. do_test pragma-2.4 {
  232. execsql {
  233. pragma aux.synchronous = ON;
  234. pragma synchronous;
  235. pragma aux.synchronous;
  236. }
  237. } {2 1}
  238. } ;# ifcapable pager_pragmas
  239. # Construct a corrupted index and make sure the integrity_check
  240. # pragma finds it.
  241. #
  242. # These tests won't work if the database is encrypted
  243. #
  244. do_test pragma-3.1 {
  245. db close
  246. file delete -force test.db test.db-journal
  247. sqlite3 db test.db
  248. execsql {
  249. PRAGMA auto_vacuum=OFF;
  250. BEGIN;
  251. CREATE TABLE t2(a,b,c);
  252. CREATE INDEX i2 ON t2(a);
  253. INSERT INTO t2 VALUES(11,2,3);
  254. INSERT INTO t2 VALUES(22,3,4);
  255. COMMIT;
  256. SELECT rowid, * from t2;
  257. }
  258. } {1 11 2 3 2 22 3 4}
  259. ifcapable attach {
  260. if {![sqlite3 -has-codec] && $sqlite_options(integrityck)} {
  261. do_test pragma-3.2 {
  262. db eval {SELECT rootpage FROM sqlite_master WHERE name='i2'} break
  263. set pgsz [db eval {PRAGMA page_size}]
  264. # overwrite the header on the rootpage of the index in order to
  265. # make the index appear to be empty.
  266. #
  267. set offset [expr {$pgsz*($rootpage-1)}]
  268. hexio_write test.db $offset 0a00000000040000000000
  269. db close
  270. sqlite3 db test.db
  271. execsql {PRAGMA integrity_check}
  272. } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  273. do_test pragma-3.3 {
  274. execsql {PRAGMA integrity_check=1}
  275. } {{rowid 1 missing from index i2}}
  276. do_test pragma-3.4 {
  277. execsql {
  278. ATTACH DATABASE 'test.db' AS t2;
  279. PRAGMA integrity_check
  280. }
  281. } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  282. do_test pragma-3.5 {
  283. execsql {
  284. PRAGMA integrity_check=4
  285. }
  286. } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2}}
  287. do_test pragma-3.6 {
  288. execsql {
  289. PRAGMA integrity_check=xyz
  290. }
  291. } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  292. do_test pragma-3.7 {
  293. execsql {
  294. PRAGMA integrity_check=0
  295. }
  296. } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  297. # Add additional corruption by appending unused pages to the end of
  298. # the database file testerr.db
  299. #
  300. do_test pragma-3.8 {
  301. execsql {DETACH t2}
  302. file delete -force testerr.db testerr.db-journal
  303. set out [open testerr.db w]
  304. fconfigure $out -translation binary
  305. set in [open test.db r]
  306. fconfigure $in -translation binary
  307. puts -nonewline $out [read $in]
  308. seek $in 0
  309. puts -nonewline $out [read $in]
  310. close $in
  311. close $out
  312. hexio_write testerr.db 28 00000000
  313. execsql {REINDEX t2}
  314. execsql {PRAGMA integrity_check}
  315. } {ok}
  316. do_test pragma-3.8.1 {
  317. execsql {PRAGMA quick_check}
  318. } {ok}
  319. do_test pragma-3.9 {
  320. execsql {
  321. ATTACH 'testerr.db' AS t2;
  322. PRAGMA integrity_check
  323. }
  324. } {{*** in database t2 ***
  325. Page 4 is never used
  326. Page 5 is never used
  327. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  328. do_test pragma-3.10 {
  329. execsql {
  330. PRAGMA integrity_check=1
  331. }
  332. } {{*** in database t2 ***
  333. Page 4 is never used}}
  334. do_test pragma-3.11 {
  335. execsql {
  336. PRAGMA integrity_check=5
  337. }
  338. } {{*** in database t2 ***
  339. Page 4 is never used
  340. Page 5 is never used
  341. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2}}
  342. do_test pragma-3.12 {
  343. execsql {
  344. PRAGMA integrity_check=4
  345. }
  346. } {{*** in database t2 ***
  347. Page 4 is never used
  348. Page 5 is never used
  349. Page 6 is never used} {rowid 1 missing from index i2}}
  350. do_test pragma-3.13 {
  351. execsql {
  352. PRAGMA integrity_check=3
  353. }
  354. } {{*** in database t2 ***
  355. Page 4 is never used
  356. Page 5 is never used
  357. Page 6 is never used}}
  358. do_test pragma-3.14 {
  359. execsql {
  360. PRAGMA integrity_check(2)
  361. }
  362. } {{*** in database t2 ***
  363. Page 4 is never used
  364. Page 5 is never used}}
  365. do_test pragma-3.15 {
  366. execsql {
  367. ATTACH 'testerr.db' AS t3;
  368. PRAGMA integrity_check
  369. }
  370. } {{*** in database t2 ***
  371. Page 4 is never used
  372. Page 5 is never used
  373. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
  374. Page 4 is never used
  375. Page 5 is never used
  376. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}}
  377. do_test pragma-3.16 {
  378. execsql {
  379. PRAGMA integrity_check(10)
  380. }
  381. } {{*** in database t2 ***
  382. Page 4 is never used
  383. Page 5 is never used
  384. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
  385. Page 4 is never used
  386. Page 5 is never used
  387. Page 6 is never used} {rowid 1 missing from index i2}}
  388. do_test pragma-3.17 {
  389. execsql {
  390. PRAGMA integrity_check=8
  391. }
  392. } {{*** in database t2 ***
  393. Page 4 is never used
  394. Page 5 is never used
  395. Page 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***
  396. Page 4 is never used
  397. Page 5 is never used}}
  398. do_test pragma-3.18 {
  399. execsql {
  400. PRAGMA integrity_check=4
  401. }
  402. } {{*** in database t2 ***
  403. Page 4 is never used
  404. Page 5 is never used
  405. Page 6 is never used} {rowid 1 missing from index i2}}
  406. }
  407. do_test pragma-3.19 {
  408. catch {db close}
  409. file delete -force test.db test.db-journal
  410. sqlite3 db test.db
  411. db eval {PRAGMA integrity_check}
  412. } {ok}
  413. }
  414. #exit
  415. # Test modifying the cache_size of an attached database.
  416. ifcapable pager_pragmas&&attach {
  417. do_test pragma-4.1 {
  418. execsql {
  419. ATTACH 'test2.db' AS aux;
  420. pragma aux.cache_size;
  421. pragma aux.default_cache_size;
  422. }
  423. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
  424. do_test pragma-4.2 {
  425. execsql {
  426. pragma aux.cache_size = 50;
  427. pragma aux.cache_size;
  428. pragma aux.default_cache_size;
  429. }
  430. } [list 50 $DFLT_CACHE_SZ]
  431. do_test pragma-4.3 {
  432. execsql {
  433. pragma aux.default_cache_size = 456;
  434. pragma aux.cache_size;
  435. pragma aux.default_cache_size;
  436. }
  437. } {456 456}
  438. do_test pragma-4.4 {
  439. execsql {
  440. pragma cache_size;
  441. pragma default_cache_size;
  442. }
  443. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
  444. do_test pragma-4.5 {
  445. execsql {
  446. DETACH aux;
  447. ATTACH 'test3.db' AS aux;
  448. pragma aux.cache_size;
  449. pragma aux.default_cache_size;
  450. }
  451. } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
  452. do_test pragma-4.6 {
  453. execsql {
  454. DETACH aux;
  455. ATTACH 'test2.db' AS aux;
  456. pragma aux.cache_size;
  457. pragma aux.default_cache_size;
  458. }
  459. } {456 456}
  460. } ;# ifcapable pager_pragmas
  461. # Test that modifying the sync-level in the middle of a transaction is
  462. # disallowed.
  463. ifcapable pager_pragmas {
  464. do_test pragma-5.0 {
  465. execsql {
  466. pragma synchronous;
  467. }
  468. } {2}
  469. do_test pragma-5.1 {
  470. catchsql {
  471. BEGIN;
  472. pragma synchronous = OFF;
  473. }
  474. } {1 {Safety level may not be changed inside a transaction}}
  475. do_test pragma-5.2 {
  476. execsql {
  477. pragma synchronous;
  478. }
  479. } {2}
  480. catchsql {COMMIT;}
  481. } ;# ifcapable pager_pragmas
  482. # Test schema-query pragmas
  483. #
  484. ifcapable schema_pragmas {
  485. ifcapable tempdb&&attach {
  486. do_test pragma-6.1 {
  487. set res {}
  488. execsql {SELECT * FROM sqlite_temp_master}
  489. foreach {idx name file} [execsql {pragma database_list}] {
  490. lappend res $idx $name
  491. }
  492. set res
  493. } {0 main 1 temp 2 aux}
  494. }
  495. do_test pragma-6.2 {
  496. execsql {
  497. CREATE TABLE t2(a,b,c);
  498. pragma table_info(t2)
  499. }
  500. } {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0}
  501. do_test pragma-6.2.1 {
  502. execsql {
  503. pragma table_info;
  504. }
  505. } {}
  506. db nullvalue <<NULL>>
  507. do_test pragma-6.2.2 {
  508. execsql {
  509. CREATE TABLE t5(
  510. a TEXT DEFAULT CURRENT_TIMESTAMP,
  511. b DEFAULT (5+3),
  512. c TEXT,
  513. d INTEGER DEFAULT NULL,
  514. e TEXT DEFAULT ''
  515. );
  516. PRAGMA table_info(t5);
  517. }
  518. } {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0}
  519. db nullvalue {}
  520. ifcapable {foreignkey} {
  521. do_test pragma-6.3.1 {
  522. execsql {
  523. CREATE TABLE t3(a int references t2(b), b UNIQUE);
  524. pragma foreign_key_list(t3);
  525. }
  526. } {0 0 t2 a b {NO ACTION} {NO ACTION} NONE}
  527. do_test pragma-6.3.2 {
  528. execsql {
  529. pragma foreign_key_list;
  530. }
  531. } {}
  532. do_test pragma-6.3.3 {
  533. execsql {
  534. pragma foreign_key_list(t3_bogus);
  535. }
  536. } {}
  537. do_test pragma-6.3.4 {
  538. execsql {
  539. pragma foreign_key_list(t5);
  540. }
  541. } {}
  542. do_test pragma-6.4 {
  543. execsql {
  544. pragma index_list(t3);
  545. }
  546. } {0 sqlite_autoindex_t3_1 1}
  547. }
  548. ifcapable {!foreignkey} {
  549. execsql {CREATE TABLE t3(a,b UNIQUE)}
  550. }
  551. do_test pragma-6.5.1 {
  552. execsql {
  553. CREATE INDEX t3i1 ON t3(a,b);
  554. pragma index_info(t3i1);
  555. }
  556. } {0 0 a 1 1 b}
  557. do_test pragma-6.5.2 {
  558. execsql {
  559. pragma index_info(t3i1_bogus);
  560. }
  561. } {}
  562. ifcapable tempdb {
  563. # Test for ticket #3320. When a temp table of the same name exists, make
  564. # sure the schema of the main table can still be queried using
  565. # "pragma table_info":
  566. do_test pragma-6.6.1 {
  567. execsql {
  568. CREATE TABLE trial(col_main);
  569. CREATE TEMP TABLE trial(col_temp);
  570. }
  571. } {}
  572. do_test pragma-6.6.2 {
  573. execsql {
  574. PRAGMA table_info(trial);
  575. }
  576. } {0 col_temp {} 0 {} 0}
  577. do_test pragma-6.6.3 {
  578. execsql {
  579. PRAGMA temp.table_info(trial);
  580. }
  581. } {0 col_temp {} 0 {} 0}
  582. do_test pragma-6.6.4 {
  583. execsql {
  584. PRAGMA main.table_info(trial);
  585. }
  586. } {0 col_main {} 0 {} 0}
  587. }
  588. do_test pragma-6.7 {
  589. execsql {
  590. CREATE TABLE test_table(
  591. one INT NOT NULL DEFAULT -1,
  592. two text,
  593. three VARCHAR(45, 65) DEFAULT 'abcde',
  594. four REAL DEFAULT X'abcdef',
  595. five DEFAULT CURRENT_TIME
  596. );
  597. PRAGMA table_info(test_table);
  598. }
  599. } [concat \
  600. {0 one INT 1 -1 0} \
  601. {1 two text 0 {} 0} \
  602. {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
  603. {3 four REAL 0 X'abcdef' 0} \
  604. {4 five {} 0 CURRENT_TIME 0} \
  605. ]
  606. } ;# ifcapable schema_pragmas
  607. # Miscellaneous tests
  608. #
  609. ifcapable schema_pragmas {
  610. do_test pragma-7.1.1 {
  611. # Make sure a pragma knows to read the schema if it needs to
  612. db close
  613. sqlite3 db test.db
  614. execsql {
  615. pragma index_list(t3);
  616. }
  617. } {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
  618. do_test pragma-7.1.2 {
  619. execsql {
  620. pragma index_list(t3_bogus);
  621. }
  622. } {}
  623. } ;# ifcapable schema_pragmas
  624. ifcapable {utf16} {
  625. if {[permutation] == ""} {
  626. do_test pragma-7.2 {
  627. db close
  628. sqlite3 db test.db
  629. catchsql {
  630. pragma encoding=bogus;
  631. }
  632. } {1 {unsupported encoding: bogus}}
  633. }
  634. }
  635. ifcapable tempdb {
  636. do_test pragma-7.3 {
  637. db close
  638. sqlite3 db test.db
  639. execsql {
  640. pragma lock_status;
  641. }
  642. } {main unlocked temp closed}
  643. } else {
  644. do_test pragma-7.3 {
  645. db close
  646. sqlite3 db test.db
  647. execsql {
  648. pragma lock_status;
  649. }
  650. } {main unlocked}
  651. }
  652. #----------------------------------------------------------------------
  653. # Test cases pragma-8.* test the "PRAGMA schema_version" and "PRAGMA
  654. # user_version" statements.
  655. #
  656. # pragma-8.1: PRAGMA schema_version
  657. # pragma-8.2: PRAGMA user_version
  658. #
  659. ifcapable schema_version {
  660. # First check that we can set the schema version and then retrieve the
  661. # same value.
  662. do_test pragma-8.1.1 {
  663. execsql {
  664. PRAGMA schema_version = 105;
  665. }
  666. } {}
  667. do_test pragma-8.1.2 {
  668. execsql2 {
  669. PRAGMA schema_version;
  670. }
  671. } {schema_version 105}
  672. do_test pragma-8.1.3 {
  673. execsql {
  674. PRAGMA schema_version = 106;
  675. }
  676. } {}
  677. do_test pragma-8.1.4 {
  678. execsql {
  679. PRAGMA schema_version;
  680. }
  681. } 106
  682. # Check that creating a table modifies the schema-version (this is really
  683. # to verify that the value being read is in fact the schema version).
  684. do_test pragma-8.1.5 {
  685. execsql {
  686. CREATE TABLE t4(a, b, c);
  687. INSERT INTO t4 VALUES(1, 2, 3);
  688. SELECT * FROM t4;
  689. }
  690. } {1 2 3}
  691. do_test pragma-8.1.6 {
  692. execsql {
  693. PRAGMA schema_version;
  694. }
  695. } 107
  696. # Now open a second connection to the database. Ensure that changing the
  697. # schema-version using the first connection forces the second connection
  698. # to reload the schema. This has to be done using the C-API test functions,
  699. # because the TCL API accounts for SCHEMA_ERROR and retries the query.
  700. do_test pragma-8.1.7 {
  701. sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]
  702. execsql {
  703. SELECT * FROM t4;
  704. } db2
  705. } {1 2 3}
  706. do_test pragma-8.1.8 {
  707. execsql {
  708. PRAGMA schema_version = 108;
  709. }
  710. } {}
  711. do_test pragma-8.1.9 {
  712. set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM t4" -1 DUMMY]
  713. sqlite3_step $::STMT
  714. } SQLITE_ERROR
  715. do_test pragma-8.1.10 {
  716. sqlite3_finalize $::STMT
  717. } SQLITE_SCHEMA
  718. # Make sure the schema-version can be manipulated in an attached database.
  719. file delete -force test2.db
  720. file delete -force test2.db-journal
  721. ifcapable attach {
  722. do_test pragma-8.1.11 {
  723. execsql {
  724. ATTACH 'test2.db' AS aux;
  725. CREATE TABLE aux.t1(a, b, c);
  726. PRAGMA aux.schema_version = 205;
  727. }
  728. } {}
  729. do_test pragma-8.1.12 {
  730. execsql {
  731. PRAGMA aux.schema_version;
  732. }
  733. } 205
  734. }
  735. do_test pragma-8.1.13 {
  736. execsql {
  737. PRAGMA schema_version;
  738. }
  739. } 108
  740. # And check that modifying the schema-version in an attached database
  741. # forces the second connection to reload the schema.
  742. ifcapable attach {
  743. do_test pragma-8.1.14 {
  744. sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]
  745. execsql {
  746. ATTACH 'test2.db' AS aux;
  747. SELECT * FROM aux.t1;
  748. } db2
  749. } {}
  750. do_test pragma-8.1.15 {
  751. execsql {
  752. PRAGMA aux.schema_version = 206;
  753. }
  754. } {}
  755. do_test pragma-8.1.16 {
  756. set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM aux.t1" -1 DUMMY]
  757. sqlite3_step $::STMT
  758. } SQLITE_ERROR
  759. do_test pragma-8.1.17 {
  760. sqlite3_finalize $::STMT
  761. } SQLITE_SCHEMA
  762. do_test pragma-8.1.18 {
  763. db2 close
  764. } {}
  765. }
  766. # Now test that the user-version can be read and written (and that we aren't
  767. # accidentally manipulating the schema-version instead).
  768. do_test pragma-8.2.1 {
  769. execsql2 {
  770. PRAGMA user_version;
  771. }
  772. } {user_version 0}
  773. do_test pragma-8.2.2 {
  774. execsql {
  775. PRAGMA user_version = 2;
  776. }
  777. } {}
  778. do_test pragma-8.2.3.1 {
  779. execsql2 {
  780. PRAGMA user_version;
  781. }
  782. } {user_version 2}
  783. do_test pragma-8.2.3.2 {
  784. db close
  785. sqlite3 db test.db
  786. execsql {
  787. PRAGMA user_version;
  788. }
  789. } {2}
  790. do_test pragma-8.2.4.1 {
  791. execsql {
  792. PRAGMA schema_version;
  793. }
  794. } {108}
  795. ifcapable vacuum {
  796. do_test pragma-8.2.4.2 {
  797. execsql {
  798. VACUUM;
  799. PRAGMA user_version;
  800. }
  801. } {2}
  802. do_test pragma-8.2.4.3 {
  803. execsql {
  804. PRAGMA schema_version;
  805. }
  806. } {109}
  807. }
  808. ifcapable attach {
  809. db eval {ATTACH 'test2.db' AS aux}
  810. # Check that the user-version in the auxilary database can be manipulated (
  811. # and that we aren't accidentally manipulating the same in the main db).
  812. do_test pragma-8.2.5 {
  813. execsql {
  814. PRAGMA aux.user_version;
  815. }
  816. } {0}
  817. do_test pragma-8.2.6 {
  818. execsql {
  819. PRAGMA aux.user_version = 3;
  820. }
  821. } {}
  822. do_test pragma-8.2.7 {
  823. execsql {
  824. PRAGMA aux.user_version;
  825. }
  826. } {3}
  827. do_test pragma-8.2.8 {
  828. execsql {
  829. PRAGMA main.user_version;
  830. }
  831. } {2}
  832. # Now check that a ROLLBACK resets the user-version if it has been modified
  833. # within a transaction.
  834. do_test pragma-8.2.9 {
  835. execsql {
  836. BEGIN;
  837. PRAGMA aux.user_version = 10;
  838. PRAGMA user_version = 11;
  839. }
  840. } {}
  841. do_test pragma-8.2.10 {
  842. execsql {
  843. PRAGMA aux.user_version;
  844. }
  845. } {10}
  846. do_test pragma-8.2.11 {
  847. execsql {
  848. PRAGMA main.user_version;
  849. }
  850. } {11}
  851. do_test pragma-8.2.12 {
  852. execsql {
  853. ROLLBACK;
  854. PRAGMA aux.user_version;
  855. }
  856. } {3}
  857. do_test pragma-8.2.13 {
  858. execsql {
  859. PRAGMA main.user_version;
  860. }
  861. } {2}
  862. }
  863. # Try a negative value for the user-version
  864. do_test pragma-8.2.14 {
  865. execsql {
  866. PRAGMA user_version = -450;
  867. }
  868. } {}
  869. do_test pragma-8.2.15 {
  870. execsql {
  871. PRAGMA user_version;
  872. }
  873. } {-450}
  874. } ; # ifcapable schema_version
  875. # Check to see if TEMP_STORE is memory or disk. Return strings
  876. # "memory" or "disk" as appropriate.
  877. #
  878. proc check_temp_store {} {
  879. db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)}
  880. db eval {PRAGMA database_list} {
  881. if {$name=="temp"} {
  882. set bt [btree_from_db db 1]
  883. if {[btree_ismemdb $bt]} {
  884. return "memory"
  885. }
  886. return "disk"
  887. }
  888. }
  889. return "unknown"
  890. }
  891. # Test temp_store and temp_store_directory pragmas
  892. #
  893. ifcapable pager_pragmas {
  894. do_test pragma-9.1 {
  895. db close
  896. sqlite3 db test.db
  897. execsql {
  898. PRAGMA temp_store;
  899. }
  900. } {0}
  901. if {$TEMP_STORE<=1} {
  902. do_test pragma-9.1.1 {
  903. check_temp_store
  904. } {disk}
  905. } else {
  906. do_test pragma-9.1.1 {
  907. check_temp_store
  908. } {memory}
  909. }
  910. do_test pragma-9.2 {
  911. db close
  912. sqlite3 db test.db
  913. execsql {
  914. PRAGMA temp_store=file;
  915. PRAGMA temp_store;
  916. }
  917. } {1}
  918. if {$TEMP_STORE==3} {
  919. # When TEMP_STORE is 3, always use memory regardless of pragma settings.
  920. do_test pragma-9.2.1 {
  921. check_temp_store
  922. } {memory}
  923. } else {
  924. do_test pragma-9.2.1 {
  925. check_temp_store
  926. } {disk}
  927. }
  928. do_test pragma-9.3 {
  929. db close
  930. sqlite3 db test.db
  931. execsql {
  932. PRAGMA temp_store=memory;
  933. PRAGMA temp_store;
  934. }
  935. } {2}
  936. if {$TEMP_STORE==0} {
  937. # When TEMP_STORE is 0, always use the disk regardless of pragma settings.
  938. do_test pragma-9.3.1 {
  939. check_temp_store
  940. } {disk}
  941. } else {
  942. do_test pragma-9.3.1 {
  943. check_temp_store
  944. } {memory}
  945. }
  946. do_test pragma-9.4 {
  947. execsql {
  948. PRAGMA temp_store_directory;
  949. }
  950. } {}
  951. ifcapable wsd {
  952. do_test pragma-9.5 {
  953. set pwd [string map {' ''} [file nativename [pwd]]]
  954. execsql "
  955. PRAGMA temp_store_directory='$pwd';
  956. "
  957. } {}
  958. do_test pragma-9.6 {
  959. execsql {
  960. PRAGMA temp_store_directory;
  961. }
  962. } [list [file nativename [pwd]]]
  963. do_test pragma-9.7 {
  964. catchsql {
  965. PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';
  966. }
  967. } {1 {not a writable directory}}
  968. do_test pragma-9.8 {
  969. execsql {
  970. PRAGMA temp_store_directory='';
  971. }
  972. } {}
  973. if {![info exists TEMP_STORE] || $TEMP_STORE<=1} {
  974. ifcapable tempdb {
  975. do_test pragma-9.9 {
  976. execsql {
  977. PRAGMA temp_store_directory;
  978. PRAGMA temp_store=FILE;
  979. CREATE TEMP TABLE temp_store_directory_test(a integer);
  980. INSERT INTO temp_store_directory_test values (2);
  981. SELECT * FROM temp_store_directory_test;
  982. }
  983. } {2}
  984. do_test pragma-9.10 {
  985. catchsql "
  986. PRAGMA temp_store_directory='$pwd';
  987. SELECT * FROM temp_store_directory_test;
  988. "
  989. } {1 {no such table: temp_store_directory_test}}
  990. }
  991. }
  992. }
  993. do_test pragma-9.11 {
  994. execsql {
  995. PRAGMA temp_store = 0;
  996. PRAGMA temp_store;
  997. }
  998. } {0}
  999. do_test pragma-9.12 {
  1000. execsql {
  1001. PRAGMA temp_store = 1;
  1002. PRAGMA temp_store;
  1003. }
  1004. } {1}
  1005. do_test pragma-9.13 {
  1006. execsql {
  1007. PRAGMA temp_store = 2;
  1008. PRAGMA temp_store;
  1009. }
  1010. } {2}
  1011. do_test pragma-9.14 {
  1012. execsql {
  1013. PRAGMA temp_store = 3;
  1014. PRAGMA temp_store;
  1015. }
  1016. } {0}
  1017. do_test pragma-9.15 {
  1018. catchsql {
  1019. BEGIN EXCLUSIVE;
  1020. CREATE TEMP TABLE temp_table(t);
  1021. INSERT INTO temp_table VALUES('valuable data');
  1022. PRAGMA temp_store = 1;
  1023. }
  1024. } {1 {temporary storage cannot be changed from within a transaction}}
  1025. do_test pragma-9.16 {
  1026. execsql {
  1027. SELECT * FROM temp_table;
  1028. COMMIT;
  1029. }
  1030. } {{valuable data}}
  1031. do_test pragma-9.17 {
  1032. execsql {
  1033. INSERT INTO temp_table VALUES('valuable data II');
  1034. SELECT * FROM temp_table;
  1035. }
  1036. } {{valuable data} {valuable data II}}
  1037. do_test pragma-9.18 {
  1038. set rc [catch {
  1039. db eval {SELECT t FROM temp_table} {
  1040. execsql {pragma temp_store = 1}
  1041. }
  1042. } msg]
  1043. list $rc $msg
  1044. } {1 {temporary storage cannot be changed from within a transaction}}
  1045. } ;# ifcapable pager_pragmas
  1046. ifcapable trigger {
  1047. do_test pragma-10.0 {
  1048. catchsql {
  1049. DROP TABLE main.t1;
  1050. }
  1051. execsql {
  1052. PRAGMA count_changes = 1;
  1053. CREATE TABLE t1(a PRIMARY KEY);
  1054. CREATE TABLE t1_mirror(a);
  1055. CREATE TABLE t1_mirror2(a);
  1056. CREATE TRIGGER t1_bi BEFORE INSERT ON t1 BEGIN
  1057. INSERT INTO t1_mirror VALUES(new.a);
  1058. END;
  1059. CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN
  1060. INSERT INTO t1_mirror2 VALUES(new.a);
  1061. END;
  1062. CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN
  1063. UPDATE t1_mirror SET a = new.a WHERE a = old.a;
  1064. END;
  1065. CREATE TRIGGER t1_au AFTER UPDATE ON t1 BEGIN
  1066. UPDATE t1_mirror2 SET a = new.a WHERE a = old.a;
  1067. END;
  1068. CREATE TRIGGER t1_bd BEFORE DELETE ON t1 BEGIN
  1069. DELETE FROM t1_mirror WHERE a = old.a;
  1070. END;
  1071. CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN
  1072. DELETE FROM t1_mirror2 WHERE a = old.a;
  1073. END;
  1074. }
  1075. } {}
  1076. do_test pragma-10.1 {
  1077. execsql {
  1078. INSERT INTO t1 VALUES(randstr(10,10));
  1079. }
  1080. } {1}
  1081. do_test pragma-10.2 {
  1082. execsql {
  1083. UPDATE t1 SET a = randstr(10,10);
  1084. }
  1085. } {1}
  1086. do_test pragma-10.3 {
  1087. execsql {
  1088. DELETE FROM t1;
  1089. }
  1090. } {1}
  1091. } ;# ifcapable trigger
  1092. ifcapable schema_pragmas {
  1093. do_test pragma-11.1 {
  1094. execsql2 {
  1095. pragma collation_list;
  1096. }
  1097. } {seq 0 name NOCASE seq 1 name RTRIM seq 2 name BINARY}
  1098. do_test pragma-11.2 {
  1099. db collate New_Collation blah...
  1100. execsql {
  1101. pragma collation_list;
  1102. }
  1103. } {0 New_Collation 1 NOCASE 2 RTRIM 3 BINARY}
  1104. }
  1105. ifcapable schema_pragmas&&tempdb {
  1106. do_test pragma-12.1 {
  1107. sqlite3 db2 test.db
  1108. execsql {
  1109. PRAGMA temp.table_info('abc');
  1110. } db2
  1111. } {}
  1112. db2 close
  1113. do_test pragma-12.2 {
  1114. sqlite3 db2 test.db
  1115. execsql {
  1116. PRAGMA temp.default_cache_size = 200;
  1117. PRAGMA temp.default_cache_size;
  1118. } db2
  1119. } {200}
  1120. db2 close
  1121. do_test pragma-12.3 {
  1122. sqlite3 db2 test.db
  1123. execsql {
  1124. PRAGMA temp.cache_size = 400;
  1125. PRAGMA temp.cache_size;
  1126. } db2
  1127. } {400}
  1128. db2 close
  1129. }
  1130. ifcapable bloblit {
  1131. do_test pragma-13.1 {
  1132. execsql {
  1133. DROP TABLE IF EXISTS t4;
  1134. PRAGMA vdbe_trace=on;
  1135. PRAGMA vdbe_listing=on;
  1136. PRAGMA sql_trace=on;
  1137. CREATE TABLE t4(a INTEGER PRIMARY KEY,b);
  1138. INSERT INTO t4(b) VALUES(x'0123456789abcdef0123456789abcdef0123456789');
  1139. INSERT INTO t4(b) VALUES(randstr(30,30));
  1140. INSERT INTO t4(b) VALUES(1.23456);
  1141. INSERT INTO t4(b) VALUES(NULL);
  1142. INSERT INTO t4(b) VALUES(0);
  1143. INSERT INTO t4(b) SELECT b||b||b||b FROM t4;
  1144. SELECT * FROM t4;
  1145. }
  1146. execsql {
  1147. PRAGMA vdbe_trace=off;
  1148. PRAGMA vdbe_listing=off;
  1149. PRAGMA sql_trace=off;
  1150. }
  1151. } {}
  1152. } ;# ifcapable bloblit
  1153. ifcapable pager_pragmas {
  1154. db close
  1155. file delete -force test.db
  1156. sqlite3 db test.db
  1157. do_test pragma-14.1 {
  1158. execsql { pragma auto_vacuum = 0 }
  1159. execsql { pragma page_count }
  1160. } {0}
  1161. do_test pragma-14.2 {
  1162. execsql {
  1163. CREATE TABLE abc(a, b, c);
  1164. PRAGMA page_count;
  1165. }
  1166. } {2}
  1167. do_test pragma-14.3 {
  1168. execsql {
  1169. BEGIN;
  1170. CREATE TABLE def(a, b, c);
  1171. PRAGMA page_count;
  1172. }
  1173. } {3}
  1174. do_test pragma-14.4 {
  1175. set page_size [db one {pragma page_size}]
  1176. expr [file size test.db] / $page_size
  1177. } {2}
  1178. do_test pragma-14.5 {
  1179. execsql {
  1180. ROLLBACK;
  1181. PRAGMA page_count;
  1182. }
  1183. } {2}
  1184. do_test pragma-14.6 {
  1185. file delete -force test2.db
  1186. sqlite3 db2 test2.db
  1187. execsql {
  1188. PRAGMA auto_vacuum = 0;
  1189. CREATE TABLE t1(a, b, c);
  1190. CREATE TABLE t2(a, b, c);
  1191. CREATE TABLE t3(a, b, c);
  1192. CREATE TABLE t4(a, b, c);
  1193. } db2
  1194. db2 close
  1195. execsql {
  1196. ATTACH 'test2.db' AS aux;
  1197. PRAGMA aux.page_count;
  1198. }
  1199. } {5}
  1200. }
  1201. # Test that the value set using the cache_size pragma is not reset when the
  1202. # schema is reloaded.
  1203. #
  1204. ifcapable pager_pragmas {
  1205. db close
  1206. sqlite3 db test.db
  1207. do_test pragma-15.1 {
  1208. execsql {
  1209. PRAGMA cache_size=59;
  1210. PRAGMA cache_size;
  1211. }
  1212. } {59}
  1213. do_test pragma-15.2 {
  1214. sqlite3 db2 test.db
  1215. execsql {
  1216. CREATE TABLE newtable(a, b, c);
  1217. } db2
  1218. db2 close
  1219. } {}
  1220. do_test pragma-15.3 {
  1221. # Evaluating this statement will cause the schema to be reloaded (because
  1222. # the schema was changed by another connection in pragma-15.2). At one
  1223. # point there was a bug that reset the cache_size to its default value
  1224. # when this happened.
  1225. execsql { SELECT * FROM sqlite_master }
  1226. execsql { PRAGMA cache_size }
  1227. } {59}
  1228. }
  1229. # Reset the sqlite3_temp_directory variable for the next run of tests:
  1230. sqlite3 dbX :memory:
  1231. dbX eval {PRAGMA temp_store_directory = ""}
  1232. dbX close
  1233. ifcapable lock_proxy_pragmas&&prefer_proxy_locking {
  1234. set sqlite_hostid_num 1
  1235. set using_proxy 0
  1236. foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {
  1237. set using_proxy $value
  1238. }
  1239. # Test the lock_proxy_file pragmas.
  1240. #
  1241. db close
  1242. set env(SQLITE_FORCE_PROXY_LOCKING) "0"
  1243. sqlite3 db test.db
  1244. do_test pragma-16.1 {
  1245. execsql {
  1246. PRAGMA lock_proxy_file="mylittleproxy";
  1247. select * from sqlite_master;
  1248. }
  1249. execsql {
  1250. PRAGMA lock_proxy_file;
  1251. }
  1252. } {mylittleproxy}
  1253. do_test pragma-16.2 {
  1254. sqlite3 db2 test.db
  1255. execsql {
  1256. PRAGMA lock_proxy_file="mylittleproxy";
  1257. } db2
  1258. } {}
  1259. db2 close
  1260. do_test pragma-16.2.1 {
  1261. sqlite3 db2 test.db
  1262. execsql {
  1263. PRAGMA lock_proxy_file=":auto:";
  1264. select * from sqlite_master;
  1265. } db2
  1266. execsql {
  1267. PRAGMA lock_proxy_file;
  1268. } db2
  1269. } {mylittleproxy}
  1270. db2 close
  1271. do_test pragma-16.3 {
  1272. sqlite3 db2 test.db
  1273. execsql {
  1274. PRAGMA lock_proxy_file="myotherproxy";
  1275. } db2
  1276. catchsql {
  1277. select * from sqlite_master;
  1278. } db2
  1279. } {1 {database is locked}}
  1280. do_test pragma-16.4 {
  1281. db2 close
  1282. db close
  1283. sqlite3 db2 test.db
  1284. execsql {
  1285. PRAGMA lock_proxy_file="myoriginalproxy";
  1286. PRAGMA lock_proxy_file="myotherproxy";
  1287. PRAGMA lock_proxy_file;
  1288. } db2
  1289. } {myotherproxy}
  1290. db2 close
  1291. set env(SQLITE_FORCE_PROXY_LOCKING) "1"
  1292. do_test pragma-16.5 {
  1293. sqlite3 db2 test.db
  1294. execsql {
  1295. PRAGMA lock_proxy_file=":auto:";
  1296. PRAGMA lock_proxy_file;
  1297. } db2
  1298. } {myotherproxy}
  1299. do_test pragma-16.6 {
  1300. db2 close
  1301. sqlite3 db2 test2.db
  1302. set lockpath [execsql {
  1303. PRAGMA lock_proxy_file=":auto:";
  1304. PRAGMA lock_proxy_file;
  1305. } db2]
  1306. string match "*test2.db:auto:" $lockpath
  1307. } {1}
  1308. set sqlite_hostid_num 2
  1309. do_test pragma-16.7 {
  1310. list [catch {
  1311. sqlite3 db test2.db
  1312. execsql {
  1313. PRAGMA lock_proxy_file=":auto:";
  1314. select * from sqlite_master;
  1315. }
  1316. } msg] $msg
  1317. } {1 {database is locked}}
  1318. db close
  1319. do_test pragma-16.8 {
  1320. list [catch {
  1321. sqlite3 db test2.db
  1322. execsql { select * from sqlite_master }
  1323. } msg] $msg
  1324. } {1 {database is locked}}
  1325. db2 close
  1326. do_test pragma-16.8.1 {
  1327. execsql {
  1328. PRAGMA lock_proxy_file="yetanotherproxy";
  1329. PRAGMA lock_proxy_file;
  1330. }
  1331. } {yetanotherproxy}
  1332. do_test pragma-16.8.2 {
  1333. execsql {
  1334. create table mine(x);
  1335. }
  1336. } {}
  1337. db close
  1338. do_test pragma-16.9 {
  1339. sqlite3 db proxytest.db
  1340. set lockpath2 [execsql {
  1341. PRAGMA lock_proxy_file=":auto:";
  1342. PRAGMA lock_proxy_file;
  1343. } db]
  1344. string match "*proxytest.db:auto:" $lockpath2
  1345. } {1}
  1346. set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy
  1347. set sqlite_hostid_num 0
  1348. }
  1349. # Parsing of auto_vacuum settings.
  1350. #
  1351. foreach {autovac_setting val} {
  1352. 0 0
  1353. 1 1
  1354. 2 2
  1355. 3 0
  1356. -1 0
  1357. none 0
  1358. NONE 0
  1359. NoNe 0
  1360. full 1
  1361. FULL 1
  1362. incremental 2
  1363. INCREMENTAL 2
  1364. -1234 0
  1365. 1234 0
  1366. } {
  1367. do_test pragma-17.1.$autovac_setting {
  1368. catch {db close}
  1369. sqlite3 db :memory:
  1370. execsql "
  1371. PRAGMA auto_vacuum=$::autovac_setting;
  1372. PRAGMA auto_vacuum;
  1373. "
  1374. } $val
  1375. }
  1376. # Parsing of temp_store settings.
  1377. #
  1378. foreach {temp_setting val} {
  1379. 0 0
  1380. 1 1
  1381. 2 2
  1382. 3 0
  1383. -1 0
  1384. file 1
  1385. FILE 1
  1386. fIlE 1
  1387. memory 2
  1388. MEMORY 2
  1389. MeMoRy 2
  1390. } {
  1391. do_test pragma-18.1.$temp_setting {
  1392. catch {db close}
  1393. sqlite3 db :memory:
  1394. execsql "
  1395. PRAGMA temp_store=$::temp_setting;
  1396. PRAGMA temp_store=$::temp_setting;
  1397. PRAGMA temp_store;
  1398. "
  1399. } $val
  1400. }
  1401. finish_test