Skip to content

Commit 6d968d2

Browse files
committed
Make compat version of exec_append_common
1 parent 3fb2583 commit 6d968d2

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/nodes_common.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -659,39 +659,54 @@ exec_append_common(CustomScanState *node,
659659
void (*fetch_next_tuple) (CustomScanState *node))
660660
{
661661
RuntimeAppendState *scan_state = (RuntimeAppendState *) node;
662+
TupleTableSlot *result;
662663

663664
/* ReScan if no plans are selected */
664665
if (scan_state->ncur_plans == 0)
665666
ExecReScan(&node->ss.ps);
666667

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
667689
for (;;)
668690
{
669691
/* Fetch next tuple if we're done with Projections */
670-
#if PG_VERSION_NUM < 100000
671692
if (!node->ss.ps.ps_TupFromTlist)
672693
{
673694
fetch_next_tuple(node); /* use specific callback */
674695

675696
if (TupIsNull(scan_state->slot))
676697
return NULL;
677698
}
678-
#endif
679699

680700
if (node->ss.ps.ps_ProjInfo)
681701
{
682702
ExprDoneCond isDone;
683-
TupleTableSlot *result;
684703

685704
ResetExprContext(node->ss.ps.ps_ExprContext);
686705

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;
691708
result = ExecProject(node->ss.ps.ps_ProjInfo, &isDone);
692-
#endif
693709

694-
#if PG_VERSION_NUM < 100000
695710
if (isDone != ExprEndResult)
696711
{
697712
node->ss.ps.ps_TupFromTlist = (isDone == ExprMultipleResult);
@@ -700,14 +715,11 @@ exec_append_common(CustomScanState *node,
700715
}
701716
else
702717
node->ss.ps.ps_TupFromTlist = false;
703-
#else
704-
if (isDone != ExprEndResult)
705-
return result;
706-
#endif
707718
}
708719
else
709720
return scan_state->slot;
710721
}
722+
#endif
711723
}
712724

713725
void

0 commit comments

Comments
 (0)