Skip to content

Conversation

@blathers-crl
Copy link

@blathers-crl blathers-crl bot commented Dec 24, 2025

Backport 1/1 commits from #159642 on behalf of @ZhouXing19.


Fixes #152233
Fixes #159145
Fixes #87475

Previously, if a function contains cast from a column to UDT in the body,
the SHOW CREATE TABLE statement for this function will error out. This
commit is to fix it.

Release note (bug fix): enable SHOW CREATE TABLE for function created with
columns casting to user defined types.


Release justification: fix a bug for a common usage of UDF

Fixes #152233
Fixes #159145
Fixes #87475

Previously, if a function contains cast from a column to UDT in the body,
the SHOW CREATE TABLE statement for this function will error out. This
commit is to fix it.

Release note (bug fix): enable SHOW CREATE TABLE for function created with
columns casting to user defined types.
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-26.1-159642 branch from e7c11c1 to af930bf Compare December 24, 2025 18:50
@blathers-crl blathers-crl bot requested review from a team as code owners December 24, 2025 18:50
@blathers-crl blathers-crl bot added the blathers-backport This is a backport that Blathers created automatically. label Dec 24, 2025
@blathers-crl blathers-crl bot removed the request for review from a team December 24, 2025 18:50
@blathers-crl blathers-crl bot added the O-robot Originated from a bot. label Dec 24, 2025
@blathers-crl blathers-crl bot requested a review from mgartner December 24, 2025 18:50
@blathers-crl
Copy link
Author

blathers-crl bot commented Dec 24, 2025

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot requested a review from DrewKimball December 24, 2025 18:50
@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Dec 24, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ZhouXing19 ZhouXing19 requested review from michae2 and removed request for a team, DrewKimball and mgartner December 24, 2025 18:51
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

@michae2 reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ZhouXing19).


pkg/sql/show_create_clauses.go line 425 at r1 (raw file):

		}

		dEnum, ok := typedExpr.(*tree.DEnum)

Could this also be a DTuple (for a user-defined composite type)?

(I'm trying to understand how the cast_to_composite testcase passes if we don't handle composite types here...)

@ZhouXing19
Copy link
Collaborator

pkg/sql/show_create_clauses.go line 425 at r1 (raw file):

Previously, michae2 (Michael Erickson) wrote…

Could this also be a DTuple (for a user-defined composite type)?

(I'm trying to understand how the cast_to_composite testcase passes if we don't handle composite types here...)

Sorry, I realized I wrote a silent bug here.

For column_name::composite_type casts, the current code would actually hit a "column doesn't exist" error in the earlier expr.TypeCheck() call because we lack table descriptor context. So we didn't even reach here, but already exited in the previous error check. But since we use simple visitor to walk the statement, this error is silently swallowed and we just stopped walking the remaining statement, so we just returned the expr as-is - that's why the cast_to_composite test still passed.

This enum-specific logic is only needed for const::enum situations where we need to deserialize binary enum data back to human-readable strings. For composite types, the original expr is already of human-readable string, so no need for this step.

Fixed this in PR #160424 by explicitly handling the UndefinedColumn error and adding proper support for non-enum UDT types.

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

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants