Fix a crash caused by adding a trigger to a shared-schema and then deleting it
using a different connection. (CVS 2873) FossilOrigin-Name: 19f93e135f1ff4f987d14afe74b955e119904017
This commit is contained in:
parent
0739723d76
commit
aaf22685d7
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\san\salignment\sproblem\sin\sthe\ssqlite3OsRandomSeed().\s\sTicket\s#1584.\s(CVS\s2872)
|
||||
D 2006-01-06T14:46:47
|
||||
C Fix\sa\scrash\scaused\sby\sadding\sa\strigger\sto\sa\sshared-schema\sand\sthen\sdeleting\sit\nusing\sa\sdifferent\sconnection.\s(CVS\s2873)
|
||||
D 2006-01-06T15:03:48
|
||||
F Makefile.in c79fbdaa264c6afcd435f2fb492551de5a8cf80d
|
||||
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -69,7 +69,7 @@ F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
|
||||
F src/select.c a60e5c7fad9ce7adc78d9eb32a0a89dd5acd04fb
|
||||
F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
|
||||
F src/sqlite.h.in ba3a29daa6a16e054191ccb384a981964e882a1d
|
||||
F src/sqliteInt.h 9b89651a99687e25bdab1e4e33b7dcadcd890283
|
||||
F src/sqliteInt.h 8e28cfdaf55761f054904c9a5c573e90b96e2433
|
||||
F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
|
||||
F src/tclsqlite.c 42151e6c78502277be77b88c00535d53ce89b917
|
||||
F src/test1.c 8e62d29dbf511b603dee63af886c43fa83d5a680
|
||||
@ -79,7 +79,7 @@ F src/test4.c a8fd681e139e1c61f22a77d07fc3a99cb28fff3f
|
||||
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
|
||||
F src/test6.c 2c195d0734f8b3517331f62c088bf6cede3818a5
|
||||
F src/tokenize.c 7a3a3d3cc734f684a77c4dfd09eb46fcee25394c
|
||||
F src/trigger.c 858c0a4974035b002fd2192399c6076ac7b75e1f
|
||||
F src/trigger.c 13c449e61cb2c831e07b9fd7175d0c16dcbb28ac
|
||||
F src/update.c c72e9cbbc0adf8d728c1c39ace03d4adb29b5cfb
|
||||
F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71
|
||||
F src/util.c 23d70b1f7e88a603d4baf28ac9592d38f60f2605
|
||||
@ -220,7 +220,7 @@ F test/select4.test c239f516aa31f42f2ef7c6d7cd01105f08f934ca
|
||||
F test/select5.test 07a90ab3c7e3f0a241a9cdea1d997b2c8a89ff0b
|
||||
F test/select6.test f459a19bdac0501c4d3eb1a4df4b7a76f1bb8ad4
|
||||
F test/select7.test 1bf795b948c133a15a2a5e99d3270e652ec58ce6
|
||||
F test/shared.test eb6b9ac456f60ed485b9ca5873d563abacae815a
|
||||
F test/shared.test 0fc3ba42901d31a9c0c48edbbe6cc61008438b16
|
||||
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
|
||||
F test/subquery.test e6de53332c0301b3cfa34edc3f3cd5fa1e859efd
|
||||
F test/subselect.test 2d13fb7f450db3595adcdd24079a0dd1d2d6abc2
|
||||
@ -335,7 +335,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P 6676c7031d81202ad702142ecf9e64f14d94d968
|
||||
R 1b60a9ed7b0ca6bc19ad7d05130da53f
|
||||
U drh
|
||||
Z 4997b116ed1a6eabde161c270985eda0
|
||||
P 373b56f0048fd6a1946a97acfcca40fd12f7d572
|
||||
R f298cefe96bf8aa08947c68d7cf6500d
|
||||
U danielk1977
|
||||
Z 0630f893c341afffaad594ffa4fb7ae6
|
||||
|
@ -1 +1 @@
|
||||
373b56f0048fd6a1946a97acfcca40fd12f7d572
|
||||
19f93e135f1ff4f987d14afe74b955e119904017
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.451 2006/01/06 12:03:19 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.452 2006/01/06 15:03:48 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -1297,8 +1297,6 @@ struct AuthContext {
|
||||
struct Trigger {
|
||||
char *name; /* The name of the trigger */
|
||||
char *table; /* The table or view to which the trigger applies */
|
||||
//u8 iDb; /* Database containing this trigger */
|
||||
u8 iTabDb; /* Database containing Trigger.table */
|
||||
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */
|
||||
u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */
|
||||
Expr *pWhen; /* The WHEN clause of the expresion (may be NULL) */
|
||||
@ -1306,7 +1304,8 @@ struct Trigger {
|
||||
the <column-list> is stored here */
|
||||
int foreach; /* One of TK_ROW or TK_STATEMENT */
|
||||
Token nameToken; /* Token containing zName. Use during parsing only */
|
||||
DbSchema *pSchema;
|
||||
DbSchema *pSchema; /* Schema containing the trigger */
|
||||
DbSchema *pTabSchema; /* Schema containing the table */
|
||||
TriggerStep *step_list; /* Link list of trigger program steps */
|
||||
Trigger *pNext; /* Next trigger associated with the table */
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ void sqlite3BeginTrigger(
|
||||
zName = 0;
|
||||
pTrigger->table = sqliteStrDup(pTableName->a[0].zName);
|
||||
pTrigger->pSchema = db->aDb[iDb].pSchema;
|
||||
pTrigger->iTabDb = iTabDb;
|
||||
pTrigger->pTabSchema = pTab->pSchema;
|
||||
pTrigger->op = op;
|
||||
pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;
|
||||
pTrigger->pWhen = sqlite3ExprDup(pWhen);
|
||||
@ -249,6 +249,7 @@ void sqlite3FinishTrigger(
|
||||
}
|
||||
|
||||
if( db->init.busy ){
|
||||
int n;
|
||||
Table *pTab;
|
||||
Trigger *pDel;
|
||||
pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash,
|
||||
@ -257,7 +258,8 @@ void sqlite3FinishTrigger(
|
||||
assert( sqlite3Tsd()->mallocFailed && pDel==pTrig );
|
||||
goto triggerfinish_cleanup;
|
||||
}
|
||||
pTab = sqlite3LocateTable(pParse,pTrig->table,db->aDb[pTrig->iTabDb].zName);
|
||||
n = strlen(pTrig->table) + 1;
|
||||
pTab = sqlite3HashFind(&pTrig->pTabSchema->tblHash, pTrig->table, n);
|
||||
assert( pTab!=0 );
|
||||
pTrig->pNext = pTab->pTrigger;
|
||||
pTab->pTrigger = pTrig;
|
||||
@ -467,7 +469,8 @@ drop_trigger_cleanup:
|
||||
** is set on.
|
||||
*/
|
||||
static Table *tableOfTrigger(sqlite3 *db, Trigger *pTrigger){
|
||||
return sqlite3FindTable(db,pTrigger->table,db->aDb[pTrigger->iTabDb].zName);
|
||||
int n = strlen(pTrigger->table) + 1;
|
||||
return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the SELECT statement.
|
||||
#
|
||||
# $Id: shared.test,v 1.4 2006/01/06 13:00:30 danielk1977 Exp $
|
||||
# $Id: shared.test,v 1.5 2006/01/06 15:03:48 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -31,8 +31,9 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
|
||||
# write-transaction, including a simple test to ensure the
|
||||
# external locking protocol is still working.
|
||||
# shared-3.*: Simple test of read-uncommitted mode.
|
||||
#
|
||||
# shared-4.*: Check that the schema is locked and unlocked correctly.
|
||||
# shared-5.*: Test that creating/dropping schema items works when databases
|
||||
# are attached in different orders to different handles.
|
||||
#
|
||||
|
||||
do_test shared-1.1 {
|
||||
@ -360,9 +361,55 @@ do_test shared-4.4.5 {
|
||||
list $rc $msg
|
||||
} {1 {(6) database schema is locked: test}}
|
||||
|
||||
|
||||
catch {db2 close}
|
||||
catch {db close}
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Tests shared-5.*
|
||||
#
|
||||
foreach db [list test.db test1.db test2.db test3.db] {
|
||||
file delete -force $db ${db}-journal
|
||||
}
|
||||
do_test shared-5.1.1 {
|
||||
sqlite3 db1 test.db
|
||||
sqlite3 db2 test.db
|
||||
execsql {
|
||||
ATTACH 'test1.db' AS test1;
|
||||
ATTACH 'test2.db' AS test2;
|
||||
ATTACH 'test3.db' AS test3;
|
||||
} db1
|
||||
execsql {
|
||||
ATTACH 'test3.db' AS test3;
|
||||
ATTACH 'test2.db' AS test2;
|
||||
ATTACH 'test1.db' AS test1;
|
||||
} db2
|
||||
} {}
|
||||
do_test shared-5.1.2 {
|
||||
execsql {
|
||||
CREATE TABLE test1.t1(a, b);
|
||||
CREATE INDEX test1.i1 ON t1(a, b);
|
||||
CREATE VIEW test1.v1 AS SELECT * FROM t1;
|
||||
CREATE TRIGGER test1.trig1 AFTER INSERT ON t1 BEGIN
|
||||
INSERT INTO t1 VALUES(new.a, new.b);
|
||||
END;
|
||||
} db1
|
||||
execsql {
|
||||
DROP INDEX i1;
|
||||
DROP VIEW v1;
|
||||
DROP TRIGGER trig1;
|
||||
DROP TABLE t1;
|
||||
} db2
|
||||
} {}
|
||||
do_test shared-5.1.2 {
|
||||
execsql {
|
||||
SELECT * FROM sqlite_master UNION ALL SELECT * FROM test1.sqlite_master
|
||||
} db1
|
||||
} {}
|
||||
|
||||
catch {db1 close}
|
||||
catch {db2 close}
|
||||
|
||||
finish_test
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user