Patch submitted by Kris Jurka to fix arrayindexoutofbounds exception caused
authorBarry Lind
Fri, 25 Oct 2002 02:54:37 +0000 (02:54 +0000)
committerBarry Lind
Fri, 25 Oct 2002 02:54:37 +0000 (02:54 +0000)
by improper array initialization.

 Modified Files:
  jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java

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

index 0a0aee92b4b81a24097c7c3a3249a99c4ea3788a..f126b4002e2a744cfc2e7ff9495fbc5e6073cda4 100644 (file)
@@ -1854,7 +1854,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
 
            // decide if we are returning a single column result.
            if (!returnTypeType.equals("c")) {
-               byte[][] tuple = new byte[13][0];
+               byte[][] tuple = new byte[13][];
                tuple[0] = null;
                tuple[1] = schema;
                tuple[2] = procedureName;
@@ -1874,7 +1874,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
            // Add a row for each argument.
            for (int i=0; i
                int argOid = ((Integer)argTypes.elementAt(i)).intValue();
-               byte[][] tuple = new byte[13][0];
+               byte[][] tuple = new byte[13][];
                tuple[0] = null;
                tuple[1] = schema;
                tuple[2] = procedureName;
@@ -1897,7 +1897,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
                ResultSet columnrs = connection.createStatement().executeQuery(columnsql);
                while (columnrs.next()) {
                    int columnTypeOid = columnrs.getInt("atttypid");
-                   byte[][] tuple = new byte[13][0];
+                   byte[][] tuple = new byte[13][];
                    tuple[0] = null;
                    tuple[1] = schema;
                    tuple[2] = procedureName;
@@ -2199,7 +2199,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
        f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, getMaxNameLength());
        for (i=0; i < types.length; i++)
        {
-           byte[][] tuple = new byte[1][0];
+           byte[][] tuple = new byte[1][];
            tuple[0] = types[i].getBytes();
            v.addElement(tuple);
        }
@@ -2318,7 +2318,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
        ResultSet rs = connection.createStatement().executeQuery(sql);
        while (rs.next())
        {
-           byte[][] tuple = new byte[18][0];
+           byte[][] tuple = new byte[18][];
            int typeOid = rs.getInt("atttypid");
 
            tuple[0] = null;                    // Catalog name, not supported
@@ -2329,6 +2329,11 @@ public abstract class AbstractJdbc1DatabaseMetaData
            String pgType = connection.getPGType(typeOid);
            tuple[5] = pgType.getBytes();       // Type name
 
+           // by default no decimal_digits
+           // if the type is numeric or decimal we will
+           // overwrite later.
+           tuple[8] = "0".getBytes();
+
            if (pgType.equals("bpchar") || pgType.equals("varchar"))
            {
                int atttypmod = rs.getInt("atttypmod");
@@ -2465,7 +2470,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
                for (int j=0; j
                    String grantee = (String)grantees.elementAt(j);
                    String grantable = owner.equals(grantee) ? "YES" : "NO";
-                   byte[][] tuple = new byte[8][0];
+                   byte[][] tuple = new byte[8][];
                    tuple[0] = null;
                    tuple[1] = schemaName;
                    tuple[2] = tableName;
@@ -2567,7 +2572,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
                for (int j=0; j
                    String grantee = (String)grantees.elementAt(j);
                    String grantable = owner.equals(grantee) ? "YES" : "NO";
-                   byte[][] tuple = new byte[7][0];
+                   byte[][] tuple = new byte[7][];
                    tuple[0] = null;
                    tuple[1] = schema;
                    tuple[2] = table;
@@ -2819,7 +2824,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
        f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
        f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
 
-       byte tuple[][] = new byte[8][0];
+       byte tuple[][] = new byte[8][];
 
        /* Postgresql does not have any column types that are
         * automatically updated like some databases' timestamp type.