Re: Make SPI_prepare argtypes argument const - Mailing list pgsql-hackers

From Ewan Young
Subject Re: Make SPI_prepare argtypes argument const
Date
Msg-id CAON2xHM18ieNfgZ69xTqSdqFp=KSoycKijErgchzbfFDDjRipw@mail.gmail.com
Whole thread
In response to Make SPI_prepare argtypes argument const  (Peter Eisentraut <peter@eisentraut.org>)
List pgsql-hackers
Reviewed this. LGTM.

I checked that argtypes / param_types is only ever read or copied along
this path (never written or freed through the pointer), so const-qualifying
it is sound rather than merely tolerated. In particular CompleteCachedPlan()
palloc's its own copy and never retains the caller's array. pg_analyze_and_
rewrite_fixedparams() already takes const Oid *, so no further change is
needed there.

Applies cleanly on HEAD and builds without warnings here.

On Thu, Jun 11, 2026 at 5:22 PM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> This changes the argtypes argument of SPI_prepare(),
> SPI_prepare_cursor(), SPI_cursor_open_with_args(), and
> SPI_execute_with_args() from Oid *argtypes to const Oid *argtypes.
> The underlying functions were already receptive to that, so this
> doesn't require any significant changes beyond the function signatures
> and some internal variables.
>
> Commit 28972b6fc3dc recently introduced a case where a const had to be
> cast away before calling these functions.  This is fixed here.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: t/035_standby_logical_decoding.pl might fail on attempt to read wrong timeline
Next
From: solai v
Date:
Subject: Re: extend JSON_TABLE top level path expression