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.26 diff -c -r1.26 AbstractJdbc1DatabaseMetaData.java *** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java 3 Nov 2003 15:22:07 -0000 1.26 --- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java 4 Nov 2003 04:03:59 -0000 *************** *** 5,10 **** --- 5,11 ---- import java.util.*; import org.postgresql.core.BaseStatement; import org.postgresql.core.Field; + import org.postgresql.core.Encoding; import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLState; import org.postgresql.Driver; *************** *** 22,27 **** --- 23,29 ---- "vacuum,verbose,version"; protected AbstractJdbc1Connection connection; // The connection association + protected Encoding encoding; // These define various OID's. Hopefully they will stay constant. protected static final int iVarcharOid = 1043; // OID for varchar *************** *** 70,78 **** return NAMEDATALEN - 1; } ! public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn) { this.connection = conn; } /* --- 72,81 ---- return NAMEDATALEN - 1; } ! public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn) throws SQLException { this.connection = conn; + this.encoding = conn.getEncoding(); } /* *************** *** 1858,1872 **** tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = "returnValue".getBytes(); ! tuple[4] = Integer.toString(java.sql.DatabaseMetaData.procedureColumnReturn).getBytes(); ! tuple[5] = Integer.toString(connection.getSQLType(returnType)).getBytes(); ! tuple[6] = connection.getPGType(returnType).getBytes(); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown).getBytes(); tuple[12] = null; v.addElement(tuple); } --- 1861,1875 ---- tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = encoding.encode("returnValue"); ! tuple[4] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureColumnReturn)); ! tuple[5] = encoding.encode(Integer.toString(connection.getSQLType(returnType))); ! tuple[6] = encoding.encode(connection.getPGType(returnType)); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown)); tuple[12] = null; v.addElement(tuple); } *************** *** 1878,1892 **** tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = ("$"+(i+1)).getBytes(); ! tuple[4] = Integer.toString(java.sql.DatabaseMetaData.procedureColumnIn).getBytes(); ! tuple[5] = Integer.toString(connection.getSQLType(argOid)).getBytes(); ! tuple[6] = connection.getPGType(argOid).getBytes(); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown).getBytes(); tuple[12] = null; v.addElement(tuple); } --- 1881,1895 ---- tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = encoding.encode("$"+(i+1)); ! tuple[4] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureColumnIn)); ! tuple[5] = encoding.encode(Integer.toString(connection.getSQLType(argOid))); ! tuple[6] = encoding.encode(connection.getPGType(argOid)); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown)); tuple[12] = null; v.addElement(tuple); } *************** *** 1901,1915 **** tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = columnrs.getString("attname").getBytes(); ! tuple[4] = Integer.toString(java.sql.DatabaseMetaData.procedureColumnResult).getBytes(); ! tuple[5] = Integer.toString(connection.getSQLType(columnTypeOid)).getBytes(); ! tuple[6] = connection.getPGType(columnTypeOid).getBytes(); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown).getBytes(); tuple[12] = null; v.addElement(tuple); } --- 1904,1918 ---- tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = columnrs.getBytes("attname"); ! tuple[4] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureColumnResult)); ! tuple[5] = encoding.encode(Integer.toString(connection.getSQLType(columnTypeOid))); ! tuple[6] = encoding.encode(connection.getPGType(columnTypeOid)); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = encoding.encode(Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown)); tuple[12] = null; v.addElement(tuple); } *************** *** 2205,2211 **** for (i=0; i < types.length; i++) { byte[][] tuple = new byte[1][]; ! tuple[0] = types[i].getBytes(); v.addElement(tuple); } --- 2208,2214 ---- for (i=0; i < types.length; i++) { byte[][] tuple = new byte[1][]; ! tuple[0] = encoding.encode(types[i]); v.addElement(tuple); } *************** *** 2338,2383 **** tuple[1] = rs.getBytes("nspname"); // Schema tuple[2] = rs.getBytes("relname"); // Table name tuple[3] = rs.getBytes("attname"); // Column name ! tuple[4] = Integer.toString(connection.getSQLType(typeOid)).getBytes(); 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"); ! tuple[6] = Integer.toString(atttypmod != -1 ? atttypmod - VARHDRSZ : 0).getBytes(); } else if (pgType.equals("numeric") || pgType.equals("decimal")) { int attypmod = rs.getInt("atttypmod") - VARHDRSZ; ! tuple[6] = Integer.toString( ( attypmod >> 16 ) & 0xffff ).getBytes(); ! tuple[8] = Integer.toString(attypmod & 0xffff).getBytes(); ! tuple[9] = "10".getBytes(); } else if (pgType.equals("bit") || pgType.equals("varbit")) { tuple[6] = rs.getBytes("atttypmod"); ! tuple[9] = "2".getBytes(); } else { tuple[6] = rs.getBytes("attlen"); ! tuple[9] = "10".getBytes(); } tuple[7] = null; // Buffer length ! tuple[10] = Integer.toString(rs.getBoolean("attnotnull") ? java.sql.DatabaseMetaData.columnNoNulls : java.sql.DatabaseMetaData.columnNullable).getBytes(); // Nullable tuple[11] = rs.getBytes("description"); // Description (if any) tuple[12] = rs.getBytes("adsrc"); // Column default tuple[13] = null; // sql data type (unused) tuple[14] = null; // sql datetime sub (unused) tuple[15] = tuple[6]; // char octet length tuple[16] = rs.getBytes("attnum"); // ordinal position ! tuple[17] = (rs.getBoolean("attnotnull") ? "NO" : "YES").getBytes(); // Is nullable v.addElement(tuple); } --- 2341,2386 ---- tuple[1] = rs.getBytes("nspname"); // Schema tuple[2] = rs.getBytes("relname"); // Table name tuple[3] = rs.getBytes("attname"); // Column name ! tuple[4] = encoding.encode(Integer.toString(connection.getSQLType(typeOid))); String pgType = connection.getPGType(typeOid); ! tuple[5] = encoding.encode(pgType); // Type name // by default no decimal_digits // if the type is numeric or decimal we will // overwrite later. ! tuple[8] = encoding.encode("0"); if (pgType.equals("bpchar") || pgType.equals("varchar")) { int atttypmod = rs.getInt("atttypmod"); ! tuple[6] = encoding.encode(Integer.toString(atttypmod != -1 ? atttypmod - VARHDRSZ : 0)); } else if (pgType.equals("numeric") || pgType.equals("decimal")) { int attypmod = rs.getInt("atttypmod") - VARHDRSZ; ! tuple[6] = encoding.encode(Integer.toString( ( attypmod >> 16 ) & 0xffff )); ! tuple[8] = encoding.encode(Integer.toString(attypmod & 0xffff)); ! tuple[9] = encoding.encode("10"); } else if (pgType.equals("bit") || pgType.equals("varbit")) { tuple[6] = rs.getBytes("atttypmod"); ! tuple[9] = encoding.encode("2"); } else { tuple[6] = rs.getBytes("attlen"); ! tuple[9] = encoding.encode("10"); } tuple[7] = null; // Buffer length ! tuple[10] = encoding.encode(Integer.toString(rs.getBoolean("attnotnull") ? java.sql.DatabaseMetaData.columnNoNulls : java.sql.DatabaseMetaData.columnNullable)); // Nullable tuple[11] = rs.getBytes("description"); // Description (if any) tuple[12] = rs.getBytes("adsrc"); // Column default tuple[13] = null; // sql data type (unused) tuple[14] = null; // sql datetime sub (unused) tuple[15] = tuple[6]; // char octet length tuple[16] = rs.getBytes("attnum"); // ordinal position ! tuple[17] = encoding.encode(rs.getBoolean("attnotnull") ? "NO" : "YES"); // Is nullable v.addElement(tuple); } *************** *** 2476,2482 **** } sortStringArray(permNames); for (i=0; i