Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Better error message text when the schema is corrupted by a CREATE TABLE AS entry. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | corrupt-schema |
Files: | files | file ages | folders |
SHA3-256: |
e13993cf833423eec5f94082cee7213b |
User & Date: | drh 2018-03-16 20:15:58.956 |
Context
2018-03-16
| ||
20:23 | Detect databases whose schema is corrupted using a CREATE TABLE AS statement and issue an appropriate error message. (check-in: d75e67654a user: drh tags: trunk) | |
20:15 | Better error message text when the schema is corrupted by a CREATE TABLE AS entry. (Closed-Leaf check-in: e13993cf83 user: drh tags: corrupt-schema) | |
19:10 | Fix a parsing issue associated with a corrupt sqlite_master table. (check-in: 5f779ff6b4 user: mistachkin tags: corrupt-schema) | |
Changes
Changes to src/build.c.
︙ | ︙ | |||
1866 1867 1868 1869 1870 1871 1872 | if( pEnd==0 && pSelect==0 ){ return; } assert( !db->mallocFailed ); p = pParse->pNewTable; if( p==0 ) return; | < < > > > > | 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 | if( pEnd==0 && pSelect==0 ){ return; } assert( !db->mallocFailed ); p = pParse->pNewTable; if( p==0 ) return; /* 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 ** for the table from the db->init.newTnum field. (The page number ** should have been put there by the sqliteOpenCb routine.) ** ** If the root page number is 1, that means this is the sqlite_master ** 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; } /* Special processing for WITHOUT ROWID Tables */ if( tabOpts & TF_WithoutRowid ){ if( (p->tabFlags & TF_Autoincrement) ){ |
︙ | ︙ |
Changes to src/parse.y.
︙ | ︙ | |||
165 166 167 168 169 170 171 | temp(A) ::= TEMP. {A = 1;} %endif SQLITE_OMIT_TEMPDB temp(A) ::= . {A = 0;} 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). { | < | | < < < < | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | temp(A) ::= TEMP. {A = 1;} %endif SQLITE_OMIT_TEMPDB temp(A) ::= . {A = 0;} 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). { sqlite3EndTable(pParse,0,0,0,S); sqlite3SelectDelete(pParse->db, S); } %type table_options {int} table_options(A) ::= . {A = 0;} table_options(A) ::= WITHOUT nm(X). { if( X.n==5 && sqlite3_strnicmp(X.z,"rowid",5)==0 ){ A = TF_WithoutRowid | TF_NoVisibleRowid; }else{ |
︙ | ︙ |
Changes to src/prepare.c.
︙ | ︙ | |||
25 26 27 28 29 30 31 | const char *zExtra /* Error information */ ){ sqlite3 *db = pData->db; if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){ char *z; if( zObj==0 ) zObj = "?"; z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | const char *zExtra /* Error information */ ){ sqlite3 *db = pData->db; if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){ char *z; if( zObj==0 ) zObj = "?"; z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); sqlite3DbFree(db, *pData->pzErrMsg); *pData->pzErrMsg = z; } pData->rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_CORRUPT_BKPT; } /* |
︙ | ︙ |