8000 sql: ALTER COLUMN TYPE general for column that has a check constraint not supported. · Issue #48288 · cockroachdb/cockroach · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
sql: ALTER COLUMN TYPE general for column that has a check constraint not supported. #48288
Open
@RichardJCai

Description

@RichardJCai

Currently, ALTER COLUMN TYPE for a column that has a check constraint is not supported.

Steps to implement:

  1. On creation of new column, copy constraints and create constraint for new column. Each comparison to the column has to be casted to the new type. Comparisons that have the column inside a nested expression must also be converted.
  2. Need to check if constraint is valid (aka casts are valid and comparisons can be done), otherwise fail schema change.
  3. After swapping the column, need to drop constraints for old column.
  4. Need to rename the constraints during/after the swap since we can't have duplicate constraint names if we want to keep the constraint name the same.

Example:
If the original column constraint was (x > 0),
after a cast to string, the new constraint should be (x > 0::string).

This is postgres behaviour.

Jira issue: CRDB-4338

Epic CRDB-44826

Metadata

Metadata

Assignees

Labels

A-schema-changesA-sql-pgcompatSemantic compatibility with PostgreSQLC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0