mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Merge all the latest changes from trunk.
FossilOrigin-Name: b86590043e17705ada90562cf30f69b3e3ef65a4
This commit is contained in:
233
src/vdbe.c
233
src/vdbe.c
@@ -637,7 +637,11 @@ int sqlite3VdbeExec(
|
||||
}
|
||||
sqlite3EndBenignMalloc();
|
||||
#endif
|
||||
for(pOp=&aOp[p->pc]; rc==SQLITE_OK; pOp++){
|
||||
for(pOp=&aOp[p->pc]; 1; pOp++){
|
||||
/* Errors are detected by individual opcodes, with an immediate
|
||||
** jumps to abort_due_to_error. */
|
||||
assert( rc==SQLITE_OK );
|
||||
|
||||
assert( pOp>=aOp && pOp<&aOp[p->nOp]);
|
||||
#ifdef VDBE_PROFILE
|
||||
start = sqlite3Hwtime();
|
||||
@@ -784,7 +788,7 @@ check_for_interrupt:
|
||||
nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
|
||||
if( db->xProgress(db->pProgressArg) ){
|
||||
rc = SQLITE_INTERRUPT;
|
||||
goto vdbe_error_halt;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1063,7 +1067,10 @@ case OP_String8: { /* same as TK_STRING, out2 */
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
if( encoding!=SQLITE_UTF8 ){
|
||||
rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);
|
||||
if( rc==SQLITE_TOOBIG ) goto too_big;
|
||||
if( rc ){
|
||||
assert( rc==SQLITE_TOOBIG ); /* This is the only possible error here */
|
||||
goto too_big;
|
||||
}
|
||||
if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem;
|
||||
assert( pOut->szMalloc>0 && pOut->zMalloc==pOut->z );
|
||||
assert( VdbeMemDynamic(pOut)==0 );
|
||||
@@ -1329,7 +1336,7 @@ case OP_ResultRow: {
|
||||
&& db->xProgress(db->pProgressArg)!=0
|
||||
){
|
||||
rc = SQLITE_INTERRUPT;
|
||||
goto vdbe_error_halt;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1339,7 +1346,7 @@ case OP_ResultRow: {
|
||||
if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){
|
||||
assert( db->flags&SQLITE_CountRows );
|
||||
assert( p->usesStmtJournal );
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
||||
/* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then
|
||||
@@ -1359,9 +1366,7 @@ case OP_ResultRow: {
|
||||
*/
|
||||
assert( p->iStatement==0 || db->flags&SQLITE_CountRows );
|
||||
rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);
|
||||
if( NEVER(rc!=SQLITE_OK) ){
|
||||
break;
|
||||
}
|
||||
assert( rc==SQLITE_OK );
|
||||
|
||||
/* Invalidate all ephemeral cursor row caches */
|
||||
p->cacheCtr = (p->cacheCtr + 2)|1;
|
||||
@@ -1684,7 +1689,8 @@ case OP_Function: {
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
|
||||
rc = pCtx->isError;
|
||||
}
|
||||
sqlite3VdbeDeleteAuxData(p, pCtx->iOp, pOp->p1);
|
||||
sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}
|
||||
|
||||
/* Copy the result of the function into register P3 */
|
||||
@@ -1868,6 +1874,7 @@ case OP_Cast: { /* in1 */
|
||||
rc = ExpandBlob(pIn1);
|
||||
sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);
|
||||
UPDATE_MAX_BLOBSIZE(pIn1);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_CAST */
|
||||
@@ -2477,7 +2484,7 @@ case OP_Column: {
|
||||
*/
|
||||
if( offset > 98307 || offset > pC->payloadSize ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
goto op_column_error;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2502,7 +2509,7 @@ case OP_Column: {
|
||||
if( pC->aRow==0 ){
|
||||
memset(&sMem, 0, sizeof(sMem));
|
||||
rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem);
|
||||
if( rc!=SQLITE_OK ) goto op_column_error;
|
||||
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
||||
zData = (u8*)sMem.z;
|
||||
}else{
|
||||
zData = pC->aRow;
|
||||
@@ -2538,7 +2545,7 @@ case OP_Column: {
|
||||
|| (offset64 > pC->payloadSize)
|
||||
){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
goto op_column_error;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
}else{
|
||||
t = 0;
|
||||
@@ -2611,15 +2618,13 @@ case OP_Column: {
|
||||
}else{
|
||||
rc = sqlite3VdbeMemFromBtree(pCrsr, aOffset[p2], len, !pC->isTable,
|
||||
pDest);
|
||||
if( rc==SQLITE_OK ){
|
||||
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
|
||||
pDest->flags &= ~MEM_Ephem;
|
||||
}
|
||||
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
||||
sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);
|
||||
pDest->flags &= ~MEM_Ephem;
|
||||
}
|
||||
}
|
||||
|
||||
op_column_out:
|
||||
op_column_error:
|
||||
UPDATE_MAX_BLOBSIZE(pDest);
|
||||
REGISTER_TRACE(pOp->p3, pDest);
|
||||
break;
|
||||
@@ -2824,6 +2829,7 @@ case OP_Count: { /* out2 */
|
||||
assert( pCrsr );
|
||||
nEntry = 0; /* Not needed. Only used to silence a warning. */
|
||||
rc = sqlite3BtreeCount(pCrsr, &nEntry);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pOut = out2Prerelease(p, pOp);
|
||||
pOut->u.i = nEntry;
|
||||
break;
|
||||
@@ -3001,6 +3007,7 @@ case OP_Savepoint: {
|
||||
}
|
||||
}
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -3037,7 +3044,7 @@ case OP_AutoCommit: {
|
||||
sqlite3VdbeError(p, "cannot commit transaction - "
|
||||
"SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
|
||||
goto vdbe_return;
|
||||
}else{
|
||||
@@ -3064,6 +3071,7 @@ case OP_AutoCommit: {
|
||||
"cannot commit - no transaction is active"));
|
||||
|
||||
rc = SQLITE_ERROR;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3186,6 +3194,7 @@ case OP_Transaction: {
|
||||
p->expired = 1;
|
||||
rc = SQLITE_SCHEMA;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3255,6 +3264,7 @@ case OP_SetCookie: {
|
||||
sqlite3ExpirePreparedStatements(db);
|
||||
p->expired = 0;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3352,7 +3362,7 @@ case OP_OpenWrite:
|
||||
|
||||
if( p->expired ){
|
||||
rc = SQLITE_ABORT_ROLLBACK;
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
||||
nField = 0;
|
||||
@@ -3386,10 +3396,7 @@ case OP_OpenWrite:
|
||||
** that opcode will always set the p2 value to 2 or more or else fail.
|
||||
** If there were a failure, the prepared statement would have halted
|
||||
** before reaching this instruction. */
|
||||
if( NEVER(p2<2) ) {
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
assert( p2>=2 );
|
||||
}
|
||||
if( pOp->p4type==P4_KEYINFO ){
|
||||
pKeyInfo = pOp->p4.pKeyInfo;
|
||||
@@ -3427,6 +3434,7 @@ open_cursor_set_hints:
|
||||
#endif
|
||||
sqlite3BtreeCursorHintFlags(pCur->uc.pCursor,
|
||||
(pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3503,6 +3511,7 @@ case OP_OpenEphemeral: {
|
||||
pCx->isTable = 1;
|
||||
}
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
|
||||
break;
|
||||
}
|
||||
@@ -3528,6 +3537,7 @@ case OP_SorterOpen: {
|
||||
assert( pCx->pKeyInfo->db==db );
|
||||
assert( pCx->pKeyInfo->enc==ENC(db) );
|
||||
rc = sqlite3VdbeSorterInit(db, pOp->p3, pCx);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3990,7 +4000,7 @@ case OP_Found: { /* jump, in3 */
|
||||
rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);
|
||||
sqlite3DbFree(db, pFree);
|
||||
if( rc!=SQLITE_OK ){
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
pC->seekResult = res;
|
||||
alreadyExists = (res==0);
|
||||
@@ -4062,6 +4072,7 @@ case OP_NotExists: { /* jump, in3 */
|
||||
goto jump_to_p2;
|
||||
}
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4204,7 +4215,8 @@ case OP_NewRowid: { /* out2 */
|
||||
0, &res))==SQLITE_OK)
|
||||
&& (res==0)
|
||||
&& (++cnt<100));
|
||||
if( rc==SQLITE_OK && res==0 ){
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( res==0 ){
|
||||
rc = SQLITE_FULL; /* IMP: R-38219-53002 */
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
@@ -4338,7 +4350,8 @@ case OP_InsertInt: {
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
|
||||
/* Invoke the update-hook if required. */
|
||||
if( rc==SQLITE_OK && db->xUpdateCallback && op && HasRowid(pTab) ){
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( db->xUpdateCallback && op && HasRowid(pTab) ){
|
||||
db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey);
|
||||
}
|
||||
break;
|
||||
@@ -4453,6 +4466,7 @@ case OP_Delete: {
|
||||
|
||||
rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
|
||||
/* Invoke the update-hook if required. */
|
||||
if( opflags & OPFLAG_NCHANGE ){
|
||||
@@ -4507,6 +4521,7 @@ case OP_SorterCompare: {
|
||||
res = 0;
|
||||
rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);
|
||||
VdbeBranchTaken(res!=0,2);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( res ) goto jump_to_p2;
|
||||
break;
|
||||
};
|
||||
@@ -4532,6 +4547,7 @@ case OP_SorterData: {
|
||||
rc = sqlite3VdbeSorterRowkey(pC, pOut);
|
||||
assert( rc!=SQLITE_OK || (pOut->flags & MEM_Blob) );
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
if( rc ) goto abort_due_to_error;
|
||||
p->apCsr[pOp->p3]->cacheStatus = CACHE_STALE;
|
||||
break;
|
||||
}
|
||||
@@ -4620,6 +4636,7 @@ case OP_RowData: {
|
||||
}else{
|
||||
rc = sqlite3BtreeData(pCrsr, 0, n, pOut->z);
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */
|
||||
UPDATE_MAX_BLOBSIZE(pOut);
|
||||
REGISTER_TRACE(pOp->p2, pOut);
|
||||
@@ -4660,6 +4677,7 @@ case OP_Rowid: { /* out2 */
|
||||
assert( pModule->xRowid );
|
||||
rc = pModule->xRowid(pC->uc.pVCur, &v);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
}else{
|
||||
assert( pC->eCurType==CURTYPE_BTREE );
|
||||
@@ -4730,6 +4748,7 @@ case OP_Last: { /* jump */
|
||||
#ifdef SQLITE_DEBUG
|
||||
pC->seekOp = OP_Last;
|
||||
#endif
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( pOp->p2>0 ){
|
||||
VdbeBranchTaken(res!=0,2);
|
||||
if( res ) goto jump_to_p2;
|
||||
@@ -4794,6 +4813,7 @@ case OP_Rewind: { /* jump */
|
||||
pC->deferredMoveto = 0;
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pC->nullRow = (u8)res;
|
||||
assert( pOp->p2>0 && pOp->p2<p->nOp );
|
||||
VdbeBranchTaken(res!=0,2);
|
||||
@@ -4906,6 +4926,7 @@ case OP_Next: /* jump */
|
||||
next_tail:
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
VdbeBranchTaken(res==0,2);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( res==0 ){
|
||||
pC->nullRow = 0;
|
||||
p->aCounter[pOp->p5]++;
|
||||
@@ -4956,19 +4977,19 @@ case OP_IdxInsert: { /* in2 */
|
||||
assert( pC->eCurType==CURTYPE_BTREE || pOp->opcode==OP_SorterInsert );
|
||||
assert( pC->isTable==0 );
|
||||
rc = ExpandBlob(pIn2);
|
||||
if( rc==SQLITE_OK ){
|
||||
if( pOp->opcode==OP_SorterInsert ){
|
||||
rc = sqlite3VdbeSorterWrite(pC, pIn2);
|
||||
}else{
|
||||
nKey = pIn2->n;
|
||||
zKey = pIn2->z;
|
||||
rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3,
|
||||
((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
|
||||
);
|
||||
assert( pC->deferredMoveto==0 );
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( pOp->opcode==OP_SorterInsert ){
|
||||
rc = sqlite3VdbeSorterWrite(pC, pIn2);
|
||||
}else{
|
||||
nKey = pIn2->n;
|
||||
zKey = pIn2->z;
|
||||
rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3,
|
||||
((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)
|
||||
);
|
||||
assert( pC->deferredMoveto==0 );
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
}
|
||||
if( rc) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4999,8 +5020,10 @@ case OP_IdxDelete: {
|
||||
r.default_rc = 0;
|
||||
r.aMem = &aMem[pOp->p2];
|
||||
rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
|
||||
if( rc==SQLITE_OK && res==0 ){
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( res==0 ){
|
||||
rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}
|
||||
assert( pC->deferredMoveto==0 );
|
||||
pC->cacheStatus = CACHE_STALE;
|
||||
@@ -5175,6 +5198,7 @@ case OP_IdxGE: { /* jump */
|
||||
res++;
|
||||
}
|
||||
VdbeBranchTaken(res>0,2);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
if( res>0 ) goto jump_to_p2;
|
||||
break;
|
||||
}
|
||||
@@ -5210,6 +5234,7 @@ case OP_Destroy: { /* out2 */
|
||||
if( db->nVdbeRead > db->nVDestroy+1 ){
|
||||
rc = SQLITE_LOCKED;
|
||||
p->errorAction = OE_Abort;
|
||||
goto abort_due_to_error;
|
||||
}else{
|
||||
iDb = pOp->p3;
|
||||
assert( DbMaskTest(p->btreeMask, iDb) );
|
||||
@@ -5217,8 +5242,9 @@ case OP_Destroy: { /* out2 */
|
||||
rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
|
||||
pOut->flags = MEM_Int;
|
||||
pOut->u.i = iMoved;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
if( rc==SQLITE_OK && iMoved!=0 ){
|
||||
if( iMoved!=0 ){
|
||||
sqlite3RootPageMoved(db, iDb, iMoved, pOp->p1);
|
||||
/* All OP_Destroy operations occur on the same btree */
|
||||
assert( resetSchemaOnFault==0 || resetSchemaOnFault==iDb+1 );
|
||||
@@ -5264,6 +5290,7 @@ case OP_Clear: {
|
||||
aMem[pOp->p3].u.i += nChange;
|
||||
}
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5287,6 +5314,7 @@ case OP_ResetSorter: {
|
||||
assert( pC->eCurType==CURTYPE_BTREE );
|
||||
assert( pC->isEphemeral );
|
||||
rc = sqlite3BtreeClearTableOfCursor(pC->uc.pCursor);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -5335,6 +5363,7 @@ case OP_CreateTable: { /* out2 */
|
||||
flags = BTREE_BLOBKEY;
|
||||
}
|
||||
rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
pOut->u.i = pgno;
|
||||
break;
|
||||
}
|
||||
@@ -5375,7 +5404,7 @@ case OP_ParseSchema: {
|
||||
"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
|
||||
db->aDb[iDb].zName, zMaster, pOp->p4.z);
|
||||
if( zSql==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
rc = SQLITE_NOMEM_BKPT;
|
||||
}else{
|
||||
assert( db->init.busy==0 );
|
||||
db->init.busy = 1;
|
||||
@@ -5387,9 +5416,12 @@ case OP_ParseSchema: {
|
||||
db->init.busy = 0;
|
||||
}
|
||||
}
|
||||
if( rc ) sqlite3ResetAllSchemasOfConnection(db);
|
||||
if( rc==SQLITE_NOMEM ){
|
||||
goto no_mem;
|
||||
if( rc ){
|
||||
sqlite3ResetAllSchemasOfConnection(db);
|
||||
if( rc==SQLITE_NOMEM ){
|
||||
goto no_mem;
|
||||
}
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -5404,6 +5436,7 @@ case OP_ParseSchema: {
|
||||
case OP_LoadAnalysis: {
|
||||
assert( pOp->p1>=0 && pOp->p1<db->nDb );
|
||||
rc = sqlite3AnalysisLoad(db, pOp->p1);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* !defined(SQLITE_OMIT_ANALYZE) */
|
||||
@@ -5663,7 +5696,7 @@ case OP_Program: { /* jump */
|
||||
if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3VdbeError(p, "too many levels of trigger recursion");
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
||||
/* Register pRt is used to store the memory required to save the state
|
||||
@@ -5723,6 +5756,9 @@ case OP_Program: { /* jump */
|
||||
pFrame->lastRowid = lastRowid;
|
||||
pFrame->nChange = p->nChange;
|
||||
pFrame->nDbChange = p->db->nChange;
|
||||
assert( pFrame->pAuxData==0 );
|
||||
pFrame->pAuxData = p->pAuxData;
|
||||
p->pAuxData = 0;
|
||||
p->nChange = 0;
|
||||
p->pFrame = pFrame;
|
||||
p->aMem = aMem = &VdbeFrameMem(pFrame)[-1];
|
||||
@@ -6027,6 +6063,7 @@ case OP_AggStep: {
|
||||
rc = pCtx->isError;
|
||||
}
|
||||
sqlite3VdbeMemRelease(&t);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}else{
|
||||
assert( t.flags==MEM_Null );
|
||||
}
|
||||
@@ -6059,6 +6096,7 @@ case OP_AggFinal: {
|
||||
rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
|
||||
if( rc ){
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
sqlite3VdbeChangeEncoding(pMem, encoding);
|
||||
UPDATE_MAX_BLOBSIZE(pMem);
|
||||
@@ -6094,7 +6132,8 @@ case OP_Checkpoint: {
|
||||
|| pOp->p2==SQLITE_CHECKPOINT_TRUNCATE
|
||||
);
|
||||
rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);
|
||||
if( rc==SQLITE_BUSY ){
|
||||
if( rc ){
|
||||
if( rc!=SQLITE_BUSY ) goto abort_due_to_error;
|
||||
rc = SQLITE_OK;
|
||||
aRes[0] = 1;
|
||||
}
|
||||
@@ -6167,7 +6206,7 @@ case OP_JournalMode: { /* out2 */
|
||||
"cannot change %s wal mode from within a transaction",
|
||||
(eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
|
||||
);
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}else{
|
||||
|
||||
if( eOld==PAGER_JOURNALMODE_WAL ){
|
||||
@@ -6197,9 +6236,7 @@ case OP_JournalMode: { /* out2 */
|
||||
}
|
||||
#endif /* ifndef SQLITE_OMIT_WAL */
|
||||
|
||||
if( rc ){
|
||||
eNew = eOld;
|
||||
}
|
||||
if( rc ) eNew = eOld;
|
||||
eNew = sqlite3PagerSetJournalMode(pPager, eNew);
|
||||
|
||||
pOut->flags = MEM_Str|MEM_Static|MEM_Term;
|
||||
@@ -6207,6 +6244,7 @@ case OP_JournalMode: { /* out2 */
|
||||
pOut->n = sqlite3Strlen30(pOut->z);
|
||||
pOut->enc = SQLITE_UTF8;
|
||||
sqlite3VdbeChangeEncoding(pOut, encoding);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
};
|
||||
#endif /* SQLITE_OMIT_PRAGMA */
|
||||
@@ -6221,6 +6259,7 @@ case OP_JournalMode: { /* out2 */
|
||||
case OP_Vacuum: {
|
||||
assert( p->readOnly==0 );
|
||||
rc = sqlite3RunVacuum(&p->zErrMsg, db);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -6241,7 +6280,8 @@ case OP_IncrVacuum: { /* jump */
|
||||
pBt = db->aDb[pOp->p1].pBt;
|
||||
rc = sqlite3BtreeIncrVacuum(pBt);
|
||||
VdbeBranchTaken(rc==SQLITE_DONE,2);
|
||||
if( rc==SQLITE_DONE ){
|
||||
if( rc ){
|
||||
if( rc!=SQLITE_DONE ) goto abort_due_to_error;
|
||||
rc = SQLITE_OK;
|
||||
goto jump_to_p2;
|
||||
}
|
||||
@@ -6292,9 +6332,12 @@ case OP_TableLock: {
|
||||
assert( DbMaskTest(p->btreeMask, p1) );
|
||||
assert( isWriteLock==0 || isWriteLock==1 );
|
||||
rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
|
||||
if( (rc&0xFF)==SQLITE_LOCKED ){
|
||||
const char *z = pOp->p4.z;
|
||||
sqlite3VdbeError(p, "database table is locked: %s", z);
|
||||
if( rc ){
|
||||
if( (rc&0xFF)==SQLITE_LOCKED ){
|
||||
const char *z = pOp->p4.z;
|
||||
sqlite3VdbeError(p, "database table is locked: %s", z);
|
||||
}
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -6316,6 +6359,7 @@ case OP_VBegin: {
|
||||
pVTab = pOp->p4.pVtab;
|
||||
rc = sqlite3VtabBegin(db, pVTab);
|
||||
if( pVTab ) sqlite3VtabImportErrmsg(p, pVTab->pVtab);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
@@ -6344,6 +6388,7 @@ case OP_VCreate: {
|
||||
rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);
|
||||
}
|
||||
sqlite3VdbeMemRelease(&sMem);
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
@@ -6358,6 +6403,7 @@ case OP_VDestroy: {
|
||||
db->nVDestroy++;
|
||||
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
|
||||
db->nVDestroy--;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
@@ -6381,25 +6427,25 @@ case OP_VOpen: {
|
||||
pVtab = pOp->p4.pVtab->pVtab;
|
||||
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
|
||||
rc = SQLITE_LOCKED;
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
pModule = pVtab->pModule;
|
||||
rc = pModule->xOpen(pVtab, &pVCur);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
if( SQLITE_OK==rc ){
|
||||
/* Initialize sqlite3_vtab_cursor base class */
|
||||
pVCur->pVtab = pVtab;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
|
||||
/* Initialize vdbe cursor object */
|
||||
pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);
|
||||
if( pCur ){
|
||||
pCur->uc.pVCur = pVCur;
|
||||
pVtab->nRef++;
|
||||
}else{
|
||||
assert( db->mallocFailed );
|
||||
pModule->xClose(pVCur);
|
||||
goto no_mem;
|
||||
}
|
||||
/* Initialize sqlite3_vtab_cursor base class */
|
||||
pVCur->pVtab = pVtab;
|
||||
|
||||
/* Initialize vdbe cursor object */
|
||||
pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);
|
||||
if( pCur ){
|
||||
pCur->uc.pVCur = pVCur;
|
||||
pVtab->nRef++;
|
||||
}else{
|
||||
assert( db->mallocFailed );
|
||||
pModule->xClose(pVCur);
|
||||
goto no_mem;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -6461,9 +6507,8 @@ case OP_VFilter: { /* jump */
|
||||
}
|
||||
rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
if( rc==SQLITE_OK ){
|
||||
res = pModule->xEof(pVCur);
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
res = pModule->xEof(pVCur);
|
||||
pCur->nullRow = 0;
|
||||
VdbeBranchTaken(res!=0,2);
|
||||
if( res ) goto jump_to_p2;
|
||||
@@ -6512,6 +6557,7 @@ case OP_VColumn: {
|
||||
if( sqlite3VdbeMemTooBig(pDest) ){
|
||||
goto too_big;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIRTUALTABLE */
|
||||
@@ -6547,9 +6593,8 @@ case OP_VNext: { /* jump */
|
||||
*/
|
||||
rc = pModule->xNext(pCur->uc.pVCur);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
if( rc==SQLITE_OK ){
|
||||
res = pModule->xEof(pCur->uc.pVCur);
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
res = pModule->xEof(pCur->uc.pVCur);
|
||||
VdbeBranchTaken(!res,2);
|
||||
if( !res ){
|
||||
/* If there is data, jump to P2 */
|
||||
@@ -6581,11 +6626,11 @@ case OP_VRename: {
|
||||
testcase( pName->enc==SQLITE_UTF16BE );
|
||||
testcase( pName->enc==SQLITE_UTF16LE );
|
||||
rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = pVtab->pModule->xRename(pVtab, pName->z);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
p->expired = 0;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
rc = pVtab->pModule->xRename(pVtab, pName->z);
|
||||
sqlite3VtabImportErrmsg(p, pVtab);
|
||||
p->expired = 0;
|
||||
if( rc ) goto abort_due_to_error;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -6634,7 +6679,7 @@ case OP_VUpdate: {
|
||||
pVtab = pOp->p4.pVtab->pVtab;
|
||||
if( pVtab==0 || NEVER(pVtab->pModule==0) ){
|
||||
rc = SQLITE_LOCKED;
|
||||
break;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
pModule = pVtab->pModule;
|
||||
nArg = pOp->p2;
|
||||
@@ -6666,6 +6711,7 @@ case OP_VUpdate: {
|
||||
}else{
|
||||
p->nChange++;
|
||||
}
|
||||
if( rc ) goto abort_due_to_error;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -6837,8 +6883,12 @@ default: { /* This is really OP_Noop and OP_Explain */
|
||||
/* If we reach this point, it means that execution is finished with
|
||||
** an error of some kind.
|
||||
*/
|
||||
vdbe_error_halt:
|
||||
abort_due_to_error:
|
||||
if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT;
|
||||
assert( rc );
|
||||
if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){
|
||||
sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
|
||||
}
|
||||
p->rc = rc;
|
||||
testcase( sqlite3GlobalConfig.xLog!=0 );
|
||||
sqlite3_log(rc, "statement aborts at %d: [%s] %s",
|
||||
@@ -6869,34 +6919,23 @@ vdbe_return:
|
||||
too_big:
|
||||
sqlite3VdbeError(p, "string or blob too big");
|
||||
rc = SQLITE_TOOBIG;
|
||||
goto vdbe_error_halt;
|
||||
goto abort_due_to_error;
|
||||
|
||||
/* Jump to here if a malloc() fails.
|
||||
*/
|
||||
no_mem:
|
||||
sqlite3OomFault(db);
|
||||
sqlite3VdbeError(p, "out of memory");
|
||||
rc = SQLITE_NOMEM;
|
||||
goto vdbe_error_halt;
|
||||
|
||||
/* Jump to here for any other kind of fatal error. The "rc" variable
|
||||
** should hold the error number.
|
||||
*/
|
||||
abort_due_to_error:
|
||||
assert( p->zErrMsg==0 );
|
||||
if( db->mallocFailed ) rc = SQLITE_NOMEM;
|
||||
if( rc!=SQLITE_IOERR_NOMEM ){
|
||||
sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
|
||||
}
|
||||
goto vdbe_error_halt;
|
||||
rc = SQLITE_NOMEM_BKPT;
|
||||
goto abort_due_to_error;
|
||||
|
||||
/* Jump to here if the sqlite3_interrupt() API sets the interrupt
|
||||
** flag.
|
||||
*/
|
||||
abort_due_to_interrupt:
|
||||
assert( db->u1.isInterrupted );
|
||||
rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_INTERRUPT;
|
||||
rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
|
||||
p->rc = rc;
|
||||
sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
|
||||
goto vdbe_error_halt;
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
|
Reference in New Issue
Block a user