|
16 | 16 | #include <utils/elog.h>
|
17 | 17 | #include <utils/lsyscache.h>
|
18 | 18 | #include <utils/memutils.h>
|
| 19 | +#include <utils/regproc.h> |
19 | 20 |
|
20 | 21 | #include "annotations.h"
|
21 | 22 | #include "export.h"
|
@@ -245,21 +246,30 @@ TS_TEST_FN(ts_test_with_clause_parse)
|
245 | 246 | HeapTuple tuple;
|
246 | 247 | WithClauseValue *result;
|
247 | 248 |
|
248 |
| - /* Look up any missing type ids before using it below to allow |
249 |
| - * user-defined types. Note that this will not look up types we have found |
250 |
| - * in previous calls of this function. */ |
| 249 | + /* |
| 250 | + * Look up any missing type ids before using it below to allow |
| 251 | + * user-defined types. |
| 252 | + * |
| 253 | + * Note that this will not look up types we have found in previous calls |
| 254 | + * of this function. |
| 255 | + * |
| 256 | + * We use the slightly more complicated way of calling to_regtype since |
| 257 | + * that exists on all versions of PostgreSQL. We cannot use regtypein |
| 258 | + * since that can generate errors and we do not want to deal with that. |
| 259 | + */ |
251 | 260 | for (unsigned int i = 0; i < TS_ARRAY_LEN(test_args); ++i)
|
252 | 261 | {
|
| 262 | + LOCAL_FCINFO(fcinfo_in, 1); |
253 | 263 | Datum result;
|
254 |
| - ErrorSaveContext escontext = { T_ErrorSaveContext }; |
255 |
| - if (test_args[i].type_id == InvalidOid && |
256 |
| - DirectInputFunctionCallSafe(regtypein, |
257 |
| - (char *) test_args[i].arg_names[0], |
258 |
| - InvalidOid, |
259 |
| - -1, |
260 |
| - (Node *) &escontext, |
261 |
| - &result)) |
262 |
| - test_args[i].type_id = DatumGetObjectId(result); |
| 264 | + if (test_args[i].type_id == InvalidOid) |
| 265 | + { |
| 266 | + InitFunctionCallInfoData(*fcinfo_in, NULL, 1, InvalidOid, NULL, NULL); |
| 267 | + fcinfo_in->args[0].value = CStringGetTextDatum(test_args[i].arg_names[0]); |
| 268 | + fcinfo_in->args[0].isnull = false; |
| 269 | + result = to_regtype(fcinfo_in); |
| 270 | + if (!fcinfo_in->isnull) |
| 271 | + test_args[i].type_id = DatumGetObjectId(result); |
| 272 | + } |
263 | 273 | }
|
264 | 274 |
|
265 | 275 | if (SRF_IS_FIRSTCALL())
|
|
0 commit comments