Skip to content

Commit e35bddb

Browse files
craig[bot]mw5h
andcommitted
Merge #144603
144603: tree: fix a test that wasn't seeing the error that it should have r=mw5h a=mw5h An astute reviewer noted that the builtin_function logic test had a PREPARE with no EXECUTE and asked if that was intentional. It turns out that it was, but the PREPARE was expected to fail! After some investigation, it was discovered that resetting use_pre_25_2_variadic_builtins was not causing CONCAT to return to the normal 25.2 behavior, which would be to error. After some poking, I discovered that the second PREPARE was not being planned at all because it was hitting the query plan cache. Flushing the plan cache in the test caused the test to correctly error. Epic: none Co-authored-by: Matt White <[email protected]>
2 parents 97d75b3 + b3dde43 commit e35bddb

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

pkg/sql/logictest/testdata/logic_test/builtin_function

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ EXECUTE concat_stmt2(':')
223223
statement ok
224224
RESET use_pre_25_2_variadic_builtins
225225

226-
statement ok
226+
statement error pgcode 42P18 pq: concat\(\): error type checking resolved expression:: could not determine data type of placeholder \$1
227227
PREPARE concat_stmt3 AS SELECT concat("foo"."a", $1) FROM foo
228228

229229
query T

pkg/sql/opt/memo/memo.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ type Memo struct {
205205
planLookupJoinsWithReverseScans bool
206206
useInsertFastPath bool
207207
internal bool
208+
usePre_25_2VariadicBuiltins bool
208209

209210
// txnIsoLevel is the isolation level under which the plan was created. This
210211
// affects the planning of some locking operations, so it must be included in
@@ -307,6 +308,7 @@ func (m *Memo) Init(ctx context.Context, evalCtx *eval.Context) {
307308
planLookupJoinsWithReverseScans: evalCtx.SessionData().OptimizerPlanLookupJoinsWithReverseScans,
308309
useInsertFastPath: evalCtx.SessionData().InsertFastPath,
309310
internal: evalCtx.SessionData().Internal,
311+
usePre_25_2VariadicBuiltins: evalCtx.SessionData().UsePre_25_2VariadicBuiltins,
310312
txnIsoLevel: evalCtx.TxnIsoLevel,
311313
}
312314
m.metadata.Init()
@@ -482,6 +484,7 @@ func (m *Memo) IsStale(
482484
m.planLookupJoinsWithReverseScans != evalCtx.SessionData().OptimizerPlanLookupJoinsWithReverseScans ||
483485
m.useInsertFastPath != evalCtx.SessionData().InsertFastPath ||
484486
m.internal != evalCtx.SessionData().Internal ||
487+
m.usePre_25_2VariadicBuiltins != evalCtx.SessionData().UsePre_25_2VariadicBuiltins ||
485488
m.txnIsoLevel != evalCtx.TxnIsoLevel {
486489
return true, nil
487490
}

pkg/sql/opt/memo/memo_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,11 @@ func TestMemoIsStale(t *testing.T) {
569569
evalCtx.SessionData().Internal = false
570570
notStale()
571571

572+
evalCtx.SessionData().UsePre_25_2VariadicBuiltins = true
573+
stale()
574+
evalCtx.SessionData().UsePre_25_2VariadicBuiltins = false
575+
notStale()
576+
572577
// User no longer has access to view.
573578
catalog.View(tree.NewTableNameWithSchema("t", catconstants.PublicSchemaName, "abcview")).Revoked = true
574579
_, err = o.Memo().IsStale(ctx, &evalCtx, catalog)

pkg/sql/sem/tree/type_check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type SemaContext struct {
7575
// supported by the current cluster version. It may be unset.
7676
UnsupportedTypeChecker UnsupportedTypeChecker
7777

78-
// UsePre25_2VariadicBuiltins is set to true when we should use the pre-25.2
78+
// UsePre_25_2VariadicBuiltins is set to true when we should use the pre-25.2
7979
// variadic builtins behavior.
8080
UsePre_25_2VariadicBuiltins bool
8181
}

0 commit comments

Comments
 (0)