pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make timetz_zone() stable, and correct a bug for DYNTZ abbreviat
Date: Mon, 06 Sep 2021 15:04:07 +0000
Message-ID: <E1mNGAJ-0002aB-Dd@gemulon.postgresql.org> (raw)

Make timetz_zone() stable, and correct a bug for DYNTZ abbreviations.

Historically, timetz_zone() has used time(NULL) as the reference point
for deciding whether DST is active.  That means its result can change
intra-statement, requiring it to be marked VOLATILE (cf. 35979e6c3).
But that definition is pretty inconsistent with the way we deal with
timestamps elsewhere.  Let's make it use the transaction start time
("now()") as the reference point instead.  That lets it be marked
STABLE, and also saves a kernel call per invocation.

While at it, remove the function's use of pg_time_t and pg_localtime.
Those are inconsistent with the other code in this area, which indeed
created a bug: timetz_zone() delivered completely wrong answers if
the zone was specified by a dynamic TZ abbreviation.  (We need to do
something about that in the back branches, but the fix will look
different from this.)

Aleksander Alekseev and Tom Lane

Discussion: https://postgr.es/m/CAJ7c6TOMG8zSNEZtCn5SPe+cCk3Lfxb71ZaQwT2F4T7PJ_t=KA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/388e71af880d579212c2489686903c2cfdea9032

Modified Files
--------------
src/backend/utils/adt/date.c     | 28 ++++++++++++++--------------
src/include/catalog/catversion.h |  2 +-
src/include/catalog/pg_proc.dat  |  2 +-
3 files changed, 16 insertions(+), 16 deletions(-)



Message-ID: <E1mNGAJ-0002aB-Dd@gemulon.postgresql.org>
Permalink:  ../E1mNGAJ-0002aB-Dd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mNGAJ-0002aB-Dd@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make timetz_zone() stable, and correct a bug for DYNTZ abbreviat
  In-Reply-To: <E1mNGAJ-0002aB-Dd@gemulon.postgresql.org>
  References: <E1mNGAJ-0002aB-Dd@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox