Give a better error message on DROP COLUMN when attempting to drop
the last column of a table. FossilOrigin-Name: 5e1f362bc3e53c60f9e6f771346d10c6e6a6cb3ff1eec5608101f9c5d6d2a5a4
This commit is contained in:
@@ -1880,6 +1880,12 @@ void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token *pName){
|
||||
goto exit_drop_column;
|
||||
}
|
||||
|
||||
/* Do not allow the number of columns to go to zero */
|
||||
if( pTab->nCol<=1 ){
|
||||
sqlite3ErrorMsg(pParse, "cannot drop column \"%s\": no other columns exist",zCol);
|
||||
goto exit_drop_column;
|
||||
}
|
||||
|
||||
/* Edit the sqlite_schema table */
|
||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||
assert( iDb>=0 );
|
||||
|
||||
Reference in New Issue
Block a user