diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-23 07:14:51 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-12-23 07:14:51 +0200 |
commit | 73985d83014e2a484dffac135193a2f0cf715b54 (patch) | |
tree | 7167799ebc178519babd7000c76234665a9d6030 /sql | |
parent | 496532b5c54d69e012f6fc2417e97d61465588f2 (diff) | |
parent | aade6e53d398dd287ca7e771191c9975099b4fa1 (diff) | |
download | mariadb-git-73985d83014e2a484dffac135193a2f0cf715b54.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql')
-rw-r--r-- | sql/CMakeLists.txt | 10 | ||||
-rw-r--r-- | sql/item.cc | 24 | ||||
-rw-r--r-- | sql/item.h | 7 | ||||
-rw-r--r-- | sql/sql_lex.h | 22 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/tztime.cc | 10 | ||||
-rw-r--r-- | sql/unireg.cc | 3 |
7 files changed, 40 insertions, 38 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index f7c97b23e87..19fdd788207 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -399,10 +399,12 @@ IF(WIN32 AND MYSQLD_EXECUTABLE) ENDIF() MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data) ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep - COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/initdb.dep - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data + OUTPUT initdb.dep + COMMAND ${CMAKE_COMMAND} -E remove_directory data + COMMAND ${CMAKE_COMMAND} -E make_directory data + COMMAND ${CMAKE_COMMAND} -E chdir data ${CMAKE_COMMAND} + ${CONFIG_PARAM} -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS mysqld ) ADD_CUSTOM_TARGET(initial_database diff --git a/sql/item.cc b/sql/item.cc index 10087ef1974..2577bbed716 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -158,6 +158,19 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate) } +longlong Item::val_datetime_packed_result() +{ + MYSQL_TIME ltime, tmp; + if (get_date_result(<ime, TIME_FUZZY_DATES | TIME_INVALID_DATES)) + return 0; + if (ltime.time_type != MYSQL_TIMESTAMP_TIME) + return pack_time(<ime); + if ((null_value= time_to_datetime_with_warn(current_thd, <ime, &tmp, 0))) + return 0; + return pack_time(&tmp); +} + + /** Get date/time/datetime. If DATETIME or DATE result is returned, it's converted to TIME. @@ -2855,12 +2868,13 @@ bool Item_field::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) bool Item_field::get_date_result(MYSQL_TIME *ltime, ulonglong fuzzydate) { - if (result_field->is_null() || result_field->get_date(ltime,fuzzydate)) + if ((null_value= result_field->is_null()) || + result_field->get_date(ltime, fuzzydate)) { bzero((char*) ltime,sizeof(*ltime)); - return (null_value= 1); + return true; } - return (null_value= 0); + return false; } @@ -8014,7 +8028,7 @@ bool Item_ref::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) longlong Item_ref::val_datetime_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_datetime_packed(); + longlong tmp= (*ref)->val_datetime_packed_result(); null_value= (*ref)->null_value; return tmp; } @@ -8023,7 +8037,7 @@ longlong Item_ref::val_datetime_packed() longlong Item_ref::val_time_packed() { DBUG_ASSERT(fixed); - longlong tmp= (*ref)->val_time_packed(); + longlong tmp= (*ref)->val_time_packed_result(); null_value= (*ref)->null_value; return tmp; } diff --git a/sql/item.h b/sql/item.h index ff4cfd6c1b8..c3db959fd44 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1503,6 +1503,13 @@ public: uint fuzzydate= TIME_FUZZY_DATES | TIME_INVALID_DATES | TIME_TIME_ONLY; return get_date(<ime, fuzzydate) ? 0 : pack_time(<ime); } + longlong val_datetime_packed_result(); + longlong val_time_packed_result() + { + MYSQL_TIME ltime; + uint fuzzydate= TIME_TIME_ONLY | TIME_INVALID_DATES | TIME_FUZZY_DATES; + return get_date_result(<ime, fuzzydate) ? 0 : pack_time(<ime); + } // Get a temporal value in packed DATE/DATETIME or TIME format longlong val_temporal_packed(enum_field_types f_type) { diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 65bce5d2579..d14843d0c24 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1298,28 +1298,6 @@ public: uint sroutines_list_own_elements; /** - Locking state of tables in this particular statement. - - If we under LOCK TABLES or in prelocked mode we consider tables - for the statement to be "locked" if there was a call to lock_tables() - (which called handler::start_stmt()) for tables of this statement - and there was no matching close_thread_tables() call. - - As result this state may differ significantly from one represented - by Open_tables_state::lock/locked_tables_mode more, which are always - "on" under LOCK TABLES or in prelocked mode. - */ - enum enum_lock_tables_state { - LTS_NOT_LOCKED = 0, - LTS_LOCKED - }; - enum_lock_tables_state lock_tables_state; - bool is_query_tables_locked() - { - return (lock_tables_state == LTS_LOCKED); - } - - /** Number of tables which were open by open_tables() and to be locked by lock_tables(). Note that we set this member only in some cases, when this value diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 33964cb270f..1bf8addbcf0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14354,7 +14354,7 @@ static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, } } else if (cond->type() == Item::FUNC_ITEM && - ((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) + ((Item_func*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) { item_equal= (Item_equal *) cond; item_equal->sort(&compare_fields_by_table_order, table_join_idx); diff --git a/sql/tztime.cc b/sql/tztime.cc index f3d178c59a2..941530b9656 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2441,7 +2441,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) if (!opt_skip_write_binlog) printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone_leap_second ENGINE=InnoDB;\n" "END IF|\n" "\\d ;\n"); @@ -2461,7 +2461,7 @@ print_tz_leaps_as_sql(const TIME_ZONE_INFO *sp) if (!opt_skip_write_binlog) printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone_leap_second ENGINE=MyISAM;\n" "END IF|\n" "\\d ;\n"); @@ -2717,7 +2717,7 @@ main(int argc, char **argv) sql_log_bin and wsrep_on to avoid Galera replicating below truncate table clauses. This will allow user to set different time zones to nodes in Galera cluster. */ - printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" + printf("set @prep1=if((select count(*) from information_schema.global_variables where variable_name='wsrep_on' and variable_value='ON'), 'SET SESSION SQL_LOG_BIN=?, WSREP_ON=OFF;', 'do ?');\n" "prepare set_wsrep_write_binlog from @prep1;\n" "set @toggle=0; execute set_wsrep_write_binlog using @toggle;\n"); @@ -2733,7 +2733,7 @@ main(int argc, char **argv) // to allow changes to them to replicate with Galera printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone ENGINE=InnoDB;\n" "ALTER TABLE time_zone_name ENGINE=InnoDB;\n" "ALTER TABLE time_zone_transition ENGINE=InnoDB;\n" @@ -2788,7 +2788,7 @@ main(int argc, char **argv) // Fall back to MyISAM printf("\\d |\n" "IF (select count(*) from information_schema.global_variables where\n" - "variable_name='wsrep_on') = 1 THEN\n" + "variable_name='wsrep_on' and variable_value='ON') = 1 THEN\n" "ALTER TABLE time_zone ENGINE=MyISAM;\n" "ALTER TABLE time_zone_name ENGINE=MyISAM;\n" "ALTER TABLE time_zone_transition ENGINE=MyISAM;\n" diff --git a/sql/unireg.cc b/sql/unireg.cc index 14c51a0de91..7b67a07d9a6 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -312,7 +312,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const char *table, pos+= reclength; int2store(pos, create_info->connect_string.length); pos+= 2; - memcpy(pos, create_info->connect_string.str, create_info->connect_string.length); + if (create_info->connect_string.length) + memcpy(pos, create_info->connect_string.str, create_info->connect_string.length); pos+= create_info->connect_string.length; int2store(pos, str_db_type.length); pos+= 2; |