Skip site navigation (1) Skip section navigation (2)

Re: JDBC timestamp does not understand [-]infinity

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: JDBC timestamp does not understand [-]infinity
Date: 2002-08-27 16:42:16
Message-ID: 200208271642.g7RGgGu29993@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbcpgsql-patches
This code doesn't exist in the jdbc driver anymore.  They must have
already fixed it.

---------------------------------------------------------------------------

Dmitry Tkach wrote:
> The attached patch fixes 'Bad Timestamp format' exception when timestamp value is 'ininity' or '-ininity'.
> I hope, it helps...
> Dima.

> Index: AbstractJdbc1ResultSet.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v
> retrieving revision 1.1
> diff -p -r1.1 AbstractJdbc1ResultSet.java
> *** AbstractJdbc1ResultSet.java	2002/07/23 03:59:55	1.1
> --- AbstractJdbc1ResultSet.java	2002/07/23 16:58:00
> *************** public abstract class AbstractJdbc1Resul
> *** 40,46 ****
> --- 40,50 ----
>   	protected StringBuffer sbuf = null;
>   	public byte[][] rowBuffer=null;
>   
> + 	public static final String MIN_DATE_STR = "0000-01-01";
> + 	public static final String MAX_DATE_STR = "9999-12-31";
> + 	
>   
> + 
>   	public AbstractJdbc1ResultSet(org.postgresql.PGConnection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
>   	{
>   		this.connection = conn;
> *************** public abstract class AbstractJdbc1Resul
> *** 853,861 ****
>   			else
>   				rs.sbuf.setLength(0);
>   
>   			// Copy s into sbuf for parsing.
>   			rs.sbuf.append(s);
> - 			int slen = s.length();
>   
>   			if (slen > 19)
>   			{
> --- 857,871 ----
>   			else
>   				rs.sbuf.setLength(0);
>   
> + 			int slen = s.length();
> + 
> + 			if (slen == 8 && s.equals ("infinity"))
> + 			  s = MAX_DATE_STR;
> + 			else if (slen == 9 && s.equals ("-infinity"))
> + 			  s = MIN_DATE_STR;
> + 			
>   			// Copy s into sbuf for parsing.
>   			rs.sbuf.append(s);
>   
>   			if (slen > 19)
>   			{

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-jdbc by date

Next:From: Warren MassengillDate: 2002-08-27 17:14:52
Subject: Re: JDK development kit
Previous:From: Jim CaleyDate: 2002-08-27 12:45:30
Subject: Re: JDK development kit

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-08-27 17:12:07
Subject: Re: cube bug accepting -.1
Previous:From: Bruce MomjianDate: 2002-08-27 15:41:07
Subject: Re: Bug found in psql interface

pgsql-patches by date

Next:From: Neil ConwayDate: 2002-08-27 17:19:15
Subject: rules regression test fix
Previous:From: Bruce MomjianDate: 2002-08-27 16:21:10
Subject: Re: minor auth code cleanup

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group