Re: dblink: add polymorphic functions.

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: dblink: add polymorphic functions.
Date: 2015-07-06 14:49:02
Message-ID: CADkLM=er4LDi_WcbB8bMNpHROPKF18-uCRA2=-whiK6M1Co95g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 6, 2015 at 10:08 AM, Joe Conway <mail(at)joeconway(dot)com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 07/06/2015 12:39 AM, Michael Paquier wrote:
> >> Yeah, particularly the use of first_optarg makes things harder
> >> to follow in the code with this patch. A C wrapper has the
> >> disadvantage to decentralize the argument checks to many places
> >> making the flow harder to follow hence using
> >> get_fn_expr_argtype() with PG_NARGS would be the way to go, at
> >> least to me. This way, you can easily find how many arguments
> >> there are, and which value is assigned to which variable before
> >> moving on to the real processing.
> >
> > Just to be clear I mean that: if (PG_NARGS() == 5) { if
> > (get_fn_expr_argtype(fcinfo->flinfo, 1) == TYPEOID) var =
> > PG_GETARG_BOOL(1) [...]
>
> Actually, I had in mind something like:
> 8<---------------------
> int i;
> int numargs;
> int *argtypes;
>
> numargs = PG_NARGS();
> argtypes = palloc(numargs * sizeof(int));
> for (i = 0; i < numargs; i++)
> argtypes[i] = get_fn_expr_argtype(fcinfo->flinfo, i);
>
> if ((numargs == 4 || numargs == 5) &&
> argtypes[0] == TEXTOID &&
> argtypes[1] == TEXTOID &&
> argtypes[2] == INT4OID &&
> argtypes[3] == BOOLOID)
> {
> [...]
> }
> else if ((numargs == 3 || numargs == 4) &&
> argtypes[0] == TEXTOID &&
> argtypes[1] == INT4OID &&
> argtypes[2] == BOOLOID)
> {
> [...]
> 8<---------------------
> etc.
>
> If the highest number of arguments is always checked first, the
> pattern is not ambiguous even with the extra anyelement.
>
>
Utterly reasonable and do-able. I'll get to work on that soonish, pending
resolution of other's concerns.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2015-07-06 14:52:51 Re: dblink: add polymorphic functions.
Previous Message Fujii Masao 2015-07-06 14:48:41 Re: RFC: replace pg_stat_activity.waiting with something more descriptive