-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: change volatility of timezone with TIME and TIMETZ to stable #51037
Conversation
6a3c80e
to
68d7bd2
Compare
pkg/sql/sem/builtins/builtins.go
Outdated
@@ -2407,7 +2407,8 @@ may increase either contention or retry errors, or both.`, | |||
), | |||
|
|||
// https://www.postgresql.org/docs/9.6/functions-datetime.html | |||
"timezone": makeBuiltin(defProps(), | |||
"timezone": makeBuiltin( | |||
tree.FunctionProperties{IgnoreVolatilityCheck: true}, |
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.
do you mind adding a comment linking to the issue here so it's easier to reconcile the justification?
also wondering if this ignore should be at the overload level, leave that up to you though.
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.
Ya I think it should be at the overload level because that's where volatility is defined. I'll make the change.
The `timezone(STRING, TIME)` and `timezone(STRING, TIMETZ)` function overloads were originally marked as volatile to copy Postgres's volatility for the `timezone(STRING, TIMETZ)` overload (Postgres does not implement `timezone (STRING, TIME)`. Postgres's volatility settings for all overloads of `timezone` are below. Name | Argument data types | Volatility ----------+---------------------------------------+------------------ timezone | interval, time with time zone | immutable zone timezone | interval, timestamp with time zone | immutable timezone | interval, timestamp without time zone | immutable timezone | text, time with time zone | volatile zone timezone | text, timestamp with time zone | immutable timezone | text, timestamp without time zone | immutable This single overload is singled out as volatile by Postgres because it is dependent on C's `time(NULL)`. See the Postgres commit originally marking this overload volatility, and the lines of code showing the dependence: postgres/postgres@35979e6 https://github.com/postgres/postgres/blob/ac3a4866c0bf1d7a14009f18d3b42ffcb063a7e9/src/backend/utils/adt/date.c#L2816 CRDB does not have the same issue. All `timezone` overloads have the same volatility, stable. This commit marks them as such. Additional context: cockroachdb#48756 (comment) This commit also moves the `IgnoreVolatilityCheck` field from function definitions to overloads. This allows overloads of the same function to be ignored when asserting that the volalitity of an overload matches Postgres's assigned volatility. Release note: None
68d7bd2
to
f949158
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.
looks lgtm to me
bors r+ |
Build failed (retrying...) |
Build succeeded |
sql: change volatility of timezone with TIME and TIMETZ to stable
The
timezone(STRING, TIME)
andtimezone(STRING, TIMETZ)
functionoverloads were originally marked as volatile to copy Postgres's
volatility for the
timezone(STRING, TIMETZ)
overload (Postgres doesnot implement
timezone (STRING, TIME)
.Postgres's volatility settings for all overloads of
timezone
arebelow.
This single overload is singled out as volatile by Postgres because it
is dependent on C's
time(NULL)
. See the Postgres commit originallymarking this overload volatility, and the lines of code showing the
dependence:
postgres/postgres@35979e6
https://github.com/postgres/postgres/blob/ac3a4866c0bf1d7a14009f18d3b42ffcb063a7e9/src/backend/utils/adt/date.c#L2816
CRDB does not have the same issue. All
timezone
overloads have thesame volatility, stable. This commit marks them as such.
Additional context: #48756 (comment)
This commit also moves the
IgnoreVolatilityCheck
field from functiondefinitions to overloads. This allows overloads of the same function to
be ignored when asserting that the volalitity of an overload matches
Postgres's assigned volatility.
Release note: None