aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authordan <dan@noemail.net>2019-01-07 15:57:35 +0000
committerdan <dan@noemail.net>2019-01-07 15:57:35 +0000
commit418454c63fe1d6f3083542110d17cf561b8f369f (patch)
treee18da9a9f159c8dd34f94e50e398074f0624e3c9 /ext
parentdcc2700d7e1c0e4fc885dffbc4406bdc1e4c4e9b (diff)
downloadsqlite-418454c63fe1d6f3083542110d17cf561b8f369f.tar.gz
sqlite-418454c63fe1d6f3083542110d17cf561b8f369f.zip
For SQLITE_ENABLE_PREUPDATE_HOOK builds, disable the optimization for a
REPLACE command on a WITHOUT ROWID table with no indexes, triggers or foreign key constraints that causes SQLite to clobber any existing row without separately checking for it. This optimization causes SQLite to omit the expected pre-update-hook callbacks. FossilOrigin-Name: 6281ef974c0ac7a7133c9e1e04c09fdbd627c019c6ff3227293548caf8283864
Diffstat (limited to 'ext')
-rw-r--r--ext/session/sessionwor.test76
1 files changed, 60 insertions, 16 deletions
diff --git a/ext/session/sessionwor.test b/ext/session/sessionwor.test
index 2b2f8ca7e..0f0b429d7 100644
--- a/ext/session/sessionwor.test
+++ b/ext/session/sessionwor.test
@@ -30,27 +30,71 @@ proc test_reset {} {
sqlite3 db2 test.db2
}
-
-do_execsql_test 1.0 {
- CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID;
-}
-
-do_iterator_test 1.1 t1 {
- INSERT INTO t1 VALUES('one', 'two');
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
} {
- {INSERT t1 0 X. {} {t one t two}}
-}
+ reset_db
-do_iterator_test 1.2 t1 {
- UPDATE t1 SET b='three'
-} {
- {UPDATE t1 0 X. {t one t two} {{} {} t three}}
+ do_execsql_test 1.$tn.0 "CREATE TABLE t1(a PRIMARY KEY, b) $wo ;"
+
+ do_iterator_test 1.$tn.1 t1 {
+ INSERT INTO t1 VALUES('one', 'two');
+ } {
+ {INSERT t1 0 X. {} {t one t two}}
+ }
+
+ do_iterator_test 1.$tn.2 t1 {
+ UPDATE t1 SET b='three'
+ } {
+ {UPDATE t1 0 X. {t one t two} {{} {} t three}}
+ }
+
+ do_iterator_test 1.$tn.3 t1 {
+ REPLACE INTO t1 VALUES('one', 'four');
+ } {
+ {UPDATE t1 0 X. {t one t three} {{} {} t four}}
+ }
+
+ do_iterator_test 1.$tn.4 t1 {
+ DELETE FROM t1;
+ } {
+ {DELETE t1 0 X. {t one t four} {}}
+ }
}
-do_iterator_test 1.3 t1 {
- DELETE FROM t1;
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
} {
- {DELETE t1 0 X. {t one t three} {}}
+ reset_db
+
+ do_execsql_test 2.$tn.0 "CREATE TABLE t1(a INTEGER PRIMARY KEY, b) $wo ;"
+
+ do_iterator_test 1.1 t1 {
+ INSERT INTO t1 VALUES(1, 'two');
+ } {
+ {INSERT t1 0 X. {} {i 1 t two}}
+ }
+
+ do_iterator_test 2.$tn.2 t1 {
+ UPDATE t1 SET b='three'
+ } {
+ {UPDATE t1 0 X. {i 1 t two} {{} {} t three}}
+ }
+
+ do_iterator_test 2.$tn.3 t1 {
+ REPLACE INTO t1 VALUES(1, 'four');
+ } {
+ {UPDATE t1 0 X. {i 1 t three} {{} {} t four}}
+ }
+
+ do_iterator_test 2.$tn.4 t1 {
+ DELETE FROM t1;
+ } {
+ {DELETE t1 0 X. {i 1 t four} {}}
+ }
}
finish_test
+