From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | patch: make setObject(...) more consistent about the types it generates |
Date: | 2003-07-22 13:36:56 |
Message-ID: | 20030722133655.GC11354@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
pgsql-wrong_bound_types.txt | text/plain | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2003-07-22 13:39:09 | Re: Patch applied for SQL Injection vulnerability for setObject(int, Object, int) |
Previous Message | Tom Lane | 2003-07-22 13:33:53 | Re: Patch applied for SQL Injection vulnerability for setObject(int, Object, int) |