1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Added FOR EACH ROW triggers functionality (CVS 562)

FossilOrigin-Name: 794bf67b6b36fce8854d5daff12f21dbb943240c
This commit is contained in:
danielk1977
2002-05-15 08:30:12 +00:00
parent 9456bcc975
commit c3f9bad209
18 changed files with 2239 additions and 125 deletions

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.58 2002/04/20 14:24:42 drh Exp $
** $Id: expr.c,v 1.59 2002/05/15 08:30:13 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -481,6 +481,33 @@ int sqliteExprResolveIds(
}
}
}
/* If we have not already resolved this *.* expression, then maybe
* it is a new.* or old.* trigger argument reference */
if (cnt == 0 && pParse->trigStack != 0) {
TriggerStack * tt = pParse->trigStack;
int j;
int t = 0;
if (tt->newIdx != -1 && sqliteStrICmp("new", zLeft) == 0) {
pExpr->iTable = tt->newIdx;
cntTab++;
t = 1;
}
if (tt->oldIdx != -1 && sqliteStrICmp("old", zLeft) == 0) {
pExpr->iTable = tt->oldIdx;
cntTab++;
t = 1;
}
if (t)
for(j=0; j<tt->pTab->nCol; j++) {
if( sqliteStrICmp(tt->pTab->aCol[j].zName, zRight)==0 ){
cnt++;
pExpr->iColumn = j;
}
}
}
if( cnt==0 && cntTab==1 && sqliteIsRowid(zRight) ){
cnt = 1;
pExpr->iColumn = -1;