diff options
| author | Tom Lane | 2024-09-09 16:18:32 +0000 |
|---|---|---|
| committer | Tom Lane | 2024-09-09 16:18:34 +0000 |
| commit | 218527d01456b65decdc7596c6f6d5ac2bdeb78b (patch) | |
| tree | 6aceaaac941dd92421d0a16dd65ded4426f421d0 /src/test/modules | |
| parent | cdb6b0fdb0b2face270406905d31f8f513b015cc (diff) | |
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
Diffstat (limited to 'src/test/modules')
| -rw-r--r-- | src/test/modules/plsample/plsample.c | 3 | ||||
| -rw-r--r-- | src/test/modules/test_predtest/test_predtest.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/test/modules/plsample/plsample.c b/src/test/modules/plsample/plsample.c index 40c462e84e0..89ea166a676 100644 --- a/src/test/modules/plsample/plsample.c +++ b/src/test/modules/plsample/plsample.c @@ -220,8 +220,7 @@ plsample_trigger_handler(PG_FUNCTION_ARGS) elog(ERROR, "not called by trigger manager"); /* Connect to the SPI manager */ - if (SPI_connect() != SPI_OK_CONNECT) - elog(ERROR, "could not connect to SPI manager"); + SPI_connect(); rc = SPI_register_trigger_data(trigdata); Assert(rc >= 0); diff --git a/src/test/modules/test_predtest/test_predtest.c b/src/test/modules/test_predtest/test_predtest.c index 27ac136ca5d..678b13ca30b 100644 --- a/src/test/modules/test_predtest/test_predtest.c +++ b/src/test/modules/test_predtest/test_predtest.c @@ -54,8 +54,7 @@ test_predtest(PG_FUNCTION_ARGS) int i; /* We use SPI to parse, plan, and execute the test query */ - if (SPI_connect() != SPI_OK_CONNECT) - elog(ERROR, "SPI_connect failed"); + SPI_connect(); /* * First, plan and execute the query, and inspect the results. To the |
