Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 97ab49b

Browse files
author
Barry Lind
committed
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
1 parent bd39e0c commit 97ab49b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* This class provides information about the database as a whole.
1515
*
16-
* $Id: DatabaseMetaData.java,v 1.33 2001/09/29 03:08:01 momjian Exp $
16+
* $Id: DatabaseMetaData.java,v 1.34 2001/10/24 04:31:48 barry Exp $
1717
*
1818
* <p>Many of the methods here return lists of information in ResultSets. You
1919
* can use the normal ResultSet methods such as getString and getInt to
@@ -2713,7 +2713,8 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
27132713
"a.amname, " +
27142714
"x.indkey, " +
27152715
"c.reltuples, " +
2716-
"c.relpages " +
2716+
"c.relpages, " +
2717+
"x.indexrelid " +
27172718
"FROM pg_index x, pg_class c, pg_class i, pg_am a " +
27182719
"WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
27192720
" AND (c.oid = x.indrelid) " +
@@ -2747,7 +2748,7 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
27472748
Integer.toString(tableIndexHashed).getBytes() :
27482749
Integer.toString(tableIndexOther).getBytes();
27492750
tuple[7] = Integer.toString(i + 1).getBytes();
2750-
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) + ")");
2751+
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(9) + ")");
27512752
columnNameRS.next();
27522753
tuple[8] = columnNameRS.getBytes(1);
27532754
tuple[9] = null; // sort sequence ???

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* This class provides information about the database as a whole.
1515
*
16-
* $Id: DatabaseMetaData.java,v 1.37 2001/09/29 03:08:01 momjian Exp $
16+
* $Id: DatabaseMetaData.java,v 1.38 2001/10/24 04:31:50 barry Exp $
1717
*
1818
* <p>Many of the methods here return lists of information in ResultSets. You
1919
* can use the normal ResultSet methods such as getString and getInt to
@@ -2716,7 +2716,8 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
27162716
"a.amname, " +
27172717
"x.indkey, " +
27182718
"c.reltuples, " +
2719-
"c.relpages " +
2719+
"c.relpages, " +
2720+
"x.indexrelid " +
27202721
"FROM pg_index x, pg_class c, pg_class i, pg_am a " +
27212722
"WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
27222723
" AND (c.oid = x.indrelid) " +
@@ -2750,7 +2751,7 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
27502751
Integer.toString(tableIndexHashed).getBytes() :
27512752
Integer.toString(tableIndexOther).getBytes();
27522753
tuple[7] = Integer.toString(i + 1).getBytes();
2753-
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) + ")");
2754+
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(9) + ")");
27542755
columnNameRS.next();
27552756
tuple[8] = columnNameRS.getBytes(1);
27562757
tuple[9] = null; // sort sequence ???

0 commit comments

Comments
 (0)