File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -2052,7 +2052,7 @@ resolve_aggregate_transtype(Oid aggfuncid,
2052
2052
2053
2053
/*
2054
2054
* agg_args_support_sendreceive
2055
- * Returns true if all non-byval of aggref's arg types have send and
2055
+ * Returns true if all non-byval types of aggref's args have send and
2056
2056
* receive functions.
2057
2057
*/
2058
2058
bool
@@ -2067,6 +2067,15 @@ agg_args_support_sendreceive(Aggref *aggref)
2067
2067
TargetEntry * tle = (TargetEntry * ) lfirst (lc );
2068
2068
Oid type = exprType ((Node * ) tle -> expr );
2069
2069
2070
+ /*
2071
+ * RECORD is a special case: it has typsend/typreceive functions, but
2072
+ * record_recv only works if passed the correct typmod to identify the
2073
+ * specific anonymous record type. array_agg_deserialize cannot do
2074
+ * that, so we have to disclaim support for the case.
2075
+ */
2076
+ if (type == RECORDOID )
2077
+ return false;
2078
+
2070
2079
typeTuple = SearchSysCache1 (TYPEOID , ObjectIdGetDatum (type ));
2071
2080
if (!HeapTupleIsValid (typeTuple ))
2072
2081
elog (ERROR , "cache lookup failed for type %u" , type );
Original file line number Diff line number Diff line change @@ -2151,8 +2151,8 @@ explain (costs off) select * from v_pagg_test order by y;
2151
2151
-> Parallel Seq Scan on pagg_test
2152
2152
(13 rows)
2153
2153
2154
- set max_parallel_workers_per_gather = 0;
2155
2154
-- Ensure results are the same without parallel aggregation.
2155
+ set max_parallel_workers_per_gather = 0;
2156
2156
select * from v_pagg_test order by y;
2157
2157
y | tmin | tmax | tndistinct | bmin | bmax | bndistinct | amin | amax | andistinct | aamin | aamax | aandistinct
2158
2158
---+------+------+------------+------+------+------------+------+------+------------+-------+-------+-------------
@@ -2168,6 +2168,24 @@ select * from v_pagg_test order by y;
2168
2168
9 | 19 | 4999 | 250 | 1019 | 999 | 250 | 19 | 4999 | 250 | 19 | 4999 | 250
2169
2169
(10 rows)
2170
2170
2171
+ -- Check that we don't fail on anonymous record types.
2172
+ set max_parallel_workers_per_gather = 2;
2173
+ explain (costs off)
2174
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
2175
+ QUERY PLAN
2176
+ --------------------------------------------
2177
+ Aggregate
2178
+ -> Gather
2179
+ Workers Planned: 2
2180
+ -> Parallel Seq Scan on pagg_test
2181
+ (4 rows)
2182
+
2183
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
2184
+ array_dims
2185
+ ------------
2186
+ [1:5000]
2187
+ (1 row)
2188
+
2171
2189
-- Clean up
2172
2190
reset max_parallel_workers_per_gather;
2173
2191
reset bytea_output;
Original file line number Diff line number Diff line change @@ -852,11 +852,16 @@ select * from v_pagg_test order by y;
852
852
-- Ensure parallel aggregation is actually being used.
853
853
explain (costs off) select * from v_pagg_test order by y;
854
854
855
- set max_parallel_workers_per_gather = 0 ;
856
-
857
855
-- Ensure results are the same without parallel aggregation.
856
+ set max_parallel_workers_per_gather = 0 ;
858
857
select * from v_pagg_test order by y;
859
858
859
+ -- Check that we don't fail on anonymous record types.
860
+ set max_parallel_workers_per_gather = 2 ;
861
+ explain (costs off)
862
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
863
+ select array_dims(array_agg(s)) from (select * from pagg_test) s;
864
+
860
865
-- Clean up
861
866
reset max_parallel_workers_per_gather;
862
867
reset bytea_output;
You can’t perform that action at this time.
0 commit comments