mysql源代码解析经典类——SELECT_LEX类

SQL查询块详解
本文介绍SQL中的查询块概念,包括其组成元素如SELECT关键字、表列表、WHERE子句等,并详细解释了SELECT_LEX类的功能及成员函数,帮助读者深入理解SQL查询的内部机制。

​ 此类表示查询块,又名查询规范,该查询块由SELECT关键字,表列表,可选的WHERE子句,GROUP BY等组成。

在#include <sql_lex.h>中。
此类表示查询块,又名查询规范,该查询块由SELECT关键字,表列表,可选的WHERE子句,GROUP BY等组成。

在#include <sql_lex.h>中。

公共函数

 	//构造并初始化SELECT_LEX对象
	SELECT_LEX (MEM_ROOT *mem_root, Item *where, Item *having)
Item * 	where_cond () const
Item ** 	where_cond_ref () 
void 	set_where_cond (Item *cond)
Item * 	having_cond () const
Item ** 	having_cond_ref ()
void 	set_having_cond (Item *cond)
void 	set_query_result (Query_result *result)
Query_result * 	query_result () const
//是否更改查询块的Query_result对象
bool 	change_query_result (THD *thd, Query_result_interceptor *new_result, Query_result_interceptor *old_result)
//设置查询块的基本选项(以及活动选项)
void 	set_base_options (ulonglong options_arg)
//将基本选项添加到查询块,还更新活动选项。
void 	add_base_options (ulonglong options)
//从查询块中删除基本选项。
void 	remove_base_options (ulonglong options)
//从基本选项,提供的选项和环境中选择激活选项:
void 	make_active_options (ulonglong added_options, ulonglong removed_options)
//调整激活选项集
void 	add_active_options (ulonglong options)
ulonglong 	active_options () const
//将关联的表设置为read_only
void 	set_tables_readonly ()
table_map 	all_tables_map () const
//删除我们之前作为transform_scalar_subqueries_to_join_with_derived的一部分添加的派生表
void 	remove_derived (THD *thd, TABLE_LIST *tl)
bool 	remove_aggregates (THD *thd, SELECT_LEX *select)
SELECT_LEX_UNIT * 	master_unit () const
SELECT_LEX_UNIT * 	first_inner_unit () const
SELECT_LEX * 	outer_select () const
SELECT_LEX * 	next_select () const
//在from子句中按名称查找(可能是未解析的)表引用 
TABLE_LIST * 	find_table_by_name (const Table_ident *ident)
bool 	is_straight_join ()
SELECT_LEX * 	last_select ()
SELECT_LEX * 	next_select_in_list () const
//将所有查询块从此标记为“最后”作为从属
void 	mark_as_dependent (SELECT_LEX *last, bool aggregate) 
bool 	is_explicitly_grouped () const
bool 	is_implicitly_grouped () const
//如果此查询块被隐式分组,则为true。
bool 	is_single_grouped () const
bool 	is_grouped () const
bool 	is_distinct () const
bool 	is_ordered () const
//根据解析时查询的结构,可以得出DISTINCT没用并将其删除的结论。
bool 	can_skip_distinct () const
bool 	has_limit () const 
bool 	has_ft_funcs () const
bool 	is_recursive () const
bool 	is_in_select_list (Item *i)
//查找与给定项目匹配的组表达式,如果没有,则返回nullptr。
ORDER * 	find_in_group_list (Item *item, int *rollup_level) const
int 	group_list_size () const
bool 	has_windows () const
//通过使指向其他SELECT_LEX_UNIT和SELECT_LEXes的指针无效来使之失效。
void 	invalidate ()
uint 	get_in_sum_expr () const
bool 	add_item_to_list (Item *item)
bool 	add_ftfunc_to_list (Item_func_match *func)
void 	add_order_to_list (ORDER *order)
//将表添加到已用表列表
TABLE_LIST * 	add_table_to_list (THD *thd, Table_ident *table, const char *alias, ulong table_options, thr_lock_type flags=TL_UNLOCK, enum_mdl_type mdl_type=MDL_SHARED_READ, List< Index_hint > *hints=nullptr, List< String > *partition_names=nullptr, LEX_STRING *option=nullptr, Parse_context *pc=nullptr)
//将项目添加到选择列表的隐藏部分
Item ** 	add_hidden_item (Item *item)
//从选择列表中删除隐藏的项目
void 	remove_hidden_items ()
TABLE_LIST * 	get_table_list () const
//初始化嵌套联接的新表列表
bool 	init_nested_join (THD *thd)
//结束嵌套的联接表列表。
TABLE_LIST * 	end_nested_join ()
//嵌套最后加入操作
TABLE_LIST * 	nest_last_join (THD *thd, size_t table_cnt=2)
//将表添加到当前联接列表
bool 	add_joined_table (TABLE_LIST *table)
mem_root_deque< Item * > * 	get_fields_list ()
//在字段/ get_fields_list()上包装,可在item-> hidden的地方隐藏项目,这意味着基于范围的for循环。
auto 	visible_fields ()
auto 	visible_fields () const
//是否检查特权以合并到查询块中的视图。
bool 	check_view_privileges (THD *thd, ulong want_privilege_first, ulong want_privilege_next)
//是否检查从查询块引用的所有列的特权
bool 	check_column_privileges (THD *thd)
//是否检查查询块的子查询中列引用的特权
bool 	check_privileges_for_subqueries (THD *thd)
//是否解决并准备有关一个查询块的表的信息
bool 	setup_tables (THD *thd, TABLE_LIST *tables, bool select_i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值