Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WuZMv-0000Nt-O2 for pgsql-odbc@arkaria.postgresql.org; Wed, 11 Jun 2014 03:38:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WuZMv-0001PF-2z for pgsql-odbc@arkaria.postgresql.org; Wed, 11 Jun 2014 03:38:33 +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 1WuZMu-0001P6-6j for pgsql-odbc@postgresql.org; Wed, 11 Jun 2014 03:38:32 +0000 Received: from sd.tpf.co.jp ([210.161.239.34]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WuZMn-00022D-Oq for pgsql-odbc@postgresql.org; Wed, 11 Jun 2014 03:38:30 +0000 Received: (qmail 19192 invoked by uid 512); 11 Jun 2014 03:38:21 -0000 Received: from unknown (HELO ?127.0.0.1?) (100.126.1.62) by sd2.tpf-fw-c.co.jp with SMTP; 11 Jun 2014 03:38:21 -0000 Message-ID: <5397CF28.1020503@tpf.co.jp> Date: Wed, 11 Jun 2014 12:38:16 +0900 From: "Inoue, Hiroshi" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Walter Couto , David Johnston CC: Adrian Klaver , "pgsql-odbc@postgresql.org" Subject: Re: Re: Inconsistency between JDBC and ODBC drivers when dealing with TIMESTAMP WITH TIME ZONE References: <7FA4F9E5512F214C801E596ECD8790E066A82A9A@ETNAMAIL01.embarcadero.com> <1402359526172-5806595.post@n5.nabble.com> <7FA4F9E5512F214C801E596ECD8790E066A82D32@ETNAMAIL01.embarcadero.com> <53967920.3090308@aklaver.com> <5396865D.7080506@tpf.co.jp>, <7FA4F9E5512F214C801E596ECD8790E066A83019@ETNAMAIL01.embarcadero.com> In-Reply-To: <7FA4F9E5512F214C801E596ECD8790E066A83019@ETNAMAIL01.embarcadero.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org Hi Walter, I would enable time zone related code and complete the coding. When I make a patch, could you test it? (2014/06/10 19:31), Walter Couto wrote: > Yes, I have to workaround this issue in my application since the > existing issue as the current drivers have this bug. And to avoid > overhead caching the server time zone is the best option to avoid > repeated calls (thought their is a risk of you being wrong as you can > changes the session time zone via a statement which will make the cached > value wrong if it was run before that. > > As apposed to showing my code to get a SQL_C_CHAR I'll show you the > ODBC code that is perplexing: > > In convert.c's copy_and_convert_field() line 946: This case statement > block states that for PG_TYPE_ABSTIME, PG_TYPE_DATETIME, > PG_TYPE_TIMESTAMP_NO_TMZONE and PG_TYPE_TIMESTAMP that the string given > by the server is: > > 1) -Infinity > > 2) -Infinity > > 3) invalid > > 4) %4d-%2d-%2d %2d:%2d:%2d%31s %15s (YYYY-MM-dd > hh:mm:ss[.ffffff][-/+zh[:zm] [BC]) (max 35 characters for year < 10000) > > What that code does for 1) - 3) is perfectly fine, you have to choose > some timestamp value and those values are as good as anything else. 4) > is dealt by the function timestamp2stime on line 224 of the > convert_field. The only bug I see in this code is how it handles the > time zone parsing, it only handles +/-zh, but not the possible but rare > +/-zh:zm format/ That bug is in the switch statement on line 245 of that > file. The cases for '+', '-' and '.' all don't check for the existence > of ":" in the string. Thanks. I was surprized that the time zone in old Japanese days was +09:18:59 . In fact using psql I see the following results. =# select cast('1887-12-31 23:59:59' as timestamp with time zone); timestamptz ------------------------------ 1887-12-31 23:59:59+09:18:59 =# select cast('1887-12-31 23:59:60' as timestamp with time zone); timestamptz ------------------------ 1888-01-01 00:00:00+09 So I would take the form -/+zh[:zm[:zs]] into account. regards, Hiroshi Inoue ญญ -- I am using the free version of SPAMfighter. SPAMfighter has removed 10739 of my spam emails to date. Get the free SPAMfighter here: http://www.spamfighter.com/len Do you have a slow PC? Try a Free scan http://www.spamfighter.com/SLOW-PCfighter?cid=sigen -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc