Skip to content

Commit

Permalink
Handle a table with no permissions correctly.
Browse files Browse the repository at this point in the history
Problem reported by danap.
  • Loading branch information
kjurka committed Oct 16, 2010
1 parent ac2b013 commit 1c4f1a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.44.2.3 2009/03/12 03:59:58 jurka Exp $
* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.44.2.4 2010/05/01 16:52:28 jurka Exp $
*
*-------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -2766,6 +2766,9 @@ else if (c == ',' && !inQuotes)
*/
private void addACLPrivileges(String acl, Hashtable privileges) {
int equalIndex = acl.lastIndexOf("=");
if (equalIndex == -1)
return;

String name = acl.substring(0, equalIndex);
if (name.length() == 0)
{
Expand Down
12 changes: 11 additions & 1 deletion org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.41 2008/01/20 15:13:29 jurka Exp $
* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v 1.41.2.1 2008/11/07 09:11:49 jurka Exp $
*
*-------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -377,6 +377,16 @@ public void testTablePrivileges() throws SQLException
assertTrue("Couldn't find SELECT priv on table testmetadata for " + TestUtil.getUser(), l_foundSelect);
}

public void testNoTablePrivileges() throws SQLException
{
Statement stmt = con.createStatement();
stmt.execute("REVOKE ALL ON testmetadata FROM PUBLIC");
stmt.execute("REVOKE ALL ON testmetadata FROM " + TestUtil.getUser());
DatabaseMetaData dbmd = con.getMetaData();
ResultSet rs = dbmd.getTablePrivileges(null, null, "testmetadata");
assertTrue(!rs.next());
}

public void testPrimaryKeys() throws SQLException
{
// At the moment just test that no exceptions are thrown KJ
Expand Down

0 comments on commit 1c4f1a6

Please sign in to comment.