【SQL引擎 - parser.cpp分析】

SQL引擎 - parser.cpp分析

数据库的SQL引擎是数据库重要的子系统之一,它对上负责承接应用程序发送过来的SQL语句对下负责指挥执行器运行执行计划。其中优化器作为SQL引擎中最重要、最复杂的模块,被称为数据库的“大脑”,优化器产生的执行计划的优劣直接决定数据库的性能。

SQL引擎主要包括查询解析(parser)、查询分流(traffic cop)、查询优化(optimizer)、查询执行(executor)。parser源码目录为/src/common/backend/parser:
在这里插入图片描述
在这里插入图片描述

src/common/backend/parser/README

Parser
======
/*这个目录不仅仅是标记和解析 SQL 查询。它也是为传递的各种复杂查询创建查询结构到优化器,然后是执行器。*/
This directory does more than tokenize and parse SQL queries.  It also
creates Query structures for the various complex queries that are passed
to the optimizer and then executor.

/*事情从这里开始*/
parser.cpp	things start here
/*将查询分解为标记*/ 
scan.l		break query into tokens
/*处理输入字符串中的转义*/ 
scansup.cpp	handle escapes in input strings
/*将关键字转换为特定的标记*/
kwlookup.cpp	turn keywords into specific tokens
/*标准关键字表(传递给 kwlookup.c)*/
keywords.cpp	table of standard keywords (passed to kwlookup.c)
/*解析标记并生成“原始”解析树*/
gram.y		parse the tokens and produce a "raw" parse tree
/*可优化查询的顶级解析分析*/
analyze.cpp	top level of parse analysis for optimizable queries
/*处理聚合,如 SUM(col1)、AVG(col2)、...*/
parse_agg.cpp	handle aggregates, like SUM(col1),  AVG(col2), ...
/*处理 WHERE、ORDER BY、GROUP BY 等子句...*/
parse_clause.cpp	handle clauses like WHERE, ORDER BY, GROUP BY, ...
/*处理 A db 兼容语法和功能支持*/
parse_compatibility.cpp	Handle A db compatibal syntax and feature support
/*处理对不同数据类型的强制表达式*/
parse_coerce.cpp	handle coercing expressions to different data types
/*在完成的表达式中分配排序规则信息*/
parse_collate.cpp	assign collation information in completed expressions
/*处理公用表表达式(WITH 子句)*/
parse_cte.cpp	handle Common Table Expressions (WITH clauses)
/*处理 col、col + 3、x = 3 或 x = 4 等表达式*/
parse_expr.cpp	handle expressions like col, col + 3, x = 3 or x = 4
/*处理函数、table.column 和列标识符*/
parse_func.cpp	handle functions, table.column and column identifiers
/**/
parse_node.cpp	create nodes for various structures
/*为各种结构创建节点*/
parse_oper.cpp	handle operators in expressions
/*处理参数(用于核心后端的情况)*/
parse_param.cpp	handle Params (for the cases used in the core backend)
/*支持表和列处理的例程*/
parse_relation.cpp	support routines for tables and column handling
/*处理查询的结果列表*/
parse_target.cpp	handle the result list of the query
/*支持数据类型处理的例程*/
parse_type.cpp		support routines for data type handling
/*实用程序命令的解析分析(在执行时完成)*/
parse_utilcmd.cpp	parse analysis for utility commands (done at execution time)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值