Below is the list of changes that have just been committed into a local
5.0 repository of marcsql. When marcsql does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-09 12:25:48-06:00, malff@weblab.(none) +1 -0
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.
Simplification of the grammar around these lists also reduced the
parser complexity:
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 43481 --> 43048 [-433]
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 570 --> 570 [0]
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 674 --> 668 [-6]
/* YYNRULES -- Number of rules. */
#define YYNRULES 2026 --> 2020 [-6]
/* YYNRULES -- Number of states. */
#define YYNSTATES 3672 --> 3666 [-6]
sql/sql_yacc.yy@stripped, 2007-08-09 12:25:46-06:00, malff@weblab.(none) +44 -40
Improved performances when parsing expression lists
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2007-08-03 10:59:12 -06:00
+++ b/sql/sql_yacc.yy 2007-08-09 12:25:46 -06:00
@@ -1080,7 +1080,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
NUM_literal
%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
%type <var_type>
@@ -1153,7 +1153,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
select_item_list select_item values_list no_braces
opt_limit_clause delete_limit_clause fields opt_values values
procedure_list procedure_list2 procedure_item
- expr_list2 udf_expr_list3 handler
+ handler
opt_precision opt_ignore opt_column opt_restrict
grant revoke set lock unlock string_list field_options field_option
field_opt_list opt_binary table_lock_list table_lock
@@ -5061,7 +5061,7 @@ simple_expr:
lex->current_select->udf_list.push_front(udf);
#endif
}
- udf_expr_list ')'
+ opt_udf_expr_list ')'
{
LEX *lex= Lex;
#ifdef HAVE_DLOPEN
@@ -5268,27 +5268,23 @@ fulltext_options:
| IN_SYM BOOLEAN_SYM MODE_SYM { $$= FT_BOOL; }
;
-udf_expr_list:
- /* empty */ { $$= NULL; }
- | udf_expr_list2 { $$= $1;}
- ;
-
-udf_expr_list2:
- { Select->expr_list.push_front(new List<Item>); }
- udf_expr_list3
- { $$= Select->expr_list.pop(); }
- ;
+opt_udf_expr_list:
+ /* empty */ { $$= NULL; }
+ | udf_expr_list { $$= $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_list:
+ udf_expr
+ {
+ $$= new (YYTHD->mem_root) List<Item>;
+ $$->push_back($1);
+ }
+ | udf_expr_list ',' udf_expr
+ {
+ $1->push_back($3);
+ $$= $1;
+ }
+ ;
udf_expr:
remember_name expr remember_end select_alias
@@ -5480,31 +5476,39 @@ cast_type:
;
opt_expr_list:
- /* empty */ { $$= NULL; }
- | expr_list { $$= $1;}
- ;
+ /* empty */ { $$= NULL; }
+ | expr_list { $$= $1;}
+ ;
expr_list:
- { Select->expr_list.push_front(new List<Item>); }
- expr_list2
- { $$= Select->expr_list.pop(); };
-
-expr_list2:
- expr { Select->expr_list.head()->push_back($1); }
- | expr_list2 ',' expr { Select->expr_list.head()->push_back($3); };
+ expr
+ {
+ $$= new (YYTHD->mem_root) List<Item>;
+ $$->push_back($1);
+ }
+ | expr_list ',' expr
+ {
+ $1->push_back($3);
+ $$= $1;
+ }
+ ;
ident_list_arg:
ident_list { $$= $1; }
| '(' ident_list ')' { $$= $2; };
ident_list:
- { Select->expr_list.push_front(new List<Item>); }
- ident_list2
- { $$= Select->expr_list.pop(); };
-
-ident_list2:
- simple_ident { Select->expr_list.head()->push_back($1); }
- | ident_list2 ',' simple_ident { Select->expr_list.head()->push_back($3); };
+ simple_ident
+ {
+ $$= new (YYTHD->mem_root) List<Item>;
+ $$->push_back($1);
+ }
+ | ident_list ',' simple_ident
+ {
+ $1->push_back($3);
+ $$= $1;
+ }
+ ;
opt_expr:
/* empty */ { $$= NULL; }