Re: Fast default stuff versus pg_upgrade

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fast default stuff versus pg_upgrade
Date: 2018-06-19 17:39:49
Message-ID: a7b651b2-0952-2d29-7e1d-632fb31b54c6@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 06/19/2018 01:19 PM, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
>> On 2018-06-19 12:37:52 -0400, Tom Lane wrote:
>>> The problem here is that that function does not exist in 11beta1.
>>> Since adding the "incoming" function is certainly going to require
>>> initdb, we have to be able to dump from the server as it now stands,
>>> or we'll be cutting existing beta testers adrift.
>> It'd probably not be too hard to write a plpgsql replacement for it,
>> should it come to that. Obviously it'd be nicer to not require users to
>> create that, but ...
> After some thought, I think it's not that hard to get the support function
> to accept the anyarray string form. I was worried about issues like
> whether float8 values would restore exactly, but really that's no worse
> than a dump/reload today. Basically, the support function would just need
> to extract the target attribute's type and typmod from the pg_attribute
> row, then call array_in().
>
> I wonder though whether there are any interesting corner cases along
> this line:
>
> 1. Create a column with a fast default.
>
> 2. Sometime later, alter the column so that the fast default value
> is no longer a legal value. If the fast default isn't in active use
> in the table, the ALTER would go through; but if it does not remove
> the attmissingval entry, then ...
>
> 3. Subsequently, pg_upgrade fails when the support function tries to
> pass the attmissingval entry through the type input function.
>
> The kind of case where this might fail is reducing the allowed
> max len (typmod) for a varchar column. I think ALTER TABLE is
> smart enough to not rewrite the table for that, so that there
> wouldn't be anything causing the fast default to get removed.
>
>

My experimentation showed this causing a rewrite. I think it only skips
the rewrite if you make the allowed length greater, not smaller.

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2018-06-19 17:41:00 Re: Fast default stuff versus pg_upgrade
Previous Message Peter Geoghegan 2018-06-19 17:38:06 Re: [WIP] [B-Tree] Retail IndexTuple deletion