Re: AbstractJdbc1DatabaseMetaData.getColumns doesn't set DECIMAL_DIGITS
От | Barry Lind |
---|---|
Тема | Re: AbstractJdbc1DatabaseMetaData.getColumns doesn't set DECIMAL_DIGITS |
Дата | |
Msg-id | 3DB6C961.1070603@xythos.com обсуждение исходный текст |
Ответ на | AbstractJdbc1DatabaseMetaData.getColumns doesn't set DECIMAL_DIGITS (Florian Wunderlich <fwunderlich@devbrain.de>) |
Список | pgsql-jdbc |
Florian, I think this should be fixed by a patch that Kris Jurka submitted yesterday. I haven't had a chance to apply the patch yet, but I have included it here if you want to try it out before it gets applied to CVS. thanks, --Barry Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java,v retrieving revision 1.8 diff -c -r1.8 AbstractJdbc1DatabaseMetaData.java *** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java 2002/10/08 01:47:55 1.8 --- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java 2002/10/22 21:00:52 *************** *** 1854,1860 **** // decide if we are returning a single column result. if (!returnTypeType.equals("c")) { ! byte[][] tuple = new byte[13][0]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; --- 1854,1860 ---- // decide if we are returning a single column result. if (!returnTypeType.equals("c")) { ! byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; *************** *** 1874,1880 **** // Add a row for each argument. for (int i=0; i<argTypes.size(); i++) { int argOid = ((Integer)argTypes.elementAt(i)).intValue(); ! byte[][] tuple = new byte[13][0]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; --- 1874,1880 ---- // Add a row for each argument. for (int i=0; i<argTypes.size(); i++) { int argOid = ((Integer)argTypes.elementAt(i)).intValue(); ! byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; *************** *** 1897,1903 **** ResultSet columnrs = connection.createStatement().executeQuery(columnsql); while (columnrs.next()) { int columnTypeOid = columnrs.getInt("atttypid"); ! byte[][] tuple = new byte[13][0]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; --- 1897,1903 ---- ResultSet columnrs = connection.createStatement().executeQuery(columnsql); while (columnrs.next()) { int columnTypeOid = columnrs.getInt("atttypid"); ! byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; *************** *** 2199,2205 **** f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, getMaxNameLength()); for (i=0; i < types.length; i++) { ! byte[][] tuple = new byte[1][0]; tuple[0] = types[i].getBytes(); v.addElement(tuple); } --- 2199,2205 ---- f[0] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, getMaxNameLength()); for (i=0; i < types.length; i++) { ! byte[][] tuple = new byte[1][]; tuple[0] = types[i].getBytes(); v.addElement(tuple); } *************** *** 2318,2324 **** ResultSet rs = connection.createStatement().executeQuery(sql); while (rs.next()) { ! byte[][] tuple = new byte[18][0]; int typeOid = rs.getInt("atttypid"); tuple[0] = null; // Catalog name, not supported --- 2318,2324 ---- ResultSet rs = connection.createStatement().executeQuery(sql); while (rs.next()) { ! byte[][] tuple = new byte[18][]; int typeOid = rs.getInt("atttypid"); tuple[0] = null; // Catalog name, not supported *************** *** 2329,2334 **** --- 2329,2339 ---- 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,2471 **** for (int j=0; j<grantees.size(); j++) { String grantee = (String)grantees.elementAt(j); String grantable = owner.equals(grantee) ? "YES" : "NO"; ! byte[][] tuple = new byte[8][0]; tuple[0] = null; tuple[1] = schemaName; tuple[2] = tableName; --- 2470,2476 ---- for (int j=0; j<grantees.size(); j++) { String grantee = (String)grantees.elementAt(j); String grantable = owner.equals(grantee) ? "YES" : "NO"; ! byte[][] tuple = new byte[8][]; tuple[0] = null; tuple[1] = schemaName; tuple[2] = tableName; *************** *** 2567,2573 **** for (int j=0; j<grantees.size(); j++) { String grantee = (String)grantees.elementAt(j); String grantable = owner.equals(grantee) ? "YES" : "NO"; ! byte[][] tuple = new byte[7][0]; tuple[0] = null; tuple[1] = schema; tuple[2] = table; --- 2572,2578 ---- for (int j=0; j<grantees.size(); j++) { String grantee = (String)grantees.elementAt(j); String grantable = owner.equals(grantee) ? "YES" : "NO"; ! byte[][] tuple = new byte[7][]; tuple[0] = null; tuple[1] = schema; tuple[2] = table; *************** *** 2819,2825 **** f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2); f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2); ! byte tuple[][] = new byte[8][0]; /* Postgresql does not have any column types that are * automatically updated like some databases' timestamp type. --- 2824,2830 ---- f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2); f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2); ! byte tuple[][] = new byte[8][]; /* Postgresql does not have any column types that are * automatically updated like some databases' timestamp type. Florian Wunderlich wrote: > In the CVS, getColumns in AbstractJdbc1DatabaseMetaData.java:2257 does > not set DECIMAL_DIGITS for types other than "numeric" and "decimal". > > A subsequent ResultSet.getInt for this column then fails with a > java.lang.StringIndexOutOfBoundsException. > > The JDBC API documentation seems to indicate that this field should > always be an int. In any case, ResultSet.getInt should not fail. > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html >
В списке pgsql-jdbc по дате отправления:
Предыдущее
От: "Narayan Murthy K S"Дата:
Сообщение: Re: getArray/setArray - desperately need to know how the