byte schema[] = rs.getBytes("nspname"); byte table[] = rs.getBytes("relname"); String owner = rs.getString("usename"); String acl = rs.getString("relacl"); HashMap permissions = parseACL(acl, owner); String permNames[] = (String[])permissions.keySet().toArray(new String[permissions.size()]);
schema = rs.getString("nspname"); table = rs.getString("relname"); owner = rs.getString("usename"); acl = rs.getString("relacl"); permissions = parseACL(acl, owner); permNames = (String[])permissions.keySet().toArray(new String[permissions.size()]);
	public java.sql.ResultSet getTablePrivileges(String catalog,		String schemaPattern, String tableNamePattern) throws SQLException	{		ResultSetField f[] = new ResultSetField[7];		ArrayList v = new ArrayList();		f[0] = new ResultSetField("TABLE_CAT", TypeOid.VARCHAR,			getMaxNameLength());		f[1] = new ResultSetField("TABLE_SCHEM", TypeOid.VARCHAR,			getMaxNameLength());		f[2] = new ResultSetField("TABLE_NAME", TypeOid.VARCHAR,			getMaxNameLength());		f[3] = new ResultSetField("GRANTOR", TypeOid.VARCHAR,			getMaxNameLength());		f[4] = new ResultSetField("GRANTEE", TypeOid.VARCHAR,			getMaxNameLength());		f[5] = new ResultSetField("PRIVILEGE", TypeOid.VARCHAR,			getMaxNameLength());		f[6] = new ResultSetField("IS_GRANTABLE", TypeOid.VARCHAR,			getMaxNameLength());		String sql = "SELECT n.nspname,c.relname,u.usename,c.relacl "				+ " FROM pg_catalog.pg_namespace n, pg_catalog.pg_class c, pg_catalog.pg_user u "				+ " WHERE c.relnamespace = n.oid "				+ " AND u.usesysid = c.relowner " + " AND c.relkind = 'r' ";		if(schemaPattern != null && !"".equals(schemaPattern))		{			sql += " AND n.nspname LIKE '" + escapeQuotes(schemaPattern)				+ "' ";		}		if(tableNamePattern != null && !"".equals(tableNamePattern))		{			sql += " AND c.relname LIKE '" + escapeQuotes(tableNamePattern)				+ "' ";		}		sql += " ORDER BY nspname, relname ";		ResultSet rs = m_connection.createStatement().executeQuery(sql);		while(rs.next())		{			byte schema[] = rs.getBytes("nspname");			byte table[] = rs.getBytes("relname");			String owner = rs.getString("usename");			String acl = rs.getString("relacl");			HashMap permissions = parseACL(acl, owner);			String permNames[] = (String[])permissions.keySet().toArray(new String[permissions.size()]);			sortStringArray(permNames);			for(int i = 0; i < permNames.length; i++)			{				byte[] privilege = encodeString(permNames[i]);				ArrayList grantees = (ArrayList)permissions.get(permNames[i]);				for(int j = 0; j < grantees.size(); j++)				{					String grantee = (String)grantees.get(j);					String grantable = owner.equals(grantee) ? "YES" : "NO";					byte[][] tuple = new byte[7][];					tuple[0] = null;					tuple[1] = schema;					tuple[2] = table;					tuple[3] = encodeString(owner);					tuple[4] = encodeString(grantee);					tuple[5] = privilege;					tuple[6] = encodeString(grantable);					v.add(tuple);				}			}		}		rs.close();		return createSyntheticResultSet(f, v);	}