Lists: | pgsql-general |
---|
From: | Bborie Park <bkpark(at)ucdavis(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Passing NULL to a function called with OidFunctionCall3 |
Date: | 2011-11-11 00:06:03 |
Message-ID: | 4EBC66EB.5070905@ucdavis.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hey all,
I'm trying to make use of OidFunctionCall3 and am wondering how to
resolve an issue. I need to be able to pass to the function called with
OidFunctionCall3 a NULL and am having difficulty figuring out how.
{{{
/* build fcnarg */
for (i = 0; i < set_count; i++) {
if (_haspixel[i]) {
fcnarg[i] = Float8GetDatum(_pixel[i]);
POSTGIS_RT_DEBUGF(4, "arg %d is %f", i, _pixel[i]);
}
else {
fcnarg[i] = (Datum) NULL;
POSTGIS_RT_DEBUGF(4, "arg %d is NULL", i);
}
}
datum = OidFunctionCall3(fcnoid, fcnarg[0], fcnarg[1], fcnuserarg);
}}}
The above does not work (segfault). What is the correct way to pass a
NULL to the function being called? Should I be using a different
function other than OidFunctionCall3?
Thanks,
Bborie
--
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkpark(at)ucdavis(dot)edu
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bborie Park <bkpark(at)ucdavis(dot)edu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Passing NULL to a function called with OidFunctionCall3 |
Date: | 2011-11-11 00:43:02 |
Message-ID: | 20953.1320972182@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Bborie Park <bkpark(at)ucdavis(dot)edu> writes:
> I'm trying to make use of OidFunctionCall3 and am wondering how to
> resolve an issue. I need to be able to pass to the function called with
> OidFunctionCall3 a NULL and am having difficulty figuring out how.
You can't. Those convenience functions are not designed to support null
arguments (nor null results, for that matter). If they did, they'd be
so much more complicated to use as to not be worth the bother.
You'll need to write out something comparable to what OidFunctionCall3
does internally; look into fmgr.c. It would behoove you also to make
sure that the function is not strict before you call it with a null,
because a function that is strict is entirely entitled to dump core
on you if you do that.
regards, tom lane
From: | Bborie Park <bkpark(at)ucdavis(dot)edu> |
---|---|
To: | |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Passing NULL to a function called with OidFunctionCall3 |
Date: | 2011-11-11 00:47:21 |
Message-ID: | 4EBC7099.3000203@ucdavis.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On 11/10/2011 04:43 PM, Tom Lane wrote:
> Bborie Park<bkpark(at)ucdavis(dot)edu> writes:
>> I'm trying to make use of OidFunctionCall3 and am wondering how to
>> resolve an issue. I need to be able to pass to the function called with
>> OidFunctionCall3 a NULL and am having difficulty figuring out how.
>
> You can't. Those convenience functions are not designed to support null
> arguments (nor null results, for that matter). If they did, they'd be
> so much more complicated to use as to not be worth the bother.
>
> You'll need to write out something comparable to what OidFunctionCall3
> does internally; look into fmgr.c. It would behoove you also to make
> sure that the function is not strict before you call it with a null,
> because a function that is strict is entirely entitled to dump core
> on you if you do that.
>
> regards, tom lane
>
Thanks Tom!
--
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkpark(at)ucdavis(dot)edu