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

This commit is contained in:
Barry Lind 2001-10-24 04:31:50 +00:00
parent bd39e0c0d7
commit 97ab49beb0
2 changed files with 8 additions and 6 deletions

View 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.33 2001/09/29 03:08:01 momjian Exp $
* $Id: DatabaseMetaData.java,v 1.34 2001/10/24 04:31:48 barry 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
@ -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 ???

View 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.37 2001/09/29 03:08:01 momjian Exp $
* $Id: DatabaseMetaData.java,v 1.38 2001/10/24 04:31:50 barry 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
@ -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 ???