PostgreSQL在何处处理 sql查询之六
生活随笔
收集整理的這篇文章主要介紹了
PostgreSQL在何处处理 sql查询之六
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前面說過 PortalStart明確執行策略后,要執行 ExecutorStart。
那么ExecutorStart 到底作了什么呢。以下是縮略:
/* ----------------------------------------------------------------* ExecutorStart** This routine must be called at the beginning of any execution of any* query plan** Takes a QueryDesc previously created by CreateQueryDesc (which is separate* only because some places use QueryDescs for utility commands). The tupDesc* field of the QueryDesc is filled in to describe the tuples that will be* returned, and the internal fields (estate and planstate) are set up.** eflags contains flag bits as described in executor.h.** NB: the CurrentMemoryContext when this is called will become the parent* of the per-query context used for this Executor invocation.** We provide a function hook variable that lets loadable plugins* get control when ExecutorStart is called. Such a plugin would* normally call standard_ExecutorStart().** ----------------------------------------------------------------*/ void ExecutorStart(QueryDesc *queryDesc, int eflags) {if (ExecutorStart_hook)(*ExecutorStart_hook) (queryDesc, eflags);elsestandard_ExecutorStart(queryDesc, eflags); }void standard_ExecutorStart(QueryDesc *queryDesc, int eflags) { .../** If non-read-only query, set the command ID to mark output tuples with*/switch (queryDesc->operation){...}/** Copy other important information into the EState*/estate->es_snapshot = RegisterSnapshot(queryDesc->snapshot);estate->es_crosscheck_snapshot = RegisterSnapshot(queryDesc->crosscheck_snapshot);estate->es_top_eflags = eflags;estate->es_instrument = queryDesc->instrument_options;/** Initialize the plan state tree*/InitPlan(queryDesc, eflags);/** Set up an AFTER-trigger statement context, unless told not to, or* unless it's EXPLAIN-only mode (when ExecutorFinish won't be called).*/if (!(eflags & (EXEC_FLAG_SKIP_TRIGGERS | EXEC_FLAG_EXPLAIN_ONLY)))AfterTriggerBeginQuery();MemoryContextSwitchTo(oldcontext); }核心一條就是,對 ?QueryDesc 型指針所指向的結構,進行了設置,以備后面的使用(ExecutorRun)。
上述代碼的注釋中已經說明:使用了CreateQueryDesc時產生的 QueryDesc,設置其tupDesc。
總結
以上是生活随笔為你收集整理的PostgreSQL在何处处理 sql查询之六的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 遍历输入图的遍历
- 下一篇: 新装ubuntu10.04后的一些设置