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

Skip to content

Commit 7ab25ff

Browse files
author
Barry Lind
committed
Patch submitted by Kris Jurka to fix arrayindexoutofbounds exception caused
by improper array initialization. Modified Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
1 parent fc5c577 commit 7ab25ff

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPatte
18541854

18551855
// decide if we are returning a single column result.
18561856
if (!returnTypeType.equals("c")) {
1857-
byte[][] tuple = new byte[13][0];
1857+
byte[][] tuple = new byte[13][];
18581858
tuple[0] = null;
18591859
tuple[1] = schema;
18601860
tuple[2] = procedureName;
@@ -1874,7 +1874,7 @@ public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPatte
18741874
// Add a row for each argument.
18751875
for (int i=0; i<argTypes.size(); i++) {
18761876
int argOid = ((Integer)argTypes.elementAt(i)).intValue();
1877-
byte[][] tuple = new byte[13][0];
1877+
byte[][] tuple = new byte[13][];
18781878
tuple[0] = null;
18791879
tuple[1] = schema;
18801880
tuple[2] = procedureName;
@@ -1897,7 +1897,7 @@ public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPatte
18971897
ResultSet columnrs = connection.createStatement().executeQuery(columnsql);
18981898
while (columnrs.next()) {
18991899
int columnTypeOid = columnrs.getInt("atttypid");
1900-
byte[][] tuple = new byte[13][0];
1900+
byte[][] tuple = new byte[13][];
19011901
tuple[0] = null;
19021902
tuple[1] = schema;
19031903
tuple[2] = procedureName;
@@ -2199,7 +2199,7 @@ public java.sql.ResultSet getTableTypes() throws SQLException
21992199
f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, getMaxNameLength());
22002200
for (i=0; i < types.length; i++)
22012201
{
2202-
byte[][] tuple = new byte[1][0];
2202+
byte[][] tuple = new byte[1][];
22032203
tuple[0] = types[i].getBytes();
22042204
v.addElement(tuple);
22052205
}
@@ -2318,7 +2318,7 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
23182318
ResultSet rs = connection.createStatement().executeQuery(sql);
23192319
while (rs.next())
23202320
{
2321-
byte[][] tuple = new byte[18][0];
2321+
byte[][] tuple = new byte[18][];
23222322
int typeOid = rs.getInt("atttypid");
23232323

23242324
tuple[0] = null; // Catalog name, not supported
@@ -2329,6 +2329,11 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
23292329
String pgType = connection.getPGType(typeOid);
23302330
tuple[5] = pgType.getBytes(); // Type name
23312331

2332+
// by default no decimal_digits
2333+
// if the type is numeric or decimal we will
2334+
// overwrite later.
2335+
tuple[8] = "0".getBytes();
2336+
23322337
if (pgType.equals("bpchar") || pgType.equals("varchar"))
23332338
{
23342339
int atttypmod = rs.getInt("atttypmod");
@@ -2465,7 +2470,7 @@ public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, Str
24652470
for (int j=0; j<grantees.size(); j++) {
24662471
String grantee = (String)grantees.elementAt(j);
24672472
String grantable = owner.equals(grantee) ? "YES" : "NO";
2468-
byte[][] tuple = new byte[8][0];
2473+
byte[][] tuple = new byte[8][];
24692474
tuple[0] = null;
24702475
tuple[1] = schemaName;
24712476
tuple[2] = tableName;
@@ -2567,7 +2572,7 @@ public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPatter
25672572
for (int j=0; j<grantees.size(); j++) {
25682573
String grantee = (String)grantees.elementAt(j);
25692574
String grantable = owner.equals(grantee) ? "YES" : "NO";
2570-
byte[][] tuple = new byte[7][0];
2575+
byte[][] tuple = new byte[7][];
25712576
tuple[0] = null;
25722577
tuple[1] = schema;
25732578
tuple[2] = table;
@@ -2819,7 +2824,7 @@ public java.sql.ResultSet getVersionColumns(String catalog, String schema, Strin
28192824
f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
28202825
f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
28212826

2822-
byte tuple[][] = new byte[8][0];
2827+
byte tuple[][] = new byte[8][];
28232828

28242829
/* Postgresql does not have any column types that are
28252830
* automatically updated like some databases' timestamp type.

0 commit comments

Comments
 (0)