Check after errors of SPI_execute() in xml.c
authorMichael Paquier <[email protected]>
Thu, 7 Nov 2019 02:13:31 +0000 (11:13 +0900)
committerMichael Paquier <[email protected]>
Thu, 7 Nov 2019 02:13:31 +0000 (11:13 +0900)
SPI gets used to build a list of relation OIDs for XML object
generation, and one code path building a list uses SPI_execute() without
looking at errors it produces.  So fix that.

Author: Mark Dilger
Reviewed-by: Michael Paquier, Pavel Stehule
Discussion: https://postgr.es/m/17d30445-4862-7917-170f-84328dcd292d@gmail.com

src/backend/utils/adt/xml.c

index 3a493dd6bf70cec435c084b490140007607a5c1e..3bc17164312c548b4723f210ddc979c2a507d7db 100644 (file)
@@ -2461,8 +2461,12 @@ query_to_oid_list(const char *query)
 {
        uint64          i;
        List       *list = NIL;
+       int                     spi_result;
 
-       SPI_execute(query, true, 0);
+       spi_result = SPI_execute(query, true, 0);
+       if (spi_result != SPI_OK_SELECT)
+               elog(ERROR, "SPI_execute returned %s for %s",
+                        SPI_result_code_string(spi_result), query);
 
        for (i = 0; i < SPI_processed; i++)
        {