]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When creating a trigger on a main database table when there is a TEMP table
authordrh <drh@noemail.net>
Mon, 15 Feb 2010 16:54:55 +0000 (16:54 +0000)
committerdrh <drh@noemail.net>
Mon, 15 Feb 2010 16:54:55 +0000 (16:54 +0000)
with the same name, make sure the trigger is bound to the main table.
Ticket [985771e11612].

FossilOrigin-Name: ec914af32675e472694270d46f3ba2214eb2fe90

manifest
manifest.uuid
src/trigger.c
test/triggerD.test

index 7c46ac417792c87d8764f029be72ef056e81446b..dfea442e14f63de5c7b46e71a80366162f24994c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Fix\sa\scompiler\swarning\sin\sshell.c.\s\sUpdates\sto\scomments\sin\strigger.c.
-D 2010-02-15T15:47:18
+C When\screating\sa\strigger\son\sa\smain\sdatabase\stable\swhen\sthere\sis\sa\sTEMP\stable\nwith\sthe\ssame\sname,\smake\ssure\sthe\strigger\sis\sbound\sto\sthe\smain\stable.\nTicket\s[985771e11612].
+D 2010-02-15T16:54:55
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -207,7 +207,7 @@ F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
 F src/test_thread.c 00fed80690ae7f1525483a35861511c48bc579f2
 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
 F src/tokenize.c e7f3606cc1b51a819a2bfee99100648d35bc791d
-F src/trigger.c a188f616acd9092231068c841e15cb531ff2bc0d
+F src/trigger.c 340c9eca0fb24b1197468d96ba059f867c9834c7
 F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208
 F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052
 F src/util.c aa0b1da8f71edff84b4b41dbe05fe6ac75d819c6
@@ -717,7 +717,7 @@ F test/trigger9.test 5b0789f1c5c4600961f8e68511b825b87be53e31
 F test/triggerA.test 0718ad2d9bfef27c7af00e636df79bee6b988da7
 F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe
 F test/triggerC.test 4083c64d80854d271bad211268a08985f3d61cbd
-F test/triggerD.test df3813735294734e276aee16419438efc4ecb348
+F test/triggerD.test c6add3817351451e419f6ff9e9a259b02b6e2de7
 F test/types.test 9a825ec8eea4e965d7113b74c76a78bb5240f2ac
 F test/types2.test 3555aacf8ed8dc883356e59efc314707e6247a84
 F test/types3.test a0f66bf12f80fad89493535474f7a6d16fa58150
@@ -790,14 +790,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 9acfb0694059c80b2efc08a60232d4be91575c32
-R f3f1e356ae050092c353da0201c436cd
+P c727601eecd85a26dbd4fc36823d77bec34da3c3
+R 45004b2e132c529777330e8469a3dee0
 U drh
-Z 5a688a63ea61023caa210ca9d98db903
+Z b2e9d944fd601fa751cf2872dbab1f73
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFLeWyJoxKgR168RlERAltLAJ9EhYGSB7HNvlpLXs8n7ZXBinUlkACfUxu8
-32nUfmidvypW0Im8sUgkg7U=
-=aFCH
+iD8DBQFLeXxioxKgR168RlERAlHrAJ4+sjtvvNq54HhErGM+S2FPfikqFwCfQzkv
+9UxvOxpkUFkuGCjFzxJh+7w=
+=TAZV
 -----END PGP SIGNATURE-----
index 924897296c0eb1ddfe5229d6b27de032f531492a..2601e3cb661c0fa5437e3935bccc854361b5a44a 100644 (file)
@@ -1 +1 @@
-c727601eecd85a26dbd4fc36823d77bec34da3c3
\ No newline at end of file
+ec914af32675e472694270d46f3ba2214eb2fe90
\ No newline at end of file
index 642833cb1482cc3d15354f983b4f90dc03931fcf..f57d5600f2f65b4c004ccade643ac35a1c3e4a20 100644 (file)
@@ -126,7 +126,8 @@ void sqlite3BeginTrigger(
     goto trigger_cleanup;
   }
   pTab = sqlite3SrcListLookup(pParse, pTableName);
-  if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
+  if( db->init.busy==0 && pName2->n==0 && pTab
+        && pTab->pSchema==db->aDb[1].pSchema ){
     iDb = 1;
   }
 
index 050edc9724bcaf687b69b6668383a3088100dc42..08945081da95ef79c0ca068ea4f27224bb0a138a 100644 (file)
@@ -123,4 +123,52 @@ do_test triggerD-2.4 {
   }
 } {r5 1 1 1 201 r6 1 1 1 201}
 
+
+###########################################################################
+#
+# Ticket [985771e1161200ae5eac3162686ea6711c035d08]:
+#
+# When both a main database table and a TEMP table have the same name,
+# and a main database trigge is created on the main table, the trigger
+# is incorrectly bound to the TEMP table. For example:
+#
+#   CREATE TABLE t1(x);
+#   CREATE TEMP TABLE t1(x);
+#   CREATE TABLE t2(z);
+#   CREATE TRIGGER main.r1 AFTER INSERT ON t1 BEGIN
+#     INSERT INTO t2 VALUES(10000 + new.x);
+#   END;
+#   INSERT INTO main.t1 VALUES(3);
+#   INSERT INTO temp.t1 VALUES(4);
+#   SELECT * FROM t2;
+# 
+# The r1 trigger fires when the value 4 is inserted into the temp.t1
+# table, rather than when value 3 is inserted into main.t1.
+#
+do_test triggerD-3.1 {
+  db eval {
+    CREATE TABLE t300(x);
+    CREATE TEMP TABLE t300(x);
+    CREATE TABLE t301(y);
+    CREATE TRIGGER main.r300 AFTER INSERT ON t300 BEGIN
+      INSERT INTO t301 VALUES(10000 + new.x);
+    END;
+    INSERT INTO main.t300 VALUES(3);
+    INSERT INTO temp.t300 VALUES(4);
+    SELECT * FROM t301;
+  }
+} {10003}
+do_test triggerD-3.2 {
+  db eval {
+    DELETE FROM t301;
+    CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN
+      INSERT INTO t301 VALUES(20000 + new.x);
+    END;
+    INSERT INTO main.t300 VALUES(3);
+    INSERT INTO temp.t300 VALUES(4);
+    SELECT * FROM t301;
+  }
+} {10003 20004}
+
+
 finish_test