diff options
author | Barry Lind <barry@xythos.com> | 2001-10-30 06:31:59 +0000 |
---|---|---|
committer | Barry Lind <barry@xythos.com> | 2001-10-30 06:31:59 +0000 |
commit | 512a3aef36591386640f34866c1acbe58c20ca6e (patch) | |
tree | f89f9ffd8095135e8acde6e9149c77ef894d97e6 | |
parent | c41b6b1b9cdb51d1e931f6c2cf77a912500c8bef (diff) | |
download | postgresql-512a3aef36591386640f34866c1acbe58c20ca6e.tar.gz postgresql-512a3aef36591386640f34866c1acbe58c20ca6e.zip |
fixed change in behavior introduced in bytea / getBytes changes. This patch reverts back unintentional change in behavior to return raw value even when not bytea column
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java | 50 | ||||
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java | 50 |
2 files changed, 62 insertions, 38 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java index bbde9d5bf91..07d5a998e64 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java @@ -391,31 +391,43 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu if (columnIndex < 1 || columnIndex > fields.length) throw new PSQLException("postgresql.res.colrange"); - //If the data is already binary then just return it - if (binaryCursor) - return this_row[columnIndex - 1]; - - if (connection.haveMinimumCompatibleVersion("7.2")) + wasNullFlag = (this_row[columnIndex - 1] == null); + if (!wasNullFlag) { + if (binaryCursor) + { + //If the data is already binary then just return it + return this_row[columnIndex - 1]; + } + else if (connection.haveMinimumCompatibleVersion("7.2")) + { //Version 7.2 supports the bytea datatype for byte arrays - return PGbytea.toBytes(getString(columnIndex)); - } - else - { + if (fields[columnIndex - 1].getPGType().equals("bytea")) + { + return PGbytea.toBytes(getString(columnIndex)); + } + else + { + return this_row[columnIndex - 1]; + } + } + else + { //Version 7.1 and earlier supports LargeObjects for byte arrays - wasNullFlag = (this_row[columnIndex - 1] == null); // Handle OID's as BLOBS - if (!wasNullFlag) + if ( fields[columnIndex - 1].getOID() == 26) { - if ( fields[columnIndex - 1].getOID() == 26) - { - LargeObjectManager lom = connection.getLargeObjectAPI(); - LargeObject lob = lom.open(getInt(columnIndex)); - byte buf[] = lob.read(lob.size()); - lob.close(); - return buf; - } + LargeObjectManager lom = connection.getLargeObjectAPI(); + LargeObject lob = lom.open(getInt(columnIndex)); + byte buf[] = lob.read(lob.size()); + lob.close(); + return buf; + } + else + { + return this_row[columnIndex - 1]; } + } } return null; } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java index cd941d2179e..4c2c61ce043 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java @@ -318,31 +318,43 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu if (columnIndex < 1 || columnIndex > fields.length) throw new PSQLException("postgresql.res.colrange"); - //If the data is already binary then just return it - if (binaryCursor) - return this_row[columnIndex - 1]; - - if (connection.haveMinimumCompatibleVersion("7.2")) + wasNullFlag = (this_row[columnIndex - 1] == null); + if (!wasNullFlag) { + if (binaryCursor) + { + //If the data is already binary then just return it + return this_row[columnIndex - 1]; + } + else if (connection.haveMinimumCompatibleVersion("7.2")) + { //Version 7.2 supports the bytea datatype for byte arrays - return PGbytea.toBytes(getString(columnIndex)); - } - else - { + if (fields[columnIndex - 1].getPGType().equals("bytea")) + { + return PGbytea.toBytes(getString(columnIndex)); + } + else + { + return this_row[columnIndex - 1]; + } + } + else + { //Version 7.1 and earlier supports LargeObjects for byte arrays - wasNullFlag = (this_row[columnIndex - 1] == null); // Handle OID's as BLOBS - if (!wasNullFlag) + if ( fields[columnIndex - 1].getOID() == 26) { - if ( fields[columnIndex - 1].getOID() == 26) - { - LargeObjectManager lom = connection.getLargeObjectAPI(); - LargeObject lob = lom.open(getInt(columnIndex)); - byte buf[] = lob.read(lob.size()); - lob.close(); - return buf; - } + LargeObjectManager lom = connection.getLargeObjectAPI(); + LargeObject lob = lom.open(getInt(columnIndex)); + byte buf[] = lob.read(lob.size()); + lob.close(); + return buf; + } + else + { + return this_row[columnIndex - 1]; } + } } return null; } |