Skip to content

Commit

Permalink
Merge #138025
Browse files Browse the repository at this point in the history
138025: sql: make annotations for planner used in backfillQueryIntoTable r=yuzefovich a=yuzefovich

We use an internal planner in `backfillQueryIntoTable`, and previously we forgot to create annotations in that code path, which could lead to an internal error in edge cases. Annotations are needed when performing object resolution, and I'm guessing that other places where we use the planner don't need them.

Fixes: #137631.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Jan 4, 2025
2 parents 848f485 + 8847382 commit d6ffb8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/create_as
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,13 @@ query B
SELECT count(*) > 0 FROM t_105887_2
----
true

# Regression test for not setting the Annotations on the planner (#137631).
statement ok
SET experimental_enable_temp_tables = 'on';

statement ok
CREATE TABLE v00 (c01 INT, c02 STRING);

statement ok
CREATE TEMP TABLE v300 AS ( ( TABLE [ SHOW EXPERIMENTAL_FINGERPRINTS FROM TABLE v00 ] ) ) ;
1 change: 1 addition & 0 deletions pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func (sc *SchemaChanger) backfillQueryIntoTable(
return err
}

localPlanner.MaybeReallocateAnnotations(stmt.NumAnnotations)
// Construct an optimized logical plan of the AS source stmt.
localPlanner.stmt = makeStatement(stmt, clusterunique.ID{}, /* queryID */
tree.FmtFlags(queryFormattingForFingerprintsMask.Get(&localPlanner.execCfg.Settings.SV)))
Expand Down

0 comments on commit d6ffb8c

Please sign in to comment.