Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXd4z-0001eo-Pj for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Dec 2018 02:19:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXd4y-0003Rk-Di for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Dec 2018 02:19:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXd4y-0003Rc-6F for pgsql-bugs@lists.postgresql.org; Fri, 14 Dec 2018 02:19:52 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXd4u-0000mm-SU for pgsql-bugs@postgresql.org; Fri, 14 Dec 2018 02:19:51 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id wBE2JbhP030423; Fri, 14 Dec 2018 11:19:37 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 60899EA7A19; Fri, 14 Dec 2018 11:19:37 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 55C48EA79B4; Fri, 14 Dec 2018 11:19:37 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 4BE214003A5; Fri, 14 Dec 2018 11:19:37 +0900 (JST) Subject: Re: Errors creating partitioned tables from existing using (LIKE ) after renaming table constraints References: <2047094.V130LYfLq4@station53.ousa.org> <977c72a1-8d56-b77c-37de-808627033654@lab.ntt.co.jp> <20181214002038.GC2921@paquier.xyz> From: Amit Langote Message-ID: Date: Fri, 14 Dec 2018 11:19:16 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <20181214002038.GC2921@paquier.xyz> Content-Type: multipart/mixed; boundary="------------96153A507C29A6286B71F22E" Content-Language: en-US X-CC-Mail-RelayStamp: 1 To: Michael Paquier Cc: Stuart , pgsql-bugs@postgresql.org X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------96153A507C29A6286B71F22E Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 2018/12/14 9:20, Michael Paquier wrote: > On Thu, Dec 13, 2018 at 06:03:35PM +0900, Amit Langote wrote: >> What's happening here is that when the ALTER TABLE RENAME CONSTRAINT is >> followed by CREATE TABLE (LIKE .. INCLUDING ALL) in the same session, the >> latter is referring to *stale* information about constraints of the source >> table. You said it works correctly after you drop and re-create the >> constraint, but that's only because ALTER TABLE DROP/ADD CONSTRAINT will >> correctly invalidate the cached information, so that subsequent CREATE >> TABLE sees the correct information from the updated cache. The way to fix >> it is to teach ALTER TABLE RENAME CONSTRAINT to reset the cached >> information. > > This analysis looks right to me, and that's indeed a bug. And as far as > I can see this is reproducible down to 9.4. I cannot check your patch > in details today unfortunately, but I'll try to look at that in the next > couple of days and see if there are any surrounding issues. Thank you for looking. I noticed that the previously posted patch doesn't apply as is to branches before 11, so here are the patches that apply to 9.4 to 10 branches. Regards, Amit --------------96153A507C29A6286B71F22E Content-Type: text/plain; charset=UTF-8; name="pg10-0001-Make-rename_constraint_internal-invalidate-relcache.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="pg10-0001-Make-rename_constraint_internal-invalidate-relcach"; filename*1="e.patch"