Re: Extensions not dumped when --schema is used

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Extensions not dumped when --schema is used
Date: 2020-05-20 09:38:21
Message-ID: CAECtzeVD7ktWWE=23pb5o4kNbEEjQZJ5w+skEmM0yoW7NtfSqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le mer. 20 mai 2020 à 11:26, Daniel Gustafsson <daniel(at)yesql(dot)se> a écrit :

> > On 20 May 2020, at 10:06, Guillaume Lelarge <guillaume(at)lelarge(dot)info>
> wrote:
>
> > I was wondering the reason behind this choice. If anyone knows, I'd be
> happy to hear about it.
>
> Extensions were dumped unconditionally in the beginning, but it was
> changed to
> match how procedural language definitions were dumped.
>
>
That makes sense. Thank you.

> * it's been overlooked, and we should dump all the extensions available
> in a schema if this schema has been selected through the --schema flag.
>
> For reference, --schema-only will include all the extensions, but not
> --schema=foo and not "--schema-only --schema=foo".
>
>
Yes.

Extensions don't belong to a schema per se, the namespace oid in
> pg_extension
> marks where most of the objects are contained but not necessarily all of
> them.
> Given that, it makes sense to not include extensions for --schema.
> However,
> that can be considered sort of an implementation detail which may not be
> entirely obvious to users (especially since you yourself is a power-user).
>
>
I agree.

> * it's kind of like the large objects handling, and I'd pretty interested
> in adding a --extensions (as the same way there is a --blobs flag).
>
> An object in a schema might have attributes that depend on an extension in
> order to restore, so it makes sense to provide a way to include them for a
> --schema dump.

That's actually how I figured this out. A customer can't restore his dump
because of a missing extension (pg_trgm to be precise).

The question is what --extensions should do: only dump any
> extensions that objects in the schema depend on; require a pattern and only
> dump matching extensions; dump all extensions (probably not) or something
> else?
>
>
Actually, "dump all extensions" (#3) would make sense to me, and has my
vote. Otherwise, and though it would imply much more work, "only dump any
extension that objects in the schema depend on" (#1) comes second in my
opinion. Using the pattern means something more manual for users, and I
really think it would be a bad idea. People dump databases, schemas, and
tables. Theu usually don't know which extensions those objects depend on.
But, anyway, I would work on any of these solutions, depending on what most
people think is best.

Thanks.

--
Guillaume.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2020-05-20 09:52:25 pgindent vs dtrace on macos
Previous Message Daniel Gustafsson 2020-05-20 09:26:36 Re: Extensions not dumped when --schema is used