Re: Exclude schema during pg_restore

From: Michael Banck <michael(dot)banck(at)credativ(dot)de>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Exclude schema during pg_restore
Date: 2016-09-19 19:23:10
Message-ID: 20160919192310.GA10054@nighthawk.caipicrew.dd-dns.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

sorry, it took me a while to find time to look at this.

On Thu, Sep 01, 2016 at 09:39:56PM -0400, Peter Eisentraut wrote:
> On 8/31/16 4:10 AM, Michael Banck wrote:
> > attached is a small patch that adds an -N option to pg_restore, in order
> > to exclude a schema, in addition to -n for the restriction to a schema.
>
> I think this is a good idea, and the approach looks sound. However,
> something doesn't work right. If I take an empty database and dump it,
> it will dump the plpgsql extension. If I run pg_dump in plain-text mode
> with -N, then the plpgsql extension is also dumped (since it is not in
> the excluded schema). But if I use the new pg_restore -N option, the
> plpgsql extension is not dumped. Maybe this is because it doesn't have
> a schema, but I haven't checked.

I was afraid that this might need major code surgery, but in the end it
seems this was just a thinko on my part in tocEntryRequired(). For the
exclude-schema case, we shouldn't skip objects without a namespace (like
the plpgsql extension you mentioned above).

> pg_dump does not apply --strict-names to -N, but your patch for
> pg_restore does that. I think that should be made the same as pg_dump.

Ok, I've removed that hunk.

Version 2 attached.

Michael

--
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax: +49 2166 9901-100
Email: michael(dot)banck(at)credativ(dot)de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Attachment Content-Type Size
pg_restore-exclude-schema_v2.patch text/x-diff 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2016-09-19 19:46:57 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Previous Message Dave Cramer 2016-09-19 19:16:19 Re: Fix for PL/Python slow input arrays traversal issue