Skip to content
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 that constraints are now eagerly validated #7730

Closed
SpicyThrow opened this issue Jul 10, 2020 · 4 comments
Closed

Document that constraints are now eagerly validated #7730

SpicyThrow opened this issue Jul 10, 2020 · 4 comments
Assignees

Comments

@SpicyThrow
Copy link
Contributor

Re: ADD CONSTRAINT

Issue Description

In the notes section of the add foreign key constraint, it should be noted that the database validates the foreign key constraint when it's added. There's no sign that this is happening when one does this and it's good to know the validation is happening.

Suggested Resolution

@jseldess
Copy link
Contributor

Thanks, @SpicyThrow. There might be other places where we should explain that we eagerly validate existing data at the time a constraint is applied as well. The exception is if the constraint is added with the NOT VALID clause. In that case, the user must use the VALIDATE CONSTRAINT statement to check.

We should update the VALIDATE CONSTRAINT docs to also mention that we eagerly validate constraints but that the statement is still useful when a constraint is added with NOT VALID.

@jseldess jseldess changed the title update notes on foreign keys in ADD CONSTRAINT Doc Update Document that constraints are now eagerly validated Jul 10, 2020
@jseldess
Copy link
Contributor

Looks like NOT VALID still needs to be documented as well: #5187.

@ajwerner
Copy link
Contributor

I stumbled into this recently. It's definitely confusing. I'd start by changing a few words in the following example and having it create the constraint NOT VALID.

https://www.cockroachlabs.com/docs/v21.1/validate-constraint#examples

@jseldess
Copy link
Contributor

Thanks, @ajwerner. This is a known gap. I started a PR a long, long time ago and then let that go state. @ericharmeling is on it now. Closing in favor of #5187.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants