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

ADD CONSTRAINT Doc Update #4681

Closed
andreimatei opened this issue Apr 23, 2019 · 2 comments
Closed

ADD CONSTRAINT Doc Update #4681

andreimatei opened this issue Apr 23, 2019 · 2 comments
Assignees
Labels
P-2 Normal priority; secondary task

Comments

@andreimatei
Copy link
Contributor

Re: ADD CONSTRAINT

This page should link to the validate constraint page: https://www.cockroachlabs.com/docs/stable/validate-constraint.html

and the relationship between the two should be explained - do all constraints added after the table has been created need to be explicitly validated? Postgres seems to have a not valid clause for add constraint that defers the validation, but we don't seem to support that, do we?

@rmloveland rmloveland self-assigned this Apr 24, 2019
@rmloveland rmloveland added A-sql P-2 Normal priority; secondary task labels Apr 24, 2019
@thoszhang
Copy link

To answer the above questions (I have skimmed the existing docs, but have not read them thoroughly):

do all constraints added after the table has been created need to be explicitly validated?

In 2.1, yes. In 19.1, this is still true for foreign keys, but not true for check constraints. @rmloveland has already updated the ADD CONSTRAINT docs to reflect the change for check constraints, so I'm not sure if anything further needs to be done here (we had a customer question from someone who was presumably reading the 2.1 docs).

Postgres seems to have a not valid clause for add constraint that defers the validation, but we don't seem to support that, do we?

Right, we don't yet support NOT VALID. Roughly speaking, as of 19.1, check constraints behave like the default in postgres, and foreign key constraints behave as with NOT VALID in postgres. Of course, the goal is to support both cases for both types of constraints. I filed an issue a while ago to track this: cockroachdb/cockroach#33551

@rmloveland
Copy link
Contributor

Thanks for filing this Andrei, and thanks Lucy for clarifying things.

we don't yet support NOT VALID. Roughly speaking, as of 19.1, check constraints behave like the default in postgres, and foreign key constraints behave as with NOT VALID in postgres. Of course, the goal is to support both cases for both types of constraints. I filed an issue a while ago to track this: cockroachdb/cockroach#33551

It looks like cockroachdb/cockroach#33551 is now in, and as Lucy says the CHECK constraint portion is already documented.

We will be tracking the work to update the foreign key docs with the NOT VALID change via #5187. Therefore I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-2 Normal priority; secondary task
Projects
None yet
Development

No branches or pull requests

4 participants