Skip to content

Commit c08bf4e

Browse files
author
hackorum
committed
Apply plperl-add-FN-v1.patch
1 parent 6e89028 commit c08bf4e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/pl/plperl/plperl.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,9 +2194,33 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
21942194
Oid *argtypes = NULL;
21952195
int nargs = 0;
21962196

2197+
HV *hv; // hash
2198+
SV *FNsv; // scalar reference to the hash
2199+
SV *svFN; // local reference to the hash
2200+
21972201
ENTER;
21982202
SAVETMPS;
21992203

2204+
/* Give functions some metadata about what's going on in $_FN (Similar to $_TD for triggers) */
2205+
2206+
FNsv = get_sv("main::_FN", GV_ADD);
2207+
if (!FNsv)
2208+
ereport(ERROR,
2209+
(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
2210+
errmsg("couldn't fetch $_FN")));
2211+
2212+
hv = newHV(); // create new hash
2213+
hv_store_string(hv, "name", cstr2sv(desc->proname));
2214+
2215+
save_item(FNsv); /* local $_FN */
2216+
2217+
sv_upgrade(FNsv, SVt_RV);
2218+
SvRV_set(FNsv, (SV*)hv);
2219+
SvROK_on(FNsv);
2220+
2221+
svFN = newRV_noinc((SV *) hv); // reference to the new hash
2222+
sv_setsv(FNsv, svFN);
2223+
22002224
PUSHMARK(SP);
22012225
EXTEND(sp, desc->nargs);
22022226

0 commit comments

Comments
 (0)