Skip to content

sql: fix crdb_internal.encode_key in some contexts#107512

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:catalog-builtins
Jul 26, 2023
Merged

sql: fix crdb_internal.encode_key in some contexts#107512
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:catalog-builtins

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich commented Jul 25, 2023

Previously, we forgot to set CatalogBuiltins for the internal planner which is used by crdb_internal.encode_key (which, in turn, is used to power SHOW RANGE ... FOR ROW), so evaluating it would lead to an error. For example, the internal planner is used in the backfill. This is now fixed.

Fixes: #106397.

Release note (bug fix): CockroachDB would previously return an error when using SHOW RANGE ... FOR ROW ... in CREATE TABLE ... AS ... construct, and this is now fixed.

@yuzefovich yuzefovich added the backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only label Jul 25, 2023
@yuzefovich yuzefovich requested review from a team, ecwall and mgartner July 25, 2023 01:03
@yuzefovich yuzefovich requested a review from a team as a code owner July 25, 2023 01:03
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@ecwall ecwall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I saw you are backporting to 23.1 - can it be backported to 22.2 also?

Copy link
Copy Markdown
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @yuzefovich)


pkg/sql/planner.go line 449 at r1 (raw file):

	p.extendedEvalCtx.Locality = execCfg.Locality
	p.extendedEvalCtx.OriginalLocality = execCfg.Locality
	p.extendedEvalCtx.CatalogBuiltins = &p.evalCatalogBuiltins

nit: We initialize p.evalCatalogBuiltins after this block. It's a bit of an anti-pattern, even if it currently works correctly.

@ecwall
Copy link
Copy Markdown
Contributor

ecwall commented Jul 25, 2023

You might need a fix similar to #107099 for the relation "show_ranges_tbl" does not exist CI error.

Previously, we forgot to set `CatalogBuiltins` for the internal planner
which is used by `crdb_internal.encode_key` (which, in turn, is used to
power `SHOW RANGE ... FOR ROW`), so evaluating it would lead to an error.
For example, the internal planner is used in the backfill. This is now
fixed.

Release note (bug fix): CockroachDB would previously return an error
when using `SHOW RANGE ... FOR ROW ...` in `CREATE TABLE ... AS ...`
construct, and this is now fixed.
Copy link
Copy Markdown
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer and the reviews!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 26, 2023

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: CREATE AS [SHOW RANGE FROM ... FOR ROW ...] job fails

4 participants