Fix an assertion failure due to interaction between the count_changes pragma and triggers. (CVS 2187)

FossilOrigin-Name: 6c7bec1b3aee0287e30f43c1d6a7b67b1c47e774
This commit is contained in:
danielk1977 2005-01-10 02:48:49 +00:00
parent 49766d6cd0
commit cc6bd38380
5 changed files with 72 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Tcl\sinterface\sdoes\sas\ssqlite3\sor\sas\ssqlite.\s\sA\scompile-time\soption\sallows\r\nduel\slinking.\s\sAlso\sfix\sa\sbug\sin\sthe\spragma\schange\sfrom\searlier\stoday.\s(CVS\s2186) C Fix\san\sassertion\sfailure\sdue\sto\sinteraction\sbetween\sthe\scount_changes\spragma\sand\striggers.\s(CVS\s2187)
D 2005-01-08T18:42:28 D 2005-01-10T02:48:49
F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4 F Makefile.in ecf441ac5ca1ccfc8748a8a9537706e69893dfa4
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@ -34,12 +34,12 @@ F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
F src/build.c af1296e8a21a406b4f4c4f1e1365e075071219f3 F src/build.c af1296e8a21a406b4f4c4f1e1365e075071219f3
F src/cursor.c f883813759742068890b1f699335872bfa8fdf41 F src/cursor.c f883813759742068890b1f699335872bfa8fdf41
F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
F src/delete.c 5e5bcf0092b146a399e571d1e704b3b22633d2d0 F src/delete.c 32277d2834e36c7538c047f14d643751c256c73b
F src/expr.c d718509e56f58b06bc5f9b46afb295675334d544 F src/expr.c d718509e56f58b06bc5f9b46afb295675334d544
F src/func.c b668e5ad043176049454c95a6a780367a0e8f6bb F src/func.c b668e5ad043176049454c95a6a780367a0e8f6bb
F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5 F src/hash.c a97721a55440b7bea31ffe471bb2f6b4123cddd5
F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
F src/insert.c 0b9077c6752530e9919a8c84375cfa2c4652260a F src/insert.c f6b69e40e8938f63a2368cbcb5087a56098cf632
F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
F src/main.c a05e1e50406d2776272c1470077136f63866bbe2 F src/main.c a05e1e50406d2776272c1470077136f63866bbe2
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
@ -161,7 +161,7 @@ F test/pager.test 394455707a079804e8a4e431d12edce831a065f0
F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85 F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85
F test/pagesize.test 1b826d1608fd86d2303aa895b5586052ad07eba1 F test/pagesize.test 1b826d1608fd86d2303aa895b5586052ad07eba1
F test/pragma.test 3673c0eb920cf2489410dc58f9875384cf4acdce F test/pragma.test c1b4cdb2545131e4adec3250d02544688c6a5c9d
F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57 F test/printf.test 92ba4c510b4fc61120ffa4a01820446ed917ae57
F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x F test/progress.test 5ddba78cb6011fba36093973cfb3ac473b8fb96a x
F test/quick.test 91e5b8ae6663dc9e3e754b271f0384f0cae706e6 F test/quick.test 91e5b8ae6663dc9e3e754b271f0384f0cae706e6
@ -263,7 +263,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746 F www/whentouse.tcl c3b50d3ac31c54be2a1af9b488a89d22f1e6e746
P 0a90eaf398aa4a689cd8326cd017951513ca748a P ad10953799f3aa15fde41cbbd5911a3b56c326ec
R c4f4620650d61e94b490965cc36efb0b R 1ac4cd5c08a83609a7da947b3ea99143
U drh U danielk1977
Z 49fbfa0204d130bf85624d3aa736264c Z 66f70bfca0a624fd768df4e664b868f3

View File

@ -1 +1 @@
ad10953799f3aa15fde41cbbd5911a3b56c326ec 6c7bec1b3aee0287e30f43c1d6a7b67b1c47e774

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements. ** in order to generate code for DELETE FROM statements.
** **
** $Id: delete.c,v 1.94 2004/12/25 01:03:14 drh Exp $ ** $Id: delete.c,v 1.95 2005/01/10 02:48:49 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@ -329,7 +329,7 @@ void sqlite3DeleteFrom(
** generating code because of a call to sqlite3NestedParse(), do not ** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function. ** invoke the callback function.
*/ */
if( db->flags & SQLITE_CountRows && pParse->nested==0 ){ if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){
sqlite3VdbeAddOp(v, OP_Callback, 1, 0); sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetNumCols(v, 1);
sqlite3VdbeSetColName(v, 0, "rows deleted", P3_STATIC); sqlite3VdbeSetColName(v, 0, "rows deleted", P3_STATIC);

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite. ** to handle INSERT statements in SQLite.
** **
** $Id: insert.c,v 1.128 2004/12/07 15:41:49 drh Exp $ ** $Id: insert.c,v 1.129 2005/01/10 02:48:49 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@ -693,7 +693,7 @@ void sqlite3Insert(
** generating code because of a call to sqlite3NestedParse(), do not ** generating code because of a call to sqlite3NestedParse(), do not
** invoke the callback function. ** invoke the callback function.
*/ */
if( db->flags & SQLITE_CountRows && pParse->nested==0 ){ if( db->flags & SQLITE_CountRows && pParse->nested==0 && !pParse->trigStack ){
sqlite3VdbeAddOp(v, OP_MemLoad, iCntMem, 0); sqlite3VdbeAddOp(v, OP_MemLoad, iCntMem, 0);
sqlite3VdbeAddOp(v, OP_Callback, 1, 0); sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetNumCols(v, 1);

View File

@ -12,7 +12,7 @@
# #
# This file implements tests for the PRAGMA command. # This file implements tests for the PRAGMA command.
# #
# $Id: pragma.test,v 1.30 2005/01/08 15:44:26 drh Exp $ # $Id: pragma.test,v 1.31 2005/01/10 02:48:49 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -25,7 +25,11 @@ source $testdir/tester.tcl
# pragma-4.*: Test cache_size and default_cache_size on attached db. # pragma-4.*: Test cache_size and default_cache_size on attached db.
# pragma-5.*: Test that pragma synchronous may not be used inside of a # pragma-5.*: Test that pragma synchronous may not be used inside of a
# transaction. # transaction.
# pragma-6.*: Test schema-query pragmas.
# pragma-7.*: Miscellaneous tests.
# pragma-8.*: Test user_version and schema_version pragmas.
# pragma-9.*: Test temp_store and temp_store_directory. # pragma-9.*: Test temp_store and temp_store_directory.
# pragma-10.*: Test the count_changes pragma in the presence of triggers.
# #
# Delete the preexisting database to avoid the special setup # Delete the preexisting database to avoid the special setup
@ -654,4 +658,57 @@ do_test pragma-9.10 {
} {1 {no such table: temp_store_directory_test}} } {1 {no such table: temp_store_directory_test}}
} ;# ifcapable pager_pragmas } ;# ifcapable pager_pragmas
ifcapable trigger {
do_test pragma-10.0 {
catchsql {
DROP TABLE main.t1;
}
execsql {
PRAGMA count_changes = 1;
CREATE TABLE t1(a PRIMARY KEY);
CREATE TABLE t1_mirror(a);
CREATE TABLE t1_mirror2(a);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1 BEGIN
INSERT INTO t1_mirror VALUES(new.a);
END;
CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN
INSERT INTO t1_mirror2 VALUES(new.a);
END;
CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN
UPDATE t1_mirror SET a = new.a WHERE a = old.a;
END;
CREATE TRIGGER t1_au AFTER UPDATE ON t1 BEGIN
UPDATE t1_mirror2 SET a = new.a WHERE a = old.a;
END;
CREATE TRIGGER t1_bd BEFORE DELETE ON t1 BEGIN
DELETE FROM t1_mirror WHERE a = old.a;
END;
CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN
DELETE FROM t1_mirror2 WHERE a = old.a;
END;
}
} {}
do_test pragma-10.1 {
execsql {
INSERT INTO t1 VALUES(randstr(10,10));
}
} {1}
do_test pragma-10.2 {
execsql {
UPDATE t1 SET a = randstr(10,10);
}
} {1}
do_test pragma-10.3 {
execsql {
DELETE FROM t1;
}
} {1}
} ;# ifcapable trigger
finish_test finish_test