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:
drh
2021-02-19 09:09:07 +00:00
parent c90fa01dbf
commit 239c84fc62
4 changed files with 15 additions and 11 deletions
+6
View File
@@ -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 );