diff options
author | danielk1977 <danielk1977@noemail.net> | 2002-06-11 02:25:40 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2002-06-11 02:25:40 +0000 |
commit | 6f34903e85f22edca3b3ac7649182fafea0643cb (patch) | |
tree | c92d0d3b3ea651835a4dba4bc64099308b6e9e88 /src/trigger.c | |
parent | 28f4b6885b32acda86b6d014430b246ad20c4336 (diff) | |
download | sqlite-6f34903e85f22edca3b3ac7649182fafea0643cb.tar.gz sqlite-6f34903e85f22edca3b3ac7649182fafea0643cb.zip |
Add RAISE() function, which allows more advanced flow-control in trigger programs (ticket #55) (CVS 614)
FossilOrigin-Name: d4a2fb10067203a0d49317db747759872e62927e
Diffstat (limited to 'src/trigger.c')
-rw-r--r-- | src/trigger.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/trigger.c b/src/trigger.c index cf31f1727..95e8fc9f8 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -480,14 +480,18 @@ static int codeTriggerProgram( pParse->trigStack->orconf = orconf; switch( pTriggerStep->op ){ case TK_SELECT: { - sqliteSelect(pParse, pTriggerStep->pSelect, SRT_Discard, 0, 0, 0, 0); + Select * ss = sqliteSelectDup(pTriggerStep->pSelect); + assert(ss); + assert(ss->pSrc); + sqliteSelect(pParse, ss, SRT_Discard, 0, 0, 0, 0); + sqliteSelectDelete(ss); break; } case TK_UPDATE: { sqliteVdbeAddOp(pParse->pVdbe, OP_ListPush, 0, 0); sqliteUpdate(pParse, &pTriggerStep->target, - sqliteExprListDup(pTriggerStep->pExprList), - sqliteExprDup(pTriggerStep->pWhere), orconf); + sqliteExprListDup(pTriggerStep->pExprList), + sqliteExprDup(pTriggerStep->pWhere), orconf); sqliteVdbeAddOp(pParse->pVdbe, OP_ListPop, 0, 0); break; } @@ -543,7 +547,8 @@ int sqliteCodeRowTrigger( Table *pTab, /* The table to code triggers from */ int newIdx, /* The indice of the "new" row to access */ int oldIdx, /* The indice of the "old" row to access */ - int orconf /* ON CONFLICT policy */ + int orconf, /* ON CONFLICT policy */ + int ignoreJump /* Instruction to jump to for RAISE(IGNORE) */ ){ Trigger * pTrigger; TriggerStack * pTriggerStack; @@ -588,6 +593,7 @@ int sqliteCodeRowTrigger( pTriggerStack->oldIdx = oldIdx; pTriggerStack->pTab = pTab; pTriggerStack->pNext = pParse->trigStack; + pTriggerStack->ignoreJump = ignoreJump; pParse->trigStack = pTriggerStack; /* code the WHEN clause */ @@ -735,14 +741,14 @@ void sqliteViewTriggers( sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0); sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, - pTab, newIdx, oldIdx, orconf); + pTab, newIdx, oldIdx, orconf, endOfLoop); sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, - pTab, newIdx, oldIdx, orconf); + pTab, newIdx, oldIdx, orconf, endOfLoop); }else{ sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, oldIdx, - orconf); + orconf, endOfLoop); sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, oldIdx, - orconf); + orconf, endOfLoop); } sqliteVdbeAddOp(v, OP_Next, oldIdx, startOfLoop); |