File tree 3 files changed +36
-4
lines changed 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -1961,7 +1961,7 @@ resolve_aggregate_transtype(Oid aggfuncid,
1961
1961
1962
1962
/*
1963
1963
* agg_args_support_sendreceive
1964
- * Returns true if all non-byval of aggref's arg types have send and
1964
+ * Returns true if all non-byval types of aggref's args have send and
1965
1965
* receive functions.
1966
1966
*/
1967
1967
bool
@@ -1976,6 +1976,15 @@ agg_args_support_sendreceive(Aggref *aggref)
1976
1976
TargetEntry * tle = (TargetEntry * ) lfirst (lc );
1977
1977
Oid type = exprType ((Node * ) tle -> expr );
1978
1978
1979
+ /*
1980
+ * RECORD is a special case: it has typsend/typreceive functions, but
1981
+ * record_recv only works if passed the correct typmod to identify the
1982
+ * specific anonymous record type. array_agg_deserialize cannot do
1983
+ * that, so we have to disclaim support for the case.
1984
+ */
1985
+ if (type == RECORDOID )
1986
+ return false;
1987
+
1979
1988
typeTuple = SearchSysCache1 (TYPEOID , ObjectIdGetDatum (type ));
1980
1989
if (!HeapTupleIsValid (typeTuple ))
1981
1990
elog (ERROR , "cache lookup failed for type %u" , type );
Original file line number Diff line number Diff line change @@ -2033,8 +2033,8 @@ explain (costs off) select * from v_pagg_test order by y;
2033
2033
-> Parallel Seq Scan on pagg_test
2034
2034
(13 rows)
2035
2035
2036
- set max_parallel_workers_per_gather = 0;
2037
2036
-- Ensure results are the same without parallel aggregation.
2037
+ set max_parallel_workers_per_gather = 0;
2038
2038
select * from v_pagg_test order by y;
2039
2039
y | tmin | tmax | tndistinct | bmin | bmax | bndistinct | amin | amax | andistinct | aamin | aamax | aandistinct
2040
2040
---+------+------+------------+------+------+------------+------+------+------------+-------+-------+-------------
@@ -2050,6 +2050,24 @@ select * from v_pagg_test order by y;
2050
2050
9 | 19 | 4999 | 250 | 1019 | 999 | 250 | 19 | 4999 | 250 | 19 | 4999 | 250
2051
2051
(10 rows)
2052
2052
2053
+ -- Check that we don't fail on anonymous record types.
2054
+ set max_parallel_workers_per_gather = 2;
2055
+ explain (costs off)
2056
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
2057
+ QUERY PLAN
2058
+ --------------------------------------------
2059
+ Aggregate
2060
+ -> Gather
2061
+ Workers Planned: 2
2062
+ -> Parallel Seq Scan on pagg_test
2063
+ (4 rows)
2064
+
2065
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
2066
+ array_dims
2067
+ ------------
2068
+ [1:5000]
2069
+ (1 row)
2070
+
2053
2071
-- Clean up
2054
2072
reset max_parallel_workers_per_gather;
2055
2073
reset bytea_output;
Original file line number Diff line number Diff line change @@ -805,11 +805,16 @@ select * from v_pagg_test order by y;
805
805
-- Ensure parallel aggregation is actually being used.
806
806
explain (costs off) select * from v_pagg_test order by y;
807
807
808
- set max_parallel_workers_per_gather = 0 ;
809
-
810
808
-- Ensure results are the same without parallel aggregation.
809
+ set max_parallel_workers_per_gather = 0 ;
811
810
select * from v_pagg_test order by y;
812
811
812
+ -- Check that we don't fail on anonymous record types.
813
+ set max_parallel_workers_per_gather = 2 ;
814
+ explain (costs off)
815
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
816
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
817
+
813
818
-- Clean up
814
819
reset max_parallel_workers_per_gather;
815
820
reset bytea_output;
You can’t perform that action at this time.
0 commit comments