tuple[3] = encodeString("returnValue"); tuple[4] = encodeString(Integer .toString(java.sql.DatabaseMetaData.procedureColumnReturn)); tuple[5] = encodeString(Integer.toString(m_connection .getSQLType(returnType))); tuple[6] = encodeString(m_connection.getPGType(returnType));
tuple[3] = "returnValue"; tuple[4] = new Short((short)java.sql.DatabaseMetaData.procedureColumnReturn); tuple[5] = new Short((short)m_connection.getSQLType(returnType.intValue())); tuple[6] = m_connection.getPGType(returnType.intValue());
	public java.sql.ResultSet getProcedureColumns(String catalog,		String schemaPattern, String procedureNamePattern,		String columnNamePattern) throws SQLException	{		ResultSetField f[] = new ResultSetField[13];		ArrayList v = new ArrayList(); // The new ResultSet tuple stuff		f[0] = new ResultSetField("PROCEDURE_CAT", TypeOid.VARCHAR,			getMaxNameLength());		f[1] = new ResultSetField("PROCEDURE_SCHEM", TypeOid.VARCHAR,			getMaxNameLength());		f[2] = new ResultSetField("PROCEDURE_NAME", TypeOid.VARCHAR,			getMaxNameLength());		f[3] = new ResultSetField("COLUMN_NAME", TypeOid.VARCHAR,			getMaxNameLength());		f[4] = new ResultSetField("COLUMN_TYPE", TypeOid.INT2, 2);		f[5] = new ResultSetField("DATA_TYPE", TypeOid.INT2, 2);		f[6] = new ResultSetField("TYPE_NAME", TypeOid.VARCHAR,			getMaxNameLength());		f[7] = new ResultSetField("PRECISION", TypeOid.INT4, 4);		f[8] = new ResultSetField("LENGTH", TypeOid.INT4, 4);		f[9] = new ResultSetField("SCALE", TypeOid.INT2, 2);		f[10] = new ResultSetField("RADIX", TypeOid.INT2, 2);		f[11] = new ResultSetField("NULLABLE", TypeOid.INT2, 2);		f[12] = new ResultSetField("REMARKS", TypeOid.VARCHAR,			getMaxNameLength());		String sql = "SELECT n.nspname,p.proname,p.prorettype,p.proargtypes, t.typtype,t.typrelid "				+ " FROM pg_catalog.pg_proc p,pg_catalog.pg_namespace n, pg_catalog.pg_type t "				+ " WHERE p.pronamespace=n.oid AND p.prorettype=t.oid ";		if(schemaPattern != null && !"".equals(schemaPattern))		{			sql += " AND n.nspname LIKE '" + escapeQuotes(schemaPattern)				+ "' ";		}		if(procedureNamePattern != null)		{			sql += " AND p.proname LIKE '"				+ escapeQuotes(procedureNamePattern) + "' ";		}		sql += " ORDER BY n.nspname, p.proname ";		ResultSet rs = m_connection.createStatement().executeQuery(sql);		while(rs.next())		{			byte schema[] = rs.getBytes("nspname");			byte procedureName[] = rs.getBytes("proname");			int returnType = rs.getInt("prorettype");			String returnTypeType = rs.getString("typtype");			int returnTypeRelid = rs.getInt("typrelid");			String strArgTypes = rs.getString("proargtypes");			StringTokenizer st = new StringTokenizer(strArgTypes);			ArrayList argTypes = new ArrayList();			while(st.hasMoreTokens())			{				argTypes.add(new Integer(st.nextToken()));			}			// 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;				tuple[3] = encodeString("returnValue");				tuple[4] = encodeString(Integer					.toString(java.sql.DatabaseMetaData.procedureColumnReturn));				tuple[5] = encodeString(Integer.toString(m_connection					.getSQLType(returnType)));				tuple[6] = encodeString(m_connection.getPGType(returnType));				tuple[7] = null;				tuple[8] = null;				tuple[9] = null;				tuple[10] = null;				tuple[11] = encodeString(Integer					.toString(java.sql.DatabaseMetaData.procedureNullableUnknown));				tuple[12] = null;				v.add(tuple);			}			// Add a row for each argument.			for(int i = 0; i < argTypes.size(); i++)			{				int argOid = ((Integer)argTypes.get(i)).intValue();				byte[][] tuple = new byte[13][];				tuple[0] = null;				tuple[1] = schema;				tuple[2] = procedureName;				tuple[3] = encodeString("$" + (i + 1));				tuple[4] = encodeString(Integer					.toString(java.sql.DatabaseMetaData.procedureColumnIn));				tuple[5] = encodeString(Integer.toString(m_connection					.getSQLType(argOid)));				tuple[6] = encodeString(m_connection.getPGType(argOid));				tuple[7] = null;				tuple[8] = null;				tuple[9] = null;				tuple[10] = null;				tuple[11] = encodeString(Integer					.toString(java.sql.DatabaseMetaData.procedureNullableUnknown));				tuple[12] = null;				v.add(tuple);			}			// if we are returning a multi-column result.			if(returnTypeType.equals("c"))			{				String columnsql = "SELECT a.attname,a.atttypid FROM pg_catalog.pg_attribute a WHERE a.attrelid = "					+ returnTypeRelid + " ORDER BY a.attnum ";				ResultSet columnrs = m_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;					tuple[3] = columnrs.getBytes("attname");					tuple[4] = encodeString(Integer						.toString(java.sql.DatabaseMetaData.procedureColumnResult));					tuple[5] = encodeString(Integer.toString(m_connection						.getSQLType(columnTypeOid)));					tuple[6] = encodeString(m_connection.getPGType(columnTypeOid));					tuple[7] = null;					tuple[8] = null;					tuple[9] = null;					tuple[10] = null;					tuple[11] = encodeString(Integer						.toString(java.sql.DatabaseMetaData.procedureNullableUnknown));					tuple[12] = null;					v.add(tuple);				}			}		}		rs.close();		return createSyntheticResultSet(f, v);	}