sql: drop and add constraint with same name in one statement #96831
Labels
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
T-sql-foundations
SQL Foundations Team (formerly SQL Schema + SQL Sessions)
The following problem exists in legacy schema changer:
Setup:
Troubled Stmt:
(The first easy-to-fix error is the ADD CONSTRAINT will complain that the name "check_i" is already used. This is easily fixed by adding some logic in
alter_table.go:validateConstraintNameIsNotUsed
)After that, it still errors with the
VALIDATE CONSTRAINT
clause saying "constraint check_i does not exist". The root cause is that we deduplicated when we build the constraint cache so thatcatalog.FindConstraintByName
in VALIDATE CONSTRAINT will see the dropping constraint check_i, and fail to realize there is another adding constraint (with the same name).I don't have an idea on how to fix it elegantly, and it's probably not worth it since this can be beautifully handled in the declarative schema changer, but I still open this issue for tracking.
Jira issue: CRDB-24354
The text was updated successfully, but these errors were encountered: