Received: from localhost (uranus.hub.org [200.46.204.60]) by postgresql.org (Postfix) with ESMTP id 3C3779FB257 for ; Tue, 14 Nov 2006 12:52:20 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.60]) (amavisd-new, port 10024) with ESMTP id 43849-07 for ; Tue, 14 Nov 2006 12:52:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from ihemail1.lucent.com (ihemail1.lucent.com [135.245.0.33]) by postgresql.org (Postfix) with ESMTP id 028FB9FB251 for ; Tue, 14 Nov 2006 12:52:15 -0400 (AST) Received: from ilexp02.ndc.lucent.com (h135-3-39-2.lucent.com [135.3.39.2]) by ihemail1.lucent.com (8.13.8/IER-o) with ESMTP id kAEGq6f9008527; Tue, 14 Nov 2006 10:52:07 -0600 (CST) Received: from ILEXC2U01.ndc.lucent.com ([135.3.39.9]) by ilexp02.ndc.lucent.com with Microsoft SMTPSVC(6.0.3790.0); Tue, 14 Nov 2006 10:52:06 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C7080D.37B8C926" Subject: Re: help with front/backend datatype converting Date: Tue, 14 Nov 2006 10:52:04 -0600 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [JDBC] help with front/backend datatype converting Thread-Index: AccFkWLA8NHQ8raKR+eAAG/7PEPsvgCeAZ3A From: "Do, Leon \(Leon\)" To: "Dave Cramer" , "imad" Cc: X-OriginalArrivalTime: 14 Nov 2006 16:52:06.0906 (UTC) FILETIME=[37EA7DA0:01C7080D] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/69 X-Sequence-Number: 16111 This is a multi-part message in MIME format. ------_=_NextPart_001_01C7080D.37B8C926 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Dave, =20 There are actually bugs in the Postgres timestamp string. See below. =20 > -----Original Message----- > From: Dave Cramer [mailto:pg@fastcrypt.com] > Sent: Saturday, November 11, 2006 8:00 AM > To: imad > Cc: Do, Leon (Leon); pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] help with front/backend datatype converting >=20 >=20 > On 11-Nov-06, at 6:40 AM, imad wrote: >=20 > > On 11/11/06, Do, Leon (Leon) wrote: > >> > >> > >> > >> > >> > >> > >> Dave, > >> > >> > >> > >> I see you raised a lot of issues about this problem but I don't > >> have any > >> suggestion as of now. I'll think about it. > >> > >> > >> > >> On the side, the timezone for timestamp is always sending in this > >> format: > >> > >> 2006-11-10 14:36:19.213000 -0500 > >> > >> > >> > >> should it be > >> > >> 2006-11-10 14:36:19.213000 -05:00 > > > > this is better. > Why ? 0500 is perfectly acceptable to postgres [Do, Leon (Leon)]=20 =20 I think postgres has a few bugs in this area. When timezone doesn't have a semicolon between hour and min, TimestampUtil.java cann't handle it. The firstNonDigits method call below returns all four digits and assigns them to timezone hour variable. =20 In the TimestampUtils.java // Possibly read timezone. sep =3D charAt(s, start); if (sep =3D=3D '-' || sep =3D=3D '+') { int tzsign =3D (sep =3D=3D '-') ? -1 : 1; int tzhr, tzmin; =20 end =3D firstNonDigit(s, start+1); // Skip +/- tzhr =3D number(s, start+1, end); start =3D end; =20 sep =3D charAt(s, start); if (sep =3D=3D ':') { end =3D firstNonDigit(s, start+1); // Skip ':' tzmin =3D number(s, start+1, end); start =3D end; } else { tzmin =3D 0; } =20 =20 And for the second bugs, fractional part of the second (e.g. 14:36:19.213000) seem to be interpreted incorrectly when converting to Java Date. 213000 would round up as additional 3.52 mins.=20 Postgres timestamp 2006-11-10 14:36:19.213000 -05:00 =20 to Java Date 2006-11-10 14:39:52.0 -05:00 =20 Would somebody help to fix these bugs? =20 thanks =20 Leon Do =20 =20 > > > > > > --Imad > > www.EnterpriseDB.com > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 7: You can help support the PostgreSQL project by donating at > > > > http://www.postgresql.org/about/donate > > =20 ------_=_NextPart_001_01C7080D.37B8C926 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Dave,

 

There are actually bugs in the Postgres timestamp string. =  See below.

 

> -----Original Message-----

> From: Dave Cramer = [mailto:pg@fastcrypt.com]

> Sent: Saturday, November 11, 2006 8:00 AM

> To: imad

> Cc: Do, Leon (Leon); pgsql-jdbc@postgresql.org

> Subject: Re: [JDBC] help with front/backend datatype = converting

>

>

> On 11-Nov-06, at 6:40 AM, imad wrote:

>

> > On 11/11/06, Do, = Leon (Leon) = <leondo@lucent.com> wrote:

> >>

> >>

> >>

> >>

> >>

> >>

> >> Dave,

> >>

> >>

> >>

> >> I see you raised a lot of issues about this = problem but I don't

> >> have any

> >> suggestion as of now.  I'll think about = it.

> >>

> >>

> >>

> >> On the side, the timezone for timestamp is always = sending in this

> >> format:

> >>

> >> 2006-11-10 14:36:19.213000 -0500

> >>

> >>

> >>

> >> should it be

> >>

> >> 2006-11-10 14:36:19.213000 = -05:00

> >

> > this is better.

> Why ? 0500 is perfectly acceptable to = postgres

[Do, Leon = (Leon)]

 

I think postgres has a few bugs = in this area.    When timezone doesn’t have a semicolon between hour and min, TimestampUtil.java cann’t handle it.   The = firstNonDigits method call below returns all four digits and assigns them to timezone hour = variable.

 

In the = TimestampUtils.java

     &nbs= p;      // Possibly read timezone.

     &nbs= p;      sep =3D charAt(s, start);

     &nbs= p;      if (sep =3D=3D '-' || sep =3D=3D '+') = {

     &nbs= p;          int tzsign =3D (sep =3D=3D '-') ? -1 : 1;

     &nbs= p;          int tzhr, tzmin;

    =

     &nbs= p;          end =3D firstNonDigit(s, start+1);    // Skip = +/-

   = ;            = tzhr =3D number(s, start+1, end);

   = ;            = start =3D end;

    =

     &nbs= p;          sep =3D charAt(s, start);

     &nbs= p;          if (sep =3D=3D ':') {

     &nbs= p;            = ;  end =3D firstNonDigit(s, start+1);  // Skip = ':'

     &nbs= p;            = ;  tzmin =3D number(s, start+1, end);

     &nbs= p;            = ;  start =3D end;

     &nbs= p;          } else {

     &nbs= p;            = ;  tzmin =3D 0;

     &nbs= p;          }

 

 

And for the second bugs, = fractional part of the second (e.g. 14:36:19.213000) seem to be interpreted incorrectly when = converting to Java Date.  213000 would round up as additional 3.52 mins. =

Postgres = timestamp

2006-11-10 14:36:19.213000 -05:00

 

to Java Date

2006-11-10 14:39:52.0 -05:00

 

Would somebody help to fix these = bugs?

 

thanks

 

Leon Do

 

 

> >

> >

> > --Imad

> > www.EnterpriseDB.com

> >

> > ---------------------------(end of

> > = broadcast)---------------------------

> > TIP 7: You can help support the PostgreSQL project by donating at

> >

> = >           &nb= sp;    http://www.postgresql.org/about/donate

> >

 

------_=_NextPart_001_01C7080D.37B8C926--