aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2021-07-20 08:23:54 +0000
committerdrh <>2021-07-20 08:23:54 +0000
commit0f91a5352b7bb81beb27306d44ad630f3fd9d3cc (patch)
tree0c064a2057a36289cec1cfda1d429b26ff8e00e3 /src
parentb4d9b2b5376e6c6605933a7b9904c795235ff3ff (diff)
downloadsqlite-0f91a5352b7bb81beb27306d44ad630f3fd9d3cc.tar.gz
sqlite-0f91a5352b7bb81beb27306d44ad630f3fd9d3cc.zip
Fix issues in the new ADD COLUMN constraint checking. Add preliminary
test cases. FossilOrigin-Name: 48434ad3fa9504c063d812d119bc8f622548fd02b3d478ff247b11474c4ce5db
Diffstat (limited to 'src')
-rw-r--r--src/alter.c8
-rw-r--r--src/build.c1
-rw-r--r--src/sqliteInt.h3
3 files changed, 5 insertions, 7 deletions
diff --git a/src/alter.c b/src/alter.c
index 7b313dae4..9c5b46261 100644
--- a/src/alter.c
+++ b/src/alter.c
@@ -446,16 +446,16 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
/* Verify that constraints are still satisfied */
- if( pParse->bDiscardCheck
+ if( pNew->pCheck!=0
|| (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0)
){
sqlite3NestedParse(pParse,
"SELECT CASE WHEN quick_check GLOB 'CHECK*'"
" THEN raise(ABORT,'CHECK constraint failed')"
- " WHEN quick_check GLOB 'NULL*'"
- " THEN raise(ABORT,'NOT NULL constraint failed')"
+ " ELSE raise(ABORT,'NOT NULL constraint failed')"
" END"
- " FROM pragma_quick_check(\"%w\",\"%w\")",
+ " FROM pragma_quick_check(\"%w\",\"%w\")"
+ " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
zTab, zDb
);
}
diff --git a/src/build.c b/src/build.c
index c1dea15aa..4eca21a3f 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1769,7 +1769,6 @@ void sqlite3AddCheckConstraint(
}else
#endif
{
- pParse->bDiscardCheck = 1;
sqlite3ExprDelete(pParse->db, pCheckExpr);
}
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 420698830..651116aa9 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3437,8 +3437,7 @@ struct Parse {
Vdbe *pVdbe; /* An engine for executing database bytecode */
int rc; /* Return code from execution */
u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */
- u8 checkSchema : 1; /* Causes schema cookie check after an error */
- u8 bDiscardCheck :1; /* A CHECK constraint was discarded by the parser */
+ u8 checkSchema; /* Causes schema cookie check after an error */
u8 nested; /* Number of nested calls to the parser/code generator */
u8 nTempReg; /* Number of temporary registers in aTempReg[] */
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */