Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: third_party/sqlite/src/test/pragma.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/permutations.test ('k') | third_party/sqlite/src/test/pragma2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #***********************************************************************
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 # pragma-20.*: Test data_store_directory. 44 # pragma-20.*: Test data_store_directory.
45 # pragma-22.*: Test that "PRAGMA [db].integrity_check" respects the "db" 45 # pragma-22.*: Test that "PRAGMA [db].integrity_check" respects the "db"
46 # directive - if it is present. 46 # directive - if it is present.
47 # 47 #
48 48
49 ifcapable !pragma { 49 ifcapable !pragma {
50 finish_test 50 finish_test
51 return 51 return
52 } 52 }
53 53
54 # Capture the output of a pragma in a TEMP table.
55 #
56 proc capture_pragma {db tabname sql} {
57 $db eval "DROP TABLE IF EXISTS temp.$tabname"
58 set once 1
59 $db eval $sql x {
60 if {$once} {
61 set once 0
62 set ins "INSERT INTO $tabname VALUES"
63 set crtab "CREATE TEMP TABLE $tabname "
64 set sep "("
65 foreach col $x(*) {
66 append ins ${sep}\$x($col)
67 append crtab ${sep}\"$col\"
68 set sep ,
69 }
70 append ins )
71 append crtab )
72 $db eval $crtab
73 }
74 $db eval $ins
75 }
76 }
77
54 # Delete the preexisting database to avoid the special setup 78 # Delete the preexisting database to avoid the special setup
55 # that the "all.test" script does. 79 # that the "all.test" script does.
56 # 80 #
57 db close 81 db close
58 delete_file test.db test.db-journal 82 delete_file test.db test.db-journal
59 delete_file test3.db test3.db-journal 83 delete_file test3.db test3.db-journal
60 sqlite3 db test.db; set DB [sqlite3_connection_pointer db] 84 sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
61 85
62 86 # EVIDENCE-OF: R-13861-56665 PRAGMA schema.cache_size; PRAGMA
87 # schema.cache_size = pages; PRAGMA schema.cache_size = -kibibytes;
88 # Query or change the suggested maximum number of database disk pages
89 # that SQLite will hold in memory at once per open database file.
90 #
63 ifcapable pager_pragmas { 91 ifcapable pager_pragmas {
64 set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}] 92 set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}]
65 set TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}] 93 set TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}]
66 do_test pragma-1.1 { 94 do_test pragma-1.1 {
67 execsql { 95 execsql {
68 PRAGMA cache_size; 96 PRAGMA cache_size;
69 PRAGMA default_cache_size; 97 PRAGMA default_cache_size;
70 PRAGMA synchronous; 98 PRAGMA synchronous;
71 } 99 }
72 } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] 100 } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]
73 do_test pragma-1.2 { 101 do_test pragma-1.2 {
102 # EVIDENCE-OF: R-42059-47211 If the argument N is positive then the
103 # suggested cache size is set to N.
74 execsql { 104 execsql {
75 PRAGMA synchronous=OFF; 105 PRAGMA synchronous=OFF;
76 PRAGMA cache_size=1234; 106 PRAGMA cache_size=1234;
77 PRAGMA cache_size; 107 PRAGMA cache_size;
78 PRAGMA default_cache_size; 108 PRAGMA default_cache_size;
79 PRAGMA synchronous; 109 PRAGMA synchronous;
80 } 110 }
81 } [list 1234 $DFLT_CACHE_SZ 0] 111 } [list 1234 $DFLT_CACHE_SZ 0]
82 do_test pragma-1.3 { 112 do_test pragma-1.3 {
83 db close 113 db close
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 PRAGMA synchronous=0; 212 PRAGMA synchronous=0;
183 PRAGMA synchronous; 213 PRAGMA synchronous;
184 } 214 }
185 } {0} 215 } {0}
186 do_test pragma-1.14 { 216 do_test pragma-1.14 {
187 execsql { 217 execsql {
188 PRAGMA synchronous=2; 218 PRAGMA synchronous=2;
189 PRAGMA synchronous; 219 PRAGMA synchronous;
190 } 220 }
191 } {2} 221 } {2}
222 do_test pragma-1.14.1 {
223 execsql {
224 PRAGMA synchronous=4;
225 PRAGMA synchronous;
226 }
227 } {0}
228 do_test pragma-1.14.2 {
229 execsql {
230 PRAGMA synchronous=3;
231 PRAGMA synchronous;
232 }
233 } {0}
234 do_test pragma-1.14.3 {
235 execsql {
236 PRAGMA synchronous=10;
237 PRAGMA synchronous;
238 }
239 } {2}
192 } ;# ifcapable pager_pragmas 240 } ;# ifcapable pager_pragmas
193 241
194 # Test turning "flag" pragmas on and off. 242 # Test turning "flag" pragmas on and off.
195 # 243 #
196 ifcapable debug { 244 ifcapable debug {
197 # Pragma "vdbe_listing" is only available if compiled with SQLITE_DEBUG 245 # Pragma "vdbe_listing" is only available if compiled with SQLITE_DEBUG
198 # 246 #
199 do_test pragma-1.15 { 247 do_test pragma-1.15 {
200 execsql { 248 execsql {
201 PRAGMA vdbe_listing=YES; 249 PRAGMA vdbe_listing=YES;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 PRAGMA writable_schema=OFF; 495 PRAGMA writable_schema=OFF;
448 ALTER TABLE t1 RENAME TO t1x; 496 ALTER TABLE t1 RENAME TO t1x;
449 PRAGMA integrity_check; 497 PRAGMA integrity_check;
450 } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in in dex t1a} {NULL value in t1x.a}} 498 } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in in dex t1a} {NULL value in t1x.a}}
451 do_execsql_test pragma-3.21 { 499 do_execsql_test pragma-3.21 {
452 PRAGMA integrity_check(3); 500 PRAGMA integrity_check(3);
453 } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in in dex t1a}} 501 } {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in in dex t1a}}
454 do_execsql_test pragma-3.22 { 502 do_execsql_test pragma-3.22 {
455 PRAGMA integrity_check(2); 503 PRAGMA integrity_check(2);
456 } {{non-unique entry in index t1a} {NULL value in t1x.a}} 504 } {{non-unique entry in index t1a} {NULL value in t1x.a}}
457 do_execsql_test pragma-3.21 { 505 do_execsql_test pragma-3.23 {
458 PRAGMA integrity_check(1); 506 PRAGMA integrity_check(1);
459 } {{non-unique entry in index t1a}} 507 } {{non-unique entry in index t1a}}
460 508
509 # PRAGMA integrity check (or more specifically the sqlite3BtreeCount()
510 # interface) used to leave index cursors in an inconsistent state
511 # which could result in an assertion fault in sqlite3BtreeKey()
512 # called from saveCursorPosition() if content is removed from the
513 # index while the integrity_check is still running. This test verifies
514 # that problem has been fixed.
515 #
516 do_test pragma-3.30 {
517 db close
518 delete_file test.db
519 sqlite3 db test.db
520 db eval {
521 CREATE TABLE t1(a,b,c);
522 WITH RECURSIVE
523 c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
524 INSERT INTO t1(a,b,c) SELECT i, printf('xyz%08x',i), 2000-i FROM c;
525 CREATE INDEX t1a ON t1(a);
526 CREATE INDEX t1bc ON t1(b,c);
527 }
528 db eval {PRAGMA integrity_check} {
529 db eval {DELETE FROM t1}
530 }
531 } {}
532
461 # Test modifying the cache_size of an attached database. 533 # Test modifying the cache_size of an attached database.
462 ifcapable pager_pragmas&&attach { 534 ifcapable pager_pragmas&&attach {
463 do_test pragma-4.1 { 535 do_test pragma-4.1 {
464 execsql { 536 execsql {
465 ATTACH 'test2.db' AS aux; 537 ATTACH 'test2.db' AS aux;
466 pragma aux.cache_size; 538 pragma aux.cache_size;
467 pragma aux.default_cache_size; 539 pragma aux.default_cache_size;
468 } 540 }
469 } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ] 541 } [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]
470 do_test pragma-4.2 { 542 do_test pragma-4.2 {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 execsql { 661 execsql {
590 pragma foreign_key_list(t3_bogus); 662 pragma foreign_key_list(t3_bogus);
591 } 663 }
592 } {} 664 } {}
593 do_test pragma-6.3.4 { 665 do_test pragma-6.3.4 {
594 execsql { 666 execsql {
595 pragma foreign_key_list(t5); 667 pragma foreign_key_list(t5);
596 } 668 }
597 } {} 669 } {}
598 do_test pragma-6.4 { 670 do_test pragma-6.4 {
599 execsql { 671 capture_pragma db out {
600 pragma index_list(t3); 672 pragma index_list(t3);
601 } 673 }
674 db eval {SELECT seq, "name", "unique" FROM out ORDER BY seq}
602 } {0 sqlite_autoindex_t3_1 1} 675 } {0 sqlite_autoindex_t3_1 1}
603 } 676 }
604 ifcapable {!foreignkey} { 677 ifcapable {!foreignkey} {
605 execsql {CREATE TABLE t3(a,b UNIQUE)} 678 execsql {CREATE TABLE t3(a,b UNIQUE)}
606 } 679 }
607 do_test pragma-6.5.1 { 680 do_test pragma-6.5.1 {
608 execsql { 681 execsql {
609 CREATE INDEX t3i1 ON t3(a,b); 682 CREATE INDEX t3i1 ON t3(a,b);
683 }
684 capture_pragma db out {
610 pragma index_info(t3i1); 685 pragma index_info(t3i1);
611 } 686 }
687 db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}
612 } {0 0 a 1 1 b} 688 } {0 0 a 1 1 b}
689
690 # EVIDENCE-OF: R-23114-21695 The auxiliary index-columns are not shown
691 # by the index_info pragma, but they are listed by the index_xinfo
692 # pragma.
693 #
694 do_test pragma-6.5.1b {
695 capture_pragma db out {PRAGMA index_xinfo(t3i1)}
696 db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}
697 } {0 0 a 1 1 b 2 -1 {}}
698
699
700 # EVIDENCE-OF: R-29448-60346 PRAGMA schema.index_info(index-name); This
701 # pragma returns one row for each key column in the named index.
702 #
703 # (The first column of output from PRAGMA index_info is...)
704 # EVIDENCE-OF: R-34186-52914 The rank of the column within the index. (0
705 # means left-most.)
706 #
707 # (The second column of output from PRAGMA index_info is...)
708 # EVIDENCE-OF: R-65019-08383 The rank of the column within the table
709 # being indexed.
710 #
711 # (The third column of output from PRAGMA index_info is...)
712 # EVIDENCE-OF: R-09773-34266 The name of the column being indexed.
713 #
714 do_execsql_test pragma-6.5.1c {
715 CREATE INDEX t3i2 ON t3(b,a);
716 PRAGMA index_info='t3i2';
717 DROP INDEX t3i2;
718 } {0 1 b 1 0 a}
719
613 do_test pragma-6.5.2 { 720 do_test pragma-6.5.2 {
614 execsql { 721 execsql {
615 pragma index_info(t3i1_bogus); 722 pragma index_info(t3i1_bogus);
616 } 723 }
617 } {} 724 } {}
618 725
619 ifcapable tempdb { 726 ifcapable tempdb {
620 # Test for ticket #3320. When a temp table of the same name exists, make 727 # Test for ticket #3320. When a temp table of the same name exists, make
621 # sure the schema of the main table can still be queried using 728 # sure the schema of the main table can still be queried using
622 # "pragma table_info": 729 # "pragma table_info":
(...skipping 22 matching lines...) Expand all
645 752
646 do_test pragma-6.7 { 753 do_test pragma-6.7 {
647 execsql { 754 execsql {
648 CREATE TABLE test_table( 755 CREATE TABLE test_table(
649 one INT NOT NULL DEFAULT -1, 756 one INT NOT NULL DEFAULT -1,
650 two text, 757 two text,
651 three VARCHAR(45, 65) DEFAULT 'abcde', 758 three VARCHAR(45, 65) DEFAULT 'abcde',
652 four REAL DEFAULT X'abcdef', 759 four REAL DEFAULT X'abcdef',
653 five DEFAULT CURRENT_TIME 760 five DEFAULT CURRENT_TIME
654 ); 761 );
655 PRAGMA table_info(test_table);
656 } 762 }
763 capture_pragma db out {PRAGMA table_info(test_table)}
764 db eval {SELECT cid, "name", type, "notnull", dflt_value, pk FROM out
765 ORDER BY cid}
657 } [concat \ 766 } [concat \
658 {0 one INT 1 -1 0} \ 767 {0 one INT 1 -1 0} \
659 {1 two text 0 {} 0} \ 768 {1 two text 0 {} 0} \
660 {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \ 769 {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \
661 {3 four REAL 0 X'abcdef' 0} \ 770 {3 four REAL 0 X'abcdef' 0} \
662 {4 five {} 0 CURRENT_TIME 0} \ 771 {4 five {} 0 CURRENT_TIME 0} \
663 ] 772 ]
773 do_test pragma-6.8 {
774 execsql {
775 CREATE TABLE t68(a,b,c,PRIMARY KEY(a,b,a,c));
776 PRAGMA table_info(t68);
777 }
778 } [concat \
779 {0 a {} 0 {} 1} \
780 {1 b {} 0 {} 2} \
781 {2 c {} 0 {} 4} \
782 ]
664 } ;# ifcapable schema_pragmas 783 } ;# ifcapable schema_pragmas
665 # Miscellaneous tests 784 # Miscellaneous tests
666 # 785 #
667 ifcapable schema_pragmas { 786 ifcapable schema_pragmas {
787 # EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This
788 # pragma returns one row for each index associated with the given table.
789 #
668 do_test pragma-7.1.1 { 790 do_test pragma-7.1.1 {
669 # Make sure a pragma knows to read the schema if it needs to 791 # Make sure a pragma knows to read the schema if it needs to
670 db close 792 db close
671 sqlite3 db test.db 793 sqlite3 db test.db
672 execsql { 794 capture_pragma db out "PRAGMA index_list(t3)"
673 pragma index_list(t3); 795 db eval {SELECT name, "origin" FROM out ORDER BY name DESC}
674 } 796 } {t3i1 c sqlite_autoindex_t3_1 u}
675 } {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
676 do_test pragma-7.1.2 { 797 do_test pragma-7.1.2 {
677 execsql { 798 execsql {
678 pragma index_list(t3_bogus); 799 pragma index_list(t3_bogus);
679 } 800 }
680 } {} 801 } {}
681 } ;# ifcapable schema_pragmas 802 } ;# ifcapable schema_pragmas
682 ifcapable {utf16} { 803 ifcapable {utf16} {
683 if {[permutation] == ""} { 804 if {[permutation] == ""} {
684 do_test pragma-7.2 { 805 do_test pragma-7.2 {
685 db close 806 db close
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 } 1304 }
1184 } {1} 1305 } {1}
1185 1306
1186 } ;# ifcapable trigger 1307 } ;# ifcapable trigger
1187 1308
1188 ifcapable schema_pragmas { 1309 ifcapable schema_pragmas {
1189 do_test pragma-11.1 { 1310 do_test pragma-11.1 {
1190 execsql2 { 1311 execsql2 {
1191 pragma collation_list; 1312 pragma collation_list;
1192 } 1313 }
1193 } {seq 0 name NOCASE seq 1 name RTRIM seq 2 name BINARY} 1314 } {seq 0 name RTRIM seq 1 name NOCASE seq 2 name BINARY}
1194 do_test pragma-11.2 { 1315 do_test pragma-11.2 {
1195 db collate New_Collation blah... 1316 db collate New_Collation blah...
1196 execsql { 1317 execsql {
1197 pragma collation_list; 1318 pragma collation_list;
1198 } 1319 }
1199 } {0 New_Collation 1 NOCASE 2 RTRIM 3 BINARY} 1320 } {0 New_Collation 1 RTRIM 2 NOCASE 3 BINARY}
1200 } 1321 }
1201 1322
1202 ifcapable schema_pragmas&&tempdb { 1323 ifcapable schema_pragmas&&tempdb {
1203 do_test pragma-12.1 { 1324 do_test pragma-12.1 {
1204 sqlite3 db2 test.db 1325 sqlite3 db2 test.db
1205 execsql { 1326 execsql {
1206 PRAGMA temp.table_info('abc'); 1327 PRAGMA temp.table_info('abc');
1207 } db2 1328 } db2
1208 } {} 1329 } {}
1209 db2 close 1330 db2 close
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 PRAGMA sql_trace=off; 1371 PRAGMA sql_trace=off;
1251 } 1372 }
1252 } {} 1373 } {}
1253 1374
1254 } ;# ifcapable bloblit 1375 } ;# ifcapable bloblit
1255 1376
1256 ifcapable pager_pragmas { 1377 ifcapable pager_pragmas {
1257 db close 1378 db close
1258 forcedelete test.db 1379 forcedelete test.db
1259 sqlite3 db test.db 1380 sqlite3 db test.db
1260 1381
1382 # EVIDENCE-OF: R-15672-33611 PRAGMA schema.page_count; Return the total
1383 # number of pages in the database file.
1384 #
1261 do_test pragma-14.1 { 1385 do_test pragma-14.1 {
1262 execsql { pragma auto_vacuum = 0 } 1386 execsql { pragma auto_vacuum = 0 }
1263 execsql { pragma page_count } 1387 execsql { pragma page_count; pragma main.page_count }
1264 } {0} 1388 } {0 0}
1265 1389
1266 do_test pragma-14.2 { 1390 do_test pragma-14.2 {
1267 execsql { 1391 execsql {
1268 CREATE TABLE abc(a, b, c); 1392 CREATE TABLE abc(a, b, c);
1269 PRAGMA page_count; 1393 PRAGMA page_count;
1394 PRAGMA main.page_count;
1395 PRAGMA temp.page_count;
1270 } 1396 }
1271 } {2} 1397 } {2 2 0}
1272 do_test pragma-14.2uc { 1398 do_test pragma-14.2uc {
1273 execsql {pragma PAGE_COUNT} 1399 execsql {pragma PAGE_COUNT}
1274 } {2} 1400 } {2}
1275 1401
1276 do_test pragma-14.3 { 1402 do_test pragma-14.3 {
1277 execsql { 1403 execsql {
1278 BEGIN; 1404 BEGIN;
1279 CREATE TABLE def(a, b, c); 1405 CREATE TABLE def(a, b, c);
1280 PRAGMA page_count; 1406 PRAGMA page_count;
1281 } 1407 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 1796
1671 db close 1797 db close
1672 forcedelete test.db test.db-wal test.db-journal 1798 forcedelete test.db test.db-wal test.db-journal
1673 sqlite3 db test.db 1799 sqlite3 db test.db
1674 sqlite3 db2 test.db 1800 sqlite3 db2 test.db
1675 do_test 23.1 { 1801 do_test 23.1 {
1676 db eval { 1802 db eval {
1677 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d); 1803 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);
1678 CREATE INDEX i1 ON t1(b,c); 1804 CREATE INDEX i1 ON t1(b,c);
1679 CREATE INDEX i2 ON t1(c,d); 1805 CREATE INDEX i2 ON t1(c,d);
1806 CREATE INDEX i2x ON t1(d COLLATE nocase, c DESC);
1680 CREATE TABLE t2(x INTEGER REFERENCES t1); 1807 CREATE TABLE t2(x INTEGER REFERENCES t1);
1681 } 1808 }
1682 db2 eval {SELECT name FROM sqlite_master} 1809 db2 eval {SELECT name FROM sqlite_master}
1683 } {t1 i1 i2 t2} 1810 } {t1 i1 i2 i2x t2}
1684 do_test 23.2 { 1811 do_test 23.2a {
1685 db eval { 1812 db eval {
1686 DROP INDEX i2; 1813 DROP INDEX i2;
1687 CREATE INDEX i2 ON t1(c,d,b); 1814 CREATE INDEX i2 ON t1(c,d,b);
1688 } 1815 }
1689 db2 eval {PRAGMA index_info(i2)} 1816 capture_pragma db2 out {PRAGMA index_info(i2)}
1690 } {0 2 c 1 3 d 2 1 b} 1817 db2 eval {SELECT cid, name, '|' FROM out ORDER BY seqno}
1818 } {2 c | 3 d | 1 b |}
1819
1820 # EVIDENCE-OF: R-56143-29319 PRAGMA schema.index_xinfo(index-name); This
1821 # pragma returns information about every column in an index.
1822 #
1823 # EVIDENCE-OF: R-45970-35618 Unlike this index_info pragma, this pragma
1824 # returns information about every column in the index, not just the key
1825 # columns.
1826 #
1827 do_test 23.2b {
1828 capture_pragma db2 out {PRAGMA index_xinfo(i2)}
1829 db2 eval {SELECT cid, name, "desc", coll, "key", '|' FROM out ORDER BY seqno}
1830 } {2 c 0 BINARY 1 | 3 d 0 BINARY 1 | 1 b 0 BINARY 1 | -1 {} 0 BINARY 0 |}
1831
1832 # (The first column of output from PRAGMA index_xinfo is...)
1833 # EVIDENCE-OF: R-00197-14279 The rank of the column within the index. (0
1834 # means left-most. Key columns come before auxiliary columns.)
1835 #
1836 # (The second column of output from PRAGMA index_xinfo is...)
1837 # EVIDENCE-OF: R-40889-06838 The rank of the column within the table
1838 # being indexed, or -1 if the index-column is the rowid of the table
1839 # being indexed.
1840 #
1841 # (The third column of output from PRAGMA index_xinfo is...)
1842 # EVIDENCE-OF: R-22751-28901 The name of the column being indexed, or
1843 # NULL if the index-column is the rowid of the table being indexed.
1844 #
1845 # (The fourth column of output from PRAGMA index_xinfo is...)
1846 # EVIDENCE-OF: R-11847-09179 1 if the index-column is sorted in reverse
1847 # (DESC) order by the index and 0 otherwise.
1848 #
1849 # (The fifth column of output from PRAGMA index_xinfo is...)
1850 # EVIDENCE-OF: R-15313-19540 The name for the collating sequence used to
1851 # compare values in the index-column.
1852 #
1853 # (The sixth column of output from PRAGMA index_xinfo is...)
1854 # EVIDENCE-OF: R-14310-64553 1 if the index-column is a key column and 0
1855 # if the index-column is an auxiliary column.
1856 #
1857 do_test 23.2c {
1858 db2 eval {PRAGMA index_xinfo(i2)}
1859 } {0 2 c 0 BINARY 1 1 3 d 0 BINARY 1 2 1 b 0 BINARY 1 3 -1 {} 0 BINARY 0}
1860 do_test 23.2d {
1861 db2 eval {PRAGMA index_xinfo(i2x)}
1862 } {0 3 d 0 nocase 1 1 2 c 1 BINARY 1 2 -1 {} 0 BINARY 0}
1863
1864 # EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This
1865 # pragma returns one row for each index associated with the given table.
1866 #
1867 # (The first column of output from PRAGMA index_list is...)
1868 # EVIDENCE-OF: R-02753-24748 A sequence number assigned to each index
1869 # for internal tracking purposes.
1870 #
1871 # (The second column of output from PRAGMA index_list is...)
1872 # EVIDENCE-OF: R-35496-03635 The name of the index.
1873 #
1874 # (The third column of output from PRAGMA index_list is...)
1875 # EVIDENCE-OF: R-57301-64506 "1" if the index is UNIQUE and "0" if not.
1876 #
1877 # (The fourth column of output from PRAGMA index_list is...)
1878 # EVIDENCE-OF: R-36609-39554 "c" if the index was created by a CREATE
1879 # INDEX statement, "u" if the index was created by a UNIQUE constraint,
1880 # or "pk" if the index was created by a PRIMARY KEY constraint.
1881 #
1691 do_test 23.3 { 1882 do_test 23.3 {
1692 db eval { 1883 db eval {
1693 CREATE INDEX i3 ON t1(d,b,c); 1884 CREATE INDEX i3 ON t1(d,b,c);
1694 } 1885 }
1695 db2 eval {PRAGMA index_list(t1)} 1886 capture_pragma db2 out {PRAGMA index_list(t1)}
1696 } {0 i3 0 1 i2 0 2 i1 0} 1887 db2 eval {SELECT seq, name, "unique", origin, '|' FROM out ORDER BY seq}
1888 } {0 i3 0 c | 1 i2 0 c | 2 i2x 0 c | 3 i1 0 c |}
1697 do_test 23.4 { 1889 do_test 23.4 {
1698 db eval { 1890 db eval {
1699 ALTER TABLE t1 ADD COLUMN e; 1891 ALTER TABLE t1 ADD COLUMN e;
1700 } 1892 }
1701 db2 eval { 1893 db2 eval {
1702 PRAGMA table_info(t1); 1894 PRAGMA table_info(t1);
1703 } 1895 }
1704 } {/4 e {} 0 {} 0/} 1896 } {/4 e {} 0 {} 0/}
1705 do_test 23.5 { 1897 do_test 23.5 {
1706 db eval { 1898 db eval {
1707 DROP TABLE t2; 1899 DROP TABLE t2;
1708 CREATE TABLE t2(x, y INTEGER REFERENCES t1); 1900 CREATE TABLE t2(x, y INTEGER REFERENCES t1);
1709 } 1901 }
1710 db2 eval { 1902 db2 eval {
1711 PRAGMA foreign_key_list(t2); 1903 PRAGMA foreign_key_list(t2);
1712 } 1904 }
1713 } {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE} 1905 } {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE}
1714 1906
1715 database_never_corrupt 1907 database_never_corrupt
1716 finish_test 1908 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/permutations.test ('k') | third_party/sqlite/src/test/pragma2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698