From d336e222f4c5d1b81a20909e36600064afcabac0 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Fri, 20 Feb 2009 10:58:41 +0000 Subject: [PATCH] Instead of using SetNumColumns, specify the number of columns in a table or index using the P4 argument. (CVS 6310) FossilOrigin-Name: e43ed649630cbc49a6f2a25a26a4a6b5fce84c48 --- manifest | 34 +++++++++++++-------------- manifest.uuid | 2 +- src/analyze.c | 5 ++-- src/build.c | 4 ++-- src/delete.c | 7 +++--- src/expr.c | 3 +-- src/insert.c | 5 ++-- src/select.c | 5 ++-- src/update.c | 8 +++---- src/vdbe.c | 63 +++++++++++++++++++++++++++----------------------- src/vdbeaux.c | 6 ++--- src/vdbeblob.c | 34 +++++++++++++-------------- src/where.c | 5 ++-- 13 files changed, 88 insertions(+), 93 deletions(-) diff --git a/manifest b/manifest index 2fe9d0f079..ef93cb2b86 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\scount\sparameter\sto\sthe\sOP_Variable\sopcode\sand\suse\sit\sto\ssimplify\nprepared\sstatements\sthat\scopy\sconsecutive\sunnamed\sparameters\sinto\nconsecutive\sregisters\s(a\scommon\scase).\s(CVS\s6309) -D 2009-02-20T03:55:05 +C Instead\sof\susing\sSetNumColumns,\sspecify\sthe\snumber\sof\scolumns\sin\sa\stable\sor\sindex\susing\sthe\sP4\sargument.\s(CVS\s6310) +D 2009-02-20T10:58:42 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 1d83fa2b1fd326b9e121012bd1ff9740537e12b3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -98,7 +98,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.def a1be7b9a4b8b51ac41c6ff6e8e44a14ef66b338b F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c f93d13aae63ea1a5ee604d76041be354311d08a5 -F src/analyze.c 2ca143d83ce545992cab74efeb5e8a446c61ab4b +F src/analyze.c 9fc52fed9da8b9c7bd5e39c8781e07ab2fb018ba F src/attach.c d34589d5c85d81e755e4a8fc946d313915a6fa6d F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 F src/backup.c 2d3f31148d7b086c5c72d9edcd04fc2751b0aa6e @@ -107,19 +107,19 @@ F src/btmutex.c 63c5cc4ad5715690767ffcb741e185d7bc35ec1a F src/btree.c 086fdb4505aa00275d6873829aeb51bf57da8d16 F src/btree.h 4eab72af6adf95f0b08b61a72ef9781bdb0bf63f F src/btreeInt.h 0a4884e6152d7cae9c741e91b830064c19fd2c05 -F src/build.c 0860029ca6e29b2bfcadbbe90084e02af98d768f +F src/build.c a1db48aec62c95049d783f231195812ff97ae268 F src/callback.c 5f10bca853e59a2c272bbfd5b720303f8b69e520 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c F src/date.c 0d804df3bbda46329946a01ff5c75c3f4f135218 -F src/delete.c 8d2fb05b32b5dea65277a574fedb0ebaa5dd877c -F src/expr.c 92e6dfcd55bdffbed8c66627700d1b5c5f9889d3 +F src/delete.c d9172e23f8b524ad23b24cc0dd7cbde8f2aecb54 +F src/expr.c e22112c8db9b82748dd100c716b783cf5d9b6cc5 F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff F src/func.c 2fb36cd7cc24e16845db203187d1e52811b0fa9c F src/global.c 448419c44ce0701104c2121b0e06919b44514c0c F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55 F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae F src/hwtime.h 4a1d45f4cae1f402ea19686acf24acf4f0cb53cb -F src/insert.c 69764f4982675863ea04d5c5232d9b3d03e28a85 +F src/insert.c 529a1b9889fe3c2eb093cc02c3053b04c65daa7e F src/journal.c e00df0c0da8413ab6e1bb7d7cab5665d4a9000d0 F src/legacy.c 8b3b95d48d202614946d7ce7256e7ba898905c3b F src/loadext.c 3f96631089fc4f3871a67f02f2e4fc7ea4d51edc @@ -155,7 +155,7 @@ F src/printf.c 9866a9a9c4a90f6d4147407f373df3fd5d5f9b6f F src/random.c 676b9d7ac820fe81e6fb2394ac8c10cff7f38628 F src/resolve.c b3aa625ec135d53a7e80c86c25ad56de46e0b415 F src/rowset.c ba9375f37053d422dd76965a9c370a13b6e1aac4 -F src/select.c fc21f384db6207a987141859ac770d83c669c933 +F src/select.c aa7328a23c0abe019f98bb7e1f4f63d62e20ba98 F src/shell.c f109ebbb50132926ebbc173a6c2d8838d5d78527 F src/sqlite.h.in 14f4d065bafed8500ea558a75a8e2be89c784d61 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 @@ -196,20 +196,20 @@ F src/test_thread.c adb9175c466e1f487295b5b957603fc0a88ea293 F src/test_wsd.c c297d7d6b8a990239e1bd25935e81d612d8ae31d F src/tokenize.c 6987fb7f0d6a87ac53499aee568cabb05eb4bea8 F src/trigger.c 9957e16e5445478f2cc60e26ac1bc836bb18d21a -F src/update.c 9edb83cc4322fb2dc5b7a0087cdb8fa00391f402 +F src/update.c fce4fa2945be1a9b65af2acec929669f7d1ac706 F src/utf.c 1da9c832dba0fa8f865b5b902d93f420a1ee4245 F src/util.c 1363f64351f3b544790f3c523439354c02f8c4e9 F src/vacuum.c 4929a585ef0fb1dfaf46302f8a9c4aa30c2d9cf5 -F src/vdbe.c 3bd3acffddf8a284d3e8c1df0e286389aaf09e1a +F src/vdbe.c 23a620da910b7d3a60ffebc088b7f00f5a6cd247 F src/vdbe.h d70a68bee196ab228914a3902c79dbd24342a0f2 F src/vdbeInt.h d12bc259b34d3d610ebf05d648eb6346d48478c3 F src/vdbeapi.c f94fe2eb6f48687e918f0df7eed1409cff9dcf58 -F src/vdbeaux.c dd5fc23bae4647d40b00ac308acd85f5c862f01e -F src/vdbeblob.c b06daa322e220f30dec55032c4e60e00346e153b +F src/vdbeaux.c 88160f4e8d3d75d42f295aa838cf70c87fb4ce77 +F src/vdbeblob.c 08d6bac666c1f6a5d67452f5fbf808cf1311d2c9 F src/vdbemem.c 543a79d722734d2f8b7ad70f08218c30bcc5bbf5 F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43 F src/walker.c 42bd3f00ca2ef5ae842304ec0d59903ef051412d -F src/where.c 2284de47b03e285a142926bc8a8022983c455a76 +F src/where.c de92174234ff56240df2b10bebe45466676ce7c3 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -701,7 +701,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P feccad8d0d05925ce67856d40ffe1bc7054168a0 -R 45f3343e100f8675023b5adecf1a6bda -U drh -Z 9ee82f1e63cdb67ae7cf41ec0375cf20 +P 48b77b04935d8942eb22f0c061f3bc5e99bbd7db +R 4c403b09f1c594ba83784cce4e18ce5c +U danielk1977 +Z 9dff27e2f1181213fee54cb9306cdb15 diff --git a/manifest.uuid b/manifest.uuid index d0023b68f6..516d487bc9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48b77b04935d8942eb22f0c061f3bc5e99bbd7db \ No newline at end of file +e43ed649630cbc49a6f2a25a26a4a6b5fce84c48 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 71e86e14cb..6b1a33628f 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code associated with the ANALYZE command. ** -** @(#) $Id: analyze.c,v 1.49 2009/02/19 14:39:25 danielk1977 Exp $ +** @(#) $Id: analyze.c,v 1.50 2009/02/20 10:58:42 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" @@ -74,8 +74,8 @@ static void openStatTable( if( !createStat1 ){ sqlite3TableLock(pParse, iDb, iRootPage, 1, "sqlite_stat1"); } - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, 3); sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur, iRootPage, iDb); + sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32); sqlite3VdbeChangeP5(v, createStat1); } @@ -131,7 +131,6 @@ static void analyzeOneTable( */ assert( iDb==sqlite3SchemaToIndex(pParse->db, pIdx->pSchema) ); nCol = pIdx->nColumn; - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, nCol+1); sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb, (char *)pKey, P4_KEYINFO_HANDOFF); VdbeComment((v, "%s", pIdx->zName)); diff --git a/src/build.c b/src/build.c index c58911d179..459539bfe0 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.519 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: build.c,v 1.520 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -603,8 +603,8 @@ char *sqlite3NameFromToken(sqlite3 *db, Token *pName){ void sqlite3OpenMasterTable(Parse *p, int iDb){ Vdbe *v = sqlite3GetVdbe(p); sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb)); - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, 5);/* sqlite_master has 5 columns */ sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb); + sqlite3VdbeChangeP4(v, -1, (char *)5, P4_INT32); /* 5 column table */ if( p->nTab==0 ){ p->nTab = 1; } diff --git a/src/delete.c b/src/delete.c index abc2ea07b8..5ad7327551 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.192 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: delete.c,v 1.193 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -77,8 +77,8 @@ void sqlite3OpenTable( v = sqlite3GetVdbe(p); assert( opcode==OP_OpenWrite || opcode==OP_OpenRead ); sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName); - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol); sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb); + sqlite3VdbeChangeP4(v, -1, (const char *)pTab->nCol, P4_INT32); VdbeComment((v, "%s", pTab->zName)); } @@ -406,8 +406,7 @@ void sqlite3DeleteFrom( /* Open the pseudo-table used to store OLD if there are triggers. */ if( triggers_exist ){ - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol); - sqlite3VdbeAddOp1(v, OP_OpenPseudo, oldIdx); + sqlite3VdbeAddOp3(v, OP_OpenPseudo, oldIdx, 0, pTab->nCol); } /* Delete every item whose key was written to the list during the diff --git a/src/expr.c b/src/expr.c index 8bc85fcb5a..af99382203 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.413 2009/02/20 03:55:05 drh Exp $ +** $Id: expr.c,v 1.414 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -1382,7 +1382,6 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ iAddr = sqlite3VdbeAddOp1(v, OP_If, iMem); sqlite3VdbeAddOp2(v, OP_Integer, 1, iMem); - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pIdx->nColumn); sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, pKey,P4_KEYINFO_HANDOFF); VdbeComment((v, "%s", pIdx->zName)); diff --git a/src/insert.c b/src/insert.c index 6616ef1114..72078c5543 100644 --- a/src/insert.c +++ b/src/insert.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.258 2009/02/20 03:02:24 drh Exp $ +** $Id: insert.c,v 1.259 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -677,8 +677,7 @@ void sqlite3Insert( /* Open the temp table for FOR EACH ROW triggers */ if( triggers_exist ){ - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol); - sqlite3VdbeAddOp2(v, OP_OpenPseudo, newIdx, 0); + sqlite3VdbeAddOp3(v, OP_OpenPseudo, newIdx, 0, pTab->nCol); } /* Initialize the count of rows to be inserted diff --git a/src/select.c b/src/select.c index 286805e499..441eee8484 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.500 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: select.c,v 1.501 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -800,8 +800,7 @@ static void generateSortTail( iTab = pOrderBy->iECursor; if( eDest==SRT_Output || eDest==SRT_Coroutine ){ pseudoTab = pParse->nTab++; - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, nColumn); - sqlite3VdbeAddOp2(v, OP_OpenPseudo, pseudoTab, eDest==SRT_Output); + sqlite3VdbeAddOp3(v, OP_OpenPseudo, pseudoTab, eDest==SRT_Output, nColumn); } addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); codeOffset(v, p, addrContinue); diff --git a/src/update.c b/src/update.c index dc4a48d4f9..bd40e26e69 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.192 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: update.c,v 1.193 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -304,10 +304,8 @@ void sqlite3Update( /* Create pseudo-tables for NEW and OLD */ - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol); - sqlite3VdbeAddOp2(v, OP_OpenPseudo, oldIdx, 0); - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pTab->nCol); - sqlite3VdbeAddOp2(v, OP_OpenPseudo, newIdx, 0); + sqlite3VdbeAddOp3(v, OP_OpenPseudo, oldIdx, 0, pTab->nCol); + sqlite3VdbeAddOp3(v, OP_OpenPseudo, newIdx, 0, pTab->nCol); iGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); addr = sqlite3VdbeMakeLabel(v); diff --git a/src/vdbe.c b/src/vdbe.c index 947db6058c..b9e1a1259b 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.820 2009/02/20 03:55:05 drh Exp $ +** $Id: vdbe.c,v 1.821 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -187,7 +187,7 @@ int sqlite3VdbeOpcodeHasProperty(int opcode, int mask){ static VdbeCursor *allocateCursor( Vdbe *p, /* The virtual machine */ int iCur, /* Index of the new VdbeCursor */ - Op *pOp, /* */ + int nField, /* Number of fields in the table or index */ int iDb, /* When database the cursor belongs to, or -1 */ int isBtreeCursor /* */ ){ @@ -213,15 +213,6 @@ static VdbeCursor *allocateCursor( int nByte; VdbeCursor *pCx = 0; - /* If the opcode of pOp is OP_SetNumColumns, then pOp->p2 contains - ** the number of fields in the records contained in the table or - ** index being opened. Use this to reserve space for the - ** VdbeCursor.aType[] array. - */ - int nField = 0; - if( pOp->opcode==OP_SetNumColumns || pOp->opcode==OP_OpenEphemeral ){ - nField = pOp->p2; - } nByte = sizeof(VdbeCursor) + (isBtreeCursor?sqlite3BtreeCursorSize():0) + @@ -1948,9 +1939,11 @@ case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ ** this opcode must be present immediately before the opcode that ** opens the cursor. */ +#if 0 case OP_SetNumColumns: { break; } +#endif /* Opcode: Column P1 P2 P3 P4 * ** @@ -2783,9 +2776,11 @@ case OP_VerifyCookie: { ** to get a read lock but fails, the script terminates with an ** SQLITE_BUSY error code. ** -** The P4 value is a pointer to a KeyInfo structure that defines the -** content and collating sequence of indices. P4 is NULL for cursors -** that are not pointing to indices. +** The P4 value may be either an integer (P4_INT32) or a pointer to +** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo +** structure, then said structure defines the content and collating +** sequence of the index being opened. Otherwise, if P4 is an integer +** value, it is set to the number of columns in the table. ** ** See also OpenWrite. */ @@ -2795,9 +2790,11 @@ case OP_VerifyCookie: { ** page is P2. Or if P5!=0 use the content of register P2 to find the ** root page. ** -** The P4 value is a pointer to a KeyInfo structure that defines the -** content and collating sequence of indices. P4 is NULL for cursors -** that are not pointing to indices. +** The P4 value may be either an integer (P4_INT32) or a pointer to +** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo +** structure, then said structure defines the content and collating +** sequence of the index being opened. Otherwise, if P4 is an integer +** value, it is set to the number of columns in the table. ** ** This instruction works just like OpenRead except that it opens the cursor ** in read/write mode. For a given table, there can be one or more read-only @@ -2807,6 +2804,8 @@ case OP_VerifyCookie: { */ case OP_OpenRead: case OP_OpenWrite: { + int nField = 0; + KeyInfo *pKeyInfo = 0; int i = pOp->p1; int p2 = pOp->p2; int iDb = pOp->p3; @@ -2840,16 +2839,19 @@ case OP_OpenWrite: { } } assert( i>=0 ); - pCur = allocateCursor(p, i, &pOp[-1], iDb, 1); - if( pCur==0 ) goto no_mem; - pCur->nullRow = 1; - rc = sqlite3BtreeCursor(pX, p2, wrFlag, pOp->p4.p, pCur->pCursor); if( pOp->p4type==P4_KEYINFO ){ - pCur->pKeyInfo = pOp->p4.pKeyInfo; - pCur->pKeyInfo->enc = ENC(p->db); - }else{ - pCur->pKeyInfo = 0; + pKeyInfo = pOp->p4.pKeyInfo; + pKeyInfo->enc = ENC(p->db); + nField = pKeyInfo->nField+1; + }else if( pOp->p4type==P4_INT32 ){ + nField = pOp->p4.i; } + pCur = allocateCursor(p, i, nField, iDb, 1); + if( pCur==0 ) goto no_mem; + pCur->nullRow = 1; + rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor); + pCur->pKeyInfo = pKeyInfo; + switch( rc ){ case SQLITE_BUSY: { p->pc = pc; @@ -2924,7 +2926,7 @@ case OP_OpenEphemeral: { SQLITE_OPEN_TRANSIENT_DB; assert( i>=0 ); - pCx = allocateCursor(p, i, pOp, -1, 1); + pCx = allocateCursor(p, i, pOp->p2, -1, 1); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; rc = sqlite3BtreeFactory(db, 0, 1, SQLITE_DEFAULT_TEMP_CACHE_SIZE, openFlags, @@ -2959,7 +2961,7 @@ case OP_OpenEphemeral: { break; } -/* Opcode: OpenPseudo P1 P2 * * * +/* Opcode: OpenPseudo P1 P2 P3 * * ** ** Open a new cursor that points to a fake table that contains a single ** row of data. Any attempt to write a second row of data causes the @@ -2978,12 +2980,15 @@ case OP_OpenEphemeral: { ** is stored. In this case, the vdbe program must ensure that the ** memory cell containing the row data is not overwritten until the ** pseudo table is closed (or a new row is inserted into it). +** +** P3 is the number of fields in the records that will be stored by +** the pseudo-table. */ case OP_OpenPseudo: { int i = pOp->p1; VdbeCursor *pCx; assert( i>=0 ); - pCx = allocateCursor(p, i, &pOp[-1], -1, 0); + pCx = allocateCursor(p, i, pOp->p3, -1, 0); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; pCx->pseudoTable = 1; @@ -4879,7 +4884,7 @@ case OP_VOpen: { pVtabCursor->pVtab = pVtab; /* Initialise vdbe cursor object */ - pCur = allocateCursor(p, pOp->p1, &pOp[-1], -1, 0); + pCur = allocateCursor(p, pOp->p1, 0, -1, 0); if( pCur ){ pCur->pVtabCursor = pVtabCursor; pCur->pModule = pVtabCursor->pVtab->pModule; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 4decef2a37..a44e5987bc 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -14,7 +14,7 @@ ** to version 2.8.7, all this code was combined into the vdbe.c source file. ** But that file was getting too big so this subroutines were split out. ** -** $Id: vdbeaux.c,v 1.437 2009/02/20 01:28:59 drh Exp $ +** $Id: vdbeaux.c,v 1.438 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -1014,13 +1014,13 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){ ** ** *pnByte is a counter of the number of bytes of space that have failed ** to allocate. If there is insufficient space in *ppFrom to satisfy the -** request, then increate *pnByte by the amount of the request. +** request, then increment *pnByte by the amount of the request. */ static void allocSpace( char *pp, /* IN/OUT: Set *pp to point to allocated buffer */ int nByte, /* Number of bytes to allocate */ u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ - u8 *pEnd, /* Pointer to 1 byte passed end of *ppFrom buffer */ + u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ int *pnByte /* If allocation cannot be made, increment *pnByte */ ){ if( (*(void**)pp)==0 ){ diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 0fccada5a5..c2ffdd1168 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -12,7 +12,7 @@ ** ** This file contains code used to implement incremental BLOB I/O. ** -** $Id: vdbeblob.c,v 1.27 2009/02/20 03:55:05 drh Exp $ +** $Id: vdbeblob.c,v 1.28 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -70,17 +70,15 @@ int sqlite3_blob_open( /* One of the following two instructions is replaced by an ** OP_Noop before exection. */ - {OP_SetNumColumns, 0, 0, 0}, /* 2: Num cols for cursor */ - {OP_OpenRead, 0, 0, 0}, /* 3: Open cursor 0 for reading */ - {OP_SetNumColumns, 0, 0, 0}, /* 4: Num cols for cursor */ - {OP_OpenWrite, 0, 0, 0}, /* 5: Open cursor 0 for read/write */ - - {OP_Variable, 1, 1, 1}, /* 6: Push the rowid to the stack */ - {OP_NotExists, 0, 10, 1}, /* 7: Seek the cursor */ - {OP_Column, 0, 0, 1}, /* 8 */ - {OP_ResultRow, 1, 0, 0}, /* 9 */ - {OP_Close, 0, 0, 0}, /* 10 */ - {OP_Halt, 0, 0, 0}, /* 11 */ + {OP_OpenRead, 0, 0, 0}, /* 2: Open cursor 0 for reading */ + {OP_OpenWrite, 0, 0, 0}, /* 3: Open cursor 0 for read/write */ + + {OP_Variable, 1, 1, 1}, /* 4: Push the rowid to the stack */ + {OP_NotExists, 0, 8, 1}, /* 5: Seek the cursor */ + {OP_Column, 0, 0, 1}, /* 6 */ + {OP_ResultRow, 1, 0, 0}, /* 7 */ + {OP_Close, 0, 0, 0}, /* 8 */ + {OP_Halt, 0, 0, 0}, /* 9 */ }; Vdbe *v = 0; @@ -178,19 +176,19 @@ int sqlite3_blob_open( /* Remove either the OP_OpenWrite or OpenRead. Set the P2 ** parameter of the other to pTab->tnum. */ - sqlite3VdbeChangeToNoop(v, (flags ? 3 : 5), 1); - sqlite3VdbeChangeP2(v, (flags ? 5 : 3), pTab->tnum); - sqlite3VdbeChangeP3(v, (flags ? 5 : 3), iDb); + sqlite3VdbeChangeToNoop(v, (flags ? 2 : 3), 1); + sqlite3VdbeChangeP2(v, (flags ? 3 : 2), pTab->tnum); + sqlite3VdbeChangeP3(v, (flags ? 3 : 2), iDb); - /* Configure the OP_SetNumColumns. Configure the cursor to + /* Configure the number of columns. Configure the cursor to ** think that the table has one more column than it really ** does. An OP_Column to retrieve this imaginary column will ** always return an SQL NULL. This is useful because it means ** we can invoke OP_Column to fill in the vdbe cursors type ** and offset cache without causing any IO. */ - sqlite3VdbeChangeP2(v, flags ? 4 : 2, pTab->nCol+1); - sqlite3VdbeChangeP2(v, 8, pTab->nCol); + sqlite3VdbeChangeP4(v, flags ? 3 : 2, (char *)(pTab->nCol+1), P4_INT32); + sqlite3VdbeChangeP2(v, 6, pTab->nCol); if( !db->mallocFailed ){ sqlite3VdbeMakeReady(v, 1, 1, 1, 0); } diff --git a/src/where.c b/src/where.c index 22b6e07baa..858c549121 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.369 2009/02/19 14:39:25 danielk1977 Exp $ +** $Id: where.c,v 1.370 2009/02/20 10:58:42 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -3240,7 +3240,7 @@ WhereInfo *sqlite3WhereBegin( Bitmask b = pTabItem->colUsed; int n = 0; for(; b; b=b>>1, n++){} - sqlite3VdbeChangeP2(v, sqlite3VdbeCurrentAddr(v)-2, n); + sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, (char*)n, P4_INT32); assert( n<=pTab->nCol ); } }else{ @@ -3253,7 +3253,6 @@ WhereInfo *sqlite3WhereBegin( int iIdxCur = pLevel->iIdxCur; assert( pIx->pSchema==pTab->pSchema ); assert( iIdxCur>=0 ); - sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, pIx->nColumn+1); sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIx->tnum, iDb, (char*)pKey, P4_KEYINFO_HANDOFF); VdbeComment((v, "%s", pIx->zName)); -- 2.47.2