Fix PL/pgSQL's handling of anycompatiblemultirange. When validating a PL/pgSQL function with polymorphic arguments or result type, we substitute a plausible concrete type for each polymorphic type. anycompatiblemultirange was missed in both places that do this, when multiranges were added. As a result, CREATE FUNCTION with an anycompatiblemultirange argument failed with "PL/pgSQL functions cannot accept type anycompatiblemultirange" when check_function_bodies is on.
Also, a function returning anycompatiblemultirange was compiled by the validator with an int4 result type, and since the function cache key doesn't include the result type, a later call in the same session with int4range arguments reused that entry and failed trying to cast the multirange result to integer. Map anycompatiblemultirange to int4multirange, as is done for anymultirange, to fix both issues. Author: Jeevan Chalke <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/CAM2+6=VEXCo7tPaxX+9_zN8SJ9DiPp2NTj_sPGN+Tb0wWTBp=w...@mail.gmail.com Backpatch-through: 14 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a34d61616134c75694e99abf8beb58b7b82b3455 Modified Files -------------- src/backend/utils/cache/funccache.c | 1 + src/pl/plpgsql/src/pl_comp.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
