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 1rVZLC-0004fQ-4u for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Feb 2024 15:51:03 +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 1rVZLB-005ag6-4P for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Feb 2024 15:51:01 +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 1rVZL9-005afs-Pw for pgsql-hackers@lists.postgresql.org; Thu, 01 Feb 2024 15:51:00 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rVZL6-004vHy-1s for pgsql-hackers@postgresql.org; Thu, 01 Feb 2024 15:50:59 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id E10D85C01C9; Thu, 1 Feb 2024 10:50:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 01 Feb 2024 10:50:51 -0500 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=fm3; t=1706802651; x= 1706889051; bh=GEzW+b2b2kBULsodHnFaJQs/Gf2oavJlb4FVMeTxMns=; b=I 9MaKE69hGv23K0R62z/KNTD0sVR+hPh2Q+vi3M+Y09KQsB8BYWIRwFMHME0BbZum EesmM+kkWcBkkUrD8nRl6WiLVLfKi/+47wtghl8ic8fnI4VdjnCLdWxLZ7SgZa8c xoebJAU0Ig5lyM8rg5w26VtaLhMR619/a8t/RKGvuw0qZ3GUzQtZTUZ1a6e8OAlD ckIgzxbgQ70Ae6tCMjCsAyOl+FZ6pkUG5FrPrWpT5eILY7AWfzZ5XfXEiO4spua8 gfmrdUhwkYisZaldep7HyQ5yuupWO/BtvHj8hmNovKsUsAAOCxjd5Df6g+lBhY9J YWIOGlA3/GM5N/0KLScVw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfeduuddgjeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 10:50:51 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1706802649; bh=hxUfO47UDZ5nYeAuOQyvs5dctD+W9tD+o2RvktrPo6w=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=T0azhwrtaXgfpAp7fkfuhr2jRH9XDb2SGbZBXMXZ1mfjq5zzCclwdOvZh00JaH83k 66diX+qrK3EIjBdukuCRL0UCHPmqU8HVN6ErY9896TSFUWVnaF60EXzD0iX+9wXUCQ 6OWnppt2VEl9NXolV0QxNb1TD8mmM0X54bhuGuA5h6Y9Gh3QqN0BXLUto2okrapMYG hda9/C6jRZXTLWW6ZZtBIflVa8Qh/gwRF5qiVXMorrm0ULesdBTh3dlET0C2GvC5ea zE7M2kkOa8MSjhEznqGh0siphQyzhLhsLE5Z+67omb+I+foc8aSzatWm+kiU+PNuy5 Y0zgaO7Zv0zIg== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 936068B; Thu, 1 Feb 2024 16:50:49 +0100 (CET) Date: Thu, 1 Feb 2024 16:50:49 +0100 From: Alvaro Herrera To: Justin Pryzby Cc: Michael Paquier , 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: <202402011550.sfszd46247zi@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 > @@ -947,20 +947,22 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, > * a type of relation that needs one, use the default. > */ > if (stmt->accessMethod != NULL) > + accessMethodId = get_table_am_oid(stmt->accessMethod, false); > + else if (RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE) > { > - accessMethod = stmt->accessMethod; > - > - if (partitioned) > - ereport(ERROR, > - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), > - errmsg("specifying a table access method is not supported on a partitioned table"))); > + if (stmt->partbound) > + { > + /* > + * For partitions, if no access method is specified, use the AM of > + * the parent table. > + */ > + Assert(list_length(inheritOids) == 1); > + accessMethodId = get_rel_relam(linitial_oid(inheritOids)); > + Assert(OidIsValid(accessMethodId)); > + } > + else > + accessMethodId = get_table_am_oid(default_table_access_method, false); > } I think this works similarly but not identically to tablespace defaults, and the difference could be confusing. You seem to have made it so that the partitioned table _always_ have a table AM, so the partitions can always inherit from it. I think it would be more sensible to _allow_ partitioned tables to have one, but not mandatory; if they don't have it, then a partition created from it would use default_table_access_method. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'. After collecting 500 such letters, he mused, a university somewhere in Arizona would probably grant him a degree. (Don Knuth)