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

Commit deaad93

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 0786c61 commit deaad93

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 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.41 2002/01/18 17:21:51 davec Exp $
16+
* $Id: DatabaseMetaData.java,v 1.42 2002/02/22 02:40:09 davec 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
@@ -2791,13 +2791,14 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
27912791
{
27922792
columnOrdinals[o++] = Integer.parseInt(stok.nextToken());
27932793
}
2794+
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE a.attrelid = " + r.getInt(9));
27942795
for (int i = 0; i < columnOrdinals.length; i++)
27952796
{
27962797
byte [] [] tuple = new byte [13] [];
27972798
tuple[0] = "".getBytes();
27982799
tuple[1] = "".getBytes();
27992800
tuple[2] = r.getBytes(1);
2800-
tuple[3] = r.getBoolean(2) ? "f".getBytes() : "t".getBytes();
2801+
tuple[3] = r.getBoolean(2) ? "false".getBytes() : "true".getBytes();
28012802
tuple[4] = null;
28022803
tuple[5] = r.getBytes(3);
28032804
tuple[6] = r.getBoolean(4) ?
@@ -2806,9 +2807,14 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
28062807
Integer.toString(tableIndexHashed).getBytes() :
28072808
Integer.toString(tableIndexOther).getBytes();
28082809
tuple[7] = Integer.toString(i + 1).getBytes();
2809-
java.sql.ResultSet columnNameRS = connection.ExecSQL("select a.attname FROM pg_attribute a WHERE (a.attnum = " + columnOrdinals[i] + ") AND (a.attrelid = " + r.getInt(9) + ")");
2810-
columnNameRS.next();
2811-
tuple[8] = columnNameRS.getBytes(1);
2810+
if (columnNameRS.next())
2811+
{
2812+
tuple[8] = columnNameRS.getBytes(1);
2813+
}
2814+
else
2815+
{
2816+
tuple[8] = "".getBytes();
2817+
}
28122818
tuple[9] = null; // sort sequence ???
28132819
tuple[10] = r.getBytes(7); // inexact
28142820
tuple[11] = r.getBytes(8);

0 commit comments

Comments
 (0)