Skip to content
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-23.1: sql: fix crdb_internal.encode_key in some contexts #107603

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pkg/sql/create_as_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ func TestCreateAsShow(t *testing.T) {
{
sql: "SHOW RANGE FROM TABLE show_ranges_tbl FOR ROW (0)",
setup: "CREATE TABLE show_ranges_tbl (id int PRIMARY KEY)",
// TODO(sql-foundations): Fix `invalid memory address or nil pointer dereference` error in job.
// See https://github.com/cockroachdb/cockroach/issues/106397.
skip: true,
},
{
sql: "SHOW SURVIVAL GOAL FROM DATABASE",
Expand Down
8 changes: 8 additions & 0 deletions pkg/sql/delegate/show_range_for_row.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ func (d *delegator) delegateShowRangeForRow(n *tree.ShowRangeForRow) (tree.State
if idx.Table().IsVirtualTable() {
return nil, errors.New("SHOW RANGE FOR ROW may not be called on a virtual table")
}
// Use qualifyDataSourceNamesInAST similarly to the Builder so that
// CREATE TABLE AS can source from a delegated expression.
// For example: CREATE TABLE t2 AS SELECT * FROM [SHOW RANGE FROM TABLE t1 FOR ROW (0)];
if d.qualifyDataSourceNamesInAST {
resName.ExplicitSchema = true
resName.ExplicitCatalog = true
(n.TableOrIndex).Table = resName.ToUnresolvedObjectName().ToTableName()
}
span := idx.Span()
table := idx.Table()
idxSpanStart := hex.EncodeToString(span.Key)
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ func newInternalPlanner(
p.schemaResolver.txn = p.txn
p.schemaResolver.authAccessor = p
p.evalCatalogBuiltins.Init(execCfg.Codec, p.txn, p.Descriptors())
p.extendedEvalCtx.CatalogBuiltins = &p.evalCatalogBuiltins

return p, func() {
// Note that we capture ctx here. This is only valid as long as we create
Expand Down