summaryrefslogtreecommitdiff
path: root/src/include/fmgr.h
diff options
context:
space:
mode:
authorAndrew Dunstan2017-03-21 12:57:46 +0000
committerAndrew Dunstan2017-03-21 12:57:46 +0000
commit29bf5016835a2c2c23786f7cda347716c083d95f (patch)
treefa54e72faa6a8fe4ec1b0e67d0d86b77bcee7c0b /src/include/fmgr.h
parent010505546a343820f291e0e298673108e436c696 (diff)
Add a direct function call mechanism using the caller's context.
The current DirectFunctionCall functions use NULL as the flinfo in initializing the FunctionCallInfoData for the call. That means the called function has no fn_mcxt or fn_extra to work with, and attempting to do so will result in an access violation. These functions instead use the provided flinfo, which will usually be the caller's own flinfo. The caller needs to ensure that it doesn't use the fn_extra in way that is incompatible with the way the called function will use it. The called function should not rely on anything else in the provided context, as it will be relevant to the caller, not the callee. Original code from Tom Lane. Discussion: https://postgr.es/m/db2b70a4-78d7-294a-a315-8e7f506c5978@2ndQuadrant.com
Diffstat (limited to 'src/include/fmgr.h')
-rw-r--r--src/include/fmgr.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 4d400d29248..0a155acee62 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -483,6 +483,19 @@ extern Datum DirectFunctionCall9Coll(PGFunction func, Oid collation,
Datum arg6, Datum arg7, Datum arg8,
Datum arg9);
+/*
+ * These functions work like the DirectFunctionCall functions except that
+ * they use the flinfo parameter to initialise the fcinfo for the call.
+ * It's recommended that the callee only use the fn_extra and fn_mcxt
+ * fields, as other fields will typically describe the calling function
+ * not the callee. Conversely, the calling function should not have
+ * used fn_extra, unless its use is known to be compatible with the callee's.
+ */
+extern Datum CallerFInfoFunctionCall1(PGFunction func, FmgrInfo *flinfo,
+ Oid collation, Datum arg1);
+extern Datum CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo,
+ Oid collation, Datum arg1, Datum arg2);
+
/* These are for invocation of a previously-looked-up function with a
* directly-computed parameter list. Note that neither arguments nor result
* are allowed to be NULL.