1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Some minor name refactoring in where.c. Avoid declaring variables before

initializing them in the amalgamation because VC++ doesn't like that. (CVS 5993)

FossilOrigin-Name: 6ed696e7c03351514278338fa986539cf0fac178
This commit is contained in:
drh
2008-12-08 21:37:14 +00:00
parent e91d16be4d
commit b3190c1501
7 changed files with 67 additions and 60 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sa\sbug\sin\swin32\scommand-line\sclient\sintroduced\sduring\sefforts\sto\sreduce\nthe\snumber\sof\sharmless\scompiler\swarnings\s(check-in\s(5982).)\s(CVS\s5992) C Some\sminor\sname\srefactoring\sin\swhere.c.\s\sAvoid\sdeclaring\svariables\sbefore\ninitializing\sthem\sin\sthe\samalgamation\sbecause\sVC++\sdoesn't\slike\sthat.\s(CVS\s5993)
D 2008-12-08T18:27:31 D 2008-12-08T21:37:15
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7 F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -119,7 +119,7 @@ F src/insert.c 73c4b33767d9540f8ead5d903504ed93f48ad147
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3 F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
F src/loadext.c 2f53996c693a347edc2d773e9217dde49d96ae64 F src/loadext.c 2f53996c693a347edc2d773e9217dde49d96ae64
F src/main.c d67d2eee7a643a4a894e5de91231a99ad88400b9 F src/main.c 951f0836d7f454f7bfc2855b6fc7a90debab10e4
F src/malloc.c 89c7c58fbec06b80101fdc6dcdf9ee849b7cd7ac F src/malloc.c 89c7c58fbec06b80101fdc6dcdf9ee849b7cd7ac
F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
F src/mem1.c bb8e26adde7d463270e961f045802c61dbabc8f1 F src/mem1.c bb8e26adde7d463270e961f045802c61dbabc8f1
@@ -155,7 +155,7 @@ F src/select.c 1d3616e4e48f6c15a0c69bf14bc5423f31624f87
F src/shell.c 484bddeefac9314be18d4a60d401e93848274ee8 F src/shell.c 484bddeefac9314be18d4a60d401e93848274ee8
F src/sqlite.h.in f13b2f27265b78226240cb0d2e07f165e2110bd9 F src/sqlite.h.in f13b2f27265b78226240cb0d2e07f165e2110bd9
F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17
F src/sqliteInt.h 7bdc5726dff17a2e92b23d478b7024c535d77a47 F src/sqliteInt.h f97f357ecd3d681b19d1d85e64889d9ecd321781
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76
F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8 F src/table.c 22744786199c9195720c15a7a42cb97b2e2728d8
@@ -191,7 +191,7 @@ F src/test_wsd.c c297d7d6b8a990239e1bd25935e81d612d8ae31d
F src/tokenize.c aaa5fa6a4536a9dd7c855a3f66f32508f1612138 F src/tokenize.c aaa5fa6a4536a9dd7c855a3f66f32508f1612138
F src/trigger.c b86eb6d216c0014138f858a04185113cb54518e4 F src/trigger.c b86eb6d216c0014138f858a04185113cb54518e4
F src/update.c 7143ac31d26dee156277126e9a7c5be953b18347 F src/update.c 7143ac31d26dee156277126e9a7c5be953b18347
F src/utf.c 86dc0f8076f606432a01f1498ae054c32de1f9d2 F src/utf.c 3d087d22b7a2d68aee32919713251b30fd327fc0
F src/util.c b9a5d1c4c1a433e17d5828f9717fac763016a2cb F src/util.c b9a5d1c4c1a433e17d5828f9717fac763016a2cb
F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9 F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9
F src/vdbe.c c7da2727447ef5ebe9a25ed37796a493fd12d781 F src/vdbe.c c7da2727447ef5ebe9a25ed37796a493fd12d781
@@ -203,7 +203,7 @@ F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
F src/vdbemem.c c4da6cee44bbd6e4ecc0129d76330fb16c29d432 F src/vdbemem.c c4da6cee44bbd6e4ecc0129d76330fb16c29d432
F src/vtab.c 02c51eac45dbff1a1d6e73f58febf92ecb563f7f F src/vtab.c 02c51eac45dbff1a1d6e73f58febf92ecb563f7f
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
F src/where.c d27611213e9fcbe99f4158bffd7c917a2b8672f0 F src/where.c 538cbf219002ba078dec8203fdb9b5101d46415c
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
@@ -649,7 +649,7 @@ F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
F tool/mkkeywordhash.c 7cd8f12dea17d26e4b2c6dee8be13515248da069 F tool/mkkeywordhash.c 7cd8f12dea17d26e4b2c6dee8be13515248da069
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c.tcl 75cb8cdbea59c0db53a2393df15229376c211ca1 F tool/mksqlite3c.tcl c259bcf64ae8fce346e3ae302c3fd6db977f89a8
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -664,7 +664,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 73c7302c5f76a2f61ecd75f8bda69bb500d3119c P 6c0b2e7579ee5504617831a5e8bb6193e283ad30
R e35fc03527ddf199e75a6f59bd7d841e R 16d93897c611a643e89664ca78d16163
U drh U drh
Z 113eac2b3090ac202a89e92fb4135418 Z 7c4f110d07988bd3998073bc21e9ea4f

View File

@@ -1 +1 @@
6c0b2e7579ee5504617831a5e8bb6193e283ad30 6ed696e7c03351514278338fa986539cf0fac178

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.514 2008/11/19 09:05:27 danielk1977 Exp $ ** $Id: main.c,v 1.515 2008/12/08 21:37:15 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -32,7 +32,9 @@
/* /*
** The version of the library ** The version of the library
*/ */
#ifndef SQLITE_AMALGAMATION
const char sqlite3_version[] = SQLITE_VERSION; const char sqlite3_version[] = SQLITE_VERSION;
#endif
const char *sqlite3_libversion(void){ return sqlite3_version; } const char *sqlite3_libversion(void){ return sqlite3_version; }
int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.804 2008/12/08 18:19:18 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.805 2008/12/08 21:37:15 drh Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -383,7 +383,7 @@ typedef INT8_TYPE i8; /* 1-byte signed integer */
** evaluated at runtime. ** evaluated at runtime.
*/ */
#ifdef SQLITE_AMALGAMATION #ifdef SQLITE_AMALGAMATION
const int sqlite3one; const int sqlite3one = 1;
#else #else
extern const int sqlite3one; extern const int sqlite3one;
#endif #endif
@@ -1523,16 +1523,16 @@ struct WhereLevel {
Index *pIdx; /* Index used. NULL if no index */ Index *pIdx; /* Index used. NULL if no index */
int iTabCur; /* The VDBE cursor used to access the table */ int iTabCur; /* The VDBE cursor used to access the table */
int iIdxCur; /* The VDBE cursor used to access pIdx */ int iIdxCur; /* The VDBE cursor used to access pIdx */
int brk; /* Jump here to break out of the loop */ int addrBrk; /* Jump here to break out of the loop */
int nxt; /* Jump here to start the next IN combination */ int addrNxt; /* Jump here to start the next IN combination */
int cont; /* Jump here to continue with the next loop cycle */ int addrCont; /* Jump here to continue with the next loop cycle */
int top; /* First instruction of interior of the loop */ int addrFirst; /* First instruction of interior of the loop */
int op, p1, p2, p5; /* Opcode used to terminate the loop */ int op, p1, p2, p5; /* Opcode used to terminate the loop */
int nEq; /* Number of == or IN constraints on this loop */ int nEq; /* Number of == or IN constraints on this loop */
int nIn; /* Number of IN operators constraining this loop */ int nIn; /* Number of IN operators constraining this loop */
struct InLoop { struct InLoop {
int iCur; /* The VDBE cursor used by this IN operator */ int iCur; /* The VDBE cursor used by this IN operator */
int topAddr; /* Top of the IN loop */ int addrInTop; /* Top of the IN loop */
} *aInLoop; /* Information about each nested IN operator */ } *aInLoop; /* Information about each nested IN operator */
sqlite3_index_info *pBestIdx; /* Index information for this level */ sqlite3_index_info *pBestIdx; /* Index information for this level */

View File

@@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8, ** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE. ** UTF-16, UTF-16BE, and UTF-16LE.
** **
** $Id: utf.c,v 1.66 2008/11/07 03:29:34 drh Exp $ ** $Id: utf.c,v 1.67 2008/12/08 21:37:15 drh Exp $
** **
** Notes on UTF-8: ** Notes on UTF-8:
** **
@@ -39,11 +39,13 @@
#include <assert.h> #include <assert.h>
#include "vdbeInt.h" #include "vdbeInt.h"
#ifndef SQLITE_AMALGAMATION
/* /*
** The following constant value is used by the SQLITE_BIGENDIAN and ** The following constant value is used by the SQLITE_BIGENDIAN and
** SQLITE_LITTLEENDIAN macros. ** SQLITE_LITTLEENDIAN macros.
*/ */
const int sqlite3one = 1; const int sqlite3one = 1;
#endif /* SQLITE_AMALGAMATION */
/* /*
** This lookup table is used to help decode the first byte of ** This lookup table is used to help decode the first byte of

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.333 2008/12/05 17:17:08 drh Exp $ ** $Id: where.c,v 1.334 2008/12/08 21:37:16 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -238,7 +238,7 @@ static void whereClauseClear(WhereClause *pWC){
** calling this routine. Such pointers may be reinitialized by referencing ** calling this routine. Such pointers may be reinitialized by referencing
** the pWC->a[] array. ** the pWC->a[] array.
*/ */
static int whereClauseInsert(WhereClause *pWC, Expr *p, int wtFlags){ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
WhereTerm *pTerm; WhereTerm *pTerm;
int idx; int idx;
if( pWC->nTerm>=pWC->nSlot ){ if( pWC->nTerm>=pWC->nSlot ){
@@ -1841,7 +1841,7 @@ static int codeEqualityTerm(
sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);
VdbeComment((v, "%.*s", pX->span.n, pX->span.z)); VdbeComment((v, "%.*s", pX->span.n, pX->span.z));
if( pLevel->nIn==0 ){ if( pLevel->nIn==0 ){
pLevel->nxt = sqlite3VdbeMakeLabel(v); pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
} }
pLevel->nIn++; pLevel->nIn++;
pLevel->aInLoop = sqlite3DbReallocOrFree(pParse->db, pLevel->aInLoop, pLevel->aInLoop = sqlite3DbReallocOrFree(pParse->db, pLevel->aInLoop,
@@ -1851,9 +1851,9 @@ static int codeEqualityTerm(
pIn += pLevel->nIn - 1; pIn += pLevel->nIn - 1;
pIn->iCur = iTab; pIn->iCur = iTab;
if( eType==IN_INDEX_ROWID ){ if( eType==IN_INDEX_ROWID ){
pIn->topAddr = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg); pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);
}else{ }else{
pIn->topAddr = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg); pIn->addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg);
} }
sqlite3VdbeAddOp1(v, OP_IsNull, iReg); sqlite3VdbeAddOp1(v, OP_IsNull, iReg);
}else{ }else{
@@ -1928,7 +1928,7 @@ static int codeAllEqualityTerms(
testcase( pTerm->eOperator & WO_ISNULL ); testcase( pTerm->eOperator & WO_ISNULL );
testcase( pTerm->eOperator & WO_IN ); testcase( pTerm->eOperator & WO_IN );
if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){ if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->brk); sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
} }
} }
return regBase; return regBase;
@@ -2063,7 +2063,7 @@ WhereInfo *sqlite3WhereBegin(
int i; /* Loop counter */ int i; /* Loop counter */
WhereInfo *pWInfo; /* Will become the return value of this function */ WhereInfo *pWInfo; /* Will become the return value of this function */
Vdbe *v = pParse->pVdbe; /* The virtual database engine */ Vdbe *v = pParse->pVdbe; /* The virtual database engine */
int brk, cont = 0; /* Addresses used during code generation */ int addrBrk, addrCont = 0; /* Addresses used during code generation */
Bitmask notReady; /* Cursors that are not yet positioned */ Bitmask notReady; /* Cursors that are not yet positioned */
WhereTerm *pTerm; /* A single term in the WHERE clause */ WhereTerm *pTerm; /* A single term in the WHERE clause */
ExprMaskSet maskSet; /* The expression mask set */ ExprMaskSet maskSet; /* The expression mask set */
@@ -2371,7 +2371,7 @@ WhereInfo *sqlite3WhereBegin(
int j, k; int j, k;
int iCur = pTabItem->iCursor; /* The VDBE cursor for the table */ int iCur = pTabItem->iCursor; /* The VDBE cursor for the table */
Index *pIdx; /* The index we will be using */ Index *pIdx; /* The index we will be using */
int nxt; /* Where to jump to continue with the next IN case */ int addrNxt; /* Where to jump to continue with the next IN case */
int iIdxCur; /* The VDBE cursor for the index */ int iIdxCur; /* The VDBE cursor for the index */
int omitTable; /* True if we use the index only */ int omitTable; /* True if we use the index only */
int bRev; /* True if we need to scan in reverse order */ int bRev; /* True if we need to scan in reverse order */
@@ -2384,17 +2384,17 @@ WhereInfo *sqlite3WhereBegin(
omitTable = (pLevel->wsFlags & WHERE_IDX_ONLY)!=0; omitTable = (pLevel->wsFlags & WHERE_IDX_ONLY)!=0;
/* Create labels for the "break" and "continue" instructions /* Create labels for the "break" and "continue" instructions
** for the current loop. Jump to brk to break out of a loop. ** for the current loop. Jump to addrBrk to break out of a loop.
** Jump to cont to go immediately to the next iteration of the ** Jump to cont to go immediately to the next iteration of the
** loop. ** loop.
** **
** When there is an IN operator, we also have a "nxt" label that ** When there is an IN operator, we also have a "addrNxt" label that
** means to continue with the next IN value combination. When ** means to continue with the next IN value combination. When
** there are no IN operators in the constraints, the "nxt" label ** there are no IN operators in the constraints, the "addrNxt" label
** is the same as "brk". ** is the same as "addrBrk".
*/ */
brk = pLevel->brk = pLevel->nxt = sqlite3VdbeMakeLabel(v); addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
cont = pLevel->cont = sqlite3VdbeMakeLabel(v); addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);
/* If this is the right table of a LEFT OUTER JOIN, allocate and /* If this is the right table of a LEFT OUTER JOIN, allocate and
** initialize a memory cell that records if this table matches any ** initialize a memory cell that records if this table matches any
@@ -2438,7 +2438,7 @@ WhereInfo *sqlite3WhereBegin(
pParse->disableColCache--; pParse->disableColCache--;
sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, iReg); sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, iReg);
sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1); sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1);
sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, iReg, pBestIdx->idxStr, sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrBrk, iReg, pBestIdx->idxStr,
pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC); pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC);
sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
pBestIdx->needToFreeIdxStr = 0; pBestIdx->needToFreeIdxStr = 0;
@@ -2468,9 +2468,9 @@ WhereInfo *sqlite3WhereBegin(
assert( pTerm->leftCursor==iCur ); assert( pTerm->leftCursor==iCur );
assert( omitTable==0 ); assert( omitTable==0 );
r1 = codeEqualityTerm(pParse, pTerm, pLevel, rtmp); r1 = codeEqualityTerm(pParse, pTerm, pLevel, rtmp);
nxt = pLevel->nxt; addrNxt = pLevel->addrNxt;
sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, nxt); sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, addrNxt);
sqlite3VdbeAddOp3(v, OP_NotExists, iCur, nxt, r1); sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, r1);
sqlite3ReleaseTempReg(pParse, rtmp); sqlite3ReleaseTempReg(pParse, rtmp);
VdbeComment((v, "pk")); VdbeComment((v, "pk"));
pLevel->op = OP_Noop; pLevel->op = OP_Noop;
@@ -2506,14 +2506,14 @@ WhereInfo *sqlite3WhereBegin(
r1 = sqlite3GetTempReg(pParse); r1 = sqlite3GetTempReg(pParse);
sqlite3ExprCode(pParse, pX->pRight, r1); sqlite3ExprCode(pParse, pX->pRight, r1);
sqlite3VdbeAddOp3(v, OP_ForceInt, r1, brk, sqlite3VdbeAddOp3(v, OP_ForceInt, r1, addrBrk,
pX->op==TK_LE || pX->op==TK_GT); pX->op==TK_LE || pX->op==TK_GT);
sqlite3VdbeAddOp3(v, bRev ? OP_MoveLt : OP_MoveGe, iCur, brk, r1); sqlite3VdbeAddOp3(v, bRev ? OP_MoveLt : OP_MoveGe, iCur, addrBrk, r1);
VdbeComment((v, "pk")); VdbeComment((v, "pk"));
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
disableTerm(pLevel, pStart); disableTerm(pLevel, pStart);
}else{ }else{
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, brk); sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
} }
if( pEnd ){ if( pEnd ){
Expr *pX; Expr *pX;
@@ -2537,7 +2537,7 @@ WhereInfo *sqlite3WhereBegin(
int r1 = sqlite3GetTempReg(pParse); int r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1); sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1);
/* sqlite3VdbeAddOp2(v, OP_SCopy, pLevel->iMem, 0); */ /* sqlite3VdbeAddOp2(v, OP_SCopy, pLevel->iMem, 0); */
sqlite3VdbeAddOp3(v, testOp, pLevel->iMem, brk, r1); sqlite3VdbeAddOp3(v, testOp, pLevel->iMem, addrBrk, r1);
sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL); sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);
sqlite3ReleaseTempReg(pParse, r1); sqlite3ReleaseTempReg(pParse, r1);
} }
@@ -2606,7 +2606,7 @@ WhereInfo *sqlite3WhereBegin(
** starting at regBase. ** starting at regBase.
*/ */
regBase = codeAllEqualityTerms(pParse, pLevel, &wc, notReady, 2); regBase = codeAllEqualityTerms(pParse, pLevel, &wc, notReady, 2);
nxt = pLevel->nxt; addrNxt = pLevel->addrNxt;
/* If this loop satisfies a sort order (pOrderBy) request that /* If this loop satisfies a sort order (pOrderBy) request that
** was passed to this function to implement a "SELECT min(x) ..." ** was passed to this function to implement a "SELECT min(x) ..."
@@ -2660,7 +2660,7 @@ WhereInfo *sqlite3WhereBegin(
} }
sqlite3ExprCode(pParse, pRangeStart->pExpr->pRight, regBase+nEq); sqlite3ExprCode(pParse, pRangeStart->pExpr->pRight, regBase+nEq);
pParse->disableColCache = dcc; pParse->disableColCache = dcc;
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, nxt); sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
nConstraint++; nConstraint++;
}else if( isMinQuery ){ }else if( isMinQuery ){
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
@@ -2677,7 +2677,7 @@ WhereInfo *sqlite3WhereBegin(
testcase( op==OP_MoveGe ); testcase( op==OP_MoveGe );
testcase( op==OP_MoveLe ); testcase( op==OP_MoveLe );
testcase( op==OP_MoveLt ); testcase( op==OP_MoveLt );
sqlite3VdbeAddOp4(v, op, iIdxCur, nxt, regBase, sqlite3VdbeAddOp4(v, op, iIdxCur, addrNxt, regBase,
SQLITE_INT_TO_PTR(nConstraint), P4_INT32); SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
/* Load the value for the inequality constraint at the end of the /* Load the value for the inequality constraint at the end of the
@@ -2686,7 +2686,7 @@ WhereInfo *sqlite3WhereBegin(
nConstraint = nEq; nConstraint = nEq;
if( pRangeEnd ){ if( pRangeEnd ){
sqlite3ExprCode(pParse, pRangeEnd->pExpr->pRight, regBase+nEq); sqlite3ExprCode(pParse, pRangeEnd->pExpr->pRight, regBase+nEq);
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, nxt); sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
codeApplyAffinity(pParse, regBase, nEq+1, pIdx); codeApplyAffinity(pParse, regBase, nEq+1, pIdx);
nConstraint++; nConstraint++;
} }
@@ -2699,7 +2699,7 @@ WhereInfo *sqlite3WhereBegin(
testcase( op==OP_Noop ); testcase( op==OP_Noop );
testcase( op==OP_IdxGE ); testcase( op==OP_IdxGE );
testcase( op==OP_IdxLT ); testcase( op==OP_IdxLT );
sqlite3VdbeAddOp4(v, op, iIdxCur, nxt, regBase, sqlite3VdbeAddOp4(v, op, iIdxCur, addrNxt, regBase,
SQLITE_INT_TO_PTR(nConstraint), P4_INT32); SQLITE_INT_TO_PTR(nConstraint), P4_INT32);
sqlite3VdbeChangeP5(v, endEq!=bRev); sqlite3VdbeChangeP5(v, endEq!=bRev);
@@ -2712,7 +2712,7 @@ WhereInfo *sqlite3WhereBegin(
testcase( pLevel->wsFlags & WHERE_TOP_LIMIT ); testcase( pLevel->wsFlags & WHERE_TOP_LIMIT );
if( pLevel->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT) ){ if( pLevel->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT) ){
sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1); sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);
sqlite3VdbeAddOp2(v, OP_IsNull, r1, cont); sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);
} }
/* Seek the table cursor, if required */ /* Seek the table cursor, if required */
@@ -2737,7 +2737,7 @@ WhereInfo *sqlite3WhereBegin(
assert( bRev==0 ); assert( bRev==0 );
pLevel->op = OP_Next; pLevel->op = OP_Next;
pLevel->p1 = iCur; pLevel->p1 = iCur;
pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, OP_Rewind, iCur, brk); pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, OP_Rewind, iCur, addrBrk);
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
} }
notReady &= ~getMask(&maskSet, iCur); notReady &= ~getMask(&maskSet, iCur);
@@ -2758,7 +2758,7 @@ WhereInfo *sqlite3WhereBegin(
continue; continue;
} }
pParse->disableColCache += k; pParse->disableColCache += k;
sqlite3ExprIfFalse(pParse, pE, cont, SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
pParse->disableColCache -= k; pParse->disableColCache -= k;
k = 1; k = 1;
pTerm->wtFlags |= TERM_CODED; pTerm->wtFlags |= TERM_CODED;
@@ -2768,7 +2768,7 @@ WhereInfo *sqlite3WhereBegin(
** at least one row of the right table has matched the left table. ** at least one row of the right table has matched the left table.
*/ */
if( pLevel->iLeftJoin ){ if( pLevel->iLeftJoin ){
pLevel->top = sqlite3VdbeCurrentAddr(v); pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin); sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit")); VdbeComment((v, "record LEFT JOIN hit"));
sqlite3ExprClearColumnCache(pParse, pLevel->iTabCur); sqlite3ExprClearColumnCache(pParse, pLevel->iTabCur);
@@ -2779,7 +2779,7 @@ WhereInfo *sqlite3WhereBegin(
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( (pTerm->prereqAll & notReady)!=0 ) continue; if( (pTerm->prereqAll & notReady)!=0 ) continue;
assert( pTerm->pExpr ); assert( pTerm->pExpr );
sqlite3ExprIfFalse(pParse, pTerm->pExpr, cont, SQLITE_JUMPIFNULL); sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
pTerm->wtFlags |= TERM_CODED; pTerm->wtFlags |= TERM_CODED;
} }
} }
@@ -2837,7 +2837,7 @@ WhereInfo *sqlite3WhereBegin(
/* Record the continuation address in the WhereInfo structure. Then /* Record the continuation address in the WhereInfo structure. Then
** clean up and return. ** clean up and return.
*/ */
pWInfo->iContinue = cont; pWInfo->iContinue = addrCont;
whereClauseClear(&wc); whereClauseClear(&wc);
return pWInfo; return pWInfo;
@@ -2865,7 +2865,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
sqlite3ExprClearColumnCache(pParse, -1); sqlite3ExprClearColumnCache(pParse, -1);
for(i=pTabList->nSrc-1; i>=0; i--){ for(i=pTabList->nSrc-1; i>=0; i--){
pLevel = &pWInfo->a[i]; pLevel = &pWInfo->a[i];
sqlite3VdbeResolveLabel(v, pLevel->cont); sqlite3VdbeResolveLabel(v, pLevel->addrCont);
if( pLevel->op!=OP_Noop ){ if( pLevel->op!=OP_Noop ){
sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2); sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
sqlite3VdbeChangeP5(v, pLevel->p5); sqlite3VdbeChangeP5(v, pLevel->p5);
@@ -2873,15 +2873,15 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
if( pLevel->nIn ){ if( pLevel->nIn ){
struct InLoop *pIn; struct InLoop *pIn;
int j; int j;
sqlite3VdbeResolveLabel(v, pLevel->nxt); sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
for(j=pLevel->nIn, pIn=&pLevel->aInLoop[j-1]; j>0; j--, pIn--){ for(j=pLevel->nIn, pIn=&pLevel->aInLoop[j-1]; j>0; j--, pIn--){
sqlite3VdbeJumpHere(v, pIn->topAddr+1); sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
sqlite3VdbeAddOp2(v, OP_Next, pIn->iCur, pIn->topAddr); sqlite3VdbeAddOp2(v, OP_Next, pIn->iCur, pIn->addrInTop);
sqlite3VdbeJumpHere(v, pIn->topAddr-1); sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
} }
sqlite3DbFree(db, pLevel->aInLoop); sqlite3DbFree(db, pLevel->aInLoop);
} }
sqlite3VdbeResolveLabel(v, pLevel->brk); sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
if( pLevel->iLeftJoin ){ if( pLevel->iLeftJoin ){
int addr; int addr;
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);
@@ -2889,7 +2889,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
if( pLevel->iIdxCur>=0 ){ if( pLevel->iIdxCur>=0 ){
sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
} }
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->top); sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst);
sqlite3VdbeJumpHere(v, addr); sqlite3VdbeJumpHere(v, addr);
} }
} }

View File

@@ -180,6 +180,9 @@ proc copy_file {filename} {
regsub {^extern } $line {} line regsub {^extern } $line {} line
puts $out "SQLITE_PRIVATE $line" puts $out "SQLITE_PRIVATE $line"
} else { } else {
if {[regexp {const char sqlite3_version\[\];} $line]} {
set line {const char sqlite3_version[] = SQLITE_VERSION;}
}
regsub {^SQLITE_EXTERN } $line {} line regsub {^SQLITE_EXTERN } $line {} line
puts $out "SQLITE_API $line" puts $out "SQLITE_API $line"
} }