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

remove unnecessary code when NDEBUG is defined (CVS 163)

FossilOrigin-Name: 738e3e49f6d45e4393e35f7f5f65a41d3c2080c9
This commit is contained in:
drh
2000-10-23 01:07:59 +00:00
parent ccb2a3daf6
commit 76634487b6
3 changed files with 127 additions and 105 deletions

View File

@@ -1,5 +1,5 @@
C fix\sa\sdebugging\sissue\s(CVS\s162) C remove\sunnecessary\scode\swhen\sNDEBUG\sis\sdefined\s(CVS\s163)
D 2000-10-22T20:39:59 D 2000-10-23T01:08:00
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 0b1fdafa55e1bf4d3a4f5213544130e66ef32052 F Makefile.in 0b1fdafa55e1bf4d3a4f5213544130e66ef32052
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -28,7 +28,7 @@ F src/tclsqlite.c 178adf318eab2ff480c288a87541d4ab1c37d985
F src/tokenize.c 95bf7baa7d829981bed81ca89080d99d2c09d463 F src/tokenize.c 95bf7baa7d829981bed81ca89080d99d2c09d463
F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc
F src/util.c 811e0ad47f842c16555aaf361b26dab7221c1a6c F src/util.c 811e0ad47f842c16555aaf361b26dab7221c1a6c
F src/vdbe.c 45d40d614a48208b560e6285197cece75dbd61a4 F src/vdbe.c d69f691d1a4adc21c47b349078b6002f5eb6ae2a
F src/vdbe.h 140cdec3c56f70483e169f8ae657bd90f9fd6e98 F src/vdbe.h 140cdec3c56f70483e169f8ae657bd90f9fd6e98
F src/where.c 3dfad2ffd0aa994d5eceac88852f7189c8d1d3c8 F src/where.c 3dfad2ffd0aa994d5eceac88852f7189c8d1d3c8
F test/all.test 71d439d4d8d5bb68ca73344ce6d2b1ebb35ab7dd F test/all.test 71d439d4d8d5bb68ca73344ce6d2b1ebb35ab7dd
@@ -76,7 +76,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
F www/tclsqlite.tcl ae101d5f7c07dcc59770e2a84aae09025fab2dad F www/tclsqlite.tcl ae101d5f7c07dcc59770e2a84aae09025fab2dad
F www/vdbe.tcl bcbfc33bcdd0ebad95eab31286adb9e1bc289520 F www/vdbe.tcl bcbfc33bcdd0ebad95eab31286adb9e1bc289520
P 9e91b729f0a708b08060979a4998be890b6d268d P f0a5255d2657ddcba24353d6d94b0d9c579d8dec
R 31bc5188fe93f51dd094373014866609 R db2de82bead6490471b7e949022ed705
U drh U drh
Z 76e7eb6325e4b7bcee9d8c7288823b0d Z 6ca067409ed7e73ca537183814c3e736

View File

@@ -1 +1 @@
f0a5255d2657ddcba24353d6d94b0d9c579d8dec 738e3e49f6d45e4393e35f7f5f65a41d3c2080c9

View File

@@ -41,7 +41,7 @@
** But other routines are also provided to help in building up ** But other routines are also provided to help in building up
** a program instruction by instruction. ** a program instruction by instruction.
** **
** $Id: vdbe.c,v 1.45 2000/10/19 14:42:05 drh Exp $ ** $Id: vdbe.c,v 1.46 2000/10/23 01:08:00 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <unistd.h> #include <unistd.h>
@@ -906,6 +906,17 @@ static Sorter *Merge(Sorter *pLeft, Sorter *pRight){
return sHead.pNext; return sHead.pNext;
} }
/*
** Code contained within the VERIFY() macro is not needed for correct
** execution. It is there only to catch errors. So when we compile
** with NDEBUG=1, the VERIFY() code is omitted.
*/
#ifdef NDEBUG
# define VERIFY(X)
#else
# define VERIFY(X) X
#endif
/* /*
** Execute the program in the VDBE. ** Execute the program in the VDBE.
** **
@@ -943,9 +954,20 @@ int sqliteVdbeExec(
Op *pOp; /* Current operation */ Op *pOp; /* Current operation */
int rc; /* Value to return */ int rc; /* Value to return */
Dbbe *pBe = p->pBe; /* The backend driver */ Dbbe *pBe = p->pBe; /* The backend driver */
sqlite *db = p->db; /* The database */
char zBuf[100]; /* Space to sprintf() and integer */ char zBuf[100]; /* Space to sprintf() and integer */
/* No instruction ever pushes more than a single element onto the
** stack. And the stack never grows on successive executions of the
** same loop. So the total number of instructions is an upper bound
** on the maximum stack depth required.
**
** Allocation all the stack space we will ever need.
*/
NeedStack(p, p->nOp);
p->tos = -1; p->tos = -1;
rc = SQLITE_OK; rc = SQLITE_OK;
#ifdef MEMORY_DEBUG #ifdef MEMORY_DEBUG
if( access("vdbe_trace",0)==0 ){ if( access("vdbe_trace",0)==0 ){
@@ -953,13 +975,13 @@ int sqliteVdbeExec(
} }
#endif #endif
/* if( pzErrMsg ){ *pzErrMsg = 0; } */ /* if( pzErrMsg ){ *pzErrMsg = 0; } */
for(pc=0; rc==SQLITE_OK && pc<p->nOp && pc>=0; pc++){ for(pc=0; rc==SQLITE_OK && pc<p->nOp VERIFY(&& pc>=0); pc++){
pOp = &p->aOp[pc]; pOp = &p->aOp[pc];
/* Interrupt processing if requested. /* Interrupt processing if requested.
*/ */
if( p->db->flags & SQLITE_Interrupt ){ if( db->flags & SQLITE_Interrupt ){
p->db->flags &= ~SQLITE_Interrupt; db->flags &= ~SQLITE_Interrupt;
rc = SQLITE_INTERRUPT; rc = SQLITE_INTERRUPT;
sqliteSetString(pzErrMsg, "interrupted", 0); sqliteSetString(pzErrMsg, "interrupted", 0);
break; break;
@@ -1004,7 +1026,7 @@ int sqliteVdbeExec(
*/ */
case OP_Integer: { case OP_Integer: {
int i = ++p->tos; int i = ++p->tos;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
p->aStack[i].i = pOp->p1; p->aStack[i].i = pOp->p1;
p->aStack[i].flags = STK_Int; p->aStack[i].flags = STK_Int;
break; break;
@@ -1017,7 +1039,7 @@ int sqliteVdbeExec(
case OP_String: { case OP_String: {
int i = ++p->tos; int i = ++p->tos;
char *z; char *z;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
z = pOp->p3; z = pOp->p3;
if( z==0 ) z = ""; if( z==0 ) z = "";
p->zStack[i] = z; p->zStack[i] = z;
@@ -1032,7 +1054,7 @@ int sqliteVdbeExec(
*/ */
case OP_Null: { case OP_Null: {
int i = ++p->tos; int i = ++p->tos;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
p->zStack[i] = 0; p->zStack[i] = 0;
p->aStack[i].flags = STK_Null; p->aStack[i].flags = STK_Null;
break; break;
@@ -1058,8 +1080,8 @@ int sqliteVdbeExec(
case OP_Dup: { case OP_Dup: {
int i = p->tos - pOp->p1; int i = p->tos - pOp->p1;
int j = ++p->tos; int j = ++p->tos;
if( i<0 ) goto not_enough_stack; VERIFY( if( i<0 ) goto not_enough_stack; )
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
p->aStack[j] = p->aStack[i]; p->aStack[j] = p->aStack[i];
if( p->aStack[i].flags & STK_Dyn ){ if( p->aStack[i].flags & STK_Dyn ){
p->zStack[j] = sqliteMalloc( p->aStack[j].n ); p->zStack[j] = sqliteMalloc( p->aStack[j].n );
@@ -1084,7 +1106,7 @@ int sqliteVdbeExec(
int i; int i;
Stack ts; Stack ts;
char *tz; char *tz;
if( from<0 ) goto not_enough_stack; VERIFY( if( from<0 ) goto not_enough_stack; )
ts = p->aStack[from]; ts = p->aStack[from];
tz = p->zStack[from]; tz = p->zStack[from];
for(i=from; i<to; i++){ for(i=from; i<to; i++){
@@ -1131,8 +1153,8 @@ int sqliteVdbeExec(
case OP_Callback: { case OP_Callback: {
int i = p->tos - pOp->p1 + 1; int i = p->tos - pOp->p1 + 1;
int j; int j;
if( i<0 ) goto not_enough_stack; VERIFY( if( i<0 ) goto not_enough_stack; )
if( NeedStack(p, p->tos+2) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos+2) ) goto no_mem; )
for(j=i; j<=p->tos; j++){ for(j=i; j<=p->tos; j++){
if( (p->aStack[j].flags & STK_Null)==0 ){ if( (p->aStack[j].flags & STK_Null)==0 ){
if( Stringify(p, j) ) goto no_mem; if( Stringify(p, j) ) goto no_mem;
@@ -1171,7 +1193,7 @@ int sqliteVdbeExec(
zSep = pOp->p3; zSep = pOp->p3;
if( zSep==0 ) zSep = ""; if( zSep==0 ) zSep = "";
nSep = strlen(zSep); nSep = strlen(zSep);
if( p->tos+1<nField ) goto not_enough_stack; VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte = 1 - nSep; nByte = 1 - nSep;
for(i=p->tos-nField+1; i<=p->tos; i++){ for(i=p->tos-nField+1; i<=p->tos; i++){
if( p->aStack[i].flags & STK_Null ){ if( p->aStack[i].flags & STK_Null ){
@@ -1196,7 +1218,7 @@ int sqliteVdbeExec(
} }
zNew[j] = 0; zNew[j] = 0;
if( pOp->p2==0 ) PopStack(p, nField); if( pOp->p2==0 ) PopStack(p, nField);
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].n = nByte; p->aStack[p->tos].n = nByte;
p->aStack[p->tos].flags = STK_Str|STK_Dyn; p->aStack[p->tos].flags = STK_Str|STK_Dyn;
@@ -1242,7 +1264,7 @@ int sqliteVdbeExec(
case OP_Divide: { case OP_Divide: {
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
if( (p->aStack[tos].flags & p->aStack[nos].flags & STK_Int)==STK_Int ){ if( (p->aStack[tos].flags & p->aStack[nos].flags & STK_Int)==STK_Int ){
int a, b; int a, b;
a = p->aStack[tos].i; a = p->aStack[tos].i;
@@ -1301,7 +1323,7 @@ int sqliteVdbeExec(
int nos = tos - 1; int nos = tos - 1;
int ft, fn; int ft, fn;
int copy = 0; int copy = 0;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
ft = p->aStack[tos].flags; ft = p->aStack[tos].flags;
fn = p->aStack[nos].flags; fn = p->aStack[nos].flags;
if( fn & STK_Null ){ if( fn & STK_Null ){
@@ -1340,7 +1362,7 @@ int sqliteVdbeExec(
int nos = tos - 1; int nos = tos - 1;
int ft, fn; int ft, fn;
int copy = 0; int copy = 0;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
ft = p->aStack[tos].flags; ft = p->aStack[tos].flags;
fn = p->aStack[nos].flags; fn = p->aStack[nos].flags;
if( fn & STK_Null ){ if( fn & STK_Null ){
@@ -1377,7 +1399,7 @@ int sqliteVdbeExec(
*/ */
case OP_AddImm: { case OP_AddImm: {
int tos = p->tos; int tos = p->tos;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
Integerify(p, tos); Integerify(p, tos);
p->aStack[tos].i += pOp->p1; p->aStack[tos].i += pOp->p1;
break; break;
@@ -1428,7 +1450,7 @@ int sqliteVdbeExec(
int nos = tos - 1; int nos = tos - 1;
int c; int c;
int ft, fn; int ft, fn;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
ft = p->aStack[tos].flags; ft = p->aStack[tos].flags;
fn = p->aStack[nos].flags; fn = p->aStack[nos].flags;
if( (ft & fn)==STK_Int ){ if( (ft & fn)==STK_Int ){
@@ -1470,7 +1492,7 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
int c; int c;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
Stringify(p, nos); Stringify(p, nos);
c = sqliteLikeCompare(p->zStack[tos], p->zStack[nos]); c = sqliteLikeCompare(p->zStack[tos], p->zStack[nos]);
@@ -1502,7 +1524,7 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
int c; int c;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
Stringify(p, nos); Stringify(p, nos);
c = sqliteGlobCompare(p->zStack[tos], p->zStack[nos]); c = sqliteGlobCompare(p->zStack[tos], p->zStack[nos]);
@@ -1529,7 +1551,7 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
int c; int c;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
Integerify(p, tos); Integerify(p, tos);
Integerify(p, nos); Integerify(p, nos);
if( pOp->opcode==OP_And ){ if( pOp->opcode==OP_And ){
@@ -1550,8 +1572,8 @@ int sqliteVdbeExec(
** with its additive inverse. ** with its additive inverse.
*/ */
case OP_Negative: { case OP_Negative: {
int tos; int tos = p->tos;
if( (tos = p->tos)<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( p->aStack[tos].flags & STK_Real ){ if( p->aStack[tos].flags & STK_Real ){
Release(p, tos); Release(p, tos);
p->aStack[tos].r = -p->aStack[tos].r; p->aStack[tos].r = -p->aStack[tos].r;
@@ -1576,7 +1598,7 @@ int sqliteVdbeExec(
*/ */
case OP_Not: { case OP_Not: {
int tos = p->tos; int tos = p->tos;
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
Integerify(p, tos); Integerify(p, tos);
Release(p, tos); Release(p, tos);
p->aStack[tos].i = !p->aStack[tos].i; p->aStack[tos].i = !p->aStack[tos].i;
@@ -1602,7 +1624,7 @@ int sqliteVdbeExec(
*/ */
case OP_If: { case OP_If: {
int c; int c;
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
Integerify(p, p->tos); Integerify(p, p->tos);
c = p->aStack[p->tos].i; c = p->aStack[p->tos].i;
PopStack(p, 1); PopStack(p, 1);
@@ -1618,7 +1640,7 @@ int sqliteVdbeExec(
*/ */
case OP_IsNull: { case OP_IsNull: {
int c; int c;
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
c = (p->aStack[p->tos].flags & STK_Null)!=0; c = (p->aStack[p->tos].flags & STK_Null)!=0;
PopStack(p, 1); PopStack(p, 1);
if( c ) pc = pOp->p2-1; if( c ) pc = pOp->p2-1;
@@ -1633,7 +1655,7 @@ int sqliteVdbeExec(
*/ */
case OP_NotNull: { case OP_NotNull: {
int c; int c;
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
c = (p->aStack[p->tos].flags & STK_Null)==0; c = (p->aStack[p->tos].flags & STK_Null)==0;
PopStack(p, 1); PopStack(p, 1);
if( c ) pc = pOp->p2-1; if( c ) pc = pOp->p2-1;
@@ -1662,7 +1684,7 @@ int sqliteVdbeExec(
int addr; int addr;
nField = pOp->p1; nField = pOp->p1;
if( p->tos+1<nField ) goto not_enough_stack; VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte = 0; nByte = 0;
for(i=p->tos-nField+1; i<=p->tos; i++){ for(i=p->tos-nField+1; i<=p->tos; i++){
if( (p->aStack[i].flags & STK_Null)==0 ){ if( (p->aStack[i].flags & STK_Null)==0 ){
@@ -1692,7 +1714,7 @@ int sqliteVdbeExec(
} }
} }
PopStack(p, nField); PopStack(p, nField);
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].n = nByte; p->aStack[p->tos].n = nByte;
p->aStack[p->tos].flags = STK_Str | STK_Dyn; p->aStack[p->tos].flags = STK_Str | STK_Dyn;
@@ -1723,7 +1745,7 @@ int sqliteVdbeExec(
int i, j; int i, j;
nField = pOp->p1; nField = pOp->p1;
if( p->tos+1<nField ) goto not_enough_stack; VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte = 0; nByte = 0;
for(i=p->tos-nField+1; i<=p->tos; i++){ for(i=p->tos-nField+1; i<=p->tos; i++){
if( p->aStack[i].flags & STK_Null ){ if( p->aStack[i].flags & STK_Null ){
@@ -1745,7 +1767,7 @@ int sqliteVdbeExec(
} }
zNewKey[j] = 0; zNewKey[j] = 0;
if( pOp->p2==0 ) PopStack(p, nField); if( pOp->p2==0 ) PopStack(p, nField);
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].n = nByte; p->aStack[p->tos].n = nByte;
p->aStack[p->tos].flags = STK_Str|STK_Dyn; p->aStack[p->tos].flags = STK_Str|STK_Dyn;
@@ -1773,7 +1795,7 @@ int sqliteVdbeExec(
case OP_Open: { case OP_Open: {
int busy = 0; int busy = 0;
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i>=p->nCursor ){ if( i>=p->nCursor ){
int j; int j;
p->aCsr = sqliteRealloc( p->aCsr, (i+1)*sizeof(Cursor) ); p->aCsr = sqliteRealloc( p->aCsr, (i+1)*sizeof(Cursor) );
@@ -1840,7 +1862,7 @@ int sqliteVdbeExec(
case OP_Fetch: { case OP_Fetch: {
int i = pOp->p1; int i = pOp->p1;
int tos = p->tos; int tos = p->tos;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor ){ if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor ){
if( p->aStack[tos].flags & STK_Int ){ if( p->aStack[tos].flags & STK_Int ){
pBe->Fetch(p->aCsr[i].pCursor, sizeof(int), pBe->Fetch(p->aCsr[i].pCursor, sizeof(int),
@@ -1867,7 +1889,7 @@ int sqliteVdbeExec(
*/ */
case OP_Fcnt: { case OP_Fcnt: {
int i = ++p->tos; int i = ++p->tos;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
p->aStack[i].i = p->nFetch; p->aStack[i].i = p->nFetch;
p->aStack[i].flags = STK_Int; p->aStack[i].flags = STK_Int;
break; break;
@@ -1906,8 +1928,8 @@ int sqliteVdbeExec(
int i = pOp->p1; int i = pOp->p1;
int tos = p->tos; int tos = p->tos;
int alreadyExists = 0; int alreadyExists = 0;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor ){
if( p->aStack[tos].flags & STK_Int ){ if( p->aStack[tos].flags & STK_Int ){
alreadyExists = pBe->Test(p->aCsr[i].pCursor, sizeof(int), alreadyExists = pBe->Test(p->aCsr[i].pCursor, sizeof(int),
(char*)&p->aStack[tos].i); (char*)&p->aStack[tos].i);
@@ -1936,12 +1958,12 @@ int sqliteVdbeExec(
case OP_New: { case OP_New: {
int i = pOp->p1; int i = pOp->p1;
int v; int v;
if( i<0 || i>=p->nCursor || p->aCsr[i].pCursor==0 ){ if( VERIFY( i<0 || i>=p->nCursor || ) p->aCsr[i].pCursor==0 ){
v = 0; v = 0;
}else{ }else{
v = pBe->New(p->aCsr[i].pCursor); v = pBe->New(p->aCsr[i].pCursor);
} }
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].i = v; p->aStack[p->tos].i = v;
p->aStack[p->tos].flags = STK_Int; p->aStack[p->tos].flags = STK_Int;
@@ -1960,8 +1982,8 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = p->tos-1; int nos = p->tos-1;
int i = pOp->p1; int i = pOp->p1;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){
char *zKey; char *zKey;
int nKey; int nKey;
if( (p->aStack[nos].flags & STK_Int)==0 ){ if( (p->aStack[nos].flags & STK_Int)==0 ){
@@ -1987,8 +2009,8 @@ int sqliteVdbeExec(
case OP_Delete: { case OP_Delete: {
int tos = p->tos; int tos = p->tos;
int i = pOp->p1; int i = pOp->p1;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){
char *zKey; char *zKey;
int nKey; int nKey;
if( p->aStack[tos].flags & STK_Int ){ if( p->aStack[tos].flags & STK_Int ){
@@ -2014,7 +2036,7 @@ int sqliteVdbeExec(
*/ */
case OP_KeyAsData: { case OP_KeyAsData: {
int i = pOp->p1; int i = pOp->p1;
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){
p->aCsr[i].keyAsData = pOp->p2; p->aCsr[i].keyAsData = pOp->p2;
} }
break; break;
@@ -2050,8 +2072,8 @@ int sqliteVdbeExec(
DbbeCursor *pCrsr; DbbeCursor *pCrsr;
char *z; char *z;
if( NeedStack(p, tos) ) goto no_mem; VERIFY( if( NeedStack(p, tos) ) goto no_mem; )
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
if( p->aCsr[i].keyAsData ){ if( p->aCsr[i].keyAsData ){
amt = pBe->KeyLength(pCrsr); amt = pBe->KeyLength(pCrsr);
if( amt<=sizeof(int)*(p2+1) ){ if( amt<=sizeof(int)*(p2+1) ){
@@ -2096,8 +2118,8 @@ int sqliteVdbeExec(
int tos = ++p->tos; int tos = ++p->tos;
DbbeCursor *pCrsr; DbbeCursor *pCrsr;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
char *z = pBe->ReadKey(pCrsr, 0); char *z = pBe->ReadKey(pCrsr, 0);
if( p->aCsr[i].keyAsData ){ if( p->aCsr[i].keyAsData ){
p->zStack[tos] = z; p->zStack[tos] = z;
@@ -2118,7 +2140,7 @@ int sqliteVdbeExec(
*/ */
case OP_Rewind: { case OP_Rewind: {
int i = pOp->p1; int i = pOp->p1;
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){
pBe->Rewind(p->aCsr[i].pCursor); pBe->Rewind(p->aCsr[i].pCursor);
} }
break; break;
@@ -2131,7 +2153,7 @@ int sqliteVdbeExec(
*/ */
case OP_Next: { case OP_Next: {
int i = pOp->p1; int i = pOp->p1;
if( i>=0 && i<p->nCursor && p->aCsr[i].pCursor!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) p->aCsr[i].pCursor!=0 ){
if( pBe->NextKey(p->aCsr[i].pCursor)==0 ){ if( pBe->NextKey(p->aCsr[i].pCursor)==0 ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
}else{ }else{
@@ -2176,9 +2198,9 @@ int sqliteVdbeExec(
int tos = ++p->tos; int tos = ++p->tos;
DbbeCursor *pCrsr; DbbeCursor *pCrsr;
if( NeedStack(p, p->tos) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; )
p->zStack[tos] = 0; p->zStack[tos] = 0;
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
int *aIdx; int *aIdx;
int nIdx; int nIdx;
int j, k; int j, k;
@@ -2221,8 +2243,8 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
DbbeCursor *pCrsr; DbbeCursor *pCrsr;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
int r; int r;
int newVal; int newVal;
Integerify(p, nos); Integerify(p, nos);
@@ -2293,8 +2315,8 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
DbbeCursor *pCrsr; DbbeCursor *pCrsr;
if( nos<0 ) goto not_enough_stack; VERIFY( if( nos<0 ) goto not_enough_stack; )
if( i>=0 && i<p->nCursor && (pCrsr = p->aCsr[i].pCursor)!=0 ){ if( VERIFY( i>=0 && i<p->nCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){
int *aIdx; int *aIdx;
int nIdx; int nIdx;
int j, k; int j, k;
@@ -2357,7 +2379,7 @@ int sqliteVdbeExec(
*/ */
case OP_ListOpen: { case OP_ListOpen: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i>=p->nList ){ if( i>=p->nList ){
int j; int j;
p->apList = sqliteRealloc( p->apList, (i+1)*sizeof(FILE*) ); p->apList = sqliteRealloc( p->apList, (i+1)*sizeof(FILE*) );
@@ -2381,9 +2403,9 @@ int sqliteVdbeExec(
*/ */
case OP_ListWrite: { case OP_ListWrite: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
if( i<p->nList && p->apList[i]!=0 ){ if( VERIFY( i<p->nList && ) p->apList[i]!=0 ){
int val; int val;
Integerify(p, p->tos); Integerify(p, p->tos);
val = p->aStack[p->tos].i; val = p->aStack[p->tos].i;
@@ -2399,8 +2421,8 @@ int sqliteVdbeExec(
*/ */
case OP_ListRewind: { case OP_ListRewind: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i<p->nList && p->apList[i]!=0 ){ if( VERIFY( i<p->nList && ) p->apList[i]!=0 ){
rewind(p->apList[i]); rewind(p->apList[i]);
} }
break; break;
@@ -2415,7 +2437,7 @@ int sqliteVdbeExec(
case OP_ListRead: { case OP_ListRead: {
int i = pOp->p1; int i = pOp->p1;
int val, amt; int val, amt;
if( i<0 || i>=p->nList || p->apList[i]==0 ) goto bad_instruction; VERIFY(if( i<0 || i>=p->nList || p->apList[i]==0 )goto bad_instruction;)
amt = fread(&val, sizeof(int), 1, p->apList[i]); amt = fread(&val, sizeof(int), 1, p->apList[i]);
if( amt==1 ){ if( amt==1 ){
p->tos++; p->tos++;
@@ -2435,8 +2457,8 @@ int sqliteVdbeExec(
*/ */
case OP_ListClose: { case OP_ListClose: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i<p->nList && p->apList[i]!=0 ){ if( VERIFY( i<p->nList && ) p->apList[i]!=0 ){
pBe->CloseTempFile(pBe, p->apList[i]); pBe->CloseTempFile(pBe, p->apList[i]);
p->apList[i] = 0; p->apList[i] = 0;
} }
@@ -2449,7 +2471,7 @@ int sqliteVdbeExec(
*/ */
case OP_SortOpen: { case OP_SortOpen: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i>=p->nSort ){ if( i>=p->nSort ){
int j; int j;
p->apSort = sqliteRealloc( p->apSort, (i+1)*sizeof(Sorter*) ); p->apSort = sqliteRealloc( p->apSort, (i+1)*sizeof(Sorter*) );
@@ -2470,8 +2492,8 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
int nos = tos - 1; int nos = tos - 1;
Sorter *pSorter; Sorter *pSorter;
if( i<0 || i>=p->nSort ) goto bad_instruction; VERIFY( if( i<0 || i>=p->nSort ) goto bad_instruction; )
if( tos<1 ) goto not_enough_stack; VERIFY( if( tos<1 ) goto not_enough_stack; )
if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem; if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
pSorter = sqliteMalloc( sizeof(Sorter) ); pSorter = sqliteMalloc( sizeof(Sorter) );
if( pSorter==0 ) goto no_mem; if( pSorter==0 ) goto no_mem;
@@ -2503,7 +2525,7 @@ int sqliteVdbeExec(
int i, j; int i, j;
nField = pOp->p1; nField = pOp->p1;
if( p->tos+1<nField ) goto not_enough_stack; VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte = 0; nByte = 0;
for(i=p->tos-nField+1; i<=p->tos; i++){ for(i=p->tos-nField+1; i<=p->tos; i++){
if( (p->aStack[i].flags & STK_Null)==0 ){ if( (p->aStack[i].flags & STK_Null)==0 ){
@@ -2525,7 +2547,7 @@ int sqliteVdbeExec(
} }
} }
PopStack(p, nField); PopStack(p, nField);
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].n = nByte; p->aStack[p->tos].n = nByte;
p->zStack[p->tos] = (char*)azArg; p->zStack[p->tos] = (char*)azArg;
@@ -2553,7 +2575,7 @@ int sqliteVdbeExec(
int i, j, k; int i, j, k;
nField = strlen(pOp->p3); nField = strlen(pOp->p3);
if( p->tos+1<nField ) goto not_enough_stack; VERIFY( if( p->tos+1<nField ) goto not_enough_stack; )
nByte = 1; nByte = 1;
for(i=p->tos-nField+1; i<=p->tos; i++){ for(i=p->tos-nField+1; i<=p->tos; i++){
if( Stringify(p, i) ) goto no_mem; if( Stringify(p, i) ) goto no_mem;
@@ -2571,7 +2593,7 @@ int sqliteVdbeExec(
} }
zNewKey[j] = 0; zNewKey[j] = 0;
PopStack(p, nField); PopStack(p, nField);
NeedStack(p, p->tos+1); VERIFY( NeedStack(p, p->tos+1); )
p->tos++; p->tos++;
p->aStack[p->tos].n = nByte; p->aStack[p->tos].n = nByte;
p->aStack[p->tos].flags = STK_Str|STK_Dyn; p->aStack[p->tos].flags = STK_Str|STK_Dyn;
@@ -2587,7 +2609,7 @@ int sqliteVdbeExec(
case OP_Sort: { case OP_Sort: {
int j; int j;
j = pOp->p1; j = pOp->p1;
if( j<0 ) goto bad_instruction; VERIFY( if( j<0 ) goto bad_instruction; )
if( j<p->nSort ){ if( j<p->nSort ){
int i; int i;
Sorter *pElem; Sorter *pElem;
@@ -2628,12 +2650,12 @@ int sqliteVdbeExec(
*/ */
case OP_SortNext: { case OP_SortNext: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i<p->nSort && p->apSort[i]!=0 ){ if( VERIFY( i<p->nSort && ) p->apSort[i]!=0 ){
Sorter *pSorter = p->apSort[i]; Sorter *pSorter = p->apSort[i];
p->apSort[i] = pSorter->pNext; p->apSort[i] = pSorter->pNext;
p->tos++; p->tos++;
NeedStack(p, p->tos); VERIFY( NeedStack(p, p->tos); )
p->zStack[p->tos] = pSorter->pData; p->zStack[p->tos] = pSorter->pData;
p->aStack[p->tos].n = pSorter->nData; p->aStack[p->tos].n = pSorter->nData;
p->aStack[p->tos].flags = STK_Str|STK_Dyn; p->aStack[p->tos].flags = STK_Str|STK_Dyn;
@@ -2652,11 +2674,11 @@ int sqliteVdbeExec(
*/ */
case OP_SortKey: { case OP_SortKey: {
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i<p->nSort && p->apSort[i]!=0 ){ if( i<p->nSort && p->apSort[i]!=0 ){
Sorter *pSorter = p->apSort[i]; Sorter *pSorter = p->apSort[i];
p->tos++; p->tos++;
NeedStack(p, p->tos); VERIFY( NeedStack(p, p->tos); )
sqliteSetString(&p->zStack[p->tos], pSorter->zKey, 0); sqliteSetString(&p->zStack[p->tos], pSorter->zKey, 0);
p->aStack[p->tos].n = pSorter->nKey; p->aStack[p->tos].n = pSorter->nKey;
p->aStack[p->tos].flags = STK_Str|STK_Dyn; p->aStack[p->tos].flags = STK_Str|STK_Dyn;
@@ -2673,7 +2695,7 @@ int sqliteVdbeExec(
*/ */
case OP_SortCallback: { case OP_SortCallback: {
int i = p->tos; int i = p->tos;
if( i<0 ) goto not_enough_stack; VERIFY( if( i<0 ) goto not_enough_stack; )
if( xCallback!=0 ){ if( xCallback!=0 ){
if( xCallback(pArg, pOp->p1, (char**)p->zStack[i], p->azColName) ){ if( xCallback(pArg, pOp->p1, (char**)p->zStack[i], p->azColName) ){
rc = SQLITE_ABORT; rc = SQLITE_ABORT;
@@ -2690,7 +2712,7 @@ int sqliteVdbeExec(
case OP_SortClose: { case OP_SortClose: {
Sorter *pSorter; Sorter *pSorter;
int i = pOp->p1; int i = pOp->p1;
if( i<0 ) goto bad_instruction; VERIFY( if( i<0 ) goto bad_instruction; )
if( i<p->nSort ){ if( i<p->nSort ){
while( (pSorter = p->apSort[i])!=0 ){ while( (pSorter = p->apSort[i])!=0 ){
p->apSort[i] = pSorter->pNext; p->apSort[i] = pSorter->pNext;
@@ -2708,7 +2730,7 @@ int sqliteVdbeExec(
** If P3 is "stdin" then open standard input for reading. ** If P3 is "stdin" then open standard input for reading.
*/ */
case OP_FileOpen: { case OP_FileOpen: {
if( pOp->p3==0 ) goto bad_instruction; VERIFY( if( pOp->p3==0 ) goto bad_instruction; )
if( p->pFile ){ if( p->pFile ){
if( p->pFile!=stdin ) fclose(p->pFile); if( p->pFile!=stdin ) fclose(p->pFile);
p->pFile = 0; p->pFile = 0;
@@ -2847,8 +2869,8 @@ int sqliteVdbeExec(
case OP_FileField: { case OP_FileField: {
int i = pOp->p1; int i = pOp->p1;
char *z; char *z;
if( NeedStack(p, p->tos+1) ) goto no_mem; VERIFY( if( NeedStack(p, p->tos+1) ) goto no_mem; )
if( i>=0 && i<p->nField && p->azField ){ if( VERIFY( i>=0 && i<p->nField && ) p->azField ){
z = p->azField[i]; z = p->azField[i];
}else{ }else{
z = 0; z = 0;
@@ -2872,7 +2894,7 @@ int sqliteVdbeExec(
int tos = p->tos; int tos = p->tos;
Mem *pMem; Mem *pMem;
char *zOld; char *zOld;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( i>=p->nMem ){ if( i>=p->nMem ){
int nOld = p->nMem; int nOld = p->nMem;
p->nMem = i + 5; p->nMem = i + 5;
@@ -2905,7 +2927,7 @@ int sqliteVdbeExec(
case OP_MemLoad: { case OP_MemLoad: {
int tos = ++p->tos; int tos = ++p->tos;
int i = pOp->p1; int i = pOp->p1;
if( NeedStack(p, tos) ) goto no_mem; VERIFY( if( NeedStack(p, tos) ) goto no_mem; )
if( i<0 || i>=p->nMem ){ if( i<0 || i>=p->nMem ){
p->aStack[tos].flags = STK_Null; p->aStack[tos].flags = STK_Null;
p->zStack[tos] = 0; p->zStack[tos] = 0;
@@ -2953,7 +2975,7 @@ int sqliteVdbeExec(
char *zKey; char *zKey;
int nKey; int nKey;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
zKey = p->zStack[tos]; zKey = p->zStack[tos];
nKey = p->aStack[tos].n; nKey = p->aStack[tos].n;
@@ -3014,9 +3036,9 @@ int sqliteVdbeExec(
AggElem *pFocus = AggInFocus(p->agg); AggElem *pFocus = AggInFocus(p->agg);
int i = pOp->p2; int i = pOp->p2;
int tos = p->tos; int tos = p->tos;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
if( pFocus==0 ) goto no_mem; if( pFocus==0 ) goto no_mem;
if( i>=0 && i<p->agg.nMem ){ if( VERIFY( i>=0 && ) i<p->agg.nMem ){
Mem *pMem = &pFocus->aMem[i]; Mem *pMem = &pFocus->aMem[i];
char *zOld; char *zOld;
if( pMem->s.flags & STK_Dyn ){ if( pMem->s.flags & STK_Dyn ){
@@ -3047,9 +3069,9 @@ int sqliteVdbeExec(
AggElem *pFocus = AggInFocus(p->agg); AggElem *pFocus = AggInFocus(p->agg);
int i = pOp->p2; int i = pOp->p2;
int tos = ++p->tos; int tos = ++p->tos;
if( NeedStack(p, tos) ) goto no_mem; VERIFY( if( NeedStack(p, tos) ) goto no_mem; )
if( pFocus==0 ) goto no_mem; if( pFocus==0 ) goto no_mem;
if( i>=0 && i<p->agg.nMem ){ if( VERIFY( i>=0 && ) i<p->agg.nMem ){
Mem *pMem = &pFocus->aMem[i]; Mem *pMem = &pFocus->aMem[i];
p->aStack[tos] = pMem->s; p->aStack[tos] = pMem->s;
p->zStack[tos] = pMem->z; p->zStack[tos] = pMem->z;
@@ -3141,9 +3163,9 @@ int sqliteVdbeExec(
case OP_SetFound: { case OP_SetFound: {
int i = pOp->p1; int i = pOp->p1;
int tos = p->tos; int tos = p->tos;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
if( i>=0 && i<p->nSet && SetTest(&p->aSet[i], p->zStack[tos]) ){ if( VERIFY( i>=0 && i<p->nSet &&) SetTest(&p->aSet[i], p->zStack[tos])){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
PopStack(p, 1); PopStack(p, 1);
@@ -3159,9 +3181,9 @@ int sqliteVdbeExec(
case OP_SetNotFound: { case OP_SetNotFound: {
int i = pOp->p1; int i = pOp->p1;
int tos = p->tos; int tos = p->tos;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
if( i>=0 && i<p->nSet && !SetTest(&p->aSet[i], p->zStack[tos]) ){ if(VERIFY( i>=0 && i<p->nSet &&) !SetTest(&p->aSet[i], p->zStack[tos])){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
PopStack(p, 1); PopStack(p, 1);
@@ -3176,7 +3198,7 @@ int sqliteVdbeExec(
case OP_Strlen: { case OP_Strlen: {
int tos = p->tos; int tos = p->tos;
int len; int len;
if( tos<0 ) goto not_enough_stack; VERIFY( if( tos<0 ) goto not_enough_stack; )
Stringify(p, tos); Stringify(p, tos);
len = p->aStack[tos].n-1; len = p->aStack[tos].n-1;
PopStack(p, 1); PopStack(p, 1);
@@ -3212,7 +3234,7 @@ int sqliteVdbeExec(
char *z; char *z;
if( pOp->p2==0 ){ if( pOp->p2==0 ){
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
Integerify(p, p->tos); Integerify(p, p->tos);
cnt = p->aStack[p->tos].i; cnt = p->aStack[p->tos].i;
PopStack(p, 1); PopStack(p, 1);
@@ -3220,14 +3242,14 @@ int sqliteVdbeExec(
cnt = pOp->p2; cnt = pOp->p2;
} }
if( pOp->p1==0 ){ if( pOp->p1==0 ){
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
Integerify(p, p->tos); Integerify(p, p->tos);
start = p->aStack[p->tos].i - 1; start = p->aStack[p->tos].i - 1;
PopStack(p, 1); PopStack(p, 1);
}else{ }else{
start = pOp->p1 - 1; start = pOp->p1 - 1;
} }
if( p->tos<0 ) goto not_enough_stack; VERIFY( if( p->tos<0 ) goto not_enough_stack; )
Stringify(p, p->tos); Stringify(p, p->tos);
n = p->aStack[p->tos].n - 1; n = p->aStack[p->tos].n - 1;
if( start<0 ){ if( start<0 ){