mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-21 13:38:01 +03:00
If a TEMP TRIGGER references an auxiliary schema, and that auxiliary schema
is detached, move the trigger to reference the TEMP schema before completing the detach, so that the trigger does not hold a dangling schema pointer. FossilOrigin-Name: 069c2f4c61f06211a8981abc412afcc1536ece13380b13a70aa99123f8f527cd
This commit is contained in:
13
src/attach.c
13
src/attach.c
@@ -299,6 +299,7 @@ static void detachFunc(
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
int i;
|
||||
Db *pDb = 0;
|
||||
HashElem *pEntry;
|
||||
char zErr[128];
|
||||
|
||||
UNUSED_PARAMETER(NotUsed);
|
||||
@@ -323,6 +324,18 @@ static void detachFunc(
|
||||
goto detach_error;
|
||||
}
|
||||
|
||||
/* If any TEMP triggers reference the schema being detached, move those
|
||||
** triggers to reference the TEMP schema itself. */
|
||||
assert( db->aDb[1].pSchema );
|
||||
pEntry = sqliteHashFirst(&db->aDb[1].pSchema->trigHash);
|
||||
while( pEntry ){
|
||||
Trigger *pTrig = (Trigger*)sqliteHashData(pEntry);
|
||||
if( pTrig->pTabSchema==pDb->pSchema ){
|
||||
pTrig->pTabSchema = pTrig->pSchema;
|
||||
}
|
||||
pEntry = sqliteHashNext(pEntry);
|
||||
}
|
||||
|
||||
sqlite3BtreeClose(pDb->pBt);
|
||||
pDb->pBt = 0;
|
||||
pDb->pSchema = 0;
|
||||
|
||||
Reference in New Issue
Block a user