]> granicus.if.org Git - postgresql/commitdiff
Patch from Cormac Twomey
authorDave Cramer <davec@fastcrypt.com>
Fri, 22 Feb 2002 02:40:09 +0000 (02:40 +0000)
committerDave Cramer <davec@fastcrypt.com>
Fri, 22 Feb 2002 02:40:09 +0000 (02:40 +0000)
fixes getIndexInfo throwing NullPointerException
fixes getIndexInfo improper results when multiple key indexs are used

src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java

index f9907e92df822310384433e9eb17618a82ceab3f..8bc6015f9d4e3da1e06d691cf8cc2c2f8a5ee9d0 100644 (file)
@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
 /*
  * This class provides information about the database as a whole.
  *
- * $Id: DatabaseMetaData.java,v 1.41 2002/01/18 17:21:51 davec Exp $
+ * $Id: DatabaseMetaData.java,v 1.42 2002/02/22 02:40:09 davec Exp $
  *
  * <p>Many of the methods here return lists of information in ResultSets.  You
  * can use the normal ResultSet methods such as getString and getInt to
@@ -2791,13 +2791,14 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
                        {
                                columnOrdinals[o++] = Integer.parseInt(stok.nextToken());
                        }
+                       java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE a.attrelid = " + r.getInt(9));
                        for (int i = 0; i < columnOrdinals.length; i++)
                        {
                                byte [] [] tuple = new byte [13] [];
                                tuple[0] = "".getBytes();
                                tuple[1] = "".getBytes();
                                tuple[2] = r.getBytes(1);
-                               tuple[3] = r.getBoolean(2) ? "f".getBytes() : "t".getBytes();
+                               tuple[3] = r.getBoolean(2) ? "false".getBytes() : "true".getBytes();
                                tuple[4] = null;
                                tuple[5] = r.getBytes(3);
                                tuple[6] = r.getBoolean(4) ?
@@ -2806,9 +2807,14 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
                                                   Integer.toString(tableIndexHashed).getBytes() :
                                                   Integer.toString(tableIndexOther).getBytes();
                                tuple[7] = Integer.toString(i + 1).getBytes();
-                               java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(9) + ")");
-                               columnNameRS.next();
-                               tuple[8] = columnNameRS.getBytes(1);
+                               if (columnNameRS.next())
+                               {
+                                       tuple[8] = columnNameRS.getBytes(1);
+                               }
+                               else
+                               {
+                                       tuple[8] = "".getBytes();
+                               }
                                tuple[9] = null;  // sort sequence ???
                                tuple[10] = r.getBytes(7);      // inexact
                                tuple[11] = r.getBytes(8);