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: fix recently introduced minor bug around PREPARE #108461

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

yuzefovich
Copy link
Member

In just merged 4a3e787, we had a minor bug that in case addPreparedStmt call fails, we don't restore the original placeholders, which can then lead to panics.

Fixes: #108421.

Release note: None

@yuzefovich yuzefovich requested a review from rafiss August 9, 2023 17:26
@blathers-crl
Copy link

blathers-crl bot commented Aug 9, 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

@@ -903,6 +903,9 @@ func (ex *connExecutor) execStmtInOpenState(
// PREPARE statement itself.
oldPlaceholders := p.extendedEvalCtx.Placeholders
p.extendedEvalCtx.Placeholders = nil
defer func() {
p.extendedEvalCtx.Placeholders = oldPlaceholders
Copy link
Collaborator

Choose a reason for hiding this comment

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

ty for fixing this! i think we could also put this into the defer:

// The call to addPreparedStmt changed the planner stmt to the statement
// being prepared. Set it back to the PREPARE statement, so that it's
// logged correctly.
p.stmt = stmt

In just merged 4a3e787, we had a minor
bug that in case `addPreparedStmt` call fails, we don't restore the
original placeholders, which can then lead to panics.

Release note: None
Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

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


pkg/sql/conn_executor_exec.go line 907 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

ty for fixing this! i think we could also put this into the defer:

// The call to addPreparedStmt changed the planner stmt to the statement
// being prepared. Set it back to the PREPARE statement, so that it's
// logged correctly.
p.stmt = stmt

Done.

@craig
Copy link
Contributor

craig bot commented Aug 9, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 9, 2023

Build succeeded:

@craig craig bot merged commit a7f0434 into cockroachdb:master Aug 9, 2023
@yuzefovich yuzefovich deleted the prepare-fix branch August 9, 2023 20:51
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.

logictest: TestLogic_prepare with high vmodule failed
3 participants