@@ -1020,8 +1020,8 @@ Datum vops_count_accumulate(PG_FUNCTION_ARGS)
1020
1020
PG_FUNCTION_INFO_V1 (vops_count_accumulate_any );
1021
1021
Datum vops_count_accumulate_any (PG_FUNCTION_ARGS )
1022
1022
{
1023
- vops_tile_hdr * opd = PG_GETARG_VOPS_HDR (0 );
1024
- int64 count = PG_GETARG_INT64 (1 );
1023
+ int64 count = PG_GETARG_INT64 (0 );
1024
+ vops_tile_hdr * opd = PG_GETARG_VOPS_HDR (1 );
1025
1025
uint64 mask = filter_mask & ~opd -> empty_mask ;
1026
1026
int i ;
1027
1027
for (i = 0 ; i < TILE_SIZE ; i ++ ) {
@@ -2632,6 +2632,17 @@ typedef struct
2632
2632
} vops_mutator_context ;
2633
2633
2634
2634
2635
+ static Oid nodeType (Node * node )
2636
+ {
2637
+ switch (nodeTag (node ))
2638
+ {
2639
+ case T_TargetEntry :
2640
+ return exprType ((Node * )((TargetEntry * )node )-> expr );
2641
+ default :
2642
+ return exprType (node );
2643
+ }
2644
+ }
2645
+
2635
2646
static void replace_count (vops_mutator_context * ctx )
2636
2647
{
2637
2648
Aggref * count = ctx -> countall ;
@@ -2641,7 +2652,7 @@ static void replace_count(vops_mutator_context* ctx)
2641
2652
{
2642
2653
count -> aggfnoid = countany_oid ;
2643
2654
count -> aggstar = false;
2644
- count -> aggargtypes = list_make1_oid (exprType (ctx -> vector_col ));
2655
+ count -> aggargtypes = list_make1_oid (nodeType (ctx -> vector_col ));
2645
2656
count -> args = list_make1 (ctx -> vector_col );
2646
2657
}
2647
2658
else
@@ -2738,7 +2749,7 @@ vops_expression_tree_mutator(Node *node, void *context)
2738
2749
else if (IsA (node , NullTest ))
2739
2750
{
2740
2751
NullTest * test = (NullTest * )node ;
2741
- if (!test -> argisrow && is_vops_type (exprType ((Node * )test -> arg )))
2752
+ if (!test -> argisrow && is_vops_type (nodeType ((Node * )test -> arg )))
2742
2753
{
2743
2754
ctx -> has_vector_ops = true;
2744
2755
ctx -> vector_col = (Node * )test -> arg ;
@@ -2764,11 +2775,10 @@ vops_expression_tree_mutator(Node *node, void *context)
2764
2775
Aggref * agg = (Aggref * )node ;
2765
2776
if (agg -> aggfnoid == count_oid ) {
2766
2777
Assert (agg -> aggstar );
2778
+ ctx -> countall = agg ;
2767
2779
if (ctx -> has_vector_ops ) {
2768
- agg -> aggfnoid = countall_oid ;
2780
+ replace_count ( ctx ) ;
2769
2781
ctx -> countall = NULL ;
2770
- } else {
2771
- ctx -> countall = agg ;
2772
2782
}
2773
2783
} else if (!agg -> aggstar && !ctx -> has_vector_ops ) {
2774
2784
Assert (list_length (agg -> aggargtypes ) >= 1 );
0 commit comments