]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure the update hook is not invoked for WITHOUT ROWID tables, as
authordrh <drh@noemail.net>
Tue, 26 Nov 2013 23:27:07 +0000 (23:27 +0000)
committerdrh <drh@noemail.net>
Tue, 26 Nov 2013 23:27:07 +0000 (23:27 +0000)
the documentation specifies.  This bug was found while adding requirements
marks, so a few extraneous requirements marks are included in this
check-in.

FossilOrigin-Name: 0978bac6b8aee229d7a0d148546f50d380d06a06

manifest
manifest.uuid
src/resolve.c
src/vdbe.c
test/e_createtable.test
test/hook.test

index 1f5ab5775641233d37b616a46a22bfd3d1c2a48e..9ce618374e45a25d8f012b3c52b719feb6951984 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\srequirements\stest\scases\sfor\sdetermining\swhen\san\sexpression\sis\strue\sand\nwhen\sit\sis\sfalse.
-D 2013-11-26T22:46:54.424
+C Make\ssure\sthe\supdate\shook\sis\snot\sinvoked\sfor\sWITHOUT\sROWID\stables,\sas\nthe\sdocumentation\sspecifies.\s\sThis\sbug\swas\sfound\swhile\sadding\srequirements\nmarks,\sso\sa\sfew\sextraneous\srequirements\smarks\sare\sincluded\sin\sthis\ncheck-in.
+D 2013-11-26T23:27:07.055
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -217,7 +217,7 @@ F src/pragma.c 5ab7279d132143feb77f773688a24ab05da75fd7
 F src/prepare.c 359d1a1e9c9bd4488e4dd3a1aaaf2d2ebb9bb768
 F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b
 F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68
-F src/resolve.c a70e32ae6ccb7b780f2b6d3e9e21837affc25ee5
+F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a
 F src/shell.c c4d06a9238a515ff4bc86b8626139633c09a00a2
@@ -280,7 +280,7 @@ F src/update.c c05a0ee658f1a149e0960dfd110f3b8bd846bcb0
 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
 F src/util.c cbe054290f780fcd472b89d701c7404c51ec9684
 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
-F src/vdbe.c d9c63f5c5679f6e6c96612264b5674b8020696c4
+F src/vdbe.c c2b3cd6baddb224a2f155e410ca69f74e6efc671
 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644
 F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263
 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
@@ -433,7 +433,7 @@ F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2
 F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e
 F test/distinct.test 44028aaf161a5e80a2f229622b3a174d3b352810
 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
-F test/e_createtable.test 3b453432cd14a12732ee9467597d2274ca37ce36
+F test/e_createtable.test a4561b93062e651d6def99c9e6956969dbf3754c
 F test/e_delete.test d5186e2f5478b659f16a2c8b66c09892823e542a
 F test/e_droptrigger.test 3cd080807622c13e5bbb61fc9a57bd7754da2412
 F test/e_dropview.test 0c9f7f60989164a70a67a9d9c26d1083bc808306
@@ -587,7 +587,7 @@ F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26
 F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36
 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536
 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98
-F test/hook.test 45cb22b940c3cc0af616ba7430f666e245711a48
+F test/hook.test 8b24a1a8a1ddf0883c6824825e7577f2636918dc
 F test/icu.test 70df4faca133254c042d02ae342c0a141f2663f4
 F test/in.test 047c4671328e9032ab95666a67021adbbd36e98e
 F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
@@ -1143,7 +1143,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P d84aa44e3919e25f9520c5120a35ec21e837a9ea
-R ceef359da24957280bf0acfc550c26b7
+P 838654e56304a5788ac384ca506c1938f48af488
+R e178483a3ba4d2f533907e57553db5a6
 U drh
-Z 5bb7513aebd7acd760a2df9416ad20ba
+Z 51c7e3abc8471c6679ba39e030a2dca2
index 05481834be797309bf67896aab9908d9dfc46efc..91c5fe5dfd6004c1886200832102cdb6c3ba2091 100644 (file)
@@ -1 +1 @@
-838654e56304a5788ac384ca506c1938f48af488
\ No newline at end of file
+0978bac6b8aee229d7a0d148546f50d380d06a06
\ No newline at end of file
index 2c0907cc47570dbe0fb7eb16a52bcdf1b494c5c9..b0adb86295dfe97292f582c3d69000995b241ad2 100644 (file)
@@ -352,7 +352,9 @@ static int lookupName(
           }
         }
         if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && HasRowid(pTab) ){
-          iCol = -1;        /* IMP: R-44911-55124 */
+          /* IMP: R-24309-18625 */
+          /* IMP: R-44911-55124 */
+          iCol = -1;
         }
         if( iCol<pTab->nCol ){
           cnt++;
index b402a5e6c00d62a9016dacd6da5821534c939a30..3b27ba144a96f10c5fc34ca01c34cfc90f1c6160 100644 (file)
@@ -4109,20 +4109,11 @@ case OP_Delete: {
   i64 iKey;
   VdbeCursor *pC;
 
-  iKey = 0;
   assert( pOp->p1>=0 && pOp->p1<p->nCursor );
   pC = p->apCsr[pOp->p1];
   assert( pC!=0 );
   assert( pC->pCursor!=0 );  /* Only valid for real tables, no pseudotables */
-
-  /* If the update-hook will be invoked, set iKey to the rowid of the
-  ** row being deleted.
-  */
-  if( db->xUpdateCallback && pOp->p4.z ){
-    assert( pC->isTable );
-    assert( pC->rowidIsValid );  /* lastRowid set by previous OP_NotFound */
-    iKey = pC->lastRowid;
-  }
+  iKey = pC->lastRowid;      /* Only used for the update hook */
 
   /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or
   ** OP_Column on the same table without any intervening operations that
@@ -4140,7 +4131,7 @@ case OP_Delete: {
   pC->cacheStatus = CACHE_STALE;
 
   /* Invoke the update-hook if required. */
-  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
+  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z && pC->isTable ){
     const char *zDb = db->aDb[pC->iDb].zName;
     const char *zTbl = pOp->p4.z;
     db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, iKey);
index 8b57c739715b38015a80958470f3794c3bdeac4b..1c8ab7d86e4b7a0deeddfd6b0341cfe2a37f0597 100644 (file)
@@ -1654,6 +1654,10 @@ do_execsql_test  4.19.4 { SELECT * FROM t5 } {}
 # of the special case-independent names "rowid", "oid", or "_rowid_" in
 # place of a column name.
 #
+# EVIDENCE-OF: R-06726-07466 A column name can be any of the names
+# defined in the CREATE TABLE statement or one of the following special
+# identifiers: "ROWID", "OID", or "_ROWID_".
+#
 drop_all_tables
 do_execsql_test 5.1.0 {
   CREATE TABLE t1(x, y);
@@ -1678,6 +1682,10 @@ do_createtable_tests 5.1 {
 # explicitly declared column and cannot be used to retrieve the integer
 # rowid value.
 #
+# EVIDENCE-OF: R-44615-33286 The special identifiers only refer to the
+# row key if the CREATE TABLE statement does not define a real column
+# with the same name.
+#
 do_execsql_test 5.2.0 {
   CREATE TABLE t2(oid, b);
   CREATE TABLE t3(a, _rowid_);
index 6346cc77a7a8239611ad84a4174011f4febdd71a..a186da3aa7c1590721dc2ffac19178f33db30e19 100644 (file)
@@ -135,9 +135,11 @@ do_test hook-4.1.1 {
   }
   execsql {
     CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+    CREATE TABLE t1w(a INT PRIMARY KEY, b) WITHOUT ROWID;
     INSERT INTO t1 VALUES(1, 'one');
     INSERT INTO t1 VALUES(2, 'two');
     INSERT INTO t1 VALUES(3, 'three');
+    INSERT INTO t1w SELECT * FROM t1;
   }
   db update_hook [list lappend ::update_hook]
 } {}
@@ -159,6 +161,20 @@ do_test hook-4.1.2 {
     DELETE main t1 4 \
 ]
 
+# EVIDENCE-OF: R-61808-14344 The sqlite3_update_hook() interface does
+# not fire callbacks for changes to a WITHOUT ROWID table.
+#
+do_test hook-4.1.2w {
+  set ::update_hook {}
+  execsql {
+    INSERT INTO t1w VALUES(4, 'four');
+    DELETE FROM t1w WHERE b = 'two';
+    UPDATE t1w SET b = '' WHERE a = 1 OR a = 3;
+    DELETE FROM t1w WHERE 1; -- Avoid the truncate optimization (for now)
+  }
+  set ::update_hook
+} {}
+
 ifcapable trigger {
   # Update hook is not invoked for changes to sqlite_master
   #