OLD | NEW |
1 # 2002 March 6 | 1 # 2002 March 6 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
12 # | 12 # |
13 # This file implements tests for the PRAGMA command. | 13 # This file implements tests for the PRAGMA command. |
14 # | 14 # |
15 # $Id: pragma.test,v 1.73 2009/01/12 14:01:45 danielk1977 Exp $ | 15 # $Id: pragma.test,v 1.73 2009/01/12 14:01:45 danielk1977 Exp $ |
16 | 16 |
17 set testdir [file dirname $argv0] | 17 set testdir [file dirname $argv0] |
18 source $testdir/tester.tcl | 18 source $testdir/tester.tcl |
19 | 19 |
| 20 # Do not use a codec for tests in this file, as the database file is |
| 21 # manipulated directly using tcl scripts (using the [hexio_write] command). |
| 22 # |
| 23 do_not_use_codec |
| 24 |
20 # Test organization: | 25 # Test organization: |
21 # | 26 # |
22 # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db. | 27 # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db. |
23 # pragma-2.*: Test synchronous on attached db. | 28 # pragma-2.*: Test synchronous on attached db. |
24 # pragma-3.*: Test detection of table/index inconsistency by integrity_check. | 29 # pragma-3.*: Test detection of table/index inconsistency by integrity_check. |
25 # pragma-4.*: Test cache_size and default_cache_size on attached db. | 30 # pragma-4.*: Test cache_size and default_cache_size on attached db. |
26 # pragma-5.*: Test that pragma synchronous may not be used inside of a | 31 # pragma-5.*: Test that pragma synchronous may not be used inside of a |
27 # transaction. | 32 # transaction. |
28 # pragma-6.*: Test schema-query pragmas. | 33 # pragma-6.*: Test schema-query pragmas. |
29 # pragma-7.*: Miscellaneous tests. | 34 # pragma-7.*: Miscellaneous tests. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 file delete -force testerr.db testerr.db-journal | 315 file delete -force testerr.db testerr.db-journal |
311 set out [open testerr.db w] | 316 set out [open testerr.db w] |
312 fconfigure $out -translation binary | 317 fconfigure $out -translation binary |
313 set in [open test.db r] | 318 set in [open test.db r] |
314 fconfigure $in -translation binary | 319 fconfigure $in -translation binary |
315 puts -nonewline $out [read $in] | 320 puts -nonewline $out [read $in] |
316 seek $in 0 | 321 seek $in 0 |
317 puts -nonewline $out [read $in] | 322 puts -nonewline $out [read $in] |
318 close $in | 323 close $in |
319 close $out | 324 close $out |
| 325 hexio_write testerr.db 28 00000000 |
320 execsql {REINDEX t2} | 326 execsql {REINDEX t2} |
321 execsql {PRAGMA integrity_check} | 327 execsql {PRAGMA integrity_check} |
322 } {ok} | 328 } {ok} |
323 do_test pragma-3.8.1 { | 329 do_test pragma-3.8.1 { |
324 execsql {PRAGMA quick_check} | 330 execsql {PRAGMA quick_check} |
325 } {ok} | 331 } {ok} |
326 do_test pragma-3.9 { | 332 do_test pragma-3.9 { |
327 execsql { | 333 execsql { |
328 ATTACH 'testerr.db' AS t2; | 334 ATTACH 'testerr.db' AS t2; |
329 PRAGMA integrity_check | 335 PRAGMA integrity_check |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 PRAGMA table_info(t5); | 532 PRAGMA table_info(t5); |
527 } | 533 } |
528 } {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEG
ER 0 NULL 0 4 e TEXT 0 '' 0} | 534 } {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEG
ER 0 NULL 0 4 e TEXT 0 '' 0} |
529 db nullvalue {} | 535 db nullvalue {} |
530 ifcapable {foreignkey} { | 536 ifcapable {foreignkey} { |
531 do_test pragma-6.3.1 { | 537 do_test pragma-6.3.1 { |
532 execsql { | 538 execsql { |
533 CREATE TABLE t3(a int references t2(b), b UNIQUE); | 539 CREATE TABLE t3(a int references t2(b), b UNIQUE); |
534 pragma foreign_key_list(t3); | 540 pragma foreign_key_list(t3); |
535 } | 541 } |
536 } {0 0 t2 a b RESTRICT RESTRICT NONE} | 542 } {0 0 t2 a b {NO ACTION} {NO ACTION} NONE} |
537 do_test pragma-6.3.2 { | 543 do_test pragma-6.3.2 { |
538 execsql { | 544 execsql { |
539 pragma foreign_key_list; | 545 pragma foreign_key_list; |
540 } | 546 } |
541 } {} | 547 } {} |
542 do_test pragma-6.3.3 { | 548 do_test pragma-6.3.3 { |
543 execsql { | 549 execsql { |
544 pragma foreign_key_list(t3_bogus); | 550 pragma foreign_key_list(t3_bogus); |
545 } | 551 } |
546 } {} | 552 } {} |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 pragma index_list(t3); | 633 pragma index_list(t3); |
628 } | 634 } |
629 } {0 t3i1 0 1 sqlite_autoindex_t3_1 1} | 635 } {0 t3i1 0 1 sqlite_autoindex_t3_1 1} |
630 do_test pragma-7.1.2 { | 636 do_test pragma-7.1.2 { |
631 execsql { | 637 execsql { |
632 pragma index_list(t3_bogus); | 638 pragma index_list(t3_bogus); |
633 } | 639 } |
634 } {} | 640 } {} |
635 } ;# ifcapable schema_pragmas | 641 } ;# ifcapable schema_pragmas |
636 ifcapable {utf16} { | 642 ifcapable {utf16} { |
637 do_test pragma-7.2 { | 643 if {[permutation] == ""} { |
638 db close | 644 do_test pragma-7.2 { |
639 sqlite3 db test.db | 645 db close |
640 catchsql { | 646 sqlite3 db test.db |
641 pragma encoding=bogus; | 647 catchsql { |
642 } | 648 pragma encoding=bogus; |
643 } {1 {unsupported encoding: bogus}} | 649 } |
| 650 } {1 {unsupported encoding: bogus}} |
| 651 } |
644 } | 652 } |
645 ifcapable tempdb { | 653 ifcapable tempdb { |
646 do_test pragma-7.3 { | 654 do_test pragma-7.3 { |
647 db close | 655 db close |
648 sqlite3 db test.db | 656 sqlite3 db test.db |
649 execsql { | 657 execsql { |
650 pragma lock_status; | 658 pragma lock_status; |
651 } | 659 } |
652 } {main unlocked temp closed} | 660 } {main unlocked temp closed} |
653 } else { | 661 } else { |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 sqlite3 db2 test2.db | 1372 sqlite3 db2 test2.db |
1365 set lockpath [execsql { | 1373 set lockpath [execsql { |
1366 PRAGMA lock_proxy_file=":auto:"; | 1374 PRAGMA lock_proxy_file=":auto:"; |
1367 PRAGMA lock_proxy_file; | 1375 PRAGMA lock_proxy_file; |
1368 } db2] | 1376 } db2] |
1369 string match "*test2.db:auto:" $lockpath | 1377 string match "*test2.db:auto:" $lockpath |
1370 } {1} | 1378 } {1} |
1371 | 1379 |
1372 set sqlite_hostid_num 2 | 1380 set sqlite_hostid_num 2 |
1373 do_test pragma-16.7 { | 1381 do_test pragma-16.7 { |
1374 sqlite3 db test2.db | 1382 list [catch { |
1375 execsql { | 1383 sqlite3 db test2.db |
1376 PRAGMA lock_proxy_file=":auto:"; | 1384 execsql { |
1377 } | 1385 PRAGMA lock_proxy_file=":auto:"; |
1378 catchsql { | 1386 select * from sqlite_master; |
1379 select * from sqlite_master; | 1387 } |
1380 } | 1388 } msg] $msg |
1381 } {1 {database is locked}} | 1389 } {1 {database is locked}} |
1382 db close | 1390 db close |
1383 | 1391 |
1384 do_test pragma-16.8 { | 1392 do_test pragma-16.8 { |
1385 sqlite3 db test2.db | 1393 list [catch { |
1386 catchsql { | 1394 sqlite3 db test2.db |
1387 select * from sqlite_master; | 1395 execsql { select * from sqlite_master } |
1388 } | 1396 } msg] $msg |
1389 } {1 {database is locked}} | 1397 } {1 {database is locked}} |
1390 | 1398 |
1391 db2 close | 1399 db2 close |
1392 do_test pragma-16.8.1 { | 1400 do_test pragma-16.8.1 { |
1393 execsql { | 1401 execsql { |
1394 PRAGMA lock_proxy_file="yetanotherproxy"; | 1402 PRAGMA lock_proxy_file="yetanotherproxy"; |
1395 PRAGMA lock_proxy_file; | 1403 PRAGMA lock_proxy_file; |
1396 } | 1404 } |
1397 } {yetanotherproxy} | 1405 } {yetanotherproxy} |
1398 do_test pragma-16.8.2 { | 1406 do_test pragma-16.8.2 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 sqlite3 db :memory: | 1471 sqlite3 db :memory: |
1464 execsql " | 1472 execsql " |
1465 PRAGMA temp_store=$::temp_setting; | 1473 PRAGMA temp_store=$::temp_setting; |
1466 PRAGMA temp_store=$::temp_setting; | 1474 PRAGMA temp_store=$::temp_setting; |
1467 PRAGMA temp_store; | 1475 PRAGMA temp_store; |
1468 " | 1476 " |
1469 } $val | 1477 } $val |
1470 } | 1478 } |
1471 | 1479 |
1472 finish_test | 1480 finish_test |
OLD | NEW |