aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-09-09 12:18:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2024-09-09 12:18:34 -0400
commit218527d01456b65decdc7596c6f6d5ac2bdeb78b (patch)
tree6aceaaac941dd92421d0a16dd65ded4426f421d0 /doc/src
parentcdb6b0fdb0b2face270406905d31f8f513b015cc (diff)
downloadpostgresql-218527d01456b65decdc7596c6f6d5ac2bdeb78b.tar.gz
postgresql-218527d01456b65decdc7596c6f6d5ac2bdeb78b.zip
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 'doc/src')
-rw-r--r--doc/src/sgml/spi.sgml18
-rw-r--r--doc/src/sgml/trigger.sgml3
2 files changed, 10 insertions, 11 deletions
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
index 7d154914b90..7e2f2df965d 100644
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -126,16 +126,16 @@ int SPI_connect_ext(int <parameter>options</parameter>)
</para>
</listitem>
</varlistentry>
-
- <varlistentry>
- <term><symbol>SPI_ERROR_CONNECT</symbol></term>
- <listitem>
- <para>
- on error
- </para>
- </listitem>
- </varlistentry>
</variablelist>
+
+ <para>
+ The fact that these functions return <type>int</type>
+ not <type>void</type> is historical. All failure cases are reported
+ via <function>ereport</function> or <function>elog</function>.
+ (In versions before <productname>PostgreSQL</productname> v10,
+ some but not all failures would be reported with a result value
+ of <symbol>SPI_ERROR_CONNECT</symbol>.)
+ </para>
</refsect1>
</refentry>
diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index 31626536a2e..49382d07fa8 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -915,8 +915,7 @@ trigf(PG_FUNCTION_ARGS)
tupdesc = trigdata->tg_relation->rd_att;
/* connect to SPI manager */
- if ((ret = SPI_connect()) < 0)
- elog(ERROR, "trigf (fired %s): SPI_connect returned %d", when, ret);
+ SPI_connect();
/* get number of rows in table */
ret = SPI_exec("SELECT count(*) FROM ttest", 0);