日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

PostgreSQL在何处处理 sql查询之四

發布時間:2025/3/19 数据库 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PostgreSQL在何处处理 sql查询之四 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

看看portal生成完畢后,干了什么(PortalDefineQuery):

1 /* 2 * Create unnamed portal to run the query or queries in. If there 3 * already is one, silently drop it. 4 */ 5 portal = CreatePortal("", true, true); 6 /* Don't display the portal in pg_cursors */ 7 portal->visible = false; 8 9 /* 10 * We don't have to copy anything into the portal, because everything 11 * we are passing here is in MessageContext, which will outlive the 12 * portal anyway. 13 */ 14 PortalDefineQuery(portal, 15 NULL, 16 query_string, 17 commandTag, 18 plantree_list, 19 NULL);

再來看PortalDefineQuery的定義:

1 /* 2 * PortalDefineQuery 3 * A simple subroutine to establish a portal's query. 4 * 5 * Notes: as of PG 8.4, caller MUST supply a sourceText string; it is not 6 * allowed anymore to pass NULL. (If you really don't have source text, 7 * you can pass a constant string, perhaps "(query not available)".) 8 * 9 * commandTag shall be NULL if and only if the original query string 10 * (before rewriting) was an empty string. Also, the passed commandTag must 11 * be a pointer to a constant string, since it is not copied. 12 * 13 * If cplan is provided, then it is a cached plan containing the stmts, and 14 * the caller must have done GetCachedPlan(), causing a refcount increment. 15 * The refcount will be released when the portal is destroyed. 16 * 17 * If cplan is NULL, then it is the caller's responsibility to ensure that 18 * the passed plan trees have adequate lifetime. Typically this is done by 19 * copying them into the portal's heap context. 20 * 21 * The caller is also responsible for ensuring that the passed prepStmtName 22 * (if not NULL) and sourceText have adequate lifetime. 23 * 24 * NB: this function mustn't do much beyond storing the passed values; in 25 * particular don't do anything that risks elog(ERROR). If that were to 26 * happen here before storing the cplan reference, we'd leak the plancache 27 * refcount that the caller is trying to hand off to us. 28 */ 29 void 30 PortalDefineQuery(Portal portal, 31 const char *prepStmtName, 32 const char *sourceText, 33 const char *commandTag, 34 List *stmts, 35 CachedPlan *cplan) 36 { 37 AssertArg(PortalIsValid(portal)); 38 AssertState(portal->status == PORTAL_NEW); 39 40 AssertArg(sourceText != NULL); 41 AssertArg(commandTag != NULL || stmts == NIL); 42 43 portal->prepStmtName = prepStmtName; 44 portal->sourceText = sourceText; 45 portal->commandTag = commandTag; 46 portal->stmts = stmts; 47 portal->cplan = cplan; 48 portal->status = PORTAL_DEFINED; 49 }

根據參數調用的情況:

*prepStmtName是NULL,sourceText是 query_string,commandTag傳遞了。
Lits *stmts 是 exec_simple_query中生成的?plantree_list,CachedPlan *cplan 是空值。

在我使用 select * from tab01 這種語句的時候,commandTag是 SELECT。







本文轉自健哥的數據花園博客園博客,原文鏈接:http://www.cnblogs.com/gaojian/archive/2013/05/22/3092323.html,如需轉載請自行聯系原作者

總結

以上是生活随笔為你收集整理的PostgreSQL在何处处理 sql查询之四的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。