本节介绍ExecutePlan函数 相关数据结构 typedef enum ScanDirection { BackwardScanDirection = -1, NoMovementScanDirection = 0, Forwar
本节介绍ExecutePlan函数
typedef enum ScanDirection
{
BackwardScanDirection = -1,
NoMovementScanDirection = 0,
ForwardScanDirection = 1
} ScanDirection;
static void
ExecutePlan(EState *estate,
PlanState *planstate,
bool use_parallel_mode,
CmdType operation,
bool sendTuples,
uint64 numberTuples,
ScanDirection direction,
DestReceiver *dest,
bool execute_once);
执行查询计划,直到获取到numberTuples个元组,并且处理时朝direction方向移动。
//src/backend/executor/execMain.c
current_tuple_count = 0;
estate->es_direction = direction;
if (!execute_once)
use_parallel_mode = false;
estate->es_use_parallel_mode = use_parallel_mode;
if (use_parallel_mode)
EnterParallelMode();
for (;;)
{
ResetPerTupleExprContext(estate);
slot = ExecProcNode(planstate);
if (TupIsNull(slot))
{
if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
(void) ExecShutdownNode(planstate);
break;
}
if (estate->es_junkFilter != NULL)
slot = ExecFilterJunk(estate->es_junkFilter, slot);
if (sendTuples)
{
if (!dest->receiveSlot(slot, dest))
break;
}
if (operation == CMD_SELECT)
(estate->es_processed)++;
current_tuple_count++;
if (numberTuples && numberTuples == current_tuple_count)
{
if (!(estate->es_top_eflags & EXEC_FLAG_BACKWARD))
(void) ExecShutdownnode(planstate);
break;
}
}
if (use_parallel_mode)
ExitParallelMode();
--结束END--
本文标题: PostgreSQL源码学习--执行器#9
本文链接: https://www.lsjlt.com/news/6676.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0