mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Simplifications to error message processing. Fix a possible problem in error
message formatting when vacuuming a database with a corrupt schema. FossilOrigin-Name: 56ef98a04765c34c1c2f3ed7a6f03a732f3b886e
This commit is contained in:
54
src/vdbe.c
54
src/vdbe.c
@@ -967,12 +967,11 @@ case OP_Halt: {
|
||||
assert( zType!=0 || pOp->p4.z!=0 );
|
||||
zLogFmt = "abort at %d in [%s]: %s";
|
||||
if( zType && pOp->p4.z ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s constraint failed: %s",
|
||||
zType, pOp->p4.z);
|
||||
sqlite3VdbeError(p, "%s constraint failed: %s", zType, pOp->p4.z);
|
||||
}else if( pOp->p4.z ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
|
||||
sqlite3VdbeError(p, "%s", pOp->p4.z);
|
||||
}else{
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType);
|
||||
sqlite3VdbeError(p, "%s constraint failed", zType);
|
||||
}
|
||||
sqlite3_log(pOp->p1, zLogFmt, pcx, p->zSql, p->zErrMsg);
|
||||
}
|
||||
@@ -1604,7 +1603,7 @@ case OP_Function: {
|
||||
/* If the function returned an error, throw an exception */
|
||||
if( ctx.fErrorOrAux ){
|
||||
if( ctx.isError ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(ctx.pOut));
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(ctx.pOut));
|
||||
rc = ctx.isError;
|
||||
}
|
||||
sqlite3VdbeDeleteAuxData(p, (int)(pOp - aOp), pOp->p1);
|
||||
@@ -2791,8 +2790,7 @@ case OP_Savepoint: {
|
||||
/* A new savepoint cannot be created if there are active write
|
||||
** statements (i.e. open read/write incremental blob handles).
|
||||
*/
|
||||
sqlite3SetString(&p->zErrMsg, db, "cannot open savepoint - "
|
||||
"SQL statements in progress");
|
||||
sqlite3VdbeError(p, "cannot open savepoint - SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
}else{
|
||||
nName = sqlite3Strlen30(zName);
|
||||
@@ -2843,15 +2841,14 @@ case OP_Savepoint: {
|
||||
iSavepoint++;
|
||||
}
|
||||
if( !pSavepoint ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", zName);
|
||||
sqlite3VdbeError(p, "no such savepoint: %s", zName);
|
||||
rc = SQLITE_ERROR;
|
||||
}else if( db->nVdbeWrite>0 && p1==SAVEPOINT_RELEASE ){
|
||||
/* It is not possible to release (commit) a savepoint if there are
|
||||
** active write statements.
|
||||
*/
|
||||
sqlite3SetString(&p->zErrMsg, db,
|
||||
"cannot release savepoint - SQL statements in progress"
|
||||
);
|
||||
sqlite3VdbeError(p, "cannot release savepoint - "
|
||||
"SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
}else{
|
||||
|
||||
@@ -2957,23 +2954,12 @@ case OP_AutoCommit: {
|
||||
assert( db->nVdbeActive>0 ); /* At least this one VM is active */
|
||||
assert( p->bIsReader );
|
||||
|
||||
#if 0
|
||||
if( turnOnAC && iRollback && db->nVdbeActive>1 ){
|
||||
/* If this instruction implements a ROLLBACK and other VMs are
|
||||
** still running, and a transaction is active, return an error indicating
|
||||
** that the other VMs must complete first.
|
||||
*/
|
||||
sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - "
|
||||
"SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
}else
|
||||
#endif
|
||||
if( turnOnAC && !iRollback && db->nVdbeWrite>0 ){
|
||||
/* If this instruction implements a COMMIT and other VMs are writing
|
||||
** return an error indicating that the other VMs must complete first.
|
||||
*/
|
||||
sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - "
|
||||
"SQL statements in progress");
|
||||
sqlite3VdbeError(p, "cannot commit transaction - "
|
||||
"SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
}else if( desiredAutoCommit!=db->autoCommit ){
|
||||
if( iRollback ){
|
||||
@@ -3000,7 +2986,7 @@ case OP_AutoCommit: {
|
||||
}
|
||||
goto vdbe_return;
|
||||
}else{
|
||||
sqlite3SetString(&p->zErrMsg, db,
|
||||
sqlite3VdbeError(p,
|
||||
(!desiredAutoCommit)?"cannot start a transaction within a transaction":(
|
||||
(iRollback)?"cannot rollback - no transaction is active":
|
||||
"cannot commit - no transaction is active"));
|
||||
@@ -5433,7 +5419,7 @@ case OP_Program: { /* jump */
|
||||
|
||||
if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3SetString(&p->zErrMsg, db, "too many levels of trigger recursion");
|
||||
sqlite3VdbeError(p, "too many levels of trigger recursion");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5736,7 +5722,7 @@ case OP_AggStep: {
|
||||
ctx.skipFlag = 0;
|
||||
(ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */
|
||||
if( ctx.isError ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&t));
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(&t));
|
||||
rc = ctx.isError;
|
||||
}
|
||||
if( ctx.skipFlag ){
|
||||
@@ -5768,7 +5754,7 @@ case OP_AggFinal: {
|
||||
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
|
||||
rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);
|
||||
if( rc ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(pMem));
|
||||
sqlite3VdbeError(p, "%s", sqlite3_value_text(pMem));
|
||||
}
|
||||
sqlite3VdbeChangeEncoding(pMem, encoding);
|
||||
UPDATE_MAX_BLOBSIZE(pMem);
|
||||
@@ -5873,7 +5859,7 @@ case OP_JournalMode: { /* out2 */
|
||||
){
|
||||
if( !db->autoCommit || db->nVdbeRead>1 ){
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3SetString(&p->zErrMsg, db,
|
||||
sqlite3VdbeError(p,
|
||||
"cannot change %s wal mode from within a transaction",
|
||||
(eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of")
|
||||
);
|
||||
@@ -6004,7 +5990,7 @@ case OP_TableLock: {
|
||||
rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);
|
||||
if( (rc&0xFF)==SQLITE_LOCKED ){
|
||||
const char *z = pOp->p4.z;
|
||||
sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z);
|
||||
sqlite3VdbeError(p, "database table is locked: %s", z);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -6552,7 +6538,7 @@ vdbe_return:
|
||||
** is encountered.
|
||||
*/
|
||||
too_big:
|
||||
sqlite3SetString(&p->zErrMsg, db, "string or blob too big");
|
||||
sqlite3VdbeError(p, "string or blob too big");
|
||||
rc = SQLITE_TOOBIG;
|
||||
goto vdbe_error_halt;
|
||||
|
||||
@@ -6560,7 +6546,7 @@ too_big:
|
||||
*/
|
||||
no_mem:
|
||||
db->mallocFailed = 1;
|
||||
sqlite3SetString(&p->zErrMsg, db, "out of memory");
|
||||
sqlite3VdbeError(p, "out of memory");
|
||||
rc = SQLITE_NOMEM;
|
||||
goto vdbe_error_halt;
|
||||
|
||||
@@ -6571,7 +6557,7 @@ abort_due_to_error:
|
||||
assert( p->zErrMsg==0 );
|
||||
if( db->mallocFailed ) rc = SQLITE_NOMEM;
|
||||
if( rc!=SQLITE_IOERR_NOMEM ){
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(rc));
|
||||
sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
|
||||
}
|
||||
goto vdbe_error_halt;
|
||||
|
||||
@@ -6582,6 +6568,6 @@ abort_due_to_interrupt:
|
||||
assert( db->u1.isInterrupted );
|
||||
rc = SQLITE_INTERRUPT;
|
||||
p->rc = rc;
|
||||
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(rc));
|
||||
sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc));
|
||||
goto vdbe_error_halt;
|
||||
}
|
||||
|
Reference in New Issue
Block a user