mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Style fixes to triggers code in various *.c files (partial fix to ticket #39) (CVS 571)
FossilOrigin-Name: 8a4195c7466962291a296e8f53034ea8cb25005f
This commit is contained in:
53
src/update.c
53
src/update.c
@@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle UPDATE statements.
|
||||
**
|
||||
** $Id: update.c,v 1.38 2002/05/15 11:44:15 drh Exp $
|
||||
** $Id: update.c,v 1.39 2002/05/19 23:43:14 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -59,11 +59,11 @@ void sqliteUpdate(
|
||||
* defined
|
||||
*/
|
||||
{
|
||||
char * zTab = sqliteTableNameFromToken(pTableName);
|
||||
char *zTab = sqliteTableNameFromToken(pTableName);
|
||||
|
||||
if(zTab != 0) {
|
||||
if( zTab != 0 ){
|
||||
pTab = sqliteFindTable(pParse->db, zTab);
|
||||
if (pTab) {
|
||||
if( pTab ){
|
||||
row_triggers_exist =
|
||||
sqliteTriggersExist(pParse, pTab->pTrigger,
|
||||
TK_UPDATE, TK_BEFORE, TK_ROW, pChanges) ||
|
||||
@@ -71,7 +71,7 @@ void sqliteUpdate(
|
||||
TK_UPDATE, TK_AFTER, TK_ROW, pChanges);
|
||||
}
|
||||
sqliteFree(zTab);
|
||||
if (row_triggers_exist && pTab->pSelect ) {
|
||||
if( row_triggers_exist && pTab->pSelect ){
|
||||
/* Just fire VIEW triggers */
|
||||
sqliteViewTriggers(pParse, pTab, pWhere, onError, pChanges);
|
||||
return;
|
||||
@@ -92,7 +92,8 @@ void sqliteUpdate(
|
||||
if( aXRef==0 ) goto update_cleanup;
|
||||
for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;
|
||||
|
||||
if (row_triggers_exist) {
|
||||
/* If there are FOR EACH ROW triggers, allocate temp tables */
|
||||
if( row_triggers_exist ){
|
||||
newIdx = pParse->nTab++;
|
||||
oldIdx = pParse->nTab++;
|
||||
}
|
||||
@@ -197,7 +198,7 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_Integer, 0, 0);
|
||||
}
|
||||
|
||||
if (row_triggers_exist) {
|
||||
if( row_triggers_exist ){
|
||||
int ii;
|
||||
|
||||
sqliteVdbeAddOp(v, OP_OpenTemp, oldIdx, 0);
|
||||
@@ -212,22 +213,24 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
|
||||
|
||||
sqliteVdbeAddOp(v, OP_Integer, 13, 0);
|
||||
for (ii = 0; ii < pTab->nCol; ii++) {
|
||||
if (ii == pTab->iPKey)
|
||||
sqliteVdbeAddOp(v, OP_Recno, base, 0);
|
||||
else
|
||||
sqliteVdbeAddOp(v, OP_Column, base, ii);
|
||||
for(ii = 0; ii < pTab->nCol; ii++){
|
||||
if( ii == pTab->iPKey ){
|
||||
sqliteVdbeAddOp(v, OP_Recno, base, 0);
|
||||
}else{
|
||||
sqliteVdbeAddOp(v, OP_Column, base, ii);
|
||||
}
|
||||
}
|
||||
sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
|
||||
sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
|
||||
|
||||
sqliteVdbeAddOp(v, OP_Integer, 13, 0);
|
||||
for (ii = 0; ii < pTab->nCol; ii++){
|
||||
for(ii = 0; ii < pTab->nCol; ii++){
|
||||
if( aXRef[ii] < 0 ){
|
||||
if (ii == pTab->iPKey)
|
||||
if( ii == pTab->iPKey ){
|
||||
sqliteVdbeAddOp(v, OP_Recno, base, 0);
|
||||
else
|
||||
}else{
|
||||
sqliteVdbeAddOp(v, OP_Column, base, ii);
|
||||
}
|
||||
}else{
|
||||
sqliteExprCode(pParse, pChanges->a[aXRef[ii]].pExpr);
|
||||
}
|
||||
@@ -239,8 +242,10 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_Rewind, oldIdx, 0);
|
||||
sqliteVdbeAddOp(v, OP_Rewind, newIdx, 0);
|
||||
|
||||
if (sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, pTab,
|
||||
newIdx, oldIdx, onError)) goto update_cleanup;
|
||||
if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_BEFORE, pTab,
|
||||
newIdx, oldIdx, onError) ){
|
||||
goto update_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* Rewind the list of records that need to be updated and
|
||||
@@ -276,7 +281,7 @@ void sqliteUpdate(
|
||||
** Also, the old data is needed to delete the old index entires.
|
||||
** So make the cursor point at the old record.
|
||||
*/
|
||||
if (!row_triggers_exist) {
|
||||
if( !row_triggers_exist ){
|
||||
int ii;
|
||||
sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
|
||||
addr = sqliteVdbeAddOp(v, OP_ListRead, 0, 0);
|
||||
@@ -337,7 +342,7 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
|
||||
}
|
||||
|
||||
if (row_triggers_exist) {
|
||||
if( row_triggers_exist ){
|
||||
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
|
||||
if( openAll || aIdxUsed[i] )
|
||||
sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
|
||||
@@ -345,8 +350,10 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_Close, base, 0);
|
||||
pParse->nTab = base;
|
||||
|
||||
if (sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, pTab,
|
||||
newIdx, oldIdx, onError)) goto update_cleanup;
|
||||
if( sqliteCodeRowTrigger(pParse, TK_UPDATE, pChanges, TK_AFTER, pTab,
|
||||
newIdx, oldIdx, onError) ){
|
||||
goto update_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* Repeat the above with the next record to be updated, until
|
||||
@@ -357,7 +364,7 @@ void sqliteUpdate(
|
||||
sqliteVdbeAddOp(v, OP_ListReset, 0, 0);
|
||||
|
||||
/* Close all tables if there were no FOR EACH ROW triggers */
|
||||
if (!row_triggers_exist) {
|
||||
if( !row_triggers_exist ){
|
||||
for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
|
||||
if( openAll || aIdxUsed[i] ){
|
||||
sqliteVdbeAddOp(v, OP_Close, base+i+1, 0);
|
||||
@@ -365,7 +372,7 @@ void sqliteUpdate(
|
||||
}
|
||||
sqliteVdbeAddOp(v, OP_Close, base, 0);
|
||||
pParse->nTab = base;
|
||||
} else {
|
||||
}else{
|
||||
sqliteVdbeAddOp(v, OP_Close, newIdx, 0);
|
||||
sqliteVdbeAddOp(v, OP_Close, oldIdx, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user