[BUGS] BUG #2020: 7.3 -> 8.0.4 migration timestamp problem -
11-04-2005
, 12:38 PM
The following bug has been logged online:
Bug reference: 2020
Logged by: Fernando Rubbo
Email address: fernando (AT) diuno (DOT) com.br
PostgreSQL version: 8.0.4
Operating system: Linux - Fedora Core 3
Description: 7.3 -> 8.0.4 migration timestamp problem
Details:
1)
I have a problem with the timestamp before 1914.
When i execute the query by java statement it has no problem, but when i
execute the query
by java preparedstatement the timestamp before 1914 have problems like
this:
PreparedStatement pst = con.prepareStatement("insert into teste values
(?, ?, ?)");
pst.setObject(1, new Integer(1));
pst.setObject(2, "TESTE");
Calendar c = new GregorianCalendar(1913, 0, 1, 0, 0, 0);
Timestamp t = new Timestamp(c.getTimeInMillis());
pst.setTimestamp(3, t);
pst.executeUpdate();
The result in the database is the timestamp equal 1912-12-31 23:53:12.0
PS: i have already debugged the Postgres-8.0 (build 313) driver and it
seems to send the correct date to database.
2)
Another problem is with functions like date_trunc and date_part that
use a timestamp parameter.
The problem ocurrs only with the java preparedstatment.
Calendar c = new GregorianCalendar();
Timestamp ts = new Timestamp(c.getTimeInMillis());
pst = con.prepareStatement("select date_trunc('day', TIMESTAMP ?)");
pst.setObject(1, ts);
rs = pst.executeQuery();
below the printstacktrace:
Exception in thread "main" java.sql.SQLException: ERROR: syntax error
at or near "$1"
at
org.postgresql.core.v3.QueryExecutorImpl.receiveEr rorResponse(QueryExecutorI
mpl.java:1471)
at
org.postgresql.core.v3.QueryExecutorImpl.processRe sults(QueryExecutorImpl.ja
va:1256)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(Q ueryExecutorImpl.java:175)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execut e(AbstractJdbc2Statement.j
ava:392)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execut eWithFlags(AbstractJdbc2St
atement.java:330)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execut eQuery(AbstractJdbc2Statem
ent.java:240)
at teste.Teste3.main(Teste3.java:54)
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend |