Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoG0E-0001KH-Uu for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Feb 2018 22:03:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eoG0D-0004T4-Em for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Feb 2018 22:03:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eoG0D-0004Su-1V for pgsql-bugs@lists.postgresql.org; Tue, 20 Feb 2018 22:03:09 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eoG05-00087b-Ah for pgsql-bugs@postgresql.org; Tue, 20 Feb 2018 22:03:07 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2004E20CCB; Tue, 20 Feb 2018 17:02:58 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Tue, 20 Feb 2018 17:02:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=2Q0e6Y10Oh6FNRxDy6goA8HgvZ6dS MadtU1WrultPWY=; b=kNcx3ZDib7fSpn9GSKKbfku2VslTlIP4F27FQRBE7gyta ho9hlXRfen/FB+A6LMG+HfhvMPmvNddgmaTWN6cIjLPgALj3omLwbNiCb5NjpmAe nwXl38b6jAGmL67TbdQ4CoNJRruB80+kuIvNMGY9gIZlNfnG2xVvoXo1y1A9bjTq eoZ6Wgir8/AHS7P6jlD7rhe6vLjQ1D1JpwrkGtHfCJBq7KBXFeRl1Cv37z1E3Fvi /BDjU3jM0jCG7SC0h0PXiYp1E1Bz9k3sfFSUrM1epIxBo/EgCXNeq/sHpJkjsMWJ Q3lDQAaXRW1TClFzbtAzcA7IQKAminQjHC9W+ZXzA== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 717177E12E; Tue, 20 Feb 2018 17:02:58 -0500 (EST) Date: Tue, 20 Feb 2018 14:02:57 -0800 From: Andres Freund To: Claudio Freire Cc: pgsql-bugs@postgresql.org Subject: Re: pg_upgrade and materialized views Message-ID: <20180220220257.hzdm2ar6alt3tjo2@alap3.anarazel.de> References: <20180220215420.cdmx6bfqtzasjjcs@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180220215420.cdmx6bfqtzasjjcs@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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