既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
在数据库中,除了DML之外的所有查询都通过ProcessUtility模块来执行,包括了各类DDL语句、事务相关语句、游标相关语句等。上层调用函数为exec_simple_query函数,其中PortalStart函数和PortalDrop函数部分较为简单。核心函数是PortalRun函数下层调用的standard_ProcessUtility函数,该函数通过switch case语句处理了各种类型的查询语句,包括事务相关查询、游标相关查询、schema相关操作、表空间相关操作、表定义相关操作等。
standard_ProcessUtility函数会根据nodeTag(parsetree)的值来确定sql的操作类型,create table一般都是进入T_CreateStmt分支,调用CreateCommand函数。
void standard\_ProcessUtility(Node\* parse_tree, const char\* query_string, ParamListInfo params, bool is_top_level,
DestReceiver\* dest,
#ifdef PGXC
bool sent_to_remote,
#endif /\* PGXC \*/
char\* completion_tag,
bool isCTAS)
{
……
errno_t errorno = EOK;
switch (nodeTag(parse_tree)) { // 根据nodeTag(parsetree)的值来确定sql的操作类型
……
case T_CreateStmt: { // create table
#ifdef PGXC
CreateCommand((CreateStmt\*)parse_tree, query_string, params, is_top_level, sent_to_remote, isCTAS);
#else
CreateCommand((CreateStmt\*)parse_tree, query_string, params, is_top_level, isCTAS);
#endif
} break;
……
CreateCommand函数先解析parse_tree获取stmt,如果stmt为空则表明表已经存在。如果stmt不为空对stmts进行遍历,如果是 CreateStmt就调用DefineRelation。AlterTableCreateToastTable判断是否需要创建toast表并创建,AlterCStoreCreateTables判断是否需要创建列存表并创建。
#ifdef PGXC
void CreateCommand(CreateStmt \*parse_tree, const char \*query_string, ParamListInfo params,
bool is_top_level, bool sent_to_remote, bool isCTAS)
#else
void CreateCommand(CreateStmt \*parse_tree, const char \*query_string, ParamListInfo params, bool is_top_level,
bool isCTAS)
#endif
{
……
/\* Run parse analysis ... \*/
if (u_sess->attr.attr_sql.enable_parallel_ddl) // 先解析parse\_tree获取stmt
stmts = transformCreateStmt((CreateStmt\*)parse_tree, query_string, NIL, true, &namespace_id, is_first_node);
else
stmts = transformCreateStmt((CreateStmt\*)parse_tree, query_string, NIL, false, &namespace_id);
/\*
\* If stmts is NULL, then the table is exists.
\* we need record that for searching the group of table.
\*/
if (stmts == NIL) { // 如果stmt为空则表明表已经存在
table_is_exist = true;
……
/\* ... and do it \*/
foreach (l, stmts) { // 遍历stmts
Node\* stmt = (Node\*)lfirst(l);
if (IsA(stmt, CreateStmt)) { // 如果是 CreateStmt就调用DefineRelation
Datum toast_options;
static const char\* const validnsps[] = HEAP_RELOPT_NAMESPACES;
/\* forbid user to set or change inner options \*/
ForbidOutUsersToSetInnerOptions(((CreateStmt\*)stmt)->options);
/\* Create the table itself \*/
rel_oid = DefineRelation((CreateStmt\*)stmt,
((CreateStmt\*)stmt)->relkind == RELKIND_MATVIEW ?
RELKIND_MATVIEW : RELKIND_RELATION,
InvalidOid, isCTAS);
……
AlterTableCreateToastTable(rel_oid, toast_options, AccessShareLock);
AlterCStoreCreateTables(rel_oid, toast_options, (CreateStmt\*)stmt);
![img](https://img-blog.csdnimg.cn/img_convert/6720a97f72807054aadb46b57507314d.png)
![img](https://img-blog.csdnimg.cn/img_convert/c2a32850af404ca174f4e83a1ed26310.png)
![img](https://img-blog.csdnimg.cn/img_convert/5b5d78fb39965cc8e0c368d082e831b4.png)
**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!**
**由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**
视频,并且后续会持续更新**
**[需要这份系统化资料的朋友,可以戳这里获取](https://bbs.csdn.net/forums/4f45ff00ff254613a03fab5e56a57acb)**