patch: make setObject(...) more consistent about the types it generates - Mailing list pgsql-jdbc

From Oliver Jowett
Subject patch: make setObject(...) more consistent about the types it generates
Date
Msg-id 20030722133655.GC11354@opencloud.com
Whole thread Raw
List 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

Attachment

pgsql-jdbc by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch applied for SQL Injection vulnerability for setObject(int,Object,int)
Next
From: Fernando Nasser
Date:
Subject: Re: the IN clause saga