-
Notifications
You must be signed in to change notification settings - Fork 689
Implement CASCADE behavior enforcement for FOREIGN KEY constraints #2337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
a88fabe
6db5c31
a16cfef
f1b0751
d668f43
b53bc38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like way too much code for this problem. Are you sure this is the best way to do it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ~200 lines in UPDATE handle all CASCADE actions for primary key changes, including pre-validation for RESTRICT, NOT NULL constraint checking, and tracking which columns are being updated to avoid unnecessary cascade operations. This is the minimum needed to properly implement SQL-99 CASCADE standard for UPDATE operations. Commit b53bc38 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a lot of code. Are you sure this is the best way to solve this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the minimum code needed for SQL-standard CASCADE behavior. The ~90 lines handle all 5 CASCADE actions (CASCADE, SET NULL, SET DEFAULT, RESTRICT, NO ACTION) with recursive support for grandchild rows and NOT NULL validation. The core logic is in the
applyCascadeDeleteshelper function which is reused for both WHERE and non-WHERE deletes to avoid duplication.Commit b53bc38