Re: New compiler warning

From: David Steele <david(at)pgmasters(dot)net>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: New compiler warning
Date: 2023-08-30 14:07:24
Message-ID: 9de558c3-5b31-fe81-fff3-dd62b37c5110@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/30/23 08:10, Aleksander Alekseev wrote:
>
>> I am seeing a new gcc 12.2.0 compiler warning from
>> src/backend/commands/sequence.c:
>
> Yep, the compiler is just not smart enough to derive that this
> actually is not going to happen.
>
> Here is a proposed fix.

Here's an alternate way to deal with this which is a bit more efficient
(code not tested):

- case SEQ_COL_CALLED:
- coldef = makeColumnDef("is_called", BOOLOID, -1, InvalidOid);
- value[i - 1] = BoolGetDatum(false);
- break;
+ default:
+ Assert(i == SEQ_COL_CALLED);
+ coldef = makeColumnDef("is_called", BOOLOID, -1, InvalidOid);
+ value[i - 1] = BoolGetDatum(false);
+ break;

The downside is that any garbage in i will lead to processing as
SEQ_COL_CALLED. But things are already pretty bad in that case, ISTM,
even with the proposed patch (or the original code for that matter).

Regards,
-David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-08-30 14:22:03 Re: tablecmds.c/MergeAttributes() cleanup
Previous Message Robert Haas 2023-08-30 13:50:41 Re: pg_stat_get_backend_subxact() and backend IDs?