From: Tom Lane <tgl@sss.pgh.pa.us>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: relkind as an enum
Date: Sun, 01 Feb 2026 21:41:07 -0500
Message-ID: <401759.1770000067@sss.pgh.pa.us> (raw)
In-Reply-To: <202602020019.6bseljwhr2k2@alvherre.pgsql>
References: <202602020019.6bseljwhr2k2@alvherre.pgsql>
=?utf-8?Q?=C3=81lvaro?= Herrera <alvherre@kurilemu.de> writes:
> There have been mentions of turning Form_pg_class->relkind into an enum,
> so that we can have compilers provide some more help with
> switch(relkind) blocks. Here's a quick experiment with that.
> ...
> 0003 is the backend-side change. This looks generally reasonable,
> though I'm annoyed that I couldn't find a way to coerce the compiler
> into telling me if I had missed some spot.
Yeah. On the whole I'm dubious that this is worth the code churn,
because I doubt that it will move the needle at all on getting
better compiler warnings. One reason why I think that is that
I don't think it's okay to assume that what comes off of disk
for the contents of pg_class.relkind is necessarily one of the
valid values: catalog corruption would break that assumption.
So even in places where it's reasonable to list every RELKIND_
value in a switch (and in many of them it looks like that would
be tedium), we'd still need to cater for a default: clause.
And then we'd get no warnings, so what have we gained?
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@kurilemu.de, pgsql-hackers@lists.postgresql.org
Subject: Re: relkind as an enum
In-Reply-To: <401759.1770000067@sss.pgh.pa.us>
* 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