DROP命令(Commands)实现:
/* * Drop one or more objects. * * We don't currently handle all object types here. Relations,for example,* require special handling,because (for example) indexes have additional * locking requirements. * * We look up all the objects first,and then delete them in a single * performMultipleDeletions() call. This avoIDs unnecessary DROP RESTRICT * errors if there are dependencIEs between them. */voIDRemoveObjects(DropStmt *stmt)/* * dispatch function for DropStmt */static voIDExecDropStmt(DropStmt *stmt,bool istopLevel){ switch (stmt->removeType) { case OBJECT_INDEX: if (stmt->concurrent) PreventTransactionChain(istopLevel,"DROP INDEX CONCURRENTLY"); /* fall through */ case OBJECT_table: case OBJECT_SEQUENCE: case OBJECT_VIEW: case OBJECT_MATVIEW: case OBJECT_FOREIGN_table: RemoveRelations(stmt); break; default: RemoveObjects(stmt); break; }}/* * standard_ProcessUtility itself deals only with utility commands for * which we do not provIDe event trigger support. Commands that do have * such support are passed down to ProcessUtilitySlow,which contains the * necessary infrastructure for such triggers. * * This division is not just for performance: it's critical that the * event trigger code not be invoked when doing START TRANSACTION for * example,because we might need to refresh the event trigger cache,* which requires being in a valID transaction. */voIDstandard_ProcessUtility(Node *parsetree,const char *queryString,ProcessUtilityContext context,ParamListInfo params,DestReceiver *dest,char *completionTag)/* * ProcessUtility * general utility function invoker * * parsetree: the parse tree for the utility statement * queryString: original source text of command * context: IDentifIEs source of statement (toplevel clIEnt command,* non-toplevel clIEnt command,subcommand of a larger utility command) * params: parameters to use during execution * dest: where to send results * completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE * in which to store a command completion status string. * * Notes: as of PG 8.4,caller MUST supply a queryString; it is not * allowed anymore to pass NulL. (If you really don't have source text,* you can pass a constant string,perhaps "(query not available)".) * * completionTag is only set nonempty if we want to return a nondefault status. * * completionTag may be NulL if caller doesn't want a status string. */voIDProcessUtility(Node *parsetree,char *completionTag)
详细调用栈如下:
#0 ExecDropStmt (stmt=0x17e9b40,istopLevel=1 '1') at utility.c:1349#1 0x0000000000759457 in ProcessUtilitySlow (parsetree=0x17e9b40,queryString=0x17e90b0 "drop table t1;",context=PROCESS_UTIliTY_topLEVEL,params=0x0,dest=0x17e9ea0,completionTag=0x7fff06aee670 "") at utility.c:1296#2 0x0000000000758849 in standard_ProcessUtility (parsetree=0x17e9b40,completionTag=0x7fff06aee670 "") at utility.c:792#3 0x0000000000757c88 in ProcessUtility (parsetree=0x17e9b40,completionTag=0x7fff06aee670 "") at utility.c:310#4 0x0000000000756e92 in PortalRunUtility (portal=0x1822d70,utilityStmt=0x17e9b40,istopLevel=1 '1',completionTag=0x7fff06aee670 "") at pquery.c:1187#5 0x0000000000757048 in PortalRunMulti (portal=0x1822d70,altdest=0x17e9ea0,completionTag=0x7fff06aee670 "") at pquery.c:1318#6 0x000000000075661c in PortalRun (portal=0x1822d70,count=9223372036854775807,completionTag=0x7fff06aee670 "") at pquery.c:816#7 0x0000000000750944 in exec_simple_query (query_string=0x17e90b0 "drop table t1;") at postgres.c:1045#8 0x0000000000754967 in PostgresMain (argc=1,argv=0x1784148,dbname=0x1784130 "wzy",username=0x1784110 "xiaochu.yh") at postgres.c:4004#9 0x00000000006e80ba in BackendRun (port=0x17a3e00) at postmaster.c:4117#10 0x00000000006e77fd in BackendStartup (port=0x17a3e00) at postmaster.c:3791#11 0x00000000006e41b2 in ServerLoop () at postmaster.c:1570#12 0x00000000006e392e in PostmasterMain (argc=3,argv=0x1783380) at postmaster.c:1223#13 0x000000000064d3d3 in main (argc=3,argv=0x1783380) at main.c:225
Portal,入口的意思。Postgre中,Portal是个抽象概念,它表示一个正在运行或可运行query的执行状态。
对于可以生成执行计划的SQL语句(planable sql),都通过Processquery来处理;对于不能生成执行计划的SQL语句,取名为命令型sql(Command sql),都通过PortalRunUtility来处理。
参考:
1. gdb使用http://blog.chinaunix.net/uID-20788636-ID-1841301.HTML
2. postgre编译安装启动http://blog.chinaunix.net/uID-11161675-ID-2903295.HTML
3. postgre官方文档http://www.postgresql.org/docs/current/static/index.HTML
4. 如何做postgre源码分析http://blog.csdn.net/anzelin_ruc/article/details/8622770
总结以上是内存溢出为你收集整理的PostgreSQL 执行Drop Table等命令型SQL的总体流程全部内容,希望文章能够帮你解决PostgreSQL 执行Drop Table等命令型SQL的总体流程所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)