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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Bug in 7.4_213 driver: returns VARCHAR instead of


  • From: Kris Jurka <books(at)ejurka(dot)com>
  • To: "j.random.programmer" <javadesigner(at)yahoo(dot)com>
  • Cc: pgsql-jdbc(at)postgresql(dot)org
  • Subject: Re: Bug in 7.4_213 driver: returns VARCHAR instead of
  • Date: Thu, 29 Jul 2004 16:33:23 -0500 (EST)
  • Message-id: <Pine.BSO.4.56.0407291519090.12809@leary.csoft.net> <text/plain>


On Tue, 27 Jul 2004, j.random.programmer wrote:

> The JDBC version 7.4_213 driver has the following bug
> 
> For database SQL type:
> text	(that is variable unlimited length)
> 
> The JDBC driver returns "java.sql.VARCHAR" as
> the column type. (via database meta data).
> 
> This is wrong. The JDBC driver SHOULD return
> java.sql.LONGVARCHAR (since the text type is
> of unlimited length).
> 

I'm not sure this is clearly wrong, but you do make a convincing argument.  
My concern is backwards compatibility with existing applications that 
expect text as VARCHAR.  When I tried the change in the driver, there were 
4 failures and 2 errors in the drivers regression test.  Some code didn't 
handle LONGVARCHAR at all and others expected text to be VARCHAR.

For example consider CallableStatements:

CallableStatement call = con.prepareCall ("{ ? = upper(?) }");
call.setString(2, "foo");
call.registerOutParameter(1, Types.VARCHAR);
call.execute();
String result = call.getString(1); // Should be "FOO"

With the proposed change this will fail because the output type of upper 
is text and it's no longer mapped to Types.VARCHAR, but LONGVARCHAR, so 
you'll get this exception:

 A CallableStatement Function was executed and the return was of type 
(java.sql.Types=-1) however type=java.sql.Types=12 was registered.


Kris Jurka
   

Attachment: text.patch
Description: Text document



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group