flinfo NULL in DirectFunctionCall callee?

Paul A Jungwirth <pj@illuminatedcomputing.com>

From: Paul A Jungwirth <pj@illuminatedcomputing.com>
To: pgsql-general@lists.postgresql.org
Date: 2019-08-26T14:51:27Z
Lists: pgsql-general
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



Commits

  1. Make comment in fmgr.h match the one in fmgr.c.