From: Date: August 22 2007 11:38pm Subject: bk commit into 5.1 tree (malff:1.2572) BUG#30333 List-Archive: http://lists.mysql.com/commits/32925 X-Bug: 30333 Message-Id: <20070822213840.091BF8E0E27@weblab.mysql.com> Below is the list of changes that have just been committed into a local 5.1 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-22 15:38:32-06:00, malff@weblab.(none) +3 -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. sql/sql_lex.cc@stripped, 2007-08-22 15:38:28-06:00, malff@weblab.(none) +0 -2 Removed unused attribute expr_list sql/sql_lex.h@stripped, 2007-08-22 15:38:28-06:00, malff@weblab.(none) +0 -1 Removed unused attribute expr_list sql/sql_yacc.yy@stripped, 2007-08-22 15:38:28-06:00, malff@weblab.(none) +41 -37 Improved performances when parsing expression lists diff -Nrup a/sql/sql_lex.cc b/sql/sql_lex.cc --- a/sql/sql_lex.cc 2007-08-16 09:52:52 -06:00 +++ b/sql/sql_lex.cc 2007-08-22 15:38:28 -06:00 @@ -323,7 +323,6 @@ void lex_start(THD *thd) lex->length=0; lex->part_info= 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= &lex->select_lex.ftfunc_list_alloc; lex->select_lex.group_list.empty(); @@ -1555,7 +1554,6 @@ void st_select_lex::init_select() options= 0; sql_cache= SQL_CACHE_UNSPECIFIED; braces= 0; - expr_list.empty(); interval_list.empty(); ftfunc_list_alloc.empty(); inner_sum_func_list= 0; diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h --- a/sql/sql_lex.h 2007-08-16 09:52:52 -06:00 +++ b/sql/sql_lex.h 2007-08-22 15:38:28 -06:00 @@ -596,7 +596,6 @@ public: const char *type; /* type of select for EXPLAIN */ SQL_LIST order_list; /* ORDER clause */ - List expr_list; SQL_LIST *gorder_list; Item *select_limit, *offset_limit; /* LIMIT clause parameters */ // Arrays of pointers to top elements of all_fields list diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy --- a/sql/sql_yacc.yy 2007-08-22 14:25:33 -06:00 +++ b/sql/sql_yacc.yy 2007-08-22 15:38:28 -06:00 @@ -1171,7 +1171,7 @@ bool my_yyoverflow(short **a, YYSTYPE ** NUM_literal %type - 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 @@ -1245,7 +1245,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 @@ -7253,7 +7253,7 @@ function_call_generic: $$= udf; #endif } - udf_expr_list ')' + opt_udf_expr_list ')' { THD *thd= YYTHD; Create_func *builder; @@ -7350,27 +7350,23 @@ opt_query_expansion: | WITH QUERY_SYM EXPANSION_SYM { $$= FT_EXPAND; } ; +opt_udf_expr_list: + /* empty */ { $$= NULL; } + | udf_expr_list { $$= $1; } + ; + udf_expr_list: - /* empty */ { $$= NULL; } - | udf_expr_list2 { $$= $1;} - ; - -udf_expr_list2: - { Select->expr_list.push_front(new List); } - udf_expr_list3 - { $$= Select->expr_list.pop(); } - ; - -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 + { + $$= new (YYTHD->mem_root) List; + $$->push_back($1); + } + | udf_expr_list ',' udf_expr + { + $1->push_back($3); + $$= $1; + } + ; udf_expr: remember_name expr remember_end select_alias @@ -7568,13 +7564,17 @@ opt_expr_list: ; expr_list: - { Select->expr_list.push_front(new List); } - 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; + $$->push_back($1); + } + | expr_list ',' expr + { + $1->push_back($3); + $$= $1; + } + ; ident_list_arg: ident_list { $$= $1; } @@ -7582,13 +7582,17 @@ ident_list_arg: ; ident_list: - { Select->expr_list.push_front(new List); } - 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; + $$->push_back($1); + } + | ident_list ',' simple_ident + { + $1->push_back($3); + $$= $1; + } + ; opt_expr: /* empty */ { $$= NULL; }