diff options
author | drh <drh@noemail.net> | 2018-03-16 20:15:58 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-03-16 20:15:58 +0000 |
commit | 1e9c47be1e81e94a67f788c98fd70e8bf70e3746 (patch) | |
tree | 30104f42d743b9dfdb824110b8a8fd245d12bfd0 /src | |
parent | 8bbddd804990caf0ec19235e128c25c631e40f8b (diff) | |
download | sqlite-1e9c47be1e81e94a67f788c98fd70e8bf70e3746.tar.gz sqlite-1e9c47be1e81e94a67f788c98fd70e8bf70e3746.zip |
Better error message text when the schema is corrupted by a CREATE TABLE AS
entry.
FossilOrigin-Name: e13993cf833423eec5f94082cee7213b2d97bcf40dddb2683cf5a8ebf50a33e3
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 6 | ||||
-rw-r--r-- | src/parse.y | 9 | ||||
-rw-r--r-- | src/prepare.c | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/src/build.c b/src/build.c index 3a656def3..eaddef5b1 100644 --- a/src/build.c +++ b/src/build.c @@ -1870,8 +1870,6 @@ void sqlite3EndTable( p = pParse->pNewTable; if( p==0 ) return; - assert( !db->init.busy || !pSelect ); - /* If the db->init.busy is 1 it means we are reading the SQL off the ** "sqlite_master" or "sqlite_temp_master" table on the disk. ** So do not write to the disk again. Extract the root page number @@ -1882,6 +1880,10 @@ void sqlite3EndTable( ** table itself. So mark it read-only. */ if( db->init.busy ){ + if( pSelect ){ + sqlite3ErrorMsg(pParse, ""); + return; + } p->tnum = db->init.newTnum; if( p->tnum==1 ) p->tabFlags |= TF_Readonly; } diff --git a/src/parse.y b/src/parse.y index 638960d24..9c41484ab 100644 --- a/src/parse.y +++ b/src/parse.y @@ -169,13 +169,8 @@ create_table_args ::= LP columnlist conslist_opt(X) RP(E) table_options(F). { sqlite3EndTable(pParse,&X,&E,F,0); } create_table_args ::= AS select(S). { - if( pParse->db->init.busy==0 ){ - sqlite3EndTable(pParse,0,0,0,S); - sqlite3SelectDelete(pParse->db, S); - }else{ - sqlite3SelectDelete(pParse->db, S); - sqlite3ErrorMsg(pParse, "corrupt schema"); - } + sqlite3EndTable(pParse,0,0,0,S); + sqlite3SelectDelete(pParse->db, S); } %type table_options {int} table_options(A) ::= . {A = 0;} diff --git a/src/prepare.c b/src/prepare.c index 65a4afcbb..c1bd20f16 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -29,7 +29,7 @@ static void corruptSchema( char *z; if( zObj==0 ) zObj = "?"; z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); - if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); + if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); sqlite3DbFree(db, *pData->pzErrMsg); *pData->pzErrMsg = z; } |