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 1mpXPx-0006qf-Ip for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Nov 2021 15:09:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpXPw-0007eG-Ff for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Nov 2021 15:09:08 +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 1mpXPw-0007e7-65 for pgsql-hackers@lists.postgresql.org; Tue, 23 Nov 2021 15:09:08 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpXPt-0004KQ-N5 for pgsql-hackers@postgresql.org; Tue, 23 Nov 2021 15:09:07 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 5C91F3201C6B; Tue, 23 Nov 2021 10:09:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 23 Nov 2021 10:09:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=kBiYFACb3bKnUoCvz8HgKP3oN06DQ96kg4a5We0WqyM=; b=B1uJileW q8Z1S1kzSOgsmFbUdSIfFeK9hx0e5ktpJpVEPhMC0y8nKnhF3ngwAOonpuG25Ntk U6Y7KmNBlBsKmCfTjiKl5ClsER5zywleBz5/yWL2UboqaZAGB1LUwmH01WsJ8n5k 2Huwqic8q6Ta+VBd7E5yf55Az+4Da+TbItPLrvk8GjSigBHutiIu1MgdlQ+G0GIY VXoQw3wT/uV/CTB810/68ESZw/Eg0Bn8PtdqxyqXZvKFb8SBQlGRjmG1JdilfR/y dNAJl/Diwu+tEVtn5XkoOFiENa3FOT4I3+7ux/EM2HKnHoNBJqCUNIhRnEDBxHha z1WUzU23aSVNLg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrgeeigdejgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepudejveejffejveduudetvdekieeuiedtvdeileefkeevjedu feeguedvjefhueelnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Nov 2021 10:09:03 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id BB79B2A06ED; Tue, 23 Nov 2021 12:09:00 -0300 (-03) Date: Tue, 23 Nov 2021 12:09:00 -0300 From: Alvaro Herrera To: Michael Paquier Cc: Peter Eisentraut , pgsql-hackers Subject: Re: Some RELKIND macro refactoring Message-ID: <202111231509.rjfq4ajv3gsn@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 On 2021-Nov-19, Michael Paquier wrote: > I think that you should keep this block as it is now. The part where > a relkind does not support table AMs and does not require storage > would get uncovered, and this new code would just attempt to create > storage, so it seems to me that the existing code is better when it > comes to prevent mistakes from developers? You could as well use an > else if (RELKIND_INDEX || RELKIND_SEQUENCE) for > RelationCreateStorage(), and fall back to Assert(false) in the else > branch, to get the same result as the original without impacting the > level of safety of the original code. Hmm, I think the added condition and else would make it safe and clear: + if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind)) + table_relation_set_new_filenode(rel, &rel->rd_node, + relpersistence, + relfrozenxid, relminmxid); + else if (RELKIND_HAS_STORAGE(rel->rd_rel->relkind)) + RelationCreateStorage(rel->rd_node, relpersistence); + else + Assert(false); This is the same coding the patch proposed to put in RelationSetNewRelfilenode, which IMO validates the idea. In init_fork(), there's a typo: + * For tables, the AM callback creates both the main and the init fork. should read: + * For tables, the AM callback creates both the main and the init forks. In heap_create_with_catalog, you have + if (!relid) should be + if (!OidIsValid(relid)) Overall, LGTM. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/