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

Convert several ALWAYS() macros in vdbe.c into assert() statements.

FossilOrigin-Name: acc40ff6b47595432ebc1b3ec71ac50384bec323
This commit is contained in:
drh
2013-11-11 03:24:11 +00:00
parent 9939118083
commit 3da046d8ba
3 changed files with 243 additions and 271 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sseveral\sharmless\scompiler\swarnings. C Convert\sseveral\sALWAYS()\smacros\sin\svdbe.c\sinto\sassert()\sstatements.
D 2013-11-11T02:46:32.106 D 2013-11-11T03:24:11.697
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -279,7 +279,7 @@ F src/update.c 95a640c56d71ea9d58be66eab863d502701d092b
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c 2fa6c821d28bbdbeec1b2a7b091a281c9ef8f918 F src/util.c 2fa6c821d28bbdbeec1b2a7b091a281c9ef8f918
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
F src/vdbe.c cd3059de95a3a638eee919db8cfe4c318c160026 F src/vdbe.c aeef5c115ccb0433934f88b1a3016097eb6d8ab2
F src/vdbe.h 8d5a7351024d80374fc0acdbbe3cfe65c51ba8b6 F src/vdbe.h 8d5a7351024d80374fc0acdbbe3cfe65c51ba8b6
F src/vdbeInt.h f2fa3ceccceeb757773921fb08af7c6e9f3caa1c F src/vdbeInt.h f2fa3ceccceeb757773921fb08af7c6e9f3caa1c
F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed
@@ -1135,7 +1135,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P aaed7d1d3ba0aef9f99fb157d3704b9f279aef71 P e6ff492f0d475c395b82e2b3b294155674d4c6d1
R 662f5504d9799bf5dac3f43bcdc7df7a R 475d55de2c4ca401ff801162b73639ef
U mistachkin U drh
Z 791474e5a293869464d96bcb0c045d7f Z 5df113c36f23c015c44c7ae86b17359f

View File

@@ -1 +1 @@
e6ff492f0d475c395b82e2b3b294155674d4c6d1 acc40ff6b47595432ebc1b3ec71ac50384bec323

View File

@@ -2309,7 +2309,8 @@ case OP_Column: {
VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &payloadSize); VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &payloadSize);
assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ assert( rc==SQLITE_OK ); /* DataSize() cannot fail */
} }
}else if( ALWAYS(pC->pseudoTableReg>0) ){ }else{
assert( pC->pseudoTableReg>0 );
pReg = &aMem[pC->pseudoTableReg]; pReg = &aMem[pC->pseudoTableReg];
if( pC->multiPseudo ){ if( pC->multiPseudo ){
sqlite3VdbeMemShallowCopy(pDest, pReg+p2, MEM_Ephem); sqlite3VdbeMemShallowCopy(pDest, pReg+p2, MEM_Ephem);
@@ -2322,9 +2323,6 @@ case OP_Column: {
zRec = pReg->z; zRec = pReg->z;
pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr; pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;
assert( payloadSize==0 || zRec!=0 ); assert( payloadSize==0 || zRec!=0 );
}else{
/* Consider the row to be NULL */
payloadSize = 0;
} }
/* If payloadSize is 0, then just store a NULL. This can happen because of /* If payloadSize is 0, then just store a NULL. This can happen because of
@@ -2716,11 +2714,8 @@ case OP_Count: { /* out2-prerelease */
BtCursor *pCrsr; BtCursor *pCrsr;
pCrsr = p->apCsr[pOp->p1]->pCursor; pCrsr = p->apCsr[pOp->p1]->pCursor;
if( ALWAYS(pCrsr) ){ assert( pCrsr );
rc = sqlite3BtreeCount(pCrsr, &nEntry); rc = sqlite3BtreeCount(pCrsr, &nEntry);
}else{
nEntry = 0;
}
pOut->u.i = nEntry; pOut->u.i = nEntry;
break; break;
} }
@@ -3531,133 +3526,126 @@ case OP_SeekGt: { /* jump, in3 */
assert( OP_SeekGe == OP_SeekLt+2 ); assert( OP_SeekGe == OP_SeekLt+2 );
assert( OP_SeekGt == OP_SeekLt+3 ); assert( OP_SeekGt == OP_SeekLt+3 );
assert( pC->isOrdered ); assert( pC->isOrdered );
if( ALWAYS(pC->pCursor!=0) ){ assert( pC->pCursor!=0 );
oc = pOp->opcode; oc = pOp->opcode;
pC->nullRow = 0; pC->nullRow = 0;
if( pC->isTable ){ if( pC->isTable ){
/* The input value in P3 might be of any type: integer, real, string, /* The input value in P3 might be of any type: integer, real, string,
** blob, or NULL. But it needs to be an integer before we can do ** blob, or NULL. But it needs to be an integer before we can do
** the seek, so covert it. */ ** the seek, so covert it. */
pIn3 = &aMem[pOp->p3]; pIn3 = &aMem[pOp->p3];
applyNumericAffinity(pIn3); applyNumericAffinity(pIn3);
iKey = sqlite3VdbeIntValue(pIn3); iKey = sqlite3VdbeIntValue(pIn3);
pC->rowidIsValid = 0; pC->rowidIsValid = 0;
/* If the P3 value could not be converted into an integer without /* If the P3 value could not be converted into an integer without
** loss of information, then special processing is required... */ ** loss of information, then special processing is required... */
if( (pIn3->flags & MEM_Int)==0 ){ if( (pIn3->flags & MEM_Int)==0 ){
if( (pIn3->flags & MEM_Real)==0 ){ if( (pIn3->flags & MEM_Real)==0 ){
/* If the P3 value cannot be converted into any kind of a number, /* If the P3 value cannot be converted into any kind of a number,
** then the seek is not possible, so jump to P2 */ ** then the seek is not possible, so jump to P2 */
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
break; break;
} }
/* If we reach this point, then the P3 value must be a floating /* If we reach this point, then the P3 value must be a floating
** point number. */ ** point number. */
assert( (pIn3->flags & MEM_Real)!=0 ); assert( (pIn3->flags & MEM_Real)!=0 );
if( iKey==SMALLEST_INT64 && (pIn3->r<(double)iKey || pIn3->r>0) ){ if( iKey==SMALLEST_INT64 && (pIn3->r<(double)iKey || pIn3->r>0) ){
/* The P3 value is too large in magnitude to be expressed as an /* The P3 value is too large in magnitude to be expressed as an
** integer. */ ** integer. */
res = 1; res = 1;
if( pIn3->r<0 ){ if( pIn3->r<0 ){
if( oc>=OP_SeekGe ){ assert( oc==OP_SeekGe || oc==OP_SeekGt ); if( oc>=OP_SeekGe ){ assert( oc==OP_SeekGe || oc==OP_SeekGt );
rc = sqlite3BtreeFirst(pC->pCursor, &res); rc = sqlite3BtreeFirst(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error; if( rc!=SQLITE_OK ) goto abort_due_to_error;
}
}else{
if( oc<=OP_SeekLe ){ assert( oc==OP_SeekLt || oc==OP_SeekLe );
rc = sqlite3BtreeLast(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error;
}
} }
if( res ){
pc = pOp->p2 - 1;
}
break;
}else if( oc==OP_SeekLt || oc==OP_SeekGe ){
/* Use the ceiling() function to convert real->int */
if( pIn3->r > (double)iKey ) iKey++;
}else{ }else{
/* Use the floor() function to convert real->int */ if( oc<=OP_SeekLe ){ assert( oc==OP_SeekLt || oc==OP_SeekLe );
assert( oc==OP_SeekLe || oc==OP_SeekGt ); rc = sqlite3BtreeLast(pC->pCursor, &res);
if( pIn3->r < (double)iKey ) iKey--; if( rc!=SQLITE_OK ) goto abort_due_to_error;
}
} }
} if( res ){
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)iKey, 0, &res); pc = pOp->p2 - 1;
if( rc!=SQLITE_OK ){ }
goto abort_due_to_error; break;
} }else if( oc==OP_SeekLt || oc==OP_SeekGe ){
if( res==0 ){ /* Use the ceiling() function to convert real->int */
pC->rowidIsValid = 1; if( pIn3->r > (double)iKey ) iKey++;
pC->lastRowid = iKey;
}
}else{
nField = pOp->p4.i;
assert( pOp->p4type==P4_INT32 );
assert( nField>0 );
r.pKeyInfo = pC->pKeyInfo;
r.nField = (u16)nField;
/* The next line of code computes as follows, only faster:
** if( oc==OP_SeekGt || oc==OP_SeekLe ){
** r.flags = UNPACKED_INCRKEY;
** }else{
** r.flags = 0;
** }
*/
r.flags = (u8)(UNPACKED_INCRKEY * (1 & (oc - OP_SeekLt)));
assert( oc!=OP_SeekGt || r.flags==UNPACKED_INCRKEY );
assert( oc!=OP_SeekLe || r.flags==UNPACKED_INCRKEY );
assert( oc!=OP_SeekGe || r.flags==0 );
assert( oc!=OP_SeekLt || r.flags==0 );
r.aMem = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif
ExpandBlob(r.aMem);
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, &r, 0, 0, &res);
if( rc!=SQLITE_OK ){
goto abort_due_to_error;
}
pC->rowidIsValid = 0;
}
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
#ifdef SQLITE_TEST
sqlite3_search_count++;
#endif
if( oc>=OP_SeekGe ){ assert( oc==OP_SeekGe || oc==OP_SeekGt );
if( res<0 || (res==0 && oc==OP_SeekGt) ){
rc = sqlite3BtreeNext(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error;
pC->rowidIsValid = 0;
}else{ }else{
res = 0; /* Use the floor() function to convert real->int */
} assert( oc==OP_SeekLe || oc==OP_SeekGt );
}else{ if( pIn3->r < (double)iKey ) iKey--;
assert( oc==OP_SeekLt || oc==OP_SeekLe );
if( res>0 || (res==0 && oc==OP_SeekLt) ){
rc = sqlite3BtreePrevious(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error;
pC->rowidIsValid = 0;
}else{
/* res might be negative because the table is empty. Check to
** see if this is the case.
*/
res = sqlite3BtreeEof(pC->pCursor);
} }
} }
assert( pOp->p2>0 ); rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)iKey, 0, &res);
if( res ){ if( rc!=SQLITE_OK ){
pc = pOp->p2 - 1; goto abort_due_to_error;
}
if( res==0 ){
pC->rowidIsValid = 1;
pC->lastRowid = iKey;
} }
}else{ }else{
/* This happens when attempting to open the sqlite3_master table nField = pOp->p4.i;
** for read access returns SQLITE_EMPTY. In this case always assert( pOp->p4type==P4_INT32 );
** take the jump (since there are no records in the table). assert( nField>0 );
r.pKeyInfo = pC->pKeyInfo;
r.nField = (u16)nField;
/* The next line of code computes as follows, only faster:
** if( oc==OP_SeekGt || oc==OP_SeekLe ){
** r.flags = UNPACKED_INCRKEY;
** }else{
** r.flags = 0;
** }
*/ */
r.flags = (u8)(UNPACKED_INCRKEY * (1 & (oc - OP_SeekLt)));
assert( oc!=OP_SeekGt || r.flags==UNPACKED_INCRKEY );
assert( oc!=OP_SeekLe || r.flags==UNPACKED_INCRKEY );
assert( oc!=OP_SeekGe || r.flags==0 );
assert( oc!=OP_SeekLt || r.flags==0 );
r.aMem = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif
ExpandBlob(r.aMem);
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, &r, 0, 0, &res);
if( rc!=SQLITE_OK ){
goto abort_due_to_error;
}
pC->rowidIsValid = 0;
}
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
#ifdef SQLITE_TEST
sqlite3_search_count++;
#endif
if( oc>=OP_SeekGe ){ assert( oc==OP_SeekGe || oc==OP_SeekGt );
if( res<0 || (res==0 && oc==OP_SeekGt) ){
rc = sqlite3BtreeNext(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error;
pC->rowidIsValid = 0;
}else{
res = 0;
}
}else{
assert( oc==OP_SeekLt || oc==OP_SeekLe );
if( res>0 || (res==0 && oc==OP_SeekLt) ){
rc = sqlite3BtreePrevious(pC->pCursor, &res);
if( rc!=SQLITE_OK ) goto abort_due_to_error;
pC->rowidIsValid = 0;
}else{
/* res might be negative because the table is empty. Check to
** see if this is the case.
*/
res = sqlite3BtreeEof(pC->pCursor);
}
}
assert( pOp->p2>0 );
if( res ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
} }
break; break;
@@ -3679,14 +3667,13 @@ case OP_Seek: { /* in2 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor ); assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
assert( pC!=0 ); assert( pC!=0 );
if( ALWAYS(pC->pCursor!=0) ){ assert( pC->pCursor!=0 );
assert( pC->isTable ); assert( pC->isTable );
pC->nullRow = 0; pC->nullRow = 0;
pIn2 = &aMem[pOp->p2]; pIn2 = &aMem[pOp->p2];
pC->movetoTarget = sqlite3VdbeIntValue(pIn2); pC->movetoTarget = sqlite3VdbeIntValue(pIn2);
pC->rowidIsValid = 0; pC->rowidIsValid = 0;
pC->deferredMoveto = 1; pC->deferredMoveto = 1;
}
break; break;
} }
@@ -3760,58 +3747,56 @@ case OP_Found: { /* jump, in3 */
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
assert( pC!=0 ); assert( pC!=0 );
pIn3 = &aMem[pOp->p3]; pIn3 = &aMem[pOp->p3];
if( ALWAYS(pC->pCursor!=0) ){ assert( pC->pCursor!=0 );
assert( pC->isTable==0 );
assert( pC->isTable==0 ); if( pOp->p4.i>0 ){
if( pOp->p4.i>0 ){ r.pKeyInfo = pC->pKeyInfo;
r.pKeyInfo = pC->pKeyInfo; r.nField = (u16)pOp->p4.i;
r.nField = (u16)pOp->p4.i; r.aMem = pIn3;
r.aMem = pIn3;
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
{ {
int i; int i;
for(i=0; i<r.nField; i++){ for(i=0; i<r.nField; i++){
assert( memIsValid(&r.aMem[i]) ); assert( memIsValid(&r.aMem[i]) );
if( i ) REGISTER_TRACE(pOp->p3+i, &r.aMem[i]); if( i ) REGISTER_TRACE(pOp->p3+i, &r.aMem[i]);
}
} }
}
#endif #endif
r.flags = UNPACKED_PREFIX_MATCH; r.flags = UNPACKED_PREFIX_MATCH;
pIdxKey = &r; pIdxKey = &r;
}else{ }else{
pIdxKey = sqlite3VdbeAllocUnpackedRecord( pIdxKey = sqlite3VdbeAllocUnpackedRecord(
pC->pKeyInfo, aTempRec, sizeof(aTempRec), &pFree pC->pKeyInfo, aTempRec, sizeof(aTempRec), &pFree
); );
if( pIdxKey==0 ) goto no_mem; if( pIdxKey==0 ) goto no_mem;
assert( pIn3->flags & MEM_Blob ); assert( pIn3->flags & MEM_Blob );
assert( (pIn3->flags & MEM_Zero)==0 ); /* zeroblobs already expanded */ assert( (pIn3->flags & MEM_Zero)==0 ); /* zeroblobs already expanded */
sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey); sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
pIdxKey->flags |= UNPACKED_PREFIX_MATCH; pIdxKey->flags |= UNPACKED_PREFIX_MATCH;
} }
if( pOp->opcode==OP_NoConflict ){ if( pOp->opcode==OP_NoConflict ){
/* For the OP_NoConflict opcode, take the jump if any of the /* For the OP_NoConflict opcode, take the jump if any of the
** input fields are NULL, since any key with a NULL will not ** input fields are NULL, since any key with a NULL will not
** conflict */ ** conflict */
for(ii=0; ii<r.nField; ii++){ for(ii=0; ii<r.nField; ii++){
if( r.aMem[ii].flags & MEM_Null ){ if( r.aMem[ii].flags & MEM_Null ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
break; break;
}
} }
} }
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res);
if( pOp->p4.i==0 ){
sqlite3DbFree(db, pFree);
}
if( rc!=SQLITE_OK ){
break;
}
pC->seekResult = res;
alreadyExists = (res==0);
pC->nullRow = 1-alreadyExists;
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
} }
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res);
if( pOp->p4.i==0 ){
sqlite3DbFree(db, pFree);
}
if( rc!=SQLITE_OK ){
break;
}
pC->seekResult = res;
alreadyExists = (res==0);
pC->nullRow = 1-alreadyExists;
pC->deferredMoveto = 0;
pC->cacheStatus = CACHE_STALE;
if( pOp->opcode==OP_Found ){ if( pOp->opcode==OP_Found ){
if( alreadyExists ) pc = pOp->p2 - 1; if( alreadyExists ) pc = pOp->p2 - 1;
}else{ }else{
@@ -3848,28 +3833,20 @@ case OP_NotExists: { /* jump, in3 */
assert( pC->isTable ); assert( pC->isTable );
assert( pC->pseudoTableReg==0 ); assert( pC->pseudoTableReg==0 );
pCrsr = pC->pCursor; pCrsr = pC->pCursor;
if( ALWAYS(pCrsr!=0) ){ assert( pCrsr!=0 );
res = 0; res = 0;
iKey = pIn3->u.i; iKey = pIn3->u.i;
rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res); rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
pC->lastRowid = pIn3->u.i; pC->lastRowid = pIn3->u.i;
pC->rowidIsValid = res==0 ?1:0; pC->rowidIsValid = res==0 ?1:0;
pC->nullRow = 0; pC->nullRow = 0;
pC->cacheStatus = CACHE_STALE; pC->cacheStatus = CACHE_STALE;
pC->deferredMoveto = 0; pC->deferredMoveto = 0;
if( res!=0 ){ if( res!=0 ){
pc = pOp->p2 - 1;
assert( pC->rowidIsValid==0 );
}
pC->seekResult = res;
}else{
/* This happens when an attempt to open a read cursor on the
** sqlite_master table returns SQLITE_EMPTY.
*/
pc = pOp->p2 - 1; pc = pOp->p2 - 1;
assert( pC->rowidIsValid==0 ); assert( pC->rowidIsValid==0 );
pC->seekResult = 0;
} }
pC->seekResult = res;
break; break;
} }
@@ -4449,9 +4426,8 @@ case OP_Last: { /* jump */
assert( pC!=0 ); assert( pC!=0 );
pCrsr = pC->pCursor; pCrsr = pC->pCursor;
res = 0; res = 0;
if( ALWAYS(pCrsr!=0) ){ assert( pCrsr!=0 );
rc = sqlite3BtreeLast(pCrsr, &res); rc = sqlite3BtreeLast(pCrsr, &res);
}
pC->nullRow = (u8)res; pC->nullRow = (u8)res;
pC->deferredMoveto = 0; pC->deferredMoveto = 0;
pC->rowidIsValid = 0; pC->rowidIsValid = 0;
@@ -4618,21 +4594,20 @@ case OP_IdxInsert: { /* in2 */
assert( pIn2->flags & MEM_Blob ); assert( pIn2->flags & MEM_Blob );
pCrsr = pC->pCursor; pCrsr = pC->pCursor;
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
if( ALWAYS(pCrsr!=0) ){ assert( pCrsr!=0 );
assert( pC->isTable==0 ); assert( pC->isTable==0 );
rc = ExpandBlob(pIn2); rc = ExpandBlob(pIn2);
if( rc==SQLITE_OK ){ if( rc==SQLITE_OK ){
if( isSorter(pC) ){ if( isSorter(pC) ){
rc = sqlite3VdbeSorterWrite(db, pC, pIn2); rc = sqlite3VdbeSorterWrite(db, pC, pIn2);
}else{ }else{
nKey = pIn2->n; nKey = pIn2->n;
zKey = pIn2->z; zKey = pIn2->z;
rc = sqlite3BtreeInsert(pCrsr, zKey, nKey, "", 0, 0, pOp->p3, rc = sqlite3BtreeInsert(pCrsr, zKey, nKey, "", 0, 0, pOp->p3,
((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
); );
assert( pC->deferredMoveto==0 ); assert( pC->deferredMoveto==0 );
pC->cacheStatus = CACHE_STALE; pC->cacheStatus = CACHE_STALE;
}
} }
} }
break; break;
@@ -4657,22 +4632,21 @@ case OP_IdxDelete: {
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
assert( pC!=0 ); assert( pC!=0 );
pCrsr = pC->pCursor; pCrsr = pC->pCursor;
assert( pCrsr!=0 );
if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;
if( ALWAYS(pCrsr!=0) ){ r.pKeyInfo = pC->pKeyInfo;
r.pKeyInfo = pC->pKeyInfo; r.nField = (u16)pOp->p3;
r.nField = (u16)pOp->p3; r.flags = UNPACKED_PREFIX_MATCH;
r.flags = UNPACKED_PREFIX_MATCH; r.aMem = &aMem[pOp->p2];
r.aMem = &aMem[pOp->p2];
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); } { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif #endif
rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res); rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
if( rc==SQLITE_OK && res==0 ){ if( rc==SQLITE_OK && res==0 ){
rc = sqlite3BtreeDelete(pCrsr); rc = sqlite3BtreeDelete(pCrsr);
}
assert( pC->deferredMoveto==0 );
pC->cacheStatus = CACHE_STALE;
} }
assert( pC->deferredMoveto==0 );
pC->cacheStatus = CACHE_STALE;
break; break;
} }
@@ -4694,20 +4668,19 @@ case OP_IdxRowid: { /* out2-prerelease */
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
assert( pC!=0 ); assert( pC!=0 );
pCrsr = pC->pCursor; pCrsr = pC->pCursor;
assert( pCrsr!=0 );
pOut->flags = MEM_Null; pOut->flags = MEM_Null;
if( ALWAYS(pCrsr!=0) ){ rc = sqlite3VdbeCursorMoveto(pC);
rc = sqlite3VdbeCursorMoveto(pC); if( NEVER(rc) ) goto abort_due_to_error;
if( NEVER(rc) ) goto abort_due_to_error; assert( pC->deferredMoveto==0 );
assert( pC->deferredMoveto==0 ); assert( pC->isTable==0 );
assert( pC->isTable==0 ); if( !pC->nullRow ){
if( !pC->nullRow ){ rc = sqlite3VdbeIdxRowid(db, pCrsr, &rowid);
rc = sqlite3VdbeIdxRowid(db, pCrsr, &rowid); if( rc!=SQLITE_OK ){
if( rc!=SQLITE_OK ){ goto abort_due_to_error;
goto abort_due_to_error;
}
pOut->u.i = rowid;
pOut->flags = MEM_Int;
} }
pOut->u.i = rowid;
pOut->flags = MEM_Int;
} }
break; break;
} }
@@ -4750,31 +4723,30 @@ case OP_IdxGE: { /* jump */
pC = p->apCsr[pOp->p1]; pC = p->apCsr[pOp->p1];
assert( pC!=0 ); assert( pC!=0 );
assert( pC->isOrdered ); assert( pC->isOrdered );
if( ALWAYS(pC->pCursor!=0) ){ assert( pC->pCursor!=0);
assert( pC->deferredMoveto==0 ); assert( pC->deferredMoveto==0 );
assert( pOp->p5==0 || pOp->p5==1 ); assert( pOp->p5==0 || pOp->p5==1 );
assert( pOp->p4type==P4_INT32 ); assert( pOp->p4type==P4_INT32 );
r.pKeyInfo = pC->pKeyInfo; r.pKeyInfo = pC->pKeyInfo;
r.nField = (u16)pOp->p4.i; r.nField = (u16)pOp->p4.i;
if( pOp->p5 ){ if( pOp->p5 ){
r.flags = UNPACKED_INCRKEY | UNPACKED_PREFIX_MATCH; r.flags = UNPACKED_INCRKEY | UNPACKED_PREFIX_MATCH;
}else{ }else{
r.flags = UNPACKED_PREFIX_MATCH; r.flags = UNPACKED_PREFIX_MATCH;
} }
r.aMem = &aMem[pOp->p3]; r.aMem = &aMem[pOp->p3];
#ifdef SQLITE_DEBUG #ifdef SQLITE_DEBUG
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); } { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
#endif #endif
rc = sqlite3VdbeIdxKeyCompare(pC, &r, &res); rc = sqlite3VdbeIdxKeyCompare(pC, &r, &res);
if( pOp->opcode==OP_IdxLT ){ if( pOp->opcode==OP_IdxLT ){
res = -res; res = -res;
}else{ }else{
assert( pOp->opcode==OP_IdxGE ); assert( pOp->opcode==OP_IdxGE );
res++; res++;
} }
if( res>0 ){ if( res>0 ){
pc = pOp->p2 - 1 ; pc = pOp->p2 - 1 ;
}
} }
break; break;
} }