Re: [HACKERS] Dumping database creation options and ACLs

Поиск
Список
Период
Сортировка
От Adrien Nayrat
Тема Re: [HACKERS] Dumping database creation options and ACLs
Дата
Msg-id 13156f0e-acf1-857e-c8d9-3c4bc39a99f9@dalibo.com
обсуждение исходный текст
Ответ на Dumping database creation options and ACLs  (Ronan Dunklau <ronan.dunklau@dalibo.com>)
Ответы Re: [HACKERS] Dumping database creation options and ACLs  (Robert Haas <robertmhaas@gmail.com>)
Re: [HACKERS] Dumping database creation options and ACLs  (Rafael Martinez <r.m.guerrero@usit.uio.no>)
Список pgsql-hackers
On 12/08/2014 04:21 PM, Ronan Dunklau wrote:
> Hello.
>
> As of now, the only way to restore database options and ACLs is to use
> pg_dumpall without the globals options. The often recommended pg_dumpall -g +
> individual dumps of the target databases doesn't restore those.
>
> Since pg_dump/pg_restore offer the ability to create the database, it should do
> so with the correct owner, options and database ACLs.
>
> There was some discussion about those issues a while ago (see
> http://www.postgresql.org/message-id/11646.1272814212@sss.pgh.pa.us for
> example). As I understand it, the best way to handle that would be to push
> these modifications in pg_dump, but it is unclear how it should be done with
> regards to restoring to a different database.
>
> In the meantime, it would be great to add an option to pg_dumpall allowing to
> dump this information. We could add the db creation in the output of
> pg_dumpall -g,  and add a specific --createdb-only option (similar to --roles-
> only and --tablespaces-only).
>
> Would such a patch be welcome ?
>
>
>

Hello,


As reported by Ronan there's no other option than using pg_dumpall to restore
database options and ACLs.

So, we use this trick to stop pg_dumpall before \connect and then use pg_restore:

pg_dumpall -s | sed -rn '/^\\connect/{q}; p' > database+grants.sql


Of course, it is not graceful as we just need results of pg_dumpall -g and what
the dumpCreateDB() function outputs.

What do you think about adding an option like --createdb-only (as suggested by
Ronan) for this?  I'm not fully satisfied with this name though, I'll be happy
if you have a better suggestion.

Attached a naive patch.

--
Adrien NAYRAT

http://dalibo.com - http://dalibo.org

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: [BUGS] [HACKERS] Segmentation fault in libpq
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: [HACKERS] Reducing pg_ctl's reaction time