public inbox for [email protected]  
help / color / mirror / Atom feed
From: Manav Kumar <[email protected]>
To: [email protected]
To: Laurenz Albe <[email protected]>
Subject: Understanding DateStyle guc in startup packet
Date: Mon, 19 May 2025 17:00:54 +0530
Message-ID: <CAPhCW+-oyivUiBiP5nOMQNxQzXLnT62SvCZ1oq7rqZkHq34KGA@mail.gmail.com> (raw)

Manav Kumar <[email protected]>
Sat, May 17, 6:05 PM (2 days ago)
to pgsql-bugs
Hi Team,
I'm writing to clarify a syntax to pass the guc options in the startup
packt of the connection via JDBC.


Wrote below small java program:

Properties props = new Properties();
props.setProperty("options", "-c DateStyle=Postgres,DMY");
props.setProperty("user", "postgres");
props.setProperty("password", "postgres");
connection = DriverManager.getConnection(
"jdbc:postgresql://localhost:5432/postgres", props);

stmt1 = connection.createStatement();
ResultSet rs = stmt1.executeQuery("show DateStyle");
while (rs.next()) {
System.out.println(rs.getString(1));
}
stmt1.execute("reset DateStyle");
rs = stmt1.executeQuery("show DateStyle");
while (rs.next()) {
System.out.println(rs.getString(1));
}

The output I'm getting is:
ISO, DMY
ISO, DMY.

As explained by @Laurenz Albe <[email protected]>  the driver forces
the value of DateStyle to remain ISO even though the client tries to set a
different value in the startup packet.

Can you please point me in the code where it happens or share briefly how
it has been implemented. I was testing a connection pool with pg and saw
the Postgres,DMY (client provided value) values coming in the startup
packet.

Best,
Manav


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]
  Subject: Re: Understanding DateStyle guc in startup packet
  In-Reply-To: <CAPhCW+-oyivUiBiP5nOMQNxQzXLnT62SvCZ1oq7rqZkHq34KGA@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