From 576b25bfd0e9a1d5bbc54931e888135bc6da8a2f Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Wed, 22 Feb 2023 13:24:51 +0000 Subject: [PATCH] Add missing support for the latest SPI status codes. SPI_result_code_string() was missing support for SPI_OK_TD_REGISTER, and in v15 and later, it was missing support for SPI_OK_MERGE, as was pltcl_process_SPI_result(). The last of those would trigger an error if a MERGE was executed from PL/Tcl. The others seem fairly innocuous, but worth fixing. Back-patch to all supported branches. Before v15, this is just adding SPI_OK_TD_REGISTER to SPI_result_code_string(), which is unlikely to be seen by anyone, but seems worth doing for completeness. Reviewed by Tom Lane. Discussion: https://postgr.es/m/CAEZATCUg8V%2BK%2BGcafOPqymxk84Y_prXgfe64PDoopjLFH6Z0Aw%40mail.gmail.com https://postgr.es/m/CAEZATCUMe%2B_KedPMM9AxKqm%3DSZogSxjUcrMe%2BsakusZh3BFcQw%40mail.gmail.com --- doc/src/sgml/spi.sgml | 9 +++++++++ src/backend/executor/spi.c | 4 ++++ src/pl/tcl/pltcl.c | 1 + 3 files changed, 14 insertions(+) diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml index 7581661fc4a..651930aa3d6 100644 --- a/doc/src/sgml/spi.sgml +++ b/doc/src/sgml/spi.sgml @@ -437,6 +437,15 @@ typedef struct SPITupleTable + + SPI_OK_MERGE + + + if a MERGE was executed + + + + SPI_OK_INSERT_RETURNING diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 29bc26669b0..1edbd4353f6 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -2029,6 +2029,10 @@ SPI_result_code_string(int code) return "SPI_OK_REL_REGISTER"; case SPI_OK_REL_UNREGISTER: return "SPI_OK_REL_UNREGISTER"; + case SPI_OK_TD_REGISTER: + return "SPI_OK_TD_REGISTER"; + case SPI_OK_MERGE: + return "SPI_OK_MERGE"; } /* Unrecognized code ... return something useful ... */ sprintf(buf, "Unrecognized SPI code %d", code); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 0dd6d8ab2c2..11f1ff19139 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2442,6 +2442,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp, case SPI_OK_INSERT: case SPI_OK_DELETE: case SPI_OK_UPDATE: + case SPI_OK_MERGE: Tcl_SetObjResult(interp, Tcl_NewWideIntObj(ntuples)); break;