Re: patch: option --if-exists for pg_dump

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Jeevan Chalke <jeevan(dot)chalke(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Josh Kupershmidt <schmiddy(at)gmail(dot)com>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Subject: Re: patch: option --if-exists for pg_dump
Date: 2014-02-28 19:02:37
Message-ID: CAFj8pRDQC70eH6z1=KuHPEFAG62-trmaJVJ5oXX2PoqFmKhf9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2014-02-28 19:31 GMT+01:00 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>:

> Pavel Stehule escribió:
>
> > It is irony, so this is death code - it is not used now. So I removed it
> > from patch.
> >
> > Reduced, fixed patch attached + used tests
>
> Nice, thanks.
>
> Here's a new version in which I reworded some comments and docs, and
> also inverted the sense of some if/else so that the oneliner case is
> first, which makes it more readable IMHO.
>

ok

thank you

>
> However, I don't think this is behaving sanely in pg_dumpall. AFAICT,
> pg_dumpall does not pass --clean to pg_dump (in other words it only
> emits DROP for the global objects, not the objects contained inside
> databases), so passing --if-exists results in failures. Therefore I
> think the solution is to not pass --if-exists to pg_dump at all, i.e.
> keep it internal to pg_dumpall. But maybe I'm missing something.
>
>
I'll look on it tomorrow

> I still find the code to inject IF EXISTS to the DROP commands ugly as
> sin. I would propose to stop storing the dropStmt in the archive
> anymore; instead just store the object identity, which can later be used
> to generate both DROP commands, with or without IF EXISTS, and the ALTER
> OWNER commands. However, that's a larger project and I don't think we
> need to burden this patch with that.
>

there are more similar parts - and I am not sure if it is little bit heroic
task.

>
> Another point is that we could argue about whether specifying
> --if-exists ought to imply --clean instead of erroring out. There's no
> backwards compatibility argument to be had; it's not like existing
> scripts are going to suddenly start dropping objects that weren't
> dropped before.
>

It is valid idea. I looked on any other options for and I don't known any
similar implication - so I prefer current implementation (no implication).
It is consistent with any other. I have not strong opinion about it - a
user comfort is against a clarity - but two "clean" option can be confusing
maybe.

Regards

Pavel

>
> Other than the pg_dumpall issue, this patch seems ready.
>
> --
> Álvaro Herrera http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2014-02-28 19:07:48 Re: proposal: new long psql parameter --on-error-stop
Previous Message Tom Lane 2014-02-28 19:00:32 Re: jsonb and nested hstore