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

sql: add assignment casts for DEFAULT and computed columns for INSERTs #74093

Merged
merged 2 commits into from
Dec 21, 2021

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Dec 20, 2021

opt: do not add empty project when no assignment casts are necessary

This commit prevents optbuilder from building empty project expressions
when no assignment casts are necessary.

It also fixes a minor bug with the scope of assignment cast projections.
Rather than pushing a new scope onto mb.outScope for assignment casts,
it replaces mb.outScope with a new scope. This bug causes no
observable effect with the current assignment code-paths, but would
cause problems as more assignment cast support is added.

Release note: None

sql: add assignment casts for DEFAULT and computed columns for INSERTs

This commit adds assignment casts to INSERTS for DEFAULT and computed
column expressions when the type of the expression is not identical to
the column's type.

This change required removing tree.ReType from
scope.resolveAndRequireType, which causes a regression of the
update-col-cast-bug test. This will be fixed in a future commit when
assignment casts are added for UPDATEs.

Release note: None

@mgartner mgartner requested review from RaduBerinde, cucaroach and a team December 20, 2021 18:22
@mgartner mgartner requested a review from a team as a code owner December 20, 2021 18:22
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit prevents optbuilder from building empty project expressions
when no assignment casts are necessary.

It also fixes a minor bug with the scope of assignment cast projections.
Rather than pushing a new scope onto `mb.outScope` for assignment casts,
it replaces `mb.outScope` with a new scope. This bug causes no
observable effect with the current assignment code-paths, but would
cause problems as more assignment cast support is added.

Release note: None
This commit adds assignment casts to INSERTS for DEFAULT and computed
column expressions when the type of the expression is not identical to
the column's type.

This change required removing `tree.ReType` from
`scope.resolveAndRequireType`, which causes a regression of the
`update-col-cast-bug` test. This will be fixed in a future commit when
assignment casts are added for UPDATEs.

Release note: None
@mgartner mgartner force-pushed the default-assignment-cast branch from e2d3131 to 4c43010 Compare December 20, 2021 18:23
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @cucaroach)

@mgartner
Copy link
Collaborator Author

TFTR!!!

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 20, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 21, 2021

Build succeeded:

@craig craig bot merged commit d6dc05a into cockroachdb:master Dec 21, 2021
@mgartner mgartner deleted the default-assignment-cast branch December 21, 2021 15:46
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.

3 participants