diff options
author | Tom Lane | 2009-10-08 02:39:25 +0000 |
---|---|---|
committer | Tom Lane | 2009-10-08 02:39:25 +0000 |
commit | 717fa274d14d9cd25396b85bb92f567e1c623f0c (patch) | |
tree | 4fe298a9faa1fc8f038a9a1f35ee033abc3e41ed /src/include | |
parent | 2eda8dfb52ed9962920282d8384da8bb4c22514d (diff) |
Support use of function argument names to identify which actual arguments
match which function parameters. The syntax uses AS, for example
funcname(value AS arg1, anothervalue AS arg2)
Pavel Stehule
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/namespace.h | 6 | ||||
-rw-r--r-- | src/include/funcapi.h | 5 | ||||
-rw-r--r-- | src/include/nodes/nodes.h | 3 | ||||
-rw-r--r-- | src/include/nodes/primnodes.h | 25 | ||||
-rw-r--r-- | src/include/parser/parse_func.h | 13 |
6 files changed, 43 insertions, 13 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 20eac6aa1c7..8959997ea96 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.542 2009/10/07 22:14:24 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.543 2009/10/08 02:39:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200910071 +#define CATALOG_VERSION_NO 200910072 #endif diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h index ed9218c03a4..2c2b88951a3 100644 --- a/src/include/catalog/namespace.h +++ b/src/include/catalog/namespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.59 2009/06/11 14:49:09 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.60 2009/10/08 02:39:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,6 +32,7 @@ typedef struct _FuncCandidateList int nargs; /* number of arg types returned */ int nvargs; /* number of args to become variadic array */ int ndargs; /* number of defaulted args */ + int *argnumbers; /* args' positional indexes, if named call */ Oid args[1]; /* arg types --- VARIABLE LENGTH ARRAY */ } *FuncCandidateList; /* VARIABLE LENGTH STRUCT */ @@ -54,7 +55,8 @@ extern bool RelationIsVisible(Oid relid); extern Oid TypenameGetTypid(const char *typname); extern bool TypeIsVisible(Oid typid); -extern FuncCandidateList FuncnameGetCandidates(List *names, int nargs, +extern FuncCandidateList FuncnameGetCandidates(List *names, + int nargs, List *argnames, bool expand_variadic, bool expand_defaults); extern bool FunctionIsVisible(Oid funcid); diff --git a/src/include/funcapi.h b/src/include/funcapi.h index 1373e4ad245..b4fe22c492b 100644 --- a/src/include/funcapi.h +++ b/src/include/funcapi.h @@ -9,7 +9,7 @@ * * Copyright (c) 2002-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.29 2009/06/11 14:49:08 momjian Exp $ + * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.30 2009/10/08 02:39:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -173,6 +173,9 @@ extern int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes); +extern int get_func_input_arg_names(Datum proargnames, Datum proargmodes, + char ***arg_names); + extern char *get_func_result_name(Oid functionId); extern TupleDesc build_function_result_tupdesc_d(Datum proallargtypes, diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 5fd046e95b8..2a4468799f9 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.227 2009/10/05 19:24:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.228 2009/10/08 02:39:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -123,6 +123,7 @@ typedef enum NodeTag T_WindowFunc, T_ArrayRef, T_FuncExpr, + T_NamedArgExpr, T_OpExpr, T_DistinctExpr, T_ScalarArrayOpExpr, diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 5f5d4125c65..0320e231553 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.150 2009/07/16 06:33:45 petere Exp $ + * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.151 2009/10/08 02:39:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -314,6 +314,29 @@ typedef struct FuncExpr } FuncExpr; /* + * NamedArgExpr - a named argument of a function + * + * This node type can only appear in the args list of a FuncCall or FuncExpr + * node. We support pure positional call notation (no named arguments), + * named notation (all arguments are named), and mixed notation (unnamed + * arguments followed by named ones). + * + * Parse analysis sets argnumber to the positional index of the argument, + * but doesn't rearrange the argument list. + * + * The planner will convert argument lists to pure positional notation + * during expression preprocessing, so execution never sees a NamedArgExpr. + */ +typedef struct NamedArgExpr +{ + Expr xpr; + Expr *arg; /* the argument expression */ + char *name; /* the name */ + int argnumber; /* argument's number in positional notation */ + int location; /* argument name location, or -1 if unknown */ +} NamedArgExpr; + +/* * OpExpr - expression node for an operator invocation * * Semantically, this is essentially the same as a function call. diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h index 7905f96e86c..0a38f740b1c 100644 --- a/src/include/parser/parse_func.h +++ b/src/include/parser/parse_func.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_func.h,v 1.65 2009/05/12 00:56:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_func.h,v 1.66 2009/10/08 02:39:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,8 @@ extern Node *ParseFuncOrColumn(ParseState *pstate, bool agg_star, bool agg_distinct, bool func_variadic, WindowDef *over, bool is_column, int location); -extern FuncDetailCode func_get_detail(List *funcname, List *fargs, +extern FuncDetailCode func_get_detail(List *funcname, + List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, Oid *funcid, Oid *rettype, @@ -68,10 +69,10 @@ extern void make_fn_arguments(ParseState *pstate, Oid *actual_arg_types, Oid *declared_arg_types); -extern const char *funcname_signature_string(const char *funcname, - int nargs, const Oid *argtypes); -extern const char *func_signature_string(List *funcname, - int nargs, const Oid *argtypes); +extern const char *funcname_signature_string(const char *funcname, int nargs, + List *argnames, const Oid *argtypes); +extern const char *func_signature_string(List *funcname, int nargs, + List *argnames, const Oid *argtypes); extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError); |