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
sql: handle implicit record return types better #96696
sql: handle implicit record return types better #96696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner)
66aede2
to
86386f9
Compare
TFTR! bors r=DrewKimball |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @rharding6373)
pkg/sql/opt/optbuilder/scalar.go
line 694 at r2 (raw file):
// defined in the function. rtyp := f.ResolvedType() if rtyp.UserDefined() {
Is there any downside to performing this check for non-user-defined types?
Can you move this check outside the loop (probably above) because it doesn't reference any specific stmts within the body.
bors r- |
Canceled. |
86386f9
to
cea454b
Compare
This PR validates the UDF return type at build time if it is a user-defined type. If the return type is no longer compatible with what the UDF body returns, we return an error instead. This is more in line with postgres behavior. Fixes: 95558 Epic: CRDB-19496 Release note (sql change): UDFs with implicit record return types will return an error when called if the return type has been altered and is no longer compatible with the body of the UDF.
cea454b
to
bed5677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @mgartner)
pkg/sql/opt/optbuilder/scalar.go
line 694 at r2 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
Is there any downside to performing this check for non-user-defined types?
Can you move this check outside the loop (probably above) because it doesn't reference any specific stmts within the body.
Good catch, moved to the beginning of the function.
Unfortunately there is some assumption under the hood of ResolveTypeByOID that it's a user defined type. Apparently this has to do with the fact that only UDTs need to be hydrated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks all! bors r+ |
Build succeeded: |
This PR validates the UDF return type at build time if it is a user-defined type. If the return type is no longer compatible with what the UDF body returns, we return an error instead. This is more in line with postgres behavior.
Fixes: #95558
Epic: CRDB-19496
Release note (sql change): UDFs with implicit record return types will return an error when called if the return type has been altered and is no longer compatible with the body of the UDF.