Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSjCk-0004yJ-5Y for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Mar 2022 17:37:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSjCi-0004NQ-Vm for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Mar 2022 17:37:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSjCi-0004NH-NV for pgsql-bugs@lists.postgresql.org; Fri, 11 Mar 2022 17:37:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSjCe-0005ZN-68 for pgsql-bugs@lists.postgresql.org; Fri, 11 Mar 2022 17:37:27 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 22BHbHtD934541; Fri, 11 Mar 2022 12:37:17 -0500 From: Tom Lane To: Japin Li cc: Michael Paquier , holly.roberts@starlingbank.com, peter@eisentraut.org, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17409: Unable to alter data type of clustered column which is referenced by foreign key In-reply-to: <933033.1647019404@sss.pgh.pa.us> References: <17409-52871dda8b5741cb@postgresql.org> <755474.1646959065@sss.pgh.pa.us> <933033.1647019404@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 11 Mar 2022 12:23:24 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <934539.1647020237.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 11 Mar 2022 12:37:17 -0500 Message-ID: <934540.1647020237@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > ... The old behavior is what > ATExecAlterColumnType wants, I judge. As this stands, we will > rebuild indexes that don't need to be rebuilt, and indeed might > be on other tables altogether from the one that is being modified > (which opens all sorts of potential locking problems). Oh, well, not so much: regression=3D# create table atref (p1 int constraint pk_atref primary key)= ; CREATE TABLE regression=3D# create table attbl (c1 int, constraint fk_atref foreign key= (c1) references atref(p1)); CREATE TABLE regression=3D# cluster atref using pk_atref; CLUSTER regression=3D# alter table attbl alter column c1 set data type bigint; ERROR: "pk_atref" is not an index for table "attbl" Still, that's just as unpleasant as the originally-reported case. (I've not figured out yet why the "cluster" step is required to make this repro work.) regards, tom lane