-
Notifications
You must be signed in to change notification settings - Fork 464
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
Document auto-validation of foreign keys #5690
Conversation
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @jseldess and @lucy-zhang)
v19.2/validate-constraint.md, line 9 at r1 (raw file):
The `VALIDATE CONSTRAINT` [statement](sql-statements.html) is part of `ALTER TABLE` and checks whether values in a column match a [constraint](constraints.html) on the column. This statement is especially useful after applying a constraint to an existing column via [`ADD CONSTRAINT`](add-constraint.html). In this case, `VALIDATE CONSTRAINT` can be used to find values already in the column that do not match the constraint. <span class="version-tag">New in v19.2:</span> Applying a foreign key constraint via `ADD CONSTRANT` now validates existing rows in addition to enforcing conformance for new rows. As such, it is no longer necessary to use [`VALIDATE CONSTRAINT`](validate-constraint.html) for foreign keys.
CONSTRAINT
v19.2/validate-constraint.md, line 40 at r1 (raw file):
{% include copy-clipboard.html %} ~~~ sql > ALTER TABLE orders ADD CONSTRAINT check_id_non_zero CHECK (id > 0);
Check constraints are also validated when added. As of 19.2, the only reason to use VALIDATE CONSTRAINT
is to validate check/FK constraints that were added as NOT VALID
(or were added in an earlier version of Cockroach). The example as it existed before could still work with NOT VALID
.
(We didn't add full support for NOT VALID
until 19.2, so as far as I know there's no existing documentation for that.)
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @lucy-zhang)
v19.2/validate-constraint.md, line 9 at r1 (raw file):
Previously, lucy-zhang (Lucy Zhang) wrote…
CONSTRAINT
Done.
v19.2/validate-constraint.md, line 40 at r1 (raw file):
Previously, lucy-zhang (Lucy Zhang) wrote…
Check constraints are also validated when added. As of 19.2, the only reason to use
VALIDATE CONSTRAINT
is to validate check/FK constraints that were added asNOT VALID
(or were added in an earlier version of Cockroach). The example as it existed before could still work withNOT VALID
.(We didn't add full support for
NOT VALID
until 19.2, so as far as I know there's no existing documentation for that.)
Ah, ok. Then I should handle that change as part of this PR as well. I'll ping you when that's ready.
688e8b4
to
14e68c9
Compare
14e68c9
to
cda3ce4
Compare
@jseldess @lucy-zhang I updated the PR to include more information on unvalidated constraints. I will open a separate PR to fix the |
Online preview: http://cockroach-docs-review.s3-website-us-east-1.amazonaws.com/cda3ce4b00b5fbbbb5142a01f058d338f32ae06b/ Edited pages: |
cda3ce4
to
6d4f05c
Compare
Online preview: http://cockroach-docs-review.s3-website-us-east-1.amazonaws.com/6d4f05c79835e8e8b5642eeea3fabde6f3b840b6/ Edited pages: |
I will incorporate an updated diagram for add constraint (cockroachdb/cockroach#43087). I think I also need to do a bit more work on the 20.1 version - should I remove the "new in 19.2" in that version? |
6d4f05c
to
40c3ae0
Compare
Online preview: http://cockroach-docs-review.s3-website-us-east-1.amazonaws.com/40c3ae044ab1f22bc2a49bf08491d68ca76298fa/ Edited pages: |
@ericharmeling, I'll close this, since I expect you'll want a clean start on #5187 and #4891. |
Fixes #4891.
Fixes #5187.