pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: 唯一★ <270246512@qq.com>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: 回复:  回复:  回复: BUG #16101: tables in the DB is not available after pg_restore
Date: Sun, 17 Nov 2019 18:42:04 +0100
Message-ID: <20191117174204.etktdaygxvnd7vkj@development> (raw)
In-Reply-To: <23243.1574010031@sss.pgh.pa.us>
References: <16101-5a569e5aac6aa84e@postgresql.org>
	<20191108111339.xlopjkbwfhxfvwt3@development>
	<tencent_5865E10D689BCC05DFD0BC291ED869BEAA05@qq.com>
	<20191113133029.kagiy6vjjeoguatp@development>
	<tencent_9DD805D110A0A91F987ADEAB25EE2D69BB05@qq.com>
	<20191113151803.6ye47vh3vyp5ufah@development>
	<tencent_9BBC6D521745C3B6A62D60F2798F96A5B707@qq.com>
	<tencent_8F1706C3F7A62AE0C279A4169C37F36D3607@qq.com>
	<23243.1574010031@sss.pgh.pa.us>

On Sun, Nov 17, 2019 at 12:00:31PM -0500, Tom Lane wrote:
>"=?gb18030?B?zqjSu6Hv?=" <270246512@qq.com> writes:
>> Do you have update for this issue?
>
>You've done nothing to convince anyone that this isn't local
>misconfiguration or process error on your part.
>
>In particular, I still like the theory I offered in
>
>https://www.postgresql.org/message-id/5802.1573657223%40sss.pgh.pa.us
>
>that the permissions on the public schema don't allow your
>non-superuser role to access anything in that schema.
>
>Looking closer at the "pg_restore -v" trace you posted in
>
>https://www.postgresql.org/message-id/tencent_5865E10D689BCC05DFD0BC291ED869BEAA05%40qq.com
>
>bolsters this theory, because I see
>
>pg_restore: dropping COMMENT SCHEMA public
>pg_restore: dropping SCHEMA public
>pg_restore: creating SCHEMA "public"
>pg_restore: creating COMMENT "SCHEMA public"
>
>but there's never any later
>
>pg_restore: creating ACL "SCHEMA public"
>
>which there ought to be, and there is when I try to reproduce this.
>That means the public schema is ending up with default permissions,
>which grant no access to anyone but the owner.
>
>Perhaps this happened because you did the dump or the restore
>with -x (--no-privileges).  Or possibly that schema's privileges
>were manually modified at some earlier point.
>

Not quite, what seems to make the difference is whether pg_dump was
executed with '-c' switch. Without the switch we end up without ACL.
Consider this:

     $ psql -U postgres -c "CREATE DATABASE cmdb WITH OWNER cm TEMPLATE = template0"
     $ psql -U postgres -c "GRANT ALL PRIVILEGES ON SCHEMA public to cm"

     $ pg_dump -U postgres -d cmdb -Fc -f cmdb.dump -v
     $ pg_restore -U postgres -d cmdb cmdb.dump -c -v
     pg_restore: connecting to database for restore
     pg_restore: dropping COMMENT EXTENSION plpgsql
     pg_restore: dropping EXTENSION plpgsql
     pg_restore: dropping COMMENT SCHEMA public
     pg_restore: dropping SCHEMA public
     pg_restore: creating SCHEMA "public"
     pg_restore: creating COMMENT "SCHEMA public"
     pg_restore: creating EXTENSION "plpgsql"
     pg_restore: creating COMMENT "EXTENSION plpgsql"

     $ dropdb cmdb
     $ psql -U postgres -c "CREATE DATABASE cmdb WITH OWNER cm TEMPLATE = template0"
     $ psql -U postgres -c "GRANT ALL PRIVILEGES ON SCHEMA public to cm"

     $ pg_dump -U postgres -d cmdb -Fc -c -f cmdb.dump -v
     $ pg_restore -U postgres -d cmdb cmdb.dump -c -v

     pg_restore: connecting to database for restore
     pg_restore: dropping COMMENT EXTENSION plpgsql
     pg_restore: dropping EXTENSION plpgsql
     pg_restore: dropping ACL SCHEMA public
     pg_restore: dropping COMMENT SCHEMA public
     pg_restore: dropping SCHEMA public
     pg_restore: creating SCHEMA "public"
     pg_restore: creating COMMENT "SCHEMA public"
     pg_restore: creating EXTENSION "plpgsql"
     pg_restore: creating COMMENT "EXTENSION plpgsql"
     pg_restore: creating ACL "SCHEMA public"


>In any case, it's fairly hard to believe that you're giving us
>a completely accurate statement of facts, because the restore
>trace also includes errors like
>
>pg_restore: dropping TABLE pgbench_accounts
>pg_restore: [archiver (db)] Error from TOC entry 199; 1259 47945 TABLE pgbench_accounts cm
>pg_restore: [archiver (db)] could not execute query: ERROR:  table "pgbench_accounts" does not exist
>Command was: DROP TABLE public.pgbench_accounts;
>
>It seems very unlikely that you could have gotten that if you
>were restoring a dump you'd just created from the same database.
>So there are additional moving parts here that you have not
>mentioned.
>

Yeah, there's a fair amount of noise in this thread :-(


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services 





view thread (8+ messages)  latest in thread

Message-ID: <20191117174204.etktdaygxvnd7vkj@development>
Permalink:  ../20191117174204.etktdaygxvnd7vkj@development/
Also on:    postgresql.org/message-id/20191117174204.etktdaygxvnd7vkj@development

 · 

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-bugs@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, tgl@sss.pgh.pa.us, 270246512@qq.com
  Subject: Re: 回复:  回复:  回复: BUG #16101: tables in the DB is not available after pg_restore
  In-Reply-To: <20191117174204.etktdaygxvnd7vkj@development>
  References: <16101-5a569e5aac6aa84e@postgresql.org> <20191108111339.xlopjkbwfhxfvwt3@development> <tencent_5865E10D689BCC05DFD0BC291ED869BEAA05@qq.com> <20191113133029.kagiy6vjjeoguatp@development> <tencent_9DD805D110A0A91F987ADEAB25EE2D69BB05@qq.com> <20191113151803.6ye47vh3vyp5ufah@development> <tencent_9BBC6D521745C3B6A62D60F2798F96A5B707@qq.com> <tencent_8F1706C3F7A62AE0C279A4169C37F36D3607@qq.com> <23243.1574010031@sss.pgh.pa.us> <20191117174204.etktdaygxvnd7vkj@development>

* 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