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.96) (envelope-from ) id 1vmjsH-00Fl0e-1w for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 02:41:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmjsF-00BF8e-0r for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 02:41:12 +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.96) (envelope-from ) id 1vmjsE-00BF8V-39 for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 02:41:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vmjsD-00000000bAf-2NtZ for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 02:41:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 6122f7IL401760; Sun, 1 Feb 2026 21:41:07 -0500 From: Tom Lane To: =?utf-8?Q?=C3=81lvaro?= Herrera cc: Pg Hackers Subject: Re: relkind as an enum In-reply-to: <202602020019.6bseljwhr2k2@alvherre.pgsql> References: <202602020019.6bseljwhr2k2@alvherre.pgsql> Comments: In-reply-to =?utf-8?Q?=C3=81lvaro?= Herrera message dated "Mon, 02 Feb 2026 01:42:48 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <401758.1770000067.1@sss.pgh.pa.us> Date: Sun, 01 Feb 2026 21:41:07 -0500 Message-ID: <401759.1770000067@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?utf-8?Q?=C3=81lvaro?= Herrera 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