diff options
| author | Tom Lane | 2020-11-04 21:09:55 +0000 |
|---|---|---|
| committer | Tom Lane | 2020-11-04 21:09:55 +0000 |
| commit | 9e38c2bb5093ceb0c04d6315ccd8975bd17add66 (patch) | |
| tree | 78afafa32e3f4a615281401b37890ac4775dfffc /src/test/regress/sql | |
| parent | 5c292e6b90433c760a3e15027646c7b94afd0cdd (diff) | |
Declare assorted array functions using anycompatible not anyelement.
Convert array_append, array_prepend, array_cat, array_position,
array_positions, array_remove, array_replace, and width_bucket
to use anycompatiblearray. This is a simple extension of commit
5c292e6b9 to hit some other places where there's a pretty obvious
gain in usability from doing so.
Ideally we'd also modify other functions taking multiple old-style
polymorphic arguments. But most of the remainder are tied into one
or more operator classes, making any such change a much larger can of
worms than I desire to open right now.
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/test/regress/sql')
| -rw-r--r-- | src/test/regress/sql/arrays.sql | 2 | ||||
| -rw-r--r-- | src/test/regress/sql/polymorphism.sql | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql index 2b689ae88f5..906fd712b71 100644 --- a/src/test/regress/sql/arrays.sql +++ b/src/test/regress/sql/arrays.sql @@ -311,6 +311,7 @@ SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY"; SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}"; SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}"; SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}"; +SELECT ARRAY[1.1] || ARRAY[2,3,4]; SELECT * FROM array_op_test WHERE i @> '{32}' ORDER BY seqno; SELECT * FROM array_op_test WHERE i && '{32}' ORDER BY seqno; @@ -616,6 +617,7 @@ select array_remove(array[1,2,2,3], 2); select array_remove(array[1,2,2,3], 5); select array_remove(array[1,NULL,NULL,3], NULL); select array_remove(array['A','CC','D','C','RR'], 'RR'); +select array_remove(array[1.0, 2.1, 3.3], 1); select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed select array_remove(array['X','X','X'], 'X') = '{}'; select array_replace(array[1,2,5,4],5,3); diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql index e5222f1f81f..70a21c89780 100644 --- a/src/test/regress/sql/polymorphism.sql +++ b/src/test/regress/sql/polymorphism.sql @@ -498,10 +498,10 @@ select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl; -- another sort of polymorphic aggregate -CREATE AGGREGATE array_cat_accum (anyarray) +CREATE AGGREGATE array_cat_accum (anycompatiblearray) ( sfunc = array_cat, - stype = anyarray, + stype = anycompatiblearray, initcond = '{}' ); @@ -549,7 +549,7 @@ create aggregate build_group(int8, integer) ( -- check proper resolution of data types for polymorphic transfn/finalfn -create function first_el(anyarray) returns anyelement as +create function first_el(anycompatiblearray) returns anycompatible as 'select $1[1]' language sql strict immutable; create aggregate first_el_agg_f8(float8) ( @@ -558,9 +558,9 @@ create aggregate first_el_agg_f8(float8) ( FINALFUNC = first_el ); -create aggregate first_el_agg_any(anyelement) ( +create aggregate first_el_agg_any(anycompatible) ( SFUNC = array_append, - STYPE = anyarray, + STYPE = anycompatiblearray, FINALFUNC = first_el ); |
