-
Notifications
You must be signed in to change notification settings - Fork 36
Timestamp functions volatility #26
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
Conversation
I don't think the functions can be set to
Additionally, this change modifies the function signature which I would consider a breaking change (you're breaking the API contract with the user, even if there is no change in the output). Therefore, I wouldn't backport it to previous versions. Instead I'd cut a new version 1.5.0 with the changes. |
Yeah, I think you're right with the STABLE volatility. Anyway, if someone has the same requirement as I do, they can modify the volatility of the functions using the following code right now ALTER FUNCTION uuid_v7_to_timestamptz STABLE;
ALTER FUNCTION uuid_timestamptz_to_v7 STABLE; |
Fixed in 1.5.0. |
I see that this issue is closed, but I think that these functions can be I think the comment quoted above is more focused on functions that are dependent on the timezone as part of the implementation and would return different results dependent on the timezone (an example: a function that takes a timestamp without a timezone and uses the current timezone to compute a timestamp with a timezone). These functions do not. |
This reasoning makes sense to me - especially given the fact that Postgres considers two I am less concerned about |
It is a good point that I think it is mostly a matter of taste if you want different invocations of If you want to provide both alternatives, you can have two different functions for this, like in pull request #33. |
Before further investing time in changing the current code / adding additional variations of the uuidv7 functions, I am looking to answer this question:
Going back to this line in the Postgres docs, what happens if the timezone is changed while the database is running? In that case, do functions that have timezone-related functionality that are marked as |
I understand your concern to ensure that the change does not cause strange behaviors, but the question is a little unclear, perhaps because it is a little too generic. In a sense, if a function has "timezone-related functionality" it cannot be marked If a function is marked as For the two functions under discussion here ( For the hypothetical function discussed above that use the timezone as part of computing the result, it would not be correct to make it |
uuid_v7_to_timestamptz
anduuid_timestamptz_to_v7
should be declared as IMMUTABLE. This is because the functions' results depend solely on their input arguments, and they will always return the same result for the same input. This change also allows you to use these functions in generated columns.