-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: only re-use resolved routine type when flag is set #143170
base: master
Are you sure you want to change the base?
Conversation
// should reuse the already resolved type, if any. This is used to handle | ||
// "re-type-checking" that occurs for a RECORD-returning routine, for which | ||
// the return type is not known until the routine body is built. | ||
RoutineUseResolvedType bool |
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.
Does it make sense to use ScalarAncestors here? The special case is a bit confusing to me - it only applies to routines within a VALUES expression?
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.
I don't think we can use ScalarAncestors
, or at least it would potentially be more confusing. We apply the special case to expressions within a VALUES
operator, but only on the second type-checking pass which happens when the VALUES
column type depends on a record-returning routine. Using ScalarAncestors
here would cause us to to also use this special behavior on the first type-checking pass.
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.
👍
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
This commit adds a `RoutineUseResolvedType` flag to the `SemaContext` properties to indicate that type-checking for a routine that has already been resolved to a concrete type should short-circuit. This is used to determine the column type for a `Values` operator which depends on a RECORD-returning routine, which only determines its type after the body is built. This will prevent regressions in other code paths that do not desire this short-circuiting behavior. Fixes cockroachdb#142615 Release note (bug fix): Fixed a bug in `v24.1.14`, `v24.3.7`, `v24.3.8`, and `v25.1` which could cause a nil-pointer error when a column's default expression contained a volatile expression (like `nextval`) as a UDF argument.
This commit adds a
RoutineUseResolvedType
flag to theSemaContext
properties to indicate that type-checking for a routine that has already been resolved to a concrete type should short-circuit. This is used to determine the column type for aValues
operator which depends on a RECORD-returning routine, which only determines its type after the body is built. This will prevent regressions in other code paths that do not desire this short-circuiting behavior.Fixes #142615
Release note (bug fix): Fixed a bug in
v24.1.14
,v24.3.7
,v24.3.8
, andv25.1
which could cause a nil-pointer error when a column's default expression contained a volatile expression (likenextval
) as a UDF argument.