Re: pg_restore ERROR: permission denied to change default privileges

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rachel Roch <rroch(at)tutanota(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pgsql General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_restore ERROR: permission denied to change default privileges
Date: 2025-06-14 15:21:19
Message-ID: c3e27dc2-343d-48dd-bf05-a1404e6939ec@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/14/25 01:42, Rachel Roch wrote:
>
>
>
> 13 Jun 2025, 20:13 by adrian(dot)klaver(at)aklaver(dot)com:
>
>>
>> To get at an editable script you can do something like:
>>
>> pg_restore -f my_database_txt.sql my_database.dump
>>
>> This will give you a plain text version of the dump that you can feed back to psql to load into remote database.
>>
>
> Thanks Adrian !
>
> I had thought maybe maybe I could do a "pg_restore -l my_database.dump" and ignore the relevant line using whatever the other flag is, but sadly there doesn't appear to be enough flexibility, i.e.
>
> pg_restore -l my_database.dump | fgrep -F postgres
> gives:
> 2067; 826 16607 DEFAULT ACL public DEFAULT PRIVILEGES FOR TABLES postgres
>
> But
>
> pg_restore -l my_database.dump | fgrep -F my_database_ro
> gives nothing.   :(

That is because the lines returned from pg_restore -l are not the full
commands, they represent(generally) a summary of the object, its name
and the owner.

The error message and your first example above show that the command is
there. See at here:

https://www.postgresql.org/docs/current/app-pgrestore.html

in the Examples section how you can comment out the line. Then you could
use -L to feed the list back to pg_restore.

Isn't fgrep -F redundant? As I understand it fgrep = grep -F

>
> So either your solution or Tom's "just ignore it" sound like they'll work.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rachel Roch 2025-06-15 08:06:40 Re: pg_restore ERROR: permission denied to change default privileges
Previous Message Rachel Roch 2025-06-14 08:42:59 Re: pg_restore ERROR: permission denied to change default privileges