-C Fix\stest\sinstrumentation\sproblems\son\sshared_err.test.\s(CVS\s4728)
-D 2008-01-18T17:03:33
+C Cleanup\sand\ssimplification\sof\sconstraint\sprocessing.\s\sSimplifications\nto\sthe\sVM\sfor\sbetter\stest\scoverage.\s(CVS\s4729)
+D 2008-01-19T03:35:59
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d
F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c
F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
-F src/insert.c ed16eaf9391929e29fdbfa589db09b7224b31905
+F src/insert.c 969b543eedaeb3ec4cd52cd6931db94da67388c3
F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
F src/prepare.c c31a879d6795f4765fd0b113675c6debbc96b7fd
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
-F src/select.c d9a394a2566849f9f7b03e2da3fd3ed4a91611eb
+F src/select.c 9fb094cc0c8acdcbf3581fdfc4490e997b5d1d1e
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 0691a3d52dc37cf6ac2f74838e5ff8ae1055ac9b
F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48
F src/trigger.c 9bd3b6fa0beff4a02d262c96466f752ec15a7fc3
-F src/update.c 2513c6120f9510ae782446a2b839931e994b75dd
+F src/update.c 31edd9c9764e80753930bd5f9b43e0edb404636f
F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
F src/util.c deda8c5a400530e1c27c03619cc4cd1a06fc5281
F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
-F src/vdbe.c 3734b4b4fc34e46be4542593f9907a8a4d31c3d4
+F src/vdbe.c 986d1b4034e271c67f8cab0e03a5e459cb288ad7
F src/vdbe.h 58a7d931ffb704e034b2a725981cfa5bd406fad9
F src/vdbeInt.h 835e6f0337ce89d705ef9a162338788808adc4b7
F src/vdbeapi.c cb8c427a3ab646490c83204a98e94eff03ee2e89
F src/vdbeaux.c 0d2a9730195d40f7d1156731bc69f240927255c5
F src/vdbeblob.c e386d49d8354aa5a58f0a7f2794303442c149120
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
-F src/vdbemem.c 666a1d7b9d48ce6b1f6eb5e454693e0da08f6187
+F src/vdbemem.c e15122efe8868e400c2aba8ea101588944e83317
F src/vtab.c 9924e37cf7f5c527aeabb5da025874af505fb91d
F src/where.c 0cc6052f73aef0d2ce59505d7ae06d6fbf696025
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 42d8a377551baef01fb4e80f35fc12f9454a3cd4
-R 53a68cbdb5a0c09e7f3102caf81464df
+P 5aef5b0dd8e44a56f84fbc6f843016bca5101987
+R 07faac02e9ea2890001493a3c96130c4
U drh
-Z f8720638d058f6048f391f0665e9a25c
+Z 11b35796b0f55998b3b3bad35c703ebb
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.225 2008/01/17 16:22:15 drh Exp $
+** $Id: insert.c,v 1.226 2008/01/19 03:35:59 drh Exp $
*/
#include "sqliteInt.h"
**
** 1. The rowid of the row to be updated before the update. This
** value is omitted unless we are doing an UPDATE that involves a
-** change to the record number. (Or writing to a virtual table.)
+** change to the record number or writing to a virtual table.
**
** 2. The rowid of the row after the update.
**
**
** The old rowid shown as entry (1) above is omitted unless both isUpdate
** and rowidChng are 1. isUpdate is true for UPDATEs and false for
-** INSERTs and rowidChng is true if the record number is being changed.
+** INSERTs. RowidChng means that the new rowid is explicitly specified by
+** the update or insert statement. If rowidChng is false, it means that
+** the rowid is computed automatically in an insert or that the rowid value
+** is not modified by the update.
**
** The code generated by this routine store new index entries into
** registers identified by aRegIdx[]. No index entry is created for
** read/write cursors with cursor number baseCur+i for the i-th cursor.
** Except, if there is no possibility of a REPLACE action then
** cursors do not need to be open for indices where aRegIdx[i]==0.
-**
-** If the isUpdate flag is true, it means that the "baseCur" cursor is
-** initially pointing to an entry that is being updated. The isUpdate
-** flag causes extra code to be generated so that the "baseCur" cursor
-** is still pointing at the same entry after the routine returns.
-** Without the isUpdate flag, the "baseCur" cursor might be moved.
*/
void sqlite3GenerateConstraintChecks(
Parse *pParse, /* The parser context */
int baseCur, /* Index of a read/write cursor pointing at pTab */
int regRowid, /* Index of the range of input registers */
int *aRegIdx, /* Register used by each index. 0 for unused indices */
- int rowidChng, /* True if the rowid will change */
+ int rowidChng, /* True if the rowid might collide with existing entry */
int isUpdate, /* True for UPDATE, False for INSERT */
int overrideError, /* Override onError to this if not OE_Default */
int ignoreDest /* Jump to this label on an OE_Ignore resolution */
Vdbe *v;
int nCol;
int onError;
- int j1, j2, j3; /* Address of jump instructions */
+ int j1, j2, j3; /* Addresses of jump instructions */
int regData; /* Register containing first data column */
int iCur;
Index *pIdx;
onError = OE_Abort;
}
- if( isUpdate ){
- j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, regRowid-1);
- }
- j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
- switch( onError ){
- default: {
- onError = OE_Abort;
- /* Fall thru into the next case */
- }
- case OE_Rollback:
- case OE_Abort:
- case OE_Fail: {
- sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0,
- "PRIMARY KEY must be unique", P4_STATIC);
- break;
+ if( onError==OE_Replace && pTab->pIndex==0 ){
+ seenReplace = 1;
+ }else{
+ if( isUpdate ){
+ j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, regRowid-1);
}
- case OE_Replace: {
- sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
- if( isUpdate ){
- sqlite3VdbeAddOp3(v, OP_MoveGe, baseCur, 0, regRowid-hasTwoRowids);
+ j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
+ switch( onError ){
+ default: {
+ onError = OE_Abort;
+ /* Fall thru into the next case */
+ }
+ case OE_Rollback:
+ case OE_Abort:
+ case OE_Fail: {
+ sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, onError, 0,
+ "PRIMARY KEY must be unique", P4_STATIC);
+ break;
+ }
+ case OE_Replace: {
+ sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);
+ seenReplace = 1;
+ break;
+ }
+ case OE_Ignore: {
+ assert( seenReplace==0 );
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
+ break;
}
- seenReplace = 1;
- break;
}
- case OE_Ignore: {
- assert( seenReplace==0 );
- sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
- break;
+ sqlite3VdbeJumpHere(v, j3);
+ if( isUpdate ){
+ sqlite3VdbeJumpHere(v, j2);
}
}
- sqlite3VdbeJumpHere(v, j3);
- if( isUpdate ){
- sqlite3VdbeJumpHere(v, j2);
- sqlite3VdbeAddOp3(v, OP_MoveGe, baseCur, 0, regRowid-1);
- }
}
/* Test all UNIQUE constraints by creating entries for each UNIQUE
}
case OE_Replace: {
sqlite3GenerateRowDelete(pParse, pTab, baseCur, regR, 0);
- if( isUpdate ){
- sqlite3VdbeAddOp3(v, OP_MoveGe, baseCur, 0, regRowid-hasTwoRowids);
- }
seenReplace = 1;
break;
}
** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code.
**
-** $Id: vdbe.c,v 1.699 2008/01/18 14:08:25 drh Exp $
+** $Id: vdbe.c,v 1.700 2008/01/19 03:35:59 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
if( prc!=0 ){
rc = SQLITE_INTERRUPT;
- goto vdbe_halt;
+ goto vdbe_error_halt;
}
nProgressOps = 0;
}
if( pOp->opcode==OP_Move ){
rc = sqlite3VdbeMemMove(pOut, pIn1);
}else{
- Release(pOut);
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
if( pOp->opcode==OP_Copy ){
Deephemeralize(pOut);
case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */
int flags;
flags = pIn1->flags | pIn2->flags;
- if( (flags & MEM_Null)!=0 ){
- Release(pOut);
- pOut->flags = MEM_Null;
- }else if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){
+ if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;
+ if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){
i64 a, b;
a = pIn1->u.i;
b = pIn2->u.i;
case OP_Subtract: b -= a; break;
case OP_Multiply: b *= a; break;
case OP_Divide: {
- if( a==0 ) goto divide_by_zero;
+ if( a==0 ) goto arithmetic_result_is_null;
/* Dividing the largest possible negative 64-bit integer (1<<63) by
** -1 returns an integer to large to store in a 64-bit data-type. On
** some architectures, the value overflows to (1<<63). On others,
break;
}
default: {
- if( a==0 ) goto divide_by_zero;
+ if( a==0 ) goto arithmetic_result_is_null;
if( a==-1 ) a = 1;
b %= a;
break;
case OP_Subtract: b -= a; break;
case OP_Multiply: b *= a; break;
case OP_Divide: {
- if( a==0.0 ) goto divide_by_zero;
+ if( a==0.0 ) goto arithmetic_result_is_null;
b /= a;
break;
}
default: {
i64 ia = (i64)a;
i64 ib = (i64)b;
- if( ia==0 ) goto divide_by_zero;
+ if( ia==0 ) goto arithmetic_result_is_null;
if( ia==-1 ) ia = 1;
b = ib % ia;
break;
}
}
if( sqlite3_isnan(b) ){
- goto divide_by_zero;
+ goto arithmetic_result_is_null;
}
Release(pOut);
pOut->r = b;
}
break;
-divide_by_zero:
- Release(pOut);
- pOut->flags = MEM_Null;
+arithmetic_result_is_null:
+ sqlite3VdbeMemSetNull(pOut);
break;
}
i64 a, b;
if( (pIn1->flags | pIn2->flags) & MEM_Null ){
- Release(pOut);
- pOut->flags = MEM_Null;
+ sqlite3VdbeMemSetNull(pOut);
break;
}
a = sqlite3VdbeIntValue(pIn2);
case OP_BitAnd: a &= b; break;
case OP_BitOr: a |= b; break;
case OP_ShiftLeft: a <<= b; break;
- case OP_ShiftRight: a >>= b; break;
- default: /* CANT HAPPEN */ break;
+ default: assert( pOp->opcode==OP_ShiftRight );
+ a >>= b; break;
}
Release(pOut);
pOut->u.i = a;
sqlite3BtreeDataSize(pCrsr, &payloadSize);
}
nField = pC->nField;
- }else if( pC->pseudoTable ){
+ }else{
+ assert( pC->pseudoTable );
/* The record is the sole entry of a pseudo-table */
payloadSize = pC->nData;
zRec = pC->pData;
assert( payloadSize==0 || zRec!=0 );
nField = pC->nField;
pCrsr = 0;
- }else{
- zRec = 0;
- payloadSize = 0;
- pCrsr = 0;
- nField = 0;
}
/* If payloadSize is 0, then just store a NULL */
/* Read and parse the table header. Store the results of the parse
** into the record header cache fields of the cursor.
*/
- if( pC && pC->cacheStatus==p->cacheCtr ){
+ if( pC->cacheStatus==p->cacheCtr ){
aType = pC->aType;
aOffset = pC->aOffset;
}else{
applyAffinity(pRec, zAffinity[pRec-pData0], encoding);
}
if( pRec->flags&MEM_Zero && pRec->n>0 ){
- ExpandBlob(pRec);
+ sqlite3VdbeMemExpandBlob(pRec);
}
serial_type = sqlite3VdbeSerialType(pRec, file_format);
len = sqlite3VdbeSerialTypeLen(serial_type);
** has an index of 1.
*/
case OP_Statement: {
- int i = pOp->p1;
- Btree *pBt;
- if( i>=0 && i<db->nDb && (pBt = db->aDb[i].pBt)!=0
- && (db->autoCommit==0 || db->activeVdbeCnt>1) ){
+ if( db->autoCommit==0 || db->activeVdbeCnt>1 ){
+ int i = pOp->p1;
+ Btree *pBt;
+ assert( i>=0 && i<db->nDb );
+ assert( db->aDb[i].pBt!=0 );
+ pBt = db->aDb[i].pBt;
assert( sqlite3BtreeIsInTrans(pBt) );
assert( (p->btreeMask & (1<<i))!=0 );
if( !sqlite3BtreeIsInStmt(pBt) ){
pCur = allocateCursor(p, i, iDb);
if( pCur==0 ) goto no_mem;
pCur->nullRow = 1;
- if( pX==0 ) break;
/* We always provide a key comparison function. If the table being
** opened is of type INTKEY, the comparision function will be ignored. */
rc = sqlite3BtreeCursor(pX, p2, wrFlag,
*/
case OP_Close: {
int i = pOp->p1;
- if( i>=0 && i<p->nCursor ){
- sqlite3VdbeFreeCursor(p, p->apCsr[i]);
- p->apCsr[i] = 0;
- }
+ assert( i>=0 && i<p->nCursor );
+ sqlite3VdbeFreeCursor(p, p->apCsr[i]);
+ p->apCsr[i] = 0;
break;
}
Mem *pData = &p->aMem[pOp->p2];
Mem *pKey = &p->aMem[pOp->p3];
+ i64 iKey; /* The integer ROWID or key for the record to be inserted */
int i = pOp->p1;
Cursor *pC;
assert( i>=0 && i<p->nCursor );
- assert( p->apCsr[i]!=0 );
+ pC = p->apCsr[i];
+ assert( pC!=0 );
+ assert( pC->pCursor!=0 || pC->pseudoTable );
+ assert( pKey->flags & MEM_Int );
+ assert( pC->isTable );
REGISTER_TRACE(pOp->p2, pData);
REGISTER_TRACE(pOp->p3, pKey);
- if( ((pC = p->apCsr[i])->pCursor!=0 || pC->pseudoTable) ){
- i64 iKey; /* The integer ROWID or key for the record to be inserted */
- assert( pKey->flags & MEM_Int );
- assert( pC->isTable );
- iKey = intToKey(pKey->u.i);
-
- if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
- if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = pKey->u.i;
- if( pC->nextRowidValid && pKey->u.i>=pC->nextRowid ){
- pC->nextRowidValid = 0;
- }
- if( pData->flags & MEM_Null ){
- pData->z = 0;
- pData->n = 0;
+ iKey = intToKey(pKey->u.i);
+ if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
+ if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = pKey->u.i;
+ if( pC->nextRowidValid && pKey->u.i>=pC->nextRowid ){
+ pC->nextRowidValid = 0;
+ }
+ if( pData->flags & MEM_Null ){
+ pData->z = 0;
+ pData->n = 0;
+ }else{
+ assert( pData->flags & (MEM_Blob|MEM_Str) );
+ }
+ if( pC->pseudoTable ){
+ sqlite3_free(pC->pData);
+ pC->iKey = iKey;
+ pC->nData = pData->n;
+ if( pData->flags & MEM_Dyn ){
+ pC->pData = pData->z;
+ pData->flags &= ~MEM_Dyn;
+ pData->flags |= MEM_Ephem;
}else{
- assert( pData->flags & (MEM_Blob|MEM_Str) );
+ pC->pData = sqlite3_malloc( pC->nData+2 );
+ if( !pC->pData ) goto no_mem;
+ memcpy(pC->pData, pData->z, pC->nData);
+ pC->pData[pC->nData] = 0;
+ pC->pData[pC->nData+1] = 0;
}
- if( pC->pseudoTable ){
- sqlite3_free(pC->pData);
- pC->iKey = iKey;
- pC->nData = pData->n;
- if( pData->flags & MEM_Dyn ){
- pC->pData = pData->z;
- pData->flags &= ~MEM_Dyn;
- pData->flags |= MEM_Ephem;
- }else{
- pC->pData = sqlite3_malloc( pC->nData+2 );
- if( !pC->pData ) goto no_mem;
- memcpy(pC->pData, pData->z, pC->nData);
- pC->pData[pC->nData] = 0;
- pC->pData[pC->nData+1] = 0;
- }
- pC->nullRow = 0;
+ pC->nullRow = 0;
+ }else{
+ int nZero;
+ if( pData->flags & MEM_Zero ){
+ nZero = pData->u.i;
}else{
- int nZero;
- if( pData->flags & MEM_Zero ){
- nZero = pData->u.i;
- }else{
- nZero = 0;
- }
- rc = sqlite3BtreeInsert(pC->pCursor, 0, iKey,
- pData->z, pData->n, nZero,
- pOp->p5 & OPFLAG_APPEND);
- }
-
- pC->rowidIsValid = 0;
- pC->deferredMoveto = 0;
- pC->cacheStatus = CACHE_STALE;
-
- /* Invoke the update-hook if required. */
- if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
- const char *zDb = db->aDb[pC->iDb].zName;
- const char *zTbl = pOp->p4.z;
- int op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
- assert( pC->isTable );
- db->xUpdateCallback(db->pUpdateArg, op, zDb, zTbl, iKey);
- assert( pC->iDb>=0 );
+ nZero = 0;
}
+ rc = sqlite3BtreeInsert(pC->pCursor, 0, iKey,
+ pData->z, pData->n, nZero,
+ pOp->p5 & OPFLAG_APPEND);
+ }
+
+ pC->rowidIsValid = 0;
+ pC->deferredMoveto = 0;
+ pC->cacheStatus = CACHE_STALE;
+
+ /* Invoke the update-hook if required. */
+ if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){
+ const char *zDb = db->aDb[pC->iDb].zName;
+ const char *zTbl = pOp->p4.z;
+ int op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);
+ assert( pC->isTable );
+ db->xUpdateCallback(db->pUpdateArg, op, zDb, zTbl, iKey);
+ assert( pC->iDb>=0 );
}
-
break;
}
BtCursor *pCrsr = pC->pCursor;
rc = sqlite3VdbeCursorMoveto(pC);
if( rc ) goto abort_due_to_error;
- if( pC->nullRow ){
- pOut->flags = MEM_Null;
- break;
- }else if( pC->isIndex ){
+ if( pC->isIndex ){
i64 n64;
assert( !pC->isTable );
sqlite3BtreeKeySize(pCrsr, &n64);
}else{
rc = sqlite3BtreeData(pCrsr, 0, n, pOut->z);
}
- }else if( pC->pseudoTable ){
+ }else{
+ assert( pC->pseudoTable );
pOut->n = pC->nData;
assert( pC->nData<=SQLITE_MAX_LENGTH );
pOut->z = pC->pData;
pOut->flags = MEM_Blob|MEM_Ephem;
- }else{
- pOut->flags = MEM_Null;
}
pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */
UPDATE_MAX_BLOBSIZE(pOut);
v = pC->lastRowid;
}else if( pC->pseudoTable ){
v = keyToInt(pC->iKey);
- }else if( pC->nullRow || pC->pCursor==0 ){
+ }else if( pC->nullRow ){
/* Leave the rowid set to a NULL */
break;
}else{
int i = pOp->p1;
Cursor *pC;
BtCursor *pCrsr;
+ int res;
assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i];
assert( pC!=0 );
- if( (pCrsr = pC->pCursor)!=0 ){
- int res;
- rc = sqlite3BtreeLast(pCrsr, &res);
- pC->nullRow = res;
- pC->deferredMoveto = 0;
- pC->cacheStatus = CACHE_STALE;
- if( res && pOp->p2>0 ){
- pc = pOp->p2 - 1;
- }
- }else{
- pC->nullRow = 0;
+ pCrsr = pC->pCursor;
+ assert( pCrsr!=0 );
+ rc = sqlite3BtreeLast(pCrsr, &res);
+ pC->nullRow = res;
+ pC->deferredMoveto = 0;
+ pC->cacheStatus = CACHE_STALE;
+ if( res && pOp->p2>0 ){
+ pc = pOp->p2 - 1;
}
break;
}
res = 1;
}
pC->nullRow = res;
- if( res && pOp->p2>0 ){
+ assert( pOp->p2>0 && pOp->p2<p->nOp );
+ if( res ){
pc = pOp->p2 - 1;
}
break;
break;
}
-/* Opcode: IdxGT P1 P2 P3 * *
-**
-** The value in register P3 is an index entry that omits the ROWID. Compare
-** the value in register P3 against the index that P1 is currently pointing to.
-** Ignore the ROWID on the P1 index.
-**
-** The P3 value might have fewer columns that P1 index.
-**
-** If the P1 index entry is greater than the value in register P3
-** then jump to P2. Otherwise fall through to the next instruction.
-*/
/* Opcode: IdxGE P1 P2 P3 * P5
**
** The value in register P3 is an index entry that omits the ROWID. Compare
** like IdxLE.
*/
case OP_IdxLT: /* jump, in3 */
-case OP_IdxGT: /* jump, in3 */
case OP_IdxGE: { /* jump, in3 */
int i= pOp->p1;
Cursor *pC;
assert( pIn3->flags & MEM_Blob ); /* Created using OP_MakeRecord */
assert( pC->deferredMoveto==0 );
ExpandBlob(pIn3);
- *pC->pIncrKey = pOp->p5!=0;
- assert( pOp->opcode!=OP_IdxGT || pOp->p5==0 );
+ assert( pOp->p5==0 || pOp->p5==1 );
+ *pC->pIncrKey = pOp->p5;
rc = sqlite3VdbeIdxKeyCompare(pC, pIn3->n, (u8*)pIn3->z, &res);
*pC->pIncrKey = 0;
if( rc!=SQLITE_OK ){
}
if( pOp->opcode==OP_IdxLT ){
res = -res;
- }else if( pOp->opcode==OP_IdxGE ){
+ }else{
+ assert( pOp->opcode==OP_IdxGE );
res++;
}
if( res>0 ){
z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
pnErr->u.i, &nErr);
pnErr->u.i -= nErr;
- Release(pIn1);
+ sqlite3VdbeMemSetNull(pIn1);
if( nErr==0 ){
assert( z==0 );
- pIn1->flags = MEM_Null;
}else{
pIn1->z = z;
pIn1->n = strlen(z);
#endif /* NDEBUG */
} /* The end of the for(;;) loop the loops through opcodes */
- /* If we reach this point, it means that execution is finished.
+ /* If we reach this point, it means that execution is finished with
+ ** an error of some kind.
*/
-vdbe_halt:
- if( rc ){
- p->rc = rc;
- rc = SQLITE_ERROR;
- }else{
- rc = SQLITE_DONE;
- }
+vdbe_error_halt:
+ assert( rc );
+ p->rc = rc;
+ rc = SQLITE_ERROR;
sqlite3VdbeHalt(p);
/* This is the only way out of this procedure. We have to
too_big:
sqlite3SetString(&p->zErrMsg, "string or blob too big", (char*)0);
rc = SQLITE_TOOBIG;
- goto vdbe_halt;
+ goto vdbe_error_halt;
/* Jump to here if a malloc() fails.
*/
db->mallocFailed = 1;
sqlite3SetString(&p->zErrMsg, "out of memory", (char*)0);
rc = SQLITE_NOMEM;
- goto vdbe_halt;
+ goto vdbe_error_halt;
/* Jump to here for an SQLITE_MISUSE error.
*/
** should hold the error number.
*/
abort_due_to_error:
- if( p->zErrMsg==0 ){
- if( db->mallocFailed ) rc = SQLITE_NOMEM;
- sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
- }
- goto vdbe_halt;
+ assert( p->zErrMsg==0 );
+ if( db->mallocFailed ) rc = SQLITE_NOMEM;
+ sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
+ goto vdbe_error_halt;
/* Jump to here if the sqlite3_interrupt() API sets the interrupt
** flag.
}
p->rc = rc;
sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(rc), (char*)0);
- goto vdbe_halt;
+ goto vdbe_error_halt;
}