1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Use the affinity and collation sequence associated with the parent key when finding child table rows to apply a foreign key action to.

FossilOrigin-Name: 9a4b7ec2928307e88783223903c842accaff7ccf
This commit is contained in:
dan
2009-09-29 16:38:59 +00:00
parent 9707c7b104
commit 652ac1d0a7
4 changed files with 58 additions and 14 deletions

View File

@@ -952,13 +952,16 @@ static Trigger *fkActionTrigger(
tToCol.n = sqlite3Strlen30(tToCol.z);
tFromCol.n = sqlite3Strlen30(tFromCol.z);
/* Create the expression "zFromCol = OLD.zToCol" */
/* Create the expression "OLD.zToCol = zFromCol". It is important
** that the "OLD.zToCol" term is on the LHS of the = operator, so
** that the affinity and collation sequence associated with the
** parent table are used for the comparison. */
pEq = sqlite3PExpr(pParse, TK_EQ,
sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol),
sqlite3PExpr(pParse, TK_DOT,
sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
, 0)
, 0),
sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
, 0);
pWhere = sqlite3ExprAnd(db, pWhere, pEq);