@@ -521,64 +521,8 @@ get_rel_persistence(Oid relid)
521
521
#endif
522
522
523
523
524
-
525
- /*
526
- * -------------
527
- * Common code
528
- * -------------
529
- */
530
-
531
- void
532
- set_append_rel_size_compat (PlannerInfo * root , RelOptInfo * rel , Index rti )
533
- {
534
- double parent_rows = 0 ;
535
- double parent_size = 0 ;
536
- ListCell * l ;
537
-
538
- foreach (l , root -> append_rel_list )
539
- {
540
- AppendRelInfo * appinfo = (AppendRelInfo * ) lfirst (l );
541
- Index childRTindex ,
542
- parentRTindex = rti ;
543
- RelOptInfo * childrel ;
544
-
545
- /* append_rel_list contains all append rels; ignore others */
546
- if (appinfo -> parent_relid != parentRTindex )
547
- continue ;
548
-
549
- childRTindex = appinfo -> child_relid ;
550
-
551
- childrel = find_base_rel (root , childRTindex );
552
- Assert (childrel -> reloptkind == RELOPT_OTHER_MEMBER_REL );
553
-
554
- /*
555
- * Accumulate size information from each live child.
556
- */
557
- Assert (childrel -> rows > 0 );
558
-
559
- parent_rows += childrel -> rows ;
560
-
561
- #if PG_VERSION_NUM >= 90600
562
- parent_size += childrel -> reltarget -> width * childrel -> rows ;
563
- #else
564
- parent_size += childrel -> width * childrel -> rows ;
565
- #endif
566
- }
567
-
568
- /* Set 'rows' for append relation */
569
- rel -> rows = parent_rows ;
570
-
571
- #if PG_VERSION_NUM >= 90600
572
- rel -> reltarget -> width = rint (parent_size / parent_rows );
573
- #else
574
- rel -> width = rint (parent_size / parent_rows );
575
- #endif
576
-
577
- rel -> tuples = parent_rows ;
578
- }
579
-
580
- #if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM <= 90505 ) \
581
- || (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM <= 90601 )
524
+ #if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM <= 90505 ) || \
525
+ (PG_VERSION_NUM >= 90600 && PG_VERSION_NUM <= 90601 )
582
526
/*
583
527
* Return a palloc'd bare attribute map for tuple conversion, matching input
584
528
* and output columns by name. (Dropped columns are ignored in both input and
@@ -642,3 +586,60 @@ convert_tuples_by_name_map(TupleDesc indesc,
642
586
return attrMap ;
643
587
}
644
588
#endif
589
+
590
+
591
+
592
+ /*
593
+ * -------------
594
+ * Common code
595
+ * -------------
596
+ */
597
+
598
+ void
599
+ set_append_rel_size_compat (PlannerInfo * root , RelOptInfo * rel , Index rti )
600
+ {
601
+ double parent_rows = 0 ;
602
+ double parent_size = 0 ;
603
+ ListCell * l ;
604
+
605
+ foreach (l , root -> append_rel_list )
606
+ {
607
+ AppendRelInfo * appinfo = (AppendRelInfo * ) lfirst (l );
608
+ Index childRTindex ,
609
+ parentRTindex = rti ;
610
+ RelOptInfo * childrel ;
611
+
612
+ /* append_rel_list contains all append rels; ignore others */
613
+ if (appinfo -> parent_relid != parentRTindex )
614
+ continue ;
615
+
616
+ childRTindex = appinfo -> child_relid ;
617
+
618
+ childrel = find_base_rel (root , childRTindex );
619
+ Assert (childrel -> reloptkind == RELOPT_OTHER_MEMBER_REL );
620
+
621
+ /*
622
+ * Accumulate size information from each live child.
623
+ */
624
+ Assert (childrel -> rows > 0 );
625
+
626
+ parent_rows += childrel -> rows ;
627
+
628
+ #if PG_VERSION_NUM >= 90600
629
+ parent_size += childrel -> reltarget -> width * childrel -> rows ;
630
+ #else
631
+ parent_size += childrel -> width * childrel -> rows ;
632
+ #endif
633
+ }
634
+
635
+ /* Set 'rows' for append relation */
636
+ rel -> rows = parent_rows ;
637
+
638
+ #if PG_VERSION_NUM >= 90600
639
+ rel -> reltarget -> width = rint (parent_size / parent_rows );
640
+ #else
641
+ rel -> width = rint (parent_size / parent_rows );
642
+ #endif
643
+
644
+ rel -> tuples = parent_rows ;
645
+ }
0 commit comments