cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

sql: ALTER TABLE ... ADD CONSTRAINT should validate existing rows

Open thoszhang opened this issue 7 years ago • 1 comments

Currently, check constraints and FK constraints are added in the Unvalidated state and not assumed to hold for existing rows in the table. Constraints can be validated later using VALIDATE CONSTRAINT. The preferable behavior would be to validate the new constraint on existing rows (asynchronously, after the transaction has committed). This would match the default behavior in Postgres, which also validates the existing rows up front (unless otherwise specified, using NOT VALID).

#32504 (not yet merged) implements this change for adding a check constraint. The plan is to handle FK constraints similarly.

thoszhang avatar Jan 07 '19 19:01 thoszhang

Closing in favor of #34238 which is tracking all related work.

thoszhang avatar Feb 26 '19 19:02 thoszhang