Skip site navigation (1) Skip section navigation (2)

Re: DatabaseMetaData.getTablePrivileges()

From: dmp <danap(at)ttc-cmc(dot)net>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DatabaseMetaData.getTablePrivileges()
Date: 2010-10-10 20:32:20
Message-ID: 4CB222D4.4090401@ttc-cmc.net (view raw or flat)
Thread:
Lists: pgsql-jdbc
> On Thu, 7 Oct 2010, danap wrote:
>
>> Today I update the one of the development systems for the MyJSQLView
>> project to test the PostgreSQL 9.0 database. Once the database was
>> installed and also the latest JDBC 9.0-801 I tested the program. The
>> application crashed and after some testing I attributed the exception to
>> the empty string "" parameter for the schemaPattern argument in
>> DatabaseMetaData.getTablePrivileges() for the JDBC.
>>
>> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
>> at java.lang.String.substring(Unknown Source)
>> org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.addACLPrivileges(AbstractJdbc2DatabaseMetaData.java:2799)
>> org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.parseACL(AbstractJdbc2DatabaseMetaData.java:2878)
>> org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getTablePrivileges(AbstractJdbc2DatabaseMetaData.java:2700)

> Kris Jurka wrote:

> This error has nothing to do with using "" as a schema pattern. The
> problem is that the server is supplying an ACL that the JDBC driver is
> failing to parse correctly. So if these are the same databases,
> something has changed in the 9.0 representation of privileges. I'm not
> sure what that change might be. I've built a driver with the attached
> patch to show the failing ACL. If you can provide the output on the
> failure, we can likely fix it with little trouble.
>
> http://ejurka.com/pgsql/jars/acl/
>
> Kris Jurka

I guess some additional information should have been provided
with the initial posting. The newly installed 9.0.1 database was
done anew. The database was dumped from 8.4.4 then imported into
the new 9.0.1 configuration. So the databases were the same. Second
I had already gotten the application up and running before posting
here by providing the space character for the schemaPattern parameter in 
the getTablePrivileges() method.

Now it looks like you said Kris the exception has nothing to do with
the empty space, "", parameter for the schemaPattern except either
that documented valid input or NULL will bring out the exception. The
exception as your patch looks for has to do with parsing the reacl
entry. That entry is for the pg_largeobject and is {}.

The SQL query to bring up the needed data to see this is:

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'  AND c.relname LIKE '%'  ORDER BY nspname, relname

I'm not sure if the mail list will except it, but attached is the
pdf output for that query for both the 8.4.4 and 9.0.1 databases.

Links here:
http://dandymadeproductions.com/temp/sql_empty_schemaPattern_8.4.4.pdf
http://dandymadeproductions.com/temp/sql_empty_schemaPattern_9.0.1.pdf

danap.






Attachment: sql_empty_schemaPattern_9.0.1.pdf
Description: application/pdf (5.7 KB)
Attachment: sql_empty_schemaPattern_8.4.4.pdf
Description: application/pdf (5.5 KB)

In response to

Responses

pgsql-jdbc by date

Next:From: David FetterDate: 2010-10-11 06:46:15
Subject: Support for JDBC setQueryTimeout, et al.
Previous:From: Kris JurkaDate: 2010-10-09 06:37:38
Subject: Re: DatabaseMetaData.getTablePrivileges()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group