Conversation
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. Before a member of our team reviews your PR, I have some potential action items for you:
I have added a few people who may be able to assist in reviewing:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
|
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Resolve timezone abbreviations through the PostgreSQL abbreviation table before falling back to IANA names. This prevents conversions using CET from applying daylight-saving rules associated with the IANA CET zone. Use the resolver across timezone builtins, session timezone assignment, and non-local session data deserialization. Add SQL and resolver regressions for winter and summer conversions, case-insensitive abbreviations, timezone overloads, timestamp construction, date truncation, IANA regions, and explicit offset conventions. Fixes cockroachdb#94078 Release note (bug fix): Timezone conversion functions now resolve PostgreSQL abbreviations such as CET using their fixed offsets instead of applying daylight-saving rules from an identically named IANA zone.
60b7525 to
297f437
Compare
|
Thank you for updating your pull request. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Summary
Resolve PostgreSQL timezone abbreviations such as
CETas fixed-offset abbreviations when they are used by SQL timezone operations and session timezone handling.Fixes #94078
Root cause
The affected call sites passed every timezone string to the generic
timeutil.TimeZoneStringToLocationresolver. That resolver treats a name such asCETas an IANA location, so the returned location applies the region's daylight-saving rules. PostgreSQL gives abbreviations precedence through itspg_timezone_abbrevsmapping;CETtherefore represents the fixed+01:00abbreviation in the relevant conversion.This difference is observable around daylight-saving transitions. For example, converting a timestamp through
timezone('CET', ...)could produce+02:00in CockroachDB when PostgreSQL keeps the abbreviation at+01:00. The same ambiguity affected session timezone assignment and deserialization, so fixing only thetimezone()builtins would leave inconsistent behavior across entry points.Change
Add a PostgreSQL-aware timezone resolver in
pkg/util/timeutil/pgdate. It first looks up the input in the existing PostgreSQL abbreviation table and returns atime.FixedZoneusing that row's offset. If the input is not a PostgreSQL abbreviation, it falls back to the existing generic resolver and preserves the behavior of named IANA zones and explicit offset forms.Use the new resolver from all identified entry points:
timezone()builtin overloads and timestamp construction path;SET TIME ZONEand session timezone mutation;This keeps region names such as
Europe/Parison their normal daylight-saving-aware path while giving PostgreSQL abbreviations their required fixed-offset semantics.Validation
CETconversion around a daylight-saving boundary.