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

Improved comments on the new code.

FossilOrigin-Name: a38f0c1d7c1d7635732ac370d8fbc7e6a2005378e4621da7bc4f51a2f99912d1
This commit is contained in:
drh
2021-01-30 21:55:38 +00:00
parent 1832f2921d
commit 28828c550f
4 changed files with 45 additions and 20 deletions

View File

@@ -739,10 +739,14 @@ Trigger *sqlite3TriggersExist(
for(p=pList; p; p=p->pNext){
if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){
mask |= p->tr_tm;
}else if( p->bReturning
&& (p->op==TK_RETURNING || (p->op!=TK_DELETE && op!=TK_DELETE)) ){
}else if( p->op==TK_RETURNING ){
/* The first time a RETURNING trigger is seen, the "op" value tells
** us what time of trigger it should be. */
p->op = op;
mask |= TRIGGER_AFTER;
}else if( p->bReturning && p->op==TK_INSERT && op==TK_UPDATE ){
/* Also fire a RETURNING trigger for INSERT on the UPDATE of an UPSERT */
mask |= TRIGGER_AFTER;
}
}
if( pMask ){
@@ -1216,13 +1220,19 @@ void sqlite3CodeRowTrigger(
assert( p->pSchema==p->pTabSchema
|| p->pSchema==pParse->db->aDb[1].pSchema );
/* Determine whether we should code this trigger */
if( (p->op==op || (p->bReturning && p->op!=TK_DELETE))
/* Determine whether we should code this trigger. One of two choices:
** 1. The trigger is an exact match to the current DML statement
** 2. This is a RETURNING trigger for INSERT but we are currently
** doing the UPDATE part of an UPSERT.
*/
if( (p->op==op || (p->bReturning && p->op==TK_INSERT && op==TK_UPDATE))
&& p->tr_tm==tr_tm
&& checkColumnOverlap(p->pColumns, pChanges)
){
u8 origOp = p->op;
p->op = op;
sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);
p->op = origOp;
}
}
}