Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XiWVb-00069v-Rd for pgsql-jdbc@arkaria.postgresql.org; Sun, 26 Oct 2014 22:42:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XiWVb-0001fB-At for pgsql-jdbc@arkaria.postgresql.org; Sun, 26 Oct 2014 22:41:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XiViz-0006In-5s for pgsql-jdbc@postgresql.org; Sun, 26 Oct 2014 21:51:45 +0000 Received: from mxout2.iskon.hr ([213.191.128.81]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XiViv-0001aA-4S for pgsql-jdbc@postgresql.org; Sun, 26 Oct 2014 21:51:43 +0000 Received: from mxscanout.iskon.hr (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 6ACBF2E3212; Sun, 26 Oct 2014 22:51:39 +0100 (CET) Received: from mxscanout.iskon.hr (localhost [127.0.0.1]) by mxscanout (MCF 1.0.2) with SMTP; Sun, 26 Oct 2014 22:51:39 +0100 (CET) Received: from in1.mail.iskon.hr (in1.mail.iskon.hr [213.191.133.66]) by mxscanout.iskon.hr (Postfix) with ESMTP id 685452E3142; Sun, 26 Oct 2014 22:51:39 +0100 (CET) Received: from kas30pipe.localhost (localhost [127.0.0.1]) by in1.mail.iskon.hr (Postfix) with ESMTP id 5D9B4C607C; Sun, 26 Oct 2014 22:51:39 +0100 (CET) X-Remote-IP: 213.202.97.37 Received: from charizard.infoart.hr (unknown [213.202.97.37]) by in1.mail.iskon.hr (Postfix) with ESMTP id C4B05C6079; Sun, 26 Oct 2014 22:51:36 +0100 (CET) Received: by charizard.infoart.hr (Postfix, from userid 5002) id B5A37CB0576; Sun, 26 Oct 2014 22:51:36 +0100 (CET) Received: from vladimir (141-136-221-118.dsl.iskon.hr [141.136.221.118]) by charizard.infoart.hr (Postfix) with ESMTP id 25012CB0290; Sun, 26 Oct 2014 22:51:36 +0100 (CET) From: =?UTF-8?Q?Vladimir_Crn=C4=8Di=C4=87_=28Infoart_d.o.o.=29?= To: "'John Lister'" , "'Dave Cramer'" Cc: "'List'" References: <001401cfedf0$2d861690$889243b0$@infoart.hr> <65A3123A-80BB-4F4C-ACDD-ED25142C7B2D@kickstone.com> In-Reply-To: <65A3123A-80BB-4F4C-ACDD-ED25142C7B2D@kickstone.com> Date: Sun, 26 Oct 2014 22:51:35 +0100 MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQGcaWlDkVsBlGTxb/YrmKw8k2prXgG7cUHWAwWrSBOcg98T0A== Content-Language: hr Message-ID: <000401cff167$03db1a50$0b914ef0$@infoart.hr> Content-Type: multipart/mixed; boundary="----=_NextPart_000_0005_01CFF16F.65A6AE40" Subject: Re: TIMESTAMP value binary transfer problem X-Anti-Virus: Kaspersky Anti-Virus for Linux Mail Server 5.6.45/RELEASE, bases: 20140401 #7726142, check: 20141026 clean X-SpamTest-Envelope-From: vcrncic@infoart.hr X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 68313 [Oct 27 2014] X-SpamTest-Info: {RECEIVED: dynamic ip detected} X-SpamTest-Info: {From: Likely Random} X-SpamTest-Info: {relay has no DNS name} X-SpamTest-Method: none X-SpamTest-Rate: 55 X-SpamTest-SPF: none X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0284], KAS30/Release X-Pg-Spam-Score: -1.8 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multipart message in MIME format. ------=_NextPart_000_0005_01CFF16F.65A6AE40 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0006_01CFF16F.65A6AE40" ------=_NextPart_001_0006_01CFF16F.65A6AE40 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Well, the server and the client are on the same development Windows 7 machi= ne. I've done some testing using class in attachment and found out that res= ults depend on time zone and daylight saving settings, in some zones result= s are always correct, in some are correct with daylight saving turned off, = in some with daylight saving turned on, and so on. Obviously there's some = problem with incoming binary data or time zone compensation in TimestampUti= ls.toTimestampBin() =20 if (!timestamptz) { if (tz =3D=3D null) { tz =3D defau= ltTz; } millis -=3D tz.getOffset(mil= lis); } =20 I don't really understand why this compensation is needed in the first plac= e, conversion in TimestampUtils.toTimestamp() takes no time zone in account= with TIMESTAMP type. Anyway, getting different results depending on data t= ransfer type is unacceptable.=20 =20 =20 From: John Lister [mailto:john.lister@kickstone.com]=20 Sent: Saturday, October 25, 2014 10:26 PM To: Dave Cramer; Vladimir Crn=C4=8Di=C4=87 (Infoart d.o.o.) Cc: List Subject: Re: [JDBC] TIMESTAMP value binary transfer problem =20 There was a problem with some time zones from memory, in the uk for example= 1970 had an odd daylight saving period and because 1970 is used in calcula= ting the time values in the driver this skews the results in the driver. Us= ing the current year fixes it when calculating times.=20 Maybe something to check.=20 On 25 October 2014 19:21:25 GMT+01:00, Dave Cramer > wrote: This is the same as https://github.com/pgjdbc/pgjdbc/pull/133 =20 So what I am wondering is why a small number of people see this and the res= t are fine ??? =20 What is unique about your environment. Are the server and the client on the= same timezone ? Dave Cramer dave.cramer(at)credativ(dot)ca http://www.credativ.ca =20 On 22 October 2014 14:03, Vladimir Crn=C4=8Di=C4=87 (Infoart d.o.o.) > wrote: There is a problem with JDBS driver interpretation of "timestamp without ti= me zone" values when binary transfer is on. When binary transfer is disable= d for TIMESTAMP columns (binaryTransferDisable=3DTIMESTAMP or binaryTransfe= r=3Dfalse) problem does not occur. =20 database version: 9.1.1 driver version: 9.2, 9.3 =20 BINARY TRANSFER: ---------------- database value (TIMESTAMP): 2014-10-26 01:00:04 bytes (AbstractJdbc2Resultset): [0, 1, -87, 71, -77, -6, 45, 0] long value (TimestampUtils): 467600404000000 java timestamp (TimestampUtils): 2014-10-26 02:00:04.0 = (not OK) =20 TEXT TRANSFER: -------------- database value (TIMESTAMP): 2014-10-26 01:0= 0:04 string value (AbstractJdbc2Resultset): 2014-10-26 01:00:04 java timestamp (TimestampUtils): 2014-10-26 01:00:0= 4.0 (OK) =20 --=20 Sent from my Android device with K-9 Mail. Please excuse my brevity. ------=_NextPart_001_0006_01CFF16F.65A6AE40 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Well, the server and the client are on the sam= e development Windows 7 machine. I've done some testing using class in atta= chment and found out that results depend on time zone and daylight saving s= ettings, in some zones results are always correct, in some are correct with= daylight saving turned off, in some with daylight saving turned on, and so= on. =C2=A0Obviously there's some problem with incoming binary data or time= zone compensation in TimestampUtils.toTimestampBin()

=

&n= bsp;

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!timestamptz) {

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (tz =3D=3D nul= l) {

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2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0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 }

 

I don't re= ally understand why this compensation is needed in the first place, convers= ion in TimestampUtils.toTimestamp() takes no time zone in account with TIME= STAMP type. Anyway, getting different results depending on data transfer ty= pe is unacceptable.

 

 

From: John Lister [mailto:john.lister@kickstone.com]
Sent: Saturd= ay, October 25, 2014 10:26 PM
To: Dave Cramer; Vladimir Crn=C4=8D= i=C4=87 (Infoart d.o.o.)
Cc: List
Subject: Re: [JDBC] T= IMESTAMP value binary transfer problem

 

There was a = problem with some time zones from memory, in the uk for example 1970 had an= odd daylight saving period and because 1970 is used in calculating the tim= e values in the driver this skews the results in the driver. Using the curr= ent year fixes it when calculating times.

Maybe something to check.=

On 25 O= ctober 2014 19:21:25 GMT+01:00, Dave Cramer <pg@fastcrypt.com> wrote:

This is the same as https://github.com/pgjdbc/pgjdbc/pull/133

 <= /p>

So what I am wonderin= g is why a small number of people see this and the rest are fine ???

&nbs= p;

What = is unique about your environment. Are the server and the client on the same= timezone ?


Dave Cramer

dave.cramer(at)credativ(dot)cahttp://www.credativ.c= a

 

On 2= 2 October 2014 14:03, Vladimir Crn=C4=8Di=C4=87 (Infoart d.o.o.) <vcrncic@infoart.hr>= ; wrote:

There is a problem with JDBS dri= ver interpretation of "timestamp without time zone" values when b= inary transfer is on. When binary transfer is disabled for TIMESTAMP column= s (binaryTransferDisable=3DTIMESTAMP or binaryTransfer=3Dfalse) problem doe= s not occur.

 

database version: 9.1.1

driver version: 9.2, 9.3

 

BINARY TRANSFER:

= ----------------

database va= lue (TIMESTAMP):          &nbs= p;      2014-10-26 01:00:04

<= p class=3DMsoNormal style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:= auto'>bytes (AbstractJdbc2Resultset):    =           [0, 1, -87, 71, -77,= -6, 45, 0]

long value (Time= stampUtils):           &n= bsp;        467600404000000

java timestamp (TimestampUtils):  &= nbsp;       2014-10-26 02:00:04.0  =             &nb= sp;    (not OK)

 

TEXT TRANSFER:

--------------

database value (TIMESTAMP):   &nbs= p;            &= nbsp;           &nbs= p;    2014-10-26 01:00:04

string value (AbstractJdbc2Resultset):     = ;            2014-10= -26 01:00:04

java timestamp = (TimestampUtils):          &nb= sp;            =   2014-10-26 01:00:04.0    (OK)

&= nbsp;


--
Sent from my Android device with K-9 Mail. Please ex= cuse my brevity.

= ------=_NextPart_001_0006_01CFF16F.65A6AE40-- ------=_NextPart_000_0005_01CFF16F.65A6AE40 Content-Type: application/octet-stream; name="TimestampTest.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="TimestampTest.java" package test;=0A= =0A= import java.sql.Connection;=0A= import java.sql.DriverManager;=0A= import java.sql.ResultSet;=0A= import java.sql.SQLException;=0A= import java.sql.Statement;=0A= import java.sql.Timestamp;=0A= =0A= public class TimestampTest {=0A= =0A= static final String JDBC_DRIVER =3D "org.postgresql.Driver";=0A= static final String DB_URL =3D "jdbc:postgresql://localhost:5432/postgres"= ;=0A= static final String USER =3D "postgres";=0A= static final String PASS =3D "dedalus28";=0A= =0A= public static void main (String[] args) {=0A= =0A= Connection conn =3D null;=0A= Statement stmt =3D null;=0A= ResultSet rs;=0A= =0A= try {=0A= // initial connection with binary transfer ON=0A= Class.forName(JDBC_DRIVER);=0A= System.setProperty("org.postgresql.forcebinary", "true");=0A= conn =3D DriverManager.getConnection(DB_URL, USER, PASS);=0A= stmt =3D conn.createStatement();=0A= =0A= // test data=0A= try {=0A= stmt.execute("CREATE TABLE tstable (tsfield TIMESTAMP(0) WITHOUT TIME Z= ONE)");=0A= } catch (Exception e) {=0A= ; // nop=0A= }=0A= stmt.execute("truncate table tstable");=0A= stmt.execute("insert into tstable (tsfield) values ('2014-10-26 01:00:04= ')");=0A= =0A= // *********************************************************************= *=0A= // TEST WITH TIMESTAMP BINARY TRANSFER ON=0A= rs =3D stmt.executeQuery("SELECT tsfield FROM tstable");=0A= rs.next();=0A= Timestamp ts =3D rs.getTimestamp("tsfield");=0A= System.out.println(ts);=0A= rs.close();=0A= stmt.close();=0A= conn.close();=0A= =0A= // *********************************************************************= *=0A= // TEST WITH TIMESTAMP BINARY TRANSFER OFF=0A= conn =3D DriverManager.getConnection(DB_URL + "?binaryTransferDisable=3D= TIMESTAMP", USER,=0A= PASS);=0A= stmt =3D conn.createStatement();=0A= rs =3D stmt.executeQuery("SELECT tsfield FROM tstable");=0A= rs.next();=0A= ts =3D rs.getTimestamp("tsfield");=0A= System.out.println(ts);=0A= rs.close();=0A= stmt.close();=0A= conn.close();=0A= =0A= } catch (Exception e) {=0A= e.printStackTrace();=0A= } finally {=0A= try {=0A= if (stmt !=3D null)=0A= stmt.close();=0A= } catch (SQLException se2) {=0A= // nop;=0A= }=0A= try {=0A= if (conn !=3D null)=0A= conn.close();=0A= } catch (Exception se) {=0A= // nop;=0A= }=0A= }=0A= }=0A= }=0A= ------=_NextPart_000_0005_01CFF16F.65A6AE40 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc ------=_NextPart_000_0005_01CFF16F.65A6AE40--