Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iWOYw-0003wn-S6 for pgsql-bugs@arkaria.postgresql.org; Sun, 17 Nov 2019 17:42:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iWOYv-0000IR-4e for pgsql-bugs@arkaria.postgresql.org; Sun, 17 Nov 2019 17:42:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iWOYu-0000IK-Su for pgsql-bugs@lists.postgresql.org; Sun, 17 Nov 2019 17:42:12 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iWOYs-000420-4D for pgsql-bugs@lists.postgresql.org; Sun, 17 Nov 2019 17:42:12 +0000 Received: by mail-wm1-x341.google.com with SMTP id 8so16246925wmo.0 for ; Sun, 17 Nov 2019 09:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WKOMMk8c0FRj6XE8P4YogjU09JRSWEHKWHvIIc4dh1Q=; b=lKEknkCUnKnNFTJECx9d7wqeEbh6WGPT3xxtOZYl2wSNrnRK5mTA1r200d9e3PhQQt 8+pX3DJxYLK3GqF62hIJgPm+xIUmHU4X++BhQXD75bxlOJhCIq3KGxG5j6ogdhNW/PJg R7JQgKryFhwZFetHombNyHXvJqEYSivh2Yi+m5GKeiZZL6mzYwQphfqhSzfzSfpFU/UI nV3xPRFXwLMKClL2HS+VcpPpP/2bHd6OYC8acZuQj0KvRraJSPk0ULIs9/CES0pB6HoZ YsoyISP3EBG3Bc3OMqtsO9lHjWEIQfPNOzZrCx7gA4plOgRQ3sRe81hFiTo1OMBdQ0dg 1ioQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WKOMMk8c0FRj6XE8P4YogjU09JRSWEHKWHvIIc4dh1Q=; b=ARhkVTOBMgN9SjaXXnqJEhLiiDqXAxFuhbQZ7H6/6MFn0X3pWvF3WMkxEGVoTvuVzL +/Bs8Zp7OLuD8EsflZRprlUCpCcGTPBIbR9t6Xcs93Aj4ycZoTCzIW3i9LelorMJaz9q 8fPNhXsLvHHwrAunV+N7J2ZNkvx7JAWlNgRdigFVyzjg66H8XS1oIVeU1rHK9gpVl5W3 RonUgcpF87Q5yaFgGEtQFyLVsOkIgrplaDXQDnqO2Bzv2Y+s4Nt/1Vco2jhPkd1jFdtB RT+ofRoW9b4nQYaAQr3it4EhPlAJgVb7nMyFmi9U6Q2z3qRYquwPsaZzWxOJfAd+rJLF uxfA== X-Gm-Message-State: APjAAAXqeP2Ej2fAxVk2EEsaMbiIFq5cSYHSnHrHQzVq1I8dH/Ru/hQI SIEIdhG34DeW05nRP274NcQ1Dg== X-Google-Smtp-Source: APXvYqwofsyVUoEWha3SYIIotUOzVvEUtwhXIKX+z6ipvzF9gtHM4yK9aLithULPOBFYJpuv0Alacg== X-Received: by 2002:a1c:8055:: with SMTP id b82mr26099812wmd.176.1574012527284; Sun, 17 Nov 2019 09:42:07 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id w19sm17123772wmk.36.2019.11.17.09.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 09:42:06 -0800 (PST) Date: Sun, 17 Nov 2019 18:42:04 +0100 From: Tomas Vondra To: Tom Lane Cc: =?utf-8?B?5ZSv5LiA4piF?= <270246512@qq.com>, pgsql-bugs Subject: Re: =?utf-8?B?5Zue5aSN77yaICDlm57lpI3vvJogIOWbnuWkje+8miBCVQ==?= =?utf-8?Q?G?= #16101: tables in the DB is not available after pg_restore Message-ID: <20191117174204.etktdaygxvnd7vkj@development> References: <16101-5a569e5aac6aa84e@postgresql.org> <20191108111339.xlopjkbwfhxfvwt3@development> <20191113133029.kagiy6vjjeoguatp@development> <20191113151803.6ye47vh3vyp5ufah@development> <23243.1574010031@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <23243.1574010031@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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