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_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9df4d21acb4dbb4a264777e499f2be5c805d2be4 Modified Files -------------- src/pl/plpgsql/src/pl_comp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
