Re: Last call for comments: fmgr rewrite [LONG] - Mailing list pgsql-hackers

From Chris Bitmead
Subject Re: Last call for comments: fmgr rewrite [LONG]
Date
Msg-id 39287745.193A5521@nimrod.itg.telecom.com.au
Whole thread Raw
In response to Last call for comments: fmgr rewrite [LONG]  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Last call for comments: fmgr rewrite [LONG]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:

> typedef struct
> {
>     FmgrInfo   *flinfo;         /* ptr to lookup info used for this call */
>     Node       *context;        /* pass info about context of call */
>     Node       *resultinfo;     /* pass or return extra info about result */
>     bool        isnull;         /* function must set true if result is NULL */
>     short       nargs;          /* # arguments actually passed */
>     Datum       arg[FUNC_MAX_ARGS];  /* Arguments passed to function */
>     bool        argnull[FUNC_MAX_ARGS];  /* T if arg[i] is actually NULL */
> } FunctionCallInfoData;

Just wondering what the implications of FUNC_MAX_ARGS is, and whether
something like...

struct FuncArg 
{  Datum arg;  bool argnull;
};

typedef struct
{   FmgrInfo   *flinfo;         /* ptr to lookup info used for this call
*/   Node       *context;        /* pass info about context of call */   Node       *resultinfo;     /* pass or return
extrainfo about
 
result */   bool        isnull;         /* function must set true if result is
NULL */   short       nargs;          /* # arguments actually passed */   struct FuncArg args[];
} FunctionCallInfoData;

might remove an arbitrary argument limit?

> int32
> int4pl(int32 arg1, int32 arg2)
> {
>     return arg1 + arg2;
> }
> to new-style
> Datum
> int4pl(FunctionCallInfo fcinfo)
> {
>     /* we assume the function is marked "strict", so we can ignore
>      * NULL-value handling */
> 
>     return Int32GetDatum(DatumGetInt32(fcinfo->arg[0]) +
>                          DatumGetInt32(fcinfo->arg[1]));
> }


Wondering if some stub code generator might be appropriate so that
functions can can continue to look as readable as before?


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Last call for comments: fmgr rewrite [LONG]
Next
From: Bruce Momjian
Date:
Subject: Re: Last call for comments: fmgr rewrite [LONG]