-
Notifications
You must be signed in to change notification settings - Fork 472
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
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.
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 |
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.
nit: For example:
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.
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. |
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.
spelling: constaint
> constraint
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.
Done
v2.0/drop-column.md
Outdated
@@ -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. | |
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.
Same as above.
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.
Done
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}} |
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.
This should link to the github issue where progress is tracked.
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.
I found #8773 but can't find the specific issue for CHECK constraint. Do you know what issue is used to track this?
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.
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.
👍 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. |
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.
all column-level Check constraints -> all column-level CHECK
constraints
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.
Done
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}} |
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.
@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.
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.
Ok, thanks for clarifying. I updated this bullet point for 2.0 and 1.1
Thanks, LGTM |
Closes #2391.