Another one noticed from the MERGE RETURNING patch -- the switch
statement in SPI_result_code_string() is missing cases for
SPI_OK_TD_REGISTER and SPI_OK_MERGE.

The SPI_OK_TD_REGISTER case goes back all the way, so I suppose it
should be back-patched to all supported branches, though evidently
this is not something anyone is likely to care about.

The SPI_OK_MERGE case is perhaps a little more visible (e.g., execute
MERGE from PL/Perl using $rv = spi_exec_query() and then examine
$rv->{status}). It's also missing from the docs for SPI_Execute().
Having tested that it now works as expected, I don't think there's
much point in adding a regression test case for it though.

Regards,
Dean
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
new file mode 100644
index 7581661..651930a
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -438,6 +438,15 @@ typedef struct SPITupleTable
     </varlistentry>
 
     <varlistentry>
+     <term><symbol>SPI_OK_MERGE</symbol></term>
+     <listitem>
+      <para>
+       if a <command>MERGE</command> was executed
+      </para>
+     </listitem>
+    </varlistentry>
+
+    <varlistentry>
      <term><symbol>SPI_OK_INSERT_RETURNING</symbol></term>
      <listitem>
       <para>
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
new file mode 100644
index 61f03e3..e3a170c
--- 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);

Reply via email to