diff options
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 1615 |
1 files changed, 1045 insertions, 570 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 74a21c9f6b6..47bd3994fd3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1,5 +1,6 @@ /* - Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2014, Oracle and/or its affiliates. + Copyright (c) 2010, 2014, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,16 +23,14 @@ */ %{ -/* -Note: YYTHD is passed as an argument to yyparse(), and subsequently to yylex(). -*/ -#define YYLIP (& YYTHD->m_parser_state->m_lip) -#define YYPS (& YYTHD->m_parser_state->m_yacc) +#define YYLIP (& thd->m_parser_state->m_lip) +#define YYPS (& thd->m_parser_state->m_yacc) #define MYSQL_YACC #define YYINITDEPTH 100 #define YYMAXDEPTH 3200 /* Because of 64K stack */ -#define Lex (YYTHD->lex) +#define Lex (thd->lex) + #define Select Lex->current_select #include "sql_priv.h" #include "unireg.h" // REQUIRED: for other includes @@ -54,6 +53,7 @@ Note: YYTHD is passed as an argument to yyparse(), and subsequently to yylex(). #include "sql_partition_admin.h" // Alter_table_*_partition_stmt #include "sql_signal.h" #include "event_parse_data.h" +#include "create_options.h" #include <myisam.h> #include <myisammrg.h> #include "keycaches.h" @@ -72,7 +72,7 @@ int yylex(void *yylval, void *yythd); ulong val= *(F); \ if (my_yyoverflow((B), (D), &val)) \ { \ - yyerror(YYTHD, (char*) (A)); \ + yyerror(thd, (char*) (A)); \ return 2; \ } \ else \ @@ -84,7 +84,7 @@ int yylex(void *yylval, void *yythd); #define MYSQL_YYABORT \ do \ { \ - LEX::cleanup_lex_after_parse_error(YYTHD);\ + LEX::cleanup_lex_after_parse_error(thd); \ YYABORT; \ } while (0) @@ -145,7 +145,7 @@ void my_parse_error(const char *s) yytext= ""; /* Push an error into the error stack */ - ErrConvString err(yytext, thd->variables.character_set_client); + ErrConvString err(yytext, strlen(yytext), thd->variables.character_set_client); my_printf_error(ER_PARSE_ERROR, ER(ER_PARSE_ERROR), MYF(0), s, err.ptr(), lip->yylineno); } @@ -196,9 +196,9 @@ void turn_parser_debug_on() The syntax to run with bison traces is as follows : - Starting a server manually : - mysqld --debug="d,parser_debug" ... + mysqld --debug-dbug="d,parser_debug" ... - Running a test : - mysql-test-run.pl --mysqld="--debug=d,parser_debug" ... + mysql-test-run.pl --mysqld="--debug-dbug=d,parser_debug" ... The result will be in the process stderr (var/log/master.err) */ @@ -709,6 +709,7 @@ static bool add_create_index_prepare (LEX *lex, Table_ident *table) lex->alter_info.flags= ALTER_ADD_INDEX; lex->col_list.empty(); lex->change= NullS; + lex->option_list= NULL; return FALSE; } @@ -718,7 +719,7 @@ static bool add_create_index (LEX *lex, Key::Keytype type, { Key *key; key= new Key(type, name, info ? info : &lex->key_create_info, generated, - lex->col_list); + lex->col_list, lex->option_list); if (key == NULL) return TRUE; @@ -757,6 +758,7 @@ static bool add_create_index (LEX *lex, Key::Keytype type, enum enum_tx_isolation tx_isolation; enum Cast_target cast_type; enum Item_udftype udf_type; + enum ha_choice choice; CHARSET_INFO *charset; thr_lock_type lock_type; interval_type interval, interval_time_st; @@ -774,6 +776,8 @@ static bool add_create_index (LEX *lex, Key::Keytype type, enum Foreign_key::fk_option m_fk_option; enum enum_yes_no_unknown m_yes_no_unk; Diag_condition_item_name diag_condition_item_name; + DYNCALL_CREATE_DEF *dyncol_def; + List<DYNCALL_CREATE_DEF> *dyncol_def_list; bool is_not_empty; } @@ -781,14 +785,14 @@ static bool add_create_index (LEX *lex, Key::Keytype type, bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %} -%parse-param { class THD *YYTHD } -%lex-param { class THD *YYTHD } -%pure-parser /* We have threads */ +%pure_parser /* We have threads */ +%parse-param { THD *thd } +%lex-param { THD *thd } /* - Currently there are 168 shift/reduce conflicts. + Currently there are 175 shift/reduce conflicts. We should not introduce new conflicts any more. */ -%expect 168 +%expect 175 /* Comments for TOKENS. @@ -818,6 +822,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ALGORITHM_SYM %token ALL /* SQL-2003-R */ %token ALTER /* SQL-2003-R */ +%token ALWAYS_SYM %token ANALYZE_SYM %token AND_AND_SYM /* OPERATOR */ %token AND_SYM /* SQL-2003-R */ @@ -864,17 +869,25 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token CHANGED %token CHARSET %token CHAR_SYM /* SQL-2003-R */ +%token CHECKPOINT_SYM %token CHECKSUM_SYM %token CHECK_SYM /* SQL-2003-R */ %token CIPHER_SYM %token CLASS_ORIGIN_SYM /* SQL-2003-N */ %token CLIENT_SYM +%token CLIENT_STATS_SYM %token CLOSE_SYM /* SQL-2003-R */ %token COALESCE /* SQL-2003-N */ %token CODE_SYM %token COLLATE_SYM /* SQL-2003-R */ %token COLLATION_SYM /* SQL-2003-N */ %token COLUMNS +%token COLUMN_ADD_SYM +%token COLUMN_CREATE_SYM +%token COLUMN_DELETE_SYM +%token COLUMN_EXISTS_SYM +%token COLUMN_GET_SYM +%token COLUMN_LIST_SYM %token COLUMN_SYM /* SQL-2003-R */ %token COLUMN_NAME_SYM /* SQL-2003-N */ %token COMMENT_SYM @@ -965,6 +978,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token EVENTS_SYM %token EVENT_SYM %token EVERY_SYM /* SQL-2003-N */ +%token EXAMINED_SYM %token EXECUTE_SYM /* SQL-2003-R */ %token EXISTS /* SQL-2003-R */ %token EXIT_SYM @@ -992,6 +1006,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token FUNCTION_SYM /* SQL-2003-R */ %token GE %token GENERAL +%token GENERATED_SYM %token GEOMETRYCOLLECTION %token GEOMETRY_SYM %token GET_FORMAT /* MYSQL-FUNC */ @@ -1002,10 +1017,12 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token GROUP_CONCAT_SYM %token GT_SYM /* OPERATOR */ %token HANDLER_SYM +%token HARD_SYM %token HASH_SYM %token HAVING /* SQL-2003-R */ %token HELP_SYM %token HEX_NUM +%token HEX_STRING %token HIGH_PRIORITY %token HOST_SYM %token HOSTS_SYM @@ -1022,6 +1039,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token IMPORT %token INDEXES %token INDEX_SYM +%token INDEX_STATS_SYM %token INFILE %token INITIAL_SIZE_SYM %token INNER_SYM /* SQL-2003-R */ @@ -1048,6 +1066,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token KILL_SYM %token LANGUAGE_SYM /* SQL-2003-R */ %token LAST_SYM /* SQL-2003-N */ +%token LAST_VALUE %token LE /* OPERATOR */ %token LEADING /* SQL-2003-R */ %token LEAVES @@ -1154,6 +1173,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ON /* SQL-2003-R */ %token ONE_SHOT_SYM %token ONE_SYM +%token ONLINE_SYM %token OPEN_SYM /* SQL-2003-R */ %token OPTIMIZE %token OPTIONS_SYM @@ -1169,13 +1189,16 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token OWNER_SYM %token PACK_KEYS_SYM %token PAGE_SYM +%token PAGE_CHECKSUM_SYM %token PARAM_MARKER %token PARSER_SYM +%token PARSE_VCOL_EXPR_SYM %token PARTIAL /* SQL-2003-N */ %token PARTITIONING_SYM %token PARTITIONS_SYM %token PARTITION_SYM /* SQL-2003-R */ %token PASSWORD +%token PERSISTENT_SYM %token PHASE_SYM %token PLUGINS_SYM %token PLUGIN_SYM @@ -1274,6 +1297,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token SMALLINT /* SQL-2003-R */ %token SNAPSHOT_SYM %token SOCKET_SYM +%token SOFT_SYM %token SONAME_SYM %token SOUNDS_SYM %token SOURCE_SYM @@ -1316,6 +1340,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TABLES %token TABLESPACE %token TABLE_REF_PRIORITY +%token TABLE_STATS_SYM %token TABLE_SYM /* SQL-2003-R */ %token TABLE_CHECKSUM_SYM %token TABLE_NAME_SYM /* SQL-2003-N */ @@ -1336,6 +1361,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token TO_SYM /* SQL-2003-R */ %token TRAILING /* SQL-2003-R */ %token TRANSACTION_SYM +%token TRANSACTIONAL_SYM %token TRIGGERS_SYM %token TRIGGER_SYM /* SQL-2003-R */ %token TRIM /* SQL-2003-N */ @@ -1363,6 +1389,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token UPGRADE_SYM %token USAGE /* SQL-2003-N */ %token USER /* SQL-2003-R */ +%token USER_STATS_SYM %token USE_FRM %token USE_SYM %token USING /* SQL-2003-R */ @@ -1377,7 +1404,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token VARIANCE_SYM %token VARYING /* SQL-2003-R */ %token VAR_SAMP_SYM +%token VIA_SYM %token VIEW_SYM /* SQL-2003-N */ +%token VIRTUAL_SYM %token WAIT_SYM %token WARNINGS %token WEEK_SYM @@ -1398,6 +1427,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token YEAR_SYM /* SQL-2003-R */ %token ZEROFILL +%token IMPOSSIBLE_ACTION /* To avoid warning for yyerrlab1 */ + %left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT /* A dummy token to force the priority of table_ref production in a join. */ %left TABLE_REF_PRIORITY @@ -1419,7 +1450,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %left INTERVAL_SYM %type <lex_str> - IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM + IDENT IDENT_QUOTED TEXT_STRING DECIMAL_NUM FLOAT_NUM NUM LONG_NUM + HEX_NUM HEX_STRING hex_num_or_string LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text IDENT_sys TEXT_STRING_sys TEXT_STRING_literal NCHAR_STRING opt_component key_cache_name @@ -1445,11 +1477,13 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); table_option opt_if_not_exists opt_no_write_to_binlog opt_temporary all_or_any opt_distinct opt_ignore_leaves fulltext_options spatial_type union_option - start_transaction_opts + start_transaction_opts field_def union_opt select_derived_init option_type2 opt_natural_language_mode opt_query_expansion opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt + optional_flush_tables_arguments opt_dyncol_type dyncol_type + opt_time_precision kill_type kill_option int_num %type <m_yes_no_unk> opt_chain opt_release @@ -1463,6 +1497,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %type <ulonglong_number> ulonglong_num real_ulonglong_num size_number +%type <choice> choice + %type <lock_type> replace_lock_option opt_low_priority insert_lock_option load_data_lock @@ -1482,7 +1518,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); function_call_keyword function_call_nonkeyword function_call_generic - function_call_conflict + function_call_conflict kill_expr signal_allowed_expr %type <item_num> @@ -1551,6 +1587,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %type <boolfunc2creator> comp_op +%type <dyncol_def> dyncall_create_element + +%type <dyncol_def_list> dyncall_create_list + %type <NONE> query verb_clause create change select do drop insert replace insert2 insert_values update delete truncate rename @@ -1601,10 +1641,13 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); init_key_options normal_key_options normal_key_opts all_key_opt spatial_key_options fulltext_key_options normal_key_opt fulltext_key_opt spatial_key_opt fulltext_key_opts spatial_key_opts + keep_gcc_happy key_using_alg part_column_list server_def server_options_list server_option definer_opt no_definer definer + parse_vcol_expr vcol_opt_specifier vcol_opt_attribute + vcol_opt_attribute_list vcol_attribute END_OF_INPUT %type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt @@ -1662,7 +1705,6 @@ rule: <-- starts at col 1 query: END_OF_INPUT { - THD *thd= YYTHD; if (!thd->bootstrap && (!(thd->lex->select_lex.options & OPTION_FOUND_COMMENT))) { @@ -1676,7 +1718,7 @@ query: { Lex_input_stream *lip = YYLIP; - if ((YYTHD->client_capabilities & CLIENT_MULTI_QUERIES) && + if ((thd->client_capabilities & CLIENT_MULTI_QUERIES) && lip->multi_statements && ! lip->eof()) { @@ -1737,11 +1779,13 @@ statement: | help | insert | install + | keep_gcc_happy + | keycache | kill | load | lock | optimize - | keycache + | parse_vcol_expr | partition_entry | preload | prepare @@ -1772,7 +1816,6 @@ statement: deallocate: deallocate_or_drop PREPARE_SYM ident { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_DEALLOCATE_PREPARE; lex->prepared_stmt_name= $3; @@ -1787,7 +1830,6 @@ deallocate_or_drop: prepare: PREPARE_SYM ident FROM prepare_src { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_PREPARE; lex->prepared_stmt_name= $2; @@ -1797,14 +1839,12 @@ prepare: prepare_src: TEXT_STRING_sys { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->prepared_stmt_code= $1; lex->prepared_stmt_code_is_varref= FALSE; } | '@' ident_or_text { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->prepared_stmt_code= $2; lex->prepared_stmt_code_is_varref= TRUE; @@ -1814,7 +1854,6 @@ prepare_src: execute: EXECUTE_SYM ident { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_EXECUTE; lex->prepared_stmt_name= $2; @@ -1867,12 +1906,7 @@ help: change: CHANGE MASTER_SYM TO_SYM { - LEX *lex = Lex; - lex->sql_command = SQLCOM_CHANGE_MASTER; - bzero((char*) &lex->mi, sizeof(lex->mi)); - lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_UNCHANGED; - - DBUG_ASSERT(Lex->mi.repl_ignore_server_ids.elements == 0); + Lex->sql_command = SQLCOM_CHANGE_MASTER; } master_defs {} @@ -1949,7 +1983,7 @@ master_def: } if (Lex->mi.heartbeat_period > slave_net_timeout) { - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX, ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MAX)); } @@ -1957,7 +1991,7 @@ master_def: { if (Lex->mi.heartbeat_period != 0.0) { - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN, ER(ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE_MIN)); Lex->mi.heartbeat_period= 0.0; @@ -1983,14 +2017,6 @@ ignore_server_id_list: ignore_server_id: ulong_num { - if (Lex->mi.repl_ignore_server_ids.elements == 0) - { - my_init_dynamic_array2(&Lex->mi.repl_ignore_server_ids, - sizeof(::server_id), - Lex->mi.server_ids_buffer, - array_elements(Lex->mi.server_ids_buffer), - 16); - } insert_dynamic(&Lex->mi.repl_ignore_server_ids, (uchar*) &($1)); } @@ -2032,7 +2058,6 @@ master_file_def: create: CREATE opt_table_options TABLE_SYM opt_if_not_exists table_ident { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_CREATE_TABLE; if (!lex->select_lex.add_table_to_list(thd, $5, NULL, @@ -2057,16 +2082,16 @@ create: } create2 { - LEX *lex= YYTHD->lex; + LEX *lex= thd->lex; lex->current_select= &lex->select_lex; if ((lex->create_info.used_fields & HA_CREATE_USED_ENGINE) && !lex->create_info.db_type) { - lex->create_info.db_type= ha_default_handlerton(YYTHD); - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + lex->create_info.db_type= ha_default_handlerton(thd); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_USING_OTHER_HANDLER, ER(ER_WARN_USING_OTHER_HANDLER), - ha_resolve_storage_engine_name(lex->create_info.db_type), + hton_name(lex->create_info.db_type)->str, $5->table.str); } create_table_set_open_action_and_adjust_tables(lex); @@ -2118,7 +2143,7 @@ create: | CREATE { Lex->create_view_mode= VIEW_CREATE_NEW; - Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; + Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; Lex->create_view_suid= TRUE; } view_or_trigger_or_sp_or_event @@ -2193,7 +2218,6 @@ server_option: event_tail: remember_name EVENT_SYM opt_if_not_exists sp_name { - THD *thd= YYTHD; LEX *lex=Lex; lex->stmt_definition_begin= $1; @@ -2260,7 +2284,7 @@ opt_ev_status: ev_starts: /* empty */ { - Item *item= new (YYTHD->mem_root) Item_func_now_local(); + Item *item= new (thd->mem_root) Item_func_now_local(0); if (item == NULL) MYSQL_YYABORT; Lex->event_parse_data->item_starts= item; @@ -2310,7 +2334,6 @@ opt_ev_comment: ev_sql_stmt: { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -2353,7 +2376,6 @@ ev_sql_stmt: } ev_sql_stmt_inner { - THD *thd= YYTHD; LEX *lex= thd->lex; /* return back to the original memory root ASAP */ @@ -2412,11 +2434,10 @@ sp_name: $$= new sp_name($1, $3, true); if ($$ == NULL) MYSQL_YYABORT; - $$->init_qname(YYTHD); + $$->init_qname(thd); } | ident { - THD *thd= YYTHD; LEX *lex= thd->lex; LEX_STRING db; if (check_routine_name(&$1)) @@ -2486,7 +2507,7 @@ call: lex->sql_command= SQLCOM_CALL; lex->spname= $2; lex->value_list.empty(); - sp_add_used_routine(lex, YYTHD, $2, TYPE_ENUM_PROCEDURE); + sp_add_used_routine(lex, thd, $2, TYPE_ENUM_PROCEDURE); } opt_sp_cparam_list {} ; @@ -2541,6 +2562,7 @@ sp_init_param: lex->interval_list.empty(); lex->uint_geom_type= 0; + lex->vcol_info= 0; } ; @@ -2559,7 +2581,7 @@ sp_fdparam: (enum enum_field_types)$3, sp_param_in); - if (lex->sphead->fill_field_definition(YYTHD, lex, + if (lex->sphead->fill_field_definition(thd, lex, (enum enum_field_types) $3, &spvar->field_def)) { @@ -2596,7 +2618,7 @@ sp_pdparam: (enum enum_field_types)$4, (sp_param_mode_t)$1); - if (lex->sphead->fill_field_definition(YYTHD, lex, + if (lex->sphead->fill_field_definition(thd, lex, (enum enum_field_types) $4, &spvar->field_def)) { @@ -2659,13 +2681,12 @@ sp_decl: { LEX *lex= Lex; - lex->sphead->reset_lex(YYTHD); + lex->sphead->reset_lex(thd); lex->spcont->declare_var_boundary($2); } type_with_opt_collate sp_opt_default { - THD *thd= YYTHD; LEX *lex= Lex; sp_pcontext *pctx= lex->spcont; uint num_vars= pctx->context_var_count(); @@ -2691,7 +2712,7 @@ sp_decl: spvar->type= var_type; spvar->dflt= dflt_value_item; - if (lex->sphead->fill_field_definition(YYTHD, lex, var_type, + if (lex->sphead->fill_field_definition(thd, lex, var_type, &spvar->field_def)) { MYSQL_YYABORT; @@ -2715,7 +2736,7 @@ sp_decl: } pctx->declare_var_boundary(0); - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; $$.vars= $2; $$.conds= $$.hndlrs= $$.curs= 0; @@ -2730,7 +2751,7 @@ sp_decl: my_error(ER_SP_DUP_COND, MYF(0), $2.str); MYSQL_YYABORT; } - if(YYTHD->lex->spcont->push_cond(&$2, $5)) + if(thd->lex->spcont->push_cond(&$2, $5)) MYSQL_YYABORT; $$.vars= $$.hndlrs= $$.curs= 0; $$.conds= 1; @@ -2816,7 +2837,7 @@ sp_decl: sp_cursor_stmt: { - Lex->sphead->reset_lex(YYTHD); + Lex->sphead->reset_lex(thd); } select { @@ -2832,7 +2853,7 @@ sp_cursor_stmt: } lex->sp_lex_in_use= TRUE; $$= lex; - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; } ; @@ -2881,7 +2902,7 @@ sp_cond: my_error(ER_WRONG_VALUE, MYF(0), "CONDITION", "0"); MYSQL_YYABORT; } - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t)); if ($$ == NULL) MYSQL_YYABORT; $$->type= sp_cond_type_t::number; @@ -2898,7 +2919,7 @@ sqlstate: my_error(ER_SP_BAD_SQLSTATE, MYF(0), $3.str); MYSQL_YYABORT; } - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t)); if ($$ == NULL) MYSQL_YYABORT; $$->type= sp_cond_type_t::state; @@ -2928,21 +2949,21 @@ sp_hcond: } | SQLWARNING_SYM /* SQLSTATEs 01??? */ { - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t)); if ($$ == NULL) MYSQL_YYABORT; $$->type= sp_cond_type_t::warning; } | not FOUND_SYM /* SQLSTATEs 02??? */ { - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t)); if ($$ == NULL) MYSQL_YYABORT; $$->type= sp_cond_type_t::notfound; } | SQLEXCEPTION_SYM /* All other SQLSTATEs */ { - $$= (sp_cond_type_t *)YYTHD->alloc(sizeof(sp_cond_type_t)); + $$= (sp_cond_type_t *) thd->alloc(sizeof(sp_cond_type_t)); if ($$ == NULL) MYSQL_YYABORT; $$->type= sp_cond_type_t::exception; @@ -2952,7 +2973,6 @@ sp_hcond: signal_stmt: SIGNAL_SYM signal_value opt_set_signal_information { - THD *thd= YYTHD; LEX *lex= thd->lex; Yacc_state *state= & thd->m_parser_state->m_yacc; @@ -3002,7 +3022,7 @@ opt_signal_value: opt_set_signal_information: /* empty */ { - YYTHD->m_parser_state->m_yacc.m_set_signal_info.clear(); + thd->m_parser_state->m_yacc.m_set_signal_info.clear(); } | SET signal_information_item_list ; @@ -3011,7 +3031,7 @@ signal_information_item_list: signal_condition_information_item_name EQ signal_allowed_expr { Set_signal_information *info; - info= & YYTHD->m_parser_state->m_yacc.m_set_signal_info; + info= &thd->m_parser_state->m_yacc.m_set_signal_info; int index= (int) $1; info->clear(); info->m_item[index]= $3; @@ -3020,7 +3040,7 @@ signal_information_item_list: signal_condition_information_item_name EQ signal_allowed_expr { Set_signal_information *info; - info= & YYTHD->m_parser_state->m_yacc.m_set_signal_info; + info= &thd->m_parser_state->m_yacc.m_set_signal_info; int index= (int) $3; if (info->m_item[index] != NULL) { @@ -3091,7 +3111,6 @@ signal_condition_information_item_name: resignal_stmt: RESIGNAL_SYM opt_signal_value opt_set_signal_information { - THD *thd= YYTHD; LEX *lex= thd->lex; Yacc_state *state= & thd->m_parser_state->m_yacc; @@ -3166,7 +3185,6 @@ sp_proc_stmt_if: sp_proc_stmt_statement: { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -3175,7 +3193,6 @@ sp_proc_stmt_statement: } statement { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; sp_head *sp= lex->sphead; @@ -3222,7 +3239,7 @@ sp_proc_stmt_statement: sp_proc_stmt_return: RETURN_SYM - { Lex->sphead->reset_lex(YYTHD); } + { Lex->sphead->reset_lex(thd); } expr { LEX *lex= Lex; @@ -3244,7 +3261,7 @@ sp_proc_stmt_return: MYSQL_YYABORT; sp->m_flags|= sp_head::HAS_RETURN; } - if (sp->restore_lex(YYTHD)) + if (sp->restore_lex(thd)) MYSQL_YYABORT; } ; @@ -3471,7 +3488,7 @@ sp_fetch_list: ; sp_if: - { Lex->sphead->reset_lex(YYTHD); } + { Lex->sphead->reset_lex(thd); } expr THEN_SYM { LEX *lex= Lex; @@ -3485,7 +3502,7 @@ sp_if: sp->add_cont_backpatch(i) || sp->add_instr(i)) MYSQL_YYABORT; - if (sp->restore_lex(YYTHD)) + if (sp->restore_lex(thd)) MYSQL_YYABORT; } sp_proc_stmts1 @@ -3524,7 +3541,7 @@ simple_case_stmt: { LEX *lex= Lex; case_stmt_action_case(lex); - lex->sphead->reset_lex(YYTHD); /* For expr $3 */ + lex->sphead->reset_lex(thd); /* For expr $3 */ } expr { @@ -3533,7 +3550,7 @@ simple_case_stmt: MYSQL_YYABORT; /* For expr $3 */ - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; } simple_when_clause_list @@ -3575,7 +3592,7 @@ searched_when_clause_list: simple_when_clause: WHEN_SYM { - Lex->sphead->reset_lex(YYTHD); /* For expr $3 */ + Lex->sphead->reset_lex(thd); /* For expr $3 */ } expr { @@ -3585,7 +3602,7 @@ simple_when_clause: if (case_stmt_action_when(lex, $3, true)) MYSQL_YYABORT; /* For expr $3 */ - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; } THEN_SYM @@ -3600,7 +3617,7 @@ simple_when_clause: searched_when_clause: WHEN_SYM { - Lex->sphead->reset_lex(YYTHD); /* For expr $3 */ + Lex->sphead->reset_lex(thd); /* For expr $3 */ } expr { @@ -3608,7 +3625,7 @@ searched_when_clause: if (case_stmt_action_when(lex, $3, false)) MYSQL_YYABORT; /* For expr $3 */ - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; } THEN_SYM @@ -3772,7 +3789,7 @@ sp_unlabeled_control: MYSQL_YYABORT; } | WHILE_SYM - { Lex->sphead->reset_lex(YYTHD); } + { Lex->sphead->reset_lex(thd); } expr DO_SYM { LEX *lex= Lex; @@ -3786,7 +3803,7 @@ sp_unlabeled_control: sp->new_cont_backpatch(i) || sp->add_instr(i)) MYSQL_YYABORT; - if (sp->restore_lex(YYTHD)) + if (sp->restore_lex(thd)) MYSQL_YYABORT; } sp_proc_stmts1 END WHILE_SYM @@ -3801,7 +3818,7 @@ sp_unlabeled_control: lex->sphead->do_cont_backpatch(); } | REPEAT_SYM sp_proc_stmts1 UNTIL_SYM - { Lex->sphead->reset_lex(YYTHD); } + { Lex->sphead->reset_lex(thd); } expr END REPEAT_SYM { LEX *lex= Lex; @@ -3813,7 +3830,7 @@ sp_unlabeled_control: if (i == NULL || lex->sphead->add_instr(i)) MYSQL_YYABORT; - if (lex->sphead->restore_lex(YYTHD)) + if (lex->sphead->restore_lex(thd)) MYSQL_YYABORT; /* We can shortcut the cont_backpatch here */ i->m_cont_dest= ip+1; @@ -4236,7 +4253,6 @@ create2: create3 {} | LIKE table_ident { - THD *thd= YYTHD; TABLE_LIST *src_table; LEX *lex= thd->lex; @@ -4251,7 +4267,6 @@ create2: } | '(' LIKE table_ident ')' { - THD *thd= YYTHD; TABLE_LIST *src_table; LEX *lex= thd->lex; @@ -4267,7 +4282,11 @@ create2: ; create2a: - create_field_list ')' opt_create_table_options + create_field_list ')' + { + Lex->create_info.option_list= NULL; + } + opt_create_table_options opt_create_partitioning create3 {} | opt_create_partitioning @@ -4852,7 +4871,7 @@ part_value_expr_item: my_parse_error(ER(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR)); MYSQL_YYABORT; } - if (part_info->add_column_list_value(YYTHD, part_expr)) + if (part_info->add_column_list_value(thd, part_expr)) { MYSQL_YYABORT; } @@ -4966,6 +4985,12 @@ opt_part_option: part_info->curr_part_elem->engine_type= $4; part_info->default_engine_type= $4; } + | CONNECTION_SYM opt_equal TEXT_STRING_sys + { + LEX *lex= Lex; + lex->part_info->curr_part_elem->connect_string.str= $3.str; + lex->part_info->curr_part_elem->connect_string.length= $3.length; + } | NODEGROUP_SYM opt_equal real_ulong_num { Lex->part_info->curr_part_elem->nodegroup_id= (uint16) $3; } | MAX_ROWS opt_equal real_ulonglong_num @@ -5136,6 +5161,11 @@ create_table_option: Lex->create_info.table_options|= $3 ? HA_OPTION_CHECKSUM : HA_OPTION_NO_CHECKSUM; Lex->create_info.used_fields|= HA_CREATE_USED_CHECKSUM; } + | PAGE_CHECKSUM_SYM opt_equal choice + { + Lex->create_info.used_fields|= HA_CREATE_USED_PAGE_CHECKSUM; + Lex->create_info.page_checksum= $3; + } | DELAY_KEY_WRITE_SYM opt_equal ulong_num { Lex->create_info.table_options|= $3 ? HA_OPTION_DELAY_KEY_WRITE : HA_OPTION_NO_DELAY_KEY_WRITE; @@ -5206,6 +5236,35 @@ create_table_option: Lex->create_info.used_fields|= HA_CREATE_USED_KEY_BLOCK_SIZE; Lex->create_info.key_block_size= $3; } + | TRANSACTIONAL_SYM opt_equal choice + { + Lex->create_info.used_fields|= HA_CREATE_USED_TRANSACTIONAL; + Lex->create_info.transactional= $3; + } + | IDENT_sys equal TEXT_STRING_sys + { + new (thd->mem_root) + engine_option_value($1, $3, true, &Lex->create_info.option_list, + &Lex->option_list_last); + } + | IDENT_sys equal ident + { + new (thd->mem_root) + engine_option_value($1, $3, false, &Lex->create_info.option_list, + &Lex->option_list_last); + } + | IDENT_sys equal real_ulonglong_num + { + new (thd->mem_root) + engine_option_value($1, $3, &Lex->create_info.option_list, + &Lex->option_list_last, thd->mem_root); + } + | IDENT_sys equal DEFAULT + { + new (thd->mem_root) + engine_option_value($1, &Lex->create_info.option_list, + &Lex->option_list_last); + } ; default_charset: @@ -5246,19 +5305,19 @@ default_collation: storage_engines: ident_or_text { - plugin_ref plugin= ha_resolve_by_name(YYTHD, &$1); + plugin_ref plugin= ha_resolve_by_name(thd, &$1); if (plugin) $$= plugin_data(plugin, handlerton*); else { - if (YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION) + if (thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION) { my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str); MYSQL_YYABORT; } $$= 0; - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_STORAGE_ENGINE, ER(ER_UNKNOWN_STORAGE_ENGINE), $1.str); @@ -5270,7 +5329,7 @@ known_storage_engines: ident_or_text { plugin_ref plugin; - if ((plugin= ha_resolve_by_name(YYTHD, &$1))) + if ((plugin= ha_resolve_by_name(thd, &$1))) $$= plugin_data(plugin, handlerton*); else { @@ -5287,6 +5346,7 @@ row_types: | COMPRESSED_SYM { $$= ROW_TYPE_COMPRESSED; } | REDUNDANT_SYM { $$= ROW_TYPE_REDUNDANT; } | COMPACT_SYM { $$= ROW_TYPE_COMPACT; } + | PAGE_SYM { $$= ROW_TYPE_PAGE; } ; merge_insert_types: @@ -5334,25 +5394,33 @@ column_def: ; key_def: - normal_key_type opt_ident key_alg '(' key_list ')' normal_key_options + normal_key_type opt_ident key_alg '(' key_list ')' + { Lex->option_list= NULL; } + normal_key_options { if (add_create_index (Lex, $1, $2)) MYSQL_YYABORT; } | fulltext opt_key_or_index opt_ident init_key_options - '(' key_list ')' fulltext_key_options + '(' key_list ')' + { Lex->option_list= NULL; } + fulltext_key_options { if (add_create_index (Lex, $1, $3)) MYSQL_YYABORT; } | spatial opt_key_or_index opt_ident init_key_options - '(' key_list ')' spatial_key_options + '(' key_list ')' + { Lex->option_list= NULL; } + spatial_key_options { if (add_create_index (Lex, $1, $3)) MYSQL_YYABORT; } | opt_constraint constraint_key_type opt_ident key_alg - '(' key_list ')' normal_key_options + '(' key_list ')' + { Lex->option_list= NULL; } + normal_key_options { if (add_create_index (Lex, $2, $3.str ? $3 : $1)) MYSQL_YYABORT; @@ -5369,6 +5437,7 @@ key_def: if (key == NULL) MYSQL_YYABORT; lex->alter_info.key_list.push_back(key); + lex->option_list= NULL; if (add_create_index (lex, Key::MULTIPLE, $1.str ? $1 : $4, &default_key_create_info, 1)) MYSQL_YYABORT; @@ -5408,8 +5477,10 @@ field_spec: lex->default_value= lex->on_update_value= 0; lex->comment=null_lex_str; lex->charset=NULL; + lex->vcol_info= 0; + lex->option_list= NULL; } - type opt_attribute + field_def { LEX *lex=Lex; if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3, @@ -5417,11 +5488,101 @@ field_spec: lex->default_value, lex->on_update_value, &lex->comment, lex->change,&lex->interval_list,lex->charset, - lex->uint_geom_type)) + lex->uint_geom_type, + lex->vcol_info, lex->option_list)) MYSQL_YYABORT; } ; +field_def: + type opt_attribute {} + | type opt_generated_always AS '(' virtual_column_func ')' + vcol_opt_specifier + vcol_opt_attribute + { + $$= (enum enum_field_types)MYSQL_TYPE_VIRTUAL; + Lex->vcol_info->set_field_type((enum enum_field_types) $1); + } + ; + +opt_generated_always: + /* empty */ + | GENERATED_SYM ALWAYS_SYM {} + ; + +vcol_opt_specifier: + /* empty */ + { + Lex->vcol_info->set_stored_in_db_flag(FALSE); + } + | VIRTUAL_SYM + { + Lex->vcol_info->set_stored_in_db_flag(FALSE); + } + | PERSISTENT_SYM + { + Lex->vcol_info->set_stored_in_db_flag(TRUE); + } + ; + +vcol_opt_attribute: + /* empty */ {} + | vcol_opt_attribute_list {} + ; + +vcol_opt_attribute_list: + vcol_opt_attribute_list vcol_attribute {} + | vcol_attribute + ; + +vcol_attribute: + UNIQUE_SYM + { + LEX *lex=Lex; + lex->type|= UNIQUE_FLAG; + lex->alter_info.flags|= ALTER_ADD_INDEX; + } + | UNIQUE_SYM KEY_SYM + { + LEX *lex=Lex; + lex->type|= UNIQUE_KEY_FLAG; + lex->alter_info.flags|= ALTER_ADD_INDEX; + } + | COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; } + ; + +parse_vcol_expr: + PARSE_VCOL_EXPR_SYM '(' virtual_column_func ')' + { + /* + "PARSE_VCOL_EXPR" can only be used by the SQL server + when reading a '*.frm' file. + Prevent the end user from invoking this command. + */ + if (!Lex->parse_vcol_expr) + { + my_message(ER_SYNTAX_ERROR, ER(ER_SYNTAX_ERROR), MYF(0)); + MYSQL_YYABORT; + } + } + ; + +virtual_column_func: + remember_name expr remember_end + { + Lex->vcol_info= new Virtual_column_info(); + if (!Lex->vcol_info) + { + mem_alloc_error(sizeof(Virtual_column_info)); + MYSQL_YYABORT; + } + uint expr_len= (uint)($3 - $1) - 1; + Lex->vcol_info->expr_str.str= (char* ) sql_memdup($1 + 1, expr_len); + Lex->vcol_info->expr_str.length= expr_len; + Lex->vcol_info->expr_item= $2; + } + ; + type: int_type opt_field_length field_options { $$=$1; } | real_type opt_precision field_options { $$=$1; } @@ -5500,7 +5661,7 @@ type: { char buff[sizeof("YEAR()") + MY_INT64_NUM_DECIMAL_DIGITS + 1]; my_snprintf(buff, sizeof(buff), "YEAR(%lu)", length); - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_NOTE, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), buff, "YEAR(4)"); @@ -5510,11 +5671,11 @@ type: } | DATE_SYM { $$=MYSQL_TYPE_DATE; } - | TIME_SYM + | TIME_SYM opt_field_length { $$=MYSQL_TYPE_TIME; } - | TIMESTAMP + | TIMESTAMP opt_field_length { - if (YYTHD->variables.sql_mode & MODE_MAXDB) + if (thd->variables.sql_mode & MODE_MAXDB) $$=MYSQL_TYPE_DATETIME; else { @@ -5525,7 +5686,7 @@ type: $$=MYSQL_TYPE_TIMESTAMP; } } - | DATETIME + | DATETIME opt_field_length { $$=MYSQL_TYPE_DATETIME; } | TINYBLOB { @@ -5647,7 +5808,7 @@ int_type: real_type: REAL { - $$= YYTHD->variables.sql_mode & MODE_REAL_AS_FLOAT ? + $$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ? MYSQL_TYPE_FLOAT : MYSQL_TYPE_DOUBLE; } | DOUBLE_SYM @@ -5722,7 +5883,7 @@ attribute: | DEFAULT now_or_signed_literal { Lex->default_value=$2; } | ON UPDATE_SYM NOW_SYM optional_braces { - Item *item= new (YYTHD->mem_root) Item_func_now_local(); + Item *item= new (thd->mem_root) Item_func_now_local(6); if (item == NULL) MYSQL_YYABORT; Lex->on_update_value= item; @@ -5766,6 +5927,29 @@ attribute: Lex->charset=$2; } } + | IDENT_sys equal TEXT_STRING_sys + { + new (thd->mem_root) + engine_option_value($1, $3, true, &Lex->option_list, + &Lex->option_list_last); + } + | IDENT_sys equal ident + { + new (thd->mem_root) + engine_option_value($1, $3, false, &Lex->option_list, + &Lex->option_list_last); + } + | IDENT_sys equal real_ulonglong_num + { + new (thd->mem_root) + engine_option_value($1, $3, &Lex->option_list, + &Lex->option_list_last, thd->mem_root); + } + | IDENT_sys equal DEFAULT + { + new (thd->mem_root) + engine_option_value($1, &Lex->option_list, &Lex->option_list_last); + } ; @@ -5793,7 +5977,7 @@ type_with_opt_collate: now_or_signed_literal: NOW_SYM optional_braces { - $$= new (YYTHD->mem_root) Item_func_now_local(); + $$= new (thd->mem_root) Item_func_now_local(6); if ($$ == NULL) MYSQL_YYABORT; } @@ -5801,6 +5985,11 @@ now_or_signed_literal: { $$=$1; } ; +hex_num_or_string: + HEX_NUM {} + | HEX_STRING {} + ; + charset: CHAR_SYM SET {} | CHARSET {} @@ -6135,6 +6324,29 @@ all_key_opt: KEY_BLOCK_SIZE opt_equal ulong_num { Lex->key_create_info.block_size= $3; } | COMMENT_SYM TEXT_STRING_sys { Lex->key_create_info.comment= $2; } + | IDENT_sys equal TEXT_STRING_sys + { + new (thd->mem_root) + engine_option_value($1, $3, true, &Lex->option_list, + &Lex->option_list_last); + } + | IDENT_sys equal ident + { + new (thd->mem_root) + engine_option_value($1, $3, false, &Lex->option_list, + &Lex->option_list_last); + } + | IDENT_sys equal real_ulonglong_num + { + new (thd->mem_root) + engine_option_value($1, $3, &Lex->option_list, + &Lex->option_list_last, thd->mem_root); + } + | IDENT_sys equal DEFAULT + { + new (thd->mem_root) + engine_option_value($1, &Lex->option_list, &Lex->option_list_last); + } ; normal_key_opt: @@ -6210,9 +6422,8 @@ string_list: */ alter: - ALTER opt_ignore TABLE_SYM table_ident + ALTER alter_options TABLE_SYM table_ident { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->name.str= 0; lex->name.length= 0; @@ -6238,7 +6449,6 @@ alter: } alter_commands { - THD *thd= YYTHD; LEX *lex= thd->lex; if (!lex->m_stmt) { @@ -6336,7 +6546,7 @@ alter: my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"); MYSQL_YYABORT; } - lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; + lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; lex->create_view_mode= VIEW_ALTER; } view_tail @@ -6351,7 +6561,7 @@ alter: Event_parse_data. */ - if (!(Lex->event_parse_data= Event_parse_data::new_instance(YYTHD))) + if (!(Lex->event_parse_data= Event_parse_data::new_instance(thd))) MYSQL_YYABORT; Lex->event_parse_data->identifier= $4; @@ -6466,7 +6676,6 @@ alter_commands: | OPTIMIZE PARTITION_SYM opt_no_write_to_binlog all_or_alt_part_name_list { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->no_write_to_binlog= $3; lex->check_opt.init(); @@ -6480,7 +6689,6 @@ alter_commands: | ANALYZE_SYM PARTITION_SYM opt_no_write_to_binlog all_or_alt_part_name_list { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->no_write_to_binlog= $3; lex->check_opt.init(); @@ -6492,7 +6700,6 @@ alter_commands: } | CHECK_SYM PARTITION_SYM all_or_alt_part_name_list { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->check_opt.init(); DBUG_ASSERT(!lex->m_stmt); @@ -6505,7 +6712,6 @@ alter_commands: | REPAIR PARTITION_SYM opt_no_write_to_binlog all_or_alt_part_name_list { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->no_write_to_binlog= $3; lex->check_opt.init(); @@ -6525,7 +6731,6 @@ alter_commands: } | TRUNCATE_SYM PARTITION_SYM all_or_alt_part_name_list { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->check_opt.init(); DBUG_ASSERT(!lex->m_stmt); @@ -6666,6 +6871,7 @@ alter_list_item: LEX *lex=Lex; lex->change= $3.str; lex->alter_info.flags|= ALTER_CHANGE_COLUMN; + lex->option_list= NULL; } field_spec opt_place { @@ -6679,8 +6885,10 @@ alter_list_item: lex->comment=null_lex_str; lex->charset= NULL; lex->alter_info.flags|= ALTER_CHANGE_COLUMN; + lex->vcol_info= 0; + lex->option_list= NULL; } - type opt_attribute + field_def { LEX *lex=Lex; if (add_field_to_list(lex->thd,&$3, @@ -6689,7 +6897,8 @@ alter_list_item: lex->default_value, lex->on_update_value, &lex->comment, $3.str, &lex->interval_list, lex->charset, - lex->uint_geom_type)) + lex->uint_geom_type, + lex->vcol_info, lex->option_list)) MYSQL_YYABORT; } opt_place @@ -6780,7 +6989,6 @@ alter_list_item: { if (!$4) { - THD *thd= YYTHD; $4= thd->variables.collation_database; } $5= $5 ? $5 : $4; @@ -6828,6 +7036,25 @@ opt_ignore: | IGNORE_SYM { Lex->ignore= 1;} ; +alter_options: + { Lex->ignore= Lex->online= 0;} alter_options_part2 + ; + +alter_options_part2: + /* empty */ + | alter_option_list + ; + +alter_option_list: + alter_option_list alter_option + | alter_option + ; + +alter_option: + IGNORE_SYM { Lex->ignore= 1;} + | ONLINE_SYM { Lex->online= 1;} + + opt_restrict: /* empty */ { Lex->drop_mode= DROP_DEFAULT; } | RESTRICT { Lex->drop_mode= DROP_RESTRICT; } @@ -6857,8 +7084,6 @@ slave: LEX *lex=Lex; lex->sql_command = SQLCOM_SLAVE_START; lex->type = 0; - /* We'll use mi structure for UNTIL options */ - bzero((char*) &lex->mi, sizeof(lex->mi)); /* If you change this code don't forget to update SLAVE START too */ } slave_until @@ -6875,8 +7100,6 @@ slave: LEX *lex=Lex; lex->sql_command = SQLCOM_SLAVE_START; lex->type = 0; - /* We'll use mi structure for UNTIL options */ - bzero((char*) &lex->mi, sizeof(lex->mi)); } slave_until {} @@ -6928,7 +7151,7 @@ slave_until: { LEX *lex=Lex; if (((lex->mi.log_file_name || lex->mi.pos) && - (lex->mi.relay_log_name || lex->mi.relay_log_pos)) || + (lex->mi.relay_log_name || lex->mi.relay_log_pos)) || !((lex->mi.log_file_name && lex->mi.pos) || (lex->mi.relay_log_name && lex->mi.relay_log_pos))) { @@ -6975,7 +7198,6 @@ repair: } table_list opt_mi_repair_type { - THD *thd= YYTHD; LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_stmt); lex->m_stmt= new (thd->mem_root) Repair_table_statement(lex); @@ -7013,7 +7235,6 @@ analyze: } table_list { - THD *thd= YYTHD; LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_stmt); lex->m_stmt= new (thd->mem_root) Analyze_table_statement(lex); @@ -7048,7 +7269,6 @@ check: } table_list opt_mi_check_type { - THD *thd= YYTHD; LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_stmt); lex->m_stmt= new (thd->mem_root) Check_table_statement(lex); @@ -7089,7 +7309,6 @@ optimize: } table_list { - THD *thd= YYTHD; LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_stmt); lex->m_stmt= new (thd->mem_root) Optimize_table_statement(lex); @@ -7174,7 +7393,7 @@ keycache_list: assign_to_keycache: table_ident cache_keys_spec { - if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ, + if (!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, MDL_SHARED_READ, Select->pop_index_hints())) MYSQL_YYABORT; @@ -7184,7 +7403,7 @@ assign_to_keycache: assign_to_keycache_parts: table_ident adm_partition cache_keys_spec { - if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ, + if (!Select->add_table_to_list(thd, $1, NULL, 0, TL_READ, MDL_SHARED_READ, Select->pop_index_hints())) MYSQL_YYABORT; @@ -7220,7 +7439,7 @@ preload_list: preload_keys: table_ident cache_keys_spec opt_ignore_leaves { - if (!Select->add_table_to_list(YYTHD, $1, NULL, $3, TL_READ, + if (!Select->add_table_to_list(thd, $1, NULL, $3, TL_READ, MDL_SHARED_READ, Select->pop_index_hints())) MYSQL_YYABORT; @@ -7230,7 +7449,7 @@ preload_keys: preload_keys_parts: table_ident adm_partition cache_keys_spec opt_ignore_leaves { - if (!Select->add_table_to_list(YYTHD, $1, NULL, $4, TL_READ, + if (!Select->add_table_to_list(thd, $1, NULL, $4, TL_READ, MDL_SHARED_READ, Select->pop_index_hints())) MYSQL_YYABORT; @@ -7247,10 +7466,8 @@ adm_partition: cache_keys_spec: { - Lex->select_lex.alloc_index_hints(YYTHD); + Lex->select_lex.alloc_index_hints(thd); Select->set_index_hint_type(INDEX_HINT_USE, - old_mode ? - INDEX_HINT_MASK_JOIN : INDEX_HINT_MASK_ALL); } cache_key_list_or_empty @@ -7462,7 +7679,6 @@ select_item_list: | select_item | '*' { - THD *thd= YYTHD; Item *item= new (thd->mem_root) Item_field(&thd->lex->current_select->context, NULL, NULL, "*"); @@ -7477,14 +7693,11 @@ select_item_list: select_item: remember_name table_wild remember_end { - THD *thd= YYTHD; - if (add_item_to_list(thd, $2)) MYSQL_YYABORT; } | remember_name expr remember_end select_alias { - THD *thd= YYTHD; DBUG_ASSERT($1 < $3); if (add_item_to_list(thd, $2)) @@ -7527,6 +7740,12 @@ select_alias: | TEXT_STRING_sys { $$=$1; } ; +opt_time_precision: + /* empty */ { $$= 0; } + | '(' ')' { $$= 0; } + | '(' real_ulong_num ')' { $$= $2; }; + ; + optional_braces: /* empty */ {} | '(' ')' {} @@ -7580,7 +7799,7 @@ expr: else { /* X OR Y */ - $$ = new (YYTHD->mem_root) Item_cond_or($1, $3); + $$ = new (thd->mem_root) Item_cond_or($1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -7588,7 +7807,7 @@ expr: | expr XOR expr %prec XOR { /* XOR is a proprietary extension */ - $$ = new (YYTHD->mem_root) Item_cond_xor($1, $3); + $$ = new (thd->mem_root) Item_func_xor($1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -7630,50 +7849,50 @@ expr: else { /* X AND Y */ - $$ = new (YYTHD->mem_root) Item_cond_and($1, $3); + $$ = new (thd->mem_root) Item_cond_and($1, $3); if ($$ == NULL) MYSQL_YYABORT; } } | NOT_SYM expr %prec NOT_SYM { - $$= negate_expression(YYTHD, $2); + $$= negate_expression(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS TRUE_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_istrue($1); + $$= new (thd->mem_root) Item_func_istrue($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not TRUE_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnottrue($1); + $$= new (thd->mem_root) Item_func_isnottrue($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS FALSE_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isfalse($1); + $$= new (thd->mem_root) Item_func_isfalse($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not FALSE_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnotfalse($1); + $$= new (thd->mem_root) Item_func_isnotfalse($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS UNKNOWN_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnull($1); + $$= new (thd->mem_root) Item_func_isnull($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not UNKNOWN_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnotnull($1); + $$= new (thd->mem_root) Item_func_isnotnull($1); if ($$ == NULL) MYSQL_YYABORT; } @@ -7683,19 +7902,19 @@ expr: bool_pri: bool_pri IS NULL_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnull($1); + $$= new (thd->mem_root) Item_func_isnull($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not NULL_SYM %prec IS { - $$= new (YYTHD->mem_root) Item_func_isnotnull($1); + $$= new (thd->mem_root) Item_func_isnotnull($1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM { - $$= new (YYTHD->mem_root) Item_func_equal($1,$3); + $$= new (thd->mem_root) Item_func_equal($1,$3); if ($$ == NULL) MYSQL_YYABORT; } @@ -7717,13 +7936,12 @@ bool_pri: predicate: bit_expr IN_SYM '(' subselect ')' { - $$= new (YYTHD->mem_root) Item_in_subselect($1, $4); + $$= new (thd->mem_root) Item_in_subselect($1, $4); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not IN_SYM '(' subselect ')' { - THD *thd= YYTHD; Item *item= new (thd->mem_root) Item_in_subselect($1, $5); if (item == NULL) MYSQL_YYABORT; @@ -7733,7 +7951,7 @@ predicate: } | bit_expr IN_SYM '(' expr ')' { - $$= handle_sql2003_note184_exception(YYTHD, $1, true, $4); + $$= handle_sql2003_note184_exception(thd, $1, true, $4); if ($$ == NULL) MYSQL_YYABORT; } @@ -7741,13 +7959,13 @@ predicate: { $6->push_front($4); $6->push_front($1); - $$= new (YYTHD->mem_root) Item_func_in(*$6); + $$= new (thd->mem_root) Item_func_in(*$6); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not IN_SYM '(' expr ')' { - $$= handle_sql2003_note184_exception(YYTHD, $1, false, $5); + $$= handle_sql2003_note184_exception(thd, $1, false, $5); if ($$ == NULL) MYSQL_YYABORT; } @@ -7755,7 +7973,7 @@ predicate: { $7->push_front($5); $7->push_front($1); - Item_func_in *item = new (YYTHD->mem_root) Item_func_in(*$7); + Item_func_in *item = new (thd->mem_root) Item_func_in(*$7); if (item == NULL) MYSQL_YYABORT; item->negate(); @@ -7763,14 +7981,14 @@ predicate: } | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate { - $$= new (YYTHD->mem_root) Item_func_between($1,$3,$5); + $$= new (thd->mem_root) Item_func_between($1,$3,$5); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate { Item_func_between *item; - item= new (YYTHD->mem_root) Item_func_between($1,$4,$6); + item= new (thd->mem_root) Item_func_between($1,$4,$6); if (item == NULL) MYSQL_YYABORT; item->negate(); @@ -7778,42 +7996,42 @@ predicate: } | bit_expr SOUNDS_SYM LIKE bit_expr { - Item *item1= new (YYTHD->mem_root) Item_func_soundex($1); - Item *item4= new (YYTHD->mem_root) Item_func_soundex($4); + Item *item1= new (thd->mem_root) Item_func_soundex($1); + Item *item4= new (thd->mem_root) Item_func_soundex($4); if ((item1 == NULL) || (item4 == NULL)) MYSQL_YYABORT; - $$= new (YYTHD->mem_root) Item_func_eq(item1, item4); + $$= new (thd->mem_root) Item_func_eq(item1, item4); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr LIKE simple_expr opt_escape { - $$= new (YYTHD->mem_root) Item_func_like($1,$3,$4,Lex->escape_used); + $$= new (thd->mem_root) Item_func_like($1,$3,$4,Lex->escape_used); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not LIKE simple_expr opt_escape { - Item *item= new (YYTHD->mem_root) Item_func_like($1,$4,$5, + Item *item= new (thd->mem_root) Item_func_like($1,$4,$5, Lex->escape_used); if (item == NULL) MYSQL_YYABORT; - $$= new (YYTHD->mem_root) Item_func_not(item); + $$= new (thd->mem_root) Item_func_not(item); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr REGEXP bit_expr { - $$= new (YYTHD->mem_root) Item_func_regex($1,$3); + $$= new (thd->mem_root) Item_func_regex($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not REGEXP bit_expr { - Item *item= new (YYTHD->mem_root) Item_func_regex($1,$4); + Item *item= new (thd->mem_root) Item_func_regex($1,$4); if (item == NULL) MYSQL_YYABORT; - $$= negate_expression(YYTHD, item); + $$= negate_expression(thd, item); if ($$ == NULL) MYSQL_YYABORT; } @@ -7823,85 +8041,85 @@ predicate: bit_expr: bit_expr '|' bit_expr %prec '|' { - $$= new (YYTHD->mem_root) Item_func_bit_or($1,$3); + $$= new (thd->mem_root) Item_func_bit_or($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '&' bit_expr %prec '&' { - $$= new (YYTHD->mem_root) Item_func_bit_and($1,$3); + $$= new (thd->mem_root) Item_func_bit_and($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT { - $$= new (YYTHD->mem_root) Item_func_shift_left($1,$3); + $$= new (thd->mem_root) Item_func_shift_left($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT { - $$= new (YYTHD->mem_root) Item_func_shift_right($1,$3); + $$= new (thd->mem_root) Item_func_shift_right($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '+' bit_expr %prec '+' { - $$= new (YYTHD->mem_root) Item_func_plus($1,$3); + $$= new (thd->mem_root) Item_func_plus($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '-' bit_expr %prec '-' { - $$= new (YYTHD->mem_root) Item_func_minus($1,$3); + $$= new (thd->mem_root) Item_func_minus($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '+' INTERVAL_SYM expr interval %prec '+' { - $$= new (YYTHD->mem_root) Item_date_add_interval($1,$4,$5,0); + $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,0); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '-' INTERVAL_SYM expr interval %prec '-' { - $$= new (YYTHD->mem_root) Item_date_add_interval($1,$4,$5,1); + $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,1); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '*' bit_expr %prec '*' { - $$= new (YYTHD->mem_root) Item_func_mul($1,$3); + $$= new (thd->mem_root) Item_func_mul($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '/' bit_expr %prec '/' { - $$= new (YYTHD->mem_root) Item_func_div($1,$3); + $$= new (thd->mem_root) Item_func_div($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '%' bit_expr %prec '%' { - $$= new (YYTHD->mem_root) Item_func_mod($1,$3); + $$= new (thd->mem_root) Item_func_mod($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr DIV_SYM bit_expr %prec DIV_SYM { - $$= new (YYTHD->mem_root) Item_func_int_div($1,$3); + $$= new (thd->mem_root) Item_func_int_div($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr MOD_SYM bit_expr %prec MOD_SYM { - $$= new (YYTHD->mem_root) Item_func_mod($1,$3); + $$= new (thd->mem_root) Item_func_mod($1,$3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '^' bit_expr { - $$= new (YYTHD->mem_root) Item_func_bit_xor($1,$3); + $$= new (thd->mem_root) Item_func_bit_xor($1,$3); if ($$ == NULL) MYSQL_YYABORT; } @@ -7942,6 +8160,133 @@ all_or_any: | ANY_SYM { $$ = 0; } ; +opt_dyncol_type: + /* empty */ + { + LEX *lex= Lex; + $$= DYN_COL_NULL; /* automatic type */ + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | AS dyncol_type { $$= $2; } + ; + +dyncol_type: + INT_SYM + { + LEX *lex= Lex; + $$= DYN_COL_INT; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | UNSIGNED INT_SYM + { + LEX *lex= Lex; + $$= DYN_COL_UINT; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | DOUBLE_SYM + { + LEX *lex= Lex; + $$= DYN_COL_DOUBLE; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | REAL + { + LEX *lex= Lex; + $$= DYN_COL_DOUBLE; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | FLOAT_SYM + { + LEX *lex= Lex; + $$= DYN_COL_DOUBLE; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | DECIMAL_SYM float_options + { + $$= DYN_COL_DECIMAL; + Lex->charset= NULL; + } + | char opt_binary + { + LEX *lex= Lex; + $$= DYN_COL_STRING; + lex->length= lex->dec= 0; + } + | nchar + { + LEX *lex= Lex; + $$= DYN_COL_STRING; + lex->charset= national_charset_info; + lex->length= lex->dec= 0; + } + | DATE_SYM + { + LEX *lex= Lex; + $$= DYN_COL_DATE; + lex->charset= NULL; + lex->length= lex->dec= 0; + } + | TIME_SYM opt_field_length + { + LEX *lex= Lex; + $$= DYN_COL_TIME; + lex->charset= NULL; + lex->dec= lex->length; + lex->length= 0; + } + | DATETIME opt_field_length + { + LEX *lex= Lex; + $$= DYN_COL_DATETIME; + lex->charset= NULL; + lex->dec= lex->length; + lex->length= 0; + } + ; + +dyncall_create_element: + expr ',' expr opt_dyncol_type + { + LEX *lex= Lex; + $$= (DYNCALL_CREATE_DEF *) + alloc_root(thd->mem_root, sizeof(DYNCALL_CREATE_DEF)); + if ($$ == NULL) + MYSQL_YYABORT; + $$->num= $1; + $$->value= $3; + $$->type= (DYNAMIC_COLUMN_TYPE)$4; + $$->cs= lex->charset; + if (lex->length) + $$->len= strtoul(lex->length, NULL, 10); + else + $$->len= 0; + if (lex->dec) + $$->frac= strtoul(lex->dec, NULL, 10); + else + $$->len= 0; + } + +dyncall_create_list: + dyncall_create_element + { + $$= new (thd->mem_root) List<DYNCALL_CREATE_DEF>; + if ($$ == NULL) + MYSQL_YYABORT; + $$->push_back($1); + } + | dyncall_create_list ',' dyncall_create_element + { + $1->push_back($3); + $$= $1; + } + ; + simple_expr: simple_ident | function_call_keyword @@ -7950,7 +8295,6 @@ simple_expr: | function_call_conflict | simple_expr COLLATE_SYM ident_or_text %prec NEG { - THD *thd= YYTHD; Item *i1= new (thd->mem_root) Item_string($3.str, $3.length, thd->charset()); @@ -7966,7 +8310,7 @@ simple_expr: | sum_expr | simple_expr OR_OR_SYM simple_expr { - $$= new (YYTHD->mem_root) Item_func_concat($1, $3); + $$= new (thd->mem_root) Item_func_concat($1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -7976,25 +8320,25 @@ simple_expr: } | '-' simple_expr %prec NEG { - $$= new (YYTHD->mem_root) Item_func_neg($2); + $$= new (thd->mem_root) Item_func_neg($2); if ($$ == NULL) MYSQL_YYABORT; } | '~' simple_expr %prec NEG { - $$= new (YYTHD->mem_root) Item_func_bit_neg($2); + $$= new (thd->mem_root) Item_func_bit_neg($2); if ($$ == NULL) MYSQL_YYABORT; } | not2 simple_expr %prec NEG { - $$= negate_expression(YYTHD, $2); + $$= negate_expression(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } | '(' subselect ')' { - $$= new (YYTHD->mem_root) Item_singlerow_subselect($2); + $$= new (thd->mem_root) Item_singlerow_subselect($2); if ($$ == NULL) MYSQL_YYABORT; } @@ -8003,20 +8347,20 @@ simple_expr: | '(' expr ',' expr_list ')' { $4->push_front($2); - $$= new (YYTHD->mem_root) Item_row(*$4); + $$= new (thd->mem_root) Item_row(*$4); if ($$ == NULL) MYSQL_YYABORT; } | ROW_SYM '(' expr ',' expr_list ')' { $5->push_front($3); - $$= new (YYTHD->mem_root) Item_row(*$5); + $$= new (thd->mem_root) Item_row(*$5); if ($$ == NULL) MYSQL_YYABORT; } | EXISTS '(' subselect ')' { - $$= new (YYTHD->mem_root) Item_exists_subselect($3); + $$= new (thd->mem_root) Item_exists_subselect($3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8025,7 +8369,7 @@ simple_expr: | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')' { $2->push_front($5); - Item_func_match *i1= new (YYTHD->mem_root) Item_func_match(*$2, $6); + Item_func_match *i1= new (thd->mem_root) Item_func_match(*$2, $6); if (i1 == NULL) MYSQL_YYABORT; Select->add_ftfunc_to_list(i1); @@ -8033,7 +8377,7 @@ simple_expr: } | BINARY simple_expr %prec NEG { - $$= create_func_cast(YYTHD, $2, ITEM_CAST_CHAR, NULL, NULL, + $$= create_func_cast(thd, $2, ITEM_CAST_CHAR, NULL, NULL, &my_charset_bin); if ($$ == NULL) MYSQL_YYABORT; @@ -8041,27 +8385,27 @@ simple_expr: | CAST_SYM '(' expr AS cast_type ')' { LEX *lex= Lex; - $$= create_func_cast(YYTHD, $3, $5, lex->length, lex->dec, + $$= create_func_cast(thd, $3, $5, lex->length, lex->dec, lex->charset); if ($$ == NULL) MYSQL_YYABORT; } | CASE_SYM opt_expr when_list opt_else END { - $$= new (YYTHD->mem_root) Item_func_case(* $3, $2, $4 ); + $$= new (thd->mem_root) Item_func_case(* $3, $2, $4 ); if ($$ == NULL) MYSQL_YYABORT; } | CONVERT_SYM '(' expr ',' cast_type ')' { - $$= create_func_cast(YYTHD, $3, $5, Lex->length, Lex->dec, + $$= create_func_cast(thd, $3, $5, Lex->length, Lex->dec, Lex->charset); if ($$ == NULL) MYSQL_YYABORT; } | CONVERT_SYM '(' expr USING charset_name ')' { - $$= new (YYTHD->mem_root) Item_func_conv_charset($3,$5); + $$= new (thd->mem_root) Item_func_conv_charset($3,$5); if ($$ == NULL) MYSQL_YYABORT; } @@ -8074,14 +8418,14 @@ simple_expr: my_error(ER_WRONG_COLUMN_NAME, MYF(0), il->my_name()->str); MYSQL_YYABORT; } - $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context(), + $$= new (thd->mem_root) Item_default_value(Lex->current_context(), $3); if ($$ == NULL) MYSQL_YYABORT; } | VALUES '(' simple_ident_nospvar ')' { - $$= new (YYTHD->mem_root) Item_insert_value(Lex->current_context(), + $$= new (thd->mem_root) Item_insert_value(Lex->current_context(), $3); if ($$ == NULL) MYSQL_YYABORT; @@ -8089,7 +8433,7 @@ simple_expr: | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM /* we cannot put interval before - */ { - $$= new (YYTHD->mem_root) Item_date_add_interval($5,$2,$3,0); + $$= new (thd->mem_root) Item_date_add_interval($5,$2,$3,0); if ($$ == NULL) MYSQL_YYABORT; } @@ -8104,19 +8448,19 @@ simple_expr: function_call_keyword: CHAR_SYM '(' expr_list ')' { - $$= new (YYTHD->mem_root) Item_func_char(*$3); + $$= new (thd->mem_root) Item_func_char(*$3); if ($$ == NULL) MYSQL_YYABORT; } | CHAR_SYM '(' expr_list USING charset_name ')' { - $$= new (YYTHD->mem_root) Item_func_char(*$3, $5); + $$= new (thd->mem_root) Item_func_char(*$3, $5); if ($$ == NULL) MYSQL_YYABORT; } | CURRENT_USER optional_braces { - $$= new (YYTHD->mem_root) Item_func_current_user(Lex->current_context()); + $$= new (thd->mem_root) Item_func_current_user(Lex->current_context()); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -8124,31 +8468,30 @@ function_call_keyword: } | DATE_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_date_typecast($3); + $$= new (thd->mem_root) Item_date_typecast($3); if ($$ == NULL) MYSQL_YYABORT; } | DAY_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_dayofmonth($3); + $$= new (thd->mem_root) Item_func_dayofmonth($3); if ($$ == NULL) MYSQL_YYABORT; } | HOUR_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_hour($3); + $$= new (thd->mem_root) Item_func_hour($3); if ($$ == NULL) MYSQL_YYABORT; } | INSERT '(' expr ',' expr ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_insert($3,$5,$7,$9); + $$= new (thd->mem_root) Item_func_insert($3,$5,$7,$9); if ($$ == NULL) MYSQL_YYABORT; } | INTERVAL_SYM '(' expr ',' expr ')' %prec INTERVAL_SYM { - THD *thd= YYTHD; List<Item> *list= new (thd->mem_root) List<Item>; if (list == NULL) MYSQL_YYABORT; @@ -8163,7 +8506,6 @@ function_call_keyword: } | INTERVAL_SYM '(' expr ',' expr ',' expr_list ')' %prec INTERVAL_SYM { - THD *thd= YYTHD; $7->push_front($5); $7->push_front($3); Item_row *item= new (thd->mem_root) Item_row(*$7); @@ -8175,103 +8517,103 @@ function_call_keyword: } | LEFT '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_left($3,$5); + $$= new (thd->mem_root) Item_func_left($3,$5); if ($$ == NULL) MYSQL_YYABORT; } | MINUTE_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_minute($3); + $$= new (thd->mem_root) Item_func_minute($3); if ($$ == NULL) MYSQL_YYABORT; } | MONTH_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_month($3); + $$= new (thd->mem_root) Item_func_month($3); if ($$ == NULL) MYSQL_YYABORT; } | RIGHT '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_right($3,$5); + $$= new (thd->mem_root) Item_func_right($3,$5); if ($$ == NULL) MYSQL_YYABORT; } | SECOND_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_second($3); + $$= new (thd->mem_root) Item_func_second($3); if ($$ == NULL) MYSQL_YYABORT; } | TIME_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_time_typecast($3); + $$= new (thd->mem_root) Item_time_typecast($3, AUTO_SEC_PART_DIGITS); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP '(' expr ')' { - $$= new (YYTHD->mem_root) Item_datetime_typecast($3); + $$= new (thd->mem_root) Item_datetime_typecast($3, AUTO_SEC_PART_DIGITS); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_add_time($3, $5, 1, 0); + $$= new (thd->mem_root) Item_func_add_time($3, $5, 1, 0); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_trim($3); + $$= new (thd->mem_root) Item_func_trim($3); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' LEADING expr FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_ltrim($6,$4); + $$= new (thd->mem_root) Item_func_ltrim($6,$4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' TRAILING expr FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_rtrim($6,$4); + $$= new (thd->mem_root) Item_func_rtrim($6,$4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' BOTH expr FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_trim($6,$4); + $$= new (thd->mem_root) Item_func_trim($6,$4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' LEADING FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_ltrim($5); + $$= new (thd->mem_root) Item_func_ltrim($5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' TRAILING FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_rtrim($5); + $$= new (thd->mem_root) Item_func_rtrim($5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' BOTH FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_trim($5); + $$= new (thd->mem_root) Item_func_trim($5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' expr FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_trim($5,$3); + $$= new (thd->mem_root) Item_func_trim($5,$3); if ($$ == NULL) MYSQL_YYABORT; } | USER '(' ')' { - $$= new (YYTHD->mem_root) Item_func_user(); + $$= new (thd->mem_root) Item_func_user(); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -8279,7 +8621,7 @@ function_call_keyword: } | YEAR_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_year($3); + $$= new (thd->mem_root) Item_func_year($3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8300,34 +8642,27 @@ function_call_keyword: function_call_nonkeyword: ADDDATE_SYM '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $5, + $$= new (thd->mem_root) Item_date_add_interval($3, $5, INTERVAL_DAY, 0); if ($$ == NULL) MYSQL_YYABORT; } | ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 0); + $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 0); if ($$ == NULL) MYSQL_YYABORT; } | CURDATE optional_braces { - $$= new (YYTHD->mem_root) Item_func_curdate_local(); + $$= new (thd->mem_root) Item_func_curdate_local(); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } - | CURTIME optional_braces + | CURTIME opt_time_precision { - $$= new (YYTHD->mem_root) Item_func_curtime_local(); - if ($$ == NULL) - MYSQL_YYABORT; - Lex->safe_to_cache_query=0; - } - | CURTIME '(' expr ')' - { - $$= new (YYTHD->mem_root) Item_func_curtime_local($3); + $$= new (thd->mem_root) Item_func_curtime_local($2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; @@ -8335,87 +8670,80 @@ function_call_nonkeyword: | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM { - $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,0); + $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,0); if ($$ == NULL) MYSQL_YYABORT; } | DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM { - $$= new (YYTHD->mem_root) Item_date_add_interval($3,$6,$7,1); + $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,1); if ($$ == NULL) MYSQL_YYABORT; } | EXTRACT_SYM '(' interval FROM expr ')' { - $$=new (YYTHD->mem_root) Item_extract( $3, $5); + $$=new (thd->mem_root) Item_extract( $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | GET_FORMAT '(' date_time_type ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_get_format($3, $5); - if ($$ == NULL) - MYSQL_YYABORT; - } - | NOW_SYM optional_braces - { - $$= new (YYTHD->mem_root) Item_func_now_local(); + $$= new (thd->mem_root) Item_func_get_format($3, $5); if ($$ == NULL) MYSQL_YYABORT; - Lex->safe_to_cache_query=0; } - | NOW_SYM '(' expr ')' + | NOW_SYM opt_time_precision { - $$= new (YYTHD->mem_root) Item_func_now_local($3); + $$= new (thd->mem_root) Item_func_now_local($2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | POSITION_SYM '(' bit_expr IN_SYM expr ')' { - $$ = new (YYTHD->mem_root) Item_func_locate($5,$3); + $$ = new (thd->mem_root) Item_func_locate($5,$3); if ($$ == NULL) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $5, + $$= new (thd->mem_root) Item_date_add_interval($3, $5, INTERVAL_DAY, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { - $$= new (YYTHD->mem_root) Item_date_add_interval($3, $6, $7, 1); + $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); + $$= new (thd->mem_root) Item_func_substr($3,$5,$7); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_substr($3,$5); + $$= new (thd->mem_root) Item_func_substr($3,$5); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr FOR_SYM expr ')' { - $$= new (YYTHD->mem_root) Item_func_substr($3,$5,$7); + $$= new (thd->mem_root) Item_func_substr($3,$5,$7); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr ')' { - $$= new (YYTHD->mem_root) Item_func_substr($3,$5); + $$= new (thd->mem_root) Item_func_substr($3,$5); if ($$ == NULL) MYSQL_YYABORT; } - | SYSDATE optional_braces + | SYSDATE opt_time_precision { /* Unlike other time-related functions, SYSDATE() is @@ -8426,56 +8754,91 @@ function_call_nonkeyword: */ Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); if (global_system_variables.sysdate_is_now == 0) - $$= new (YYTHD->mem_root) Item_func_sysdate_local(); + $$= new (thd->mem_root) Item_func_sysdate_local($2); else - $$= new (YYTHD->mem_root) Item_func_now_local(); - if ($$ == NULL) - MYSQL_YYABORT; - Lex->safe_to_cache_query=0; - } - | SYSDATE '(' expr ')' - { - if (global_system_variables.sysdate_is_now == 0) - $$= new (YYTHD->mem_root) Item_func_sysdate_local($3); - else - $$= new (YYTHD->mem_root) Item_func_now_local($3); + $$= new (thd->mem_root) Item_func_now_local($2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_date_add_interval($7,$5,$3,0); + $$= new (thd->mem_root) Item_date_add_interval($7,$5,$3,0); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_timestamp_diff($5,$7,$3); + $$= new (thd->mem_root) Item_func_timestamp_diff($5,$7,$3); if ($$ == NULL) MYSQL_YYABORT; } | UTC_DATE_SYM optional_braces { - $$= new (YYTHD->mem_root) Item_func_curdate_utc(); + $$= new (thd->mem_root) Item_func_curdate_utc(); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } - | UTC_TIME_SYM optional_braces + | UTC_TIME_SYM opt_time_precision { - $$= new (YYTHD->mem_root) Item_func_curtime_utc(); + $$= new (thd->mem_root) Item_func_curtime_utc($2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } - | UTC_TIMESTAMP_SYM optional_braces + | UTC_TIMESTAMP_SYM opt_time_precision { - $$= new (YYTHD->mem_root) Item_func_now_utc(); + $$= new (thd->mem_root) Item_func_now_utc($2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } + | + COLUMN_ADD_SYM '(' expr ',' dyncall_create_list ')' + { + $$= create_func_dyncol_add(thd, $3, *$5); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + COLUMN_DELETE_SYM '(' expr ',' expr_list ')' + { + $$= create_func_dyncol_delete(thd, $3, *$5); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + COLUMN_EXISTS_SYM '(' expr ',' expr ')' + { + $$= new (thd->mem_root) Item_func_dyncol_exists($3, $5); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + COLUMN_LIST_SYM '(' expr ')' + { + $$= new (thd->mem_root) Item_func_dyncol_list($3); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + COLUMN_CREATE_SYM '(' dyncall_create_list ')' + { + $$= create_func_dyncol_create(thd, *$3); + if ($$ == NULL) + MYSQL_YYABORT; + } + | + COLUMN_GET_SYM '(' expr ',' expr AS cast_type ')' + { + LEX *lex= Lex; + $$= create_func_dyncol_get(thd, $3, $5, $7, + lex->length, lex->dec, + lex->charset); + if ($$ == NULL) + MYSQL_YYABORT; + } ; /* @@ -8486,62 +8849,67 @@ function_call_nonkeyword: function_call_conflict: ASCII_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_ascii($3); + $$= new (thd->mem_root) Item_func_ascii($3); if ($$ == NULL) MYSQL_YYABORT; } | CHARSET '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_charset($3); + $$= new (thd->mem_root) Item_func_charset($3); if ($$ == NULL) MYSQL_YYABORT; } | COALESCE '(' expr_list ')' { - $$= new (YYTHD->mem_root) Item_func_coalesce(* $3); + $$= new (thd->mem_root) Item_func_coalesce(* $3); if ($$ == NULL) MYSQL_YYABORT; } | COLLATION_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_collation($3); + $$= new (thd->mem_root) Item_func_collation($3); if ($$ == NULL) MYSQL_YYABORT; } | DATABASE '(' ')' { - $$= new (YYTHD->mem_root) Item_func_database(); + $$= new (thd->mem_root) Item_func_database(); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | IF '(' expr ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_if($3,$5,$7); + $$= new (thd->mem_root) Item_func_if($3,$5,$7); + if ($$ == NULL) + MYSQL_YYABORT; + } + | LAST_VALUE '(' expr_list ')' + { + $$= new (thd->mem_root) Item_func_last_value(* $3); if ($$ == NULL) MYSQL_YYABORT; } | MICROSECOND_SYM '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_microsecond($3); + $$= new (thd->mem_root) Item_func_microsecond($3); if ($$ == NULL) MYSQL_YYABORT; } | MOD_SYM '(' expr ',' expr ')' { - $$ = new (YYTHD->mem_root) Item_func_mod($3, $5); + $$ = new (thd->mem_root) Item_func_mod($3, $5); if ($$ == NULL) MYSQL_YYABORT; } | OLD_PASSWORD '(' expr ')' { - $$= new (YYTHD->mem_root) Item_func_old_password($3); + $$= new (thd->mem_root) Item_func_old_password($3); if ($$ == NULL) MYSQL_YYABORT; } | PASSWORD '(' expr ')' { - THD *thd= YYTHD; Item* i1; if (thd->variables.old_passwords) i1= new (thd->mem_root) Item_func_old_password($3); @@ -8553,31 +8921,30 @@ function_call_conflict: } | QUARTER_SYM '(' expr ')' { - $$ = new (YYTHD->mem_root) Item_func_quarter($3); + $$ = new (thd->mem_root) Item_func_quarter($3); if ($$ == NULL) MYSQL_YYABORT; } | REPEAT_SYM '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_repeat($3,$5); + $$= new (thd->mem_root) Item_func_repeat($3,$5); if ($$ == NULL) MYSQL_YYABORT; } | REPLACE '(' expr ',' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_replace($3,$5,$7); + $$= new (thd->mem_root) Item_func_replace($3,$5,$7); if ($$ == NULL) MYSQL_YYABORT; } | TRUNCATE_SYM '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_round($3,$5,1); + $$= new (thd->mem_root) Item_func_round($3,$5,1); if ($$ == NULL) MYSQL_YYABORT; } | WEEK_SYM '(' expr ')' { - THD *thd= YYTHD; Item *i1= new (thd->mem_root) Item_int((char*) "0", thd->variables.default_week_format, 1); @@ -8589,7 +8956,7 @@ function_call_conflict: } | WEEK_SYM '(' expr ',' expr ')' { - $$= new (YYTHD->mem_root) Item_func_week($3,$5); + $$= new (thd->mem_root) Item_func_week($3,$5); if ($$ == NULL) MYSQL_YYABORT; } @@ -8611,52 +8978,52 @@ function_call_conflict: geometry_function: CONTAINS_SYM '(' expr ',' expr ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_rel($3, $5, Item_func::SP_CONTAINS_FUNC)); } | GEOMETRYCOLLECTION '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_geometrycollection, Geometry::wkb_point)); } | LINESTRING '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_linestring, Geometry::wkb_point)); } | MULTILINESTRING '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_multilinestring, Geometry::wkb_linestring)); } | MULTIPOINT '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_multipoint, Geometry::wkb_point)); } | MULTIPOLYGON '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_multipolygon, Geometry::wkb_polygon)); } | POINT_SYM '(' expr ',' expr ')' { - $$= GEOM_NEW(YYTHD, Item_func_point($3,$5)); + $$= GEOM_NEW(thd, Item_func_point($3,$5)); } | POLYGON '(' expr_list ')' { - $$= GEOM_NEW(YYTHD, + $$= GEOM_NEW(thd, Item_func_spatial_collection(* $3, Geometry::wkb_polygon, Geometry::wkb_linestring)); @@ -8694,7 +9061,6 @@ function_call_generic: } opt_udf_expr_list ')' { - THD *thd= YYTHD; Create_func *builder; Item *item= NULL; @@ -8748,7 +9114,6 @@ function_call_generic: } | ident '.' ident '(' opt_expr_list ')' { - THD *thd= YYTHD; Create_qfunc *builder; Item *item= NULL; @@ -8778,7 +9143,7 @@ function_call_generic: builder= find_qualified_function_builder(thd); DBUG_ASSERT(builder); - item= builder->create(thd, $1, $3, true, $5); + item= builder->create_with_db(thd, $1, $3, true, $5); if (! ($$= item)) { @@ -8812,7 +9177,7 @@ opt_udf_expr_list: udf_expr_list: udf_expr { - $$= new (YYTHD->mem_root) List<Item>; + $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; $$->push_back($1); @@ -8845,7 +9210,7 @@ udf_expr: remember_name we may get quoted or escaped names. */ else if ($2->type() != Item::FIELD_ITEM) - $2->set_name($1, (uint) ($3 - $1), YYTHD->charset()); + $2->set_name($1, (uint) ($3 - $1), thd->charset()); $$= $2; } ; @@ -8853,46 +9218,46 @@ udf_expr: sum_expr: AVG_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_avg($3, FALSE); + $$= new (thd->mem_root) Item_sum_avg($3, FALSE); if ($$ == NULL) MYSQL_YYABORT; } | AVG_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_avg($4, TRUE); + $$= new (thd->mem_root) Item_sum_avg($4, TRUE); if ($$ == NULL) MYSQL_YYABORT; } | BIT_AND '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_and($3); + $$= new (thd->mem_root) Item_sum_and($3); if ($$ == NULL) MYSQL_YYABORT; } | BIT_OR '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_or($3); + $$= new (thd->mem_root) Item_sum_or($3); if ($$ == NULL) MYSQL_YYABORT; } | BIT_XOR '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_xor($3); + $$= new (thd->mem_root) Item_sum_xor($3); if ($$ == NULL) MYSQL_YYABORT; } | COUNT_SYM '(' opt_all '*' ')' { - Item *item= new (YYTHD->mem_root) Item_int((int32) 0L,1); + Item *item= new (thd->mem_root) Item_int((int32) 0L,1); if (item == NULL) MYSQL_YYABORT; - $$= new (YYTHD->mem_root) Item_sum_count(item); + $$= new (thd->mem_root) Item_sum_count(item); if ($$ == NULL) MYSQL_YYABORT; } | COUNT_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_count($3); + $$= new (thd->mem_root) Item_sum_count($3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8902,13 +9267,13 @@ sum_expr: { Select->in_sum_expr--; } ')' { - $$= new (YYTHD->mem_root) Item_sum_count(* $5); + $$= new (thd->mem_root) Item_sum_count(* $5); if ($$ == NULL) MYSQL_YYABORT; } | MIN_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_min($3); + $$= new (thd->mem_root) Item_sum_min($3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8919,55 +9284,55 @@ sum_expr: */ | MIN_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_min($4); + $$= new (thd->mem_root) Item_sum_min($4); if ($$ == NULL) MYSQL_YYABORT; } | MAX_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_max($3); + $$= new (thd->mem_root) Item_sum_max($3); if ($$ == NULL) MYSQL_YYABORT; } | MAX_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_max($4); + $$= new (thd->mem_root) Item_sum_max($4); if ($$ == NULL) MYSQL_YYABORT; } | STD_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_std($3, 0); + $$= new (thd->mem_root) Item_sum_std($3, 0); if ($$ == NULL) MYSQL_YYABORT; } | VARIANCE_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_variance($3, 0); + $$= new (thd->mem_root) Item_sum_variance($3, 0); if ($$ == NULL) MYSQL_YYABORT; } | STDDEV_SAMP_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_std($3, 1); + $$= new (thd->mem_root) Item_sum_std($3, 1); if ($$ == NULL) MYSQL_YYABORT; } | VAR_SAMP_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_variance($3, 1); + $$= new (thd->mem_root) Item_sum_variance($3, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUM_SYM '(' in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_sum($3, FALSE); + $$= new (thd->mem_root) Item_sum_sum($3, FALSE); if ($$ == NULL) MYSQL_YYABORT; } | SUM_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (YYTHD->mem_root) Item_sum_sum($4, TRUE); + $$= new (thd->mem_root) Item_sum_sum($4, TRUE); if ($$ == NULL) MYSQL_YYABORT; } @@ -8979,7 +9344,7 @@ sum_expr: { SELECT_LEX *sel= Select; sel->in_sum_expr--; - $$= new (YYTHD->mem_root) + $$= new (thd->mem_root) Item_func_group_concat(Lex->current_context(), $3, $5, sel->gorder_list, $7); if ($$ == NULL) @@ -9008,20 +9373,20 @@ variable_aux: ident_or_text SET_VAR expr { Item_func_set_user_var *item; - $$= item= new (YYTHD->mem_root) Item_func_set_user_var($1, $3, false); + $$= item= new (thd->mem_root) Item_func_set_user_var($1, $3); if ($$ == NULL) MYSQL_YYABORT; LEX *lex= Lex; - lex->uncacheable(UNCACHEABLE_RAND); + lex->uncacheable(UNCACHEABLE_SIDEEFFECT); lex->set_var_list.push_back(item); } | ident_or_text { - $$= new (YYTHD->mem_root) Item_func_get_user_var($1); + $$= new (thd->mem_root) Item_func_get_user_var($1); if ($$ == NULL) MYSQL_YYABORT; LEX *lex= Lex; - lex->uncacheable(UNCACHEABLE_RAND); + lex->uncacheable(UNCACHEABLE_SIDEEFFECT); } | '@' opt_var_ident_type ident_or_text opt_component { @@ -9031,7 +9396,7 @@ variable_aux: my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; } - if (!($$= get_system_var(YYTHD, $2, $3, $4))) + if (!($$= get_system_var(thd, $2, $3, $4))) MYSQL_YYABORT; if (!((Item_func_get_system_var*) $$)->is_written_to_binlog()) Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE); @@ -9046,7 +9411,7 @@ opt_distinct: opt_gconcat_separator: /* empty */ { - $$= new (YYTHD->mem_root) String(",", 1, &my_charset_latin1); + $$= new (thd->mem_root) String(",", 1, &my_charset_latin1); if ($$ == NULL) MYSQL_YYABORT; } @@ -9073,9 +9438,9 @@ opt_gorder_clause: gorder_list: gorder_list ',' order_ident order_dir - { if (add_gorder_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; } + { if (add_gorder_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } | order_ident order_dir - { if (add_gorder_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; } + { if (add_gorder_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } ; in_sum_expr: @@ -9102,6 +9467,8 @@ cast_type: { $$=ITEM_CAST_CHAR; Lex->dec= 0; } | NCHAR_SYM opt_field_length { $$=ITEM_CAST_CHAR; Lex->charset= national_charset_info; Lex->dec=0; } + | INT_SYM + { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } | SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } | SIGNED_SYM INT_SYM @@ -9112,13 +9479,24 @@ cast_type: { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } | DATE_SYM { $$=ITEM_CAST_DATE; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } - | TIME_SYM - { $$=ITEM_CAST_TIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } - | DATETIME - { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; Lex->dec=Lex->length= (char*)0; } + | TIME_SYM opt_field_length + { + $$=ITEM_CAST_TIME; + LEX *lex= Lex; + lex->charset= NULL; lex->dec= lex->length; lex->length= (char*)0; + } + | DATETIME opt_field_length + { + $$=ITEM_CAST_DATETIME; + LEX *lex= Lex; + lex->charset= NULL; lex->dec= lex->length; lex->length= (char*)0; + } | DECIMAL_SYM float_options { $$=ITEM_CAST_DECIMAL; Lex->charset= NULL; } - ; + | DOUBLE_SYM + { Lex->charset= NULL; Lex->length= Lex->dec= 0;} + opt_precision + { $$=ITEM_CAST_DOUBLE; } opt_expr_list: /* empty */ { $$= NULL; } @@ -9128,7 +9506,7 @@ opt_expr_list: expr_list: expr { - $$= new (YYTHD->mem_root) List<Item>; + $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; $$->push_back($1); @@ -9148,7 +9526,7 @@ ident_list_arg: ident_list: simple_ident { - $$= new (YYTHD->mem_root) List<Item>; + $$= new (thd->mem_root) List<Item>; if ($$ == NULL) MYSQL_YYABORT; $$->push_back($1); @@ -9195,7 +9573,10 @@ table_ref: { LEX *lex= Lex; if (!($$= lex->current_select->nest_last_join(lex->thd))) + { + my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; + } } ; @@ -9248,7 +9629,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $3); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(YYTHD, $1, $3)) + if (push_new_name_resolution_context(thd, $1, $3)) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -9263,7 +9644,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $3); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(YYTHD, $1, $3)) + if (push_new_name_resolution_context(thd, $1, $3)) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -9293,7 +9674,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $5); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(YYTHD, $1, $5)) + if (push_new_name_resolution_context(thd, $1, $5)) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -9329,7 +9710,7 @@ join_table: { MYSQL_YYABORT_UNLESS($1 && $5); /* Change the current name resolution context to a local context. */ - if (push_new_name_resolution_context(YYTHD, $1, $5)) + if (push_new_name_resolution_context(thd, $1, $5)) MYSQL_YYABORT; Select->parsing_place= IN_ON; } @@ -9384,7 +9765,7 @@ table_factor: } table_ident opt_table_alias opt_key_definition { - if (!($$= Select->add_table_to_list(YYTHD, $2, $3, + if (!($$= Select->add_table_to_list(thd, $2, $3, Select->get_table_join_options(), YYPS->m_lock_type, YYPS->m_mdl_type, @@ -9466,6 +9847,10 @@ table_factor: lex->pop_context(); lex->nest_level--; } + /*else if (($3->select_lex && + $3->select_lex->master_unit()->is_union() && + ($3->select_lex->master_unit()->first_select() == + $3->select_lex || !$3->lifted)) || $5)*/ else if ($5 != NULL) { /* @@ -9659,7 +10044,7 @@ opt_outer: index_hint_clause: /* empty */ { - $$= old_mode ? INDEX_HINT_MASK_JOIN : INDEX_HINT_MASK_ALL; + $$= thd->variables.old_mode ? INDEX_HINT_MASK_JOIN : INDEX_HINT_MASK_ALL; } | FOR_SYM JOIN_SYM { $$= INDEX_HINT_MASK_JOIN; } | FOR_SYM ORDER_SYM BY { $$= INDEX_HINT_MASK_ORDER; } @@ -9691,7 +10076,7 @@ index_hints_list: opt_index_hints_list: /* empty */ - | { Select->alloc_index_hints(YYTHD); } index_hints_list + | { Select->alloc_index_hints(thd); } index_hints_list ; opt_key_definition: @@ -9700,15 +10085,15 @@ opt_key_definition: ; opt_key_usage_list: - /* empty */ { Select->add_index_hint(YYTHD, NULL, 0); } + /* empty */ { Select->add_index_hint(thd, NULL, 0); } | key_usage_list {} ; key_usage_element: ident - { Select->add_index_hint(YYTHD, $1.str, $1.length); } + { Select->add_index_hint(thd, $1.str, $1.length); } | PRIMARY_SYM - { Select->add_index_hint(YYTHD, (char *)"PRIMARY", 7); } + { Select->add_index_hint(thd, (char *)"PRIMARY", 7); } ; key_usage_list: @@ -9721,7 +10106,7 @@ using_list: { if (!($$= new List<String>)) MYSQL_YYABORT; - String *s= new (YYTHD->mem_root) String((const char *) $1.str, + String *s= new (thd->mem_root) String((const char *) $1.str, $1.length, system_charset_info); if (s == NULL) @@ -9730,7 +10115,7 @@ using_list: } | using_list ',' ident { - String *s= new (YYTHD->mem_root) String((const char *) $3.str, + String *s= new (thd->mem_root) String((const char *) $3.str, $3.length, system_charset_info); if (s == NULL) @@ -9804,7 +10189,7 @@ where_clause: expr { SELECT_LEX *select= Select; - select->where= $3; + select->where= normalize_cond($3); select->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -9820,7 +10205,7 @@ having_clause: expr { SELECT_LEX *sel= Select; - sel->having= $3; + sel->having= normalize_cond($3); sel->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -9835,7 +10220,6 @@ opt_escape: } | /* empty */ { - THD *thd= YYTHD; Lex->escape_used= FALSE; $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? new (thd->mem_root) Item_string("", 0, &my_charset_latin1) : @@ -9856,9 +10240,9 @@ group_clause: group_list: group_list ',' order_ident order_dir - { if (add_group_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; } + { if (add_group_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } | order_ident order_dir - { if (add_group_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; } + { if (add_group_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } ; olap_opt: @@ -9919,7 +10303,6 @@ alter_order_list: alter_order_item: simple_ident_nospvar order_dir { - THD *thd= YYTHD; bool ascending= ($2 == 1) ? true : false; if (add_order_to_list(thd, $1, ascending)) MYSQL_YYABORT; @@ -9972,9 +10355,9 @@ order_clause: order_list: order_list ',' order_ident order_dir - { if (add_order_to_list(YYTHD, $3,(bool) $4)) MYSQL_YYABORT; } + { if (add_order_to_list(thd, $3,(bool) $4)) MYSQL_YYABORT; } | order_ident order_dir - { if (add_order_to_list(YYTHD, $1,(bool) $2)) MYSQL_YYABORT; } + { if (add_order_to_list(thd, $1,(bool) $2)) MYSQL_YYABORT; } ; order_dir: @@ -9990,6 +10373,7 @@ opt_limit_clause_init: SELECT_LEX *sel= lex->current_select; sel->offset_limit= 0; sel->select_limit= 0; + lex->limit_rows_examined= 0; } | limit_clause {} ; @@ -10004,6 +10388,14 @@ limit_clause: { Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT); } + | LIMIT limit_options ROWS_SYM EXAMINED_SYM limit_rows_option + { + Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT); + } + | LIMIT ROWS_SYM EXAMINED_SYM limit_rows_option + { + Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT); + } ; limit_options: @@ -10034,7 +10426,6 @@ limit_option: ident { Item_splocal *splocal; - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= & thd->m_parser_state->m_lip; sp_variable_t *spv; @@ -10071,24 +10462,31 @@ limit_option: } | ULONGLONG_NUM { - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | LONG_NUM { - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | NUM { - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } ; +limit_rows_option: + limit_option + { + LEX *lex=Lex; + lex->limit_rows_examined= $1; + } + delete_limit_clause: /* empty */ { @@ -10102,6 +10500,14 @@ delete_limit_clause: Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_LIMIT); sel->explicit_limit= 1; } + | LIMIT ROWS_SYM EXAMINED_SYM { my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; } + | LIMIT limit_option ROWS_SYM EXAMINED_SYM { my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; } + ; + +int_num: + NUM { int error; $$= (int) my_strtoll10($1.str, (char**) 0, &error); } + | '-' NUM { int error; $$= -(int) my_strtoll10($2.str, (char**) 0, &error); } + | '-' LONG_NUM { int error; $$= -(int) my_strtoll10($2.str, (char**) 0, &error); } ; ulong_num: @@ -10132,6 +10538,7 @@ ulonglong_num: real_ulonglong_num: NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } | ULONGLONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } + | HEX_NUM { $$= strtoull($1.str, (char**) 0, 16); } | LONG_NUM { int error; $$= (ulonglong) my_strtoll10($1.str, (char**) 0, &error); } | dec_num_error { MYSQL_YYABORT; } ; @@ -10146,6 +10553,11 @@ dec_num: | FLOAT_NUM ; +choice: + ulong_num { $$= $1 != 0 ? HA_CHOICE_YES : HA_CHOICE_NO; } + | DEFAULT { $$= HA_CHOICE_UNDEF; } + ; + procedure_clause: /* empty */ | PROCEDURE_SYM ident /* Procedure name */ @@ -10166,7 +10578,7 @@ procedure_clause: lex->proc_list.elements=0; lex->proc_list.first=0; lex->proc_list.next= &lex->proc_list.first; - Item_field *item= new (YYTHD->mem_root) + Item_field *item= new (thd->mem_root) Item_field(&lex->current_select->context, NULL, NULL, $2.str); if (item == NULL) @@ -10191,8 +10603,6 @@ procedure_list2: procedure_item: remember_name expr remember_end { - THD *thd= YYTHD; - if (add_proc_to_list(thd, $2)) MYSQL_YYABORT; if (!$2->name) @@ -10366,7 +10776,6 @@ drop: } | DROP FUNCTION_SYM if_exists ident '.' ident { - THD *thd= YYTHD; LEX *lex= thd->lex; sp_name *spname; if ($4.str && check_db_name(&$4)) @@ -10389,7 +10798,6 @@ drop: } | DROP FUNCTION_SYM if_exists ident { - THD *thd= YYTHD; LEX *lex= thd->lex; LEX_STRING db= {0, 0}; sp_name *spname; @@ -10474,7 +10882,7 @@ table_list: table_name: table_ident { - if (!Select->add_table_to_list(YYTHD, $1, NULL, + if (!Select->add_table_to_list(thd, $1, NULL, TL_OPTION_UPDATING, YYPS->m_lock_type, YYPS->m_mdl_type)) @@ -10490,7 +10898,7 @@ table_alias_ref_list: table_alias_ref: table_ident_opt_wild { - if (!Select->add_table_to_list(YYTHD, $1, NULL, + if (!Select->add_table_to_list(thd, $1, NULL, TL_OPTION_UPDATING | TL_OPTION_ALIAS, YYPS->m_lock_type, YYPS->m_mdl_type)) @@ -10549,22 +10957,18 @@ replace: insert_lock_option: /* empty */ { -#ifdef HAVE_QUERY_CACHE /* - If it is SP we do not allow insert optimisation whan result of + If it is SP we do not allow insert optimisation when result of insert visible only after the table unlocking but everyone can read table. */ $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); -#else - $$= TL_WRITE_CONCURRENT_INSERT; -#endif } | LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; } | DELAYED_SYM { Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() - - YYTHD->query()); + thd->query()); Lex->keyword_delayed_end_offset= Lex->keyword_delayed_begin_offset + YYLIP->yyLength() + 1; $$= TL_WRITE_DELAYED; @@ -10577,7 +10981,7 @@ replace_lock_option: | DELAYED_SYM { Lex->keyword_delayed_begin_offset= (uint)(YYLIP->get_tok_start() - - YYTHD->query()); + thd->query()); Lex->keyword_delayed_end_offset= Lex->keyword_delayed_begin_offset + YYLIP->yyLength() + 1; $$= TL_WRITE_DELAYED; @@ -10694,7 +11098,7 @@ expr_or_default: expr { $$= $1;} | DEFAULT { - $$= new (YYTHD->mem_root) Item_default_value(Lex->current_context()); + $$= new (thd->mem_root) Item_default_value(Lex->current_context()); if ($$ == NULL) MYSQL_YYABORT; } @@ -10747,7 +11151,7 @@ update_list: update_elem: simple_ident_nospvar equal expr_or_default { - if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3)) + if (add_item_to_list(thd, $1) || add_value_to_list(thd, $3)) MYSQL_YYABORT; } ; @@ -10792,7 +11196,7 @@ delete: single_multi: FROM table_ident { - if (!Select->add_table_to_list(YYTHD, $2, NULL, TL_OPTION_UPDATING, + if (!Select->add_table_to_list(thd, $2, NULL, TL_OPTION_UPDATING, YYPS->m_lock_type, YYPS->m_mdl_type)) MYSQL_YYABORT; @@ -10836,7 +11240,7 @@ table_wild_one: Table_ident *ti= new Table_ident($1); if (ti == NULL) MYSQL_YYABORT; - if (!Select->add_table_to_list(YYTHD, + if (!Select->add_table_to_list(thd, ti, NULL, TL_OPTION_UPDATING | TL_OPTION_ALIAS, @@ -10846,10 +11250,10 @@ table_wild_one: } | ident '.' ident opt_wild { - Table_ident *ti= new Table_ident(YYTHD, $1, $3, 0); + Table_ident *ti= new Table_ident(thd, $1, $3, 0); if (ti == NULL) MYSQL_YYABORT; - if (!Select->add_table_to_list(YYTHD, + if (!Select->add_table_to_list(thd, ti, NULL, TL_OPTION_UPDATING | TL_OPTION_ALIAS, @@ -10889,7 +11293,6 @@ truncate: } table_name { - THD *thd= YYTHD; LEX* lex= thd->lex; DBUG_ASSERT(!lex->m_stmt); lex->m_stmt= new (thd->mem_root) Truncate_statement(lex); @@ -10983,7 +11386,7 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_DATABASES; - if (prepare_schema_table(YYTHD, lex, 0, SCH_SCHEMATA)) + if (prepare_schema_table(thd, lex, 0, SCH_SCHEMATA)) MYSQL_YYABORT; } | opt_full TABLES opt_db wild_and_where @@ -10991,7 +11394,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TABLES; lex->select_lex.db= $3; - if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES)) + if (prepare_schema_table(thd, lex, 0, SCH_TABLE_NAMES)) MYSQL_YYABORT; } | opt_full TRIGGERS_SYM opt_db wild_and_where @@ -10999,7 +11402,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TRIGGERS; lex->select_lex.db= $3; - if (prepare_schema_table(YYTHD, lex, 0, SCH_TRIGGERS)) + if (prepare_schema_table(thd, lex, 0, SCH_TRIGGERS)) MYSQL_YYABORT; } | EVENTS_SYM opt_db wild_and_where @@ -11007,7 +11410,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_EVENTS; lex->select_lex.db= $2; - if (prepare_schema_table(YYTHD, lex, 0, SCH_EVENTS)) + if (prepare_schema_table(thd, lex, 0, SCH_EVENTS)) MYSQL_YYABORT; } | TABLE_SYM STATUS_SYM opt_db wild_and_where @@ -11015,7 +11418,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_TABLE_STATUS; lex->select_lex.db= $3; - if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLES)) + if (prepare_schema_table(thd, lex, 0, SCH_TABLES)) MYSQL_YYABORT; } | OPEN_SYM TABLES opt_db wild_and_where @@ -11023,14 +11426,14 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_OPEN_TABLES; lex->select_lex.db= $3; - if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES)) + if (prepare_schema_table(thd, lex, 0, SCH_OPEN_TABLES)) MYSQL_YYABORT; } | PLUGINS_SYM { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_PLUGINS; - if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS)) + if (prepare_schema_table(thd, lex, 0, SCH_PLUGINS)) MYSQL_YYABORT; } | ENGINE_SYM known_storage_engines show_engine_param @@ -11043,7 +11446,7 @@ show_param: lex->sql_command= SQLCOM_SHOW_FIELDS; if ($5) $4->change_db($5); - if (prepare_schema_table(YYTHD, lex, $4, SCH_COLUMNS)) + if (prepare_schema_table(thd, lex, $4, SCH_COLUMNS)) MYSQL_YYABORT; } | master_or_binary LOGS_SYM @@ -11070,21 +11473,21 @@ show_param: lex->sql_command= SQLCOM_SHOW_KEYS; if ($4) $3->change_db($4); - if (prepare_schema_table(YYTHD, lex, $3, SCH_STATISTICS)) + if (prepare_schema_table(thd, lex, $3, SCH_STATISTICS)) MYSQL_YYABORT; } | opt_storage ENGINES_SYM { LEX *lex=Lex; lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES; - if (prepare_schema_table(YYTHD, lex, 0, SCH_ENGINES)) + if (prepare_schema_table(thd, lex, 0, SCH_ENGINES)) MYSQL_YYABORT; } | AUTHORS_SYM { LEX *lex=Lex; lex->sql_command= SQLCOM_SHOW_AUTHORS; - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, ER(ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), "SHOW AUTHORS"); @@ -11093,7 +11496,7 @@ show_param: { LEX *lex=Lex; lex->sql_command= SQLCOM_SHOW_CONTRIBUTORS; - push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, ER(ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), "SHOW CONTRIBUTORS"); @@ -11117,7 +11520,7 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_PROFILE; - if (prepare_schema_table(YYTHD, lex, NULL, SCH_PROFILES) != 0) + if (prepare_schema_table(thd, lex, NULL, SCH_PROFILES) != 0) YYABORT; } | opt_var_type STATUS_SYM wild_and_where @@ -11125,7 +11528,7 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS; lex->option_type= $1; - if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS)) + if (prepare_schema_table(thd, lex, 0, SCH_STATUS)) MYSQL_YYABORT; } | opt_full PROCESSLIST_SYM @@ -11135,21 +11538,21 @@ show_param: LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_VARIABLES; lex->option_type= $1; - if (prepare_schema_table(YYTHD, lex, 0, SCH_VARIABLES)) + if (prepare_schema_table(thd, lex, 0, SCH_VARIABLES)) MYSQL_YYABORT; } | charset wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_CHARSETS; - if (prepare_schema_table(YYTHD, lex, 0, SCH_CHARSETS)) + if (prepare_schema_table(thd, lex, 0, SCH_CHARSETS)) MYSQL_YYABORT; } | COLLATION_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_COLLATIONS; - if (prepare_schema_table(YYTHD, lex, 0, SCH_COLLATIONS)) + if (prepare_schema_table(thd, lex, 0, SCH_COLLATIONS)) MYSQL_YYABORT; } | GRANTS @@ -11179,7 +11582,7 @@ show_param: { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE; - if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0)) + if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0)) MYSQL_YYABORT; lex->only_view= 0; lex->create_info.storage_media= HA_SM_DEFAULT; @@ -11188,7 +11591,7 @@ show_param: { LEX *lex= Lex; lex->sql_command = SQLCOM_SHOW_CREATE; - if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL, 0)) + if (!lex->select_lex.add_table_to_list(thd, $3, NULL, 0)) MYSQL_YYABORT; lex->only_view= 1; } @@ -11200,6 +11603,34 @@ show_param: { Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT; } + | CLIENT_STATS_SYM + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_SHOW_CLIENT_STATS; + if (prepare_schema_table(thd, lex, 0, SCH_CLIENT_STATS)) + MYSQL_YYABORT; + } + | USER_STATS_SYM + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_SHOW_USER_STATS; + if (prepare_schema_table(thd, lex, 0, SCH_USER_STATS)) + MYSQL_YYABORT; + } + | TABLE_STATS_SYM + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_SHOW_TABLE_STATS; + if (prepare_schema_table(thd, lex, 0, SCH_TABLE_STATS)) + MYSQL_YYABORT; + } + | INDEX_STATS_SYM + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_SHOW_INDEX_STATS; + if (prepare_schema_table(thd, lex, 0, SCH_INDEX_STATS)) + MYSQL_YYABORT; + } | CREATE PROCEDURE_SYM sp_name { LEX *lex= Lex; @@ -11224,14 +11655,14 @@ show_param: { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_PROC; - if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES)) + if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) MYSQL_YYABORT; } | FUNCTION_SYM STATUS_SYM wild_and_where { LEX *lex= Lex; lex->sql_command= SQLCOM_SHOW_STATUS_FUNC; - if (prepare_schema_table(YYTHD, lex, 0, SCH_PROCEDURES)) + if (prepare_schema_table(thd, lex, 0, SCH_PROCEDURES)) MYSQL_YYABORT; } | PROCEDURE_SYM CODE_SYM sp_name @@ -11299,14 +11730,14 @@ wild_and_where: /* empty */ | LIKE TEXT_STRING_sys { - Lex->wild= new (YYTHD->mem_root) String($2.str, $2.length, + Lex->wild= new (thd->mem_root) String($2.str, $2.length, system_charset_info); if (Lex->wild == NULL) MYSQL_YYABORT; } | WHERE expr { - Select->where= $2; + Select->where= normalize_cond($2); if ($2) $2->top_level_item(); } @@ -11322,7 +11753,7 @@ describe: lex->sql_command= SQLCOM_SHOW_FIELDS; lex->select_lex.db= 0; lex->verbose= 0; - if (prepare_schema_table(YYTHD, lex, $2, SCH_COLUMNS)) + if (prepare_schema_table(thd, lex, $2, SCH_COLUMNS)) MYSQL_YYABORT; } opt_describe_column @@ -11354,7 +11785,7 @@ opt_describe_column: | text_string { Lex->wild= $1; } | ident { - Lex->wild= new (YYTHD->mem_root) String((const char*) $1.str, + Lex->wild= new (thd->mem_root) String((const char*) $1.str, $1.length, system_charset_info); if (Lex->wild == NULL) @@ -11395,10 +11826,10 @@ flush_options: opt_with_read_lock: /* empty */ {} - | WITH READ_SYM LOCK_SYM + | WITH READ_SYM LOCK_SYM optional_flush_tables_arguments { TABLE_LIST *tables= Lex->query_tables; - Lex->type|= REFRESH_READ_LOCK; + Lex->type|= REFRESH_READ_LOCK | $4; for (; tables; tables= tables->next_global) { tables->mdl_request.set_type(MDL_SHARED_NO_WRITE); @@ -11442,6 +11873,14 @@ flush_option: Lex->type|= REFRESH_SLAVE; Lex->reset_slave_info.all= false; } + | CLIENT_STATS_SYM + { Lex->type|= REFRESH_CLIENT_STATS; } + | USER_STATS_SYM + { Lex->type|= REFRESH_USER_STATS; } + | TABLE_STATS_SYM + { Lex->type|= REFRESH_TABLE_STATS; } + | INDEX_STATS_SYM + { Lex->type|= REFRESH_INDEX_STATS; } | MASTER_SYM { Lex->type|= REFRESH_MASTER; } | DES_KEY_FILE @@ -11455,6 +11894,10 @@ opt_table_list: | table_list {} ; +optional_flush_tables_arguments: + /* empty */ {$$= 0;} + | AND_SYM DISABLE_SYM CHECKPOINT_SYM {$$= REFRESH_CHECKPOINT; } + reset: RESET_SYM { @@ -11514,19 +11957,41 @@ purge_option: /* kill threads */ kill: - KILL_SYM kill_option expr + KILL_SYM { LEX *lex=Lex; lex->value_list.empty(); - lex->value_list.push_front($3); + lex->users_list.empty(); lex->sql_command= SQLCOM_KILL; } + kill_type kill_option kill_expr + { + Lex->kill_signal= (killed_state) ($3 | $4); + } ; +kill_type: + /* Empty */ { $$= (int) KILL_HARD_BIT; } + | HARD_SYM { $$= (int) KILL_HARD_BIT; } + | SOFT_SYM { $$= 0; } + kill_option: - /* empty */ { Lex->type= 0; } - | CONNECTION_SYM { Lex->type= 0; } - | QUERY_SYM { Lex->type= ONLY_KILL_QUERY; } + /* empty */ { $$= (int) KILL_CONNECTION; } + | CONNECTION_SYM { $$= (int) KILL_CONNECTION; } + | QUERY_SYM { $$= (int) KILL_QUERY; } + ; + +kill_expr: + expr + { + Lex->value_list.push_front($$); + Lex->kill_type= KILL_TYPE_ID; + } + | USER user + { + Lex->users_list.push_back($2); + Lex->kill_type= KILL_TYPE_USER; + } ; /* change database */ @@ -11545,7 +12010,6 @@ use: load: LOAD data_or_xml { - THD *thd= YYTHD; LEX *lex= thd->lex; if (lex->sphead) @@ -11568,7 +12032,7 @@ load: opt_duplicate INTO TABLE_SYM table_ident { LEX *lex=Lex; - if (!Select->add_table_to_list(YYTHD, $12, NULL, TL_OPTION_UPDATING, + if (!Select->add_table_to_list(thd, $12, NULL, TL_OPTION_UPDATING, $4, MDL_SHARED_WRITE)) MYSQL_YYABORT; lex->field_list.empty(); @@ -11597,15 +12061,11 @@ load_data_lock: /* empty */ { $$= TL_WRITE_DEFAULT; } | CONCURRENT { -#ifdef HAVE_QUERY_CACHE /* - Ignore this option in SP to avoid problem with query cache + Ignore this option in SP to avoid problem with query cache and + triggers with non default priority locks */ - if (Lex->sphead != 0) - $$= TL_WRITE_DEFAULT; - else -#endif - $$= TL_WRITE_CONCURRENT_INSERT; + $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); } | LOW_PRIORITY { $$= TL_WRITE_LOW_PRIORITY; } ; @@ -11711,7 +12171,7 @@ field_or_var: simple_ident_nospvar {$$= $1;} | '@' ident_or_text { - $$= new (YYTHD->mem_root) Item_user_var_as_out_param($2); + $$= new (thd->mem_root) Item_user_var_as_out_param($2); if ($$ == NULL) MYSQL_YYABORT; } @@ -11731,17 +12191,10 @@ load_data_set_elem: simple_ident_nospvar equal remember_name expr_or_default remember_end { LEX *lex= Lex; - uint length= (uint) ($5 - $3); - String *val= new (YYTHD->mem_root) String($3, - length, - YYTHD->charset()); - if (val == NULL) - MYSQL_YYABORT; - if (lex->update_list.push_back($1) || - lex->value_list.push_back($4) || - lex->load_set_str_list.push_back(val)) + if (lex->update_list.push_back($1) || + lex->value_list.push_back($4)) MYSQL_YYABORT; - $4->set_name($3, length, YYTHD->charset()); + $4->set_name_no_truncate($3, (uint) ($5 - $3), thd->charset()); } ; @@ -11751,7 +12204,6 @@ text_literal: TEXT_STRING { LEX_STRING tmp; - THD *thd= YYTHD; CHARSET_INFO *cs_con= thd->variables.collation_connection; CHARSET_INFO *cs_cli= thd->variables.character_set_client; uint repertoire= thd->lex->text_string_is_7bit && @@ -11777,7 +12229,7 @@ text_literal: uint repertoire= Lex->text_string_is_7bit ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30; DBUG_ASSERT(my_charset_is_ascii_based(national_charset_info)); - $$= new (YYTHD->mem_root) Item_string($1.str, $1.length, + $$= new (thd->mem_root) Item_string($1.str, $1.length, national_charset_info, DERIVATION_COERCIBLE, repertoire); @@ -11786,7 +12238,7 @@ text_literal: } | UNDERSCORE_CHARSET TEXT_STRING { - Item_string *str= new (YYTHD->mem_root) Item_string($2.str, + Item_string *str= new (thd->mem_root) Item_string($2.str, $2.length, $1); if (str == NULL) MYSQL_YYABORT; @@ -11805,7 +12257,7 @@ text_literal: If the string has been pure ASCII so far, check the new part. */ - CHARSET_INFO *cs= YYTHD->variables.collation_connection; + CHARSET_INFO *cs= thd->variables.collation_connection; item->collation.repertoire|= my_string_repertoire(cs, $2.str, $2.length); @@ -11816,15 +12268,15 @@ text_literal: text_string: TEXT_STRING_literal { - $$= new (YYTHD->mem_root) String($1.str, + $$= new (thd->mem_root) String($1.str, $1.length, - YYTHD->variables.collation_connection); + thd->variables.collation_connection); if ($$ == NULL) MYSQL_YYABORT; } | HEX_NUM { - Item *tmp= new (YYTHD->mem_root) Item_hex_string($1.str, $1.length); + Item *tmp= new (thd->mem_root) Item_hex_hybrid($1.str, $1.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -11834,9 +12286,17 @@ text_string: tmp->quick_fix_field(); $$= tmp->val_str((String*) 0); } + | HEX_STRING + { + Item *tmp= new (thd->mem_root) Item_hex_string($1.str, $1.length); + if (tmp == NULL) + MYSQL_YYABORT; + tmp->quick_fix_field(); + $$= tmp->val_str((String*) 0); + } | BIN_NUM { - Item *tmp= new (YYTHD->mem_root) Item_bin_string($1.str, $1.length); + Item *tmp= new (thd->mem_root) Item_bin_string($1.str, $1.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -11851,7 +12311,6 @@ text_string: param_marker: PARAM_MARKER { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; Item_param *item; @@ -11884,38 +12343,44 @@ literal: | NUM_literal { $$ = $1; } | NULL_SYM { - $$ = new (YYTHD->mem_root) Item_null(); + $$ = new (thd->mem_root) Item_null(); if ($$ == NULL) MYSQL_YYABORT; YYLIP->next_state= MY_LEX_OPERATOR_OR_IDENT; } | FALSE_SYM { - $$= new (YYTHD->mem_root) Item_int((char*) "FALSE",0,1); + $$= new (thd->mem_root) Item_int((char*) "FALSE",0,1); if ($$ == NULL) MYSQL_YYABORT; } | TRUE_SYM { - $$= new (YYTHD->mem_root) Item_int((char*) "TRUE",1,1); + $$= new (thd->mem_root) Item_int((char*) "TRUE",1,1); if ($$ == NULL) MYSQL_YYABORT; } | HEX_NUM { - $$ = new (YYTHD->mem_root) Item_hex_string($1.str, $1.length); + $$ = new (thd->mem_root) Item_hex_hybrid($1.str, $1.length); + if ($$ == NULL) + MYSQL_YYABORT; + } + | HEX_STRING + { + $$ = new (thd->mem_root) Item_hex_string($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | BIN_NUM { - $$= new (YYTHD->mem_root) Item_bin_string($1.str, $1.length); + $$= new (thd->mem_root) Item_bin_string($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } - | UNDERSCORE_CHARSET HEX_NUM + | UNDERSCORE_CHARSET hex_num_or_string { - Item *tmp= new (YYTHD->mem_root) Item_hex_string($2.str, $2.length); + Item *tmp= new (thd->mem_root) Item_hex_string($2.str, $2.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -11926,7 +12391,7 @@ literal: String *str= tmp->val_str((String*) 0); Item_string *item_str; - item_str= new (YYTHD->mem_root) + item_str= new (thd->mem_root) Item_string(NULL, /* name will be set in select_item */ str ? str->ptr() : "", str ? str->length() : 0, @@ -11944,7 +12409,7 @@ literal: } | UNDERSCORE_CHARSET BIN_NUM { - Item *tmp= new (YYTHD->mem_root) Item_bin_string($2.str, $2.length); + Item *tmp= new (thd->mem_root) Item_bin_string($2.str, $2.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -11955,7 +12420,7 @@ literal: String *str= tmp->val_str((String*) 0); Item_string *item_str; - item_str= new (YYTHD->mem_root) + item_str= new (thd->mem_root) Item_string(NULL, /* name will be set in select_item */ str ? str->ptr() : "", str ? str->length() : 0, @@ -11979,7 +12444,7 @@ NUM_literal: NUM { int error; - $$= new (YYTHD->mem_root) + $$= new (thd->mem_root) Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); @@ -11989,7 +12454,7 @@ NUM_literal: | LONG_NUM { int error; - $$= new (YYTHD->mem_root) + $$= new (thd->mem_root) Item_int($1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); @@ -11998,23 +12463,23 @@ NUM_literal: } | ULONGLONG_NUM { - $$= new (YYTHD->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint($1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | DECIMAL_NUM { - $$= new (YYTHD->mem_root) Item_decimal($1.str, $1.length, - YYTHD->charset()); - if (($$ == NULL) || (YYTHD->is_error())) + $$= new (thd->mem_root) Item_decimal($1.str, $1.length, + thd->charset()); + if (($$ == NULL) || (thd->is_error())) { MYSQL_YYABORT; } } | FLOAT_NUM { - $$= new (YYTHD->mem_root) Item_float($1.str, $1.length); - if (($$ == NULL) || (YYTHD->is_error())) + $$= new (thd->mem_root) Item_float($1.str, $1.length); + if (($$ == NULL) || (thd->is_error())) { MYSQL_YYABORT; } @@ -12034,7 +12499,7 @@ table_wild: ident '.' '*' { SELECT_LEX *sel= Select; - $$= new (YYTHD->mem_root) Item_field(Lex->current_context(), + $$= new (thd->mem_root) Item_field(Lex->current_context(), NullS, $1.str, "*"); if ($$ == NULL) MYSQL_YYABORT; @@ -12042,7 +12507,6 @@ table_wild: } | ident '.' ident '.' '*' { - THD *thd= YYTHD; SELECT_LEX *sel= Select; const char* schema= thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS : $1.str; @@ -12062,7 +12526,6 @@ order_ident: simple_ident: ident { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; sp_variable_t *spv; @@ -12113,7 +12576,6 @@ simple_ident: simple_ident_nospvar: ident { - THD *thd= YYTHD; SELECT_LEX *sel=Select; if ((sel->parsing_place != IN_HAVING) || (sel->get_in_sum_expr() > 0)) @@ -12135,7 +12597,6 @@ simple_ident_nospvar: simple_ident_q: ident '.' ident { - THD *thd= YYTHD; LEX *lex= thd->lex; /* @@ -12214,7 +12675,6 @@ simple_ident_q: } | '.' ident '.' ident { - THD *thd= YYTHD; LEX *lex= thd->lex; SELECT_LEX *sel= lex->current_select; if (sel->no_table_names_allowed) @@ -12239,7 +12699,6 @@ simple_ident_q: } | ident '.' ident '.' ident { - THD *thd= YYTHD; LEX *lex= thd->lex; SELECT_LEX *sel= lex->current_select; const char* schema= (thd->client_capabilities & CLIENT_NO_SCHEMA ? @@ -12307,7 +12766,7 @@ table_ident: } | ident '.' ident { - $$= new Table_ident(YYTHD, $1,$3,0); + $$= new Table_ident(thd, $1,$3,0); if ($$ == NULL) MYSQL_YYABORT; } @@ -12329,7 +12788,7 @@ table_ident_opt_wild: } | ident '.' ident opt_wild { - $$= new Table_ident(YYTHD, $1,$3,0); + $$= new Table_ident(thd, $1,$3,0); if ($$ == NULL) MYSQL_YYABORT; } @@ -12339,7 +12798,7 @@ table_ident_nodb: ident { LEX_STRING db={(char*) any_db,3}; - $$= new Table_ident(YYTHD, db,$1,0); + $$= new Table_ident(thd, db,$1,0); if ($$ == NULL) MYSQL_YYABORT; } @@ -12349,8 +12808,6 @@ IDENT_sys: IDENT { $$= $1; } | IDENT_QUOTED { - THD *thd= YYTHD; - if (thd->charset_is_system_charset) { CHARSET_INFO *cs= system_charset_info; @@ -12379,8 +12836,6 @@ IDENT_sys: TEXT_STRING_sys: TEXT_STRING { - THD *thd= YYTHD; - if (thd->charset_is_system_charset) $$= $1; else @@ -12395,8 +12850,6 @@ TEXT_STRING_sys: TEXT_STRING_literal: TEXT_STRING { - THD *thd= YYTHD; - if (thd->charset_is_collation_connection) $$= $1; else @@ -12411,8 +12864,6 @@ TEXT_STRING_literal: TEXT_STRING_filesystem: TEXT_STRING { - THD *thd= YYTHD; - if (thd->charset_is_character_set_filesystem) $$= $1; else @@ -12429,7 +12880,6 @@ ident: IDENT_sys { $$=$1; } | keyword { - THD *thd= YYTHD; $$.str= thd->strmake($1.str, $1.length); if ($$.str == NULL) MYSQL_YYABORT; @@ -12441,7 +12891,6 @@ label_ident: IDENT_sys { $$=$1; } | keyword_sp { - THD *thd= YYTHD; $$.str= thd->strmake($1.str, $1.length); if ($$.str == NULL) MYSQL_YYABORT; @@ -12458,7 +12907,6 @@ ident_or_text: user: ident_or_text { - THD *thd= YYTHD; if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) MYSQL_YYABORT; $$->user = $1; @@ -12469,13 +12917,12 @@ user: $$->auth= empty_lex_str; if (check_string_char_length(&$$->user, ER(ER_USERNAME), - USERNAME_CHAR_LENGTH, + username_char_length, system_charset_info, 0)) MYSQL_YYABORT; } | ident_or_text '@' ident_or_text { - THD *thd= YYTHD; if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) MYSQL_YYABORT; $$->user = $1; $$->host=$3; @@ -12484,7 +12931,7 @@ user: $$->auth= empty_lex_str; if (check_string_char_length(&$$->user, ER(ER_USERNAME), - USERNAME_CHAR_LENGTH, + username_char_length, system_charset_info, 0) || check_host_name(&$$->host)) MYSQL_YYABORT; @@ -12497,7 +12944,7 @@ user: } | CURRENT_USER optional_braces { - if (!($$=(LEX_USER*) YYTHD->alloc(sizeof(st_lex_user)))) + if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) MYSQL_YYABORT; /* empty LEX_USER means current_user and @@ -12518,13 +12965,21 @@ keyword: | CACHE_SYM {} | CHARSET {} | CHECKSUM_SYM {} + | CHECKPOINT_SYM {} | CLOSE_SYM {} + | COLUMN_ADD_SYM {} + | COLUMN_CREATE_SYM {} + | COLUMN_DELETE_SYM {} + | COLUMN_EXISTS_SYM {} + | COLUMN_GET_SYM {} + | COLUMN_LIST_SYM {} | COMMENT_SYM {} | COMMIT_SYM {} | CONTAINS_SYM {} | DEALLOCATE_SYM {} | DO_SYM {} | END {} + | EXAMINED_SYM {} | EXECUTE_SYM {} | FLUSH_SYM {} | HANDLER_SYM {} @@ -12534,6 +12989,7 @@ keyword: | LANGUAGE_SYM {} | NO_SYM {} | OPEN_SYM {} + | OPTION {} | OPTIONS_SYM {} | OWNER_SYM {} | PARSER_SYM {} @@ -12575,6 +13031,7 @@ keyword_sp: | AGAINST {} | AGGREGATE_SYM {} | ALGORITHM_SYM {} + | ALWAYS_SYM {} | ANY_SYM {} | AT_SYM {} | AUTHORS_SYM {} @@ -12593,6 +13050,7 @@ keyword_sp: | CHAIN_SYM {} | CHANGED {} | CIPHER_SYM {} + | CLIENT_STATS_SYM {} | CLIENT_SYM {} | CLASS_ORIGIN_SYM {} | COALESCE {} @@ -12652,16 +13110,19 @@ keyword_sp: | FIRST_SYM {} | FIXED_SYM {} | GENERAL {} + | GENERATED_SYM {} | GEOMETRY_SYM {} | GEOMETRYCOLLECTION {} | GET_FORMAT {} | GRANTS {} | GLOBAL_SYM {} | HASH_SYM {} + | HARD_SYM {} | HOSTS_SYM {} | HOUR_SYM {} | IDENTIFIED_SYM {} | IGNORE_SERVER_IDS_SYM {} + | INDEX_STATS_SYM {} | INVOKER_SYM {} | IMPORT {} | INDEXES {} @@ -12672,6 +13133,7 @@ keyword_sp: | ISSUER_SYM {} | INSERT_METHOD {} | KEY_BLOCK_SIZE {} + | LAST_VALUE {} | LAST_SYM {} | LEAVES {} | LESS_SYM {} @@ -12735,12 +13197,14 @@ keyword_sp: | OLD_PASSWORD {} | ONE_SHOT_SYM {} | ONE_SYM {} + | ONLINE_SYM {} | PACK_KEYS_SYM {} | PAGE_SYM {} | PARTIAL {} | PARTITIONING_SYM {} | PARTITIONS_SYM {} | PASSWORD {} + | PERSISTENT_SYM {} | PHASE_SYM {} | PLUGIN_SYM {} | PLUGINS_SYM {} @@ -12792,6 +13256,7 @@ keyword_sp: | SHUTDOWN {} | SLOW {} | SNAPSHOT_SYM {} + | SOFT_SYM {} | SOUNDS_SYM {} | SOURCE_SYM {} | SQL_CACHE_SYM {} @@ -12812,6 +13277,7 @@ keyword_sp: | SWAPS_SYM {} | SWITCHES_SYM {} | TABLE_NAME_SYM {} + | TABLE_STATS_SYM {} | TABLES {} | TABLE_CHECKSUM_SYM {} | TABLESPACE {} @@ -12820,6 +13286,7 @@ keyword_sp: | TEXT_SYM {} | THAN_SYM {} | TRANSACTION_SYM {} + | TRANSACTIONAL_SYM {} | TRIGGERS_SYM {} | TIMESTAMP {} | TIMESTAMP_ADD {} @@ -12836,9 +13303,11 @@ keyword_sp: | UNKNOWN_SYM {} | UNTIL_SYM {} | USER {} + | USER_STATS_SYM {} | USE_FRM {} | VARIABLES {} | VIEW_SYM {} + | VIRTUAL_SYM {} | VALUE_SYM {} | WARNINGS {} | WAIT_SYM {} @@ -12847,6 +13316,7 @@ keyword_sp: | X509_SYM {} | XML_SYM {} | YEAR_SYM {} + | VIA_SYM {} ; /* Option functions */ @@ -12878,7 +13348,6 @@ option_value_list: option_type_value: { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -12909,7 +13378,6 @@ option_type_value: } ext_option_value { - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -12992,7 +13460,6 @@ ext_option_value: sys_option_value: option_type internal_variable_name equal set_expr_or_default { - THD *thd= YYTHD; LEX *lex= Lex; LEX_STRING *name= &$2.base_name; @@ -13004,7 +13471,7 @@ sys_option_value: my_parse_error(ER(ER_SYNTAX_ERROR)); MYSQL_YYABORT; } - if (set_trigger_new_row(YYTHD, name, $4)) + if (set_trigger_new_row(thd, name, $4)) MYSQL_YYABORT; } else if ($2.var) @@ -13034,7 +13501,6 @@ sys_option_value: } | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types { - THD *thd= YYTHD; LEX *lex=Lex; lex->option_type= $1; Item *item= new (thd->mem_root) Item_int((int32) $5); @@ -13054,7 +13520,7 @@ option_value: '@' ident_or_text equal expr { Item_func_set_user_var *item; - item= new (YYTHD->mem_root) Item_func_set_user_var($2, $4, false); + item= new (thd->mem_root) Item_func_set_user_var($2, $4); if (item == NULL) MYSQL_YYABORT; set_var_user *var= new set_var_user(item); @@ -13064,7 +13530,6 @@ option_value: } | '@' '@' opt_var_ident_type internal_variable_name equal set_expr_or_default { - THD *thd= YYTHD; struct sys_var_with_base tmp= $4; /* Lookup if necessary: must be a system variable. */ if (tmp.var == NULL) @@ -13077,7 +13542,6 @@ option_value: } | charset old_or_new_charset_name_or_default { - THD *thd= YYTHD; LEX *lex= thd->lex; CHARSET_INFO *cs2; cs2= $2 ? $2: global_system_variables.character_set_client; @@ -13125,7 +13589,6 @@ option_value: } | PASSWORD equal text_or_password { - THD *thd= YYTHD; LEX *lex= thd->lex; LEX_USER *user; sp_pcontext *spc= lex->spcont; @@ -13165,7 +13628,6 @@ option_value: internal_variable_name: ident { - THD *thd= YYTHD; sp_pcontext *spc= thd->lex->spcont; sp_variable_t *spv; @@ -13224,7 +13686,7 @@ internal_variable_name: } else { - sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length); + sys_var *tmp=find_sys_var(thd, $3.str, $3.length); if (!tmp) MYSQL_YYABORT; if (!tmp->is_struct()) @@ -13235,7 +13697,7 @@ internal_variable_name: } | DEFAULT '.' ident { - sys_var *tmp=find_sys_var(YYTHD, $3.str, $3.length); + sys_var *tmp=find_sys_var(thd, $3.str, $3.length); if (!tmp) MYSQL_YYABORT; if (!tmp->is_struct()) @@ -13257,16 +13719,16 @@ text_or_password: TEXT_STRING { $$=$1.str;} | PASSWORD '(' TEXT_STRING ')' { - $$= $3.length ? YYTHD->variables.old_passwords ? - Item_func_old_password::alloc(YYTHD, $3.str, $3.length) : - Item_func_password::alloc(YYTHD, $3.str, $3.length) : + $$= $3.length ? thd->variables.old_passwords ? + Item_func_old_password::alloc(thd, $3.str, $3.length) : + Item_func_password::alloc(thd, $3.str, $3.length) : $3.str; if ($$ == NULL) MYSQL_YYABORT; } | OLD_PASSWORD '(' TEXT_STRING ')' { - $$= $3.length ? Item_func_old_password::alloc(YYTHD, $3.str, + $$= $3.length ? Item_func_old_password::alloc(thd, $3.str, $3.length) : $3.str; if ($$ == NULL) @@ -13280,19 +13742,19 @@ set_expr_or_default: | DEFAULT { $$=0; } | ON { - $$=new (YYTHD->mem_root) Item_string("ON", 2, system_charset_info); + $$=new (thd->mem_root) Item_string("ON", 2, system_charset_info); if ($$ == NULL) MYSQL_YYABORT; } | ALL { - $$=new (YYTHD->mem_root) Item_string("ALL", 3, system_charset_info); + $$=new (thd->mem_root) Item_string("ALL", 3, system_charset_info); if ($$ == NULL) MYSQL_YYABORT; } | BINARY { - $$=new (YYTHD->mem_root) Item_string("binary", 6, system_charset_info); + $$=new (thd->mem_root) Item_string("binary", 6, system_charset_info); if ($$ == NULL) MYSQL_YYABORT; } @@ -13331,8 +13793,10 @@ table_lock: { thr_lock_type lock_type= (thr_lock_type) $3; bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE); - if (!Select->add_table_to_list(YYTHD, $1, $2, 0, lock_type, + if (!Select->add_table_to_list(thd, $1, $2, 0, lock_type, (lock_for_write ? + lock_type == TL_WRITE_CONCURRENT_INSERT ? + MDL_SHARED_WRITE : MDL_SHARED_NO_READ_WRITE : MDL_SHARED_READ))) MYSQL_YYABORT; @@ -13342,6 +13806,11 @@ table_lock: lock_option: READ_SYM { $$= TL_READ_NO_INSERT; } | WRITE_SYM { $$= TL_WRITE_DEFAULT; } + | WRITE_SYM CONCURRENT + { + $$= (Lex->sphead ? TL_WRITE_DEFAULT : TL_WRITE_CONCURRENT_INSERT); + } + | LOW_PRIORITY WRITE_SYM { $$= TL_WRITE_LOW_PRIORITY; } | READ_SYM LOCAL_SYM { $$= TL_READ; } ; @@ -13402,11 +13871,12 @@ handler: lex->expr_allows_subselect= FALSE; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ - Item *one= new (YYTHD->mem_root) Item_int((int32) 1); + Item *one= new (thd->mem_root) Item_int((int32) 1); if (one == NULL) MYSQL_YYABORT; lex->current_select->select_limit= one; lex->current_select->offset_limit= 0; + lex->limit_rows_examined= 0; if (!lex->current_select->add_table_to_list(lex->thd, $2, 0, 0)) MYSQL_YYABORT; } @@ -13466,13 +13936,13 @@ revoke: ; revoke_command: - grant_privileges ON opt_table grant_ident FROM grant_list + grant_privileges ON opt_table grant_ident FROM user_list { LEX *lex= Lex; lex->sql_command= SQLCOM_REVOKE; lex->type= 0; } - | grant_privileges ON FUNCTION_SYM grant_ident FROM grant_list + | grant_privileges ON FUNCTION_SYM grant_ident FROM user_list { LEX *lex= Lex; if (lex->columns.elements) @@ -13483,7 +13953,7 @@ revoke_command: lex->sql_command= SQLCOM_REVOKE; lex->type= TYPE_ENUM_FUNCTION; } - | grant_privileges ON PROCEDURE_SYM grant_ident FROM grant_list + | grant_privileges ON PROCEDURE_SYM grant_ident FROM user_list { LEX *lex= Lex; if (lex->columns.elements) @@ -13494,11 +13964,11 @@ revoke_command: lex->sql_command= SQLCOM_REVOKE; lex->type= TYPE_ENUM_PROCEDURE; } - | ALL opt_privileges ',' GRANT OPTION FROM grant_list + | ALL opt_privileges ',' GRANT OPTION FROM user_list { Lex->sql_command = SQLCOM_REVOKE_ALL; } - | PROXY_SYM ON user FROM grant_list + | PROXY_SYM ON user FROM user_list { LEX *lex= Lex; lex->users_list.push_front ($3); @@ -13740,18 +14210,19 @@ grant_list: } ; +via_or_with: VIA_SYM | WITH ; +using_or_as: USING | AS ; + grant_user: user IDENTIFIED_SYM BY TEXT_STRING { $$=$1; $1->password=$4; - if (Lex->sql_command == SQLCOM_REVOKE) - MYSQL_YYABORT; if ($4.length) { - if (YYTHD->variables.old_passwords) + if (thd->variables.old_passwords) { char *buff= - (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); + (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); if (buff == NULL) MYSQL_YYABORT; my_make_scrambled_password_323(buff, $4.str, $4.length); @@ -13761,7 +14232,7 @@ grant_user: else { char *buff= - (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); + (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); if (buff == NULL) MYSQL_YYABORT; my_make_scrambled_password(buff, $4.str, $4.length); @@ -13772,23 +14243,17 @@ grant_user: } | user IDENTIFIED_SYM BY PASSWORD TEXT_STRING { - if (Lex->sql_command == SQLCOM_REVOKE) - MYSQL_YYABORT; $$= $1; $1->password= $5; } - | user IDENTIFIED_SYM WITH ident_or_text + | user IDENTIFIED_SYM via_or_with ident_or_text { - if (Lex->sql_command == SQLCOM_REVOKE) - MYSQL_YYABORT; $$= $1; $1->plugin= $4; $1->auth= empty_lex_str; } - | user IDENTIFIED_SYM WITH ident_or_text AS TEXT_STRING_sys + | user IDENTIFIED_SYM via_or_with ident_or_text using_or_as TEXT_STRING_sys { - if (Lex->sql_command == SQLCOM_REVOKE) - MYSQL_YYABORT; $$= $1; $1->plugin= $4; $1->auth= $6; @@ -13814,7 +14279,7 @@ column_list: column_list_id: ident { - String *new_str = new (YYTHD->mem_root) String((const char*) $1.str,$1.length,system_charset_info); + String *new_str = new (thd->mem_root) String((const char*) $1.str,$1.length,system_charset_info); if (new_str == NULL) MYSQL_YYABORT; List_iterator <LEX_COLUMN> iter(Lex->columns); @@ -13823,7 +14288,7 @@ column_list_id: while ((point=iter++)) { if (!my_strcasecmp(system_charset_info, - point->column.ptr(), new_str->ptr())) + point->column.c_ptr(), new_str->c_ptr())) break; } lex->grant_tot_col|= lex->which_columns; @@ -13894,7 +14359,7 @@ grant_option: lex->mqh.conn_per_hour= $2; lex->mqh.specified_limits|= USER_RESOURCES::CONNECTIONS_PER_HOUR; } - | MAX_USER_CONNECTIONS_SYM ulong_num + | MAX_USER_CONNECTIONS_SYM int_num { LEX *lex=Lex; lex->mqh.user_conn= $2; @@ -14024,7 +14489,6 @@ opt_union_order_or_limit: union_order_or_limit: { - THD *thd= YYTHD; LEX *lex= thd->lex; DBUG_ASSERT(lex->current_select->linkage != GLOBAL_OPTIONS_TYPE); SELECT_LEX *sel= lex->current_select; @@ -14040,7 +14504,6 @@ union_order_or_limit: } order_or_limit { - THD *thd= YYTHD; thd->lex->current_select->no_table_names_allowed= 0; thd->where= ""; } @@ -14222,14 +14685,14 @@ no_definer: from older master servers (i.e. to create non-suid trigger in this case). */ - YYTHD->lex->definer= 0; + thd->lex->definer= 0; } ; definer: DEFINER_SYM EQ user { - YYTHD->lex->definer= get_current_user(YYTHD, $3); + thd->lex->definer= get_current_user(thd, $3); } ; @@ -14255,7 +14718,7 @@ view_replace: view_algorithm: ALGORITHM_SYM EQ UNDEFINED_SYM - { Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; } + { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; } | ALGORITHM_SYM EQ MERGE_SYM { Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; } | ALGORITHM_SYM EQ TEMPTABLE_SYM @@ -14274,7 +14737,6 @@ view_suid: view_tail: view_suid VIEW_SYM table_ident { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sql_command= SQLCOM_CREATE_VIEW; /* first table in list is target VIEW name */ @@ -14318,7 +14780,6 @@ view_select: } view_select_aux view_check_option { - THD *thd= YYTHD; LEX *lex= Lex; uint len= YYLIP->get_cpp_ptr() - lex->create_view_select.str; void *create_view_select= thd->memdup(lex->create_view_select.str, len); @@ -14374,7 +14835,6 @@ trigger_tail: EACH_SYM ROW_SYM { /* $15 */ - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; sp_head *sp; @@ -14408,8 +14868,8 @@ trigger_tail: sp_head *sp= lex->sphead; lex->sql_command= SQLCOM_CREATE_TRIGGER; - sp->set_stmt_end(YYTHD); - sp->restore_thd_mem_root(YYTHD); + sp->set_stmt_end(thd); + sp->restore_thd_mem_root(thd); if (sp->is_not_allowed_in_function("trigger")) MYSQL_YYABORT; @@ -14419,7 +14879,7 @@ trigger_tail: sp_proc_stmt alternatives are not saving/restoring LEX, so lex->query_tables can be wiped out. */ - if (!lex->select_lex.add_table_to_list(YYTHD, $9, + if (!lex->select_lex.add_table_to_list(thd, $9, (LEX_STRING*) 0, TL_OPTION_UPDATING, TL_READ_NO_INSERT, @@ -14438,7 +14898,6 @@ udf_tail: AGGREGATE_SYM remember_name FUNCTION_SYM ident RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys { - THD *thd= YYTHD; LEX *lex= thd->lex; if (is_native_function(thd, & $4)) { @@ -14456,7 +14915,6 @@ udf_tail: | remember_name FUNCTION_SYM ident RETURNS_SYM udf_type SONAME_SYM TEXT_STRING_sys { - THD *thd= YYTHD; LEX *lex= thd->lex; if (is_native_function(thd, & $3)) { @@ -14479,7 +14937,6 @@ sf_tail: sp_name /* $3 */ '(' /* $4 */ { /* $5 */ - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; sp_head *sp; @@ -14520,6 +14977,7 @@ sf_tail: lex->length= lex->dec= NULL; lex->interval_list.empty(); lex->type= 0; + lex->vcol_info= 0; } type_with_opt_collate /* $11 */ { /* $12 */ @@ -14537,7 +14995,7 @@ sf_tail: MYSQL_YYABORT; } - if (sp->fill_field_definition(YYTHD, lex, + if (sp->fill_field_definition(thd, lex, (enum enum_field_types) $11, &sp->m_return_field_def)) MYSQL_YYABORT; @@ -14546,7 +15004,6 @@ sf_tail: } sp_c_chistics /* $13 */ { /* $14 */ - THD *thd= YYTHD; LEX *lex= thd->lex; Lex_input_stream *lip= YYLIP; @@ -14555,7 +15012,6 @@ sf_tail: } sp_proc_stmt /* $15 */ { - THD *thd= YYTHD; LEX *lex= thd->lex; sp_head *sp= lex->sphead; @@ -14626,10 +15082,10 @@ sp_tail: sp= new sp_head(); if (sp == NULL) MYSQL_YYABORT; - sp->reset_thd_mem_root(YYTHD); + sp->reset_thd_mem_root(thd); sp->init(lex); sp->m_type= TYPE_ENUM_PROCEDURE; - sp->init_sp_name(YYTHD, $3); + sp->init_sp_name(thd, $3); lex->sphead= sp; } @@ -14644,7 +15100,6 @@ sp_tail: sp_pdparam_list ')' { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sphead->m_param_end= YYLIP->get_cpp_tok_start(); @@ -14652,7 +15107,6 @@ sp_tail: } sp_c_chistics { - THD *thd= YYTHD; LEX *lex= thd->lex; lex->sphead->m_chistics= &lex->sp_chistics; @@ -14663,9 +15117,9 @@ sp_tail: LEX *lex= Lex; sp_head *sp= lex->sphead; - sp->set_stmt_end(YYTHD); + sp->set_stmt_end(thd); lex->sql_command= SQLCOM_CREATE_PROCEDURE; - sp->restore_thd_mem_root(YYTHD); + sp->restore_thd_mem_root(thd); } ; @@ -14702,21 +15156,21 @@ xid: text_string { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE); - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set(1L, $1->ptr(), $1->length(), 0, 0); } | text_string ',' text_string { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set(1L, $1->ptr(), $1->length(), $3->ptr(), $3->length()); } | text_string ',' text_string ',' ulong_num { MYSQL_YYABORT_UNLESS($1->length() <= MAXGTRIDSIZE && $3->length() <= MAXBQUALSIZE); - if (!(Lex->xid=(XID *)YYTHD->alloc(sizeof(XID)))) + if (!(Lex->xid=(XID *)thd->alloc(sizeof(XID)))) MYSQL_YYABORT; Lex->xid->set($5, $1->ptr(), $1->length(), $3->ptr(), $3->length()); } @@ -14759,6 +15213,13 @@ install: lex->comment= $3; lex->ident= $5; } + | INSTALL_SYM SONAME_SYM TEXT_STRING_sys + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_INSTALL_PLUGIN; + lex->comment= null_lex_str; + lex->ident= $3; + } ; uninstall: @@ -14768,8 +15229,22 @@ uninstall: lex->sql_command= SQLCOM_UNINSTALL_PLUGIN; lex->comment= $3; } + | UNINSTALL_SYM SONAME_SYM TEXT_STRING_sys + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_UNINSTALL_PLUGIN; + lex->comment= null_lex_str; + lex->ident= $3; + } ; +/* Avoid compiler warning from sql_yacc.cc where yyerrlab1 is not used */ +keep_gcc_happy: + IMPOSSIBLE_ACTION + { + YYERROR; + } + /** @} (end of group Parser) */ |