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

From: Kris Jurka <books(at)ejurka(dot)com>
To: "j(dot)random(dot)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: 2004-07-29 21:33:23
Message-ID: Pine.BSO.4.56.0407291519090.12809@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
text.patch text/plain 11.3 KB

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-07-29 21:41:49 Re: Wrong column names in ResultSetMetaData
Previous Message Kris Jurka 2004-07-29 18:23:46 Re: PreparedStatement.getMetaData() and Creator