-
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: legacy schema changer handles add/drop constraint and validate c…
…onstraint in one stmt correctly Previously, CRDB has incompatible behavior when it comes to adding and validating constraints in one statment. Consider ``` 1. ALTER TABLE .. ADD CONSTRAINT .. [NOT VALID], VALIDATE CONSTRAINT ..; 2. ALTER TABLE .. DROP CONSTRAINT .. [NOT VALID], VALIDATE CONSTRAINT ..; ``` This PR ensures 1. The VALIDATE CONSTRAINT is either a no-op (for vanilla constraint) or validates the newly added constraint (for not-valid constraint) 2. The VALIDATE CONSTRAINT errors with a Constraint-Not-Found error. This is consistent with PG's behavior. This also result in behavior changes in schema changes in txns. E.g. ``` BEGIN; ALTER TABLE .. ADD CONSTRAINT .. [NOT VALID] Or ALTER TABLE .. DROP CONSTRAINT .. [NOT VALID] ALTER TABLE .. VALIDATE CONSTRAINT .. COMMIT; ``` The VALIDATE CONSTRAINT will have the same behavior here as above. This is also consistent with PG's behavior. Release note (bug fix): Fixed bugs for `ALTER TABLE .. ADD/DROP CONSTRAINT ..; VALIDATE CONSTRAINT ..` so that its behavior is consistent with PG.
- Loading branch information
Showing
6 changed files
with
62 additions
and
21 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