- C Add\sthe\s"defer_foreign_keys"\spragma\sand\sthe\sSQLITE_DBSTATUS_DEFERRED_FKS\nvalue\sfor\ssqlite3_db_status().\s\sThis\sis\sa\scherry-pick\sof\sa\ssequence\sof\sfive\ncheckins\sin\sthe\ssessions\sbranch\sbetween\s[1d44e5d3c2]\sand\s[d39e65fe70].
- D 2013-07-11T15:03:32.117
-C Experimental\s"PRAGMA\squery_only=BOOLEAN"\sstatement\sthat\sis\sable\sto\sturn\nwrite\scapabilities\son\sand\soff.
-D 2013-07-10T13:33:49.764
++C Add\sthe\sexperimental\s"query_only"\spragma.
++D 2013-07-11T15:22:31.810
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
F src/pcache1.c d23d07716de96c7c0c2503ec5051a4384c3fb938
- F src/pragma.c c87581d93a7518cba656b7919e32ded5d331b76a
-F src/pragma.c f91b64b84cbc3f3d2a1bbcae0d59e0a782fc67f8
++F src/pragma.c 2790c5175bc3f95d2a0cf39283d144b9b012fec7
F src/prepare.c 2306be166bbeddf454e18bf8b21dba8388d05328
F src/printf.c 41c49dac366a3a411190001a8ab495fa8887974e
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
F src/select.c 91b62654caf8dfe292fb8882715e575d34ad3874
F src/shell.c c8cd06e6b66250a3ea0149c4edec30de14f57b6f
-F src/sqlite.h.in 0a87152a6dde55381afb8f1cf37f337b2f32fd06
+F src/sqlite.h.in 80d11140d401f366f7249f3c4fe031c49a5a06f8
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
- F src/sqliteInt.h 074f5cdfb99e0d4dc8100c217824f384c16af56b
-F src/sqliteInt.h 2819a1e48805199a957570223e54e787935937d6
++F src/sqliteInt.h 6d3115f774aa3e87737f9447c9c0cea992c5bdbf
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
-F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
+F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c b8835978e853a89bf58de88acc943a5ca94d752e
F src/test1.c 870fc648a48cb6d6808393174f7ebe82b8c840fa
F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9
F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8
- F src/vdbe.c 0661945edc8b8d85dccc137925c45542fad9a5a4
-F src/vdbe.c c714445b47b4f242082e97de01272f0c31c3c921
++F src/vdbe.c 420ebf1d551a76406cbbe0adc52d22d45aac039a
F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d
-F src/vdbeInt.h aa185c6df4f2b5ec9896cdb5f96789af1ef69f76
-F src/vdbeapi.c e3ad4cddb713a387527f982e79d9e001a0dbffa5
-F src/vdbeaux.c 9683f262c7fd0af8cb03f0053651135005cdda8a
+F src/vdbeInt.h 5e666c971c555c7977714b0e34cb8d4b20282557
+F src/vdbeapi.c c88222946d657984bdaf394604cb58ed1d641460
+F src/vdbeaux.c 1633408f6dea06129441c5e2f22b2a5ce30fe97e
F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69
F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab
F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017
F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
F test/fkey5.test 0bf64f2d19ad80433ca0b24edbf604a18b353d5f
- F test/fkey6.test 2d76497c54db0e5bfbecee0acf00bb8a706b37db
++F test/fkey6.test c555f7fc45d842cc84b0d3ff93951ce2b8c25fc8
F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
F test/progress.test 552dc1edc37333a8d3098b8c26a2b7f06f5799d7
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
++F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca
F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26
F test/quota.test b5b3eec55a059e0fe493c66c6e27bd2c07676cfd
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
- P 908141d5bf7a9ad8f40c2332476847733eca7fdc
- R f701d887eba2f81d7816617ba86ca3a2
-P 3e8b02011db2f393d4850115a471709b0a88594f
-R 2ffb7f6b213f90920cd38490a5dc43b1
-T *branch * query_only
-T *sym-query_only *
-T -sym-trunk *
++P 527121ac3cdc96ac33ad975c227a6685a2f7e999 ece960c496717a3a6c25526ef77dd76b08d607bc
++R 9c4545357c659a752e6cc07bddb23b90
U drh
- Z 50e77e8dbcbbcc008f0da119505e5900
-Z c3b9d6d6edee565b9fc4629e8b5e8b24
++Z 7d5f7fd6ecb9e38390dc44516a410268
- 527121ac3cdc96ac33ad975c227a6685a2f7e999
-ece960c496717a3a6c25526ef77dd76b08d607bc
++6557c407983b067449deb76bc4c5248de64e07dc
#define SQLITE_PreferBuiltin 0x00100000 /* Preference to built-in funcs */
#define SQLITE_LoadExtension 0x00200000 /* Enable load_extension */
#define SQLITE_EnableTrigger 0x00400000 /* True to enable triggers */
-#define SQLITE_QueryOnly 0x00800000 /* Disable database changes */
+#define SQLITE_DeferFKs 0x00800000 /* Defer all FK constraints */
++#define SQLITE_QueryOnly 0x01000000 /* Disable database changes */
++
/*
** Bits of the sqlite3.dbOptFlags field that are used by the
--- /dev/null
- # 2012 December 17
++# 2013-07-11
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library.
+#
+# This file tests the PRAGMA defer_foreign_keys and
+# SQLITE_DBSTATUS_DEFERRED_FKS
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable {!foreignkey} {
+ finish_test
+ return
+}
+
+do_execsql_test fkey6-1.1 {
+ PRAGMA foreign_keys=ON;
+ CREATE TABLE t1(x INTEGER PRIMARY KEY);
+ CREATE TABLE t2(y INTEGER PRIMARY KEY,
+ z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED);
+ CREATE INDEX t2z ON t2(z);
+ CREATE TABLE t3(u INTEGER PRIMARY KEY, v INTEGER REFERENCES t1(x));
+ CREATE INDEX t3v ON t3(v);
+ INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
+ INSERT INTO t2 VALUES(1,1),(2,2);
+ INSERT INTO t3 VALUES(3,3),(4,4);
+} {}
+do_test fkey6-1.2 {
+ catchsql {DELETE FROM t1 WHERE x=2;}
+} {1 {foreign key constraint failed}}
+do_test fkey6-1.3 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.4 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE x=1;
+ }
+} {}
+do_test fkey6-1.5.1 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 1
+} {0 1 0}
+do_test fkey6-1.5.2 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+do_test fkey6-1.6 {
+ execsql {
+ ROLLBACK;
+ }
+} {}
+do_test fkey6-1.7 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.8 {
+ execsql {
+ PRAGMA defer_foreign_keys=ON;
+ BEGIN;
+ DELETE FROM t1 WHERE x=3;
+ }
+} {}
+do_test fkey6-1.9 {
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+do_test fkey6-1.10 {
+ execsql {
+ ROLLBACK;
+ PRAGMA defer_foreign_keys=OFF;
+ BEGIN;
+ }
+ catchsql {DELETE FROM t1 WHERE x=3}
+} {1 {foreign key constraint failed}}
+db eval {ROLLBACK}
+
+do_test fkey6-1.20 {
+ execsql {
+ BEGIN;
+ DELETE FROM t1 WHERE x=1;
+ }
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 1 0}
+do_test fkey6-1.21 {
+ execsql {
+ DELETE FROM t2 WHERE y=1;
+ }
+ sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0
+} {0 0 0}
+do_test fkey6-1.22 {
+ execsql {
+ COMMIT;
+ }
+} {}
+
+
+finish_test
--- /dev/null
--- /dev/null
++# 2013-07-11
++#
++# The author disclaims copyright to this source code. In place of
++# a legal notice, here is a blessing:
++#
++# May you do good and not evil.
++# May you find forgiveness for yourself and forgive others.
++# May you share freely, never taking more than you give.
++#
++#***********************************************************************
++# This file implements regression tests for SQLite library.
++#
++# This file tests the "query_only" pragma.
++#
++
++set testdir [file dirname $argv0]
++source $testdir/tester.tcl
++
++do_execsql_test queryonly-1.1 {
++ CREATE TABLE t1(a);
++ INSERT INTO t1 VALUES(123),(456);
++ SELECT a FROM t1 ORDER BY a;
++} {123 456}
++do_execsql_test queryonly-1.2 {
++ PRAGMA query_only;
++} {0}
++do_execsql_test queryonly-1.3 {
++ PRAGMA query_only=ON;
++ PRAGMA query_only;
++} {1}
++do_test queryonly-1.4 {
++ catchsql {INSERT INTO t1 VALUES(789);}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.5 {
++ catchsql {DELETE FROM t1;}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.6 {
++ catchsql {UPDATE t1 SET a=a+1;}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.7 {
++ catchsql {CREATE TABLE t2(b);}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.8 {
++ catchsql {CREATE INDEX t1a ON t1(a);}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.9 {
++ catchsql {DROP TABLE t1;}
++} {1 {attempt to write a readonly database}}
++do_test queryonly-1.10 {
++ catchsql {ANALYZE;}
++} {1 {attempt to write a readonly database}}
++do_execsql_test queryonly-1.11 {
++ SELECT a FROM t1 ORDER BY a;
++} {123 456}
++
++do_execsql_test queryonly-2.2 {
++ PRAGMA query_only;
++} {1}
++do_execsql_test queryonly-2.3 {
++ PRAGMA query_only=OFF;
++ PRAGMA query_only;
++} {0}
++do_execsql_test queryonly-2.4 {
++ INSERT INTO t1 VALUES(789);
++ SELECT a FROM t1 ORDER BY a;
++} {123 456 789}
++do_execsql_test queryonly-2.5 {
++ UPDATE t1 SET a=a+1;
++ SELECT a FROM t1 ORDER BY a;
++} {124 457 790}
++
++finish_test