I found the following line in my postgresql.conf
:
timezone = 'CET'
And I do also get this by querying the settings:
postgres=# show timezone;
TimeZone
----------
CET
Anyways, we currently still have DST active and following example shows, that the server knows this (+02 is CEST):
postgres=# select now();
now
-------------------------------
2019-10-09 02:03:33.48477+02
But there are also time zones known to PostgreSQL, that are abbreviated by CET
and do not have DST. In particular, all of the time zones with this abbreviation have offset +01:
postgres=# select * from pg_timezone_names() where abbrev = 'CET';
name | abbrev | utc_offset | is_dst
----------------+--------+------------+--------
Africa/Algiers | CET | 01:00:00 | f
Africa/Tunis | CET | 01:00:00 | f
postgres=# select * from pg_timezone_abbrevs where abbrev = 'CET';
abbrev | utc_offset | is_dst
--------+------------+--------
CET | 01:00:00 | f
I am now confused about this and the meaning of this abbreviation and the TimeZone
setting. I expected, that every timestamp with time zone
is displayed in the time zone that is set by this parameter. But obviously, this does not hold:
postgres=# select now(), now() AT TIME ZONE (SELECT setting FROM pg_settings WHERE name = 'TimeZone');
now | timezone
------------------------------+---------------------------
2019-10-09 02:03:33.48477+02 | 2019-10-09 01:03:33.48477
So finally, here are my questions:
How does this really work? Is there anywhere a setting specifying to use certain DST rules? The output I get is what I expected from a time zone like Europe/Berlin
, which has DST rules. But what if I needed my database to run in real CET (so without any DST)? Or is there another configuration I did not see, which overrides the TimeZone
?
Also I wonder about how AT TIME ZONE
works. In the documentation, I found the following:
They are converted to local time in the zone specified by the TimeZone configuration parameter before being displayed to the client.
But as my query shows, this does not really apply. There is also the following statement at the same page, that seems not to apply as well (log_timezone
is also CET
):
You cannot set the configuration parameters TimeZone or log_timezone to a time zone abbreviation, but you can use abbreviations in date/time input values and with the AT TIME ZONE operator.
Did I mix up anything? Or are their some known bugs (and are they perhaps fixed in newer versions)? Are the docs just wrong?
My PostgreSQL version()
is PostgreSQL 9.6.5, compiled by Visual C++ build 1800, 64-bit
.
(Disclaimer: I am somewhat happy about what it is doing, at least apart from the "problem" with AT TIME ZONE
, since I am in Germany and we have DST. But I do not understand why CET
defaults to using DST and I wonder if there is a parameter to turn this off / configure it. Also I feel like there is something wrong with the AT TIME ZONE
specification or the default behavior respectively.)