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 1nKura-0007F5-Vf for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Feb 2022 04:27:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKurZ-0008L5-8B for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Feb 2022 04:27:21 +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 1nKurX-0008Kw-IA for pgsql-bugs@lists.postgresql.org; Fri, 18 Feb 2022 04:27:20 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKurU-0000Gh-AE for pgsql-bugs@lists.postgresql.org; Fri, 18 Feb 2022 04:27:18 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id B639D3200C4A; Thu, 17 Feb 2022 23:27:12 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 17 Feb 2022 23:27:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; bh=7drmMGhdosPgp/elgsM1dJEoeX/vV8X1dutATW rDoMI=; b=YBt8cxQUtmo0IhN/jVp4928xTrO0tX9iGAFP5nFN2o09IcjprR4Xld da5fR6Qu17QQgEQWRHdEBDnDjw0eqiG6mTaBpPi42Gcm9nOVJlNUu0mci1l+0nkd 2el9JZ7F10wCHQneYRTkMbVOEsu+Fx8mUjlBKP7DSzBYPZ5Jp3oadzdb5mD3qW5T dpAdVhBRb2WFrzRAc2Q4Cv7s9Yhg0hgldAtb3WmW+gGMUqU6IjlGYB49X7/ZvJ40 POawNwZGoV6dfcrxGAsWoFGp0EPsYlP/gkxD6nmZcJMXZPnr1NBO5T9u5BwcPJOZ hyhcRSjGpeDLzA89wKP8gkk0TK0SVfsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=7drmMGhdosPgp/elg sM1dJEoeX/vV8X1dutATWrDoMI=; b=MRQeb0cwnbu6WQfLGx8vwLso1C/3s3BYV PJO11WBa8QCrtr2/hpoJ8UXW3f9bqfdeBpDrEXbSvGKziYI0oc3vQafbVs3uPEJf VoBgrPPWlfyKvmsts7NOVdWGZlw6NMs9kJcnIB3UASdt+71K+cTwxoM9G9IQ38gN T2yq+UNIL6n2T7BrZo4v8vDBYpUm/Ax/47QR1kVyDa4ewsWWkJ1W3NkPfTYp9vz0 JK6v4wBoHGaZ4ouXVdi3LKmNr62eS3ksngIBgLo3d2aU84tnuRNmr1Hizz9eH6Ds O1qyHsT7NrqevZAFfevB1L6v7LJw5tKVX+Z/OkfAUiL0nUFvQygOA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrjeelgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepvdegudeuhfdtueeltedtveejheeh ieevueeigeelteegleejleeiueeiheegvefhnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 17 Feb 2022 23:27:10 -0500 (EST) Date: Fri, 18 Feb 2022 13:27:06 +0900 From: Michael Paquier To: Japin Li Cc: 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 Message-ID: References: <17409-52871dda8b5741cb@postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="84J2EfwlgTxF9KQ8" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --84J2EfwlgTxF9KQ8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 18, 2022 at 01:30:46AM +0800, Japin Li wrote: > On Fri, 18 Feb 2022 at 01:28, Japin Li wrote: >> The RememberClusterOnForRebuilding() use the tab->clusterOnIndex to check >> the cluster index exist or not, however, the cluster index can occur more >> than once, so I think we should check the clustered index by index name. >> Here is a patch to fix it. Any suggestions? >=20 > Sorry for forgetting attach the patch. Reusing the test case at the top of the thread, this can also be triggered for replica identities, as of the code just at the top of what you have patched. See for example: CREATE TABLE parent ( parent_field INTEGER CONSTRAINT pk_parent PRIMARY KEY); ALTER TABLE parent REPLICA IDENTITY USING INDEX pk_parent; CREATE TABLE child ( child_field INTEGER, CONSTRAINT fk_child FOREIGN KEY (child_field) REFERENCES parent (parent_f= ield)); -- error here ALTER TABLE parent ALTER COLUMN parent_field SET DATA TYPE BIGINT; We surely should have test cases for all that. Anyway, I'd need to think more about your suggestion, but is that actually the best thing we can do? In this case, we'd attempt to register twice an index to rebuild within RememberIndexForRebuilding(), for the same relation, but there is no need to do so. Shouldn't we try instead to do a better job at scanning the pg_depend entries in ATExecAlterColumnType() and avoid the risk to do the same job twice? That would take care of the replica identity case that I have just mentioned, and of the clustered index case reported upthread. -- Michael --84J2EfwlgTxF9KQ8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmIPIBoACgkQnvQgOdby QH3oWhAAgzb3bEJl6sFhzHlBSjH5uwQYcAk3vBuc7GHr4GvqTfjXa7/kSGh/GFC4 Cun8RbJ/lIq00IzRN6X9ZdgU06RgH7q8BkZ6jPDUaQdnYuwP6jcoc7QW4lBhuy9l G7UPGo/ArnxVLQ8TwKmknFus8TEScaDexm9M64w105AZOlD9QibhvE3HpdT/hzY0 M21Qx1Yb1QMTwCM/gdHRU+QZnYg176IKMYGLHAe4vBbiL4yxtjQYqcyVmTey1+Wf SLK2QWXEnX2FxxvZ8Z2hzGD4Und96+wd3Js4CI3JdtBQ+Gt+XzFKyw/042NLZeya RAHEymx2NDXe55rcIEO9AwTYdZnO+e2R0mJdCluWPsFU1WAkcBfV8pFS5xVh+KdM mfxmFl6oZOCCI4YCqG1EbxzGO4N+FGQowsxKn/aSm43r5OYlPXJwkWaXlq63kxEJ 3ZzOxDXeWVukpZZvbPlwKWZ+dPmQ/HNw5tEhLhbOrYYmO3Bol44HnJQCEfWntywJ dlAQ5gGLlzbqwYGHL9+l+OSV7EUJA+qm5dIJCe4DrVj1dxxoxx5JSKO4H+9mNjaC vp/3dQjWn0m9K5BhuIOrOHfO1zLk7Cx7Z1LBkkr+shluaQ4TqoJt1AgDfgJHcdr7 q40lt8Q/e0+KLfoyC/4UaCpqVyuNaBgaYGaISQ/Gq4dGr82wpn4= =EoKv -----END PGP SIGNATURE----- --84J2EfwlgTxF9KQ8--