Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ci4Rh-0008Hs-6Y for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Feb 2017 19:25:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ci4Rg-0004uW-54 for pgsql-hackers@arkaria.postgresql.org; Sun, 26 Feb 2017 19:25:24 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ci4Rd-0004t6-VB for pgsql-hackers@postgresql.org; Sun, 26 Feb 2017 19:25:22 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ci4Ra-0000Ao-Gb for pgsql-hackers@postgresql.org; Sun, 26 Feb 2017 19:25:20 +0000 Received: by mail-wm0-x22a.google.com with SMTP id v77so48118892wmv.0 for ; Sun, 26 Feb 2017 11:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=kr/tpsjcCZb5wgFZUt+QW70ut0LR2cMGZVY0HSewQ2w=; b=u0Yc2oZXKJfobpxqgp1+OYtBd/fytv0zYqU0TkQ40q53lmoFNhK8VPVUZWE+W5M0X9 YJ69P3n+Rba1Wycar0tx7+WMC1orHKG8oGAfcmU6CiuZ/ZfqaAwk4GKHdPo2V3+Q7+zN 9UiC4KbkyNQ6Jd/w84JJSHyHaga4XIhLMZq4JAqzOHCaCu7YLPcw1vltweYWQ+sTyS1o Ct2sWcwH1VgqYyTnkNb3QXx/CMXB29rSoaQIOWypq4AIxkaJ13bGUg2uZ/+o58WnWiRh V5zW6irDFtmwkuc37rHXjei+sL3w+iFQdZFR+hIczgBncGiTGeNZnOOanhedB0KPVs2N 2w0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=kr/tpsjcCZb5wgFZUt+QW70ut0LR2cMGZVY0HSewQ2w=; b=daNkKklhxk1+TWVRJakYIZWp518Jm2UUhqMKM7MZ/lbitkfezo1CNZoh2VXKeU8ww7 BflRhjIFRHnRFFQeb+0OEnJqgcY+0Yg+ffb3romJqszUjGVUaFRhaRH85e5Oxhd8ENBN RJvd5hK3SlZycH42j5xiwUPNpSQBHBCpynuEBy0OFa7NQkTM81DUc6nfz2i3aYw35Irv Nhm/sWcslqDmnCLV/mVK7vB/ekd5+taudK8FjDoNYtfj/w8pRAw0mmzU0jXyMbbtPUdX qMmG+D3Rh1ktmTabt+4YXAVr1wh+P2irvg3T/oNeykSJ8oCgucwXVQTrdKqW1R9uUvzE BVQA== X-Gm-Message-State: AMke39lZ4OUZJU2WJwyNX1QvOyfIccT531U0+5LCe2dXAppVe0zrqMVQkngd+4R1Isl7T1E0aJF935Womj22xT5ajJRrJCZcjezhb3twyA2inDwCC0z2p+qxINwa/aU/Td9fP/IPFV2U9cpehaw7tOPxOUDCxhnxCTDfZU3sJ4AfFZQai/52xY8VavgNMQh8NImsp1E7cFiQ X-Received: by 10.28.141.16 with SMTP id p16mr10183817wmd.42.1488137115960; Sun, 26 Feb 2017 11:25:15 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id m80sm11235934wmi.34.2017.02.26.11.25.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Feb 2017 11:25:14 -0800 (PST) Subject: Re: PUBLICATIONS and pg_dump To: Stephen Frost , Peter Eisentraut References: <20170207201932.GH9812@tamriel.snowman.net> <9314263d-f331-3ef0-a127-0c475f133914@2ndquadrant.com> Cc: pgsql-hackers@postgresql.org From: Petr Jelinek Message-ID: <20682078-6656-e2c1-ac01-2423a4bbb853@2ndquadrant.com> Date: Sun, 26 Feb 2017 20:25:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------D7A43C67901D1BFFC87A67F8" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------D7A43C67901D1BFFC87A67F8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 08/02/17 05:02, Stephen Frost wrote: > Peter, > > On Tue, Feb 7, 2017 at 22:49 Peter Eisentraut > > wrote: > > On 2/7/17 3:19 PM, Stephen Frost wrote: > > I understand that this is a bit complicated, but I would have thought > > we'd do something similar to what is done for DEFAULT PRIVILEGES, > where > > we include the "global" default privileges when we are doing a dump of > > "everything", but if we're dumping a specific schema then we only > > include the default privileges directly associated with that schema. > > > > Perhaps we need to include publications which are specific to a > > particular table, but the current logic of, essentially, "always > include > > all publications" does not seem to make a lot of sense to me. > > I think it would be sensible to refine it along those lines. > > > Great! I've added it to the open items list for PG10. > Yeah that was oversight in initial patch, publications and their membership was supposed to be dumped only when table filter is not used. I mistakenly made it check for data_only instead of using the selectDumpableObject machinery. Fix attached. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------D7A43C67901D1BFFC87A67F8 Content-Type: text/x-patch; name="0001-Don-t-dump-publications-with-pg_dump-t.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Don-t-dump-publications-with-pg_dump-t.patch" =46rom 907dcca71712558ba954a28cdf65ccdd77473bfe Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Sun, 26 Feb 2017 20:12:26 +0100 Subject: [PATCH] Don't dump publications with pg_dump -t --- src/bin/pg_dump/pg_dump.c | 29 +++++++++++++++++++++++++---- src/bin/pg_dump/t/002_pg_dump.pl | 17 +++++++++-------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 7273ec8..8f7245d 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1613,6 +1613,23 @@ selectDumpableExtension(ExtensionInfo *extinfo, Dump= Options *dopt) } =20 /* + * selectDumpablePublicationTable: policy-setting subroutine + * Mark a publication table as to be dumped or not + * + * Publication tables have schemas but those should be ignored in decitions + * making as publications are only dumped when we are dumping everything. + */ +static void +selectDumpablePublicationTable(DumpableObject *dobj, Archive *fout) +{ + if (checkExtensionMembership(dobj, fout)) + return; /* extension membership overrides all else */ + + dobj->dump =3D fout->dopt->include_everything ? + DUMP_COMPONENT_ALL : DUMP_COMPONENT_NONE; +} + +/* * selectDumpableObject: policy-setting subroutine * Mark a generic dumpable object as to be dumped or not * @@ -3389,6 +3406,9 @@ getPublications(Archive *fout) if (strlen(pubinfo[i].rolname) =3D=3D 0) write_msg(NULL, "WARNING: owner of publication \"%s\" appears to be inv= alid\n", pubinfo[i].dobj.name); + + /* Decide whether we want to dump it */ + selectDumpableObject(&(pubinfo[i].dobj), fout); } PQclear(res); =20 @@ -3402,11 +3422,10 @@ getPublications(Archive *fout) static void dumpPublication(Archive *fout, PublicationInfo *pubinfo) { - DumpOptions *dopt =3D fout->dopt; PQExpBuffer delq; PQExpBuffer query; =20 - if (dopt->dataOnly) + if (!(pubinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) return; =20 delq =3D createPQExpBuffer(); @@ -3534,6 +3553,9 @@ getPublicationTables(Archive *fout, TableInfo tblinfo= [], int numTables) pubrinfo[j].dobj.namespace =3D tbinfo->dobj.namespace; pubrinfo[j].pubname =3D pg_strdup(PQgetvalue(res, j, i_pubname)); pubrinfo[j].pubtable =3D tbinfo; + + /* Decide whether we want to dump it */ + selectDumpablePublicationTable(&(pubrinfo[j].dobj), fout); } PQclear(res); } @@ -3547,12 +3569,11 @@ getPublicationTables(Archive *fout, TableInfo tblin= fo[], int numTables) static void dumpPublicationTable(Archive *fout, PublicationRelInfo *pubrinfo) { - DumpOptions *dopt =3D fout->dopt; TableInfo *tbinfo =3D pubrinfo->pubtable; PQExpBuffer query; char *tag; =20 - if (dopt->dataOnly) + if (!(pubrinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) return; =20 tag =3D psprintf("%s %s", pubrinfo->pubname, tbinfo->dobj.name); diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_du= mp.pl index f73bf89..40509a4 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -2242,14 +2242,14 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM= SQL WITH FUNCTION pg_catalog exclude_test_table =3D> 1, no_privs =3D> 1, no_owner =3D> 1, - only_dump_test_schema =3D> 1, - only_dump_test_table =3D> 1, pg_dumpall_dbprivs =3D> 1, schema_only =3D> 1, - section_post_data =3D> 1, - test_schema_plus_blobs =3D> 1, }, + section_post_data =3D> 1, }, unlike =3D> { section_pre_data =3D> 1, + only_dump_test_table =3D> 1, + test_schema_plus_blobs =3D> 1, + only_dump_test_schema =3D> 1, pg_dumpall_globals =3D> 1, pg_dumpall_globals_clean =3D> 1, }, }, 'ALTER PUBLICATION pub1 ADD TABLE test_table' =3D> { @@ -2268,16 +2268,17 @@ qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM= SQL WITH FUNCTION pg_catalog exclude_test_table_data =3D> 1, no_privs =3D> 1, no_owner =3D> 1, - only_dump_test_schema =3D> 1, - only_dump_test_table =3D> 1, pg_dumpall_dbprivs =3D> 1, schema_only =3D> 1, - section_post_data =3D> 1, - test_schema_plus_blobs =3D> 1, }, + section_post_data =3D> 1, }, unlike =3D> { section_pre_data =3D> 1, exclude_dump_test_schema =3D> 1, exclude_test_table =3D> 1, + only_dump_test_schema =3D> 1, + only_dump_test_table =3D> 1, + only_dump_test_table =3D> 1, + test_schema_plus_blobs =3D> 1, pg_dumpall_globals =3D> 1, pg_dumpall_globals_clean =3D> 1, }, }, =20 --=20 2.7.4 --------------D7A43C67901D1BFFC87A67F8 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------D7A43C67901D1BFFC87A67F8--