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

opt: assignment casts of non-equivalent types in DEFAULT and ON UPDATE #81863

Merged
merged 1 commit into from
May 26, 2022

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented May 25, 2022

This commit allows the optimizer to build assignment casts for DEFAULT
and ON UPDATE expressions that have types that are not equivalent with
their column's type. If the cast from the DEFAULT or ON UPDATE
expression type to the column type is not a valid assignment cast, an
error is returned. In practice, this error should never occur because 1)
it is currently impossible to create DEFAULT and ON UPDATE
expressions that do not match their column's type (the tests here get
around this limitation because they use the optimizer test catalog which
has much looser restrictions) and 2) a future PR will allow creating
DEFAULT and ON UPDATE expressions that do not match their column's
type only if the cast from the expression type to the column type is a
valid assignment cast.

Unblocks #81071

Release note: None

@mgartner mgartner requested a review from a team as a code owner May 25, 2022 21:39
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit allows the optimizer to build assignment casts for `DEFAULT`
and `ON UPDATE` expressions that have types that are not equivalent with
their column's type. If the cast from the `DEFAULT` or `ON UPDATE`
expression type to the column type is not a valid assignment cast, an
error is returned. In practice, this error should never occur because 1)
it is currently impossible to create `DEFAULT` and `ON UPDATE`
expressions that do not match their column's type (the tests here get
around this limitation because they use the optimizer test catalog which
has much looser restrictions) and 2) a future PR will allow creating
`DEFAULT` and `ON UPDATE` expressions that do not match their column's
type only if the cast from the expression type to the column type is a
valid assignment cast.

Unblocks cockroachdb#81071

Release note: None
Copy link
Contributor

@msirek msirek left a comment

Choose a reason for hiding this comment

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

Great usability improvement!
:lgtm:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @e-mbrown and @michae2)

@mgartner
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented May 26, 2022

Build succeeded:

@craig craig bot merged commit c50a68a into cockroachdb:master May 26, 2022
@mgartner mgartner deleted the allow-assignment-casts branch May 26, 2022 15:17
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.

None yet

3 participants