Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWLLG-00Eb5x-Ai for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jul 2024 19:38:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sWLLC-00Fcu2-CI for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Jul 2024 19:38:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWLLC-00Fctu-3V for pgsql-bugs@lists.postgresql.org; Tue, 23 Jul 2024 19:38:30 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWLLA-0016VM-2x for pgsql-bugs@lists.postgresql.org; Tue, 23 Jul 2024 19:38:29 +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 46NJcNGD1080056; Tue, 23 Jul 2024 15:38:24 -0400 From: Tom Lane To: Alvaro Herrera cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18550: Cross-partition update of a former inheritance parent leads to an assertion failure In-reply-to: <202407231721.772zsh7kjvki@alvherre.pgsql> References: <202407231721.772zsh7kjvki@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 23 Jul 2024 19:21:12 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1080054.1721763503.1@sss.pgh.pa.us> Date: Tue, 23 Jul 2024 15:38:23 -0400 Message-ID: <1080055.1721763503@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > On 2024-Jul-23, Tom Lane wrote: >> I observe that in the case given, t1 still has pg_class.relhassubclass >> true after the ATTACH PARTITION. Maybe it'd be wise to force that >> false after verifying there are no subclasses? (I tried fixing it >> manually, and that prevents the assertion crash.) > Yeah, that seems to work. We can do that essentially for free in > StorePartitionBound(), like in the attached (which was taken in 14). Looks sane. > I'd add Alexander's script as a test too, somewhere near the bottom of > create_table.sql. Personally I'd include this in the existing alter_table.sql test case, to save a few steps: -- check that the table being attached is not part of regular inheritance CREATE TABLE parent (LIKE list_parted); CREATE TABLE child () INHERITS (parent); ALTER TABLE list_parted ATTACH PARTITION child FOR VALUES IN (1); ERROR: cannot attach inheritance child as partition ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1); ERROR: cannot attach inheritance parent as partition +DROP TABLE child; +-- now it should work +ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1); +-- test insert/update, per bug #18550 +INSERT INTO parent ... +UPDATE parent ... DROP TABLE parent CASCADE; regards, tom lane