db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Schneider <bschnei...@vecna.com>
Subject more on BLOB/OID with Torque and postgresql
Date Mon, 03 Feb 2003 04:13:21 GMT
I looked into this in more detail and it turns out that if you patch the
PostgreSQL JDBC driver to return VARBINARY for "oid" columns as documented,
things still break even though the village Record class is calling

It looks like the most recent versions of the PostgreSQL driver (7.2+) don't
support setBytes(int, byte[]) as a mechanism for setting the content of an
OID column anymore.  Instead, the driver code appears to make the assumption
that, if you're calling setBytes, you must be dealing with a "bytea" column
instead, which does work with Torque.

The code in question is in org.postgresql.jdbc1.AbstractJdbc1Statement:,
whose logic boils down to something like this:

public void setBytes(int i, byte[] x) {
  if (7.2 or higher) {
    setString(i, convert-to-string(x));
    // correct behavior if column is really a "bytea" but breaks if column
is an "oid";
    // if column is an oid, tries to parse x as the oid instead of the
large-object content
  } else {
    create new LOB and write x to it;
    setInt(i, OID of new LOB)
    // correct behavior if column is an "oid" but would break if is a bytea

Further discussions on the subject probably belong on the pgsql-jdbc mailing
list instead.

-- Bill

View raw message