Skip to content

Calcutta/Kolkata time zone name mismatch prevents connection #3642

@eirikbakke

Description

@eirikbakke

Describe the issue

If a user with a Java client version that runs with the time zone "Asia/Calcutta" connects to a PostgreSQL server that uses the newer equivalent name "Asia/Kolkata" for the same time zone, the following exception is seen:

org.postgresql.util.PSQLException: FATAL: invalid value for parameter "TimeZone": "Asia/Calcutta"
  at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
  at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2837)
  at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:175)
  at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:317)
  at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
  at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:273)
  at org.postgresql.Driver.makeConnection(Driver.java:446)
  at org.postgresql.Driver.connect(Driver.java:298)

I suspect the same can happen with mismatches between "Europe/Kiev" and "Europe/Kyiv" as well (another recent name change I have seen in time zone databases).

The relevant JDBC driver code is in org.postgresql.core.v3.ConnectionFactoryImpl.createPostgresTimeZone(). For the time zones "Asia/Calcutta", "Asia/Kolkata", "Europe/Kiev", and "Europe/Kyiv", it would probably be better to generate an offset-based time zone name that works regardless of server version and distribution. Or if it's not possible to pass offset-based time zone names for the TimeZone connection parameter, perhaps pass "GMT" instead and automatically call "SET SESSION TIME ZONE INTERVAL" to set the offset instead.

Driver Version?

42.7.3

Java Version?

21.0.4

OS Version?

Windows

PostgreSQL Version?

Unknown (bug was reported by a user of my database UI product, Ultorg).

To Reproduce

Use a PostgreSQL server that uses the newer "Asia/Kolkata" time zone name. For the client, use OpenJDK 21.0.4 for Windows which uses the older "Asia/Calcutta". Then set the machine time zone to India time and attempt to connect.

Expected behaviour

The connection should succeed, but does not.

Logs

See the earlier-pasted stack trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions