pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[patch] Bug in pg_dump/pg_restore using --no-publication
2+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2018-09-25 08c9917e24 1f50394119 55a586ba97  Ignore publication tables when --no-publications is used
* [patch] Bug in pg_dump/pg_restore using --no-publication
@ 2018-09-21 15:44  Gilles Darold <gilles.darold@dalibo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Gilles Darold @ 2018-09-21 15:44 UTC (permalink / raw)
  To: pgsql-hackers@lists.postgresql.org

Hi,


Attached is a patch that fixes a bug in pg_dump since 10.0 and
reproducible in master. When using option --no-publication : ALTER
PUBLICATION orders are still present in the dump.


Steps to reproduce:

postgres=# CREATE DATABASE test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# create table t1 (id integer);
CREATE TABLE
test=# CREATE PUBLICATION p1 FOR TABLE t1;
CREATE PUBLICATION
test=# CREATE PUBLICATION p_all FOR ALL TABLES;
CREATE PUBLICATION
test=# CREATE PUBLICATION p_insert_only FOR TABLE t1 WITH (publish =
'insert');
CREATE PUBLICATION
test=# \q

$ pg_dump -p 5400 --no-publication test | grep PUBLICATION
-- Name: p1 t1; Type: PUBLICATION TABLE; Schema: public; Owner:
ALTER PUBLICATION p1 ADD TABLE ONLY public.t1;
-- Name: p_insert_only t1; Type: PUBLICATION TABLE; Schema: public; Owner:
ALTER PUBLICATION p_insert_only ADD TABLE ONLY public.t1;


pg_restore suffers the same problem:

pg_restore --no-publication test.dump | grep PUBLICATION
-- Name: p1 t1; Type: PUBLICATION TABLE; Schema: public; Owner:
ALTER PUBLICATION p1 ADD TABLE ONLY public.t1;
-- Name: p_insert_only t1; Type: PUBLICATION TABLE; Schema: public; Owner:
ALTER PUBLICATION p_insert_only ADD TABLE ONLY public.t1;

pg_restore --no-publication test.dump -l test.dump| grep PUBLICATION
2230; 6106 16389 PUBLICATION TABLE public p1 t1
2231; 6106 16392 PUBLICATION TABLE public p_insert_only t1


Should I add it to current commitfest ?


-- 
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org

Attachments:

patch_pg_dump_option_no_publication-v1.diff (text/x-patch, 1.3K) download diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 7d1d439ba2..2e86664c17 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -2920,7 +2920,8 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) return 0; /* If it's a publication, maybe ignore it */ - if (ropt->no_publications && strcmp(te->desc, "PUBLICATION") == 0) + if (ropt->no_publications && (strcmp(te->desc, "PUBLICATION") == 0 + || strcmp(te->desc, "PUBLICATION TABLE") == 0)) return 0; /* If it's a security label, maybe ignore it */ diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 0687a81914..c8d01ed4a4 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -3907,6 +3907,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables) PQExpBuffer query; PGresult *res; PublicationRelInfo *pubrinfo; + DumpOptions *dopt = fout->dopt; int i_tableoid; int i_oid; int i_pubname; @@ -3914,7 +3915,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables) j, ntups; - if (fout->remoteVersion < 100000) + if (dopt->no_publications || fout->remoteVersion < 100000) return; query = createPQExpBuffer();
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: [patch] Bug in pg_dump/pg_restore using --no-publication
@ 2018-09-25 02:08  Michael Paquier <michael@paquier.xyz>
  parent: Gilles Darold <gilles.darold@dalibo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2018-09-25 02:08 UTC (permalink / raw)
  To: Gilles Darold <gilles.darold@dalibo.com>; +Cc: pgsql-hackers@lists.postgresql.org

On Fri, Sep 21, 2018 at 05:44:02PM +0200, Gilles Darold wrote:
> Attached is a patch that fixes a bug in pg_dump since 10.0 and
> reproducible in master. When using option --no-publication : ALTER
> PUBLICATION orders are still present in the dump.

Thanks for the report, the patch, and the test case, Gilles!

> pg_restore --no-publication test.dump -l test.dump| grep PUBLICATION
> 2230; 6106 16389 PUBLICATION TABLE public p1 t1
> 2231; 6106 16392 PUBLICATION TABLE public p_insert_only t1

This command does not actually work ;)

> Should I add it to current commitfest ?

No need to.  I have committed your patch down to v10 after making sure
that we are not missing any other spots, and testing each branch
manually.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-09-25 02:08 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-21 15:44 [patch] Bug in pg_dump/pg_restore using --no-publication Gilles Darold <gilles.darold@dalibo.com>
2018-09-25 02:08 ` Michael Paquier <michael@paquier.xyz>

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