pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Wall <d.wall@computer.org>
To: pgsql-jdbc@postgresql.org
Subject: JDBC with PG 9.2 and large object permissions as they relate to blobs (after upgrade from 8.4)
Date: Mon, 17 Dec 2012 10:31:56 -0800
Message-ID: <50CF651C.9040004@computer.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

We upgraded our PG from 8.4 to 9.2 and found that our pg_dump and 
pg_restore caused all of the large objects to be given permission to our 
db admin user, but not our application user.  This resulted in some null 
pointers in our java code when trying to access an OID column, with the 
PG error saying: permission denied for large object NNNN.

I checked with the excellent PG team and they pointed out that prior to 
9.0 large objects didn't have any access permissions/roles assigned to 
them.  So I guess on restore, all of the large objects became owned by 
our DB admin account, and despite all of our application role table 
GRANTS, these permission changes did not go down to the related large 
objects.

I'm just checking if the latest JDBC library is doing anything special 
with respect to large objects and permissions.  We just use the 
PreparedStatement getBlob()/setBlob().  Will the large objects be owned 
by the role that executes the INSERT?

By the way, we used the following psql script (found in posting 
http://doginpool.blogspot.com/2011/10/today-upgraded-to-new-ubuntu-11.html) 
to give all large objects ownership back to our application role and 
this seems to have resolved our issue:

do $$
declare r record;
begin
for r in select loid from pg_catalog.pg_largeobject loop
execute 'ALTER LARGE OBJECT ' || r.loid || ' OWNER TO DBUSER';
end loop;
end$$;
CLOSE ALL;

Thanks,
David


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (3+ messages)  latest in thread

Message-ID: <50CF651C.9040004@computer.org>
Permalink:  ../50CF651C.9040004@computer.org/
Also on:    postgresql.org/message-id/50CF651C.9040004@computer.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: d.wall@computer.org
  Subject: Re: JDBC with PG 9.2 and large object permissions as they relate to blobs (after upgrade from 8.4)
  In-Reply-To: <50CF651C.9040004@computer.org>
  References: <50CF651C.9040004@computer.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox