diff options
author | drh <> | 2023-10-13 22:19:23 +0000 |
---|---|---|
committer | drh <> | 2023-10-13 22:19:23 +0000 |
commit | 9132b8816aba57e5f00d22637008d2eb588e768b (patch) | |
tree | 92b56fd77de30abbd6d1bf45ec64d1ef1efc8820 /src | |
parent | cc67a62fa01ecf2ebab6ddb52adc58d41d95f66a (diff) | |
download | sqlite-9132b8816aba57e5f00d22637008d2eb588e768b.tar.gz sqlite-9132b8816aba57e5f00d22637008d2eb588e768b.zip |
Earlier detection of a host of errors in CREATE TABLE, such the CREATE TABLE
statement itself fails, rather than generating an error on the first attempted
use of the created table.
FossilOrigin-Name: 348fa7aaf7958b3fb689ed023d946064ae8d92718a497a346e95114a2410cbf5
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 1 | ||||
-rw-r--r-- | src/build.c | 10 | ||||
-rw-r--r-- | src/vdbe.c | 13 |
3 files changed, 21 insertions, 3 deletions
diff --git a/src/btree.c b/src/btree.c index 1575d7d94..3c4f00d15 100644 --- a/src/btree.c +++ b/src/btree.c @@ -10708,6 +10708,7 @@ static int checkTreePage( if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ checkAppendMsg(pCheck, "unable to get the page. error code=%d", rc); + if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM; goto end_of_check; } diff --git a/src/build.c b/src/build.c index 0920b0f22..24f5d3f96 100644 --- a/src/build.c +++ b/src/build.c @@ -2921,12 +2921,16 @@ void sqlite3EndTable( sqlite3VdbeAddParseSchemaOp(v, iDb, sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); - /* Test for cycles in generated columns */ + /* Test for cycles in generated columns and illegal expressions + ** in CHECK constraints and in DEFAULT clauses. */ if( p->tabFlags & TF_HasGenerated ){ - sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, - sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%s\"", + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", + db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } /* Add the table to the in-memory representation of the database. diff --git a/src/vdbe.c b/src/vdbe.c index 00d365680..ce094f997 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6906,18 +6906,31 @@ case OP_CreateBtree: { /* out2 */ /* Opcode: SqlExec * * * P4 * ** ** Run the SQL statement or statements specified in the P4 string. +** Disable Auth and Trace callbacks while those statements are running if +** P1 is true. */ case OP_SqlExec: { char *zErr; + sqlite3_xauth xAuth; + u8 mTrace; sqlite3VdbeIncrWriteCounter(p, 0); db->nSqlExec++; zErr = 0; + xAuth = db->xAuth; + mTrace = db->mTrace; + if( pOp->p1 ){ + db->xAuth = 0; + db->mTrace = 0; + } rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); db->nSqlExec--; + db->xAuth = xAuth; + db->mTrace = mTrace; if( rc || zErr ){ sqlite3VdbeError(p, "%s", zErr); sqlite3_free(zErr); + if( rc==SQLITE_NOMEM ) goto no_mem; goto abort_due_to_error; } break; |