Re: Extensions, patch 22 (cleanup, review, cleanup)

From: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extensions, patch 22 (cleanup, review, cleanup)
Date: 2010-12-21 09:16:03
Message-ID: 87vd2nbi5o.fsf@hi-media-techno.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> function <link linkend="functions-extension">pg_extension_flag_dump</link>
[...]
> So presumably this shouldn't be documented because it cannot be called
> anyway?

It can be called but only from an extension's script.

> To be honest I don't understand the purpose of this part of the patch.

So the problem we're offering a solution for, here, is the extension
with user data problem: the extension infrastructure is only there so
that pg_dump knows to filter OUT sql objects from its dump, prefering a
single create extension command. Some extension allows users to control
the data in some of they're objects: now you want to have those in the
backup again.

From the docs:

http://pgsql.tapoueh.org/extensions/doc/html/functions-admin.html#FUNCTIONS-EXTENSION

pg_extension_with_user_data allows extension's author to prepare
installation scripts that will work well for initial installation and
when restoring from a pg_dump backup, which issues CREATE EXTENSION
foo WITH NO USER DATA;. See CREATE EXTENSION for details. One way to
use it is as following:

DO $$
BEGIN
IF pg_extension_with_user_data() THEN
create schema foo;
create table foo.bar(id serial primary key);
perform pg_extension_flag_dump('foo.bar_id_seq'::regclass);
perform pg_extension_flag_dump('foo.bar::regclass);
END IF;
END;
$$;

I don't really know how to improve the docs, you seem to have been
surprised by reading the CREATE EXTENSION docs but you didn't follow the
link to the function's doc with the above details, did you?

I'm open to improving things here, but I'm not seeing how yet.

> I attach some minor fixes while reading it over. I compiled but didn't
> run it :-)

Thanks a lot, that's applied in my git repo, and I did run it
successfully! It will be part of the next patch revision.

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message tv 2010-12-21 10:37:42 Re: proposal : cross-column stats
Previous Message Dimitri Fontaine 2010-12-21 08:57:12 Re: Extensions, patch 22 (cleanup, review, cleanup)