-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: allow cascading action when default is set implicitly to null
Add support for implicitly setting the default value of a column to null, for cascading tables for both ON DELETE and ON UPDATE. Previously, if a user set a reference to a column and added a SET DEFAULT for an ON DELETE/UPDATE cascading action, without an explicit default expression, CRDB would forbid it. Postgres does not distinguish between SET NULL and the absence of a default expression. Thus, the change is to also have CRDB not distinguish between the two cases. In the situation where a user creates a table with an explicit default null via SET NULL, CRDB does not allow the user to create the table at all. This deviates from how postgres handles it. Postgres allows the user to create the table but throws an error if a cascading action occurs that uses the default value. The new changes now prevent the user from creating a table when they constrain the columns to be non-nullable, and implicitly set the default to NULL. This is done to match the behavior for the explicit case of setting the default to NULL. Resolves: #38975 Release note (sql change): Columns without an explicit default value now support foreign keys with the SET DEFAULT action, in the same way as the SET NULL and SET DEFAULT NULL cases.
- Loading branch information
Tyler314
committed
Aug 6, 2019
1 parent
fbf3a6d
commit 0af26a0
Showing
7 changed files
with
153 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters