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

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Bug in 7.4_213 driver: returns VARCHAR instead of
Дата
Msg-id Pine.BSO.4.56.0407291519090.12809@leary.csoft.net
обсуждение исходный текст
Ответ на Bug in 7.4_213 driver: returns VARCHAR instead of LONGVARCHAR for text types  ("j.random.programmer" <javadesigner@yahoo.com>)
Ответы Re: Bug in 7.4_213 driver: returns VARCHAR instead of  (Kris Jurka <books@ejurka.com>)
Список 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


Вложения

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Mike Martin"
Дата:
Сообщение: Re: Wrong column names in ResultSetMetaData
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: Wrong column names in ResultSetMetaData