diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-17 19:36:41 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-03-17 19:36:41 -0400 |
| commit | e6c178b5b73ac1fb822829e6d9b99e3fc1129c21 (patch) | |
| tree | cc458fdcb6761971a6c5f6ce1cfd86ac27edfe9f /src/include/parser | |
| parent | dbbb55385cf5eb75837eb3eb7ca1f14e2beb5a63 (diff) | |
Refactor our checks for valid function and aggregate signatures.
pg_proc.c and pg_aggregate.c had near-duplicate copies of the logic
to decide whether a function or aggregate's signature is legal.
This seems like a bad thing even without the problem that the
upcoming "anycompatible" patch would roughly double the complexity
of that logic. Hence, refactor so that the rules are localized
in new subroutines supplied by parse_coerce.c. (One could quibble
about just where to add that code, but putting it beside
enforce_generic_type_consistency seems not totally unreasonable.)
The fact that the rules are about to change would mandate some
changes in the wording of the associated error messages in any case.
I ended up spelling things out in a fairly literal fashion in the
errdetail messages, eg "A result of type anyelement requires at
least one input of type anyelement, anyarray, anynonarray, anyenum,
or anyrange." Perhaps this is overkill, but once there's more than
one subgroup of polymorphic types, people might get confused by
more-abstract messages.
Discussion: https://postgr.es/m/24137.1584139352@sss.pgh.pa.us
Diffstat (limited to 'src/include/parser')
| -rw-r--r-- | src/include/parser/parse_coerce.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index ff9219dda93..8686eaacbc9 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -80,6 +80,13 @@ extern Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid rettype, bool allow_poly); +extern char *check_valid_polymorphic_signature(Oid ret_type, + const Oid *declared_arg_types, + int nargs); +extern char *check_valid_internal_signature(Oid ret_type, + const Oid *declared_arg_types, + int nargs); + extern CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, |
