-
Notifications
You must be signed in to change notification settings - Fork 4k
release-25.2.1-rc: sql: do not rewrite UDF body statement slice while assigning placeholders #147468
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
release-25.2.1-rc: sql: do not rewrite UDF body statement slice while assigning placeholders #147468
Conversation
…ders Previously, we accidentally modified the original slice that contains the body statements of a UDF while copying it during the placeholder assignment step. As a result, constant folding that occurred in one session could become visible in the query plan cache, causing incorrect results. This commit fixes the bug by copying the slice as well as the body statements. This bug only applied to prepared statements, since we don't add plans with stable expressions to the plan cache outside of the prepare path. Fixes cockroachdb#147186 Release note (bug fix): Fixed a bug that could cause stable expressions to be folded in cached query plans. The bug could cause stable expressions like `current_setting` to return the wrong result if used in a prepared statement. The bug was introduced in point releases v23.2.22, v24.1.14, v24.3.9, and v25.1.2, and the v25.2 alpha.
|
Thanks for opening a backport. Please check the backport criteria before merging:
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
Also, please add a brief release justification to the body of your PR to justify this |
michae2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)
Backport 1/1 commits from #147187.
/cc @cockroachdb/release
Previously, we accidentally modified the original slice that contains the body statements of a UDF while copying it during the placeholder assignment step. As a result, constant folding that occurred in one session could become visible in the query plan cache, causing incorrect results. This commit fixes the bug by copying the slice as well as the body statements.
This bug only applied to prepared statements, since we don't add plans with stable expressions to the plan cache outside of the prepare path.
Fixes #147186
Release note (bug fix): Fixed a bug that could cause stable expressions to be folded in cached query plans. The bug could cause stable expressions like
current_settingto return the wrong result if used in a prepared statement. The bug was introduced in point releases v23.2.22, v24.1.14, v24.3.9, and v25.1.2, and the v25.2 alpha.Release justification: critical fix for bug introduced in earlier backport.