summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2020-04-04 22:03:30 +0000
committerTom Lane2020-04-04 22:03:30 +0000
commit07871d40c72e498b6e034eb674df5d8d206976bc (patch)
tree76045cf9e82f7d28b4806e83ba6cbca6f4151119 /src/test
parentc6b92041d38512a4176ed76ad06f713d2e6c01a8 (diff)
Remove bogus Assert, add some regression test cases showing why.
Commit 77ec5affb added an assertion to enforce_generic_type_consistency that boils down to "if the function result is polymorphic, there must be at least one polymorphic argument". This should be true for user-created functions, but there are built-in functions for which it's not true, as pointed out by Jaime Casanova. Hence, go back to the old behavior of leaving the return type alone. There's only a limited amount of stuff you can do with such a function result, but it does work to some extent; add some regression test cases to ensure we don't break that again. Discussion: https://postgr.es/m/CAJGNTeMbhtsCUZgJJ8h8XxAJbK7U2ipsX8wkHRtZRz-NieT8RA@mail.gmail.com
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/polymorphism.out13
-rw-r--r--src/test/regress/sql/polymorphism.sql5
2 files changed, 18 insertions, 0 deletions
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index d86a7004a6f..1ff40764d9a 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -852,6 +852,19 @@ where histogram_bounds is not null;
-- (WHERE clause here is to avoid possibly getting a collation error instead)
select max(histogram_bounds) from pg_stats where tablename = 'pg_am';
ERROR: cannot compare arrays of different element types
+-- another corner case is the input functions for polymorphic pseudotypes
+select array_in('{1,2,3}','int4'::regtype,-1); -- this has historically worked
+ array_in
+----------
+ {1,2,3}
+(1 row)
+
+select * from array_in('{1,2,3}','int4'::regtype,-1); -- this not
+ERROR: function "array_in" in FROM has unsupported return type anyarray
+LINE 1: select * from array_in('{1,2,3}','int4'::regtype,-1);
+ ^
+select anyrange_in('[10,20)','int4range'::regtype,-1);
+ERROR: cannot accept a value of type anyrange
-- test variadic polymorphic functions
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql
index b57591f69f6..e5222f1f81f 100644
--- a/src/test/regress/sql/polymorphism.sql
+++ b/src/test/regress/sql/polymorphism.sql
@@ -577,6 +577,11 @@ where histogram_bounds is not null;
-- (WHERE clause here is to avoid possibly getting a collation error instead)
select max(histogram_bounds) from pg_stats where tablename = 'pg_am';
+-- another corner case is the input functions for polymorphic pseudotypes
+select array_in('{1,2,3}','int4'::regtype,-1); -- this has historically worked
+select * from array_in('{1,2,3}','int4'::regtype,-1); -- this not
+select anyrange_in('[10,20)','int4range'::regtype,-1);
+
-- test variadic polymorphic functions
create function myleast(variadic anyarray) returns anyelement as $$