Skip to content

Commit

Permalink
opt: set opt tester search path to empty
Browse files Browse the repository at this point in the history
`OptTester` now sets its `SemaContext`'s `SearchPath` to
`EmptySearchPath`, instead of `nil`, to avoid nil pointer exceptions
when resolving unknown functions.

Release note: None
  • Loading branch information
mgartner committed Jul 25, 2022
1 parent 48ffa80 commit b138769
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/opt/optbuilder/testdata/udf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
SELECT foo()
----
error (42883): unknown function: foo()
1 change: 1 addition & 0 deletions pkg/sql/opt/testutils/opttester/opt_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ func New(catalog cat.Catalog, sql string) *OptTester {
semaCtx: tree.MakeSemaContext(),
evalCtx: eval.MakeTestingEvalContext(cluster.MakeTestingClusterSettings()),
}
ot.semaCtx.SearchPath = tree.EmptySearchPath
ot.semaCtx.FunctionResolver = ot.catalog
// To allow opttester tests to use now(), we hardcode a preset transaction
// time. May 10, 2017 is a historic day: the release date of CockroachDB 1.0.
Expand Down

0 comments on commit b138769

Please sign in to comment.