pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't bother checking the result of SPI_connect[_ext] anymore.
Date: Mon, 09 Sep 2024 16:18:52 +0000
Message-ID: <E1snh6J-000Js9-U0@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1snh6J-000Js9-U0@gemulon.postgresql.org>
Permalink:  ../E1snh6J-000Js9-U0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1snh6J-000Js9-U0@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Don't bother checking the result of SPI_connect[_ext] anymore.
  In-Reply-To: <E1snh6J-000Js9-U0@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox