Unix Technical Forum

Strange result from DatabaseMetaData.getTablePrivileges()

This is a discussion on Strange result from DatabaseMetaData.getTablePrivileges() within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hello, I just noticed that getTablePrivileges() returns the same privilege for the same user multiple times. Additionally it returns ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:33 AM
Thomas Kellerer
 
Posts: n/a
Default Strange result from DatabaseMetaData.getTablePrivileges()

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("jdbcostgresql://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


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:33 AM
Kris Jurka
 
Posts: n/a
Default Re: Strange result from DatabaseMetaData.getTablePrivileges()



On Sun, 28 Jan 2007, Thomas Kellerer wrote:

> I just noticed that getTablePrivileges() returns the same privilege for the
> same user multiple times. Additionally it returns several rows with the
> privilege "UNKNOWN".


This is a known bug. The ACL parsing code has not been updated since the
7.3 release and the format has changed numerous times.

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:03 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com