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_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/791446a140a7392261756f6e0d466cc2b8224ebd Modified Files -------------- src/backend/utils/cache/funccache.c | 1 + src/pl/plpgsql/src/pl_comp.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
