1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Registers (aka memory cells) in the VM are now numbered starting with 1

instead of 0.  A register number of 0 means "no such register". (CVS 4669)

FossilOrigin-Name: 0b849805c3a0f562d50623f406279b400d335639
This commit is contained in:
drh
2008-01-03 18:03:08 +00:00
parent 2a339ff677
commit 0a07c107a6
14 changed files with 110 additions and 111 deletions

View File

@@ -1,5 +1,5 @@
C Modify\sOP_VUpdate\sto\sread\sarguments\sfrom\sa\srange\sof\smemory\scells\sinstead\sof\sfrom\sthe\sstack.\s(CVS\s4668) 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-03T17:31:45 D 2008-01-03T18:03:09
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -79,24 +79,24 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4 F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4
F sqlite3.pc.in abed4664817e1cd500f2276142c71958087c16bc F sqlite3.pc.in abed4664817e1cd500f2276142c71958087c16bc
F src/alter.c b58ed3becc77885e2aec6754c689255534f2734c F src/alter.c b58ed3becc77885e2aec6754c689255534f2734c
F src/analyze.c d7b4dace3823b45d0a18568dd43067f78aa0f133 F src/analyze.c addc8e75cc43eb7ad699cd3ffc0a9157b4bf9405
F src/attach.c 4b214b411237531491e1186211e005e4de73630d F src/attach.c 4b214b411237531491e1186211e005e4de73630d
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/btmutex.c 5d39da37c9d1282f3c6f9967afae6a34ee36b7ff F src/btmutex.c 5d39da37c9d1282f3c6f9967afae6a34ee36b7ff
F src/btree.c 5164b32950cfd41f2c5c31e8ff82c4a499918aef F src/btree.c 5164b32950cfd41f2c5c31e8ff82c4a499918aef
F src/btree.h 19dcf5ad23c17b98855da548e9a8e3eb4429d5eb F src/btree.h 19dcf5ad23c17b98855da548e9a8e3eb4429d5eb
F src/btreeInt.h 1c5a9da165718ef7de81e35ce9ab5d9ba9283f76 F src/btreeInt.h 1c5a9da165718ef7de81e35ce9ab5d9ba9283f76
F src/build.c 11cd1e6a6425893662edcdf4b39abe02a1fb2ecb F src/build.c b7874b45716fa56e6fd1291ffb0b97a55e470728
F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6 F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6
F src/delete.c 1fa15280738943907cb1c5f2b9d5506bf84a9915 F src/delete.c b5f77d88cc35367cfafc2e4edcf9327d19428615
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c 24202e79a92c8b9b0b5a609d03051ff3d91e5bf4 F src/expr.c 4e6bd195630aa99c0fe1a17d1e913873402cb40c
F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d
F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/insert.c b5e3def19f5a21a9e916b25a41ce78eaf8b0966d F src/insert.c febae80da43fe28852f54d6ff8757ad03d1cda7b
F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2 F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66 F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
@@ -127,11 +127,11 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 0cb6ccea4b9615627d61d7c4417cedc45776d429 F src/pager.c 0cb6ccea4b9615627d61d7c4417cedc45776d429
F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa
F src/parse.y 2ae06e8d3190faace49c5b82e7cea1fc60d084a1 F src/parse.y 2ae06e8d3190faace49c5b82e7cea1fc60d084a1
F src/pragma.c 61b9d171a6d53d36a77c66cb921d47a5c09a8441 F src/pragma.c ac8d91bb15dd475d239b9d7bd5dbd7d69a9428e7
F src/prepare.c f1bb8eb642082e618a359c08e3e107490eafe0e3 F src/prepare.c f1bb8eb642082e618a359c08e3e107490eafe0e3
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
F src/select.c 539a71c9b302ac003e5be72eee007d1f2e452e43 F src/select.c dae0e2ed8838746f89b0fd6e642e819a792168e3
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 5391e889384d2062249f668110d64ed16f601c4b F src/shell.c 5391e889384d2062249f668110d64ed16f601c4b
F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
@@ -163,21 +163,21 @@ F src/test_server.c a6ece6c835e7eae835054124e09e947e422b1ac5
F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59 F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730 F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48 F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48
F src/trigger.c caa971c1a9bba37b6ad705e7990316dd1e8266c9 F src/trigger.c 713b501b12ea41bf0297a2cf78f7d954c4a25d13
F src/update.c b4b8790d63749fb3ef5ee41108c43bfdbfa48623 F src/update.c b4aa2e8b6bda3b4d917c9427568fe5c85b4a0ea8
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624 F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0 F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
F src/vdbe.c e54f89e877d13987d795ffe26e2f878a53334c9d F src/vdbe.c 4e72b3a23a017c68f7847b369b5bba7b5aaaa7a7
F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5 F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5
F src/vdbeInt.h 869d0f550354c1364dde1d3611d770bd1c767505 F src/vdbeInt.h 869d0f550354c1364dde1d3611d770bd1c767505
F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c
F src/vdbeaux.c 85e5dd393628f2a8a7cd9f6c6f13beecfb979af0 F src/vdbeaux.c 54b7ad5d95ff3ac52f97a9a362c93b4f8c01440a
F src/vdbeblob.c b90f7494c408d47ce6835000b01e40b371e27baf F src/vdbeblob.c b90f7494c408d47ce6835000b01e40b371e27baf
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4 F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4
F src/vtab.c 03014b2bfa8096ecac5fcdc80d34cd76e06af52a F src/vtab.c 03014b2bfa8096ecac5fcdc80d34cd76e06af52a
F src/where.c 6b1d4acf10e3a9ba0424a03812fe35d75d45c0e6 F src/where.c f02ecb55e58465055a1fd2f3143deb449b49bb93
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba
@@ -603,7 +603,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 7e8330c8044dc7718e720dbd33f6e2fe970ead77 P 955b15a020e9ea6401fe03a36f5139a03ea80b8a
R d11ee9bd6acba303515dc16046acb770 R 1925857a0a0640a748c55cd88d09327a
U danielk1977 U drh
Z d78d4992a9bc07790c788a8fc06b7da2 Z 06e0ffbaabe30d8dbe94386b95a09746

View File

@@ -1 +1 @@
955b15a020e9ea6401fe03a36f5139a03ea80b8a 0b849805c3a0f562d50623f406279b400d335639

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code associated with the ANALYZE command. ** This file contains code associated with the ANALYZE command.
** **
** @(#) $Id: analyze.c,v 1.29 2008/01/03 09:51:55 danielk1977 Exp $ ** @(#) $Id: analyze.c,v 1.30 2008/01/03 18:03:09 drh Exp $
*/ */
#ifndef SQLITE_OMIT_ANALYZE #ifndef SQLITE_OMIT_ANALYZE
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -241,7 +241,7 @@ static void analyzeDatabase(Parse *pParse, int iDb){
sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3BeginWriteOperation(pParse, 0, iDb);
iStatCur = pParse->nTab++; iStatCur = pParse->nTab++;
openStatTable(pParse, iDb, iStatCur, 0); openStatTable(pParse, iDb, iStatCur, 0);
iMem = pParse->nMem; iMem = pParse->nMem+1;
for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
Table *pTab = (Table*)sqliteHashData(k); Table *pTab = (Table*)sqliteHashData(k);
analyzeOneTable(pParse, pTab, iStatCur, iMem); analyzeOneTable(pParse, pTab, iStatCur, iMem);
@@ -263,7 +263,7 @@ static void analyzeTable(Parse *pParse, Table *pTab){
sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3BeginWriteOperation(pParse, 0, iDb);
iStatCur = pParse->nTab++; iStatCur = pParse->nTab++;
openStatTable(pParse, iDb, iStatCur, pTab->zName); openStatTable(pParse, iDb, iStatCur, pTab->zName);
analyzeOneTable(pParse, pTab, iStatCur, pParse->nMem); analyzeOneTable(pParse, pTab, iStatCur, pParse->nMem+1);
loadAnalysis(pParse, iDb); loadAnalysis(pParse, iDb);
} }

View File

@@ -22,7 +22,7 @@
** COMMIT ** COMMIT
** ROLLBACK ** ROLLBACK
** **
** $Id: build.c,v 1.455 2008/01/03 09:51:55 danielk1977 Exp $ ** $Id: build.c,v 1.456 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -2628,7 +2628,7 @@ void sqlite3CreateIndex(
else if( db->init.busy==0 ){ else if( db->init.busy==0 ){
Vdbe *v; Vdbe *v;
char *zStmt; char *zStmt;
int iMem = pParse->nMem++; int iMem = ++pParse->nMem;
v = sqlite3GetVdbe(pParse); v = sqlite3GetVdbe(pParse);
if( v==0 ) goto exit_create_index; if( v==0 ) goto exit_create_index;

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
** in order to generate code for DELETE FROM statements. ** in order to generate code for DELETE FROM statements.
** **
** $Id: delete.c,v 1.143 2008/01/03 17:31:45 danielk1977 Exp $ ** $Id: delete.c,v 1.144 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -65,8 +65,8 @@ int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
** reads the key and data to insert from memory cells. ** reads the key and data to insert from memory cells.
*/ */
void sqlite3CodeInsert(Parse *p, int iCur, u8 flags){ void sqlite3CodeInsert(Parse *p, int iCur, u8 flags){
int iData = p->nMem++; int iData = ++p->nMem;
int iKey = p->nMem++; int iKey = ++p->nMem;
Vdbe *v = sqlite3GetVdbe(p); Vdbe *v = sqlite3GetVdbe(p);
sqlite3VdbeAddOp2(v, OP_MemStore, iData, 1); sqlite3VdbeAddOp2(v, OP_MemStore, iData, 1);
sqlite3VdbeAddOp2(v, OP_MemStore, iKey, 1); sqlite3VdbeAddOp2(v, OP_MemStore, iKey, 1);
@@ -82,7 +82,7 @@ void sqlite3CodeInsert(Parse *p, int iCur, u8 flags){
*/ */
int sqlite3StackToReg(Parse *p, int nVal){ int sqlite3StackToReg(Parse *p, int nVal){
int i; int i;
int iRet = p->nMem; int iRet = p->nMem+1;
Vdbe *v = sqlite3GetVdbe(p); Vdbe *v = sqlite3GetVdbe(p);
assert(v); assert(v);
p->nMem += nVal; p->nMem += nVal;
@@ -263,7 +263,7 @@ void sqlite3DeleteFrom(
** we are counting rows. ** we are counting rows.
*/ */
if( db->flags & SQLITE_CountRows ){ if( db->flags & SQLITE_CountRows ){
memCnt = pParse->nMem++; memCnt = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemInt, 0, memCnt); sqlite3VdbeAddOp2(v, OP_MemInt, 0, memCnt);
} }
@@ -346,7 +346,7 @@ void sqlite3DeleteFrom(
sqlite3VdbeAddOp1(v, OP_StackDepth, -1); sqlite3VdbeAddOp1(v, OP_StackDepth, -1);
if( triggers_exist ){ if( triggers_exist ){
int mem1 = pParse->nMem++; int mem1 = ++pParse->nMem;
if( !isView ){ if( !isView ){
sqlite3VdbeAddOp1(v, OP_MemStore, mem1); sqlite3VdbeAddOp1(v, OP_MemStore, mem1);
} }

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.326 2008/01/03 07:54:24 danielk1977 Exp $ ** $Id: expr.c,v 1.327 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -307,7 +307,7 @@ Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken){
return 0; /* Malloc failed */ return 0; /* Malloc failed */
} }
depth = atoi((char*)&pToken->z[1]); depth = atoi((char*)&pToken->z[1]);
p->iTable = pParse->nMem++; p->iTable = ++pParse->nMem;
sqlite3VdbeAddOp1(v, OP_Dup, depth); sqlite3VdbeAddOp1(v, OP_Dup, depth);
sqlite3VdbeAddOp2(v, OP_MemStore, p->iTable, 1); sqlite3VdbeAddOp2(v, OP_MemStore, p->iTable, 1);
return p; return p;
@@ -1600,7 +1600,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int mustBeUnique){
*/ */
assert(v); assert(v);
if( iCol<0 ){ if( iCol<0 ){
int iMem = pParse->nMem++; int iMem = ++pParse->nMem;
int iAddr; int iAddr;
Table *pTab = p->pSrc->a[0].pTab; Table *pTab = p->pSrc->a[0].pTab;
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
@@ -1635,7 +1635,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int mustBeUnique){
&& (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None)) && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))
){ ){
int iDb; int iDb;
int iMem = pParse->nMem++; int iMem = ++pParse->nMem;
int iAddr; int iAddr;
char *pKey; char *pKey;
@@ -1699,7 +1699,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
** save the results, and reuse the same result on subsequent invocations. ** save the results, and reuse the same result on subsequent invocations.
*/ */
if( !ExprHasAnyProperty(pExpr, EP_VarSelect) && !pParse->trigStack ){ if( !ExprHasAnyProperty(pExpr, EP_VarSelect) && !pParse->trigStack ){
int mem = pParse->nMem++; int mem = ++pParse->nMem;
sqlite3VdbeAddOp1(v, OP_MemLoad, mem); sqlite3VdbeAddOp1(v, OP_MemLoad, mem);
testAddr = sqlite3VdbeAddOp0(v, OP_If); testAddr = sqlite3VdbeAddOp0(v, OP_If);
assert( testAddr>0 || pParse->db->mallocFailed ); assert( testAddr>0 || pParse->db->mallocFailed );
@@ -1804,7 +1804,7 @@ void sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
SelectDest dest; SelectDest dest;
pSel = pExpr->pSelect; pSel = pExpr->pSelect;
dest.iParm = pParse->nMem++; dest.iParm = ++pParse->nMem;
if( pExpr->op==TK_SELECT ){ if( pExpr->op==TK_SELECT ){
dest.eDest = SRT_Mem; dest.eDest = SRT_Mem;
sqlite3VdbeAddOp2(v, OP_MemNull, 0, dest.iParm); sqlite3VdbeAddOp2(v, OP_MemNull, 0, dest.iParm);
@@ -2343,7 +2343,7 @@ void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr){
addr2 = sqlite3VdbeCurrentAddr(v); addr2 = sqlite3VdbeCurrentAddr(v);
if( addr2>addr1+1 if( addr2>addr1+1
|| ((pOp = sqlite3VdbeGetOp(v, addr1))!=0 && pOp->opcode==OP_Function) ){ || ((pOp = sqlite3VdbeGetOp(v, addr1))!=0 && pOp->opcode==OP_Function) ){
iMem = pExpr->iTable = pParse->nMem++; iMem = pExpr->iTable = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemStore, iMem, 0); sqlite3VdbeAddOp2(v, OP_MemStore, iMem, 0);
pExpr->op = TK_REGISTER; pExpr->op = TK_REGISTER;
} }
@@ -2364,7 +2364,7 @@ int sqlite3ExprIntoReg(Parse *pParse, Expr *pExpr, int target){
if( v==0 ) return -1; if( v==0 ) return -1;
sqlite3ExprCode(pParse, pExpr); sqlite3ExprCode(pParse, pExpr);
if( target<0 ){ if( target<0 ){
target = pParse->nMem++; target = ++pParse->nMem;
} }
sqlite3VdbeAddOp2(v, OP_MemStore, target, 1); sqlite3VdbeAddOp2(v, OP_MemStore, target, 1);
return target; return target;
@@ -2724,7 +2724,7 @@ static int analyzeAggregate(void *pArg, Expr *pExpr){
pCol->pTab = pExpr->pTab; pCol->pTab = pExpr->pTab;
pCol->iTable = pExpr->iTable; pCol->iTable = pExpr->iTable;
pCol->iColumn = pExpr->iColumn; pCol->iColumn = pExpr->iColumn;
pCol->iMem = pParse->nMem++; pCol->iMem = ++pParse->nMem;
pCol->iSorterColumn = -1; pCol->iSorterColumn = -1;
pCol->pExpr = pExpr; pCol->pExpr = pExpr;
if( pAggInfo->pGroupBy ){ if( pAggInfo->pGroupBy ){
@@ -2780,7 +2780,7 @@ static int analyzeAggregate(void *pArg, Expr *pExpr){
if( i>=0 ){ if( i>=0 ){
pItem = &pAggInfo->aFunc[i]; pItem = &pAggInfo->aFunc[i];
pItem->pExpr = pExpr; pItem->pExpr = pExpr;
pItem->iMem = pParse->nMem++; pItem->iMem = ++pParse->nMem;
pItem->pFunc = sqlite3FindFunction(pParse->db, pItem->pFunc = sqlite3FindFunction(pParse->db,
(char*)pExpr->token.z, pExpr->token.n, (char*)pExpr->token.z, pExpr->token.n,
pExpr->pList ? pExpr->pList->nExpr : 0, enc, 0); pExpr->pList ? pExpr->pList->nExpr : 0, enc, 0);

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 INSERT statements in SQLite. ** to handle INSERT statements in SQLite.
** **
** $Id: insert.c,v 1.206 2008/01/03 17:31:45 danielk1977 Exp $ ** $Id: insert.c,v 1.207 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -146,7 +146,7 @@ static int readsTable(Vdbe *v, int iStartAddr, int iDb, Table *pTab){
** This routine returns the index of the mem[] cell that contains ** This routine returns the index of the mem[] cell that contains
** the maximum rowid counter. ** the maximum rowid counter.
** **
** Two memory cells are allocated. The next memory cell after the ** Two memory cells are allocated. The next memory cell befor the
** one returned holds the rowid in sqlite_sequence where we will ** one returned holds the rowid in sqlite_sequence where we will
** write back the revised maximum rowid. ** write back the revised maximum rowid.
*/ */
@@ -163,8 +163,8 @@ static int autoIncBegin(
int addr; int addr;
assert( v ); assert( v );
addr = sqlite3VdbeCurrentAddr(v); addr = sqlite3VdbeCurrentAddr(v);
memId = pParse->nMem+1;
pParse->nMem += 2; pParse->nMem += 2;
memId = pParse->nMem;
sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenRead); sqlite3OpenTable(pParse, iCur, iDb, pDb->pSchema->pSeqTab, OP_OpenRead);
sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addr+12); sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addr+12);
sqlite3VdbeAddOp2(v, OP_Column, iCur, 0); sqlite3VdbeAddOp2(v, OP_Column, iCur, 0);
@@ -618,7 +618,7 @@ void sqlite3Insert(
/* Initialize the count of rows to be inserted /* Initialize the count of rows to be inserted
*/ */
if( db->flags & SQLITE_CountRows ){ if( db->flags & SQLITE_CountRows ){
iCntMem = pParse->nMem++; iCntMem = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemInt, 0, iCntMem); sqlite3VdbeAddOp2(v, OP_MemInt, 0, iCntMem);
} }

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** This file contains code used to implement the PRAGMA command.
** **
** $Id: pragma.c,v 1.156 2008/01/03 01:28:59 drh Exp $ ** $Id: pragma.c,v 1.157 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -147,7 +147,7 @@ static int changeTempStorage(Parse *pParse, const char *zStorageType){
*/ */
static void returnSingleInt(Parse *pParse, const char *zLabel, int value){ static void returnSingleInt(Parse *pParse, const char *zLabel, int value){
Vdbe *v = sqlite3GetVdbe(pParse); Vdbe *v = sqlite3GetVdbe(pParse);
int mem = pParse->nMem++; int mem = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemInt, value, mem); sqlite3VdbeAddOp2(v, OP_MemInt, value, mem);
if( pParse->explain==0 ){ if( pParse->explain==0 ){
sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetNumCols(v, 1);
@@ -492,11 +492,11 @@ void sqlite3Pragma(
iLimit = 0x7fffffff; iLimit = 0x7fffffff;
} }
sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3BeginWriteOperation(pParse, 0, iDb);
sqlite3VdbeAddOp2(v, OP_MemInt, iLimit, 0); sqlite3VdbeAddOp2(v, OP_MemInt, iLimit, 1);
addr = sqlite3VdbeAddOp2(v, OP_IncrVacuum, iDb, 0); addr = sqlite3VdbeAddOp2(v, OP_IncrVacuum, iDb, 0);
sqlite3VdbeAddOp2(v, OP_Callback, 0, 0); sqlite3VdbeAddOp2(v, OP_Callback, 0, 0);
sqlite3VdbeAddOp2(v, OP_MemIncr, -1, 0); sqlite3VdbeAddOp2(v, OP_MemIncr, -1, 1);
sqlite3VdbeAddOp2(v, OP_IfMemPos, 0, addr); sqlite3VdbeAddOp2(v, OP_IfMemPos, 1, addr);
sqlite3VdbeJumpHere(v, addr); sqlite3VdbeJumpHere(v, addr);
}else }else
#endif #endif
@@ -830,7 +830,7 @@ void sqlite3Pragma(
** error message ** error message
*/ */
static const VdbeOpList endCode[] = { static const VdbeOpList endCode[] = {
{ OP_MemLoad, 0, 0, 0}, { OP_MemLoad, 1, 0, 0},
{ OP_Integer, 0, 0, 0}, { OP_Integer, 0, 0, 0},
{ OP_Ne, 0, 0, 0}, /* 2 */ { OP_Ne, 0, 0, 0}, /* 2 */
{ OP_String8, 0, 0, 0}, /* 3 */ { OP_String8, 0, 0, 0}, /* 3 */
@@ -852,7 +852,7 @@ void sqlite3Pragma(
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
} }
} }
sqlite3VdbeAddOp2(v, OP_MemInt, mxErr, 0); sqlite3VdbeAddOp2(v, OP_MemInt, mxErr, 1);
/* Do an integrity check on each database file */ /* Do an integrity check on each database file */
for(i=0; i<db->nDb; i++){ for(i=0; i<db->nDb; i++){
@@ -863,7 +863,7 @@ void sqlite3Pragma(
if( OMIT_TEMPDB && i==1 ) continue; if( OMIT_TEMPDB && i==1 ) continue;
sqlite3CodeVerifySchema(pParse, i); sqlite3CodeVerifySchema(pParse, i);
addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 0, 0); addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 1, 0);
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
sqlite3VdbeJumpHere(v, addr); sqlite3VdbeJumpHere(v, addr);
@@ -881,7 +881,7 @@ void sqlite3Pragma(
} }
} }
if( cnt==0 ) continue; if( cnt==0 ) continue;
sqlite3VdbeAddOp2(v, OP_IntegrityCk, 0, i); sqlite3VdbeAddOp2(v, OP_IntegrityCk, 1, i);
addr = sqlite3VdbeAddOp2(v, OP_IsNull, -1, 0); addr = sqlite3VdbeAddOp2(v, OP_IsNull, -1, 0);
sqlite3VdbeAddOp4(v, OP_String8, 0, 0, 0, sqlite3VdbeAddOp4(v, OP_String8, 0, 0, 0,
sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName), sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zName),
@@ -899,17 +899,17 @@ void sqlite3Pragma(
int loopTop; int loopTop;
if( pTab->pIndex==0 ) continue; if( pTab->pIndex==0 ) continue;
addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 0, 0); addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 1, 0);
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
sqlite3VdbeJumpHere(v, addr); sqlite3VdbeJumpHere(v, addr);
sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
sqlite3VdbeAddOp2(v, OP_MemInt, 0, 1); sqlite3VdbeAddOp2(v, OP_MemInt, 0, 2);
loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
sqlite3VdbeAddOp2(v, OP_MemIncr, 1, 1); sqlite3VdbeAddOp2(v, OP_MemIncr, 1, 2);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2; int jmp2;
static const VdbeOpList idxErr[] = { static const VdbeOpList idxErr[] = {
{ OP_MemIncr, -1, 0, 0}, { OP_MemIncr, -1, 1, 0},
{ OP_String8, 0, 0, 0}, /* 1 */ { OP_String8, 0, 0, 0}, /* 1 */
{ OP_Rowid, 1, 0, 0}, { OP_Rowid, 1, 0, 0},
{ OP_String8, 0, 0, 0}, /* 3 */ { OP_String8, 0, 0, 0}, /* 3 */
@@ -929,21 +929,21 @@ void sqlite3Pragma(
sqlite3VdbeJumpHere(v, loopTop); sqlite3VdbeJumpHere(v, loopTop);
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
static const VdbeOpList cntIdx[] = { static const VdbeOpList cntIdx[] = {
{ OP_MemInt, 0, 2, 0}, { OP_MemInt, 0, 3, 0},
{ OP_Rewind, 0, 0, 0}, /* 1 */ { OP_Rewind, 0, 0, 0}, /* 1 */
{ OP_MemIncr, 1, 2, 0}, { OP_MemIncr, 1, 3, 0},
{ OP_Next, 0, 0, 0}, /* 3 */ { OP_Next, 0, 0, 0}, /* 3 */
{ OP_MemLoad, 1, 0, 0},
{ OP_MemLoad, 2, 0, 0}, { OP_MemLoad, 2, 0, 0},
{ OP_MemLoad, 3, 0, 0},
{ OP_Eq, 0, 0, 0}, /* 6 */ { OP_Eq, 0, 0, 0}, /* 6 */
{ OP_MemIncr, -1, 0, 0}, { OP_MemIncr, -1, 1, 0},
{ OP_String8, 0, 0, 0}, /* 8 */ { OP_String8, 0, 0, 0}, /* 8 */
{ OP_String8, 0, 0, 0}, /* 9 */ { OP_String8, 0, 0, 0}, /* 9 */
{ OP_Concat, 0, 0, 0}, { OP_Concat, 0, 0, 0},
{ OP_Callback, 1, 0, 0}, { OP_Callback, 1, 0, 0},
}; };
if( pIdx->tnum==0 ) continue; if( pIdx->tnum==0 ) continue;
addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 0, 0); addr = sqlite3VdbeAddOp2(v, OP_IfMemPos, 1, 0);
sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
sqlite3VdbeJumpHere(v, addr); sqlite3VdbeJumpHere(v, addr);
addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);

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 SELECT statements in SQLite. ** to handle SELECT statements in SQLite.
** **
** $Id: select.c,v 1.380 2008/01/03 09:51:55 danielk1977 Exp $ ** $Id: select.c,v 1.381 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -541,7 +541,7 @@ static int selectInnerLoop(
}else{ }else{
n = pEList->nExpr; n = pEList->nExpr;
} }
iMem = pParse->nMem; iMem = ++pParse->nMem;
pParse->nMem += n+1; pParse->nMem += n+1;
sqlite3VdbeAddOp2(v, OP_MemInt, n, iMem); sqlite3VdbeAddOp2(v, OP_MemInt, n, iMem);
if( nColumn>0 ){ if( nColumn>0 ){
@@ -1746,8 +1746,8 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
** no rows. ** no rows.
*/ */
if( p->pLimit ){ if( p->pLimit ){
p->iLimit = iLimit = pParse->nMem; p->iLimit = iLimit = ++pParse->nMem;
pParse->nMem += 2; pParse->nMem++;
v = sqlite3GetVdbe(pParse); v = sqlite3GetVdbe(pParse);
if( v==0 ) return; if( v==0 ) return;
sqlite3ExprCode(pParse, p->pLimit); sqlite3ExprCode(pParse, p->pLimit);
@@ -1758,7 +1758,7 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
sqlite3VdbeAddOp2(v, OP_MemLoad, iLimit, 0); sqlite3VdbeAddOp2(v, OP_MemLoad, iLimit, 0);
} }
if( p->pOffset ){ if( p->pOffset ){
p->iOffset = iOffset = pParse->nMem++; p->iOffset = iOffset = ++pParse->nMem;
v = sqlite3GetVdbe(pParse); v = sqlite3GetVdbe(pParse);
if( v==0 ) return; if( v==0 ) return;
sqlite3ExprCode(pParse, p->pOffset); sqlite3ExprCode(pParse, p->pOffset);
@@ -3449,11 +3449,11 @@ int sqlite3Select(
/* Initialize memory locations used by GROUP BY aggregate processing /* Initialize memory locations used by GROUP BY aggregate processing
*/ */
iUseFlag = pParse->nMem++; iUseFlag = ++pParse->nMem;
iAbortFlag = pParse->nMem++; iAbortFlag = ++pParse->nMem;
iAMem = pParse->nMem; iAMem = pParse->nMem + 1;
pParse->nMem += pGroupBy->nExpr; pParse->nMem += pGroupBy->nExpr;
iBMem = pParse->nMem; iBMem = pParse->nMem + 1;
pParse->nMem += pGroupBy->nExpr; pParse->nMem += pGroupBy->nExpr;
sqlite3VdbeAddOp2(v, OP_MemInt, 0, iAbortFlag); sqlite3VdbeAddOp2(v, OP_MemInt, 0, iAbortFlag);
VdbeComment((v, "clear abort flag")); VdbeComment((v, "clear abort flag"));

View File

@@ -243,8 +243,8 @@ void sqlite3FinishTrigger(
}; };
int addr; int addr;
Vdbe *v; Vdbe *v;
int iKey = pParse->nMem++; int iKey = ++pParse->nMem;
int iData = pParse->nMem++; int iData = ++pParse->nMem;
/* Make an entry in the sqlite_master table */ /* Make an entry in the sqlite_master table */
v = sqlite3GetVdbe(pParse); v = sqlite3GetVdbe(pParse);

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.153 2008/01/03 17:31:45 danielk1977 Exp $ ** $Id: update.c,v 1.154 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -268,7 +268,7 @@ void sqlite3Update(
if( v==0 ) goto update_cleanup; if( v==0 ) goto update_cleanup;
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
sqlite3BeginWriteOperation(pParse, 1, iDb); sqlite3BeginWriteOperation(pParse, 1, iDb);
mem1 = pParse->nMem++; mem1 = ++pParse->nMem;
#ifndef SQLITE_OMIT_VIRTUALTABLE #ifndef SQLITE_OMIT_VIRTUALTABLE
/* Virtual tables must be handled separately */ /* Virtual tables must be handled separately */
@@ -353,7 +353,7 @@ void sqlite3Update(
/* Initialize the count of updated rows /* Initialize the count of updated rows
*/ */
if( db->flags & SQLITE_CountRows && !pParse->trigStack ){ if( db->flags & SQLITE_CountRows && !pParse->trigStack ){
memCnt = pParse->nMem++; memCnt = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemInt, 0, memCnt); sqlite3VdbeAddOp2(v, OP_MemInt, 0, memCnt);
} }

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.670 2008/01/03 17:31:45 danielk1977 Exp $ ** $Id: vdbe.c,v 1.671 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -1040,8 +1040,8 @@ case OP_ResultRow: { /* no-push */
Mem *pMem; Mem *pMem;
int i; int i;
assert( p->nResColumn==pOp->p2 ); assert( p->nResColumn==pOp->p2 );
assert( pOp->p1>=0 ); assert( pOp->p1>0 );
assert( pOp->p1+pOp->p2<p->nMem ); assert( pOp->p1+pOp->p2<=p->nMem );
/* Data in the pager might be moved or changed out from under us /* Data in the pager might be moved or changed out from under us
** in between the return from this sqlite3_step() call and the ** in between the return from this sqlite3_step() call and the
@@ -2391,10 +2391,10 @@ case OP_MakeRecord: {
if( pOp->opcode==OP_RegMakeRec || pOp->opcode==OP_RegMakeIRec ){ if( pOp->opcode==OP_RegMakeRec || pOp->opcode==OP_RegMakeIRec ){
Mem *pCount; Mem *pCount;
assert( nField>=0 && nField<p->nMem ); assert( nField>0 && nField<=p->nMem );
pCount = &p->aMem[nField]; pCount = &p->aMem[nField];
assert( pCount->flags & MEM_Int ); assert( pCount->flags & MEM_Int );
assert( pCount->u.i>=0 && pCount->u.i+nField<p->nMem ); assert( pCount->u.i>0 && pCount->u.i+nField<=p->nMem );
leaveOnStack = 1; leaveOnStack = 1;
nField = pCount->u.i; nField = pCount->u.i;
pData0 = &pCount[1]; pData0 = &pCount[1];
@@ -3501,7 +3501,7 @@ case OP_NewRowid: {
#ifndef SQLITE_OMIT_AUTOINCREMENT #ifndef SQLITE_OMIT_AUTOINCREMENT
if( pOp->p2 ){ if( pOp->p2 ){
Mem *pMem; Mem *pMem;
assert( pOp->p2>0 && pOp->p2<p->nMem ); /* P2 is a valid memory cell */ assert( pOp->p2>0 && pOp->p2<=p->nMem ); /* P2 is a valid memory cell */
pMem = &p->aMem[pOp->p2]; pMem = &p->aMem[pOp->p2];
sqlite3VdbeMemIntegerify(pMem); sqlite3VdbeMemIntegerify(pMem);
assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P2) holds an integer */ assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P2) holds an integer */
@@ -4452,7 +4452,7 @@ case OP_IntegrityCk: {
aRoot = sqlite3_malloc( sizeof(int)*(nRoot+1) ); aRoot = sqlite3_malloc( sizeof(int)*(nRoot+1) );
if( aRoot==0 ) goto no_mem; if( aRoot==0 ) goto no_mem;
j = pOp->p1; j = pOp->p1;
assert( j>=0 && j<p->nMem ); assert( j>0 && j<=p->nMem );
pnErr = &p->aMem[j]; pnErr = &p->aMem[j];
assert( (pnErr->flags & MEM_Int)!=0 ); assert( (pnErr->flags & MEM_Int)!=0 );
for(j=0; j<nRoot; j++){ for(j=0; j<nRoot; j++){
@@ -4573,7 +4573,7 @@ case OP_ContextPop: { /* no-push */
*/ */
case OP_MemStore: { /* no-push */ case OP_MemStore: { /* no-push */
assert( pTos>=p->aStack ); assert( pTos>=p->aStack );
assert( pOp->p1>=0 && pOp->p1<p->nMem ); assert( pOp->p1>0 && pOp->p1<=p->nMem );
rc = sqlite3VdbeMemMove(&p->aMem[pOp->p1], pTos); rc = sqlite3VdbeMemMove(&p->aMem[pOp->p1], pTos);
pTos--; pTos--;
@@ -4595,7 +4595,7 @@ case OP_MemStore: { /* no-push */
*/ */
case OP_MemLoad: { case OP_MemLoad: {
int i = pOp->p1; int i = pOp->p1;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pTos++; pTos++;
sqlite3VdbeMemShallowCopy(pTos, &p->aMem[i], MEM_Ephem); sqlite3VdbeMemShallowCopy(pTos, &p->aMem[i], MEM_Ephem);
break; break;
@@ -4614,7 +4614,7 @@ case OP_MemMax: { /* no-push */
int i = pOp->p1; int i = pOp->p1;
Mem *pMem; Mem *pMem;
assert( pTos>=p->aStack ); assert( pTos>=p->aStack );
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pMem = &p->aMem[i]; pMem = &p->aMem[i];
sqlite3VdbeMemIntegerify(pMem); sqlite3VdbeMemIntegerify(pMem);
sqlite3VdbeMemIntegerify(pTos); sqlite3VdbeMemIntegerify(pTos);
@@ -4635,7 +4635,7 @@ case OP_MemMax: { /* no-push */
case OP_MemIncr: { /* no-push */ case OP_MemIncr: { /* no-push */
int i = pOp->p2; int i = pOp->p2;
Mem *pMem; Mem *pMem;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pMem = &p->aMem[i]; pMem = &p->aMem[i];
assert( pMem->flags==MEM_Int ); assert( pMem->flags==MEM_Int );
pMem->u.i += pOp->p1; pMem->u.i += pOp->p1;
@@ -4652,7 +4652,7 @@ case OP_MemIncr: { /* no-push */
case OP_IfMemPos: { /* no-push */ case OP_IfMemPos: { /* no-push */
int i = pOp->p1; int i = pOp->p1;
Mem *pMem; Mem *pMem;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pMem = &p->aMem[i]; pMem = &p->aMem[i];
assert( pMem->flags==MEM_Int ); assert( pMem->flags==MEM_Int );
if( pMem->u.i>0 ){ if( pMem->u.i>0 ){
@@ -4671,7 +4671,7 @@ case OP_IfMemPos: { /* no-push */
case OP_IfMemNeg: { /* no-push */ case OP_IfMemNeg: { /* no-push */
int i = pOp->p1; int i = pOp->p1;
Mem *pMem; Mem *pMem;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pMem = &p->aMem[i]; pMem = &p->aMem[i];
assert( pMem->flags==MEM_Int ); assert( pMem->flags==MEM_Int );
if( pMem->u.i<0 ){ if( pMem->u.i<0 ){
@@ -4690,7 +4690,7 @@ case OP_IfMemNeg: { /* no-push */
case OP_IfMemZero: { /* no-push */ case OP_IfMemZero: { /* no-push */
int i = pOp->p1; int i = pOp->p1;
Mem *pMem; Mem *pMem;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
pMem = &p->aMem[i]; pMem = &p->aMem[i];
assert( pMem->flags==MEM_Int ); assert( pMem->flags==MEM_Int );
if( pMem->u.i==0 ){ if( pMem->u.i==0 ){
@@ -4705,7 +4705,7 @@ case OP_IfMemZero: { /* no-push */
*/ */
case OP_IfMemNull: { /* no-push */ case OP_IfMemNull: { /* no-push */
int i = pOp->p1; int i = pOp->p1;
assert( i>=0 && i<p->nMem ); assert( i>0 && i<=p->nMem );
if( p->aMem[i].flags & MEM_Null ){ if( p->aMem[i].flags & MEM_Null ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
@@ -4717,7 +4717,7 @@ case OP_IfMemNull: { /* no-push */
** Store a NULL in memory cell P2 ** Store a NULL in memory cell P2
*/ */
case OP_MemNull: { case OP_MemNull: {
assert( pOp->p2>=0 && pOp->p2<p->nMem ); assert( pOp->p2>0 && pOp->p2<=p->nMem );
sqlite3VdbeMemSetNull(&p->aMem[pOp->p2]); sqlite3VdbeMemSetNull(&p->aMem[pOp->p2]);
break; break;
} }
@@ -4727,7 +4727,7 @@ case OP_MemNull: {
** Store the integer value P1 in memory cell P2. ** Store the integer value P1 in memory cell P2.
*/ */
case OP_MemInt: { case OP_MemInt: {
assert( pOp->p2>=0 && pOp->p2<p->nMem ); assert( pOp->p2>0 && pOp->p2<=p->nMem );
sqlite3VdbeMemSetInt64(&p->aMem[pOp->p2], pOp->p1); sqlite3VdbeMemSetInt64(&p->aMem[pOp->p2], pOp->p1);
break; break;
} }
@@ -4739,8 +4739,8 @@ case OP_MemInt: {
** containing a NULL. ** containing a NULL.
*/ */
case OP_MemMove: { case OP_MemMove: {
assert( pOp->p1>=0 && pOp->p1<p->nMem ); assert( pOp->p1>0 && pOp->p1<=p->nMem );
assert( pOp->p2>=0 && pOp->p2<p->nMem ); assert( pOp->p2>0 && pOp->p2<=p->nMem );
rc = sqlite3VdbeMemMove(&p->aMem[pOp->p1], &p->aMem[pOp->p2]); rc = sqlite3VdbeMemMove(&p->aMem[pOp->p1], &p->aMem[pOp->p2]);
break; break;
} }
@@ -4771,7 +4771,7 @@ case OP_AggStep: { /* no-push */
storeTypeInfo(pRec, encoding); storeTypeInfo(pRec, encoding);
} }
ctx.pFunc = pOp->p4.pFunc; ctx.pFunc = pOp->p4.pFunc;
assert( pOp->p1>=0 && pOp->p1<p->nMem ); assert( pOp->p1>0 && pOp->p1<=p->nMem );
ctx.pMem = pMem = &p->aMem[pOp->p1]; ctx.pMem = pMem = &p->aMem[pOp->p1];
pMem->n++; pMem->n++;
ctx.s.flags = MEM_Null; ctx.s.flags = MEM_Null;
@@ -4810,7 +4810,7 @@ case OP_AggStep: { /* no-push */
*/ */
case OP_AggFinal: { /* no-push */ case OP_AggFinal: { /* no-push */
Mem *pMem; Mem *pMem;
assert( pOp->p1>=0 && pOp->p1<p->nMem ); assert( pOp->p1>0 && pOp->p1<=p->nMem );
pMem = &p->aMem[pOp->p1]; pMem = &p->aMem[pOp->p1];
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 ); assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc); rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);

View File

@@ -971,7 +971,7 @@ void sqlite3VdbeMakeReady(
assert( nVar>=0 ); assert( nVar>=0 );
assert( nStack<p->nOp ); assert( nStack<p->nOp );
if( isExplain ){ if( isExplain ){
nStack = 10; nStack = 16;
} }
p->aStack = sqlite3DbMallocZero(db, p->aStack = sqlite3DbMallocZero(db,
nStack*sizeof(p->aStack[0]) /* aStack */ nStack*sizeof(p->aStack[0]) /* aStack */
@@ -979,12 +979,12 @@ void sqlite3VdbeMakeReady(
+ nVar*sizeof(Mem) /* aVar */ + nVar*sizeof(Mem) /* aVar */
+ nVar*sizeof(char*) /* azVar */ + nVar*sizeof(char*) /* azVar */
+ nMem*sizeof(Mem) /* aMem */ + nMem*sizeof(Mem) /* aMem */
+ nCursor*sizeof(Cursor*) /* apCsr */ + nCursor*sizeof(Cursor*) + 1 /* apCsr */
); );
if( !db->mallocFailed ){ if( !db->mallocFailed ){
p->aMem = &p->aStack[nStack]; p->aMem = &p->aStack[nStack-1]; /* aMem[] goes from 1..nMem */
p->nMem = nMem; p->nMem = nMem; /* not from 0..nMem-1 */
p->aVar = &p->aMem[nMem]; p->aVar = &p->aMem[nMem+1];
p->nVar = nVar; p->nVar = nVar;
p->okVar = 0; p->okVar = 0;
p->apArg = (Mem**)&p->aVar[nVar]; p->apArg = (Mem**)&p->aVar[nVar];
@@ -1000,7 +1000,7 @@ void sqlite3VdbeMakeReady(
} }
} }
} }
for(n=0; n<p->nMem; n++){ for(n=1; n<=p->nMem; n++){
p->aMem[n].flags = MEM_Null; p->aMem[n].flags = MEM_Null;
p->aMem[n].db = db; p->aMem[n].db = db;
} }
@@ -1089,7 +1089,7 @@ static void Cleanup(Vdbe *p){
p->pTos = &p->aStack[-1]; p->pTos = &p->aStack[-1];
} }
closeAllCursorsExceptActiveVtabs(p); closeAllCursorsExceptActiveVtabs(p);
releaseMemArray(p->aMem, p->nMem); releaseMemArray(&p->aMem[1], p->nMem);
sqlite3VdbeFifoClear(&p->sFifo); sqlite3VdbeFifoClear(&p->sFifo);
if( p->contextStack ){ if( p->contextStack ){
for(i=0; i<p->contextStackTop; i++){ for(i=0; i<p->contextStackTop; i++){

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.269 2008/01/03 07:54:24 danielk1977 Exp $ ** $Id: where.c,v 1.270 2008/01/03 18:03:09 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -1808,7 +1808,7 @@ static void codeAllEqualityTerms(
** value. If there are IN operators we'll need one for each == or ** value. If there are IN operators we'll need one for each == or
** IN constraint. ** IN constraint.
*/ */
pLevel->iMem = pParse->nMem++; pLevel->iMem = ++pParse->nMem;
if( pLevel->flags & WHERE_COLUMN_IN ){ if( pLevel->flags & WHERE_COLUMN_IN ){
pParse->nMem += pLevel->nEq; pParse->nMem += pLevel->nEq;
termsInMem = 1; termsInMem = 1;
@@ -2260,8 +2260,7 @@ WhereInfo *sqlite3WhereBegin(
** row of the left table of the join. ** row of the left table of the join.
*/ */
if( pLevel->iFrom>0 && (pTabItem[0].jointype & JT_LEFT)!=0 ){ if( pLevel->iFrom>0 && (pTabItem[0].jointype & JT_LEFT)!=0 ){
if( !pParse->nMem ) pParse->nMem++; pLevel->iLeftJoin = ++pParse->nMem;
pLevel->iLeftJoin = pParse->nMem++;
sqlite3VdbeAddOp2(v, OP_MemInt, 0, pLevel->iLeftJoin); sqlite3VdbeAddOp2(v, OP_MemInt, 0, pLevel->iLeftJoin);
VdbeComment((v, "init LEFT JOIN no-match flag")); VdbeComment((v, "init LEFT JOIN no-match flag"));
} }
@@ -2358,7 +2357,7 @@ WhereInfo *sqlite3WhereBegin(
assert( pX!=0 ); assert( pX!=0 );
assert( pEnd->leftCursor==iCur ); assert( pEnd->leftCursor==iCur );
sqlite3ExprCode(pParse, pX->pRight); sqlite3ExprCode(pParse, pX->pRight);
pLevel->iMem = pParse->nMem++; pLevel->iMem = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemStore, pLevel->iMem, 1); sqlite3VdbeAddOp2(v, OP_MemStore, pLevel->iMem, 1);
if( pX->op==TK_LT || pX->op==TK_GT ){ if( pX->op==TK_LT || pX->op==TK_GT ){
testOp = bRev ? OP_Le : OP_Ge; testOp = bRev ? OP_Le : OP_Ge;
@@ -2450,7 +2449,7 @@ WhereInfo *sqlite3WhereBegin(
} }
if( testOp!=OP_Noop ){ if( testOp!=OP_Noop ){
int nCol = nEq + topLimit; int nCol = nEq + topLimit;
pLevel->iMem = pParse->nMem++; pLevel->iMem = ++pParse->nMem;
buildIndexProbe(v, nCol, pIdx); buildIndexProbe(v, nCol, pIdx);
if( bRev ){ if( bRev ){
int op = topEq ? OP_MoveLe : OP_MoveLt; int op = topEq ? OP_MoveLe : OP_MoveLt;
@@ -2489,7 +2488,7 @@ WhereInfo *sqlite3WhereBegin(
int nCol = nEq + btmLimit; int nCol = nEq + btmLimit;
buildIndexProbe(v, nCol, pIdx); buildIndexProbe(v, nCol, pIdx);
if( bRev ){ if( bRev ){
pLevel->iMem = pParse->nMem++; pLevel->iMem = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_MemStore, pLevel->iMem, 1); sqlite3VdbeAddOp2(v, OP_MemStore, pLevel->iMem, 1);
testOp = OP_IdxLT; testOp = OP_IdxLT;
}else{ }else{