Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTAui-00036T-IB for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 22:08:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lTAuh-0003da-H9 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Apr 2021 22:08:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTAuh-0003dT-2B for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 22:08:11 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lTAue-0003YC-Ot for pgsql-hackers@lists.postgresql.org; Sun, 04 Apr 2021 22:08:10 +0000 Received: by mail-pl1-x631.google.com with SMTP id v8so4788584plz.10 for ; Sun, 04 Apr 2021 15:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rA4wUiZ7cTVqDFQfRY4vfR5OPA5Vbzw3R16kAxjSlcs=; b=DG1KmrtvOeT7UTKxuPaqNEp/qAkCUaCLtphtihSo3+U+dv3ElS/iv+9F3C+BQ2K2ds lXmR1uzy5E4IykrkmmyWR+igF0cGAiihwPPG5bZNgmrUb3PGmf2m26vtuzrZU8rEDeh0 wOAJnmOAMtv0Jo6UoC4V0iZE9yEoxUdncOjvI= 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:user-agent; bh=rA4wUiZ7cTVqDFQfRY4vfR5OPA5Vbzw3R16kAxjSlcs=; b=YVxTVZ4uG+OIrWDm/j5CU/xzZJ0zH3gIpvhdLb3ClF9RpHxwC2S2pFGckwhHTOWWUx XhjOKSdpm0zg8GbkhetnP88NSac9XpeHp/C63bQVpFx3k1gDxNf9Kq0bR+zwUHxk+7rA sRgjj9VOG9OubZdiQUqX88RaZPwr6qLVo9mQ+TIxUUpI5E7G3Q1aUw8LZsQ9VSNXBCgp IDXXX8s2Y8mYqXWiGewB52/PTyhtmO27M3KSBrNhaH3SmngeeBtAR3SwYop5Hgtkysos hh+UcBwrLTNHml00EHIy6buF6J1HQJEdWD2erOqrK0xAE8azH+c/39k/Cils2bX7mfUa jwlw== X-Gm-Message-State: AOAM533oRfyw6uN9RvRYSajtKadbhU/hktKzCX5gAppOps96ZYvpM4R3 JjdhMTge3/Qfl27lbQgZPJraZw== X-Google-Smtp-Source: ABdhPJzHnkDzGyW9oTCbOLHKqPJWEQhNH88obP9T/P5ZbgJZQwlm6YXULs6xwS/YTW5DC5SkhVTAjg== X-Received: by 2002:a17:90a:5898:: with SMTP id j24mr23900501pji.103.1617574086350; Sun, 04 Apr 2021 15:08:06 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id n10sm13477243pjo.15.2021.04.04.15.08.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Apr 2021 15:08:04 -0700 (PDT) Date: Sun, 4 Apr 2021 15:08:02 -0700 From: Noah Misch To: Michael Paquier Cc: Guillaume Lelarge , Julien Rouhaud , Tom Lane , Daniel Gustafsson , PostgreSQL Hackers Subject: Re: Extensions not dumped when --schema is used Message-ID: <20210404220802.GA728316@rfd.leadboat.com> References: <20210315102155.qgp32wo6tcuu6w4l@nol> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 31, 2021 at 09:37:44AM +0900, Michael Paquier wrote: > On Tue, Mar 30, 2021 at 12:02:45PM +0900, Michael Paquier wrote: > > Okay. So I have looked at that stuff in details, and after fixing > > all the issues reported upthread in the code, docs and tests I am > > finishing with the attached. The tests have been moved out of > > src/bin/pg_dump/ to src/test/modules/test_pg_dump/, and include both > > positive and negative tests (used the trick with plpgsql for the > > latter to avoid the dump of the extension test_pg_dump or any data > > related to it). > > I have double-checked this stuff this morning, and did not notice any > issues. So, applied. I noticed the patch's behavior for relations that are members of non-dumped extensions and are also registered using pg_extension_config_dump(). It depends on the schema: - If extschema='public', "pg_dump -e plpgsql" makes no mention of the relations. - If extschema='public', "pg_dump -e plpgsql --schema=public" includes commands to dump the relation data. This surprised me. (The --schema=public argument causes selectDumpableNamespace() to set nsinfo->dobj.dump=DUMP_COMPONENT_ALL instead of DUMP_COMPONENT_ACL.) - If extschema is not any sort of built-in schema, "pg_dump -e plpgsql" includes commands to dump the relation data. This surprised me. I'm attaching a test case patch that demonstrates this. Is this behavior intentional? --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="without_extension_explicit_schema-v0.patch" commit d210c01 (demo-dumpext-public) Author: Noah Misch AuthorDate: Thu Apr 1 17:36:13 2021 -0700 Commit: Noah Misch CommitDate: Thu Apr 1 17:36:13 2021 -0700 demo --- src/test/modules/test_pg_dump/t/001_base.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index 7c053c4..600015e 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -203,11 +203,23 @@ my %pgdump_runs = ( }, # plgsql in the list blocks the dump of extension test_pg_dump + # TODO --no-sync needn't appear twice without_extension => { dump_cmd => [ 'pg_dump', '--no-sync', "--file=$tempdir/without_extension.sql", '--extension=plpgsql', '--no-sync', 'postgres', ], + }, + + without_extension_explicit_schema => { + dump_cmd => [ + 'pg_dump', + '--no-sync', + "--file=$tempdir/without_extension_explicit_schema.sql", + '--extension=plpgsql', + '--schema=public', + 'postgres', + ], },); ############################################################### @@ -632,6 +644,8 @@ my %tests = ( pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, + # excludes this schema + without_extension_explicit_schema => 1, }, }, @@ -646,6 +660,8 @@ my %tests = ( pg_dumpall_globals => 1, section_data => 1, section_pre_data => 1, + # excludes this schema + without_extension_explicit_schema => 1, }, }, --4Ckj6UjgE2iN1+kY--