Re: ALTER EXTENSION UPGRADE, v3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: marcin mank <marcin(dot)mank(at)gmail(dot)com>
Cc: Kääriäinen Anssi <anssi(dot)kaariainen(at)thl(dot)fi>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, "David E(dot) Wheeler" <david(at)kineticode(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER EXTENSION UPGRADE, v3
Date: 2011-02-12 03:29:36
Message-ID: 17042.1297481376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

marcin mank <marcin(dot)mank(at)gmail(dot)com> writes:
> On Fri, Feb 11, 2011 at 8:15 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Hmm. That seems like it would require a rather pathological collection
>> of upgrade scripts. In particular why would you have a one-step upgrade
>> from 1.1 to 2.0 but no short path from 1.2?

> Say we have 20 versions, with up- and downgrade scripts between
> consecutive versions, and a fast path from 5 to 20.
> if we are at version 6, it would go 6->5->20. if 6->5 drops a table,
> we`re in trouble.

So basically, to get into trouble you need all three of these elements:

1. A downgrade script;

2. A fast-path upgrade script that reverses the effect of the downgrade
and skips at least two versions further than that;

3. An irreversible action in the downgrade script.

That seems sufficiently far-fetched to me that documenting the hazard
ought to be enough (and I've done so).

If we could identify downgrade scripts, it would be easy enough to
modify the shortest-path algorithm to not use them unless necessary
(by assigning them a very large weight instead of weight 1). However,
I'm still not excited about defining a version comparison rule just for
that. One possibility is to invent a file naming rule that marks
downgrade scripts, for example an extra dash:

extension-oldversion-newversion-.sql

I'm really not convinced it's worth the trouble, though.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-02-12 04:10:27 Re: [pgsql-general 2011-1-21:] Are there any projects interested in object functionality? (+ rule bases)
Previous Message Alex Hunsaker 2011-02-12 03:12:08 Re: pl/python tracebacks