Skip to content

optbuilder: reset annotations when building CREATE FUNCTION#105581

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:reset-annotations-create-function
Jun 27, 2023
Merged

optbuilder: reset annotations when building CREATE FUNCTION#105581
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:reset-annotations-create-function

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Jun 26, 2023

In 22dabb0 we started overriding the annotations for each statement in the UDF body. We should reset them to the original values, so we don't accidentally leave the old reference.

Epic: None
Release note: None

@rafiss rafiss requested a review from DrewKimball June 26, 2023 21:07
@rafiss rafiss requested a review from a team as a code owner June 26, 2023 21:07
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jun 26, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/opt/optbuilder/create_function.go line 61 at r1 (raw file):

		b.qualifyDataSourceNamesInAST = false
		b.evalCtx.Annotations = oldEvalCtxAnn
		b.semaCtx.Annotations = oldSemaCtxAnn

Is this not handled by the defer here?

Copy link
Copy Markdown
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

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


pkg/sql/opt/optbuilder/create_function.go line 61 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

Is this not handled by the defer here?

i was thinking about it more, and i thought we should set it at the end of the loop in case, since it's possible something could use b after the loop ends, but before the function returns.

Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/opt/optbuilder/create_function.go line 61 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

i was thinking about it more, and i thought we should set it at the end of the loop in case, since it's possible something could use b after the loop ends, but before the function returns.

I see, SGTM.

In 22dabb0 we started overriding the annotations for each statement
in the UDF body. We should reset them to the original values, so we
don't accidentally leave the old reference.

Release note: None
@rafiss rafiss force-pushed the reset-annotations-create-function branch from 3bfae5d to d66290a Compare June 27, 2023 14:09
@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Jun 27, 2023

tftr!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 27, 2023

Build succeeded:

@craig craig bot merged commit 45be076 into cockroachdb:master Jun 27, 2023
@rafiss rafiss deleted the reset-annotations-create-function branch June 27, 2023 15:04
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