|
7 | 7 | * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -2137,8 +2137,13 @@ query_to_xmlschema(PG_FUNCTION_ARGS)
|
2137 | 2137 | Portal portal;
|
2138 | 2138 |
|
2139 | 2139 | 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 | + |
2142 | 2147 | result = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc,
|
2143 | 2148 | InvalidOid, nulls,
|
2144 | 2149 | tableforest, targetns));
|
@@ -2209,8 +2214,13 @@ query_to_xml_and_xmlschema(PG_FUNCTION_ARGS)
|
2209 | 2214 | Portal portal;
|
2210 | 2215 |
|
2211 | 2216 | 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 | + |
2214 | 2224 | xmlschema = _SPI_strdup(map_sql_table_to_xmlschema(portal->tupDesc,
|
2215 | 2225 | InvalidOid, nulls, tableforest, targetns));
|
2216 | 2226 | SPI_cursor_close(portal);
|
|
0 commit comments