summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2006-03-02 21:13:11 +0000
committerTom Lane2006-03-02 21:13:11 +0000
commit005439889d29ea61360d2e0af4102ff9900ff572 (patch)
tree8686903f603a41159ccdf5df608422c36ca1abe2
parent039be1221e3ef25a60f0a252970102bf1b1002b8 (diff)
Repair oidvectorrecv and int2vectorrecv, which I broke while changing
them to use array_recv :-(. Per report from Tim Kordas.
-rw-r--r--src/backend/utils/adt/int.c25
-rw-r--r--src/backend/utils/adt/oid.c25
2 files changed, 40 insertions, 10 deletions
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index 004168fe93..2035d6fd0d 100644
--- a/src/backend/utils/adt/int.c
+++ b/src/backend/utils/adt/int.c
@@ -212,13 +212,28 @@ Datum
int2vectorrecv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
+ FunctionCallInfoData locfcinfo;
int2vector *result;
- result = (int2vector *)
- DatumGetPointer(DirectFunctionCall3(array_recv,
- PointerGetDatum(buf),
- ObjectIdGetDatum(INT2OID),
- Int32GetDatum(-1)));
+ /*
+ * Normally one would call array_recv() using DirectFunctionCall3,
+ * but that does not work since array_recv wants to cache some data
+ * using fcinfo->flinfo->fn_extra. So we need to pass it our own
+ * flinfo parameter.
+ */
+ InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL);
+
+ locfcinfo.arg[0] = PointerGetDatum(buf);
+ locfcinfo.arg[1] = ObjectIdGetDatum(INT2OID);
+ locfcinfo.arg[2] = Int32GetDatum(-1);
+ locfcinfo.argnull[0] = false;
+ locfcinfo.argnull[1] = false;
+ locfcinfo.argnull[2] = false;
+
+ result = (int2vector *) DatumGetPointer(array_recv(&locfcinfo));
+
+ Assert(!locfcinfo.isnull);
+
/* sanity checks: int2vector must be 1-D, no nulls */
if (ARR_NDIM(result) != 1 ||
ARR_HASNULL(result) ||
diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c
index 6efe439e28..cb066cca32 100644
--- a/src/backend/utils/adt/oid.c
+++ b/src/backend/utils/adt/oid.c
@@ -254,13 +254,28 @@ Datum
oidvectorrecv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
+ FunctionCallInfoData locfcinfo;
oidvector *result;
- result = (oidvector *)
- DatumGetPointer(DirectFunctionCall3(array_recv,
- PointerGetDatum(buf),
- ObjectIdGetDatum(OIDOID),
- Int32GetDatum(-1)));
+ /*
+ * Normally one would call array_recv() using DirectFunctionCall3,
+ * but that does not work since array_recv wants to cache some data
+ * using fcinfo->flinfo->fn_extra. So we need to pass it our own
+ * flinfo parameter.
+ */
+ InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL);
+
+ locfcinfo.arg[0] = PointerGetDatum(buf);
+ locfcinfo.arg[1] = ObjectIdGetDatum(OIDOID);
+ locfcinfo.arg[2] = Int32GetDatum(-1);
+ locfcinfo.argnull[0] = false;
+ locfcinfo.argnull[1] = false;
+ locfcinfo.argnull[2] = false;
+
+ result = (oidvector *) DatumGetPointer(array_recv(&locfcinfo));
+
+ Assert(!locfcinfo.isnull);
+
/* sanity checks: oidvector must be 1-D, no nulls */
if (ARR_NDIM(result) != 1 ||
ARR_HASNULL(result) ||