mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Change the way SubProgram objects are deleted so that the code is the same for deletion and measurement.
FossilOrigin-Name: 00e55102a8309eb6df08ad4a8937ba02688bac62
This commit is contained in:
@@ -800,6 +800,7 @@ static TriggerPrg *codeRowTrigger(
|
||||
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
|
||||
|
||||
assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
|
||||
assert( pTop->pVdbe );
|
||||
|
||||
/* Allocate the TriggerPrg and SubProgram objects. To ensure that they
|
||||
** are freed if an error occurs, link them into the Parse.pTriggerPrg
|
||||
@@ -810,7 +811,7 @@ static TriggerPrg *codeRowTrigger(
|
||||
pTop->pTriggerPrg = pPrg;
|
||||
pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
|
||||
if( !pProgram ) return 0;
|
||||
pProgram->nRef = 1;
|
||||
sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);
|
||||
pPrg->pTrigger = pTrigger;
|
||||
pPrg->orconf = orconf;
|
||||
pPrg->aColmask[0] = 0xffffffff;
|
||||
@@ -944,8 +945,9 @@ void sqlite3CodeRowTriggerDirect(
|
||||
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
|
||||
** is a pointer to the sub-vdbe containing the trigger program. */
|
||||
if( pPrg ){
|
||||
int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));
|
||||
|
||||
sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);
|
||||
pPrg->pProgram->nRef++;
|
||||
sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);
|
||||
VdbeComment(
|
||||
(v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf)));
|
||||
@@ -955,7 +957,7 @@ void sqlite3CodeRowTriggerDirect(
|
||||
** invocation is disallowed if (a) the sub-program is really a trigger,
|
||||
** not a foreign key action, and (b) the flag to enable recursive triggers
|
||||
** is clear. */
|
||||
sqlite3VdbeChangeP5(v, (u8)(p->zName && !(pParse->db->flags&SQLITE_RecTriggers)));
|
||||
sqlite3VdbeChangeP5(v, (u8)bRecursive);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user