|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.69 2005/11/17 22:14:53 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.70 2006/03/02 21:13:04 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -212,13 +212,28 @@ Datum
|
212 | 212 | int2vectorrecv(PG_FUNCTION_ARGS)
|
213 | 213 | {
|
214 | 214 | StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
|
| 215 | + FunctionCallInfoData locfcinfo; |
215 | 216 | int2vector *result;
|
216 | 217 |
|
217 |
| - result = (int2vector *) |
218 |
| - DatumGetPointer(DirectFunctionCall3(array_recv, |
219 |
| - PointerGetDatum(buf), |
220 |
| - ObjectIdGetDatum(INT2OID), |
221 |
| - Int32GetDatum(-1))); |
| 218 | + /* |
| 219 | + * Normally one would call array_recv() using DirectFunctionCall3, |
| 220 | + * but that does not work since array_recv wants to cache some data |
| 221 | + * using fcinfo->flinfo->fn_extra. So we need to pass it our own |
| 222 | + * flinfo parameter. |
| 223 | + */ |
| 224 | + InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL); |
| 225 | + |
| 226 | + locfcinfo.arg[0] = PointerGetDatum(buf); |
| 227 | + locfcinfo.arg[1] = ObjectIdGetDatum(INT2OID); |
| 228 | + locfcinfo.arg[2] = Int32GetDatum(-1); |
| 229 | + locfcinfo.argnull[0] = false; |
| 230 | + locfcinfo.argnull[1] = false; |
| 231 | + locfcinfo.argnull[2] = false; |
| 232 | + |
| 233 | + result = (int2vector *) DatumGetPointer(array_recv(&locfcinfo)); |
| 234 | + |
| 235 | + Assert(!locfcinfo.isnull); |
| 236 | + |
222 | 237 | /* sanity checks: int2vector must be 1-D, no nulls */
|
223 | 238 | if (ARR_NDIM(result) != 1 ||
|
224 | 239 | ARR_HASNULL(result) ||
|
|
0 commit comments