Skip to content

drop CHECK when column is dropped #2638

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

Merged
merged 5 commits into from
Mar 9, 2018
Merged

drop CHECK when column is dropped #2638

merged 5 commits into from
Mar 9, 2018

Conversation

lnhsingh
Copy link
Contributor

@lnhsingh lnhsingh commented Mar 8, 2018

Closes #2391.

@lnhsingh lnhsingh requested a review from jseldess March 8, 2018 17:43
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@cockroach-teamcity
Copy link
Member

@cockroach-teamcity
Copy link
Member

Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with a few nites.

You should also get @knz to review, since he made this change in the product.

v2.0/check.md Outdated
- If you add a `CHECK` constraint to an existing table, existing values are not checked. However, any updates to those values will be.
{{site.data.alerts.callout_info}}In the future we plan to expand the `CHECK` constraint to include a check on any existing values in the column.{{site.data.alerts.end}}
- `CHECK` constraints may be specified at the column or table level and can reference other columns within the table. Internally, all column-level Check constraints are converted to table-level constraints so they can be handled consistently.
- You can have multiple `CHECK` constraints on a single column but ideally, for performance optimization, these should be combined using the logical operators. For example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: For example:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

v2.0/check.md Outdated
~~~ sql
warranty_period INT CHECK (warranty_period BETWEEN 0 AND 24)
~~~
- When a column with a `CHECK` constraint is dropped, the `CHECK` constaint is also dropped.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling: constaint > constraint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -21,7 +21,7 @@ The user must have the `CREATE` [privilege](privileges.html) on the table.
| Parameter | Description |
|-----------|-------------|
| `table_name` | The name of the table with the column you want to drop. |
| `name` | The name of the column you want to drop. |
| `name` | The name of the column you want to drop.<br><br>When a column with a `CHECK` constraint is dropped, the `CHECK` constaint is also dropped. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@lnhsingh lnhsingh requested a review from knz March 8, 2018 22:35
@cockroach-teamcity
Copy link
Member

v2.0/check.md Outdated
- Check constraints may be specified at the column or table level and can reference other columns within the table. Internally, all column-level Check constraints are converted to table-level constraints so they can be handled consistently.
- You can have multiple Check constraints on a single column but ideally, for performance optimization, these should be combined using the logical operators. For example
- If you add a `CHECK` constraint to an existing table, existing values are not checked. However, any updates to those values will be.
{{site.data.alerts.callout_info}}In the future we plan to expand the `CHECK` constraint to include a check on any existing values in the column.{{site.data.alerts.end}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should link to the github issue where progress is tracked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found #8773 but can't find the specific issue for CHECK constraint. Do you know what issue is used to track this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks!

v2.0/check.md Outdated
- You can have multiple Check constraints on a single column but ideally, for performance optimization, these should be combined using the logical operators. For example
- If you add a `CHECK` constraint to an existing table, existing values are not checked. However, any updates to those values will be.
{{site.data.alerts.callout_info}}In the future we plan to expand the `CHECK` constraint to include a check on any existing values in the column.{{site.data.alerts.end}}
- `CHECK` constraints may be specified at the column or table level and can reference other columns within the table. Internally, all column-level Check constraints are converted to table-level constraints so they can be handled consistently.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all column-level Check constraints -> all column-level CHECK constraints

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@cockroach-teamcity
Copy link
Member

v2.0/check.md Outdated
- Check constraints may be specified at the column or table level and can reference other columns within the table. Internally, all column-level Check constraints are converted to table-level constraints so they can be handled consistently.
- You can have multiple Check constraints on a single column but ideally, for performance optimization, these should be combined using the logical operators. For example
- If you add a `CHECK` constraint to an existing table, existing values are not checked. However, any updates to those values will be.
{{site.data.alerts.callout_info}}In the future we plan to [expand the `CHECK` constraint](https://github.com/cockroachdb/cockroach/issues/23663) to include a check on any existing values in the column.{{site.data.alerts.end}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dt just pointed out this point (and the callout) are plainly wrong. This limitation was lifted in cockroachdb 1.1.
(in cockroachdb/cockroach#9152 )
One needs to use VALIDATE to check the previous rows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for clarifying. I updated this bullet point for 2.0 and 1.1

@cockroach-teamcity
Copy link
Member

@knz
Copy link
Contributor

knz commented Mar 9, 2018

Thanks, LGTM

@jseldess jseldess merged commit 4d070ef into master Mar 9, 2018
@jseldess jseldess deleted the fixit-check branch March 9, 2018 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants