From: danielk1977 Date: Thu, 3 Jan 2008 18:39:41 +0000 (+0000) Subject: Modify VFilter and VRename to use registers instead of the vdbe stack for inputs... X-Git-Tag: version-3.6.10~1507 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6dbee8185c0f23e519b1e0a9bfc89c5e0f074d6e;p=thirdparty%2Fsqlite.git Modify VFilter and VRename to use registers instead of the vdbe stack for inputs. (CVS 4670) FossilOrigin-Name: 253ed40aa36247fc846cc41c8612cd29899d9f8f --- diff --git a/manifest b/manifest index 595915bde3..5e4f597e4a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Registers\s(aka\smemory\scells)\sin\sthe\sVM\sare\snow\snumbered\sstarting\swith\s1\ninstead\sof\s0.\s\sA\sregister\snumber\sof\s0\smeans\s"no\ssuch\sregister".\s(CVS\s4669) -D 2008-01-03T18:03:09 +C Modify\sVFilter\sand\sVRename\sto\suse\sregisters\sinstead\sof\sthe\svdbe\sstack\sfor\sinputs.\s(CVS\s4670) +D 2008-01-03T18:39:42 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -78,7 +78,7 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4 F sqlite3.pc.in abed4664817e1cd500f2276142c71958087c16bc -F src/alter.c b58ed3becc77885e2aec6754c689255534f2734c +F src/alter.c f95b19dab6e77978da5d75675f5cde7c6d3df120 F src/analyze.c addc8e75cc43eb7ad699cd3ffc0a9157b4bf9405 F src/attach.c 4b214b411237531491e1186211e005e4de73630d F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 @@ -168,16 +168,16 @@ F src/update.c b4aa2e8b6bda3b4d917c9427568fe5c85b4a0ea8 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736 F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624 F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0 -F src/vdbe.c 4e72b3a23a017c68f7847b369b5bba7b5aaaa7a7 +F src/vdbe.c 0fa40511ae71f0acac07782c323ed4cdac73b4b0 F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5 F src/vdbeInt.h 869d0f550354c1364dde1d3611d770bd1c767505 F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c -F src/vdbeaux.c 54b7ad5d95ff3ac52f97a9a362c93b4f8c01440a +F src/vdbeaux.c 2b5aa5820daffb3cf90d3462b0854c1026f7534f F src/vdbeblob.c b90f7494c408d47ce6835000b01e40b371e27baf F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6 F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4 F src/vtab.c 03014b2bfa8096ecac5fcdc80d34cd76e06af52a -F src/where.c f02ecb55e58465055a1fd2f3143deb449b49bb93 +F src/where.c 10c0616d30112732cf4b13b8cd06d7ceefb6d985 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba @@ -603,7 +603,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 955b15a020e9ea6401fe03a36f5139a03ea80b8a -R 1925857a0a0640a748c55cd88d09327a -U drh -Z 06e0ffbaabe30d8dbe94386b95a09746 +P 0b849805c3a0f562d50623f406279b400d335639 +R 13147325b139cd4d2f4693ae66738f7d +U danielk1977 +Z fbbaf889648e9db07fda0b9d48b503d1 diff --git a/manifest.uuid b/manifest.uuid index 36eebe5701..9705396d8d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0b849805c3a0f562d50623f406279b400d335639 \ No newline at end of file +253ed40aa36247fc846cc41c8612cd29899d9f8f \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 23346b7f9f..e938a8fa3e 100644 --- a/src/alter.c +++ b/src/alter.c @@ -12,7 +12,7 @@ ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** -** $Id: alter.c,v 1.36 2008/01/03 00:01:24 drh Exp $ +** $Id: alter.c,v 1.37 2008/01/03 18:39:42 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -362,8 +362,10 @@ void sqlite3AlterRenameTable( */ #ifndef SQLITE_OMIT_VIRTUALTABLE if( isVirtualRename ){ + int i; sqlite3VdbeAddOp4(v, OP_String8, 0, 0, 0, zName, 0); - sqlite3VdbeAddOp4(v, OP_VRename, 0, 0, 0,(const char*)pTab->pVtab, P4_VTAB); + i = sqlite3StackToReg(pParse, 1); + sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pTab->pVtab, P4_VTAB); } #endif diff --git a/src/vdbe.c b/src/vdbe.c index 3dd7598ac6..d94a1d0846 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.671 2008/01/03 18:03:09 drh Exp $ +** $Id: vdbe.c,v 1.672 2008/01/03 18:39:42 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -4988,7 +4988,7 @@ case OP_VOpen: { /* no-push */ #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE -/* Opcode: VFilter P1 P2 P4 +/* Opcode: VFilter P1 P2 P3 P4 * ** ** P1 is a cursor opened using VOpen. P2 is an address to jump to if ** the filtered result set is empty. @@ -4998,31 +4998,29 @@ case OP_VOpen: { /* no-push */ ** to the module implementation. ** ** This opcode invokes the xFilter method on the virtual table specified -** by P1. The integer query plan parameter to xFilter is the top of the -** stack. Next down on the stack is the argc parameter. Beneath the -** next of stack are argc additional parameters which are passed to -** xFilter as argv. The topmost parameter (i.e. 3rd element popped from -** the stack) becomes argv[argc-1] when passed to xFilter. +** by P1. The integer query plan parameter to xFilter is stored in register +** P3. Register P3+1 stores the argc parameter to be passed to the +** xFilter method. Registers P3+2..P3+1+argc are the argc additional +** parametersneath additional parameters which are passed to +** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. ** -** The integer query plan parameter, argc, and all argv stack values -** are popped from the stack before this instruction completes. -** -** A jump is made to P2 if the result set after filtering would be -** empty. +** A jump is made to P2 if the result set after filtering would be empty. */ case OP_VFilter: { /* no-push */ int nArg; - + int iQuery; const sqlite3_module *pModule; + Mem *pQuery = &p->aMem[pOp->p3]; + Mem *pArgc = &pQuery[1]; Cursor *pCur = p->apCsr[pOp->p1]; assert( pCur->pVtabCursor ); pModule = pCur->pVtabCursor->pVtab->pModule; /* Grab the index number and argc parameters off the top of the stack. */ - assert( (&pTos[-1])>=p->aStack ); - assert( (pTos[0].flags&MEM_Int)!=0 && pTos[-1].flags==MEM_Int ); - nArg = pTos[-1].u.i; + assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int ); + nArg = pArgc->u.i; + iQuery = pQuery->u.i; /* Invoke the xFilter method */ { @@ -5030,13 +5028,13 @@ case OP_VFilter: { /* no-push */ int i; Mem **apArg = p->apArg; for(i = 0; iinVtabMethod = 1; - rc = pModule->xFilter(pCur->pVtabCursor, pTos->u.i, pOp->p4.z, nArg, apArg); + rc = pModule->xFilter(pCur->pVtabCursor, iQuery, pOp->p4.z, nArg, apArg); p->inVtabMethod = 0; if( rc==SQLITE_OK ){ res = pModule->xEof(pCur->pVtabCursor); @@ -5048,8 +5046,6 @@ case OP_VFilter: { /* no-push */ } } - /* Pop the index number, argc value and parameters off the stack */ - popStack(&pTos, 2+nArg); break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ @@ -5173,26 +5169,25 @@ case OP_VNext: { /* no-push */ #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE -/* Opcode: VRename * * P4 +/* Opcode: VRename P1 * P4 ** ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. ** This opcode invokes the corresponding xRename method. The value -** on the top of the stack is popped and passed as the zName argument -** to the xRename method. +** in register P1 is passed as the zName argument to the xRename method. */ case OP_VRename: { /* no-push */ sqlite3_vtab *pVtab = pOp->p4.pVtab; + Mem *pName = &p->aMem[pOp->p1]; assert( pVtab->pModule->xRename ); - Stringify(pTos, encoding); + Stringify(pName, encoding); if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; sqlite3VtabLock(pVtab); - rc = pVtab->pModule->xRename(pVtab, pTos->z); + rc = pVtab->pModule->xRename(pVtab, pName->z); sqlite3VtabUnlock(db, pVtab); if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; - popStack(&pTos, 1); break; } #endif diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 848286313d..01e8e7e301 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -333,8 +333,8 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs, int *pMaxStack){ }else if( opcode==OP_VFilter ){ int n; assert( p->nOp - i >= 3 ); - assert( pOp[-2].opcode==OP_Integer ); - n = pOp[-2].p1; + assert( pOp[-1].opcode==OP_MemInt ); + n = pOp[-1].p1; if( n>nMaxArgs ) nMaxArgs = n; #endif } diff --git a/src/where.c b/src/where.c index 1211958301..c5f64eed64 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.270 2008/01/03 18:03:09 drh Exp $ +** $Id: where.c,v 1.271 2008/01/03 18:39:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -2271,6 +2271,7 @@ WhereInfo *sqlite3WhereBegin( ** to access the data. */ int j; + int iReg; /* P3 Value for OP_VFilter */ sqlite3_index_info *pBestIdx = pLevel->pBestIdx; int nConstraint = pBestIdx->nConstraint; struct sqlite3_index_constraint_usage *aUsage = @@ -2289,9 +2290,12 @@ WhereInfo *sqlite3WhereBegin( } if( k==nConstraint ) break; } - sqlite3VdbeAddOp2(v, OP_Integer, j-1, 0); - sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, 0); - sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, 0, pBestIdx->idxStr, + iReg = ++pParse->nMem; + pParse->nMem++; + sqlite3StackToReg(pParse, j-1); + sqlite3VdbeAddOp2(v, OP_MemInt, pBestIdx->idxNum, iReg); + sqlite3VdbeAddOp2(v, OP_MemInt, j-1, iReg+1); + sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, iReg, pBestIdx->idxStr, pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC); pBestIdx->needToFreeIdxStr = 0; for(j=0; jnConstraint; j++){