From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, melanieplageman(at)gmail(dot)com, vignesh21(at)gmail(dot)com, pryzby(at)telsasoft(dot)com, lukas(at)fittl(dot)com, alvherre(at)alvh(dot)no-ip(dot)org, magnus(at)hagander(dot)net, pgsql-hackers(at)postgresql(dot)org, thomas(dot)munro(at)gmail(dot)com, m(dot)sakrejda(at)gmail(dot)com |
Subject: | Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) |
Date: | 2023-02-26 18:52:47 |
Message-ID: | 23770.1677437567@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> The issue seems to be that code like this:
> ...
> is far too cute for its own good.
Oh, there's another thing here that qualifies as too-cute: loops like
for (IOObject io_object = IOOBJECT_FIRST;
io_object < IOOBJECT_NUM_TYPES; io_object++)
make it look like we could define these enums as 1-based rather
than 0-based, but if we did this code would fail, because it's
confusing "the number of values" with "1 more than the last value".
Again, we could fix that with tests like "io_context <= IOCONTEXT_LAST",
but I don't see the point of adding more macros rather than removing
some. We do need IOOBJECT_NUM_TYPES to declare array sizes with,
so I think we should nuke the "xxx_FIRST" macros as being not worth
the electrons they're written on, and write these loops like
for (int io_object = 0; io_object < IOOBJECT_NUM_TYPES; io_object++)
which is not actually adding any assumptions that you don't already
make by using io_object as a C array subscript.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan S. Katz | 2023-02-26 19:11:53 | Re: logical decoding and replication of sequences, take 2 |
Previous Message | Tom Lane | 2023-02-26 18:20:00 | Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?) |