Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5217663

Browse files
author
Neil Conway
committed
Fix two places in xml.c that neglected to check the return values of
SPI_prepare() and SPI_cursor_open(), to silence a Coverity warning.
1 parent 25b7583 commit 5217663

File tree

1 file changed

+15
-5
lines changed
  • src/backend/utils/adt

1 file changed

+15
-5
lines changed

src/backend/utils/adt/xml.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.65 2008/01/12 10:38:32 neilc Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.66 2008/01/12 10:50:03 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2137,8 +2137,13 @@ query_to_xmlschema(PG_FUNCTION_ARGS)
21372137
Portal portal;
21382138

21392139
SPI_connect();
2140-
plan = SPI_prepare(query, 0, NULL);
2141-
portal = SPI_cursor_open(NULL, plan, NULL, NULL, true);
2140+
2141+
if ((plan = SPI_prepare(query, 0, NULL)) == NULL)
2142+
elog(ERROR, "SPI_prepare(\"%s\") failed", query);
2143+
2144+
if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL)
2145+
elog(ERROR, "SPI_cursor_open(\"%s\") failed", query);
2146+
21422147
result = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc,
21432148
InvalidOid, nulls,
21442149
tableforest, targetns));
@@ -2209,8 +2214,13 @@ query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
22092214
Portal portal;
22102215

22112216
SPI_connect();
2212-
plan = SPI_prepare(query, 0, NULL);
2213-
portal = SPI_cursor_open(NULL, plan, NULL, NULL, true);
2217+
2218+
if ((plan = SPI_prepare(query, 0, NULL)) == NULL)
2219+
elog(ERROR, "SPI_prepare(\"%s\") failed", query);
2220+
2221+
if ((portal = SPI_cursor_open(NULL, plan, NULL, NULL, true)) == NULL)
2222+
elog(ERROR, "SPI_cursor_open(\"%s\") failed", query);
2223+
22142224
xmlschema = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc,
22152225
InvalidOid, nulls, tableforest, targetns));
22162226
SPI_cursor_close(portal);

0 commit comments

Comments
 (0)