Re: patch: option --if-exists for pg_dump
От | Pavel Stehule |
---|---|
Тема | Re: patch: option --if-exists for pg_dump |
Дата | |
Msg-id | CAFj8pRDQC70eH6z1=KuHPEFAG62-trmaJVJ5oXX2PoqFmKhf9A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: patch: option --if-exists for pg_dump (Alvaro Herrera <alvherre@2ndquadrant.com>) |
Список | pgsql-hackers |
2014-02-28 19:31 GMT+01:00 Alvaro Herrera <alvherre@2ndquadrant.com>:
Pavel Stehule escribió:Nice, thanks.
> 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
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
В списке pgsql-hackers по дате отправления: