Обсуждение: BUG #2882: jdbc driver: date returned from a stored proc is incorrect
The following bug has been logged online: Bug reference: 2882 Logged by: Ravi Email address: ravitx12@yahoo.com PostgreSQL version: 8.1.4 Operating system: Linux RHEL 3 Description: jdbc driver: date returned from a stored proc is incorrect Details: This is a PostgreSQL driver issue. The value returned should be Jan 1 1900, instead it returns Jan 2 1900. The failure could be seen only on RHEL3 and not RHEL4. Documented. On Red Hat Enterprise Linux AS release 4 (Nahant Update 3) the milliseconds returned is as follows -2209028400000 = -25567.458333333333333333333333333 = Jan 1 1900 On Red Hat Enterprise Linux AS release 3 (Taroon Update 3) the milliseconds returned is as follows -2208952800000 = -25566.583333333333333333333333333 = Jan 2 1900 Negative indicates before Jan 1 1970. Store Procedure used - create or replace function proc_test_dt1 (a in date) returns date as' begin delete from test_dt; insert into test_dt values(a); return a; end; ' language 'plpgsql' Table was created as follows: create table test_dt(datefld date); The inserted value looks fine.
Ravi wrote: > On Red Hat Enterprise Linux AS release 4 (Nahant Update 3) the milliseconds > returned is as follows > > -2209028400000 = -25567.458333333333333333333333333 = Jan 1 1900 > > On Red Hat Enterprise Linux AS release 3 (Taroon Update 3) the milliseconds > returned is as follows > -2208952800000 = -25566.583333333333333333333333333 = Jan 2 1900 Is one of these compiled with --enable-integer-datetimes, and the other not? You can tell by calling pg_controldata, IIRC. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Ravi Periasamy wrote: > I do not think this is a server issue, seems like a > driver issue. When I connect to the DB from RHEL4 > through the driver (running on RHEL4) it works. But, > when the driver is running on RHEL3 it fails. Oh, I hadn't realized that both clients were connecting to the same server. Yes, most likely this is a JDBC issue of some sort. Can't help you there. > What is IIRC? If I Recall Correctly. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
I do not think this is a server issue, seems like a driver issue. When I connect to the DB from RHEL4 through the driver (running on RHEL4) it works. But, when the driver is running on RHEL3 it fails. Anyways, here's the output: [root@bdc31014e pgsql]# pg_controldata `pwd`/data pg_control version number: 812 Catalog version number: 200510211 Database system identifier: 4972362701494942605 Database cluster state: in production pg_control last modified: Thu 11 Jan 2007 04:32:27 AM IST Current log file ID: 0 Next log file segment: 2 Latest checkpoint location: 0/15F3CD0 Prior checkpoint location: 0/15F3B1C Latest checkpoint's REDO location: 0/15F3CD0 Latest checkpoint's UNDO location: 0/0 Latest checkpoint's TimeLineID: 1 Latest checkpoint's NextXID: 5195 Latest checkpoint's NextOID: 25214 Latest checkpoint's NextMultiXactId: 1 Latest checkpoint's NextMultiOffset: 0 Time of latest checkpoint: Thu 11 Jan 2007 04:32:27 AM IST Maximum data alignment: 4 Database block size: 8192 Blocks per segment of large relation: 131072 Bytes per WAL segment: 16777216 Maximum length of identifiers: 64 Maximum columns in an index: 32 Date/time type storage: floating-point numbers Maximum length of locale name: 128 LC_COLLATE: en_US.UTF-8 LC_CTYPE: en_US.UTF-8 [root@bdc31014e pgsql]# What is IIRC? Thanks Ravi --- Alvaro Herrera <alvherre@commandprompt.com> wrote: > Ravi wrote: > > > On Red Hat Enterprise Linux AS release 4 (Nahant > Update 3) the milliseconds > > returned is as follows > > > > -2209028400000 = > -25567.458333333333333333333333333 = Jan 1 1900 > > > > On Red Hat Enterprise Linux AS release 3 (Taroon > Update 3) the milliseconds > > returned is as follows > > -2208952800000 = > -25566.583333333333333333333333333 = Jan 2 1900 > > Is one of these compiled with > --enable-integer-datetimes, and the other > not? You can tell by calling pg_controldata, IIRC. > > -- > Alvaro Herrera > http://www.CommandPrompt.com/ > PostgreSQL Replication, Consulting, Custom > Development, 24x7 support > ____________________________________________________________________________________ Need a quick answer? Get one in minutes from people who know. Ask your question on www.Answers.yahoo.com
A after thought- I was working with Oliver Cloud on a similar issue and he has a fix for that issue, that would solve this as well. Basically the changeTime() method called from Statement.getDate(int, Calendar) is causing the problem. Make sure, the code from ResultSet.getDate(int, Calendar) is reused here too. I worked around this and it's working for me now. Thanks Ravi --- Alvaro Herrera <alvherre@commandprompt.com> wrote: > Ravi Periasamy wrote: > > I do not think this is a server issue, seems like > a > > driver issue. When I connect to the DB from RHEL4 > > through the driver (running on RHEL4) it works. > But, > > when the driver is running on RHEL3 it fails. > > Oh, I hadn't realized that both clients were > connecting to the same > server. Yes, most likely this is a JDBC issue of > some sort. Can't help > you there. > > > What is IIRC? > > If I Recall Correctly. > > -- > Alvaro Herrera > http://www.CommandPrompt.com/ > PostgreSQL Replication, Consulting, Custom > Development, 24x7 support > ____________________________________________________________________________________ Never Miss an Email Stay connected with Yahoo! Mail on your mobile. Get started! http://mobile.yahoo.com/services?promote=mail