Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id AFDDB9FB298 for ; Sun, 28 Jan 2007 13:26:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 49420-07 for ; Sun, 28 Jan 2007 13:26:38 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id CC0B79FA377 for ; Sun, 28 Jan 2007 13:26:38 -0400 (AST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1HBDnS-0004gQ-I0 for pgsql-jdbc@postgresql.org; Sun, 28 Jan 2007 18:26:30 +0100 Received: from ppp-82-135-68-77.dynamic.mnet-online.de ([82.135.68.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Jan 2007 18:26:30 +0100 Received: from spam_eater by ppp-82-135-68-77.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Jan 2007 18:26:30 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Strange result from DatabaseMetaData.getTablePrivileges() Date: Sun, 28 Jan 2007 18:26:19 +0100 Lines: 64 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ppp-82-135-68-77.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/177 X-Sequence-Number: 16542 Hello, I just noticed that getTablePrivileges() returns the same privilege for the same user multiple times. Additionally it returns several rows with the privilege "UNKNOWN". Is this a bug, or am I simply misunderstanding something? The following test code: Class.forName("org.postgresql.Driver"); con = DriverManager.getConnection("jdbc:postgresql://localhost/wbtest", "thomas", "****"); con.setAutoCommit(true); stmt = con.createStatement(); stmt.executeUpdate("create table test_table (nr integer)"); stmt.executeUpdate("grant select,insert,update on test_table to postgres"); rs = con.getMetaData().getTablePrivileges(null, "public", "test_table"); while (rs.next()) { System.out.print("table_name: " + rs.getString("TABLE_NAME")); System.out.print(", grantor: " + rs.getString("GRANTOR")); System.out.print(", grantee: " + rs.getString("GRANTEE")); System.out.println(", privilege: " + rs.getString("PRIVILEGE")); } stmt.executeUpdate("drop table test_table"); produces the following ouput: table_name: test_table, grantor: thomas, grantee: thomas, privilege: DELETE table_name: test_table, grantor: thomas, grantee: thomas, privilege: INSERT table_name: test_table, grantor: thomas, grantee: thomas, privilege: INSERT table_name: test_table, grantor: thomas, grantee: postgres, privilege: INSERT table_name: test_table, grantor: thomas, grantee: postgres, privilege: INSERT table_name: test_table, grantor: thomas, grantee: thomas, privilege: REFERENCES table_name: test_table, grantor: thomas, grantee: thomas, privilege: SELECT table_name: test_table, grantor: thomas, grantee: postgres, privilege: SELECT table_name: test_table, grantor: thomas, grantee: thomas, privilege: TRIGGER table_name: test_table, grantor: thomas, grantee: thomas, privilege: TRIGGER table_name: test_table, grantor: thomas, grantee: postgres, privilege: TRIGGER table_name: test_table, grantor: thomas, grantee: thomas, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: thomas, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: thomas, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: thomas, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: thomas, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: postgres, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: postgres, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: postgres, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: postgres, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: postgres, privilege: UNKNOWN table_name: test_table, grantor: thomas, grantee: thomas, privilege: UPDATE table_name: test_table, grantor: thomas, grantee: postgres, privilege: UPDATE Note that e.g. the INSERT privilege for the user postgres is returned twice, whereas the SELECT privilege for the user postgres is only returned once (which is what I would have expected) And what are all the UNKNOWN entries? This is with build 504 of the JDBC Driver running on Windows XP against a Postgres 8.2.1 installed on the same machine using JDK 1.5. Thomas