@@ -612,6 +612,27 @@ end_append_common(CustomScanState *node)
612
612
hash_destroy (scan_state -> children_table );
613
613
}
614
614
615
+ /*
616
+ * This function is similar to ChangeVarNodes, but changes only
617
+ * varno attributes, but doesn't change varnoold attribute
618
+ */
619
+ static bool
620
+ change_only_varnos (Node * node , const int * idx )
621
+ {
622
+ if (node == NULL )
623
+ return false;
624
+
625
+ if (IsA (node , Var ))
626
+ {
627
+ Var * var = (Var * ) node ;
628
+ Assert (var -> varno == 1 );
629
+ var -> varno = * idx ;
630
+ return false;
631
+ }
632
+
633
+ return expression_tree_walker (node , change_only_varnos , (void * ) idx );
634
+ }
635
+
615
636
void
616
637
rescan_append_common (CustomScanState * node )
617
638
{
@@ -625,16 +646,14 @@ rescan_append_common(CustomScanState *node)
625
646
int nparts ;
626
647
Node * prel_expr ;
627
648
649
+ const int index_var = INDEX_VAR ;
650
+
628
651
prel = get_pathman_relation_info (scan_state -> relid );
629
652
Assert (prel );
630
653
631
654
/* Prepare expression */
632
- prel_expr = prel -> expr ;
633
- if (INDEX_VAR != 1 )
634
- {
635
- prel_expr = copyObject (prel_expr );
636
- ChangeVarNodes (prel_expr , 1 , INDEX_VAR , 0 );
637
- }
655
+ prel_expr = copyObject (prel -> expr );
656
+ change_only_varnos (prel_expr , & index_var );
638
657
639
658
/* First we select all available partitions... */
640
659
ranges = list_make1_irange (make_irange (0 , PrelLastChild (prel ), IR_COMPLETE ));
0 commit comments