Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9356877

Browse files
committed
Repair oidvectorrecv and int2vectorrecv, which I broke while changing
them to use array_recv :-(. Per report from Tim Kordas.
1 parent 487b7f5 commit 9356877

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

src/backend/utils/adt/int.c

+21-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -212,13 +212,28 @@ Datum
212212
int2vectorrecv(PG_FUNCTION_ARGS)
213213
{
214214
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
215+
FunctionCallInfoData locfcinfo;
215216
int2vector *result;
216217

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+
222237
/* sanity checks: int2vector must be 1-D, no nulls */
223238
if (ARR_NDIM(result) != 1 ||
224239
ARR_HASNULL(result) ||

src/backend/utils/adt/oid.c

+21-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.66 2005/11/22 18:17:23 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.67 2006/03/02 21:13:04 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -254,13 +254,28 @@ Datum
254254
oidvectorrecv(PG_FUNCTION_ARGS)
255255
{
256256
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
257+
FunctionCallInfoData locfcinfo;
257258
oidvector *result;
258259

259-
result = (oidvector *)
260-
DatumGetPointer(DirectFunctionCall3(array_recv,
261-
PointerGetDatum(buf),
262-
ObjectIdGetDatum(OIDOID),
263-
Int32GetDatum(-1)));
260+
/*
261+
* Normally one would call array_recv() using DirectFunctionCall3,
262+
* but that does not work since array_recv wants to cache some data
263+
* using fcinfo->flinfo->fn_extra. So we need to pass it our own
264+
* flinfo parameter.
265+
*/
266+
InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL);
267+
268+
locfcinfo.arg[0] = PointerGetDatum(buf);
269+
locfcinfo.arg[1] = ObjectIdGetDatum(OIDOID);
270+
locfcinfo.arg[2] = Int32GetDatum(-1);
271+
locfcinfo.argnull[0] = false;
272+
locfcinfo.argnull[1] = false;
273+
locfcinfo.argnull[2] = false;
274+
275+
result = (oidvector *) DatumGetPointer(array_recv(&locfcinfo));
276+
277+
Assert(!locfcinfo.isnull);
278+
264279
/* sanity checks: oidvector must be 1-D, no nulls */
265280
if (ARR_NDIM(result) != 1 ||
266281
ARR_HASNULL(result) ||

0 commit comments

Comments
 (0)