mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix a problem with shared-schemas and temp triggers. (CVS 2901)
FossilOrigin-Name: 9c18a1ce1e7ff6a02eb0f9ce344cab9660819740
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C If\scompiled\swith\smemory-debugging,\swrite\sgarbage\sto\smemory\swhen\sit\sis\sfreed.\sFix\sfor\s#1594.\s(CVS\s2900)
|
||||
D 2006-01-10T07:14:23
|
||||
C Fix\sa\sproblem\swith\sshared-schemas\sand\stemp\striggers.\s(CVS\s2901)
|
||||
D 2006-01-10T12:31:40
|
||||
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
|
||||
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@@ -70,7 +70,7 @@ F src/select.c acfeda959fe07eac04950d945ac7ec0518ef4b7d
|
||||
F src/server.c 42a2bd02eec5018098a96e08f7a923f4965a2b1d
|
||||
F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
|
||||
F src/sqlite.h.in 537bac9e9ef703695268aaad5c56b6bf64f815be
|
||||
F src/sqliteInt.h 073d84b12a07b25a31e08a3fd5115d44424511c3
|
||||
F src/sqliteInt.h 01703e82a73f0e4558f8862c35a4b287f587573c
|
||||
F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
|
||||
F src/tclsqlite.c d650bea0248fc0a310ddc2cb94273a3a5021fddf
|
||||
F src/test1.c 5f634ce9aa452dbcc362993c9612047df800216c
|
||||
@@ -82,7 +82,7 @@ F src/test6.c 74d91b487c68154156eded457925d96aa2a3fdbb
|
||||
F src/test7.c bfe36c62cae189509660acfeeb891ffb9da8ef0c
|
||||
F src/test_async.c 9733deb7fefa18a3596e5234c1ef05b4685c6ad7
|
||||
F src/tokenize.c 196486012c871cdcad6cc84a820cc988603f1b9d
|
||||
F src/trigger.c c515afa5fe964e9854c54dc66dde179a90d0cfe3
|
||||
F src/trigger.c 883b5f3b97137fbe417e3337c3fa20ac8e9c1ae5
|
||||
F src/update.c e09da54cb8e042f89f4177f4ef879b594d8ab946
|
||||
F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71
|
||||
F src/util.c 264083f0de25b92c362e88a23402cc76e93613ba
|
||||
@@ -225,7 +225,7 @@ F test/select5.test 07a90ab3c7e3f0a241a9cdea1d997b2c8a89ff0b
|
||||
F test/select6.test f459a19bdac0501c4d3eb1a4df4b7a76f1bb8ad4
|
||||
F test/select7.test 1bf795b948c133a15a2a5e99d3270e652ec58ce6
|
||||
F test/server1.test 95c497a8b4c35599768d6a93b168cc272e83fee3
|
||||
F test/shared.test 413289e177e73c844cfc9896b6d78e0f2e62d963
|
||||
F test/shared.test b375b17588568eb4080005167e7c717539f7574c
|
||||
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
|
||||
F test/subquery.test e6de53332c0301b3cfa34edc3f3cd5fa1e859efd
|
||||
F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
|
||||
@@ -340,7 +340,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P 8719f880a395db8be65ea45615d8e55985306f1e
|
||||
R b2a531b43730473163449399fcf314d6
|
||||
P bd02a6faefa3602d0b93d54bc57809a2222d5903
|
||||
R b3a5083bd04048926b4b9deff43305a7
|
||||
U danielk1977
|
||||
Z 8cdee85eddce52cc29622696f9c74204
|
||||
Z 4a23a33bfc9bd6ad6c92d55f05958140
|
||||
|
@@ -1 +1 @@
|
||||
bd02a6faefa3602d0b93d54bc57809a2222d5903
|
||||
9c18a1ce1e7ff6a02eb0f9ce344cab9660819740
|
@@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.457 2006/01/09 23:40:25 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.458 2006/01/10 12:31:40 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@@ -674,6 +674,8 @@ struct CollSeq {
|
||||
** is generated for each row of the table. Table.hasPrimKey is true if
|
||||
** the table has any PRIMARY KEY, INTEGER or otherwise.
|
||||
**
|
||||
** TODO: This comment is out of date. Table.iDb no longer exists.
|
||||
**
|
||||
** Table.tnum is the page number for the root BTree page of the table in the
|
||||
** database file. If Table.iDb is the index of the database table backend
|
||||
** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
|
||||
@@ -694,7 +696,6 @@ struct Table {
|
||||
int tnum; /* Root BTree node for this table (see note above) */
|
||||
Select *pSelect; /* NULL for tables. Points to definition if a view. */
|
||||
u8 readOnly; /* True if this table should not be written by the user */
|
||||
// u8 iDb; /* Index into sqlite.aDb[] of the backend for this table */
|
||||
u8 isTransient; /* True if automatically deleted when VDBE finishes */
|
||||
u8 hasPrimKey; /* True if there exists a primary key */
|
||||
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
|
||||
@@ -806,7 +807,7 @@ struct KeyInfo {
|
||||
u8 enc; /* Text encoding - one of the TEXT_Utf* values */
|
||||
u8 incrKey; /* Increase 2nd key by epsilon before comparison */
|
||||
int nField; /* Number of entries in aColl[] */
|
||||
u8 *aSortOrder; /* If defined an aSortOrder[i] is true, sort DESC */
|
||||
u8 *aSortOrder; /* If defined and aSortOrder[i] is true, sort DESC */
|
||||
CollSeq *aColl[1]; /* Collating sequence for each term of the key */
|
||||
};
|
||||
|
||||
@@ -845,10 +846,9 @@ struct Index {
|
||||
int tnum; /* Page containing root of this index in database file */
|
||||
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
|
||||
u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */
|
||||
// u8 iDb; /* Index in sqlite.aDb[] of where this index is stored */
|
||||
char *zColAff; /* String defining the affinity of each column */
|
||||
Index *pNext; /* The next index associated with the same table */
|
||||
Schema *pSchema;
|
||||
Schema *pSchema; /* Schema containing this index */
|
||||
KeyInfo keyInfo; /* Info on how to order keys. MUST BE LAST */
|
||||
};
|
||||
|
||||
@@ -958,7 +958,6 @@ struct AggInfo {
|
||||
struct Expr {
|
||||
u8 op; /* Operation performed by this node */
|
||||
char affinity; /* The affinity of the column or 0 if not a column */
|
||||
//u8 iDb; /* Database referenced by this expression */
|
||||
u8 flags; /* Various flags. See below */
|
||||
CollSeq *pColl; /* The collation type of the column or 0 */
|
||||
Expr *pLeft, *pRight; /* Left and right subnodes */
|
||||
|
@@ -740,8 +740,7 @@ int sqlite3CodeRowTrigger(
|
||||
int orconf, /* ON CONFLICT policy */
|
||||
int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */
|
||||
){
|
||||
Trigger *pTrigger;
|
||||
TriggerStack *pStack;
|
||||
Trigger *p;
|
||||
TriggerStack trigStackEntry;
|
||||
|
||||
assert(op == TK_UPDATE || op == TK_INSERT || op == TK_DELETE);
|
||||
@@ -749,21 +748,20 @@ int sqlite3CodeRowTrigger(
|
||||
|
||||
assert(newIdx != -1 || oldIdx != -1);
|
||||
|
||||
pTrigger = pTab->pTrigger;
|
||||
while( pTrigger ){
|
||||
for(p=pTab->pTrigger; p; p=p->pNext){
|
||||
int fire_this = 0;
|
||||
|
||||
/* determine whether we should code this trigger */
|
||||
if( pTrigger->op == op && pTrigger->tr_tm == tr_tm ){
|
||||
/* Determine whether we should code this trigger */
|
||||
if(
|
||||
p->op==op &&
|
||||
p->tr_tm==tr_tm &&
|
||||
(p->pSchema==p->pTabSchema || p->pSchema==pParse->db->aDb[1].pSchema) &&
|
||||
(op!=TK_UPDATE||!p->pColumns||checkColumnOverLap(p->pColumns,pChanges))
|
||||
){
|
||||
TriggerStack *pS; /* Pointer to trigger-stack entry */
|
||||
for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext);
|
||||
if( !pS ){
|
||||
fire_this = 1;
|
||||
for(pStack=pParse->trigStack; pStack; pStack=pStack->pNext){
|
||||
if( pStack->pTrigger==pTrigger ){
|
||||
fire_this = 0;
|
||||
}
|
||||
}
|
||||
if( op == TK_UPDATE && pTrigger->pColumns &&
|
||||
!checkColumnOverLap(pTrigger->pColumns, pChanges) ){
|
||||
fire_this = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,18 +775,18 @@ int sqlite3CodeRowTrigger(
|
||||
sNC.pParse = pParse;
|
||||
|
||||
/* Push an entry on to the trigger stack */
|
||||
trigStackEntry.pTrigger = pTrigger;
|
||||
trigStackEntry.pTrigger = p;
|
||||
trigStackEntry.newIdx = newIdx;
|
||||
trigStackEntry.oldIdx = oldIdx;
|
||||
trigStackEntry.pTab = pTab;
|
||||
trigStackEntry.pNext = pParse->trigStack;
|
||||
trigStackEntry.ignoreJump = ignoreJump;
|
||||
pParse->trigStack = &trigStackEntry;
|
||||
sqlite3AuthContextPush(pParse, &sContext, pTrigger->name);
|
||||
sqlite3AuthContextPush(pParse, &sContext, p->name);
|
||||
|
||||
/* code the WHEN clause */
|
||||
endTrigger = sqlite3VdbeMakeLabel(pParse->pVdbe);
|
||||
whenExpr = sqlite3ExprDup(pTrigger->pWhen);
|
||||
whenExpr = sqlite3ExprDup(p->pWhen);
|
||||
if( sqlite3ExprResolveNames(&sNC, whenExpr) ){
|
||||
pParse->trigStack = trigStackEntry.pNext;
|
||||
sqlite3ExprDelete(whenExpr);
|
||||
@@ -797,7 +795,7 @@ int sqlite3CodeRowTrigger(
|
||||
sqlite3ExprIfFalse(pParse, whenExpr, endTrigger, 1);
|
||||
sqlite3ExprDelete(whenExpr);
|
||||
|
||||
codeTriggerProgram(pParse, pTrigger->step_list, orconf);
|
||||
codeTriggerProgram(pParse, p->step_list, orconf);
|
||||
|
||||
/* Pop the entry off the trigger stack */
|
||||
pParse->trigStack = trigStackEntry.pNext;
|
||||
@@ -805,7 +803,6 @@ int sqlite3CodeRowTrigger(
|
||||
|
||||
sqlite3VdbeResolveLabel(pParse->pVdbe, endTrigger);
|
||||
}
|
||||
pTrigger = pTrigger->pNext;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# $Id: shared.test,v 1.8 2006/01/09 16:12:05 danielk1977 Exp $
|
||||
# $Id: shared.test,v 1.9 2006/01/10 12:31:41 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -604,6 +604,59 @@ do_test shared-8.2.3 {
|
||||
|
||||
catch {db close}
|
||||
catch {db2 close}
|
||||
file delete -force test.db test2.db
|
||||
|
||||
if 0 {
|
||||
|
||||
do_test shared-9.1 {
|
||||
sqlite3 db test.db
|
||||
} {}
|
||||
do_test shared-9.2 {
|
||||
execsql {CREATE TABLE t1(a);}
|
||||
} {}
|
||||
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
|
||||
do_test shared-9.3 {
|
||||
execsql {
|
||||
CREATE TABLE t5(a);
|
||||
INSERT INTO t5 VALUES('one');
|
||||
} db
|
||||
} {}
|
||||
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# The following tests - shared-9.* - test interactions between TEMP triggers
|
||||
# and shared-schemas.
|
||||
#
|
||||
ifcapable trigger&&tempdb {
|
||||
|
||||
do_test shared-9.1 {
|
||||
sqlite3 db test.db
|
||||
sqlite3 db2 test.db
|
||||
execsql {
|
||||
CREATE TABLE abc(a, b, c);
|
||||
CREATE TABLE abc_mirror(a, b, c);
|
||||
CREATE TEMP TRIGGER BEFORE INSERT ON abc BEGIN
|
||||
INSERT INTO abc_mirror(a, b, c) VALUES(new.a, new.b, new.c);
|
||||
END;
|
||||
INSERT INTO abc VALUES(1, 2, 3);
|
||||
SELECT * FROM abc_mirror;
|
||||
}
|
||||
} {1 2 3}
|
||||
do_test shared-9.2 {
|
||||
execsql {
|
||||
INSERT INTO abc VALUES(4, 5, 6);
|
||||
SELECT * FROM abc_mirror;
|
||||
} db2
|
||||
} {1 2 3}
|
||||
do_test shared-9.3 {
|
||||
db close
|
||||
db2 close
|
||||
} {}
|
||||
|
||||
} ; # End shared-9.*
|
||||
|
||||
finish_test
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
|
Reference in New Issue
Block a user