revision-id: f2e1451740d417f1c9ea8626d937fbcacc91bb55 (mariadb-10.1.38-17-gf2e1451740d) parent(s): e39d6e0c53bccaf0c6b2a0341f8deb420f5e79be 2d34713294d5339d1459911a46fa20395443b3c7 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2019-03-01 15:52:06 +0100 message: Merge branch '10.0' into 10.1 mysql-test/r/loaddata.result | 50 +++++++++++++++++++++++++++++++++++++++ mysql-test/r/sp.result | 33 ++++++++++++++++++++++++++ mysql-test/t/loaddata.test | 45 +++++++++++++++++++++++++++++++++++ mysql-test/t/sp.test | 41 ++++++++++++++++++++++++++++++++ sql/sql_delete.cc | 6 ++--- sql/sql_derived.cc | 31 +----------------------- sql/sql_derived.h | 1 - sql/sql_insert.cc | 3 +-- sql/sql_lex.cc | 16 ++++--------- sql/sql_lex.h | 32 ++++++++++++++++++++++++- sql/sql_load.cc | 10 ++++++-- sql/sql_prepare.cc | 21 +++++++++++----- sql/sql_union.cc | 5 ++-- win/packaging/create_msi.cmake.in | 5 ++-- 14 files changed, 239 insertions(+), 60 deletions(-) diff --cc sql/sql_lex.h index edc647522d3,6483aa0e44d..0142f812632 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@@ -2915,89 -2776,32 +2920,114 @@@ public bool save_prep_leaf_tables(); int print_explain(select_result_sink *output, uint8 explain_flags, - bool *printed_anything); + bool is_analyze, bool *printed_anything); + void restore_set_statement_var(); + + void init_last_field(Create_field *field, const char *name, CHARSET_INFO *cs); + void set_last_field_type(enum enum_field_types type); + bool set_bincmp(CHARSET_INFO *cs, bool bin); + // Check if "KEY IF NOT EXISTS name" used outside of ALTER context + bool check_add_key(DDL_options_st ddl) + { + if (ddl.if_not_exists() && sql_command != SQLCOM_ALTER_TABLE) + { + parse_error(); + return true; + } + return false; + } + // Add a key as a part of CREATE TABLE or ALTER TABLE + bool add_key(Key::Keytype key_type, const LEX_STRING &key_name, + ha_key_alg algorithm, DDL_options_st ddl) + { + if (check_add_key(ddl) || + !(last_key= new Key(key_type, key_name, algorithm, false, ddl))) + return true; + alter_info.key_list.push_back(last_key); + return false; + } + // Add a key for a CREATE INDEX statement + bool add_create_index(Key::Keytype key_type, const LEX_STRING &key_name, + ha_key_alg algorithm, DDL_options_st ddl) + { + if (check_create_options(ddl) || + !(last_key= new Key(key_type, key_name, algorithm, false, ddl))) + return true; + alter_info.key_list.push_back(last_key); + return false; + } + void set_command(enum_sql_command command, + DDL_options_st options) + { + sql_command= command; + create_info.set(options); + } + void set_command(enum_sql_command command, + uint scope, + DDL_options_st options) + { + set_command(command, options); + create_info.options|= scope; // HA_LEX_CREATE_TMP_TABLE or 0 + } + bool check_create_options(DDL_options_st options) + { + if (options.or_replace() && options.if_not_exists()) + { + my_error(ER_WRONG_USAGE, MYF(0), "OR REPLACE", "IF NOT EXISTS"); + return true; + } + return false; + } + bool add_create_options_with_check(DDL_options_st options) + { + create_info.add(options); + return check_create_options(create_info); + } + bool set_command_with_check(enum_sql_command command, + uint scope, + DDL_options_st options) + { + set_command(command, scope, options); + return check_create_options(options); + } + bool set_command_with_check(enum_sql_command command, DDL_options_st options) + { + set_command(command, options); + return check_create_options(options); + } + /* + DROP shares lex->create_info to store TEMPORARY and IF EXISTS options + to save on extra initialization in lex_start(). + Add some wrappers, to avoid direct use of lex->create_info in the + caller code processing DROP statements (which might look confusing). + */ + bool tmp_table() const { return create_info.tmp_table(); } + bool if_exists() const { return create_info.if_exists(); } + + /* + Run specified phases for derived tables/views in the given list + + @param table_list - list of derived tables/view to handle + @param phase - phases to process tables/views through + + @details + This method runs phases specified by the 'phases' on derived + tables/views found in the 'table_list' with help of the + TABLE_LIST::handle_derived function. + 'this' is passed as an argument to the TABLE_LIST::handle_derived. + + @return false - ok + @return true - error + */ + bool handle_list_of_derived(TABLE_LIST *table_list, uint phases) + { + for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local) + { + if (tl->is_view_or_derived() && tl->handle_derived(this, phases)) + return true; + } + return false; + } }; diff --cc sql/sql_union.cc index e12cae0f80e,b8bcbd6909d..56d6cecadf6 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@@ -313,10 -215,11 +313,11 @@@ st_select_lex_unit::init_prepare_fake_s called at the first execution of the statement, while first_execution shows whether this is called at the first execution of the union that may form just a subselect. - */ - if (!fake_select_lex->first_execution && first_execution) + */ + if ((fake_select_lex->changed_elements & TOUCHED_SEL_COND) && + first_execution) { - for (ORDER *order= global_parameters->order_list.first; + for (ORDER *order= global_parameters()->order_list.first; order; order= order->next) order->item= &order->item_ptr;