1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Prevent ALTER TABLE from being used to add a column with a REFERENCES clause and a non-NULL default value while foreign key support is enabled.

FossilOrigin-Name: 353b1b18253ab71ba38a887e555994f5469b87bd
This commit is contained in:
dan
2009-09-25 11:26:54 +00:00
parent 140026bdb5
commit 53c3fa8dbe
4 changed files with 53 additions and 8 deletions

View File

@@ -515,6 +515,11 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
sqlite3ErrorMsg(pParse, "Cannot add a UNIQUE column");
return;
}
if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){
sqlite3ErrorMsg(pParse,
"Cannot add a REFERENCES column with non-NULL default value");
return;
}
if( pCol->notNull && !pDflt ){
sqlite3ErrorMsg(pParse,
"Cannot add a NOT NULL column with default value NULL");