Re: pg_upgrade and materialized views

From: Andres Freund <andres(at)anarazel(dot)de>
To: Claudio Freire <klaussfreire(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: pg_upgrade and materialized views
Date: 2018-02-20 22:02:57
Message-ID: 20180220220257.hzdm2ar6alt3tjo2@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2018-02-20 13:54:20 -0800, Andres Freund wrote:
> note that the above if clause doesn't include materialized tables. Which
> sems to explain this bug? Could you check that just updating the above
> if to include matviews fixes the bug for you?

I suspect that a proper fix would be to move the relevant block one
level up, to have it's own if block. The current location seems to be
wrong, this is unrelated work to the header:
* To create binary-compatible heap files, we have to ensure the same
* physical column order, including dropped columns, as in the
* original. Therefore, we create dropped columns above and drop them
* here, also updating their attlen/attalign values so that the
* dropped column can be skipped properly. (We do not bother with
* restoring the original attbyval setting.) Also, inheritance
* relationships are set up by doing ALTER TABLE INHERIT rather than
* using an INHERITS clause --- the latter would possibly mess up the
* column order. That also means we have to take care about setting
* attislocal correctly, plus fix up any inherited CHECK constraints.
* Analogously, we set up typed tables using ALTER TABLE / OF here.
*/
of that block.

A later if block just concerned to restoring frozenxid for all relevant
types of tables seems more appropriate. I also wonder if we shouldn't
just always restore relfrozenxid / minmxid if set on the source system,
rather than having relkind specific dispatch.

Also, dear god, this code could use some refactoring :(

Greetings,

Andres Freund

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Claudio Freire 2018-02-20 22:05:12 Re: pg_upgrade and materialized views
Previous Message Andres Freund 2018-02-20 21:54:20 Re: pg_upgrade and materialized views