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);