pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Michael Paquier <michael@paquier.xyz>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Some RELKIND macro refactoring
Date: Tue, 23 Nov 2021 12:09:00 -0300
Message-ID: <202111231509.rjfq4ajv3gsn@alvherre.pgsql> (raw)
In-Reply-To: <YZdS3b2lrrJL6PuD@paquier.xyz>

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/





view thread (16+ messages)  latest in thread

Message-ID: <202111231509.rjfq4ajv3gsn@alvherre.pgsql>
Permalink:  ../202111231509.rjfq4ajv3gsn@alvherre.pgsql/
Also on:    postgresql.org/message-id/202111231509.rjfq4ajv3gsn@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, michael@paquier.xyz, peter.eisentraut@enterprisedb.com
  Subject: Re: Some RELKIND macro refactoring
  In-Reply-To: <202111231509.rjfq4ajv3gsn@alvherre.pgsql>
  References: <YZdS3b2lrrJL6PuD@paquier.xyz> <202111231509.rjfq4ajv3gsn@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox