pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedflinfo NULL in DirectFunctionCall callee?
4+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2019-08-26 348778ddbc Make comment in fmgr.h match the one in fmgr.c.
* flinfo NULL in DirectFunctionCall callee?
@ 2019-08-26 14:51 Paul A Jungwirth <pj@illuminatedcomputing.com>
0 siblings, 1 reply; 4+ messages in thread
From: Paul A Jungwirth @ 2019-08-26 14:51 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hello,
I'm writing a multirange_cmp function which calls range_cmp to compare
individual elements. It looks like this:
cmp = DatumGetInt32(DirectFunctionCall2(
range_cmp,
RangeTypePGetDatum(r1),
RangeTypePGetDatum(r2)));
But I get a segfault when range_cmp tries to reach its
fcinfo->flinfo->fn_extra, because it has a NULL flinfo, as you can see
from these debugging messages:
NOTICE: multirange_cmp fcinfo = 0x7f875a0a66c0
NOTICE: multirange_cmp flinfo = 0x7f875a0a6690
NOTICE: multirange_cmp fn_extra = 0x7f875a099450
NOTICE: range_cmp fcinfo = 0x7ffee5ff9820
NOTICE: range_cmp flinfo = 0x0
Is it expected for flinfo to be null when using DirectFunctionCall*?
Is there something else I should use instead? It looks like
FunctionCall2 would let me pass my own flinfo, but I'm not sure how to
set that up first.
Thanks!
Paul
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: flinfo NULL in DirectFunctionCall callee?
@ 2019-08-26 15:11 Tom Lane <tgl@sss.pgh.pa.us>
parent: Paul A Jungwirth <pj@illuminatedcomputing.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2019-08-26 15:11 UTC (permalink / raw)
To: Paul A Jungwirth <pj@illuminatedcomputing.com>; +Cc: pgsql-general@lists.postgresql.org
Paul A Jungwirth <pj@illuminatedcomputing.com> writes:
> Is it expected for flinfo to be null when using DirectFunctionCall*?
Yes, per the comment on those functions:
* 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.
> Is there something else I should use instead? It looks like
> FunctionCall2 would let me pass my own flinfo, but I'm not sure how to
> set that up first.
Use fmgr_info() or a sibling to fill in the FmgrInfo.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: flinfo NULL in DirectFunctionCall callee?
@ 2019-08-26 17:41 Paul A Jungwirth <pj@illuminatedcomputing.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Paul A Jungwirth @ 2019-08-26 17:41 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
On Mon, Aug 26, 2019 at 8:12 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Paul A Jungwirth <pj@illuminatedcomputing.com> writes:
> > Is it expected for flinfo to be null when using DirectFunctionCall*?
>
> Yes, per the comment on those functions:
>
> * 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.
Thanks Tom! Alas I saw that same comment in fmgr.h but it was missing
the last sentence. Would you like a patch updating it there? Is that
the kind of thing you make CF entries for? (And sorry this is veering
into pgsql-hackers territory....)
> Use fmgr_info() or a sibling to fill in the FmgrInfo.
Thanks for this too! I wound up just adding a range_cmp_internal to
avoid the whole issue, which is a pattern already used by a bunch of
the other range_* functions.
Yours,
Paul
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: flinfo NULL in DirectFunctionCall callee?
@ 2019-08-26 18:34 Tom Lane <tgl@sss.pgh.pa.us>
parent: Paul A Jungwirth <pj@illuminatedcomputing.com>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2019-08-26 18:34 UTC (permalink / raw)
To: Paul A Jungwirth <pj@illuminatedcomputing.com>; +Cc: pgsql-general@lists.postgresql.org
Paul A Jungwirth <pj@illuminatedcomputing.com> writes:
> On Mon, Aug 26, 2019 at 8:12 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yes, per the comment on those functions:
>> * 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.
> Thanks Tom! Alas I saw that same comment in fmgr.h but it was missing
> the last sentence.
Oh, hm, that's not very nice. Fixed.
> Would you like a patch updating it there? Is that
> the kind of thing you make CF entries for?
Not really worth the overhead, for something as simple as this.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2019-08-26 18:34 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 14:51 flinfo NULL in DirectFunctionCall callee? Paul A Jungwirth <pj@illuminatedcomputing.com>
2019-08-26 15:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-08-26 17:41 ` Paul A Jungwirth <pj@illuminatedcomputing.com>
2019-08-26 18:34 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox