From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: btree_gin and btree_gist for enums
Date: Sat, 25 Feb 2017 12:27:36 -0500
Message-ID: <4e730f28-742b-45e9-d507-4d292fbd7834@2ndQuadrant.com> (raw)
In-Reply-To: <12734.1488042261@sss.pgh.pa.us>
References: <56EA8A71.8060107@dunslane.net>
<56EACB8C.1040406@dunslane.net>
<CAE2gYzyB=vyquQ2hEWA9UwNb=zYAKFsNO5vBtbfkV2=PzoPZjg@mail.gmail.com>
<03f7d748-0f89-e8e1-094d-f04e1026b93d@dunslane.net>
<27220.1478360811@sss.pgh.pa.us>
<e60f50c4-899a-d48a-6cb4-4611acf2f73c@dunslane.net>
<31412.1478366009@sss.pgh.pa.us>
<60fb708c-8b3c-1337-934e-c1bfe2afc539@dunslane.net>
<db2b70a4-78d7-294a-a315-8e7f506c5978@2ndQuadrant.com>
<8258.1487886101@sss.pgh.pa.us>
<4376a7bf-ab8c-e640-9021-94b148f9d733@2ndQuadrant.com>
<6704.1487952174@sss.pgh.pa.us>
<930cb563-6dc6-c4af-3be9-31f06c60361e@2ndQuadrant.com>
<8a8c60b4-39c0-69a4-824c-e364f5fd97ea@2ndQuadrant.com>
<fac3c5d1-ad66-3a15-c181-c7aadf1d6ad1@2ndQuadrant.com>
<12734.1488042261@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On 02/25/2017 12:04 PM, Tom Lane wrote:
> I think it'd be better to leave DirectFunctionCallN alone and just invent
> a small number of CallerFInfoFunctionCallN support functions (maybe N=1
> and N=2 would be enough, at least for now).
>
>
See attached.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackersAttachments:callfinfofunctioncall2.patch (text/x-diff, 2.6K) downloaddiff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.cindex 3976496..66227e5 100644--- a/src/backend/utils/fmgr/fmgr.c+++ b/src/backend/utils/fmgr/fmgr.c@@ -1276,6 +1276,54 @@ DirectFunctionCall9Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2,
return result;
}
+/*+ * These functions work like the DirectFunctionCall functions except that+ * they use the flinfo parameter to initialise the fcinfo for the call.+ * The callee should not look at anything except the fn_mcxt and fn_extra.+ * Anything else is likely to be bogus.+ */++Datum+CallerFInfoFunctionCall1(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1)+{+ FunctionCallInfoData fcinfo;+ Datum result;++ InitFunctionCallInfoData(fcinfo, flinfo, 1, collation, NULL, NULL);++ fcinfo.arg[0] = arg1;+ fcinfo.argnull[0] = false;++ result = (*func) (&fcinfo);++ /* Check for null result, since caller is clearly not expecting one */+ if (fcinfo.isnull)+ elog(ERROR, "function %p returned NULL", (void *) func);++ return result;+}++Datum+CallerFInfoFunctionCall2(PGFunction func, FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)+{+ FunctionCallInfoData fcinfo;+ Datum result;++ InitFunctionCallInfoData(fcinfo, flinfo, 2, collation, NULL, NULL);++ fcinfo.arg[0] = arg1;+ fcinfo.arg[1] = arg2;+ fcinfo.argnull[0] = false;+ fcinfo.argnull[1] = false;++ result = (*func) (&fcinfo);++ /* Check for null result, since caller is clearly not expecting one */+ if (fcinfo.isnull)+ elog(ERROR, "function %p returned NULL", (void *) func);++ return result;+}
/*
* These are for invocation of a previously-looked-up function with a
diff --git a/src/include/fmgr.h b/src/include/fmgr.hindex a671480..739ce46 100644--- a/src/include/fmgr.h+++ b/src/include/fmgr.h@@ -475,6 +475,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.+ * The callee should not look at anything except the fn_mcxt and fn_extra.+ * Anything else is likely to be bogus.+ */++extern Datum CallerFInfoFunctionCall1(PGFunction func, FmgrInfo *flinfo,+ Oid collation, Datum arg1);+extern Datum CallerFInfoFunctionCall1(PGFunction func, FmgrInfo *flinfo,+ Oid collation, Datum arg1);++
/* 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: andrew.dunstan@2ndquadrant.com, tgl@sss.pgh.pa.us
Subject: Re: btree_gin and btree_gist for enums
In-Reply-To: <4e730f28-742b-45e9-d507-4d292fbd7834@2ndQuadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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