Skip to content

Commit 7184a42

Browse files
committed
The small context diff below corrects what seems to be an oversight in
fmgr.h - it's discouraged to access fcinfo directly but there is no macro to get the number of arguments passed to the function. Checking the number of arguments is often useful when you have a function which can be called like: func('arg'); func(null); func(); all mapping to the same C function. the macro has a function-like appearance to match the other PG_* macros. Lee Kindness.
1 parent e57ab04 commit 7184a42

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/include/fmgr.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $Id: fmgr.h,v 1.24 2002/09/04 20:31:36 momjian Exp $
14+
* $Id: fmgr.h,v 1.25 2002/09/12 00:26:42 momjian Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -115,6 +115,11 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
115115
/* Standard parameter list for fmgr-compatible functions */
116116
#define PG_FUNCTION_ARGS FunctionCallInfo fcinfo
117117

118+
/*
119+
* Get number of arguments passed to function.
120+
*/
121+
#define PG_NARGS() (fcinfo->nargs)
122+
118123
/*
119124
* If function is not marked "proisstrict" in pg_proc, it must check for
120125
* null arguments using this macro. Do not try to GETARG a null argument!

0 commit comments

Comments
 (0)