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 1rp4cu-004vDq-Ip for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:05:57 +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 1rp4ct-00DgzC-3y for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:05:55 +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 1rp4cs-00Dgz1-Ow for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 11:05:55 +0000 Received: from fout1-smtp.messagingengine.com ([103.168.172.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rp4cq-006ZWB-3y for pgsql-hackers@postgresql.org; Tue, 26 Mar 2024 11:05:54 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.nyi.internal (Postfix) with ESMTP id 564E413800AA; Tue, 26 Mar 2024 07:05:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 26 Mar 2024 07:05:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1711451150; x= 1711537550; bh=750dpMAgqR2/R8qEq5bjkUwsauk8aH/v1VXXhZwsvZc=; b=R qB7yVFl+aKFLvcxBmeZpoZ10svOn5bAwzQajeyi90oJnVgoWBrDNbchWakWpM/Zg dhZmaEZK0Jdbocb8X6Ub4qqwdwxc23OYiNcirpal+cWUzhuJYYH2Yne/zIdYObyK rvCzGKfMnkAdwWx4RCFKf/Yh9JdV9il+mlL4Vz8wutYoN4PLXbcdUEmiOg69NIUL WUSrsY6jDxeYSUDcUCEUwoLn3UkxSmUFUJe8DNkz4TY5X/TnnN1CO0xSNvNvyxEz y48Zkx0nvvO5Bp35isZ72uzurdZJ2gu3sQ7cCb4zPIcsUKwa1UWyh2IqixMfc3QZ /9babF6pm0yQo+tD2vZ1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddufedgvdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudelkeekgfdttdettdekgfduvdeiffelteegjeeihfet heekveeftedtuddvhfeunecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Mar 2024 07:05:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1711451147; bh=qRqoO4OpBJ0jiAClKUKFuYU1VOLpDOrt/9VSM5kFNWE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=czajbkp88Hdzdlkqno+9vFCxUZUOc0LH9KLWoDT87PkcWeReohNma28BOMIvcuaAQ 7vgFDLdJGtsPWAx6x/2/XgAkT5tVxZ/Nh4ixh8f0ujWoys9NIxKA9O3IMGaVyMH7AO cb0hnVGHnH1tQx+Ki9VzMMk01QROevZYIxwwEtZkiRA+mn2DyLBypR7e5365nGw+2b BjPWb/T2kpiz/PFdtJN+nt7MpcwK1ViNVu9eC/67grMjp8UcKfCPLtxdZZMWspUVA9 v0r7Dc2LRFK4r+MXw4+F/FAwHfwK6YDRP/G5+dt1gyVxthEkV5xMvpE5POUlL85BhN /mChlnI03fXxg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 3BF6D153; Tue, 26 Mar 2024 12:05:47 +0100 (CET) Date: Tue, 26 Mar 2024 12:05:47 +0100 From: Alvaro Herrera To: Alexander Lakhin Cc: Michael Paquier , Justin Pryzby , Peter Eisentraut , Soumyadeep Chakraborty , Zhihong Yu , pgsql-hackers@postgresql.org, Ashwin Agrawal , vanjared@vmware.com Subject: Re: ALTER TABLE SET ACCESS METHOD on partitioned tables Message-ID: <202403261105.6o4ff4d6qagc@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="mufqa2v6kaqqvw6h" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --mufqa2v6kaqqvw6h Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2024-Mar-26, Alexander Lakhin wrote: > Hello Alvaro, > > 21.03.2024 15:07, Alvaro Herrera wrote: > > Given that Michaël is temporarily gone, I propose to push the attached > > tomorrow. > > Please look at a new anomaly introduced with 374c7a229. > Starting from that commit, the following erroneous query: > CREATE FOREIGN TABLE fp PARTITION OF pg_am DEFAULT SERVER x; > > triggers an assertion failure: > TRAP: failed Assert("relation->rd_rel->relam == InvalidOid"), File: "relcache.c", Line: 1219, PID: 3706301 Hmm, yeah, we're setting relam for relations that shouldn't have it. I propose the attached. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ --mufqa2v6kaqqvw6h Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-relam-fixes.patch" From 8b68591cea43fdc50fe53f11b077fcd42d501946 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 26 Mar 2024 11:58:53 +0100 Subject: [PATCH] relam fixes --- src/backend/commands/tablecmds.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 635d54645d..315d355238 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -714,7 +714,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, Oid ofTypeId; ObjectAddress address; LOCKMODE parentLockmode; - Oid accessMethodId = InvalidOid; + Oid accessMethodId; /* * Truncate relname to appropriate length (probably a waste of time, as @@ -958,15 +958,21 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, } /* - * Select access method to use: an explicitly indicated one, or (in the - * case of a partitioned table) the parent's, if it has one. + * For relations with table AM and partitioned tables, select access method + * to use: an explicitly indicated one, or (in the case of a partitioned + * table) the parent's, if it has one. */ - if (stmt->accessMethod != NULL) - accessMethodId = get_table_am_oid(stmt->accessMethod, false); - else if (stmt->partbound) + if (RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE) { - Assert(list_length(inheritOids) == 1); - accessMethodId = get_rel_relam(linitial_oid(inheritOids)); + if (stmt->accessMethod != NULL) + accessMethodId = get_table_am_oid(stmt->accessMethod, false); + else if (stmt->partbound) + { + Assert(list_length(inheritOids) == 1); + accessMethodId = get_rel_relam(linitial_oid(inheritOids)); + } + else + accessMethodId = InvalidOid; } else accessMethodId = InvalidOid; -- 2.39.2 --mufqa2v6kaqqvw6h--