Add asserts as evidence that all FK constraints are either immediate or
deferred.
FossilOrigin-Name: 634ef4fc9f4051245b38f558bb1c733031548c2f
diff --git a/src/build.c b/src/build.c
index 215b3c0..7b0ea04b 100644
--- a/src/build.c
+++ b/src/build.c
@@ -2267,7 +2267,7 @@
Table *pTab;
FKey *pFKey;
if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
- assert( isDeferred==0 || isDeferred==1 );
+ assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */
pFKey->isDeferred = (u8)isDeferred;
#endif
}
diff --git a/src/fkey.c b/src/fkey.c
index 55d0a4f..8af7ea9 100644
--- a/src/fkey.c
+++ b/src/fkey.c
@@ -1178,7 +1178,11 @@
fkTriggerDelete(pTab->dbMem, pFKey->apTrigger[1]);
#endif
- /* Delete the memory allocated for the FK structure. */
+ /* EV: R-30323-21917 Each foreign key constraint in SQLite is
+ ** classified as either immediate or deferred.
+ */
+ assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );
+
pNext = pFKey->pNextFrom;
sqlite3DbFree(pTab->dbMem, pFKey);
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 03ff1be..2675f44 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -1289,6 +1289,7 @@
FKey *pNextTo; /* Next foreign key on table named zTo */
FKey *pPrevTo; /* Previous foreign key on table named zTo */
int nCol; /* Number of columns in this key */
+ /* EV: R-30323-21917 */
u8 isDeferred; /* True if constraint checking is deferred till COMMIT */
u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */
Trigger *apTrigger[2]; /* Triggers for aAction[] actions */