Re: More const-marking cleanup

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-05T20:52:40Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix some cases of indirectly casting away const.

  2. Fix another case of indirectly casting away const.

  3. ecpg: refactor to eliminate cast-away-const in find_variable().

Attachments

I wrote:
> Ah.  Your script didn't notice the need for const'ification of
> additional variables in map_locale() :-(.  I fixed that and
> pushed everything except the ecpg/preproc/variable.c changes,
> which I'm not too comfortable about yet.  (The code coverage
> report shows that large chunks of those functions are untested,
> so I wonder if they worked before let alone after.)

I was right to be suspicious about variable.c: I'd misunderstood
what was happening in find_struct_member(), with the consequence
that I broke some cases that were not being tested.  Here's v2,
with that repaired, more commentary, and more test cases.

Adding these comments feels a bit like putting lipstick on a pig.
find_variable and its subroutines are an inelegant, duplicative
mess that fails to handle cases it easily could handle if it were
rewritten.  But I've put enough brain cells into this already,
and also it appears that there are restrictions elsewhere in ecpg
that'd have to be lifted before it'd make a difference.

			regards, tom lane