]> granicus.if.org Git - postgresql/commitdiff
fixed change in behavior introduced in bytea / getBytes changes. This patch reverts...
authorBarry Lind <barry@xythos.com>
Tue, 30 Oct 2001 06:31:59 +0000 (06:31 +0000)
committerBarry Lind <barry@xythos.com>
Tue, 30 Oct 2001 06:31:59 +0000 (06:31 +0000)
src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

index bbde9d5bf9122786ca774199450480528bebeac6..07d5a998e64841b65f8e2edf33569a6bef944d29 100644 (file)
@@ -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;
        }
index cd941d2179ebc2f362106d1a3202190e70fff5c9..4c2c61ce043562e104235b30b2730fa297c7d7a7 100644 (file)
@@ -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;
        }