Re: BUG #11761: range_in dosn't work via direct functional call - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #11761: range_in dosn't work via direct functional call
Date
Msg-id 544A4F4E.9080407@vmware.com
Whole thread Raw
In response to BUG #11761: range_in dosn't work via direct functional call  (olegjobs@mail.ru)
Responses Re: BUG #11761: range_in dosn't work via direct functional call
List pgsql-bugs
On 10/22/2014 08:27 PM, olegjobs@mail.ru wrote:
> This function test_ext_get_range(cstring) returns int4range:
>
> Datum test_ext_get_range(PG_FUNCTION_ARGS)
> {
>     char *ts = PG_GETARG_CSTRING(0);
>
>     return DirectFunctionCall3(range_in, CStringGetDatum(ts),
> ObjectIdGetDatum(3904), Int32GetDatum(0);
> }
> In psql:
> select test_ext_get_range('[1,1]');
> error:
> connection to the server was lost.
>
> it seems to me that some memory problems because of "The range I/O functions
> need a bit more cached info than other range
>   * functions, so they store a RangeIOData struct in fn_extra, not just a
>   * pointer to a type cache entry. "

Yeah, DirectFunctionCall cannot be used with range_in. Use FunctionCall3
instead. See this comment in fmgr.c, above DirectFunctionCall1Coll:

> /*
>  * These are for invocation of a specifically named function with a
>  * directly-computed parameter list.  Note that neither arguments nor result
>  * are allowed to be NULL.  Also, the function cannot be one that needs to
>  * look at FmgrInfo, since there won't be any.
>  */

range_in needs to look at FmgrInfo.

- Heikki

pgsql-bugs by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: BUG #11749: range_in, range_out dosn't work
Next
From: Pavel Stehule
Date:
Subject: Re: BUG #11761: range_in dosn't work via direct functional call