pgsql: Fix some odd behaviors when using a SQL-style simple GMT offset

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix some odd behaviors when using a SQL-style simple GMT offset
Дата
Msg-id E1VcHMX-0007Lo-6c@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix some odd behaviors when using a SQL-style simple GMT offset timezone.

Formerly, when using a SQL-spec timezone setting with a fixed GMT offset
(called a "brute force" timezone in the code), the session_timezone
variable was not updated to match the nominal timezone; rather, all code
was expected to ignore session_timezone if HasCTZSet was true.  This is
of course obviously fragile, though a search of the code finds only
timeofday() failing to honor the rule.  A bigger problem was that
DetermineTimeZoneOffset() supposed that if its pg_tz parameter was
pointer-equal to session_timezone, then HasCTZSet should override the
parameter.  This would cause datetime input containing an explicit zone
name to be treated as referencing the brute-force zone instead, if the
zone name happened to match the session timezone that had prevailed
before installing the brute-force zone setting (as reported in bug #8572).
The same malady could affect AT TIME ZONE operators.

To fix, set up session_timezone so that it matches the brute-force zone
specification, which we can do using the POSIX timezone definition syntax
"<abbrev>offset", and get rid of the bogus lookaside check in
DetermineTimeZoneOffset().  Aside from fixing the erroneous behavior in
datetime parsing and AT TIME ZONE, this will cause the timeofday() function
to print its result in the user-requested time zone rather than some
previously-set zone.  It might also affect results in third-party
extensions, if there are any that make use of session_timezone without
considering HasCTZSet, but in all cases the new behavior should be saner
than before.

Back-patch to all supported branches.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/2650c5cf4beb727e739f71a77369b01bf6daaf60

Modified Files
--------------
src/backend/commands/variable.c        |    2 ++
src/backend/utils/adt/datetime.c       |    6 -----
src/include/pgtime.h                   |    1 +
src/test/regress/expected/horology.out |   30 ++++++++++++++++++++++++
src/test/regress/sql/horology.sql      |   16 +++++++++++++
src/timezone/pgtz.c                    |   40 ++++++++++++++++++++++++++++++++
6 files changed, 89 insertions(+), 6 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix some odd behaviors when using a SQL-style simple GMT offset
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix some odd behaviors when using a SQL-style simple GMT offset