mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-04 12:27:37 +08:00
Commit 2453ea142 redefined pg_proc.proargtypes to include the types of OUT parameters, for procedures only. While that had some advantages for implementing the SQL-spec behavior of DROP PROCEDURE, it was pretty disastrous from a number of other perspectives. Notably, since the primary key of pg_proc is name + proargtypes, this made it possible to have multiple procedures with identical names + input arguments and differing output argument types. That would make it impossible to call any one of the procedures by writing just NULL (or "?", or any other data-type-free notation) for the output argument(s). The change also seems likely to cause grave confusion for client applications that examine pg_proc and expect the traditional definition of proargtypes. Hence, revert the definition of proargtypes to what it was, and undo a number of complications that had been added to support that. To support the SQL-spec behavior of DROP PROCEDURE, when there are no argmode markers in the command's parameter list, we perform the lookup both ways (that is, matching against both proargtypes and proallargtypes), succeeding if we get just one unique match. In principle this could result in ambiguous-function failures that would not happen when using only one of the two rules. However, overloading of procedure names is thought to be a pretty rare usage, so this shouldn't cause many problems in practice. Postgres-specific code such as pg_dump can defend against any possibility of such failures by being careful to specify argmodes for all procedure arguments. This also fixes a few other bugs in the area of CALL statements with named parameters, and improves the documentation a little. catversion bump forced because the representation of procedures with OUT arguments changes. Discussion: https://postgr.es/m/3742981.1621533210@sss.pgh.pa.us
75 lines
2.4 KiB
C
75 lines
2.4 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* parse_func.h
|
|
*
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/parser/parse_func.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PARSE_FUNC_H
|
|
#define PARSE_FUNC_H
|
|
|
|
#include "catalog/namespace.h"
|
|
#include "parser/parse_node.h"
|
|
|
|
|
|
/* Result codes for func_get_detail */
|
|
typedef enum
|
|
{
|
|
FUNCDETAIL_NOTFOUND, /* no matching function */
|
|
FUNCDETAIL_MULTIPLE, /* too many matching functions */
|
|
FUNCDETAIL_NORMAL, /* found a matching regular function */
|
|
FUNCDETAIL_PROCEDURE, /* found a matching procedure */
|
|
FUNCDETAIL_AGGREGATE, /* found a matching aggregate function */
|
|
FUNCDETAIL_WINDOWFUNC, /* found a matching window function */
|
|
FUNCDETAIL_COERCION /* it's a type coercion request */
|
|
} FuncDetailCode;
|
|
|
|
|
|
extern Node *ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
|
Node *last_srf, FuncCall *fn, bool proc_call,
|
|
int location);
|
|
|
|
extern FuncDetailCode func_get_detail(List *funcname,
|
|
List *fargs, List *fargnames,
|
|
int nargs, Oid *argtypes,
|
|
bool expand_variadic, bool expand_defaults,
|
|
bool include_out_arguments,
|
|
Oid *funcid, Oid *rettype,
|
|
bool *retset, int *nvargs, Oid *vatype,
|
|
Oid **true_typeids, List **argdefaults);
|
|
|
|
extern int func_match_argtypes(int nargs,
|
|
Oid *input_typeids,
|
|
FuncCandidateList raw_candidates,
|
|
FuncCandidateList *candidates);
|
|
|
|
extern FuncCandidateList func_select_candidate(int nargs,
|
|
Oid *input_typeids,
|
|
FuncCandidateList candidates);
|
|
|
|
extern void make_fn_arguments(ParseState *pstate,
|
|
List *fargs,
|
|
Oid *actual_arg_types,
|
|
Oid *declared_arg_types);
|
|
|
|
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 missing_ok);
|
|
extern Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func,
|
|
bool missing_ok);
|
|
|
|
extern void check_srf_call_placement(ParseState *pstate, Node *last_srf,
|
|
int location);
|
|
|
|
#endif /* PARSE_FUNC_H */
|