Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chg9l-0007gr-Mi for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Feb 2017 17:29:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1chg9k-0002Ea-Gw for pgsql-hackers@arkaria.postgresql.org; Sat, 25 Feb 2017 17:29:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1chg8I-0000bu-J0 for pgsql-hackers@postgresql.org; Sat, 25 Feb 2017 17:27:46 +0000 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1chg8A-0006JW-Uv for pgsql-hackers@postgresql.org; Sat, 25 Feb 2017 17:27:45 +0000 Received: by mail-qk0-x22c.google.com with SMTP id u188so47005915qkc.2 for ; Sat, 25 Feb 2017 09:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to; bh=BbfucdPI2wFQSRGDtESZtv+ePXAvCX7dWvB8Rx65gRo=; b=bDBad/BL4YtqV+g8dIuJRNRO3zR7mtPXyVUNE8NUai6mKLARN6r8Ivigi2s7FkS3/R REWjHl5uOh7EJLC80uwBQ5Ri9QSOzAr4HCO//2TKkQPvojkbkMRLRJ8AyQu5uZ8QSlw+ lacUaFNMJL6RQBav/R0bLo01FtIwD/YqIhEskgEMV5LMt+oWWbDioCu85gHYdN8LMwUW wI3DoQwWUJWmcVl5Jui+KBOjkUjaOMKKxv+LB2z3Mq5yOMoSUTkht7hqV1mSswc8EjEd +LuPaMUnE+2IB8DWvGG7gz2wr2zJwfVpT71lP3I3Q8iqFsQ7iGHSbxAAmhaEzULis87U Gr4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to; bh=BbfucdPI2wFQSRGDtESZtv+ePXAvCX7dWvB8Rx65gRo=; b=CtVSItGNcNUmYF0MqMbwiQ02nHK3xcnADC5hqtiVMegIiS9Q8peMeE7oWctUd7JJsG xOJ3zSzgg49GyhI+0/rW0DOcSw+cO1O0rPJU1lxVe9N2BYYPX+aKSCTTMH1t5jfxuKTB Zmgna+TfPd+goyoxmQTGtMu3eCKEHKjzGDJOk6G/vmcQtFNfUIdU0eZgSt2ceR3zM1n4 up4GVJC3t5OiwacPKH2lOg6D5bqWMyzK3atdouulJtBwRMr7yd9XR3RHgc8SHk5IENRt YynZeZYS309mTiMHVftiO2y5CDZjOk8AQrB+y1RsLPxT79CPSa8Naht8/y8VLpsA81/0 1/gQ== X-Gm-Message-State: AMke39llCvlt5ORbtDnBgOmPzsZoNyK4mOxnhNxnYDstFshQ7ByesrqqPfiz6qs8iYhEUzIF18R6MfPi9ycBjYQj/02Cu6gcvoK9F61A2FAZ9wGPZ4knY7jUqcVLas3OhD4jHXInLC7OsWO0GCgPWAKrA3B/zs28pcsImEUtLTOU1xVDYJWlro0eVEqffCBr6K1SXYuesj8SZ78= X-Received: by 10.200.55.115 with SMTP id p48mr8160768qtb.209.1488043657764; Sat, 25 Feb 2017 09:27:37 -0800 (PST) Received: from [192.168.10.146] ([98.122.164.227]) by smtp.gmail.com with ESMTPSA id k6sm7124945qte.53.2017.02.25.09.27.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Feb 2017 09:27:37 -0800 (PST) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: btree_gin and btree_gist for enums To: Tom Lane References: <56EA8A71.8060107@dunslane.net> <56EACB8C.1040406@dunslane.net> <03f7d748-0f89-e8e1-094d-f04e1026b93d@dunslane.net> <27220.1478360811@sss.pgh.pa.us> <31412.1478366009@sss.pgh.pa.us> <60fb708c-8b3c-1337-934e-c1bfe2afc539@dunslane.net> <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> <12734.1488042261@sss.pgh.pa.us> Cc: PostgreSQL-development Message-ID: <4e730f28-742b-45e9-d507-4d292fbd7834@2ndQuadrant.com> Date: Sat, 25 Feb 2017 12:27:36 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <12734.1488042261@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------CA8D7CFBD4524B4F0003593E" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------CA8D7CFBD4524B4F0003593E Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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 --------------CA8D7CFBD4524B4F0003593E Content-Type: text/x-diff; name="callfinfofunctioncall2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="callfinfofunctioncall2.patch" diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 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.h index 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. --------------CA8D7CFBD4524B4F0003593E Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --------------CA8D7CFBD4524B4F0003593E--