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

Eliminate the OP_VRowid opcode. The regular OP_Rowid now work for both

regular and virtual tables. (CVS 6537)

FossilOrigin-Name: ecbef45011f1f98d940b2d3492941213d9f04172
This commit is contained in:
drh
2009-04-22 17:15:02 +00:00
parent 6149526c25
commit 044925be0b
6 changed files with 41 additions and 62 deletions

View File

@@ -1,5 +1,5 @@
C Change\sthe\sOP_Rowid\sopcode\sso\sthat\sa\sdeferred\sOP_Seek\sis\spending,\sit\ssimply\npulls\sthe\srowid\sfrom\sthe\sdeferred\sseek\starget\sand\sdoes\snot\sactually\smove\nthe\scursor\sor\sdo\sa\sseek.\s\sOther\swhere.c\scleanups.\s(CVS\s6536) C Eliminate\sthe\sOP_VRowid\sopcode.\s\sThe\sregular\sOP_Rowid\snow\swork\sfor\sboth\nregular\sand\svirtual\stables.\s(CVS\s6537)
D 2009-04-22T15:32:59 D 2009-04-22T17:15:03
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -111,7 +111,7 @@ F src/callback.c 73016376d6848ba987709e8c9048d4f0e0776036
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c d327ec7bb2f64b08d32b1035de82b9ba8675de91 F src/date.c d327ec7bb2f64b08d32b1035de82b9ba8675de91
F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf F src/delete.c eb1066b2f35489fee46ad765d2b66386fc7d8adf
F src/expr.c ccc5b5fa3bac249a9ab6e5e10629d77ff293c9f8 F src/expr.c 51ec16f86855a0a6ba44ba9d219abb72f06fd1c8
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c f667fe886309707c7178542073bb0ced00a9fae7 F src/func.c f667fe886309707c7178542073bb0ced00a9fae7
F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c
@@ -196,11 +196,11 @@ F src/test_thread.c b8a1ab7ca1a632f18e8a361880d5d65eeea08eac
F src/test_wsd.c 3ae5101de6cbfda2720152ab659ea84079719241 F src/test_wsd.c 3ae5101de6cbfda2720152ab659ea84079719241
F src/tokenize.c 7bd3b6dd56566604ad24ed4aa017e6618166b500 F src/tokenize.c 7bd3b6dd56566604ad24ed4aa017e6618166b500
F src/trigger.c 21f39db410cdc32166a94900ac1b3df98ea560e6 F src/trigger.c 21f39db410cdc32166a94900ac1b3df98ea560e6
F src/update.c 8ededddcde6f7b6da981dd0429a5d34518a475b7 F src/update.c 9617202877aa55c585b55937e0097bf050970c67
F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff F src/utf.c 9541d28f40441812c0b40f00334372a0542c00ff
F src/util.c 828c552a22a1d5b650b8a5ea0009546715c45d93 F src/util.c 828c552a22a1d5b650b8a5ea0009546715c45d93
F src/vacuum.c 07121a727beeee88f27d704a00313ad6a7c9bef0 F src/vacuum.c 07121a727beeee88f27d704a00313ad6a7c9bef0
F src/vdbe.c ff8870fd2a4a5a3f7f8d24e5d0f4e73c22402c4f F src/vdbe.c b7a27b4c3de1d2df80f3f9ee5a206c4af2abeb5a
F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
F src/vdbeInt.h 8726f7b4e3b55c8acf6d304a5b5f727ac1b6c5ab F src/vdbeInt.h 8726f7b4e3b55c8acf6d304a5b5f727ac1b6c5ab
F src/vdbeapi.c 015c9d0fb7047657a13a7bb6aa886f75e43db02d F src/vdbeapi.c 015c9d0fb7047657a13a7bb6aa886f75e43db02d
@@ -209,7 +209,7 @@ F src/vdbeblob.c e67757450ae8581a8b354d9d7e467e41502dfe38
F src/vdbemem.c 111d8193859d16aefd5d3cb57472808584ea5503 F src/vdbemem.c 111d8193859d16aefd5d3cb57472808584ea5503
F src/vtab.c 6118d71c5137e20a7ac51fb5d9beb0361fbedb89 F src/vtab.c 6118d71c5137e20a7ac51fb5d9beb0361fbedb89
F src/walker.c 7cdf63223c953d4343c6833e940f110281a378ee F src/walker.c 7cdf63223c953d4343c6833e940f110281a378ee
F src/where.c 576a21f6e0bb6651f3354b5cee7ecc67b935b2a5 F src/where.c 423ed1dab78a8a62bfc4f349e7d53756b31deeaa
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@@ -720,7 +720,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P e963bed0fe3ce5fa32f04b930e5ed0956dc2aa47 P 1c508a99822caa383e7e24b5d09a9bddd2ee3a00
R 1585578003f3d07014cf9b3e3edcfb74 R 999e0378f327461c6dde395dd11ca7e1
U drh U drh
Z e0df7c75ae1c0bc5ef9879b2922e6098 Z 6d0b2cfca513b61db3f6e2221f153ea3

View File

@@ -1 +1 @@
1c508a99822caa383e7e24b5d09a9bddd2ee3a00 ecbef45011f1f98d940b2d3492941213d9f04172

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and ** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite. ** 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" #include "sqliteInt.h"
@@ -1745,8 +1745,7 @@ int sqlite3ExprCodeGetColumn(
} }
assert( v!=0 ); assert( v!=0 );
if( iColumn<0 ){ if( iColumn<0 ){
int op = (pTab && IsVirtual(pTab)) ? OP_VRowid : OP_Rowid; sqlite3VdbeAddOp2(v, OP_Rowid, iTable, iReg);
sqlite3VdbeAddOp2(v, op, iTable, iReg);
}else if( pTab==0 ){ }else if( pTab==0 ){
sqlite3VdbeAddOp3(v, OP_Column, iTable, iColumn, iReg); sqlite3VdbeAddOp3(v, OP_Column, iTable, iColumn, iReg);
}else{ }else{

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle UPDATE statements. ** 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" #include "sqliteInt.h"
@@ -352,7 +352,7 @@ void sqlite3Update(
/* Remember the rowid of every item to be updated. /* 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 ){ if( !okOnePass ){
regRowSet = ++pParse->nMem; regRowSet = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);

View File

@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** 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 "sqliteInt.h"
#include "vdbeInt.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 ** Store in register P2 an integer which is the key of the table entry that
** P1 is currently point to. ** 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 */ case OP_Rowid: { /* out2-prerelease */
int i = pOp->p1; int i = pOp->p1;
@@ -3905,18 +3909,32 @@ case OP_Rowid: { /* out2-prerelease */
assert( i>=0 && i<p->nCursor ); assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i]; pC = p->apCsr[i];
assert( pC!=0 ); 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; 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{ }else{
rc = sqlite3VdbeCursorMoveto(pC); rc = sqlite3VdbeCursorMoveto(pC);
if( rc ) goto abort_due_to_error; if( rc ) goto abort_due_to_error;
if( pC->rowidIsValid ){ if( pC->rowidIsValid ){
v = pC->lastRowid; v = pC->lastRowid;
}else if( pC->pseudoTable ){
v = keyToInt(pC->iKey);
}else if( pC->nullRow ){
/* Leave the rowid set to a NULL */
break;
}else{ }else{
assert( pC->pCursor!=0 ); assert( pC->pCursor!=0 );
sqlite3BtreeKeySize(pC->pCursor, &v); sqlite3BtreeKeySize(pC->pCursor, &v);
@@ -5093,37 +5111,6 @@ case OP_VFilter: { /* jump */
} }
#endif /* SQLITE_OMIT_VIRTUALTABLE */ #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 #ifndef SQLITE_OMIT_VIRTUALTABLE
/* Opcode: VColumn P1 P2 P3 * * /* Opcode: VColumn P1 P2 P3 * *
** **

View File

@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting ** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer". ** 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" #include "sqliteInt.h"
@@ -2975,15 +2975,8 @@ static Bitmask codeOneLoopStart(
*/ */
assert( iReleaseReg==0 ); assert( iReleaseReg==0 );
iReleaseReg = iRowidReg = sqlite3GetTempReg(pParse); 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 ){ if( pWInfo->wctrlFlags&WHERE_FILL_ROWSET ){
sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, iRowidReg); sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, iRowidReg);