mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#30333 (Performance, expressions lists in the parser)
Before this patch, the parser would execute: - Select->expr_list.push_front() - Select->expr_list.pop() when parsing expressions lists, in the following rules: - udf_expr_list - expr_list - ident_list This is unnecessary, and introduces overhead due to the memory allocations performed with Select->expr_list With this patch, this code has been removed. The list being parsed is maintained in the parser stack instead. Also, 'udf_expr_list' has been renamed 'opt_udf_expr_list', since this production can be empty. sql/sql_lex.cc: Removed unused attribute expr_list sql/sql_lex.h: Removed unused attribute expr_list sql/sql_yacc.yy: Improved performances when parsing expression lists
This commit is contained in:
@ -323,7 +323,6 @@ void lex_start(THD *thd)
|
|||||||
lex->length=0;
|
lex->length=0;
|
||||||
lex->part_info= 0;
|
lex->part_info= 0;
|
||||||
lex->select_lex.in_sum_expr=0;
|
lex->select_lex.in_sum_expr=0;
|
||||||
lex->select_lex.expr_list.empty();
|
|
||||||
lex->select_lex.ftfunc_list_alloc.empty();
|
lex->select_lex.ftfunc_list_alloc.empty();
|
||||||
lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
|
lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc;
|
||||||
lex->select_lex.group_list.empty();
|
lex->select_lex.group_list.empty();
|
||||||
@ -1555,7 +1554,6 @@ void st_select_lex::init_select()
|
|||||||
options= 0;
|
options= 0;
|
||||||
sql_cache= SQL_CACHE_UNSPECIFIED;
|
sql_cache= SQL_CACHE_UNSPECIFIED;
|
||||||
braces= 0;
|
braces= 0;
|
||||||
expr_list.empty();
|
|
||||||
interval_list.empty();
|
interval_list.empty();
|
||||||
ftfunc_list_alloc.empty();
|
ftfunc_list_alloc.empty();
|
||||||
inner_sum_func_list= 0;
|
inner_sum_func_list= 0;
|
||||||
|
@ -596,7 +596,6 @@ public:
|
|||||||
const char *type; /* type of select for EXPLAIN */
|
const char *type; /* type of select for EXPLAIN */
|
||||||
|
|
||||||
SQL_LIST order_list; /* ORDER clause */
|
SQL_LIST order_list; /* ORDER clause */
|
||||||
List<List_item> expr_list;
|
|
||||||
SQL_LIST *gorder_list;
|
SQL_LIST *gorder_list;
|
||||||
Item *select_limit, *offset_limit; /* LIMIT clause parameters */
|
Item *select_limit, *offset_limit; /* LIMIT clause parameters */
|
||||||
// Arrays of pointers to top elements of all_fields list
|
// Arrays of pointers to top elements of all_fields list
|
||||||
|
@ -1171,7 +1171,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||||||
NUM_literal
|
NUM_literal
|
||||||
|
|
||||||
%type <item_list>
|
%type <item_list>
|
||||||
expr_list udf_expr_list udf_expr_list2 when_list
|
expr_list opt_udf_expr_list udf_expr_list when_list
|
||||||
ident_list ident_list_arg opt_expr_list
|
ident_list ident_list_arg opt_expr_list
|
||||||
|
|
||||||
%type <var_type>
|
%type <var_type>
|
||||||
@ -1245,7 +1245,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
|||||||
select_item_list select_item values_list no_braces
|
select_item_list select_item values_list no_braces
|
||||||
opt_limit_clause delete_limit_clause fields opt_values values
|
opt_limit_clause delete_limit_clause fields opt_values values
|
||||||
procedure_list procedure_list2 procedure_item
|
procedure_list procedure_list2 procedure_item
|
||||||
expr_list2 udf_expr_list3 handler
|
handler
|
||||||
opt_precision opt_ignore opt_column opt_restrict
|
opt_precision opt_ignore opt_column opt_restrict
|
||||||
grant revoke set lock unlock string_list field_options field_option
|
grant revoke set lock unlock string_list field_options field_option
|
||||||
field_opt_list opt_binary table_lock_list table_lock
|
field_opt_list opt_binary table_lock_list table_lock
|
||||||
@ -7253,7 +7253,7 @@ function_call_generic:
|
|||||||
$<udf>$= udf;
|
$<udf>$= udf;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
udf_expr_list ')'
|
opt_udf_expr_list ')'
|
||||||
{
|
{
|
||||||
THD *thd= YYTHD;
|
THD *thd= YYTHD;
|
||||||
Create_func *builder;
|
Create_func *builder;
|
||||||
@ -7350,27 +7350,23 @@ opt_query_expansion:
|
|||||||
| WITH QUERY_SYM EXPANSION_SYM { $$= FT_EXPAND; }
|
| WITH QUERY_SYM EXPANSION_SYM { $$= FT_EXPAND; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_udf_expr_list:
|
||||||
|
/* empty */ { $$= NULL; }
|
||||||
|
| udf_expr_list { $$= $1; }
|
||||||
|
;
|
||||||
|
|
||||||
udf_expr_list:
|
udf_expr_list:
|
||||||
/* empty */ { $$= NULL; }
|
udf_expr
|
||||||
| udf_expr_list2 { $$= $1;}
|
{
|
||||||
;
|
$$= new (YYTHD->mem_root) List<Item>;
|
||||||
|
$$->push_back($1);
|
||||||
udf_expr_list2:
|
}
|
||||||
{ Select->expr_list.push_front(new List<Item>); }
|
| udf_expr_list ',' udf_expr
|
||||||
udf_expr_list3
|
{
|
||||||
{ $$= Select->expr_list.pop(); }
|
$1->push_back($3);
|
||||||
;
|
$$= $1;
|
||||||
|
}
|
||||||
udf_expr_list3:
|
;
|
||||||
udf_expr
|
|
||||||
{
|
|
||||||
Select->expr_list.head()->push_back($1);
|
|
||||||
}
|
|
||||||
| udf_expr_list3 ',' udf_expr
|
|
||||||
{
|
|
||||||
Select->expr_list.head()->push_back($3);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
udf_expr:
|
udf_expr:
|
||||||
remember_name expr remember_end select_alias
|
remember_name expr remember_end select_alias
|
||||||
@ -7568,13 +7564,17 @@ opt_expr_list:
|
|||||||
;
|
;
|
||||||
|
|
||||||
expr_list:
|
expr_list:
|
||||||
{ Select->expr_list.push_front(new List<Item>); }
|
expr
|
||||||
expr_list2
|
{
|
||||||
{ $$= Select->expr_list.pop(); };
|
$$= new (YYTHD->mem_root) List<Item>;
|
||||||
|
$$->push_back($1);
|
||||||
expr_list2:
|
}
|
||||||
expr { Select->expr_list.head()->push_back($1); }
|
| expr_list ',' expr
|
||||||
| expr_list2 ',' expr { Select->expr_list.head()->push_back($3); };
|
{
|
||||||
|
$1->push_back($3);
|
||||||
|
$$= $1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
ident_list_arg:
|
ident_list_arg:
|
||||||
ident_list { $$= $1; }
|
ident_list { $$= $1; }
|
||||||
@ -7582,13 +7582,17 @@ ident_list_arg:
|
|||||||
;
|
;
|
||||||
|
|
||||||
ident_list:
|
ident_list:
|
||||||
{ Select->expr_list.push_front(new List<Item>); }
|
simple_ident
|
||||||
ident_list2
|
{
|
||||||
{ $$= Select->expr_list.pop(); };
|
$$= new (YYTHD->mem_root) List<Item>;
|
||||||
|
$$->push_back($1);
|
||||||
ident_list2:
|
}
|
||||||
simple_ident { Select->expr_list.head()->push_back($1); }
|
| ident_list ',' simple_ident
|
||||||
| ident_list2 ',' simple_ident { Select->expr_list.head()->push_back($3); };
|
{
|
||||||
|
$1->push_back($3);
|
||||||
|
$$= $1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_expr:
|
opt_expr:
|
||||||
/* empty */ { $$= NULL; }
|
/* empty */ { $$= NULL; }
|
||||||
|
Reference in New Issue
Block a user