Обсуждение: Forcing postgres to reload current time zone.

Поиск
Список
Период
Сортировка

Forcing postgres to reload current time zone.

От
Дата:
Hello,

I'm writing an application that issues "SELECT current_timestamp" from
postgres on a regular basis to get the time. However, the user may
change the system's time zone and postgres does not seem to reflect this
change  unless I restart the database daemon. I cannot have all of my
program threads issue a SET TIME ZONE query, and was hoping there is a
query I could issue that would globally update the time zone for all
currently running postgres sessions, or a more gentle way to force
postgres to reload its time zone information without completely
restarting the daemon. Any advice?

I've done quite a bit of searching for this answer and I'm not coming up
with anything useful. I'm running postgres on RedHat Linux 9.

Many thanks,

trena



Re: Forcing postgres to reload current time zone.

От
Tom Lane
Дата:
<trena-no-spam@cotse.net> writes:
> I'm writing an application that issues "SELECT current_timestamp" from
> postgres on a regular basis to get the time. However, the user may
> change the system's time zone and postgres does not seem to reflect this
> change  unless I restart the database daemon. I cannot have all of my
> program threads issue a SET TIME ZONE query, and was hoping there is a
> query I could issue that would globally update the time zone for all
> currently running postgres sessions, or a more gentle way to force
> postgres to reload its time zone information without completely
> restarting the daemon. Any advice?

Readjust your objectives?  AFAIK every other daemon in your system will
behave the same way.

You could force Postgres into a new timezone by adjusting the timezone
setting in postgresql.conf and SIGHUP'ing the postmaster.  But it hardly
seems reasonable to build a mechanism to make that happen whenever the
user hacks on the system-wide timezone setting (especially considering
what a wide variety of means there are in different Unixen for defining
what the "system-wide timezone" is).

Note also that the timezone is hardly the only setting which your user
will have trouble changing on-the-fly --- locale and IP address come to
mind, and I'm sure there are others.  Again, Postgres is not the only
daemon that is not designed to recognize such changes instantly.

            regards, tom lane