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

WIP: Support constraints for ALTER COLUMN TYPE #48516

Conversation

RichardJCai
Copy link
Contributor

@RichardJCai RichardJCai commented May 7, 2020

Depends on #46933
Fixes #48288

Support altering data type of a column that has check constraints. Rewrite constraints to support the new data type of the column.In a check constraint, any binary expression that contains the column will have the opposite side casted to the type of the column.

Example: Given column x INT with check constraint (x > 5) if x is changed to a FLOAT, the new constraint will be (x > 5::FLOAT).

Right now, the DFS naively checks if a BinaryExpr/ComparisonExpr is contains the column and casts the opposite side to the cast. Furthermore if either the Left or Right Expr of a BinaryExpr/Comparison was changed, the opposite side is casted as well.

Enable experimental ALTER COLUMN TYPE general using SET enable_experimental_alter_column_type_general = true;

Release note (sql change): Support for ALTER COLUMN TYPE online schema change for changing a column type's data.
Enable experimental ALTER COLUMN TYPE general using SET enable_experimental_alter_column_type_general = true;

Release note (sql change): Support for ALTER COLUMN TYPE online schema change for changing a column type's data.
Rewrite constraints to support the new data type of the column.
In a check constraint, any binary expression that contains the column will have the opposite side casted to the type of the column.
Example: Given column x INT with check constraint (x > 5) if x is changed to a FLOAT, the new constraint will be (x > 5::FLOAT).
@cockroach-teamcity
Copy link
Member

This change is Reviewable

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.

sql: ALTER COLUMN TYPE general for column that has a check constraint not supported.
2 participants