postgres 9.4 timezone unknown - postgresql

My company just upgraded from postgres 9.0.4 to postgres 9.4.2
when timezone unknown was specified in the postgres.conf file in 9.0.4, postgres "figured out" what the local timezone was, and set that as the local timezone.
in 9.4.2 the documentation says that if not specified it uses GMT.
I want to know if there's a way to get the legacy behavior

I got the answer mostly from information from Tom Lane.
postgres 9.2+ "figures out" the local timezone during initdb.

Related

how to permanently change AWS RDS postgreSQL db timezone

I need to permanently change my postgreSQL db timezone from AEST to UTC, the instance is on AWS rds.
On my AWS RDS postgreSQL parameter group, the timezone shows UTC but when i run
show timezone; it returns my local time zone which is AEST
the sql SET TIMEZONE='UTC'; only change the session, so what's the right way to change the timezone to UTC permanently?
this link shows changing the parameter group value should work? https://aws.amazon.com/premiumsupport/knowledge-center/rds-change-time-zone/
thanks
A "source" of 'client' means that when your client connects, it sets the timezone it wants to use. This will override anything you do globally and permanently on the database side, as the client can always change their own setting for this.
If you tell us what your client is and how it is configured, someone may be able to help you change this behavior. For example if it is a libpq-based client, then having the PGTZ environment variable set will cause this behavior.

Database timezone not using TZ

I have a timestamp column 'submitted_on' with default as now().
I have set the heroku TZ to my zone and added a php user ini with the same timezone.
But the database is still using UTC timezone. I see this when I ran this sql:
show timezone;
Is there a fix? Or this is how heroku databases work? Also I'm using free dynos.
Setting a TZ config var only affects the Dynos environment, as the database is located on a different machine, it has no effect.
Generally speaking, you should always keep servers clocks running on UTC, store all times in UTC, and perform any timezone/locale changes in your application framework.
The parameter timezone is determined when the database cluster is created.
You can either change the value in postgresql.conf, or you can use ALTER SYSTEM as a superuser to change the value.
I don't know if Heroku allows you either of these options.

Clojure: java.jdbc can't connect to Postgres after changing OS timezone to UTC

When I set my timezone on my server to UTC via timedatectl set-timezone UTC and restart Postgres server, I can connect via psql and verify that select now() returns the correct value.
When I try to start my Clojure app and run a query, I get the following error:
Acquisition Attempt Failed!!! Clearing pending acquires.
While trying to acquire a needed new resource, we failed
to succeed more than the maximum number of allowed
acquisition attempts (30). Last acquisition attempt exception:
org.postgresql.util.PSQLException: FATAL: invalid value for parameter "TimeZone": "UTC"
I am using the following database libraries in my app:
[org.postgresql/postgresql "9.4.1208"]
[clojure.jdbc/clojure.jdbc-c3p0 "0.3.2"]
[org.clojure/java.jdbc "0.6.1"]
The error looks like it comes from Postgres, but only happens when connecting via the Clojure app.
Everything works if I return the OS timezone to America/New_York
Take a look at
postgres default timezone
See what timezone names are understood by the database:
SELECT * FROM pg_timezone_names;

Postgres and c3p0 invalid timezone error during connection

I get the following error when trying to connect a standalone Java application to Postgres:
org.postgresql.util.PSQLException: FATAL: invalid value for parameter "TimeZone": "America/New_York"
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java 572)
...
at com.mchange.v2.c3p0.DriveManagerDataSource.getConnection(DriveManagerDataSource.java: 164)
...
(sorry, I have to type this in by hand because of my setup).
I am using Postgres 9.3.3 with PostGIS 2.1.1 extensions, the Postgres 9.3-1100 jdbc driver and the 0.2.6.3 c3p0 library.
I get this on both Linux and Windows systems. When I changed the TZ to GMT on the Linux system the connection works, but that's not a good solution.
Any idea what I con do to fix this?
Thanks,
Ken
Pavel Horal had the correct answer. The Postgres installation was messed up and only root had access to the /usr/local/pgsql_933/share/timezone/America directory. Once I did a chmod on that and the files in it my problem went away.
Check your default timezone in postgresql(UTC) and make sure connection timezone and default are same.

Postgres now() returns +03 timezone but show timezone returns GMT

prompt$ date
Mon Oct 7 17:32:24 UTC 2013
prompt$ psql -U postgres
postgres=# show timezone;
TimeZone
----------
GMT
(1 row)
postgres=# select now();
now
-------------------------------
2013-10-07 20:32:42.354384+03
(1 row)
Why is it returning it in +03 timezone format? What am I obviously missing here?
EDIT: I solved the problem, but a question still remains. Here is what happened:
I had changed the system's OS timezone, without restarting the postgres server. Previous OS timezone was indeed +03. After I restarted postgres, it worked correctly. But it is a strange situation: postgresql.conf has not any timezone explicitly defined and the client (psql) should should always output timestamps in the timezone reported by "show timezone". So there is still this unexplained question:
Why psql was reporting GMT as timezone setting but displayed timestamps in the OS new timezone. Is this expected behaviour?
This is certainly odd behavior, largely because I would have expected show timezone to show the same timezone as now() showed. My recommendation is try to reproduce the situation and then email the PostgreSQL list or file a bug report. It sounds like you might be able to cause this by changing your system timezone while PostgreSQL is running. A reload or restart might fix the problem.
I also second the notion of watching out for ALTER USER ... SET TIMEZONE, but on top of that you can also ALTER DATABASE ... SET TIMEZONE and even ALTER FUNCTION ... SET TIMEZONE