返回顶部
首页 > 资讯 > 数据库 >PostgreSQL源码学习--执行器#10,11
  • 643
分享到

PostgreSQL源码学习--执行器#10,11

PostgreSQL源码学习--执行器#10,11 2021-08-04 09:08:15 643人浏览 无得
摘要

本节介绍standard_ExecutorRun和ExecutorRun函数。 standard_ExecutorRun函数 //src/include/execurot/executor.h extern void standard_E

PostgreSQL源码学习--执行器#10,11

本节介绍standard_ExecutorRun和ExecutorRun函数。

standard_ExecutorRun函数

//src/include/execurot/executor.h

extern void standard_ExecutorRun(QueryDesc *queryDesc,
			 ScanDirection direction, uint64 count, bool execute_once);

//src/backend/executor/execMain.c

Assert(queryDesc != NULL);

estate = queryDesc->estate;

Assert(estate != NULL);
Assert(!(estate->es_top_eflags & EXEC_FLAG_EXPLAIN_ONLY));


oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);


if (queryDesc->totaltime)
	InstrStartNode(queryDesc->totaltime);

operation = queryDesc->operation;
dest = queryDesc->dest;


estate->es_processed = 0;

sendTuples = (operation == CMD_SELECT ||
		  queryDesc->plannedstmt->hasReturning);

if (sendTuples)
	dest->rStartup(dest, operation, queryDesc->tupDesc);


if (!ScanDirectionIsNoMovement(direction))
{
	if (execute_once && queryDesc->already_executed)
		elog(ERROR, "can"t re-execute query flagged for single execution");
	queryDesc->already_executed = true;

	ExecutePlan(estate,
		queryDesc->planstate,
		queryDesc->plannedstmt->parallelModeNeeded,
		operation,
		sendTuples,
		count,
		direction,
		dest,
		execute_once);
}


if (sendTuples)
	dest->rShutdown(dest);


if (queryDesc->totaltime)
	InstrStopNode(queryDesc->totaltime, estate->es_processed);


MemoryContextSwitchTo(oldcontext);

ExecutorRun函数

void
ExecutorRun(QueryDesc *queryDesc,
			ScanDirection direction, uint64 count,
			bool execute_once)
{
	if (ExecutorRun_hook)
		(*ExecutorRun_hook) (queryDesc, direction, count, execute_once);
	else
		standard_ExecutorRun(queryDesc, direction, count, execute_once);
}

您可能感兴趣的文档:

--结束END--

本文标题: PostgreSQL源码学习--执行器#10,11

本文链接: https://lsjlt.com/news/6679.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作