postgresql/src/include/parser
Tom Lane 4dbcb3f844 Restructure polymorphic-type resolution in funcapi.c.
resolve_polymorphic_tupdesc() and resolve_polymorphic_argtypes() failed to
cover the case of having to resolve anyarray given only an anyrange input.
The bug was masked if anyelement was also used (as either input or
output), which probably helps account for our not having noticed.

While looking at this I noticed that resolve_generic_type() would produce
the wrong answer if asked to make that same resolution.  ISTM that
resolve_generic_type() is confusingly defined and overly complex, so
rather than fix it, let's just make funcapi.c do the specific lookups
it requires for itself.

With this change, resolve_generic_type() is not used anywhere, so remove
it in HEAD.  In the back branches, leave it alone (complete with bug)
just in case any external code is using it.

While we're here, make some other refactoring adjustments in funcapi.c
with an eye to upcoming future expansion of the set of polymorphic types:

* Simplify quick-exit tests by adding an overall have_polymorphic_result
flag.  This is about a wash now but will be a win when there are more
flags.

* Reduce duplication of code between resolve_polymorphic_tupdesc() and
resolve_polymorphic_argtypes().

* Don't bother to validate correct matching of anynonarray or anyenum;
the parser should have done that, and even if it didn't, just doing
"return false" here would lead to a very confusing, off-point error
message.  (Really, "return false" in these two functions should only
occur if the call_expr isn't supplied or we can't obtain data type
info from it.)

* For the same reason, throw an elog rather than "return false" if
we fail to resolve a polymorphic type.

The bug's been there since we added anyrange, so back-patch to
all supported branches.

Discussion: https://postgr.es/m/6093.1584202130@sss.pgh.pa.us
2020-03-14 14:42:22 -04:00
..
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
analyze.h Fill in extraUpdatedCols in logical replication 2020-02-17 15:20:57 +01:00
gramparse.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
kwlist.h ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION 2020-01-14 13:36:03 +01:00
parse_agg.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_clause.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_coerce.h Restructure polymorphic-type resolution in funcapi.c. 2020-03-14 14:42:22 -04:00
parse_collate.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_cte.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_enr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_expr.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_func.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_node.h Make parser rely more heavily on the ParseNamespaceItem data structure. 2020-01-02 11:29:01 -05:00
parse_oper.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_param.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_relation.h Reconsider the representation of join alias Vars. 2020-01-09 11:56:59 -05:00
parse_target.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_type.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parse_utilcmd.h Restructure ALTER TABLE execution to fix assorted bugs. 2020-01-15 18:49:24 -05:00
parser.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
parsetree.h Make parser rely more heavily on the ParseNamespaceItem data structure. 2020-01-02 11:29:01 -05:00
scanner.h Allow Unicode escapes in any server encoding, not only UTF-8. 2020-03-06 14:17:43 -05:00
scansup.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00