Re: SPI_connect, SPI_connect_ext return type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Stepan <sndcppg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: SPI_connect, SPI_connect_ext return type
Date: 2024-09-05 21:13:50
Message-ID: 2074782.1725570830@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(at)eisentraut(dot)org> writes:
> On 10.08.24 16:12, Tom Lane wrote:
>> We go to a lot of effort to keep the SPI API as stable as we can
>> across major versions, so I don't see why we'd just randomly make
>> an API-breaking change like this.

> Here is a previous discussion:
> https://www.postgresql.org/message-id/flat/1356682025.20017.4.camel%40vanquo.pezone.net

> I like the idea that we would keep the API but convert most errors to
> exceptions.

After thinking about this for awhile, one reason that it's practical
to change it today for SPI_connect is that SPI_connect has not
returned anything except SPI_OK_CONNECT since v10. So if we tell
extension authors they don't need to check the result, it's unlikely
that that will cause any new code they write to get used with PG
versions where it would be wrong. I fear that we'd need a similar
multi-year journey to get to a place where we could deprecate checking
the result of any other SPI function.

Nonetheless, there seems no reason not to do it now for SPI_connect.
So attached is a patch that documents the result value as vestigial
and removes the calling-code checks in our own code, but doesn't
touch SPI_connect[_ext] itself. This combines portions of Stepan's
two patches with some additional work (mostly, that he'd missed fixing
any of contrib/).

regards, tom lane

Attachment Content-Type Size
v1-0001-deprecate-checking-SPI_connect-result.patch text/x-diff 15.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-09-05 21:28:21 Re: Add trim_trailing_whitespace to editorconfig file
Previous Message Ilia Evdokimov 2024-09-05 21:11:08 Re: Adding NOTICE for differences between estimated and actual rows