From: | Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com> |
---|---|
To: | Manav Kumar <mkumar(at)yugabyte(dot)com> |
Cc: | pgsql-jdbc(at)lists(dot)postgresql(dot)org, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
Subject: | Re: Understanding DateStyle guc in startup packet |
Date: | 2025-05-19 12:23:11 |
Message-ID: | CAB=Je-Gznb3j_M--EAn9zW0cHLzgMg_YyWxWGM==g_kRfxEzrA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Long story short: it might be nice to decouple pgjdbc from requiring
DateStyle=ISO, however, it does not look like a walk in the park to me.
I guess here's the line that configures DateStyle ISO:
https://github.com/pgjdbc/pgjdbc/blob/d9e20874590f59543c39a99b824e09344f00a813/pgjdbc/src/main/java/org/postgresql/core/v3/ConnectionFactoryImpl.java#L409
It looks like options come after DateStyle.
At the same time, for some reason related to COPY processing, the driver
asserts DateStyle must start with ISO:
https://github.com/pgjdbc/pgjdbc/issues/131
---
For historical reasons, pgjdbc often sends timestamps and dates as
text-encoded literals, so it needs the backend to recognize the value
properly.
The reason is that Java's `setTimestamp()` does not distinguish between
timestamp and timestamptz, so the driver can't use Oid for
timestamp/timestamptz,
so it falls back to text encoding with Oid "unknown".
I have not explored if the server would parse the timestamps appropriately.
---
At the same time, DateStyle might affect text representation of the
timestamps, and the driver is not prepared to parse various flavours of
timestamp representation.
A way out might be to make sure pgjdbc always requires binary encoding when
receiving timestamp/timestamptz/date.
However, it might be trickier when processing arrays or structs as
requiring all the arrays and structs to be in binary would take a bit of
time as well.
Vladimir
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2025-05-19 15:12:10 | Re: Understanding DateStyle guc in startup packet |
Previous Message | Manav Kumar | 2025-05-19 11:30:54 | Understanding DateStyle guc in startup packet |