pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
18+ messages / 5 participants
[nested] [flat]

* BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
@ 2016-12-08 19:16 daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 18+ messages in thread

From: daniele.varrazzo@gmail.com @ 2016-12-08 19:16 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14456
Logged by:          Daniele Varrazzo
Email address:      daniele.varrazzo@gmail.com
PostgreSQL version: 9.5.4
Operating system:   Linux
Description:        

As per title. To test:

1) create an extension containing a table, e.g.:

$ cat /usr/share/postgresql/9.5/extension/testext.control 
default_version = '1.0'
comment = 'test of a pg bug'
superuser = false

$ cat /usr/share/postgresql/9.5/extension/testext--1.0.sql 
create table testtbl (id serial primary key, data text);
select pg_catalog.pg_extension_config_dump('testtbl', '');


2) Load the extension in the database

=# create database test;
CREATE DATABASE

=# \c test;
test=# create schema extschema;
CREATE SCHEMA

test=# create extension testext with schema extschema;
CREATE EXTENSION


3) Customize extension table permissions

test=# create user u2;
CREATE ROLE

test=# grant select on extschema.testtbl to u2;
GRANT

test=# \dpp extschema.testtbl
                               Access privileges
  Schema   |  Name   | Type  | Access privileges | Column privileges |
Policies 
-----------+---------+-------+-------------------+-------------------+----------
 extschema | testtbl | table | piro=arwdDxt/piro+|                   | 
           |         |       | u2=r/piro         |                   | 
(1 row)

test=# insert into extschema.testtbl (data) values ('asdf');
INSERT 0 1


4) Create a new database and dump/restore data there

test=# create database test2;
CREATE DATABASE

$ pg_dump test | psql -1 test2


5) permissions are not restored

test2=# \dpp extschema.testtbl
                               Access privileges
  Schema   |  Name   | Type  | Access privileges | Column privileges |
Policies 
-----------+---------+-------+-------------------+-------------------+----------
 extschema | testtbl | table |                   |                   | 
(1 row)


Note that using ALTER DEFAULT PRIVILEGES doesn't work either: the default
privs on the schemas are restored after the extension is created so the
tables created by the extensions don't benefit of it.


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


^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
@ 2016-12-08 19:29 ` Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Stephen Frost @ 2016-12-08 19:29 UTC (permalink / raw)
  To: daniele.varrazzo@gmail.com; +Cc: pgsql-bugs

Greetings Daniele,

* daniele.varrazzo@gmail.com (daniele.varrazzo@gmail.com) wrote:
> PostgreSQL version: 9.5.4
[...]
> As per title. To test:

Prior to 9.6, dump/reload of an extension with custom ACLs wasn't
really supported.  This should work correctly in 9.6.  Unfortunately,
the changes required are too much to be able to back-patch to prior
versions of PG.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
@ 2017-01-12 18:24   ` Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 18+ messages in thread

From: Moshe Jacobson @ 2017-01-12 18:24 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; +Cc: pgsql-bugs

I'm experiencing issues with this new "feature".
My extension dynamically creates extension-owned tables and puts ACLs on
them.
When the database is dumped, it includes grants/revokes for those tables,
which will not exist when the extension is re-installed.
As a result, when the database is restored, I keep getting warnings because
it's trying to apply ACLs to tables that don't exist.

Is there a way around this issue?

On Thu, Dec 8, 2016 at 2:31 PM Stephen Frost <sfrost@snowman.net> wrote:

> Greetings Daniele,
>
> * daniele.varrazzo@gmail.com (daniele.varrazzo@gmail.com) wrote:
> > PostgreSQL version: 9.5.4
> [...]
> > As per title. To test:
>
> Prior to 9.6, dump/reload of an extension with custom ACLs wasn't
> really supported.  This should work correctly in 9.6.  Unfortunately,
> the changes required are too much to be able to back-patch to prior
> versions of PG.
>
> Thanks!
>
> Stephen
>
-- 
Moshe Jacobson
Principal Architect, Nead Werx Inc.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
@ 2017-01-12 18:34     ` Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Stephen Frost @ 2017-01-12 18:34 UTC (permalink / raw)
  To: Moshe Jacobson <moshe@neadwerx.com>; +Cc: daniele.varrazzo@gmail.com; pgsql-bugs

Greetings,

* Moshe Jacobson (moshe@neadwerx.com) wrote:
> My extension dynamically creates extension-owned tables and puts ACLs on
> them.

Ok, in 9.6, we should realize that your extension changed the ACLs for
those tables.

> When the database is dumped, it includes grants/revokes for those tables,
> which will not exist when the extension is re-installed.

When the database is dumped, it should include a CREATE EXTENSION
command.  It also shouldn't include GRANTs/REVOKEs unless the user
changed the permissions on the extension's tables from what they were
set to when the extension was installed.

> As a result, when the database is restored, I keep getting warnings because
> it's trying to apply ACLs to tables that don't exist.
> 
> Is there a way around this issue?

A self-contained test case against 9.6 which shows the issue you're
having would really be the best way to help us.

If the issue is that you're working on a pre-9.6 version of PG, then I'm
afraid you'll need to upgrade or live with the warnings.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
@ 2017-01-12 18:49       ` Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 18+ messages in thread

From: Moshe Jacobson @ 2017-01-12 18:49 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: daniele.varrazzo@gmail.com; pgsql-bugs

Stephen, thank you for responding, but your response indicated a
misunderstanding. In lieu of a standalone example, let me explain the issue
again.

Scenario:

   1. Extension is installed into its own schema. Installation is now
   complete.
   2. Extension creates a new table in its schema
   3. Extension changes ACLs on the table.
   4. After changing ACLs, the table is added to the extension (ALTER
   EXTENSION)
   5. A pg_dump of this database will now include ACL commands for the
   table.
   6. A pg_restore of this file will give warnings because the ACLs refer
   to a table that is not created as part of the installation process.

Because I am setting the ACLs before adding the table to the extension, is
should not include those ACLs in the pg_dump output.

Thanks.

On Thu, Jan 12, 2017 at 1:35 PM Stephen Frost <sfrost@snowman.net> wrote:

> Greetings,
>
> * Moshe Jacobson (moshe@neadwerx.com) wrote:
> > My extension dynamically creates extension-owned tables and puts ACLs on
> > them.
>
> Ok, in 9.6, we should realize that your extension changed the ACLs for
> those tables.
>
> > When the database is dumped, it includes grants/revokes for those tables,
> > which will not exist when the extension is re-installed.
>
> When the database is dumped, it should include a CREATE EXTENSION
> command.  It also shouldn't include GRANTs/REVOKEs unless the user
> changed the permissions on the extension's tables from what they were
> set to when the extension was installed.
>
> > As a result, when the database is restored, I keep getting warnings
> because
> > it's trying to apply ACLs to tables that don't exist.
> >
> > Is there a way around this issue?
>
> A self-contained test case against 9.6 which shows the issue you're
> having would really be the best way to help us.
>
> If the issue is that you're working on a pre-9.6 version of PG, then I'm
> afraid you'll need to upgrade or live with the warnings.
>
> Thanks!
>
> Stephen
>
-- 
Moshe Jacobson
Principal Architect, Nead Werx Inc.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
@ 2017-01-12 19:01         ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:10           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  0 siblings, 2 replies; 18+ messages in thread

From: Tom Lane @ 2017-01-12 19:01 UTC (permalink / raw)
  To: Moshe Jacobson <moshe@neadwerx.com>; +Cc: Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; pgsql-bugs

Moshe Jacobson <moshe@neadwerx.com> writes:
> Scenario:

>    1. Extension is installed into its own schema. Installation is now
>    complete.
>    2. Extension creates a new table in its schema
>    3. Extension changes ACLs on the table.

Extensions are not actors, so claiming that "the extension" did something
is at best pretty fuzzy thinking.

>    4. After changing ACLs, the table is added to the extension (ALTER
>    EXTENSION)
>    5. A pg_dump of this database will now include ACL commands for the
>    table.

Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
absorb whatever the object's current ACLs are into the pg_init_privs
entries for the extension.  (I don't think it does that now, though
I might be wrong.)  However ...

>    6. A pg_restore of this file will give warnings because the ACLs refer
>    to a table that is not created as part of the installation process.

I think this scenario is simply pilot error, or at least gross abuse of
the extension system.  If you dump and reload a DB containing an extension,
the extension definition that's fetched by CREATE EXTENSION is expected
to define (at least) all the objects that belonged to the extension in the
old DB.  You can't just randomly ALTER EXTENSION and not update the
extension definition script to match.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-12 19:08           ` Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 18+ messages in thread

From: Stephen Frost @ 2017-01-12 19:08 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; daniele.varrazzo@gmail.com; pgsql-bugs

Greetings,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Moshe Jacobson <moshe@neadwerx.com> writes:
> > Scenario:
> 
> >    1. Extension is installed into its own schema. Installation is now
> >    complete.
> >    2. Extension creates a new table in its schema
> >    3. Extension changes ACLs on the table.
> 
> Extensions are not actors, so claiming that "the extension" did something
> is at best pretty fuzzy thinking.

Agreed.

> >    4. After changing ACLs, the table is added to the extension (ALTER
> >    EXTENSION)
> >    5. A pg_dump of this database will now include ACL commands for the
> >    table.
> 
> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> absorb whatever the object's current ACLs are into the pg_init_privs
> entries for the extension.  (I don't think it does that now, though
> I might be wrong.)  However ...

I've not gone and looked yet, but I doubt that it does.  I think I can
agree with the argument that it really should add those ACLs to
pg_init_privs.  Of course, any furhter manipulation of the ACLs from
that point will cause those ACLs to be included in the pg_dump.

I'll take a look at ALTER EXTENSION ADD and pg_init_privs.

> >    6. A pg_restore of this file will give warnings because the ACLs refer
> >    to a table that is not created as part of the installation process.
> 
> I think this scenario is simply pilot error, or at least gross abuse of
> the extension system.  If you dump and reload a DB containing an extension,
> the extension definition that's fetched by CREATE EXTENSION is expected
> to define (at least) all the objects that belonged to the extension in the
> old DB.  You can't just randomly ALTER EXTENSION and not update the
> extension definition script to match.

Agreed.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
@ 2017-01-12 19:16             ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:24               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-20 22:10               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-30 04:30               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  0 siblings, 3 replies; 18+ messages in thread

From: Tom Lane @ 2017-01-12 19:16 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; daniele.varrazzo@gmail.com; pgsql-bugs

Stephen Frost <sfrost@snowman.net> writes:
> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
>> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
>> absorb whatever the object's current ACLs are into the pg_init_privs
>> entries for the extension.  (I don't think it does that now, though
>> I might be wrong.)  However ...

> I've not gone and looked yet, but I doubt that it does.  I think I can
> agree with the argument that it really should add those ACLs to
> pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> that point will cause those ACLs to be included in the pg_dump.

> I'll take a look at ALTER EXTENSION ADD and pg_init_privs.

By the same token, does ALTER EXTENSION DROP remove those entries?

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-12 19:24               ` Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:34                 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2 siblings, 1 reply; 18+ messages in thread

From: Stephen Frost @ 2017-01-12 19:24 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; daniele.varrazzo@gmail.com; pgsql-bugs

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> >> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> >> absorb whatever the object's current ACLs are into the pg_init_privs
> >> entries for the extension.  (I don't think it does that now, though
> >> I might be wrong.)  However ...
> 
> > I've not gone and looked yet, but I doubt that it does.  I think I can
> > agree with the argument that it really should add those ACLs to
> > pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> > that point will cause those ACLs to be included in the pg_dump.
> 
> > I'll take a look at ALTER EXTENSION ADD and pg_init_privs.
> 
> By the same token, does ALTER EXTENSION DROP remove those entries?

I'll make sure it does.  My guess at the moment is that it doesn't.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:24               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
@ 2017-01-12 19:34                 ` Moshe Jacobson <moshe@neadwerx.com>
  0 siblings, 0 replies; 18+ messages in thread

From: Moshe Jacobson @ 2017-01-12 19:34 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: daniele.varrazzo@gmail.com; pgsql-bugs

Thank you both, Tom and Stephen!

On Thu, Jan 12, 2017 at 2:25 PM Stephen Frost <sfrost@snowman.net> wrote:

> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> > Stephen Frost <sfrost@snowman.net> writes:
> > > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> > >> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> > >> absorb whatever the object's current ACLs are into the pg_init_privs
> > >> entries for the extension.  (I don't think it does that now, though
> > >> I might be wrong.)  However ...
> >
> > > I've not gone and looked yet, but I doubt that it does.  I think I can
> > > agree with the argument that it really should add those ACLs to
> > > pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> > > that point will cause those ACLs to be included in the pg_dump.
> >
> > > I'll take a look at ALTER EXTENSION ADD and pg_init_privs.
> >
> > By the same token, does ALTER EXTENSION DROP remove those entries?
>
> I'll make sure it does.  My guess at the moment is that it doesn't.
>
> Thanks!
>
> Stephen
>
-- 
Moshe Jacobson
Principal Architect, Nead Werx Inc.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-20 22:10               ` Stephen Frost <sfrost@snowman.net>
  2017-01-23 15:23                 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2 siblings, 1 reply; 18+ messages in thread

From: Stephen Frost @ 2017-01-20 22:10 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; daniele.varrazzo@gmail.com; pgsql-bugs

Tom, Moshe,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> >> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> >> absorb whatever the object's current ACLs are into the pg_init_privs
> >> entries for the extension.  (I don't think it does that now, though
> >> I might be wrong.)  However ...
> 
> > I've not gone and looked yet, but I doubt that it does.  I think I can
> > agree with the argument that it really should add those ACLs to
> > pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> > that point will cause those ACLs to be included in the pg_dump.
> 
> > I'll take a look at ALTER EXTENSION ADD and pg_init_privs.
> 
> By the same token, does ALTER EXTENSION DROP remove those entries?

Please find attached a WIP patch to have ALTER EXTENSION ADD/DROP update
pg_init_privs accordingly.

It's a bit big as it needs to have independent code for every different
kind of object that ALTER EXTENSION ADD/DROP supports.  Most of that
code is pretty boiler-plate, of course.

I'm planning to review it further, add more regression tests, and then
back-patch it to 9.6.

Moshe, if you're feeling adventurous and want to give it a spin and make
sure it behaves as you're expecting, that'd be great.

Tom, your thoughts and comments are always welcome, if you'd like to
peruse the patch, of course.

Otherwise, I expect to have time to wrap this all up over the weekend.

Thanks!

Stephen

Attachments:

alter_ext_adddrop_init_privs_v1_master.patch (text/x-diff, 22.7K) download diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c new file mode 100644 index 7803d0d..73471c6 *** a/src/backend/catalog/aclchk.c --- b/src/backend/catalog/aclchk.c *************** *** 27,33 **** --- 27,36 ---- #include "catalog/dependency.h" #include "catalog/indexing.h" #include "catalog/objectaccess.h" + #include "catalog/pg_aggregate.h" + #include "catalog/pg_am.h" #include "catalog/pg_authid.h" + #include "catalog/pg_cast.h" #include "catalog/pg_collation.h" #include "catalog/pg_conversion.h" #include "catalog/pg_database.h" *************** *** 49,54 **** --- 52,60 ---- #include "catalog/pg_type.h" #include "catalog/pg_ts_config.h" #include "catalog/pg_ts_dict.h" + #include "catalog/pg_ts_parser.h" + #include "catalog/pg_ts_template.h" + #include "catalog/pg_transform.h" #include "commands/dbcommands.h" #include "commands/event_trigger.h" #include "commands/extension.h" *************** static AclMode pg_aclmask(AclObjectKind *** 130,135 **** --- 136,143 ---- Oid roleid, AclMode mask, AclMaskHow how); static void recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl); + static void recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, + Acl *new_acl); #ifdef ACLDEBUG *************** get_user_default_acl(GrantObjectType obj *** 5226,5235 **** } /* ! * Record initial ACL for an extension object * ! * This will perform a wholesale replacement of the entire ACL for the object ! * passed in, therefore be sure to pass in the complete new ACL to use. * * Can be called at any time, we check if 'creating_extension' is set and, if * not, exit immediately. --- 5234,5604 ---- } /* ! * Record initial privileges for the top-level object passed in. * ! * For the object passed in, this will record its ACL (if any) and the ACLs of ! * any sub-objects (eg: columns) into pg_init_privs. ! * ! * Any new kinds of objects which have ACLs associated with them and can be ! * added to an extension should be added to the if-else tree below. ! */ ! void ! recordExtObjInitPriv(Oid objoid, Oid classoid) ! { ! /* ! * pg_class / pg_attribute ! * ! * If this is a relation then we need to see if there are any sub-objects ! * (eg: columns) for it and, if so, be sure to call ! * recordExtensionInitPrivWorker() for each one. ! */ ! if (classoid == RelationRelationId) ! { ! Form_pg_class pg_class_tuple; ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for relation %u", objoid); ! pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); ! ! /* Indexes don't have permissions */ ! if (pg_class_tuple->relkind == RELKIND_INDEX) ! return; ! ! /* Composite types don't have permissions either */ ! if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE) ! return; ! ! /* ! * If this isn't a sequence, index, or composite type then it's ! * possibly going to have columns associated with it that might have ! * ACLs. ! */ ! if (pg_class_tuple->relkind != RELKIND_SEQUENCE) ! { ! AttrNumber curr_att; ! AttrNumber nattrs = pg_class_tuple->relnatts; ! ! for (curr_att = 1; curr_att <= nattrs; curr_att++) ! { ! HeapTuple attTuple; ! Datum attaclDatum; ! ! attTuple = SearchSysCache2(ATTNUM, ! ObjectIdGetDatum(objoid), ! Int16GetDatum(curr_att)); ! ! if (!HeapTupleIsValid(attTuple)) ! continue; ! ! /* ignore dropped columns */ ! if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! attaclDatum = SysCacheGetAttr(ATTNUM, attTuple, ! Anum_pg_attribute_attacl, ! &isNull); ! ! /* no need to do anything for a NULL ACL */ ! if (isNull) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! recordExtensionInitPrivWorker(objoid, classoid, curr_att, ! DatumGetAclP(attaclDatum)); ! ! ReleaseSysCache(attTuple); ! } ! } ! ! aclDatum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_foreign_data_wrapper */ ! else if (classoid == ForeignDataWrapperRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(FOREIGNDATAWRAPPEROID, ! ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for foreign data wrapper %u", ! objoid); ! ! aclDatum = SysCacheGetAttr(FOREIGNDATAWRAPPEROID, tuple, ! Anum_pg_foreign_data_wrapper_fdwacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_foreign_server */ ! else if (classoid == ForeignServerRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for foreign data wrapper %u", ! objoid); ! ! aclDatum = SysCacheGetAttr(FOREIGNSERVEROID, tuple, ! Anum_pg_foreign_server_srvacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_language */ ! else if (classoid == LanguageRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(LANGOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for language %u", objoid); ! ! aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_largeobject_metadata */ ! else if (classoid == LargeObjectMetadataRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ScanKeyData entry[1]; ! SysScanDesc scan; ! Relation relation; ! ! relation = heap_open(LargeObjectMetadataRelationId, RowExclusiveLock); ! ! /* There's no syscache for pg_largeobject_metadata */ ! ScanKeyInit(&entry[0], ! ObjectIdAttributeNumber, ! BTEqualStrategyNumber, F_OIDEQ, ! ObjectIdGetDatum(objoid)); ! ! scan = systable_beginscan(relation, ! LargeObjectMetadataOidIndexId, true, ! NULL, 1, entry); ! ! tuple = systable_getnext(scan); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for large object %u", objoid); ! ! aclDatum = heap_getattr(tuple, ! Anum_pg_largeobject_metadata_lomacl, ! RelationGetDescr(relation), &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! systable_endscan(scan); ! } ! /* pg_namespace */ ! else if (classoid == NamespaceRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(NAMESPACEOID, tuple, ! Anum_pg_namespace_nspacl, &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_proc */ ! else if (classoid == ProcedureRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! /* pg_type */ ! else if (classoid == TypeRelationId) ! { ! Datum aclDatum; ! bool isNull; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for function %u", objoid); ! ! aclDatum = SysCacheGetAttr(TYPEOID, tuple, Anum_pg_type_typacl, ! &isNull); ! ! /* Add the record, if any, for the top-level object */ ! if (!isNull) ! recordExtensionInitPrivWorker(objoid, classoid, 0, ! DatumGetAclP(aclDatum)); ! ! ReleaseSysCache(tuple); ! } ! else if (classoid == AccessMethodRelationId || ! classoid == AggregateRelationId || ! classoid == CastRelationId || ! classoid == CollationRelationId || ! classoid == ConversionRelationId || ! classoid == EventTriggerRelationId || ! classoid == OperatorRelationId || ! classoid == OperatorClassRelationId || ! classoid == OperatorFamilyRelationId || ! classoid == NamespaceRelationId || ! classoid == TSConfigRelationId || ! classoid == TSDictionaryRelationId || ! classoid == TSParserRelationId || ! classoid == TSTemplateRelationId || ! classoid == TransformRelationId ! ) ! { ! /* no ACL for these object types, so do nothing. */ ! } ! /* ! * complain if we are given a class OID for a class that extensions don't ! * support or that we don't recognize. ! */ ! else ! { ! elog(ERROR, "unrecognized or unsupported class OID: %u", classoid); ! } ! } ! ! /* ! * For the object passed in, remove its ACL and the ACLs of any object subIds ! * from pg_init_privs (via recordExtensionInitPrivWorker()). ! */ ! void ! removeExtObjInitPriv(Oid objoid, Oid classoid) ! { ! /* ! * If this is a relation then we need to see if there are any sub-objects ! * (eg: columns) for it and, if so, be sure to call ! * recordExtensionInitPrivWorker() for each one. ! */ ! if (classoid == RelationRelationId) ! { ! Form_pg_class pg_class_tuple; ! HeapTuple tuple; ! ! tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(objoid)); ! if (!HeapTupleIsValid(tuple)) ! elog(ERROR, "cache lookup failed for relation %u", objoid); ! pg_class_tuple = (Form_pg_class) GETSTRUCT(tuple); ! ! /* Indexes don't have permissions */ ! if (pg_class_tuple->relkind == RELKIND_INDEX) ! return; ! ! /* Composite types don't have permissions either */ ! if (pg_class_tuple->relkind == RELKIND_COMPOSITE_TYPE) ! return; ! ! /* ! * If this isn't a sequence, index, or composite type then it's ! * possibly going to have columns associated with it that might have ! * ACLs. ! */ ! if (pg_class_tuple->relkind != RELKIND_SEQUENCE) ! { ! AttrNumber curr_att; ! AttrNumber nattrs = pg_class_tuple->relnatts; ! ! for (curr_att = 1; curr_att <= nattrs; curr_att++) ! { ! HeapTuple attTuple; ! ! attTuple = SearchSysCache2(ATTNUM, ! ObjectIdGetDatum(objoid), ! Int16GetDatum(curr_att)); ! ! if (!HeapTupleIsValid(attTuple)) ! continue; ! ! /* ignore dropped columns */ ! if (((Form_pg_attribute) GETSTRUCT(attTuple))->attisdropped) ! { ! ReleaseSysCache(attTuple); ! continue; ! } ! ! recordExtensionInitPrivWorker(objoid, classoid, curr_att, NULL); ! ! ReleaseSysCache(attTuple); ! } ! } ! ! ReleaseSysCache(tuple); ! } ! ! /* Remove the record, if any, for the top-level object */ ! recordExtensionInitPrivWorker(objoid, classoid, 0, NULL); ! } ! ! /* ! * Record initial ACL for an extension object * * Can be called at any time, we check if 'creating_extension' is set and, if * not, exit immediately. *************** get_user_default_acl(GrantObjectType obj *** 5248,5259 **** static void recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) { - Relation relation; - ScanKeyData key[3]; - SysScanDesc scan; - HeapTuple tuple; - HeapTuple oldtuple; - /* * Generally, we only record the initial privileges when an extension is * being created, but because we don't actually use CREATE EXTENSION --- 5617,5622 ---- *************** recordExtensionInitPriv(Oid objoid, Oid *** 5265,5270 **** --- 5628,5657 ---- if (!creating_extension && !binary_upgrade_record_init_privs) return; + recordExtensionInitPrivWorker(objoid, classoid, objsubid, new_acl); + } + + /* + * Record initial ACL for an extension object, worker. + * + * This will perform a wholesale replacement of the entire ACL for the object + * passed in, therefore be sure to pass in the complete new ACL to use. + * + * Generally speaking, do *not* use this function directly but instead use + * recordExtensionInitPriv(), which checks if 'creating_extension' is set. + * This function does *not* check if 'creating_extension' is set as it is also + * used when an object is added to or removed from an extension via ALTER + * EXTENSION ... ADD/DROP. + */ + static void + recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_acl) + { + Relation relation; + ScanKeyData key[3]; + SysScanDesc scan; + HeapTuple tuple; + HeapTuple oldtuple; + relation = heap_open(InitPrivsRelationId, RowExclusiveLock); ScanKeyInit(&key[0], *************** recordExtensionInitPriv(Oid objoid, Oid *** 5317,5344 **** } else { - /* No entry found, so add it. */ Datum values[Natts_pg_init_privs]; bool nulls[Natts_pg_init_privs]; ! MemSet(nulls, false, sizeof(nulls)); ! values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid); ! values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid); ! values[Anum_pg_init_privs_objsubid - 1] = Int32GetDatum(objsubid); ! /* This function only handles initial privileges of extensions */ ! values[Anum_pg_init_privs_privtype - 1] = ! CharGetDatum(INITPRIVS_EXTENSION); ! values[Anum_pg_init_privs_privs - 1] = PointerGetDatum(new_acl); ! tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls); ! simple_heap_insert(relation, tuple); ! /* keep the catalog indexes up to date */ ! CatalogUpdateIndexes(relation, tuple); } systable_endscan(scan); --- 5704,5740 ---- } else { Datum values[Natts_pg_init_privs]; bool nulls[Natts_pg_init_privs]; ! /* ! * Only add a new entry if the new ACL is non-NULL. ! * ! * If we are passed in a NULL ACL and no entry exists, we can just fall ! * through and do nothing. ! */ ! if (new_acl) ! { ! /* No entry found, so add it. */ ! MemSet(nulls, false, sizeof(nulls)); ! values[Anum_pg_init_privs_objoid - 1] = ObjectIdGetDatum(objoid); ! values[Anum_pg_init_privs_classoid - 1] = ObjectIdGetDatum(classoid); ! values[Anum_pg_init_privs_objsubid - 1] = Int32GetDatum(objsubid); ! /* This function only handles initial privileges of extensions */ ! values[Anum_pg_init_privs_privtype - 1] = ! CharGetDatum(INITPRIVS_EXTENSION); ! values[Anum_pg_init_privs_privs - 1] = PointerGetDatum(new_acl); ! tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls); ! simple_heap_insert(relation, tuple); ! /* keep the catalog indexes up to date */ ! CatalogUpdateIndexes(relation, tuple); ! } } systable_endscan(scan); diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c new file mode 100644 index be52148..e6108ff *** a/src/backend/commands/extension.c --- b/src/backend/commands/extension.c *************** *** 52,57 **** --- 52,58 ---- #include "nodes/makefuncs.h" #include "storage/fd.h" #include "tcop/utility.h" + #include "utils/acl.h" #include "utils/builtins.h" #include "utils/fmgroids.h" #include "utils/lsyscache.h" *************** ExecAlterExtensionContentsStmt(AlterExte *** 3239,3244 **** --- 3240,3255 ---- * OK, add the dependency. */ recordDependencyOn(&object, &extension, DEPENDENCY_EXTENSION); + + /* + * Also record the initial ACL on the object, if any. + * + * Note that this will handle the object's ACLs, as well as any ACLs + * on object subIds. (In other words, when the object is a table, + * this will record the table's ACL and the ACLs for the columns on + * the table, if any). + */ + recordExtObjInitPriv(object.objectId, object.classId); } else { *************** ExecAlterExtensionContentsStmt(AlterExte *** 3266,3271 **** --- 3277,3292 ---- */ if (object.classId == RelationRelationId) extension_config_remove(extension.objectId, object.objectId); + + /* + * Remove all the initial ACLs, if any. + * + * Note that this will remove the object's ACLs, as well as any ACLs + * on object subIds. (In other words, when the object is a table, + * this will remove the table's ACL and the ACLs for the columns on + * the table, if any). + */ + removeExtObjInitPriv(object.objectId, object.classId); } InvokeObjectPostAlterHook(ExtensionRelationId, extension.objectId, 0); diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h new file mode 100644 index 433ba2d..6508cc1 *** a/src/include/utils/acl.h --- b/src/include/utils/acl.h *************** extern void aclcheck_error_col(AclResult *** 312,317 **** --- 312,321 ---- extern void aclcheck_error_type(AclResult aclerr, Oid typeOid); + extern void recordExtObjInitPriv(Oid objoid, Oid classoid); + extern void removeExtObjInitPriv(Oid objoid, Oid classoid); + + /* ownercheck routines just return true (owner) or false (not) */ extern bool pg_class_ownercheck(Oid class_oid, Oid roleid); extern bool pg_type_ownercheck(Oid type_oid, Oid roleid); diff --git a/src/test/modules/test_pg_dump/expected/test_pg_dump.out b/src/test/modules/test_pg_dump/expected/test_pg_dump.out new file mode 100644 index 360caa2..d37aea0 *** a/src/test/modules/test_pg_dump/expected/test_pg_dump.out --- b/src/test/modules/test_pg_dump/expected/test_pg_dump.out *************** *** 1,6 **** ! SELECT 1; ! ?column? ! ---------- ! 1 ! (1 row) ! --- 1,2 ---- ! CREATE ROLE regress_dump_test_role; ! CREATE EXTENSION test_pg_dump; diff --git a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql new file mode 100644 index e0ac49d..d37aea0 *** a/src/test/modules/test_pg_dump/sql/test_pg_dump.sql --- b/src/test/modules/test_pg_dump/sql/test_pg_dump.sql *************** *** 1 **** ! SELECT 1; --- 1,2 ---- ! CREATE ROLE regress_dump_test_role; ! CREATE EXTENSION test_pg_dump; diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl new file mode 100644 index dc90a4a..643fc8d *** a/src/test/modules/test_pg_dump/t/001_base.pl --- b/src/test/modules/test_pg_dump/t/001_base.pl *************** my %pgdump_runs = ( *** 188,193 **** --- 188,213 ---- # as the regexps are used for each run the test applies to. my %tests = ( + 'ALTER EXTENSION test_pg_dump' => { + create_order => 9, + create_sql => 'ALTER EXTENSION test_pg_dump ADD TABLE regress_pg_dump_table_added;', + regexp => qr/^ + \QCREATE TABLE regress_pg_dump_table_added (\E + \n\s+\Qcol1 integer NOT NULL,\E + \n\s+\Qcol2 integer\E + \n\);\n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, 'CREATE EXTENSION test_pg_dump' => { create_order => 2, create_sql => 'CREATE EXTENSION test_pg_dump;', *************** my %tests = ( *** 283,288 **** --- 303,328 ---- schema_only => 1, section_pre_data => 1, section_post_data => 1, }, }, + 'CREATE TABLE regress_pg_dump_table_added' => { + create_order => 7, + create_sql => 'CREATE TABLE regress_pg_dump_table_added (col1 int not null, col2 int);', + regexp => qr/^ + \QCREATE TABLE regress_pg_dump_table_added (\E + \n\s+\Qcol1 integer NOT NULL,\E + \n\s+\Qcol2 integer\E + \n\);\n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, 'CREATE ACCESS METHOD regress_test_am' => { regexp => qr/^ \QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E *************** my %tests = ( *** 373,378 **** --- 413,457 ---- no_privs => 1, pg_dumpall_globals => 1, section_post_data => 1, }, }, + 'GRANT SELECT regress_pg_dump_table_added pre-ALTER EXTENSION' => { + create_order => 8, + create_sql => 'GRANT SELECT ON regress_pg_dump_table_added TO regress_dump_test_role;', + regexp => qr/^ + \QGRANT SELECT ON TABLE regress_pg_dump_table_added TO regress_dump_test_role;\E + \n/xm, + like => { binary_upgrade => 1, }, + unlike => { + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_privs => 1, + no_owner => 1, + pg_dumpall_globals => 1, + schema_only => 1, + section_pre_data => 1, + section_post_data => 1, }, }, + 'REVOKE SELECT regress_pg_dump_table_added post-ALTER EXTENSION' => { + create_order => 10, + create_sql => 'REVOKE SELECT ON regress_pg_dump_table_added FROM regress_dump_test_role;', + regexp => qr/^ + \QREVOKE SELECT ON TABLE regress_pg_dump_table_added FROM regress_dump_test_role;\E + \n/xm, + like => { + binary_upgrade => 1, + clean => 1, + clean_if_exists => 1, + createdb => 1, + defaults => 1, + no_owner => 1, + schema_only => 1, + section_pre_data => 1, + }, + unlike => { + no_privs => 1, + pg_dumpall_globals => 1, + section_post_data => 1, + }, }, 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' => { create_order => 5,
signature.asc (application/pgp-signature, 818B) download ^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-20 22:10               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
@ 2017-01-23 15:23                 ` Moshe Jacobson <moshe@neadwerx.com>
  2017-01-23 15:32                   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 18+ messages in thread

From: Moshe Jacobson @ 2017-01-23 15:23 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: pgsql-bugs

On Fri, Jan 20, 2017 at 5:10 PM Stephen Frost <sfrost@snowman.net> wrote:

> Please find attached a WIP patch to have ALTER EXTENSION ADD/DROP update
> pg_init_privs accordingly.
>

Thanks so much Stephen.

We're not used to compiling from source around here, so it may be difficult
for me to find the time to test, but if I am able, I will let you know.
-- 
Moshe Jacobson
Principal Architect, Nead Werx Inc.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-20 22:10               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-23 15:23                 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
@ 2017-01-23 15:32                   ` Stephen Frost <sfrost@snowman.net>
  0 siblings, 0 replies; 18+ messages in thread

From: Stephen Frost @ 2017-01-23 15:32 UTC (permalink / raw)
  To: Moshe Jacobson <moshe@neadwerx.com>; +Cc: pgsql-bugs

* Moshe Jacobson (moshe@neadwerx.com) wrote:
> On Fri, Jan 20, 2017 at 5:10 PM Stephen Frost <sfrost@snowman.net> wrote:
> > Please find attached a WIP patch to have ALTER EXTENSION ADD/DROP update
> > pg_init_privs accordingly.
> 
> Thanks so much Stephen.
> 
> We're not used to compiling from source around here, so it may be difficult
> for me to find the time to test, but if I am able, I will let you know.

No problem.  I'm planning to push it later today and it'll be in 9.6.2.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:08           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 19:16             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-30 04:30               ` Stephen Frost <sfrost@snowman.net>
  2 siblings, 0 replies; 18+ messages in thread

From: Stephen Frost @ 2017-01-30 04:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; daniele.varrazzo@gmail.com; pgsql-bugs

All,

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Stephen Frost <sfrost@snowman.net> writes:
> > * Tom Lane (tgl@sss.pgh.pa.us) wrote:
> >> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> >> absorb whatever the object's current ACLs are into the pg_init_privs
> >> entries for the extension.  (I don't think it does that now, though
> >> I might be wrong.)  However ...
> 
> > I've not gone and looked yet, but I doubt that it does.  I think I can
> > agree with the argument that it really should add those ACLs to
> > pg_init_privs.  Of course, any furhter manipulation of the ACLs from
> > that point will cause those ACLs to be included in the pg_dump.
> 
> > I'll take a look at ALTER EXTENSION ADD and pg_init_privs.
> 
> By the same token, does ALTER EXTENSION DROP remove those entries?

I've pushed a fix for this and back-patched it to 9.6.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-12 19:10           ` Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 21:00             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 18+ messages in thread

From: Moshe Jacobson @ 2017-01-12 19:10 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; pgsql-bugs

Hi Tom,

Thanks for the response.

On Thu, Jan 12, 2017 at 2:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> >    3. Extension changes ACLs on the table.
>
> Extensions are not actors, so claiming that "the extension" did something
> is at best pretty fuzzy thinking.
>

Fair enough. The extension's includes code that stores logs into a table
that is partitioned by timestamp. A function belonging to the extension is
periodically called to rotate out the currently-active partition and create
a new one.


> >    4. After changing ACLs, the table is added to the extension (ALTER
> >    EXTENSION)
> >    5. A pg_dump of this database will now include ACL commands for the
> >    table.
>
> Hmm.  There's an argument to be made that ALTER EXTENSION ADD should
> absorb whatever the object's current ACLs are into the pg_init_privs
> entries for the extension.  (I don't think it does that now, though
> I might be wrong.)  However ...
>

Yes, that's what I'm arguing for. As I write this I see another message in
which it looks like Stephen has agreed to look at this, so thank you
Stephen!

>    6. A pg_restore of this file will give warnings because the ACLs refer
> >    to a table that is not created as part of the installation process.
>
> I think this scenario is simply pilot error, or at least gross abuse of
> the extension system.  If you dump and reload a DB containing an extension,
> the extension definition that's fetched by CREATE EXTENSION is expected
> to define (at least) all the objects that belonged to the extension in the
> old DB.  You can't just randomly ALTER EXTENSION and not update the
> extension definition script to match.
>

The reason I add the dynamically-created tables to the extension is so that
they are never included in the pg_dump output. If this is a gross abuse of
the extension system, is there another way you can suggest to mark these
tables as not-to-be-dumped?

Thank you.
-- 
Moshe Jacobson
Principal Architect, Nead Werx Inc.

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:10           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
@ 2017-01-12 21:00             ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 21:22               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Tom Lane @ 2017-01-12 21:00 UTC (permalink / raw)
  To: Moshe Jacobson <moshe@neadwerx.com>; +Cc: Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; pgsql-bugs

Moshe Jacobson <moshe@neadwerx.com> writes:
> On Thu, Jan 12, 2017 at 2:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I think this scenario is simply pilot error, or at least gross abuse of
>> the extension system.  If you dump and reload a DB containing an extension,
>> the extension definition that's fetched by CREATE EXTENSION is expected
>> to define (at least) all the objects that belonged to the extension in the
>> old DB.  You can't just randomly ALTER EXTENSION and not update the
>> extension definition script to match.

> The reason I add the dynamically-created tables to the extension is so that
> they are never included in the pg_dump output. If this is a gross abuse of
> the extension system, is there another way you can suggest to mark these
> tables as not-to-be-dumped?

The extension mechanism definitely isn't meant to do that ;-).  Maybe
you could put these not-to-dump tables in their own schema and exclude
that schema from pg_dump with -N?

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:10           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 21:00             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-01-12 21:22               ` Alvaro Herrera <alvherre@2ndquadrant.com>
  2017-01-12 21:27                 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 18+ messages in thread

From: Alvaro Herrera @ 2017-01-12 21:22 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; pgsql-bugs

Tom Lane wrote:
> Moshe Jacobson <moshe@neadwerx.com> writes:
> > On Thu, Jan 12, 2017 at 2:01 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> I think this scenario is simply pilot error, or at least gross abuse of
> >> the extension system.  If you dump and reload a DB containing an extension,
> >> the extension definition that's fetched by CREATE EXTENSION is expected
> >> to define (at least) all the objects that belonged to the extension in the
> >> old DB.  You can't just randomly ALTER EXTENSION and not update the
> >> extension definition script to match.
> 
> > The reason I add the dynamically-created tables to the extension is so that
> > they are never included in the pg_dump output. If this is a gross abuse of
> > the extension system, is there another way you can suggest to mark these
> > tables as not-to-be-dumped?
> 
> The extension mechanism definitely isn't meant to do that ;-).  Maybe
> you could put these not-to-dump tables in their own schema and exclude
> that schema from pg_dump with -N?

Is this related to this commit?
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f2fcad27d59c8e5c48f8fa0a96c8355e4...

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension
  2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
  2016-12-08 19:29 ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:24   ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 18:34     ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Stephen Frost <sfrost@snowman.net>
  2017-01-12 18:49       ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 19:01         ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 19:10           ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Moshe Jacobson <moshe@neadwerx.com>
  2017-01-12 21:00             ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Tom Lane <tgl@sss.pgh.pa.us>
  2017-01-12 21:22               ` Re: BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2017-01-12 21:27                 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 18+ messages in thread

From: Tom Lane @ 2017-01-12 21:27 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Moshe Jacobson <moshe@neadwerx.com>; Stephen Frost <sfrost@snowman.net>; daniele.varrazzo@gmail.com; pgsql-bugs

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> Moshe Jacobson <moshe@neadwerx.com> writes:
>>> The reason I add the dynamically-created tables to the extension is so that
>>> they are never included in the pg_dump output.

>> The extension mechanism definitely isn't meant to do that ;-).  Maybe
>> you could put these not-to-dump tables in their own schema and exclude
>> that schema from pg_dump with -N?

> Is this related to this commit?
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f2fcad27d59c8e5c48f8fa0a96c8355e4...

Seems like it doesn't quite match Moshe's use case --- he *doesn't* want
those tables dumped.  I'm not sure if he cares whether they have
dependencies on the extension.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2017-01-30 04:30 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-12-08 19:16 BUG #14456: pg_dump doesn't restore permissions on tables belonging to an extension daniele.varrazzo@gmail.com
2016-12-08 19:29 ` Stephen Frost <sfrost@snowman.net>
2017-01-12 18:24   ` Moshe Jacobson <moshe@neadwerx.com>
2017-01-12 18:34     ` Stephen Frost <sfrost@snowman.net>
2017-01-12 18:49       ` Moshe Jacobson <moshe@neadwerx.com>
2017-01-12 19:01         ` Tom Lane <tgl@sss.pgh.pa.us>
2017-01-12 19:08           ` Stephen Frost <sfrost@snowman.net>
2017-01-12 19:16             ` Tom Lane <tgl@sss.pgh.pa.us>
2017-01-12 19:24               ` Stephen Frost <sfrost@snowman.net>
2017-01-12 19:34                 ` Moshe Jacobson <moshe@neadwerx.com>
2017-01-20 22:10               ` Stephen Frost <sfrost@snowman.net>
2017-01-23 15:23                 ` Moshe Jacobson <moshe@neadwerx.com>
2017-01-23 15:32                   ` Stephen Frost <sfrost@snowman.net>
2017-01-30 04:30               ` Stephen Frost <sfrost@snowman.net>
2017-01-12 19:10           ` Moshe Jacobson <moshe@neadwerx.com>
2017-01-12 21:00             ` Tom Lane <tgl@sss.pgh.pa.us>
2017-01-12 21:22               ` Alvaro Herrera <alvherre@2ndquadrant.com>
2017-01-12 21:27                 ` Tom Lane <tgl@sss.pgh.pa.us>

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