@@ -659,39 +659,54 @@ exec_append_common(CustomScanState *node,
659
659
void (* fetch_next_tuple ) (CustomScanState * node ))
660
660
{
661
661
RuntimeAppendState * scan_state = (RuntimeAppendState * ) node ;
662
+ TupleTableSlot * result ;
662
663
663
664
/* ReScan if no plans are selected */
664
665
if (scan_state -> ncur_plans == 0 )
665
666
ExecReScan (& node -> ss .ps );
666
667
668
+ #if PG_VERSION_NUM >= 100000
669
+ fetch_next_tuple (node ); /* use specific callback */
670
+
671
+ if (TupIsNull (scan_state -> slot ))
672
+ return NULL ;
673
+
674
+ if (!node -> ss .ps .ps_ProjInfo )
675
+ return scan_state -> slot ;
676
+
677
+ /*
678
+ * Assuming that current projection doesn't involve SRF
679
+ *
680
+ * Any SFR functions are evaluated in the specialized parent node ProjectSet
681
+ */
682
+ ResetExprContext (node -> ss .ps .ps_ExprContext );
683
+ node -> ss .ps .ps_ProjInfo -> pi_exprContext -> ecxt_scantuple =
684
+ scan_state -> slot ;
685
+ result = ExecProject (node -> ss .ps .ps_ProjInfo );
686
+
687
+ return result ;
688
+ #elif PG_VERSION_NUM >= 90500
667
689
for (;;)
668
690
{
669
691
/* Fetch next tuple if we're done with Projections */
670
- #if PG_VERSION_NUM < 100000
671
692
if (!node -> ss .ps .ps_TupFromTlist )
672
693
{
673
694
fetch_next_tuple (node ); /* use specific callback */
674
695
675
696
if (TupIsNull (scan_state -> slot ))
676
697
return NULL ;
677
698
}
678
- #endif
679
699
680
700
if (node -> ss .ps .ps_ProjInfo )
681
701
{
682
702
ExprDoneCond isDone ;
683
- TupleTableSlot * result ;
684
703
685
704
ResetExprContext (node -> ss .ps .ps_ExprContext );
686
705
687
- node -> ss .ps .ps_ProjInfo -> pi_exprContext -> ecxt_scantuple = scan_state -> slot ;
688
- #if PG_VERSION_NUM >= 100000
689
- result = ExecProject (node -> ss .ps .ps_ProjInfo );
690
- #else
706
+ node -> ss .ps .ps_ProjInfo -> pi_exprContext -> ecxt_scantuple =
707
+ scan_state -> slot ;
691
708
result = ExecProject (node -> ss .ps .ps_ProjInfo , & isDone );
692
- #endif
693
709
694
- #if PG_VERSION_NUM < 100000
695
710
if (isDone != ExprEndResult )
696
711
{
697
712
node -> ss .ps .ps_TupFromTlist = (isDone == ExprMultipleResult );
@@ -700,14 +715,11 @@ exec_append_common(CustomScanState *node,
700
715
}
701
716
else
702
717
node -> ss .ps .ps_TupFromTlist = false;
703
- #else
704
- if (isDone != ExprEndResult )
705
- return result ;
706
- #endif
707
718
}
708
719
else
709
720
return scan_state -> slot ;
710
721
}
722
+ #endif
711
723
}
712
724
713
725
void
0 commit comments