pgsql: Don't bother checking the result of SPI_connect[_ext] anymore.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't bother checking the result of SPI_connect[_ext] anymore.
Date: 2024-09-09 16:18:52
Message-ID: E1snh6J-000Js9-U0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't bother checking the result of SPI_connect[_ext] anymore.

SPI_connect/SPI_connect_ext have not returned any value other than
SPI_OK_CONNECT since commit 1833f1a1c in v10; any errors are thrown
via ereport. (The most likely failure is out-of-memory, which has
always been thrown that way, so callers had better be prepared for
such errors.) This makes it somewhat pointless to check these
functions' result, and some callers within our code haven't been
bothering; indeed, the only usage example within spi.sgml doesn't
bother. So it's likely that the omission has propagated into
extensions too.

Hence, let's standardize on not checking, and document the return
value as historical, while not actually changing these functions'
behavior. (The original proposal was to change their return type
to "void", but that would needlessly break extensions that are
conforming to the old practice.) This saves a small amount of
boilerplate code in a lot of places.

Stepan Neretin

Discussion: https://postgr.es/m/CAMaYL5Z9Uk8cD9qGz9QaZ2UBJFOu7jFx5Mwbznz-1tBbPDQZow@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/218527d01456b65decdc7596c6f6d5ac2bdeb78b

Modified Files
--------------
contrib/dblink/dblink.c | 4 +---
contrib/spi/refint.c | 8 ++------
contrib/tablefunc/tablefunc.c | 18 ++++--------------
contrib/xml2/xpath.c | 3 +--
doc/src/sgml/spi.sgml | 18 +++++++++---------
doc/src/sgml/trigger.sgml | 3 +--
src/backend/commands/matview.c | 3 +--
src/backend/utils/adt/ri_triggers.c | 24 ++++++++----------------
src/backend/utils/adt/ruleutils.c | 6 ++----
src/pl/plperl/plperl.c | 12 ++++--------
src/pl/plpgsql/src/pl_handler.c | 9 +++------
src/pl/plpython/plpy_main.c | 6 ++----
src/pl/tcl/pltcl.c | 9 +++------
src/test/modules/plsample/plsample.c | 3 +--
src/test/modules/test_predtest/test_predtest.c | 3 +--
src/test/regress/regress.c | 3 +--
16 files changed, 44 insertions(+), 88 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-09-09 18:34:17 pgsql: Consistently use PageGetExactFreeSpace() in pgstattuple.
Previous Message Robert Haas 2024-09-09 15:56:44 pgsql: Add PQfullProtocolVersion() to surface the precise protocol vers