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 #*********************************************************************** |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } {123 123 2} | 179 } {123 123 2} |
180 } | 180 } |
181 do_test pragma-1.10 { | 181 do_test pragma-1.10 { |
182 execsql { | 182 execsql { |
183 PRAGMA synchronous=NORMAL; | 183 PRAGMA synchronous=NORMAL; |
184 PRAGMA cache_size; | 184 PRAGMA cache_size; |
185 PRAGMA default_cache_size; | 185 PRAGMA default_cache_size; |
186 PRAGMA synchronous; | 186 PRAGMA synchronous; |
187 } | 187 } |
188 } {123 123 1} | 188 } {123 123 1} |
189 do_test pragma-1.11 { | 189 do_test pragma-1.11.1 { |
| 190 execsql { |
| 191 PRAGMA synchronous=EXTRA; |
| 192 PRAGMA cache_size; |
| 193 PRAGMA default_cache_size; |
| 194 PRAGMA synchronous; |
| 195 } |
| 196 } {123 123 3} |
| 197 do_test pragma-1.11.2 { |
190 execsql { | 198 execsql { |
191 PRAGMA synchronous=FULL; | 199 PRAGMA synchronous=FULL; |
192 PRAGMA cache_size; | 200 PRAGMA cache_size; |
193 PRAGMA default_cache_size; | 201 PRAGMA default_cache_size; |
194 PRAGMA synchronous; | 202 PRAGMA synchronous; |
195 } | 203 } |
196 } {123 123 2} | 204 } {123 123 2} |
197 do_test pragma-1.12 { | 205 do_test pragma-1.12 { |
198 db close | 206 db close |
199 sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] | 207 sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] |
(...skipping 17 matching lines...) Expand all Loading... |
217 execsql { | 225 execsql { |
218 PRAGMA synchronous=2; | 226 PRAGMA synchronous=2; |
219 PRAGMA synchronous; | 227 PRAGMA synchronous; |
220 } | 228 } |
221 } {2} | 229 } {2} |
222 do_test pragma-1.14.1 { | 230 do_test pragma-1.14.1 { |
223 execsql { | 231 execsql { |
224 PRAGMA synchronous=4; | 232 PRAGMA synchronous=4; |
225 PRAGMA synchronous; | 233 PRAGMA synchronous; |
226 } | 234 } |
227 } {0} | 235 } {4} |
228 do_test pragma-1.14.2 { | 236 do_test pragma-1.14.2 { |
229 execsql { | 237 execsql { |
230 PRAGMA synchronous=3; | 238 PRAGMA synchronous=3; |
231 PRAGMA synchronous; | 239 PRAGMA synchronous; |
232 } | 240 } |
| 241 } {3} |
| 242 do_test pragma-1.14.3 { |
| 243 execsql { |
| 244 PRAGMA synchronous=8; |
| 245 PRAGMA synchronous; |
| 246 } |
233 } {0} | 247 } {0} |
234 do_test pragma-1.14.3 { | 248 do_test pragma-1.14.4 { |
235 execsql { | 249 execsql { |
236 PRAGMA synchronous=10; | 250 PRAGMA synchronous=10; |
237 PRAGMA synchronous; | 251 PRAGMA synchronous; |
238 } | 252 } |
239 } {2} | 253 } {2} |
240 } ;# ifcapable pager_pragmas | 254 } ;# ifcapable pager_pragmas |
241 | 255 |
242 # Test turning "flag" pragmas on and off. | 256 # Test turning "flag" pragmas on and off. |
243 # | 257 # |
244 ifcapable debug { | 258 ifcapable debug { |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 set res {} | 621 set res {} |
608 execsql {SELECT * FROM sqlite_temp_master} | 622 execsql {SELECT * FROM sqlite_temp_master} |
609 foreach {idx name file} [execsql {pragma database_list}] { | 623 foreach {idx name file} [execsql {pragma database_list}] { |
610 lappend res $idx $name | 624 lappend res $idx $name |
611 } | 625 } |
612 set res | 626 set res |
613 } {0 main 1 temp 2 aux} | 627 } {0 main 1 temp 2 aux} |
614 } | 628 } |
615 do_test pragma-6.2 { | 629 do_test pragma-6.2 { |
616 execsql { | 630 execsql { |
617 CREATE TABLE t2(a,b,c); | 631 CREATE TABLE t2(a TYPE_X, b [TYPE_Y], c "TYPE_Z"); |
618 pragma table_info(t2) | 632 pragma table_info(t2) |
619 } | 633 } |
620 } {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0} | 634 } {0 a TYPE_X 0 {} 0 1 b TYPE_Y 0 {} 0 2 c TYPE_Z 0 {} 0} |
621 do_test pragma-6.2.1 { | 635 do_test pragma-6.2.1 { |
622 execsql { | 636 execsql { |
623 pragma table_info; | 637 pragma table_info; |
624 } | 638 } |
625 } {} | 639 } {} |
626 db nullvalue <<NULL>> | 640 db nullvalue <<NULL>> |
627 do_test pragma-6.2.2 { | 641 do_test pragma-6.2.2 { |
628 execsql { | 642 execsql { |
629 CREATE TABLE t5( | 643 CREATE TABLE t5( |
630 a TEXT DEFAULT CURRENT_TIMESTAMP, | 644 a TEXT DEFAULT CURRENT_TIMESTAMP, |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 execsql { | 1076 execsql { |
1063 PRAGMA user_version; | 1077 PRAGMA user_version; |
1064 } | 1078 } |
1065 } {-450} | 1079 } {-450} |
1066 } ; # ifcapable schema_version | 1080 } ; # ifcapable schema_version |
1067 | 1081 |
1068 # Check to see if TEMP_STORE is memory or disk. Return strings | 1082 # Check to see if TEMP_STORE is memory or disk. Return strings |
1069 # "memory" or "disk" as appropriate. | 1083 # "memory" or "disk" as appropriate. |
1070 # | 1084 # |
1071 proc check_temp_store {} { | 1085 proc check_temp_store {} { |
1072 db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)} | 1086 db eval { |
| 1087 PRAGMA temp.cache_size = 1; |
| 1088 CREATE TEMP TABLE IF NOT EXISTS a(b); |
| 1089 DELETE FROM a; |
| 1090 INSERT INTO a VALUES(randomblob(1000)); |
| 1091 INSERT INTO a SELECT * FROM a; |
| 1092 INSERT INTO a SELECT * FROM a; |
| 1093 INSERT INTO a SELECT * FROM a; |
| 1094 INSERT INTO a SELECT * FROM a; |
| 1095 INSERT INTO a SELECT * FROM a; |
| 1096 INSERT INTO a SELECT * FROM a; |
| 1097 INSERT INTO a SELECT * FROM a; |
| 1098 INSERT INTO a SELECT * FROM a; |
| 1099 } |
1073 db eval {PRAGMA database_list} { | 1100 db eval {PRAGMA database_list} { |
1074 if {$name=="temp"} { | 1101 if {$name=="temp"} { |
1075 set bt [btree_from_db db 1] | 1102 set bt [btree_from_db db 1] |
1076 if {[btree_ismemdb $bt]} { | 1103 if {[btree_ismemdb $bt]} { |
1077 return "memory" | 1104 return "memory" |
1078 } | 1105 } |
1079 return "disk" | 1106 return "disk" |
1080 } | 1107 } |
1081 } | 1108 } |
1082 return "unknown" | 1109 return "unknown" |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 catchsql "PRAGMA data_store_directory='';" | 1747 catchsql "PRAGMA data_store_directory='';" |
1721 } {0 {}} | 1748 } {0 {}} |
1722 do_test pragma-20.8 { | 1749 do_test pragma-20.8 { |
1723 catchsql {PRAGMA data_store_directory} | 1750 catchsql {PRAGMA data_store_directory} |
1724 } {0 {}} | 1751 } {0 {}} |
1725 | 1752 |
1726 forcedelete data_dir | 1753 forcedelete data_dir |
1727 } ;# endif windows | 1754 } ;# endif windows |
1728 | 1755 |
1729 database_may_be_corrupt | 1756 database_may_be_corrupt |
| 1757 if {![nonzero_reserved_bytes]} { |
1730 | 1758 |
1731 do_test 21.1 { | 1759 do_test 21.1 { |
1732 # Create a corrupt database in testerr.db. And a non-corrupt at test.db. | 1760 # Create a corrupt database in testerr.db. And a non-corrupt at test.db. |
1733 # | 1761 # |
1734 db close | 1762 db close |
1735 forcedelete test.db | 1763 forcedelete test.db |
1736 sqlite3 db test.db | 1764 sqlite3 db test.db |
1737 execsql { | 1765 execsql { |
1738 PRAGMA page_size = 1024; | 1766 PRAGMA page_size = 1024; |
1739 PRAGMA auto_vacuum = 0; | 1767 PRAGMA auto_vacuum = 0; |
1740 CREATE TABLE t1(a PRIMARY KEY, b); | 1768 CREATE TABLE t1(a PRIMARY KEY, b); |
1741 INSERT INTO t1 VALUES(1, 1); | 1769 INSERT INTO t1 VALUES(1, 1); |
1742 } | 1770 } |
1743 for {set i 0} {$i < 10} {incr i} { | 1771 for {set i 0} {$i < 10} {incr i} { |
1744 execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 } | 1772 execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 } |
1745 } | 1773 } |
1746 db close | 1774 db close |
1747 forcecopy test.db testerr.db | 1775 forcecopy test.db testerr.db |
1748 hexio_write testerr.db 15000 [string repeat 55 100] | 1776 hexio_write testerr.db 15000 [string repeat 55 100] |
1749 } {100} | 1777 } {100} |
1750 | 1778 |
1751 set mainerr {*** in database main *** | 1779 set mainerr {*** in database main *** |
1752 Multiple uses for byte 672 of page 15} | 1780 Multiple uses for byte 672 of page 15} |
1753 set auxerr {*** in database aux *** | 1781 set auxerr {*** in database aux *** |
1754 Multiple uses for byte 672 of page 15} | 1782 Multiple uses for byte 672 of page 15} |
1755 | 1783 |
1756 set mainerr {/{\*\*\* in database main \*\*\* | 1784 set mainerr {/{\*\*\* in database main \*\*\* |
1757 Multiple uses for byte 672 of page 15}.*/} | 1785 Multiple uses for byte 672 of page 15}.*/} |
1758 set auxerr {/{\*\*\* in database aux \*\*\* | 1786 set auxerr {/{\*\*\* in database aux \*\*\* |
1759 Multiple uses for byte 672 of page 15}.*/} | 1787 Multiple uses for byte 672 of page 15}.*/} |
1760 | 1788 |
1761 do_test 22.2 { | 1789 do_test 22.2 { |
1762 catch { db close } | 1790 catch { db close } |
1763 sqlite3 db testerr.db | 1791 sqlite3 db testerr.db |
1764 execsql { PRAGMA integrity_check } | 1792 execsql { PRAGMA integrity_check } |
1765 } $mainerr | 1793 } $mainerr |
1766 | 1794 |
1767 do_test 22.3.1 { | 1795 do_test 22.3.1 { |
1768 catch { db close } | 1796 catch { db close } |
1769 sqlite3 db test.db | 1797 sqlite3 db test.db |
1770 execsql { | 1798 execsql { |
1771 ATTACH 'testerr.db' AS 'aux'; | 1799 ATTACH 'testerr.db' AS 'aux'; |
1772 PRAGMA integrity_check; | 1800 PRAGMA integrity_check; |
1773 } | 1801 } |
1774 } $auxerr | 1802 } $auxerr |
1775 do_test 22.3.2 { | 1803 do_test 22.3.2 { |
1776 execsql { PRAGMA main.integrity_check; } | 1804 execsql { PRAGMA main.integrity_check; } |
1777 } {ok} | 1805 } {ok} |
1778 do_test 22.3.3 { | 1806 do_test 22.3.3 { |
1779 execsql { PRAGMA aux.integrity_check; } | 1807 execsql { PRAGMA aux.integrity_check; } |
1780 } $auxerr | 1808 } $auxerr |
1781 | 1809 |
1782 do_test 22.4.1 { | 1810 do_test 22.4.1 { |
1783 catch { db close } | 1811 catch { db close } |
1784 sqlite3 db testerr.db | 1812 sqlite3 db testerr.db |
1785 execsql { | 1813 execsql { |
1786 ATTACH 'test.db' AS 'aux'; | 1814 ATTACH 'test.db' AS 'aux'; |
1787 PRAGMA integrity_check; | 1815 PRAGMA integrity_check; |
1788 } | 1816 } |
1789 } $mainerr | 1817 } $mainerr |
1790 do_test 22.4.2 { | 1818 do_test 22.4.2 { |
1791 execsql { PRAGMA main.integrity_check; } | 1819 execsql { PRAGMA main.integrity_check; } |
1792 } $mainerr | 1820 } $mainerr |
1793 do_test 22.4.3 { | 1821 do_test 22.4.3 { |
1794 execsql { PRAGMA aux.integrity_check; } | 1822 execsql { PRAGMA aux.integrity_check; } |
1795 } {ok} | 1823 } {ok} |
1796 | 1824 } |
| 1825 |
1797 db close | 1826 db close |
1798 forcedelete test.db test.db-wal test.db-journal | 1827 forcedelete test.db test.db-wal test.db-journal |
1799 sqlite3 db test.db | 1828 sqlite3 db test.db |
1800 sqlite3 db2 test.db | 1829 sqlite3 db2 test.db |
1801 do_test 23.1 { | 1830 do_test 23.1 { |
1802 db eval { | 1831 db eval { |
1803 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d); | 1832 CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d); |
1804 CREATE INDEX i1 ON t1(b,c); | 1833 CREATE INDEX i1 ON t1(b,c); |
1805 CREATE INDEX i2 ON t1(c,d); | 1834 CREATE INDEX i2 ON t1(c,d); |
1806 CREATE INDEX i2x ON t1(d COLLATE nocase, c DESC); | 1835 CREATE INDEX i2x ON t1(d COLLATE nocase, c DESC); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 DROP TABLE t2; | 1928 DROP TABLE t2; |
1900 CREATE TABLE t2(x, y INTEGER REFERENCES t1); | 1929 CREATE TABLE t2(x, y INTEGER REFERENCES t1); |
1901 } | 1930 } |
1902 db2 eval { | 1931 db2 eval { |
1903 PRAGMA foreign_key_list(t2); | 1932 PRAGMA foreign_key_list(t2); |
1904 } | 1933 } |
1905 } {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE} | 1934 } {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE} |
1906 | 1935 |
1907 database_never_corrupt | 1936 database_never_corrupt |
1908 finish_test | 1937 finish_test |
OLD | NEW |