提交 97ab49be 编写于 作者: B Barry Lind

fix for a bug in DatabaseMetaData.getIndexInfo(). This fixes a bug reported...

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
上级 bd39e0c0
...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException; ...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
/** /**
* This class provides information about the database as a whole. * 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 * <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 * can use the normal ResultSet methods such as getString and getInt to
...@@ -2713,7 +2713,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2713,7 +2713,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
"a.amname, " + "a.amname, " +
"x.indkey, " + "x.indkey, " +
"c.reltuples, " + "c.reltuples, " +
"c.relpages " + "c.relpages, " +
"x.indexrelid " +
"FROM pg_index x, pg_class c, pg_class i, pg_am a " + "FROM pg_index x, pg_class c, pg_class i, pg_am a " +
"WHERE ((c.relname = '" + tableName.toLowerCase() + "') " + "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
" AND (c.oid = x.indrelid) " + " AND (c.oid = x.indrelid) " +
...@@ -2747,7 +2748,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2747,7 +2748,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
Integer.toString(tableIndexHashed).getBytes() : Integer.toString(tableIndexHashed).getBytes() :
Integer.toString(tableIndexOther).getBytes(); Integer.toString(tableIndexOther).getBytes();
tuple[7] = Integer.toString(i + 1).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(); columnNameRS.next();
tuple[8] = columnNameRS.getBytes(1); tuple[8] = columnNameRS.getBytes(1);
tuple[9] = null; // sort sequence ??? tuple[9] = null; // sort sequence ???
......
...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException; ...@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
/** /**
* This class provides information about the database as a whole. * 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 * <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 * can use the normal ResultSet methods such as getString and getInt to
...@@ -2716,7 +2716,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2716,7 +2716,8 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
"a.amname, " + "a.amname, " +
"x.indkey, " + "x.indkey, " +
"c.reltuples, " + "c.reltuples, " +
"c.relpages " + "c.relpages, " +
"x.indexrelid " +
"FROM pg_index x, pg_class c, pg_class i, pg_am a " + "FROM pg_index x, pg_class c, pg_class i, pg_am a " +
"WHERE ((c.relname = '" + tableName.toLowerCase() + "') " + "WHERE ((c.relname = '" + tableName.toLowerCase() + "') " +
" AND (c.oid = x.indrelid) " + " AND (c.oid = x.indrelid) " +
...@@ -2750,7 +2751,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData ...@@ -2750,7 +2751,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
Integer.toString(tableIndexHashed).getBytes() : Integer.toString(tableIndexHashed).getBytes() :
Integer.toString(tableIndexOther).getBytes(); Integer.toString(tableIndexOther).getBytes();
tuple[7] = Integer.toString(i + 1).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(); columnNameRS.next();
tuple[8] = columnNameRS.getBytes(1); tuple[8] = columnNameRS.getBytes(1);
tuple[9] = null; // sort sequence ??? tuple[9] = null; // sort sequence ???
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册