release-24.1: sql/schemachanger: fix nil pointer preparing a schema changer statement #147668
+20
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #147658 on behalf of @fqazi.
Previously, the code to track if a plan was using the declarative or legacy schema changer updated the instrumentation based on curPlan. This worked correctly if a previous statement was executed and the instrumentation was set up on that plan. However, if a PREPARE is the first statement on a connection, this breaks. To address this, this patch updates the planner's instrumentation to track if a statement is a declarative schema change.
Fixes: #146907
Informs: #147271
Fixes: #147256
Informs: #147251
Fixes: #145305
Release note (bug fix): Prepare statements on schema changes could fail with runtime errors.
Release justification: low risk fix for a bug that can cause PREPARE statements with schema changes to hit runtime errors.