From 97ab49beb02e73c4e29eab21edefd887183496ad Mon Sep 17 00:00:00 2001 From: Barry Lind Date: Wed, 24 Oct 2001 04:31:50 +0000 Subject: [PATCH] fix for a bug in DatabaseMetaData.getIndexInfo(). This fixes a bug reported by tom_falconer@lineone.net. On Sept 7th, he sent a test case to the list demonstrating the bug. His test case now works successfully with this patch --- .../jdbc/org/postgresql/jdbc1/DatabaseMetaData.java | 7 ++++--- .../jdbc/org/postgresql/jdbc2/DatabaseMetaData.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java index a9d34bcc44..3b24aebc0a 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java @@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException; /** * This class provides information about the database as a whole. * - * $Id: DatabaseMetaData.java,v 1.33 2001/09/29 03:08:01 momjian Exp $ + * $Id: DatabaseMetaData.java,v 1.34 2001/10/24 04:31:48 barry Exp $ * *

Many of the methods here return lists of information in ResultSets. You * can use the normal ResultSet methods such as getString and getInt to @@ -2713,7 +2713,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData "a.amname, " + "x.indkey, " + "c.reltuples, " + - "c.relpages " + + "c.relpages, " + + "x.indexrelid " + "FROM pg_index x, pg_class c, pg_class i, pg_am a " + "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " + " AND (c.oid = x.indrelid) " + @@ -2747,7 +2748,7 @@ 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, pg_class c WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(8) + ")"); + 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); tuple[9] = null; // sort sequence ??? diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java index e6f558fb55..6cb522466c 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java @@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException; /** * This class provides information about the database as a whole. * - * $Id: DatabaseMetaData.java,v 1.37 2001/09/29 03:08:01 momjian Exp $ + * $Id: DatabaseMetaData.java,v 1.38 2001/10/24 04:31:50 barry Exp $ * *

Many of the methods here return lists of information in ResultSets. You * can use the normal ResultSet methods such as getString and getInt to @@ -2716,7 +2716,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData "a.amname, " + "x.indkey, " + "c.reltuples, " + - "c.relpages " + + "c.relpages, " + + "x.indexrelid " + "FROM pg_index x, pg_class c, pg_class i, pg_am a " + "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " + " AND (c.oid = x.indrelid) " + @@ -2750,7 +2751,7 @@ 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, pg_class c WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(8) + ")"); + 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); tuple[9] = null; // sort sequence ??? -- 2.40.0