X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0974FD1B1D0 for ; Sun, 11 Jul 2004 21:38:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31643-03 for ; Mon, 12 Jul 2004 00:38:33 +0000 (GMT) Received: from mail.svhost.com.ar (mail.svhost.com.ar [200.80.239.22]) by svr1.postgresql.org (Postfix) with ESMTP id CEC58D1B181 for ; Sun, 11 Jul 2004 21:38:28 -0300 (ADT) Received: from sistemat.com.ar (devel.sistemat.com.ar [192.168.1.40]) by mail.svhost.com.ar (Postfix) with ESMTP id EDFD01DB9C; Sun, 11 Jul 2004 21:37:01 -0300 (ART) Message-ID: <40F1DFA1.20407@sistemat.com.ar> Date: Sun, 11 Jul 2004 21:47:29 -0300 From: "Dario V. Fassi" Organization: SISTEMATICA ingenieria de software srl User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: es, es-ar, en-us, en MIME-Version: 1.0 To: Oliver Jowett Cc: "pgsql-jdbc@postgresql.org" Subject: Re: Timestamp Question References: <40F012E4.3000001@markhamdirect.com> <40F02556.1070109@sistemat.com.ar> <1089552466.11544.311.camel@localhost.localdomain> <40F19294.8090700@sistemat.com.ar> <40F1D5D8.2000205@opencloud.com> In-Reply-To: <40F1D5D8.2000205@opencloud.com> Content-Type: multipart/alternative; boundary="------------000506040703030204000807" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: * X-Archive-Number: 200407/103 X-Sequence-Number: 10487 This is a multi-part message in MIME format. --------------000506040703030204000807 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Oliver Jowett wrote: > Dario V. Fassi wrote: > >> I say that would help a lot if the microseconds part of a timestamp >> will be zero padded to a minimum length of 5 or 6 digits. >> Like: >> "then most databases can take 2004-07-10 12:59:59.123 as 2004-07-10 >> 12:59:59.123000 " >> >> This behavior help is cross (vendor) database operations . > > > Isn't this done by the driver already when dealing with a > java.sql.Timestamp? Do you have a testcase that shows the problem? > > The server itself seems to already handle zero-padding just fine: > >> test=> select '2004-07-10 12:59:59.000123'::timestamp(6); >> timestamp ---------------------------- >> 2004-07-10 12:59:59.000123 >> (1 row) >> >> test=> select '2004-07-10 12:59:59.123'::timestamp(6); >> timestamp ------------------------- >> 2004-07-10 12:59:59.123 >> (1 row) >> >> >> test=> select '2004-07-10 12:59:59.123000'::timestamp(6); >> timestamp ------------------------- >> 2004-07-10 12:59:59.123 >> (1 row) > You are seeing it: > test=> select '2004-07-10 12:59:59.123'::timestamp(6); > timestamp ------------------------- > 2004-07-10 12:59:59.123 I suggest that is cross DBs (eg. DB2 / PgSql etc) , the above situation cause troubles. The server -ALWAYS- should return a zero padded 5 digits minimun length milliseconds. This way others databases can receive pgsql returned timestant with or without timezone. -- TESTCASE -- create table public.t ( a timestamp with default current_timestamp ); insert into public.t; ** From a Jdbc client can see rows like: 2004-07-10 12:59:59.123 in plase of: 2004-07-10 12:59:59.12300 or 2004-07-10 12:59:59.00123 Dario --------------000506040703030204000807 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Oliver Jowett wrote:
Dario V. Fassi wrote:
I say that would help a lot if the microseconds part of a timestamp will be zero padded to a minimum length of 5 or 6 digits.
Like:
"then most databases can take 2004-07-10 12:59:59.123 as 2004-07-10 12:59:59.123000 "

This behavior help is cross (vendor) database operations .

Isn't this done by the driver already when dealing with a java.sql.Timestamp? Do you have a testcase that shows the problem?

The server itself seems to already handle zero-padding just fine:
test=> select '2004-07-10 12:59:59.000123'::timestamp(6);
         timestamp          ----------------------------
 2004-07-10 12:59:59.000123
(1 row)

test=> select '2004-07-10 12:59:59.123'::timestamp(6);
        timestamp        -------------------------
 2004-07-10 12:59:59.123
(1 row)


test=> select '2004-07-10 12:59:59.123000'::timestamp(6);
        timestamp        -------------------------
 2004-07-10 12:59:59.123
(1 row)
You are seeing it:

> test=> select '2004-07-10 12:59:59.123'::timestamp(6);
>        timestamp        -------------------------
> 2004-07-10 12:59:59.123

I suggest that is cross DBs (eg.  DB2 / PgSql etc) ,  the above situation cause troubles.

The server -ALWAYS-  should return a zero padded 5 digits minimun  length milliseconds. This way others databases can receive pgsql returned timestant with or without timezone.

-- TESTCASE --

create table public.t (  a timestamp with default current_timestamp );
insert into public.t;

** From a Jdbc client can see rows like:
    2004-07-10 12:59:59.123

in plase of:

    2004-07-10 12:59:59.12300
or
    2004-07-10 12:59:59.00123

Dario
--------------000506040703030204000807--