public inbox for [email protected]
help / color / mirror / Atom feedFrom: Manav Kumar <[email protected]>
To: Vladimir Sitnikov <[email protected]>
Cc: [email protected]
Cc: Laurenz Albe <[email protected]>
Subject: Re: Understanding DateStyle guc in startup packet
Date: Fri, 23 May 2025 14:08:07 +0530
Message-ID: <CAPhCW+8+8iQd5TLSTkyXN5OR-KoC2JfyO2kn89jPwSDF0HJdtg@mail.gmail.com> (raw)
In-Reply-To: <CAPhCW+_geB205gMyqCC-9V1oLsZDNXJYHzC6J8qo1EAM5ohihg@mail.gmail.com>
References: <CAPhCW+-oyivUiBiP5nOMQNxQzXLnT62SvCZ1oq7rqZkHq34KGA@mail.gmail.com>
<CAB=Je-Gznb3j_M--EAn9zW0cHLzgMg_YyWxWGM==g_kRfxEzrA@mail.gmail.com>
<CADK3HHKC-1iTEZNT4fvjS-mBkLYVmKQVG3Kvq9_KHXnctACUjA@mail.gmail.com>
<CAB=Je-EmfXoyBRm2LefkxugqNGPta7vf=Ky8ycYpkd02_-WX_w@mail.gmail.com>
<CAPhCW+8m6g4dpMjwR1KtGYaC_su_qBc5jH-T4vnH2SaZVJp9kw@mail.gmail.com>
<CAPhCW+_geB205gMyqCC-9V1oLsZDNXJYHzC6J8qo1EAM5ohihg@mail.gmail.com>
cc: Laurenz, pgsql-jdbc.
Hi,
Can you also share how does DRIVER comes to know the value been set for
DateStyle is other than "ISO". and throw an error:
The server's DateStyle parameter was changed to Postgres, DMY. The JDBC
driver requires DateStyle to begin with ISO for correct operation.
I thought it used to read the PARAMETER STATUS packet that it receives from
the server. But I tried changing it connection pooler i doens't see the
same error. Can you point me to code where this assert check is present.
On Thu, May 22, 2025 at 6:23 PM Manav Kumar <[email protected]> wrote:
> Hi,
> Can you also share how does DRIVER comes to know the value been set for
> DateStyle is other than "ISO". and throw an error:
> The server's DateStyle parameter was changed to Postgres, DMY. The JDBC
> driver requires DateStyle to begin with ISO for correct operation.
>
> I thought it used to read the PARAMETER STATUS packet that it receives
> from the server. But I tried changing it connection pooler i doens't see
> the same error. Can you point me to code where this assert check is
> present.
>
> On Mon, May 19, 2025 at 11:31 PM Manav Kumar <[email protected]> wrote:
>
>> Got it.
>> Let me know if you think my understanding is correct.
>> The way these special GUC's are being set is:
>> https://github.com/pgjdbc/pgjdbc/blob/d9e20874590f59543c39a99b824e09344f00a813/pgjdbc/src/main/java/...
>>
>> "DateStyle" : "ISO"
>> "Client_encoding": "UTF8".
>>
>> And when we pass
>> "options": "DateStyle=Postgres,DMY"
>> I think it takes less precedence in the server than if the direct key as
>> a guc variable is passed as key.
>>
>> This can be verified from below codes i found on server side:
>>
>> https://github.com/postgres/postgres/blob/29f7ce6fe78e3f8d520764b5870453d791a3ca65/src/backend/utils...
>> - First cmd line options are processed i.e -options.
>>
>> Followed by
>>
>> https://github.com/postgres/postgres/blob/29f7ce6fe78e3f8d520764b5870453d791a3ca65/src/backend/utils...
>> - Followed by GUC options are set/overriden.
>>
>> "DateStyle", "Client_encoding" etc all comes into guc_options as general
>> GUC options.
>> https://github.com/postgres/postgres/blob/29f7ce6fe78e3f8d520764b5870453d791a3ca65/src/backend/tcop/...
>>
>>
>>
>>
>> My next question is: Suppose i comment the code to set the value of
>> "DateStyle" to "ISO" from startup where key is my "DateStyle".
>> The error I get is:
>> org.postgresql.util.PSQLException: The server's DateStyle parameter was
>> changed to Postgres, DMY. The JDBC driver requires DateStyle to begin with
>> ISO for correct operation.
>> at
>> org.postgresql.core.v3.QueryExecutorImpl.receiveParameterStatus(QueryExecutorImpl.java:2887)
>> *Questions *is how does the driver comes to know which value has been
>> set on server, is it due to PARAMETER STATUS which is been returned for the
>> "DateStyle" on getting set and it contains the value as "Postgres,DMY" and
>> driver reads this value to throw an error as it doesn't matches "ISO". Is
>> it correct ?
>>
>>
>> Thanks a lot for giving me all hints and help!
>> Best
>> Manav
>>
>>
>>
>>
>>
>> On Mon, May 19, 2025 at 9:07 PM Vladimir Sitnikov <
>> [email protected]> wrote:
>>
>>> >Why would you want to change it?
>>>
>>> Applications might have their own view on the way DateStyle connection
>>> property should be set.
>>> It could make a difference if the app uses things like select
>>> '03-05-2025'::date.
>>>
>>> Of course, it would be great if the app code could resist from casting
>>> text to dates, however,
>>> I think the driver should stand in the way there by enforcing a very
>>> specific DateStyle value.
>>>
>>> To me, DateStyle looks like timezone, and client_encoding which we
>>> currently enforce, yet we could do better and skip enforcing the values.
>>>
>>> Vladimir
>>>
>>>
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Understanding DateStyle guc in startup packet
In-Reply-To: <CAPhCW+8+8iQd5TLSTkyXN5OR-KoC2JfyO2kn89jPwSDF0HJdtg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox