]> granicus.if.org Git - postgresql/commitdiff
Attached is a patch which deals with
authorBruce Momjian <bruce@momjian.us>
Thu, 4 Oct 2001 15:46:49 +0000 (15:46 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 4 Oct 2001 15:46:49 +0000 (15:46 +0000)
select 'id' as xxx from table

The issue is:

When the driver gets a data type which does not map into the SQL.Types
it attempts to load the object into a java object. Eventually throwing
an exception indicating that the type "unknown" was not found.

Since the backend defaults "unknown" types to text it was suggested that
the jdbc driver do the same.

This patch does just that.

I have tested it on the above select statement as well as a small
program that serializes, and deserializes a class

Dave Cramer

src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

index 8949eabc75b114192d2a429754f862534914c110..eecce9c939cd371a47dc694d6904df5494a61637 100644 (file)
@@ -862,7 +862,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
       case Types.VARBINARY:
        return getBytes(columnIndex);   
       default:
-        return connection.getObject(field.getPGType(), getString(columnIndex));
+        String type = field.getPGType();
+        // if the backend doesn't know the type then coerce to String
+        if (type.equals("unknown")){
+           return getString(columnIndex);
+        }else{
+           return connection.getObject(field.getPGType(), getString(columnIndex));
+        }
       }
   }
   
index 9df669910daf71c2f507f3541d6707b65d41fc0e..feec8d08c26b2bfa2f1d27bf07f5d04ea23d1b37 100644 (file)
@@ -727,7 +727,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
       case Types.VARBINARY:
        return getBytes(columnIndex);   
       default:
-        return connection.getObject(field.getPGType(), getString(columnIndex));
+        String type = field.getPGType();
+        // if the backend doesn't know the type then coerce to String
+        if (type.equals("unknown")){
+           return getString(columnIndex);
+        }else{
+           return connection.getObject(field.getPGType(), getString(columnIndex));
+        }
       }
   }