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

tree: make SET TRANSACTION a walkable statement #113689

Merged
merged 1 commit into from Nov 14, 2023

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Nov 2, 2023

SET TRANSACTION is now a walkable statement. This fixes a bug where
placeholders in a SET TRANSACTION statement were not resolved correctly.

The statement must be walkable for the placeholderAnnotationVisitor to
work correctly -- it is an AST visitor that relies on walkStmt to
discover all placeholders in a statement.

func ProcessPlaceholderAnnotations(
semaCtx *SemaContext, stmt Statement, typeHints PlaceholderTypes,
) error {
v := placeholderAnnotationVisitor{
types: typeHints,
state: make([]annotationState, len(typeHints)),
ctx: semaCtx,
}
for placeholder := range typeHints {
if typeHints[placeholder] != nil {
v.state[placeholder] = typeFromHint
}
}
walkStmt(&v, stmt)
return v.err
}

Epic: None
Release note (bug fix): Placeholder arguments can now be used in SET TRANSACTION statements.

@rafiss rafiss requested review from bdarnell and a team November 2, 2023 17:22
@rafiss rafiss requested a review from a team as a code owner November 2, 2023 17:22
Copy link

blathers-crl bot commented Nov 2, 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
Member

This change is Reviewable

Copy link
Contributor

@chrisseto chrisseto left a comment

Choose a reason for hiding this comment

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

Change LGTM but I don't really see how this fixes the bug. Is there an issue to reference or maybe a quick example that could be added to the commit message?

@rafiss
Copy link
Collaborator Author

rafiss commented Nov 14, 2023

I think the test I added is the example I had in mind. it allows the SET TRANSACTION statement to be prepared with a placeholder, but before this change, that test would fail.

what else would you like to see?

SET TRANSACTION is now a walkable statement. This fixes a bug where
placeholders in a SET TRANSACTION statement were not resolved correctly.

The statement must be walkable for the placeholderAnnotationVisitor to
work correctly -- it is an AST visitor that relies on walkStmt to
discover all placeholders in a statement.

Release note (bug fix): Placeholder arguments can now be used in SET
TRANSACTION statements.
@rafiss
Copy link
Collaborator Author

rafiss commented Nov 14, 2023

I have added a code reference to the commit message.

Copy link
Contributor

@chrisseto chrisseto left a comment

Choose a reason for hiding this comment

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

Perfect, thanks for the clarification! :lgtm:

@rafiss
Copy link
Collaborator Author

rafiss commented Nov 14, 2023

tftr!

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 14, 2023

Build failed:

@rafiss
Copy link
Collaborator Author

rafiss commented Nov 14, 2023

bors r+

@craig craig bot merged commit 65667e9 into cockroachdb:master Nov 14, 2023
6 of 8 checks passed
@craig
Copy link
Contributor

craig bot commented Nov 14, 2023

Build succeeded:

@rafiss rafiss deleted the fix-set-txn-aost branch November 14, 2023 22:39
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