Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uGzWi-00BMcK-S3 for pgsql-jdbc@arkaria.postgresql.org; Mon, 19 May 2025 12:23:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uGzWh-00FJUZ-1Z for pgsql-jdbc@arkaria.postgresql.org; Mon, 19 May 2025 12:23:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uGzWg-00FJTj-Pp for pgsql-jdbc@lists.postgresql.org; Mon, 19 May 2025 12:23:26 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uGzWe-002ZMF-0x for pgsql-jdbc@lists.postgresql.org; Mon, 19 May 2025 12:23:25 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-ad563b69908so184723666b.3 for ; Mon, 19 May 2025 05:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747657403; x=1748262203; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JB00n6fE3X2mHJJ5aUwWEx+omlKWXkDWirdXCeADXWM=; b=agZQUnsOsbXdPLCqQqGnpexPppGdHJ0Lf4wmaH5TwQLRuUEXmkn+lkxS13yqcpUE5H pyw03z4wE8t5GHxJ955JND/4SFKAXvh9J1scUT7IWPuAgvydvRF7rNF/6NJQ+EILL6tR 8iQ3xZv3I3d0jXq+FFtJi7HE00Z7R4RYezCNPIZHKb1VS24j3kjPm3o2vIzUfwmVjvJU JJvCRqxQDg7IUtg2TgPhyiV6aTcwmkpRE405A2qKf87BTZLC7SZ+ueDLGD/Lfte667X8 +cXRuszRrbFPZTvurjyngRhLuyX6F3LlQyYK3ys+vIK6QsItuGpnWIKihPrauHj7xafL qFUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747657403; x=1748262203; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JB00n6fE3X2mHJJ5aUwWEx+omlKWXkDWirdXCeADXWM=; b=T9/gjVMFExoi8OM3mbeFDyNO/nfeXfB6v96sJkUSedRRU7QlZ9Rb3b751EA+2Jqd6R F0zLjFtVay8OcP9xWaofU7ydFIxirofmLSdgFM/j2mMXwx1ttthR7qOo2Bh13L4A/ieT 4GNiAT8hwZ7a7rY2ydTbATiU0miF/Yc3Lchj38Wsnyhj83taWOIgz9gsSev+7gXQDEAY emYH9vRwTJL1eV2EPSVZKQm1qspA7OrBaIz+RVEbFyb1OtVS6oGfhDwvAdJCul4dx22I 9e5BgZMu+3LWvmt3csBHK5PhBJgPeGGnepsV261qLJ32Gqy9aMaSQ7/lLSd3xsInaZCA lZTw== X-Gm-Message-State: AOJu0YyR1FG6qqJOEqFuNOnIfks/0W6r9tLFgoE2AvM5IKLNaAHeqAi0 zCvSIDPpHZjhebvRZJ5NUd3sk8QcVxq7BVcc8yqW/zwNZCcO6cyJ7RfA2hZwx2fPruy2Ictsfyy hK8AEysjOwMyyi5CQsl3pfY4wnSeL/QU= X-Gm-Gg: ASbGnctp85B7EgfjpT0v8d7HMDFzpWdkUO7EKpdcTw6la0ldsNXXqqBqCrySSf/sXY2 KmPtf9W4tfEMQz7MOronJZbNCG4buGx3Y49dS5XRgax+b9SHJemk2K6k0rV4BOfwcNT6BYCLh2m wSWzsXg17T0QDQ7HAAq7aQrY8YE8vCZ+XYFg== X-Google-Smtp-Source: AGHT+IHYJd1tzOIHhMUu5qCN6jwYuOcf8Cn3ClG4bFrnl7o83XHCnxzZwh1xd7SGf9TZ/fHeXba0uBw0fh1jebBiy+g= X-Received: by 2002:a17:907:7ea7:b0:ace:8398:b772 with SMTP id a640c23a62f3a-ad536b7c003mr795814866b.14.1747657403266; Mon, 19 May 2025 05:23:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Vladimir Sitnikov Date: Mon, 19 May 2025 15:23:11 +0300 X-Gm-Features: AX0GCFtPRiXnEBxA2zDpUGWUj2avs-uyVPpHaynjmYajnpj0rwjdDNFjIHx4Y3o Message-ID: Subject: Re: Understanding DateStyle guc in startup packet To: Manav Kumar Cc: pgsql-jdbc@lists.postgresql.org, Laurenz Albe Content-Type: multipart/alternative; boundary="000000000000b5fdb006357c3236" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b5fdb006357c3236 Content-Type: text/plain; charset="UTF-8" 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 --000000000000b5fdb006357c3236 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Long story short: it might be nice to decouple pgjdbc= from requiring DateStyle=3DISO, however, it does not look like a walk in t= he park to me.


=
It looks like options come=C2=A0after DateStyle.

<= div>At the same time, for some reason related to COPY processing, the drive= r asserts DateStyle must start with ISO:=C2=A0https://github.com/pgjdbc/pgjdbc/issues/131<= /div>

---

For historical reason= s, 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 tim= estamps appropriately.

---

At the same time, DateStyle might affect text representation of the times= tamps, and the driver is not prepared to parse various flavours of timestam= p representation.
A way out might be to make sure pgjdbc always r= equires binary encoding when receiving timestamp/timestamptz/date.
However, it might be trickier when processing arrays or structs as requir= ing all the arrays and structs to be in binary would take a bit of time as = well.

Vladimir

--000000000000b5fdb006357c3236--