diff options
author | drh <drh@noemail.net> | 2001-09-23 02:35:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2001-09-23 02:35:53 +0000 |
commit | ecdc7530dda7a793c96df4010313792de4a6390c (patch) | |
tree | eaef12ba2ead1e93fd05f62f34ba7cb0f0cf39cc /src/update.c | |
parent | beae319476c5d81e8f399010dc7dc5a2336f0606 (diff) | |
download | sqlite-ecdc7530dda7a793c96df4010313792de4a6390c.tar.gz sqlite-ecdc7530dda7a793c96df4010313792de4a6390c.zip |
Fixes to the locking and rollback behavior. (CVS 261)
FossilOrigin-Name: 337b3d3b2a903328d9744c111979909a284b8348
Diffstat (limited to 'src/update.c')
-rw-r--r-- | src/update.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/update.c b/src/update.c index 62c024118..fb67ac66b 100644 --- a/src/update.c +++ b/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.14 2001/09/16 00:13:27 drh Exp $ +** $Id: update.c,v 1.15 2001/09/23 02:35:53 drh Exp $ */ #include "sqliteInt.h" @@ -34,12 +34,14 @@ void sqliteUpdate( Index *pIdx; /* For looping over indices */ int nIdx; /* Number of indices that need updating */ int base; /* Index of first available table cursor */ + sqlite *db; /* The database structure */ Index **apIdx = 0; /* An array of indices that need updating too */ int *aXRef = 0; /* aXRef[i] is the index in pChanges->a[] of the ** an expression for the i-th column of the table. ** aXRef[i]==-1 if the i-th column is not changed. */ if( pParse->nErr || sqlite_malloc_failed ) goto update_cleanup; + db = pParse->db; /* Locate the table which we want to update. This table has to be ** put in an IdList structure because some of the subroutines we @@ -49,7 +51,7 @@ void sqliteUpdate( pTabList = sqliteIdListAppend(0, pTableName); if( pTabList==0 ) goto update_cleanup; for(i=0; i<pTabList->nId; i++){ - pTabList->a[i].pTab = sqliteFindTable(pParse->db, pTabList->a[i].zName); + pTabList->a[i].pTab = sqliteFindTable(db, pTabList->a[i].zName); if( pTabList->a[i].pTab==0 ){ sqliteSetString(&pParse->zErrMsg, "no such table: ", pTabList->a[i].zName, 0); @@ -132,9 +134,10 @@ void sqliteUpdate( */ v = sqliteGetVdbe(pParse); if( v==0 ) goto update_cleanup; - if( (pParse->db->flags & SQLITE_InTrans)==0 ){ + if( (db->flags & SQLITE_InTrans)==0 ){ sqliteVdbeAddOp(v, OP_Transaction, 0, 0, 0, 0); - sqliteVdbeAddOp(v, OP_VerifyCookie, pParse->db->schema_cookie, 0, 0, 0); + sqliteVdbeAddOp(v, OP_VerifyCookie, db->schema_cookie, 0, 0, 0); + pParse->schemaVerified = 1; } /* Begin the database scan @@ -156,9 +159,9 @@ void sqliteUpdate( */ sqliteVdbeAddOp(v, OP_ListRewind, 0, 0, 0, 0); base = pParse->nTab; - sqliteVdbeAddOp(v, OP_Open, base, pTab->tnum, 0, 0); + sqliteVdbeAddOp(v, OP_OpenWrite, base, pTab->tnum, 0, 0); for(i=0; i<nIdx; i++){ - sqliteVdbeAddOp(v, OP_Open, base+i+1, apIdx[i]->tnum, 0, 0); + sqliteVdbeAddOp(v, OP_OpenWrite, base+i+1, apIdx[i]->tnum, 0, 0); } /* Loop over every record that needs updating. We have to load @@ -216,7 +219,7 @@ void sqliteUpdate( */ sqliteVdbeAddOp(v, OP_Goto, 0, addr, 0, 0); sqliteVdbeAddOp(v, OP_ListClose, 0, 0, 0, end); - if( (pParse->db->flags & SQLITE_InTrans)==0 ){ + if( (db->flags & SQLITE_InTrans)==0 ){ sqliteVdbeAddOp(v, OP_Commit, 0, 0, 0, 0); } |