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

Add assert() statements on the nExtraDelete variable in vdbe.c to try to verify

that the FORDELETE and IDXDELETE flags are being generated correctly.  Those
flags are not currently generated correctly, and so the assert()s trip on this
check-in.

FossilOrigin-Name: dde1db0dd2e2cf04706117629756c352b178ebb8
This commit is contained in:
drh
2016-01-27 15:49:32 +00:00
parent 8716bfd8cd
commit b89aeb6aa2
7 changed files with 62 additions and 23 deletions

View File

@@ -551,6 +551,9 @@ int sqlite3VdbeExec(
Op *pOp = aOp; /* Current operation */
#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
Op *pOrigOp; /* Value of pOp at the top of the loop */
#endif
#ifdef SQLITE_DEBUG
int nExtraDelete = 0; /* Verifies FORDELETE and IDXDELETE flags */
#endif
int rc = SQLITE_OK; /* Value to return */
sqlite3 *db = p->db; /* The database */
@@ -3392,6 +3395,9 @@ case OP_OpenWrite:
pCur->nullRow = 1;
pCur->isOrdered = 1;
pCur->pgnoRoot = p2;
#ifdef SQLITE_DEBUG
pCur->wrFlag = wrFlag;
#endif
rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->uc.pCursor);
pCur->pKeyInfo = pKeyInfo;
/* Set the VdbeCursor.isTable variable. Previous versions of
@@ -4390,10 +4396,24 @@ case OP_Delete: {
assert( pC->movetoTarget==iKey );
}
#endif
/* Only flags that can be set are SAVEPOISTION and IDXDELETE */
assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_IDXDELETE))==0 );
assert( OPFLAG_SAVEPOSITION==BTREE_SAVEPOSITION );
assert( OPFLAG_IDXDELETE==BTREE_IDXDELETE );
#ifdef SQLITE_DEBUG
if( pC->isEphemeral==0
&& (pOp->p5 & OPFLAG_IDXDELETE)==0
&& (pC->wrFlag & OPFLAG_FORDELETE)==0
){
nExtraDelete++;
}
if( pOp->p2 & OPFLAG_NCHANGE ){
nExtraDelete--;
}
#endif
rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);
pC->cacheStatus = CACHE_STALE;
@@ -4939,7 +4959,16 @@ case OP_IdxDelete: {
r.default_rc = 0;
r.aMem = &aMem[pOp->p2];
#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]) );
if( pC->isEphemeral==0
&& (pOp->p5 & OPFLAG_IDXDELETE)==0
&& (pC->wrFlag & OPFLAG_FORDELETE)==0
){
nExtraDelete++;
}
}
#endif
rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
if( rc==SQLITE_OK && res==0 ){
@@ -6762,6 +6791,7 @@ vdbe_return:
testcase( nVmStep>0 );
p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep;
sqlite3VdbeLeave(p);
assert( nExtraDelete==0 || sqlite3_strlike("DELETE%",p->zSql,0)!=0 );
return rc;
/* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH