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.92) (envelope-from ) id 1jCRV9-0005Gn-Fx for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2020 17:20:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jCRV8-0002Th-5M for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2020 17:20:06 +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 1jCRV7-0002TZ-SO for pgsql-hackers@lists.postgresql.org; Thu, 12 Mar 2020 17:20:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jCRV5-00008m-Am for pgsql-hackers@postgresql.org; Thu, 12 Mar 2020 17:20:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02CHJuPs025887; Thu, 12 Mar 2020 13:19:56 -0400 From: Tom Lane To: Justin Pryzby cc: Michael Paquier , Alvaro Herrera , Amit Langote , pgsql-hackers@postgresql.org Subject: Re: ALTER tbl rewrite loses CLUSTER ON index In-reply-to: <20200303013625.GA21225@telsasoft.com> References: <20200206144426.GH403@telsasoft.com> <20200206172447.GA28041@alvherre.pgsql> <20200207143935.GP403@telsasoft.com> <17937.1582932364@sss.pgh.pa.us> <20200229024202.GH29456@telsasoft.com> <20200229165258.GJ29456@telsasoft.com> <20200302032818.GB32059@paquier.xyz> <20200303013132.GA684@telsasoft.com> <20200303013625.GA21225@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Mon, 02 Mar 2020 19:36:25 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25885.1584033596.1@sss.pgh.pa.us> Date: Thu, 12 Mar 2020 13:19:56 -0400 Message-ID: <25886.1584033596@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > @cfbot: resending with only Amit's 0001, since Michael pushed a variation on > 0002. Boy, I really dislike this patch. ATPostAlterTypeParse is documented as using the supplied definition string, and nothing else, to reconstruct the index. This breaks that without even the courtesy of documenting the breakage. Moreover, the reason why it's designed like that is to avoid requiring the old index objects to still be accessible. So I'm surprised that this hack works at all. I don't think it would have worked at the time the code was first written, and I think it's imposing a constraint we'll have problems with (again?) in future. The right way to fix this is to note the presence of the indisclustered flag when we're examining the index earlier, and include a suitable command in the definition string. So probably pg_get_indexdef_string() is what needs to change. It doesn't look like that's used anywhere else, so we can just redefine its behavior as needed. regards, tom lane