1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Simplification of the DROP TRIGGER logic using sqlite3NestedParse() instead

of hand-coded VDBE code.  This is a manual cherry-pick of the key change from
check-in [c80bbf14b365d].

FossilOrigin-Name: 8021b4c8139ba56d6b1e2e26aeec4f9bf77f37c9
This commit is contained in:
drh
2015-12-09 16:26:38 +00:00
parent 72ea29d7ae
commit 8c8dddc904
3 changed files with 11 additions and 30 deletions

View File

@@ -559,31 +559,12 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
*/
assert( pTable!=0 );
if( (v = sqlite3GetVdbe(pParse))!=0 ){
int base;
static const int iLn = VDBE_OFFSET_LINENO(2);
static const VdbeOpList dropTrigger[] = {
{ OP_Rewind, 0, ADDR(9), 0},
{ OP_String8, 0, 1, 0}, /* 1 */
{ OP_Column, 0, 1, 2},
{ OP_Ne, 2, ADDR(8), 1},
{ OP_String8, 0, 1, 0}, /* 4: "trigger" */
{ OP_Column, 0, 0, 2},
{ OP_Ne, 2, ADDR(8), 1},
{ OP_Delete, 0, 0, 0},
{ OP_Next, 0, ADDR(1), 0}, /* 8 */
};
sqlite3BeginWriteOperation(pParse, 0, iDb);
sqlite3OpenMasterTable(pParse, iDb);
base = sqlite3VdbeAddOpList(v, ArraySize(dropTrigger), dropTrigger, iLn);
sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT);
sqlite3VdbeChangeP4(v, base+4, "trigger", P4_STATIC);
sqlite3NestedParse(pParse,
"DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'",
db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pTrigger->zName
);
sqlite3ChangeCookie(pParse, iDb);
sqlite3VdbeAddOp2(v, OP_Close, 0, 0);
sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);
if( pParse->nMem<3 ){
pParse->nMem = 3;
}
}
}