Re: patch: option --if-exists for pg_dump
От | Alvaro Herrera |
---|---|
Тема | Re: patch: option --if-exists for pg_dump |
Дата | |
Msg-id | 20140228183100.GU4759@eldon.alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: patch: option --if-exists for pg_dump (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: patch: option --if-exists for pg_dump
Re: patch: option --if-exists for pg_dump |
Список | pgsql-hackers |
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. 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 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. 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. Other than the pg_dumpall issue, this patch seems ready. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Вложения
В списке pgsql-hackers по дате отправления: