Re: Bug in 7.4_213 driver: returns VARCHAR instead of - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Bug in 7.4_213 driver: returns VARCHAR instead of
Date
Msg-id Pine.BSO.4.56.0407291519090.12809@leary.csoft.net
Whole thread Raw
In response to Bug in 7.4_213 driver: returns VARCHAR instead of LONGVARCHAR for text types  ("j.random.programmer" <javadesigner@yahoo.com>)
Responses Re: Bug in 7.4_213 driver: returns VARCHAR instead of
List pgsql-jdbc

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

pgsql-jdbc by date:

Previous
From: "Mike Martin"
Date:
Subject: Re: Wrong column names in ResultSetMetaData
Next
From: Kris Jurka
Date:
Subject: Re: Wrong column names in ResultSetMetaData