PostgreSQL源码学习--调度器#13
短信预约 信息系统项目管理师 报名、考试、查分时间动态提醒
本节介绍PortalRunMulti函数。
PortalRunMulti函数
static void
PortalRunMulti(Portal portal,
bool isTopLevel, bool setHoldSnapshot,
DestReceiver *dest, DestReceiver *altdest,
char *completionTag);
//class="lazy" data-src/backend/tcop/pquery.c
if (dest->mydest == DestRemoteExecute)
dest = None_Receiver;
if (altdest->mydest == DestRemoteExecute)
altdest = None_Receiver;
foreach(stmtlist_item, portal->stmts)
{
PlannedStmt *pstmt = lfirst_node(PlannedStmt, stmtlist_item);
CHECK_FOR_INTERRUPTS();
if (pstmt->utilityStmt == NULL)
{
TRACE_POSTGRESQL_QUERY_EXECUTE_START();
if (log_executor_stats)
ResetUsage();
if (!active_snapshot_set)
{
Snapshot snapshot = GetTransactionSnapshot();
if (setHoldSnapshot)
{
snapshot = RegisterSnapshot(snapshot);
portal->holdSnapshot = snapshot;
}
PushCopiedSnapshot(snapshot);
active_snapshot_set = true;
}
UpdateActiveSnapshotCommandId();
if (pstmt->canSetTag)
{
ProcessQuery(pstmt,
portal->sourceText,
portal->portalParams,
portal->queryEnv,
dest, completionTag);
}
else
{
ProcessQuery(pstmt,
portal->sourceText,
portal->portalParams,
portal->queryEnv,
altdest, NULL);
}
if (log_executor_stats)
ShowUsage("EXECUTOR STATISTICS");
TRACE_POSTGRESQL_QUERY_EXECUTE_DONE();
}
else
{
if (pstmt->canSetTag)
{
Assert(!active_snapshot_set);
PortalRunUtility(portal, pstmt, isTopLevel, false,
dest, completionTag);
}
else
{
Assert(IsA(pstmt->utilityStmt, NotifyStmt));
PortalRunUtility(portal, pstmt, isTopLevel, false,
altdest, NULL);
}
}
if (lnext(stmtlist_item) != NULL)
CommandCounterIncrement();
Assert(portal->portalContext == CurrentMemoryContext);
MemoryContextDeleteChildren(portal->portalContext);
}
if (active_snapshot_set)
PopActiveSnapshot();
if (completionTag && completionTag[0] == "")
{
if (portal->commandTag)
strcpy(completionTag, portal->commandTag);
if (strcmp(completionTag, "SELECT") == 0)
sprintf(completionTag, "SELECT 0 0");
else if (strcmp(completionTag, "INSERT") == 0)
strcpy(completionTag, "INSERT 0 0");
else if (strcmp(completionTag, "UPDATE") == 0)
strcpy(completionTag, "UPDATE 0");
else if (strcmp(completionTag, "DELETE") == 0)
strcpy(completionTag, "DELETE 0");
}
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341