aboutsummaryrefslogtreecommitdiff
path: root/src/delete.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2006-01-07 13:21:04 +0000
committerdanielk1977 <danielk1977@noemail.net>2006-01-07 13:21:04 +0000
commitc00da105654fb2bd0712acccac3e36b539805d08 (patch)
treebe8fb606d3568c09ec40310e35179152dcd56a03 /src/delete.c
parent8c0ca7d27c60c5a43dbfeab3c869a45e0e3603b1 (diff)
downloadsqlite-c00da105654fb2bd0712acccac3e36b539805d08.tar.gz
sqlite-c00da105654fb2bd0712acccac3e36b539805d08.zip
In shared-cache mode, lock all required tables before beginning to execute the body of the statement program. (CVS 2881)
FossilOrigin-Name: 23b587b05b89727248805e6d9e5141e018cf2152
Diffstat (limited to 'src/delete.c')
-rw-r--r--src/delete.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/delete.c b/src/delete.c
index 9114304ed..9c5cf5175 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
-** $Id: delete.c,v 1.114 2006/01/05 11:34:34 danielk1977 Exp $
+** $Id: delete.c,v 1.115 2006/01/07 13:21:04 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -59,15 +59,19 @@ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
/*
** Generate code that will open a table for reading.
*/
-void sqlite3OpenTableForReading(
- Vdbe *v, /* Generate code into this VDBE */
+void sqlite3OpenTable(
+ Parse *p, /* Generate code into this VDBE */
int iCur, /* The cursor number of the table */
int iDb, /* The database index in sqlite3.aDb[] */
- Table *pTab /* The table to be opened */
+ Table *pTab, /* The table to be opened */
+ int opcode /* OP_OpenRead or OP_OpenWrite */
){
+ Vdbe *v = sqlite3GetVdbe(p);
+ assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
+ sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite), pTab->zName);
sqlite3VdbeAddOp(v, OP_Integer, iDb, 0);
VdbeComment((v, "# %s", pTab->zName));
- sqlite3VdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
+ sqlite3VdbeAddOp(v, opcode, iCur, pTab->tnum);
sqlite3VdbeAddOp(v, OP_SetNumColumns, iCur, pTab->nCol);
}
@@ -208,7 +212,7 @@ void sqlite3DeleteFrom(
int endOfLoop = sqlite3VdbeMakeLabel(v);
int addr;
if( !isView ){
- sqlite3OpenTableForReading(v, iCur, iDb, pTab);
+ sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
}
sqlite3VdbeAddOp(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);
addr = sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);
@@ -276,7 +280,7 @@ void sqlite3DeleteFrom(
addr = sqlite3VdbeAddOp(v, OP_FifoRead, 0, end);
if( !isView ){
sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
- sqlite3OpenTableForReading(v, iCur, iDb, pTab);
+ sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
}
sqlite3VdbeAddOp(v, OP_MoveGe, iCur, 0);
sqlite3VdbeAddOp(v, OP_Rowid, iCur, 0);