patch: make setObject(...) more consistent about the types it generates

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема patch: make setObject(...) more consistent about the types it generates
Дата
Msg-id 20030722133655.GC11354@opencloud.com
обсуждение исходный текст
Список pgsql-jdbc
The current CVS tree's setObject() doesn't set m_bindTypes correctly in some
cases, which breaks server-side prepares in these cases.

For example, when preparing:

 setObject(n, new Boolean(true), Types.BIT) uses "text" not "boolean"
 setObject(n, new Boolean(true), Types.INTEGER) uses "boolean" not "integer"
 setObject(n, new Integer(true), Types.BIT) uses "text" not "boolean"
 setNull(n, Types.BIT) uses "text" not "boolean"

This then ends up with the server complaining about incompatible types when
preparing the statement.

The attached patch adds testcases for (some of) these cases and fixes
AbstractJdbc1Statement so they pass. I've also modified the Types.BIT case
when given a Number from "value == 1" to "value != 0" which is more
conventional for "number as truth value", and made the strings used as
boolean values in setObject() consistent with those in setBoolean() ('t' /
'f').

IIRC there was some reason for using 't'/'f' for boolean constants in the
driver rather than the currently-recommended TRUE/FALSE, but I can't
remember what .. if there's no reason, it should probably use TRUE/FALSE.

-O

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Patch applied for SQL Injection vulnerability for setObject(int,Object,int)
Следующее
От: Fernando Nasser
Дата:
Сообщение: Re: the IN clause saga