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 1n3luB-0000hS-8d for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Jan 2022 21:27:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n3luA-00067O-0Z for pgsql-bugs@arkaria.postgresql.org; Sat, 01 Jan 2022 21:27:10 +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 1n3lu9-00067F-MG for pgsql-bugs@lists.postgresql.org; Sat, 01 Jan 2022 21:27:09 +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 1n3lu7-0002Hl-Eh for pgsql-bugs@lists.postgresql.org; Sat, 01 Jan 2022 21:27:08 +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 201LR5JU3057472; Sat, 1 Jan 2022 16:27:05 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17351: Altering a composite type created for a partitioned table can lead to a crash In-reply-to: <17351-6db1870f3f4f612a@postgresql.org> References: <17351-6db1870f3f4f612a@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sat, 01 Jan 2022 18:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3057470.1641072425.1@sss.pgh.pa.us> Date: Sat, 01 Jan 2022 16:27:05 -0500 Message-ID: <3057471.1641072425@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When executing the following queries: > create table pt (a int, b int) partition by list (b); > create table t(a pt, check (a = '(1, 2)'::pt)); > alter table pt alter column a type char(4); > \d+ t > The server crashes with the following stack: Hmm. We really ought to reject the ALTER TABLE. We do if "pt" is a plain table: regression=# create table pt (a int, b int); CREATE TABLE regression=# create table t(a pt); CREATE TABLE regression=# alter table pt alter column a type char(4); ERROR: cannot alter table "pt" because column "t.a" uses its row type So something is mistakenly skipping that check for partitioned tables. I think we're also failing to worry about the rowtype of the constant in t's check constraint; it seems like that has to be complained of as well, even if the underyling columns aren't of type "pt". regards, tom lane