-- -- anycompatible / anycompatiblearray polymorphic pseudo-types (PostgreSQL -- 13+). On PostgreSQL 11 and 12 the types do not exist; the alternate -- expected file anycompat_1.out matches that case. -- CREATE FUNCTION ac_identity(anycompatible) RETURNS anycompatible LANGUAGE plruby AS $$ args[0] $$; SELECT ac_identity(42); SELECT ac_identity('hello'::text); SELECT ac_identity(3.5::float8); -- anycompatible unifies its arguments to a common type before the call. CREATE FUNCTION ac_max2(anycompatible, anycompatible) RETURNS anycompatible LANGUAGE plruby AS $$ a, b = args a >= b ? a : b $$; SELECT ac_max2(3, 7); SELECT ac_max2(2.5::float8, 1); -- anycompatiblearray: the array arrives as a Ruby Array and returns unchanged. CREATE FUNCTION ac_arr(anycompatiblearray) RETURNS anycompatiblearray LANGUAGE plruby AS $$ args[0] $$; SELECT ac_arr(ARRAY[1, 2, 3]); SELECT ac_arr(ARRAY['a', 'b']::text[]); DROP FUNCTION ac_identity(anycompatible); DROP FUNCTION ac_max2(anycompatible, anycompatible); DROP FUNCTION ac_arr(anycompatiblearray);