Skip to content

sql: resolve PostgreSQL timezone abbreviations as fixed offsets - #175301

Closed
Alignyx wants to merge 1 commit into
cockroachdb:masterfrom
Alignyx:fix-94078-postgres-timezone-abbreviations
Closed

Alignyx wants to merge 1 commit into
cockroachdb:masterfrom
Alignyx:fix-94078-postgres-timezone-abbreviations

Conversation

@Alignyx

@Alignyx Alignyx commented Sep 12, 2026

Copy link
Copy Markdown

Summary

Resolve PostgreSQL timezone abbreviations such as CET as 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.TimeZoneStringToLocation resolver. That resolver treats a name such as CET as an IANA location, so the returned location applies the region's daylight-saving rules. PostgreSQL gives abbreviations precedence through its pg_timezone_abbrevs mapping; CET therefore represents the fixed +01:00 abbreviation in the relevant conversion.

This difference is observable around daylight-saving transitions. For example, converting a timestamp through timezone('CET', ...) could produce +02:00 in CockroachDB when PostgreSQL keeps the abbreviation at +01:00. The same ambiguity affected session timezone assignment and deserialization, so fixing only the timezone() 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 a time.FixedZone using 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:

  • the timezone() builtin overloads and timestamp construction path;
  • SET TIME ZONE and session timezone mutation;
  • non-local session data deserialization.

This keeps region names such as Europe/Paris on their normal daylight-saving-aware path while giving PostgreSQL abbreviations their required fixed-offset semantics.

Validation

  • Exercised the reported CET conversion around a daylight-saving boundary.
  • Verified session timezone assignment and deserialization use the same resolution rules.
  • Ran the affected module tests, native regression checks, held-out checks, and the full regression suite.

@Alignyx
Alignyx requested a review from a team as a code owner September 12, 2026 12:35
@Alignyx
Alignyx requested review from himanshu-shrivastava-crl and removed request for a team September 12, 2026 12:35
@blathers-crl

blathers-crl Bot commented Sep 12, 2026

Copy link
Copy Markdown

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:

  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

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.

@blathers-crl blathers-crl Bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Sep 12, 2026
@blathers-crl

blathers-crl Bot commented Sep 13, 2026

Copy link
Copy Markdown

Thank you for updating your pull request.

Before a member of our team reviews your PR, I have some potential action items for you:

  • We notice you have more than one commit in your PR. We try break logical changes into separate commits, but commits such as "fix typo" or "address review commits" should be squashed into one commit and pushed with --force
  • Please ensure your git commit message contains a release note.
  • When CI has completed, please ensure no errors have appeared.

🦉 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.
@Alignyx
Alignyx force-pushed the fix-94078-postgres-timezone-abbreviations branch from 60b7525 to 297f437 Compare September 13, 2026 12:09
@blathers-crl

blathers-crl Bot commented Sep 13, 2026

Copy link
Copy Markdown

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.

@rafiss rafiss closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community X-blathers-triaged blathers was able to find an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: timezone abbreviations should not consider daylight savings

2 participants