aboutsummaryrefslogtreecommitdiff
path: root/test/hook.test
diff options
context:
space:
mode:
authordrh <>2021-02-18 22:47:34 +0000
committerdrh <>2021-02-18 22:47:34 +0000
commita7da40f377c368fbd3eea9c2befb74ef6cd03f4c (patch)
treea1014db371a3a19c2030e164154556a9eec35939 /test/hook.test
parent678f3b33cc057f8253444343575d24ab093d8ddf (diff)
parenta55a839ab327630511f37098ed25d5df71b558d3 (diff)
downloadsqlite-a7da40f377c368fbd3eea9c2befb74ef6cd03f4c.tar.gz
sqlite-a7da40f377c368fbd3eea9c2befb74ef6cd03f4c.zip
Merge changes from trunk into the alter-table-drop-column branch.
FossilOrigin-Name: 9ea640073f8809dfe2612ae1ea384a938b433f884c54d9e5aa3712de79397ac1
Diffstat (limited to 'test/hook.test')
-rw-r--r--test/hook.test58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/hook.test b/test/hook.test
index d137e9056..0b72b2dcf 100644
--- a/test/hook.test
+++ b/test/hook.test
@@ -956,5 +956,63 @@ ifcapable analyze {
}]
}
+#-------------------------------------------------------------------------
+# Test that the pre-update hook is fired for INSERT statements that use
+# the xfer optimization on without rowid tables.
+#
+reset_db
+do_execsql_test 12.1 {
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ CREATE TABLE t2(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+
+ INSERT INTO t1 VALUES(1, 2);
+ INSERT INTO t1 VALUES(3, 4);
+ INSERT INTO t2 VALUES(5, 6);
+ INSERT INTO t2 VALUES(7, 8);
+
+ CREATE TABLE t3 (a INTEGER PRIMARY KEY, b) WITHOUT ROWID;
+}
+
+db preupdate hook preupdate_cb
+db update_hook update_cb
+
+proc preupdate_cb {args} { lappend ::res "preupdate" $args }
+proc update_cb {args} { lappend ::res "update" $args }
+
+set ::res [list]
+do_test 12.2 {
+ execsql VACUUM
+ set ::res
+} {}
+
+do_test 12.3 {
+ set ::res [list]
+ execsql { INSERT INTO t3 SELECT a, b FROM t2 }
+ set ::res
+} {preupdate {INSERT main t3 0 0} preupdate {INSERT main t3 0 0}}
+
+do_test 12.4 {
+ execsql { DELETE FROM t3 }
+ set ::res [list]
+ execsql { INSERT INTO t3 SELECT * FROM t2 }
+ set ::res
+} {preupdate {INSERT main t3 0 0} preupdate {INSERT main t3 0 0}}
+
+do_execsql_test 12.5 {
+ CREATE TABLE t4(a COLLATE nocase PRIMARY KEY, b) WITHOUT ROWID;
+ INSERT INTO t4 VALUES('abc', 1);
+ INSERT INTO t4 VALUES('DEF', 2);
+}
+
+set ::res [list]
+do_test 12.6 {
+ execsql VACUUM
+ set ::res
+} {}
+
+do_catchsql_test 12.6 {
+ INSERT INTO t4 VALUES('def', 3);
+} {1 {UNIQUE constraint failed: t4.a}}
finish_test
+