Re: Extension Templates S03E11

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Boszormenyi Zoltan <zb(at)cybertec(dot)at>, Thom Brown <thom(at)linux(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extension Templates S03E11
Date: 2013-11-30 09:05:39
Message-ID: 1385802339.7500.223.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2013-11-27 at 18:34 +0100, Dimitri Fontaine wrote:
> Stephen Frost <sfrost(at)snowman(dot)net> writes:
> > We already have other 'template' objects in the system and I'm not
> > excited about the confusion. This also applies to 'CreateTemplate',
> > 'CreateTemplateTupleDesc', right down to 'template.h' and 'template.c'.
>
...
> We could of course have a 50 lines templates.c file that calls into an
> extension_template.c file for the meat of the implementation if that's
> prefered by the project.

I think that Stephen was just talking about the naming. I would have
expected the names to be something like "xtmpl" (which is the shortest
abbreviation that came to my mind) rather than "tpl", for instance. Use
of "template" is a bit ambiguous.

> I merged your patch in, rebased against master, fixed some more typos I
> found, and filled in the gaps you found in the docs. Version 17 of the
> patch is attached to that email, passes `make check`.
>
> ENOTIME for building docs, will do tomorrow, I though you might
> appreciate an update meanwhile (and with some luck docs still build
> fine).

Yes, they build fine.

However, I find the "full version" quite awkward still. I don't think
it's purely a documentation issue -- the "default full version" concept
itself is a bit awkward.

If I understand correctly, it goes something like this:

When a user does:
CREATE EXTENSION foo VERSION '3.0';

and there are templates for 1.0, 2.0, and 2.1, and upgrades from
1.0->2.0, 2.0->2.1, and 2.1->3.0, then there are three possible actions
that might be taken:

1. Install 1.0 and run three upgrades
2. Install 2.0 and run two upgrade
3. Install 2.1 and run one upgrade

There are two ways to disambiguate:

1. Specify the initial version using "FROM 2.0" in CREATE EXTENSION
command (though the documentation seems to say that the FROM clause is
only useful for unpackaged, for some reason)
2. If not specified there, it falls through to DEFAULT FULL VERSION
for the extension template

But that's a little strange. Many extensions are likely to have all
relevant versions available in full, and DEFAULT FULL won't kick in.
Those that do make use of upgrade-only paths are likely to have a few
full versions and a few upgrade scripts based off each. If you pick a
default full version of 2.0, then it won't be useful for installing
version 1.0, nor version 23.7. In each of those cases, you'll want to
specify the FROM clause in CREATE EXTENSION.

I suppose the idea is to avoid the need for specifying "FROM" in the
common case where you want to install the latest version. But it seems
like you could just as well keep a full copy of the extension's latest
version, and just prune them out when they become old.

Unless I'm missing something, I'd be inclined to just get rid of the
concept of DEFAULT FULL VERSION just to keep the documentation simpler
without losing any real functionality.

In passing, I'll also make a quick complaint about the code:

/*
* If we have a full script for the target version (or a create
template),
* we don't need to care about unpackaged or default_major_version, nor
* about upgrade sequences.
*/

...

* If the user did
* ask for a target version that happens to be the same as the
* default_full_version, just install that one directly.

The second one (in an "else" branch) shouldn't happen, assuming
default_full_version points at a proper full version, right?

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2013-11-30 09:12:05 Re: fe-secure.c and SSL/TLS
Previous Message mohsen soodkhah mohammadi 2013-11-30 09:00:43 palloc0