Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0786c61

Browse files
author
Dave Cramer
committed
Patch from Cormac Twomey
fixes getIndexInfo throwing NullPointerException fixes getIndexInfo improper results when multiple key indexs are used
1 parent 178961a commit 0786c61

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/*
1616
* This class provides information about the database as a whole.
1717
*
18-
* $Id: DatabaseMetaData.java,v 1.48 2002/01/18 17:21:31 davec Exp $
18+
* $Id: DatabaseMetaData.java,v 1.49 2002/02/22 02:17:13 davec Exp $
1919
*
2020
* <p>Many of the methods here return lists of information in ResultSets. You
2121
* can use the normal ResultSet methods such as getString and getInt to
@@ -2919,6 +2919,8 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
29192919
{
29202920
columnOrdinals[o++] = Integer.parseInt(stok.nextToken());
29212921
}
2922+
2923+
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE a.attrelid = " + r.getInt(9));
29222924
for (int i = 0; i < columnOrdinals.length; i++)
29232925
{
29242926
byte [] [] tuple = new byte [13] [];
@@ -2934,12 +2936,11 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
29342936
Integer.toString(tableIndexHashed).getBytes() :
29352937
Integer.toString(tableIndexOther).getBytes();
29362938
tuple[7] = Integer.toString(i + 1).getBytes();
2937-
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(9) + ")");
29382939
if (columnNameRS.next())
29392940
tuple[8] = columnNameRS.getBytes(1);
29402941
else
29412942
tuple[8] = "".getBytes();
2942-
tuple[8] = columnNameRS.getBytes(1);
2943+
29432944
tuple[9] = null; // sort sequence ???
29442945
tuple[10] = r.getBytes(7); // inexact
29452946
tuple[11] = r.getBytes(8);

0 commit comments

Comments
 (0)