diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index ceca0e3ede..cb341b8db6 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -1890,10 +1890,9 @@ getTypeIOParam(HeapTuple typeTuple) /* * Array types get their typelem as parameter; everybody else gets their - * own type OID as parameter. (As of 8.2, domains must get their own OID - * even if their base type is an array.) + * own type OID as parameter. */ - if (typeStruct->typtype == TYPTYPE_BASE && OidIsValid(typeStruct->typelem)) + if (OidIsValid(typeStruct->typelem)) return typeStruct->typelem; else return HeapTupleGetOid(typeTuple); diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out index 4d1fc2beb0..cb3d756290 100644 --- a/src/test/regress/expected/polymorphism.out +++ b/src/test/regress/expected/polymorphism.out @@ -578,6 +578,27 @@ select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl; -4567890123456789 | -4567890123456788 (5 rows) +-- another sort of polymorphic aggregate +CREATE AGGREGATE array_cat_accum (anyarray) +( + sfunc = array_cat, + stype = anyarray, + initcond = '{}' +); +SELECT array_cat_accum(i) +FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4])) as t(i); + array_cat_accum +----------------- + {1,2,3,4} +(1 row) + +SELECT array_cat_accum(i) +FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)])) as t(i); + array_cat_accum +----------------------------------- + {"(1,2)","(3,4)","(5,6)","(7,8)"} +(1 row) + -- another kind of polymorphic aggregate create function add_group(grp anyarray, ad anyelement, size integer) returns anyarray diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql index 50e6905d4c..3d8dd1e554 100644 --- a/src/test/regress/sql/polymorphism.sql +++ b/src/test/regress/sql/polymorphism.sql @@ -392,6 +392,21 @@ select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl; select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl; +-- another sort of polymorphic aggregate + +CREATE AGGREGATE array_cat_accum (anyarray) +( + sfunc = array_cat, + stype = anyarray, + initcond = '{}' +); + +SELECT array_cat_accum(i) +FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4])) as t(i); + +SELECT array_cat_accum(i) +FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)])) as t(i); + -- another kind of polymorphic aggregate create function add_group(grp anyarray, ad anyelement, size integer)