MySQL 8.0.39
Source Code Documentation
|
This class provide framework to build a Query_block using ParseTree nodes. More...
#include <show_query_builder.h>
Public Member Functions | |
Select_lex_builder (const POS *pc, THD *thd) | |
bool | add_star_select_item () |
Add item representing star in "SELECT '*' ...". More... | |
bool | add_select_item (const LEX_CSTRING &field_name, const LEX_CSTRING &alias) |
Add item representing a column as,. More... | |
bool | add_select_expr (Item *select_list_item, const LEX_CSTRING &alias) |
Add expression as an item tree, with an alias to name the resulting column. More... | |
bool | add_from_item (const LEX_CSTRING &schema_name, const LEX_CSTRING &table_name) |
Add item representing a FROM clause table as,. More... | |
bool | add_from_item (PT_derived_table *dt) |
Add item representing a FROM clause table as,. More... | |
Item * | prepare_like_item (const LEX_CSTRING &field_name, const String *wild) |
Prepare item representing a LIKE condition,. More... | |
Item * | prepare_equal_item (const LEX_CSTRING &field_name, const LEX_CSTRING &value) |
Prepare item representing a equal to comparison condition,. More... | |
bool | add_condition (Item *a) |
Add a WHERE clause condition to Select_lex_builder. More... | |
bool | add_order_by (const LEX_CSTRING &field_name) |
Add a ORDER BY clause field to Select_lex_builder. More... | |
PT_derived_table * | prepare_derived_table (const LEX_CSTRING &table_alias) |
This function build ParseTree node that represents this Select_lex_builder as sub-query. More... | |
Query_block * | prepare_query_block () |
Prepare a Query_block using all the information information added to this Select_lex_builder. More... | |
Private Member Functions | |
bool | add_to_select_item_list (Item *expr) |
Prepare a list of expression used to build select items for the query being built. More... | |
Private Attributes | |
const POS * | m_pos |
THD * | m_thd |
PT_select_item_list * | m_select_item_list |
Mem_root_array_YY< PT_table_reference * > | m_table_reference_list |
Item * | m_where_clause |
PT_order_list * | m_order_by_list |
This class provide framework to build a Query_block using ParseTree nodes.
Note that this class is designed to help build queries that are required to implement SHOW commands over data dictionary tables. It does not provide complete framework, e.g., you cannot add a GROUP BY node for now, mainly because that is not needed to implement SHOW command.
This class is used by implementation of SHOW command in sql/dd/show.cc. The class enables code re-usability.
One can build Query_block that represents following,
... SELECT star_select_item, select_item1, select_item2, ... FROM from_item OR FROM PT_derived_table WHERE condition AND condition AND ... ORDER BY order_by_field1, order_by_field2 , ... ...
Where as, a 'condition' can be one of, field_name = "value" field_name LIKE "value%"
One can think of enhancing this framework on need basis.
Note to server general team: This framework can be used by sql/sql_show_status.* implementation. For now, this file is kept inside sql/dd, but we can think of moving it out to sql/.
The memory used while building the this Parse Tree is thd->mem_root.
bool dd::info_schema::Select_lex_builder::add_condition | ( | Item * | a | ) |
Add a WHERE clause condition to Select_lex_builder.
If there are existing conditions, then the new condition is append to the WHERE clause conditions with a 'AND' condition.
bool dd::info_schema::Select_lex_builder::add_from_item | ( | const LEX_CSTRING & | schema_name, |
const LEX_CSTRING & | table_name | ||
) |
Add item representing a FROM clause table as,.
Only single table can be added. We cannot build a query with JOIN clause for now.
bool dd::info_schema::Select_lex_builder::add_from_item | ( | PT_derived_table * | dt | ) |
bool dd::info_schema::Select_lex_builder::add_order_by | ( | const LEX_CSTRING & | field_name | ) |
Add a ORDER BY clause field to Select_lex_builder.
If there are existing ORDER BY field, then we append a new field to the ORDER BY clause. All the fields are added to be order in ascending order.
bool dd::info_schema::Select_lex_builder::add_select_expr | ( | Item * | select_list_item, |
const LEX_CSTRING & | alias | ||
) |
Add expression as an item tree, with an alias to name the resulting column.
Add expression item representing a column as, "SELECT <expr> AS <alias>, ...".
The item will be appended to existing list of select items for this query block.
bool dd::info_schema::Select_lex_builder::add_select_item | ( | const LEX_CSTRING & | field_name, |
const LEX_CSTRING & | alias | ||
) |
Add item representing a column as,.
Add item representing a column as, "SELECT <field_name> AS <alias>, ...".
The item will be appended to existing list of select items for this query.
bool dd::info_schema::Select_lex_builder::add_star_select_item | ( | ) |
Add item representing star in "SELECT '*' ...".
|
private |
Prepare a list of expression used to build select items for the query being built.
PT_derived_table * dd::info_schema::Select_lex_builder::prepare_derived_table | ( | const LEX_CSTRING & | table_alias | ) |
This function build ParseTree node that represents this Select_lex_builder as sub-query.
This enables us to build a Query_block containing a sub-query in its FROM clause. This sub-query is represented by ParseTree node PT_derived_table.
Item * dd::info_schema::Select_lex_builder::prepare_equal_item | ( | const LEX_CSTRING & | field_name, |
const LEX_CSTRING & | value | ||
) |
Prepare item representing a equal to comparison condition,.
This item should be intern added to Select_lex_builder using add_condition() method.
Item * dd::info_schema::Select_lex_builder::prepare_like_item | ( | const LEX_CSTRING & | field_name, |
const String * | wild | ||
) |
Prepare item representing a LIKE condition,.
This item should be intern added to Select_lex_builder using add_condition() method.
Query_block * dd::info_schema::Select_lex_builder::prepare_query_block | ( | ) |
Prepare a Query_block using all the information information added to this Select_lex_builder.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |