document and use SPI_result_code_string()

Started by Peter Eisentrautabout 9 years ago5 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t37326
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 10:25 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t37326_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t37326_1 && git checkout t37326_1

Patchset v1 (message #1) is on t37326_1

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

A lot of semi-internal code just prints out numeric SPI error codes,
which is not very helpful. We already have an API function
SPI_result_code_string() to convert the codes to a string, so here is a
patch to make more use of that and also document it for external use.

Also included are two patches to clarify that some RI error handling
code that I encountered at the same time.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

t37326_1
0001-Move-SPI-error-reporting-out-of-ri_ReportViolation.patchtext/plain; charset=UTF-8; name=0001-Move-SPI-error-reporting-out-of-ri_ReportViolation.patch; x-mac-creator=0; x-mac-type=0Download+11-19
0002-Add-attribute-noreturn.patchtext/plain; charset=UTF-8; name=0002-Add-attribute-noreturn.patch; x-mac-creator=0; x-mac-type=0Download+1-2
0003-Document-and-use-SPI_result_code_string.patchtext/plain; charset=UTF-8; name=0003-Document-and-use-SPI_result_code_string.patch; x-mac-creator=0; x-mac-type=0Download+63-11
#2Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#1)
Re: document and use SPI_result_code_string()

On Thu, Aug 31, 2017 at 11:23 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

A lot of semi-internal code just prints out numeric SPI error codes,
which is not very helpful. We already have an API function
SPI_result_code_string() to convert the codes to a string, so here is a
patch to make more use of that and also document it for external use.

Also included are two patches to clarify that some RI error handling
code that I encountered at the same time.

Those are simple things. Agreed for 0001 to untangle things.

Fine for 0002. This reminds me of LockGXact and RemoveGXact in
twophase.c, as well as _hash_squeezebucket that have some code paths
that cannot return... Any thoughts about having some kind of
PG_NOTREACHED defined to 0 which could be put in an assertion?

+1 for 0003. There are other undocumented functions available to users:
- SPI_plan_is_valid
- SPI_execute_snapshot
- SPI_plan_get_plan_sources
- SPI_plan_get_cached_plan
- SPI_datumTransfer
-- 
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Paquier (#2)
Re: document and use SPI_result_code_string()

Michael Paquier <michael.paquier@gmail.com> writes:

Fine for 0002. This reminds me of LockGXact and RemoveGXact in
twophase.c, as well as _hash_squeezebucket that have some code paths
that cannot return... Any thoughts about having some kind of
PG_NOTREACHED defined to 0 which could be put in an assertion?

Generally we just do "Assert(false)", maybe with "not reached" in a
comment. I don't feel a strong need to invent a new way to do that.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Daniel Gustafsson
daniel@yesql.se
In reply to: Tom Lane (#3)
Re: document and use SPI_result_code_string()

On 06 Sep 2017, at 14:25, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Michael Paquier <michael.paquier@gmail.com> writes:

Fine for 0002. This reminds me of LockGXact and RemoveGXact in
twophase.c, as well as _hash_squeezebucket that have some code paths
that cannot return... Any thoughts about having some kind of
PG_NOTREACHED defined to 0 which could be put in an assertion?

Generally we just do "Assert(false)", maybe with "not reached" in a
comment. I don't feel a strong need to invent a new way to do that.

Moving this to the next commitfest and bumping status to Ready for committer
based on the discussion in this thread.

cheers ./daniel

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Daniel Gustafsson (#4)
Re: document and use SPI_result_code_string()

On 10/2/17 03:28, Daniel Gustafsson wrote:

On 06 Sep 2017, at 14:25, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Michael Paquier <michael.paquier@gmail.com> writes:

Fine for 0002. This reminds me of LockGXact and RemoveGXact in
twophase.c, as well as _hash_squeezebucket that have some code paths
that cannot return... Any thoughts about having some kind of
PG_NOTREACHED defined to 0 which could be put in an assertion?

Generally we just do "Assert(false)", maybe with "not reached" in a
comment. I don't feel a strong need to invent a new way to do that.

Moving this to the next commitfest and bumping status to Ready for committer
based on the discussion in this thread.

committed

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers