PSQLException exception when dropping database and calling has_database_privilege: ERROR: database "test_1" does not exist

From: Yandong Yao <yydzero(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PSQLException exception when dropping database and calling has_database_privilege: ERROR: database "test_1" does not exist
Date: 2011-09-23 00:46:25
Message-ID: CA+ZQTxqC0wzLu=Wh+mo8md3M5Ja587wzMGobP_P6z4aLE8iQrA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Guys,

I have an application which will call following SQL code to retrieve roles
privileges on all databases in one server instance:

SELECT r.rolname, d.datname, has_database_privilege(r.oid, d.oid, 'CONNECT')
connectable,

has_database_privilege(r.oid, d.oid, 'CREATE') creatable

FROM pg_catalog.pg_roles r, pg_catalog.pg_database d

WHERE datname != 'postgres' AND datistemplate is false AND rolname IN
('role1', 'role2', 'role3')

While above code will report PSQLException exception: ERROR: database
"test_1" does not exist if one of database is dropping by other scripts.

How could i avoid this kind of exception?

or is it any better way to get many users privilege on database objects such
as schema, table and columns instead of calling has_***_privilege.

I am using PostgreSQL 8.4.

Thanks very much in advance!
Yandong

Browse pgsql-general by date

  From Date Subject
Next Message Andreas 2011-09-23 00:46:42 how to install 9.1 on non-graphical server?
Previous Message Tim Landscheidt 2011-09-22 22:43:43 Re: Quick Date/Time Index Question