aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c5
-rw-r--r--src/update.c4
-rw-r--r--src/vdbe.c63
-rw-r--r--src/where.c11
4 files changed, 31 insertions, 52 deletions
diff --git a/src/expr.c b/src/expr.c
index 35a585377..b7d30412b 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -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.426 2009/04/08 13:51:51 drh Exp $
+** $Id: expr.c,v 1.427 2009/04/22 17:15:03 drh Exp $
*/
#include "sqliteInt.h"
@@ -1745,8 +1745,7 @@ int sqlite3ExprCodeGetColumn(
}
assert( v!=0 );
if( iColumn<0 ){
- int op = (pTab && IsVirtual(pTab)) ? OP_VRowid : OP_Rowid;
- sqlite3VdbeAddOp2(v, op, iTable, iReg);
+ sqlite3VdbeAddOp2(v, OP_Rowid, iTable, iReg);
}else if( pTab==0 ){
sqlite3VdbeAddOp3(v, OP_Column, iTable, iColumn, iReg);
}else{
diff --git a/src/update.c b/src/update.c
index 81831831e..872e00da5 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.196 2009/02/28 10:47:42 danielk1977 Exp $
+** $Id: update.c,v 1.197 2009/04/22 17:15:03 drh Exp $
*/
#include "sqliteInt.h"
@@ -352,7 +352,7 @@ void sqlite3Update(
/* Remember the rowid of every item to be updated.
*/
- sqlite3VdbeAddOp2(v, IsVirtual(pTab)?OP_VRowid:OP_Rowid, iCur, regOldRowid);
+ sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regOldRowid);
if( !okOnePass ){
regRowSet = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);
diff --git a/src/vdbe.c b/src/vdbe.c
index be6cd4fff..b2b3c57b5 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.838 2009/04/22 15:32:59 drh Exp $
+** $Id: vdbe.c,v 1.839 2009/04/22 17:15:03 drh Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@@ -3896,6 +3896,10 @@ case OP_RowData: {
**
** Store in register P2 an integer which is the key of the table entry that
** P1 is currently point to.
+**
+** P1 can be either an ordinary table or a virtual table. There used to
+** be a separate OP_VRowid opcode for use with virtual tables, but this
+** one opcode now works for both table types.
*/
case OP_Rowid: { /* out2-prerelease */
int i = pOp->p1;
@@ -3905,18 +3909,32 @@ case OP_Rowid: { /* out2-prerelease */
assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i];
assert( pC!=0 );
- if( pC->deferredMoveto ){
+ if( pC->nullRow ){
+ /* Do nothing so that reg[P2] remains NULL */
+ break;
+ }else if( pC->deferredMoveto ){
v = pC->movetoTarget;
+ }else if( pC->pseudoTable ){
+ v = keyToInt(pC->iKey);
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ }else if( pC->pVtabCursor ){
+ sqlite3_vtab *pVtab;
+ const sqlite3_module *pModule;
+ pVtab = pC->pVtabCursor->pVtab;
+ pModule = pVtab->pModule;
+ assert( pModule->xRowid );
+ if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
+ rc = pModule->xRowid(pC->pVtabCursor, &v);
+ sqlite3DbFree(db, p->zErrMsg);
+ p->zErrMsg = pVtab->zErrMsg;
+ pVtab->zErrMsg = 0;
+ if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
}else{
rc = sqlite3VdbeCursorMoveto(pC);
if( rc ) goto abort_due_to_error;
if( pC->rowidIsValid ){
v = pC->lastRowid;
- }else if( pC->pseudoTable ){
- v = keyToInt(pC->iKey);
- }else if( pC->nullRow ){
- /* Leave the rowid set to a NULL */
- break;
}else{
assert( pC->pCursor!=0 );
sqlite3BtreeKeySize(pC->pCursor, &v);
@@ -5094,37 +5112,6 @@ case OP_VFilter: { /* jump */
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifndef SQLITE_OMIT_VIRTUALTABLE
-/* Opcode: VRowid P1 P2 * * *
-**
-** Store into register P2 the rowid of
-** the virtual-table that the P1 cursor is pointing to.
-*/
-case OP_VRowid: { /* out2-prerelease */
- sqlite3_vtab *pVtab;
- const sqlite3_module *pModule;
- sqlite_int64 iRow;
- VdbeCursor *pCur = p->apCsr[pOp->p1];
-
- assert( pCur->pVtabCursor );
- if( pCur->nullRow ){
- break;
- }
- pVtab = pCur->pVtabCursor->pVtab;
- pModule = pVtab->pModule;
- assert( pModule->xRowid );
- if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
- rc = pModule->xRowid(pCur->pVtabCursor, &iRow);
- sqlite3DbFree(db, p->zErrMsg);
- p->zErrMsg = pVtab->zErrMsg;
- pVtab->zErrMsg = 0;
- if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
- MemSetTypeFlag(pOut, MEM_Int);
- pOut->u.i = iRow;
- break;
-}
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-
-#ifndef SQLITE_OMIT_VIRTUALTABLE
/* Opcode: VColumn P1 P2 P3 * *
**
** Store the value of the P2-th column of
diff --git a/src/where.c b/src/where.c
index 6b81c363f..3b81602fb 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.386 2009/04/22 15:32:59 drh Exp $
+** $Id: where.c,v 1.387 2009/04/22 17:15:03 drh Exp $
*/
#include "sqliteInt.h"
@@ -2975,14 +2975,7 @@ static Bitmask codeOneLoopStart(
*/
assert( iReleaseReg==0 );
iReleaseReg = iRowidReg = sqlite3GetTempReg(pParse);
-#ifndef SQLITE_OMIT_VIRTUALTABLE
- if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){
- sqlite3VdbeAddOp2(v, OP_VRowid, iCur, iRowidReg);
- }else
-#endif
- {
- sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);
- }
+ sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);
}
if( pWInfo->wctrlFlags&WHERE_FILL_ROWSET ){