| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: relkind as an enum |
| Date: | 2026-02-02 02:41:07 |
| Message-ID: | 401759.1770000067@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
=?utf-8?Q?=C3=81lvaro?= Herrera <alvherre(at)kurilemu(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | zengman | 2026-02-02 03:02:39 | Re: [PATCH] Fix error message in RemoveWalSummaryIfOlderThan to indicate file removal failure |
| Previous Message | Xuneng Zhou | 2026-02-02 02:37:43 | Re: Re: A out of date comment of WaitForWALToBecomeAvailable |