What's the correct way to use FunctionCallInvoke()?

Started by Boszormenyi Zoltanalmost 19 years ago2 messagesgeneral
Jump to latest
#1Boszormenyi Zoltan
zb@cybertec.at

Hi,

I have a problem calling a C function
from another C function - DirectFunctionCall*
cannot be used since some parameters may be NULL.
This dies:

FunctionCallInfoData fcinfo1;

InitFunctionCallInfoData(fcinfo1, NULL, 7, NULL, NULL);
/* arg[] and arnull[] are filled with correct values */
result = myfunc(&fcinfo1);

Also this also:

FunctionCallInfoData fcinfo1;
FmgrInfo flinfo1;

MemSet(&flinfo1, 0, sizeof(flinfo1));
flinfo1.fn_addr = myfunc;
flinfo1.fn_nargs = 7;
InitFunctionCallInfoData(fcinfo1, &flinfo1, 7, NULL, NULL);
/* arg[] and arnull[] are filled with correct values */
result = FunctionCallInvoke(&fcinfo1);

How to do it correctly? I am on PostgreSQL 8.1.9 currently.

--
----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Geschwinde & Sch�nig GmbH
http://www.postgresql.at/

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Boszormenyi Zoltan (#1)
Re: What's the correct way to use FunctionCallInvoke()?

Zoltan Boszormenyi <zb@cybertec.at> writes:

FmgrInfo flinfo1;

MemSet(&flinfo1, 0, sizeof(flinfo1));

This is certainly not the approved way to set up an FmgrInfo.
Use fmgr_info().

regards, tom lane