diff options
Diffstat (limited to 'sql')
135 files changed, 1827 insertions, 1349 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index f4101832214..4938f8da02b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -237,6 +237,15 @@ FOREACH(se aria partition perfschema sql_sequence wsrep) ENDIF() ENDFOREACH() +IF(VISIBILITY_HIDDEN_FLAG AND TARGET partition AND WITH_UBSAN) + # the spider plugin needs some partition symbols from inside mysqld + # when built with ubsan, in which case we need to remove + # -fvisibility=hidden from partition + GET_TARGET_PROPERTY(f partition COMPILE_FLAGS) + STRING(REPLACE "${VISIBILITY_HIDDEN_FLAG}" "" f ${f}) + SET_TARGET_PROPERTIES(partition PROPERTIES COMPILE_FLAGS "${f}") +ENDIF() + IF(WIN32) SET(MYSQLD_SOURCE main.cc message.rc) ELSE() diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 55523a728f8..eac111d32d7 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -18,6 +18,7 @@ #include "mariadb.h" #include "debug_sync.h" +#include <cstring> #if defined(ENABLED_DEBUG_SYNC) @@ -48,6 +49,8 @@ struct st_debug_sync_action String wait_for; /* signal to wait for */ String sync_point; /* sync point name */ bool need_sort; /* if new action, array needs sort */ + bool clear_event; /* do not clear signal when waited + for if false. */ }; /* Debug sync control. Referenced by THD. */ @@ -67,21 +70,99 @@ struct st_debug_sync_control }; + + /** Definitions for the debug sync facility. - 1. Global string variable to hold a "signal" ("signal post", "flag mast"). + 1. Global string variable to hold a set of of "signals". 2. Global condition variable for signaling and waiting. 3. Global mutex to synchronize access to the above. */ struct st_debug_sync_globals { - String ds_signal; /* signal variable */ + Hash_set<LEX_CSTRING> ds_signal_set; /* A set of active signals */ mysql_cond_t ds_cond; /* condition variable */ mysql_mutex_t ds_mutex; /* mutex variable */ ulonglong dsp_hits; /* statistics */ ulonglong dsp_executed; /* statistics */ ulonglong dsp_max_active; /* statistics */ + + st_debug_sync_globals() : ds_signal_set(PSI_NOT_INSTRUMENTED, signal_key) {}; + ~st_debug_sync_globals() + { + clear_set(); + } + + void clear_set() + { + Hash_set<LEX_CSTRING>::Iterator it{ds_signal_set}; + LEX_CSTRING *s; + while ((s= it++)) + my_free(s); + ds_signal_set.clear(); + } + + /* Hash key function for ds_signal_set. */ + static uchar *signal_key(const LEX_CSTRING *str, size_t *klen, my_bool) + { + *klen= str->length; + return (uchar*) str->str; + } + + /** + Return true if the signal is found in global signal list. + + @param signal_name Signal name identifying the signal. + + @note + If signal is found in the global signal set, it means that the + signal thread has signalled to the waiting thread. This method + must be called with the debug_sync_global.ds_mutex held. + + @retval true if signal is found in the global signal list. + @retval false otherwise. + */ + + inline bool is_signalled(const char *signal_name, size_t length) + { + return ds_signal_set.find(signal_name, length); + } + + void clear_signal(const String &signal_name) + { + DBUG_ENTER("clear_signal"); + LEX_CSTRING *record= ds_signal_set.find(signal_name.ptr(), + signal_name.length()); + if (record) + { + ds_signal_set.remove(record); + my_free(record); + } + DBUG_VOID_RETURN; + } + + bool set_signal(const char *signal_name, size_t length) + { + /* Need to check if the signal is already in the hash set, because + Hash_set doesn't differentiate between OOM and key already in. */ + if (is_signalled(signal_name, length)) + return FALSE; + /* LEX_CSTRING and the string allocated with only one malloc. */ + LEX_CSTRING *s= (LEX_CSTRING *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(LEX_CSTRING) + length + 1, + MYF(0)); + char *str= (char *)(s + 1); + memcpy(str, signal_name, length); + str[length]= '\0'; + + s->length= length; + s->str= str; + if (ds_signal_set.insert(s)) + return TRUE; + return FALSE; + } }; + static st_debug_sync_globals debug_sync_global; /* All globals in one object */ /** @@ -161,7 +242,7 @@ int debug_sync_init(void) int rc; /* Initialize the global variables. */ - debug_sync_global.ds_signal.length(0); + debug_sync_global.clear_set(); if ((rc= mysql_cond_init(key_debug_sync_globals_ds_cond, &debug_sync_global.ds_cond, NULL)) || (rc= mysql_mutex_init(key_debug_sync_globals_ds_mutex, @@ -195,7 +276,7 @@ void debug_sync_end(void) debug_sync_C_callback_ptr= NULL; /* Destroy the global variables. */ - debug_sync_global.ds_signal.free(); + debug_sync_global.clear_set(); mysql_cond_destroy(&debug_sync_global.ds_cond); mysql_mutex_destroy(&debug_sync_global.ds_mutex); @@ -272,6 +353,40 @@ void debug_sync_init_thread(THD *thd) /** + Returns an allocated buffer containing a comma-separated C string of all + active signals. + + Buffer must be freed by the caller. +*/ +static const char *get_signal_set_as_string() +{ + mysql_mutex_assert_owner(&debug_sync_global.ds_mutex); + size_t req_size= 1; // In case of empty set for the end '\0' char. + + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + req_size+= debug_sync_global.ds_signal_set.at(i)->length + 1; + + char *buf= (char *) my_malloc(PSI_NOT_INSTRUMENTED, req_size, MYF(0)); + if (!buf) + return nullptr; + memset(buf, '\0', req_size); + + char *cur_pos= buf; + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + const LEX_CSTRING *signal= debug_sync_global.ds_signal_set.at(i); + memcpy(cur_pos, signal->str, signal->length); + if (i != debug_sync_global.ds_signal_set.size() - 1) + cur_pos[signal->length]= ','; + else + cur_pos[signal->length] = '\0'; + cur_pos+= signal->length + 1; + } + return buf; +} + + +/** End the debug sync facility at thread end. @param[in] thd thread handle @@ -554,7 +669,7 @@ static void debug_sync_reset(THD *thd) /* Clear the global signal. */ mysql_mutex_lock(&debug_sync_global.ds_mutex); - debug_sync_global.ds_signal.length(0); + debug_sync_global.clear_set(); mysql_mutex_unlock(&debug_sync_global.ds_mutex); DBUG_VOID_RETURN; @@ -1175,6 +1290,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) /* Set default for EXECUTE and TIMEOUT options. */ action->execute= 1; action->timeout= opt_debug_sync_timeout; + action->clear_event= true; /* Get next token. If none follows, set action. */ if (!(ptr= debug_sync_token(&token, &token_length, ptr, action_end))) @@ -1226,6 +1342,16 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) } /* + Try NO_CLEAR_EVENT. + */ + if (!my_strcasecmp(system_charset_info, token, "NO_CLEAR_EVENT")) + { + action->clear_event= false; + /* Get next token. If none follows, set action. */ + if (!(ptr = debug_sync_token(&token, &token_length, ptr, action_end))) goto set_action; + } + + /* Try HIT_LIMIT. */ if (!my_strcasecmp(system_charset_info, token, "HIT_LIMIT")) @@ -1325,13 +1451,19 @@ uchar *debug_sync_value_ptr(THD *thd) if (opt_debug_sync_timeout) { - static char on[]= "ON - current signal: '"; + static char on[]= "ON - current signals: '"; // Ensure exclusive access to debug_sync_global.ds_signal mysql_mutex_lock(&debug_sync_global.ds_mutex); - size_t lgt= (sizeof(on) /* includes '\0' */ + - debug_sync_global.ds_signal.length() + 1 /* for '\'' */); + size_t lgt= sizeof(on) + 1; /* +1 as we'll have to append ' at the end. */ + + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + /* Assume each signal is separated by a comma, hence +1. */ + lgt+= debug_sync_global.ds_signal_set.at(i)->length + 1; + } + char *vend; char *vptr; @@ -1339,10 +1471,15 @@ uchar *debug_sync_value_ptr(THD *thd) { vend= value + lgt - 1; /* reserve space for '\0'. */ vptr= debug_sync_bmove_len(value, vend, STRING_WITH_LEN(on)); - vptr= debug_sync_bmove_len(vptr, vend, debug_sync_global.ds_signal.ptr(), - debug_sync_global.ds_signal.length()); - if (vptr < vend) - *(vptr++)= '\''; + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + const LEX_CSTRING *s= debug_sync_global.ds_signal_set.at(i); + vptr= debug_sync_bmove_len(vptr, vend, s->str, s->length); + if (i != debug_sync_global.ds_signal_set.size() - 1) + *(vptr++)= ','; + } + DBUG_ASSERT(vptr < vend); + *(vptr++)= '\''; *vptr= '\0'; /* We have one byte reserved for the worst case. */ } mysql_mutex_unlock(&debug_sync_global.ds_mutex); @@ -1358,6 +1495,9 @@ uchar *debug_sync_value_ptr(THD *thd) } + + + /** Execute requested action at a synchronization point. @@ -1413,12 +1553,28 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) read access too, to create a memory barrier in order to avoid that threads just reads an old cached version of the signal. */ + mysql_mutex_lock(&debug_sync_global.ds_mutex); if (action->signal.length()) { - /* Copy the signal to the global variable. */ - if (debug_sync_global.ds_signal.copy(action->signal)) + int offset= 0, pos; + bool error= false; + + /* This loop covers all signals in the list except for the last one. + Split the signal string by commas and set a signal in the global + variable for each one. */ + while (!error && (pos= action->signal.strstr(",", 1, offset)) > 0) + { + error= debug_sync_global.set_signal(action->signal.ptr() + offset, + pos - offset); + offset= pos + 1; + } + + if (error || + /* The last signal in the list. */ + debug_sync_global.set_signal(action->signal.ptr() + offset, + action->signal.length() - offset)) { /* Error is reported by my_malloc(). @@ -1461,31 +1617,43 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) restore_current_mutex = false; set_timespec(abstime, action->timeout); - DBUG_EXECUTE("debug_sync_exec", - /* Functions as DBUG_PRINT args can change keyword and line nr. */ - DBUG_PRINT("debug_sync_exec", - ("wait for '%s' at: '%s' curr: '%s'", - sig_wait, dsp_name, - debug_sync_global.ds_signal.c_ptr()));); + DBUG_EXECUTE("debug_sync_exec", { + const char *signal_set= get_signal_set_as_string(); + if (!signal_set) + { + DBUG_PRINT("debug_sync_exec", + ("Out of memory when fetching signal set")); + } + else + { + /* Functions as DBUG_PRINT args can change keyword and line nr. */ + DBUG_PRINT("debug_sync_exec", + ("wait for '%s' at: '%s', curr: '%s'", + sig_wait, dsp_name, signal_set)); + my_free((void *)signal_set); + }}); + /* - Wait until global signal string matches the wait_for string. - Interrupt when thread or query is killed or facility disabled. + Wait until the signal set contains the wait_for string. + Interrupt when thread or query is killed or facility is disabled. The facility can become disabled when some thread cannot get the required dynamic memory allocated. */ - while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) && - !(thd->killed & KILL_HARD_BIT) && opt_debug_sync_timeout) + while (!debug_sync_global.is_signalled(action->wait_for.ptr(), + action->wait_for.length()) && + !(thd->killed & KILL_HARD_BIT) && + opt_debug_sync_timeout) { error= mysql_cond_timedwait(&debug_sync_global.ds_cond, &debug_sync_global.ds_mutex, &abstime); - DBUG_EXECUTE("debug_sync", + // TODO turn this into a for loop printing. + DBUG_EXECUTE("debug_sync", { /* Functions as DBUG_PRINT args can change keyword and line nr. */ DBUG_PRINT("debug_sync", - ("awoke from %s global: %s error: %d", - sig_wait, debug_sync_global.ds_signal.c_ptr(), - error));); + ("awoke from %s error: %d", + sig_wait, error));}); if (unlikely(error == ETIMEDOUT || error == ETIME)) { // We should not make the statement fail, even if in strict mode. @@ -1498,6 +1666,10 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) } error= 0; } + + if (action->clear_event) + debug_sync_global.clear_signal(action->wait_for); + DBUG_EXECUTE("debug_sync_exec", if (thd->killed) DBUG_PRINT("debug_sync_exec", @@ -1571,10 +1743,10 @@ static void debug_sync(THD *thd, const char *sync_point_name, size_t name_len) st_debug_sync_control *ds_control= thd->debug_sync_control; st_debug_sync_action *action; DBUG_ENTER("debug_sync"); + DBUG_PRINT("debug_sync_point", ("hit: '%s'", sync_point_name)); DBUG_ASSERT(sync_point_name); DBUG_ASSERT(name_len); DBUG_ASSERT(ds_control); - DBUG_PRINT("debug_sync_point", ("hit: '%s'", sync_point_name)); /* Statistics. */ ds_control->dsp_hits++; diff --git a/sql/derived_handler.h b/sql/derived_handler.h index 171165bbe6f..f6feed8db32 100644 --- a/sql/derived_handler.h +++ b/sql/derived_handler.h @@ -56,7 +56,7 @@ public: derived_handler(THD *thd_arg, handlerton *ht_arg) : thd(thd_arg), ht(ht_arg), derived(0),table(0), tmp_table_param(0), unit(0), select(0) {} - virtual ~derived_handler() {} + virtual ~derived_handler() = default; /* Functions to scan data. All these returns 0 if ok, error code in case diff --git a/sql/discover.h b/sql/discover.h index 1775f5d6551..750c2944ede 100644 --- a/sql/discover.h +++ b/sql/discover.h @@ -28,7 +28,7 @@ int writefile(const char *path, const char *db, const char *table, inline void deletefrm(const char *path) { char frm_name[FN_REFLEN]; - strxmov(frm_name, path, reg_ext, NullS); + strxnmov(frm_name, sizeof(frm_name)-1, path, reg_ext, NullS); mysql_file_delete(key_file_frm, frm_name, MYF(0)); } diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 3980f248327..bb552aa9de8 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -328,9 +328,7 @@ Event_queue_element::Event_queue_element(): SYNOPSIS Event_queue_element::Event_queue_element() */ -Event_queue_element::~Event_queue_element() -{ -} +Event_queue_element::~Event_queue_element() = default; /* @@ -356,9 +354,7 @@ Event_timed::Event_timed(): Event_timed::~Event_timed() */ -Event_timed::~Event_timed() -{ -} +Event_timed::~Event_timed() = default; /* diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h index b89a1a15155..29b5031bc28 100644 --- a/sql/event_db_repository.h +++ b/sql/event_db_repository.h @@ -71,7 +71,7 @@ class Event_parse_data; class Event_db_repository { public: - Event_db_repository(){} + Event_db_repository() = default; bool create_event(THD *thd, Event_parse_data *parse_data, diff --git a/sql/field.cc b/sql/field.cc index 6b782f79d3a..5a618a5a2a9 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1924,17 +1924,11 @@ Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, } -void Field::hash(ulong *nr, ulong *nr2) +void Field::hash_not_null(Hasher *hasher) { - if (is_null()) - { - *nr^= (*nr << 1) | 1; - } - else - { - uint len= pack_length(); - sort_charset()->hash_sort(ptr, len, nr, nr2); - } + DBUG_ASSERT(marked_for_read()); + DBUG_ASSERT(!is_null()); + hasher->add(sort_charset(), ptr, pack_length()); } size_t @@ -8345,17 +8339,12 @@ bool Field_varstring::is_equal(const Column_definition &new_field) const } -void Field_varstring::hash(ulong *nr, ulong *nr2) +void Field_varstring::hash_not_null(Hasher *hasher) { - if (is_null()) - { - *nr^= (*nr << 1) | 1; - } - else - { - uint len= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); - charset()->hash_sort(ptr + length_bytes, len, nr, nr2); - } + DBUG_ASSERT(marked_for_read()); + DBUG_ASSERT(!is_null()); + uint len= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); + hasher->add(charset(), ptr + length_bytes, len); } @@ -8730,6 +8719,17 @@ oom_error: } +void Field_blob::hash_not_null(Hasher *hasher) +{ + DBUG_ASSERT(marked_for_read()); + DBUG_ASSERT(!is_null()); + char *blob; + memcpy(&blob, ptr + packlength, sizeof(char*)); + if (blob) + hasher->add(Field_blob::charset(), blob, get_length(ptr)); +} + + double Field_blob::val_real(void) { DBUG_ASSERT(marked_for_read()); @@ -9792,20 +9792,27 @@ const DTCollation & Field_bit::dtcollation() const } -void Field_bit::hash(ulong *nr, ulong *nr2) +/* + This method always calculates hash over 8 bytes. + This is different from how the HEAP engine calculate hash: + HEAP takes into account the actual octet size, so say for BIT(18) + it calculates hash over three bytes only: + - the incomplete byte with bits 16..17 + - the two full bytes with bits 0..15 + See hp_rec_hashnr(), hp_hashnr() for details. + + The HEAP way is more efficient, especially for short lengths. + Let's consider fixing Field_bit eventually to do it in the HEAP way, + with proper measures to upgrade partitioned tables easy. +*/ +void Field_bit::hash_not_null(Hasher *hasher) { - if (is_null()) - { - *nr^= (*nr << 1) | 1; - } - else - { - CHARSET_INFO *cs= &my_charset_bin; - longlong value= Field_bit::val_int(); - uchar tmp[8]; - mi_int8store(tmp,value); - cs->hash_sort(tmp, 8, nr, nr2); - } + DBUG_ASSERT(marked_for_read()); + DBUG_ASSERT(!is_null()); + longlong value= Field_bit::val_int(); + uchar tmp[8]; + mi_int8store(tmp,value); + hasher->add(&my_charset_bin, tmp, 8); } diff --git a/sql/field.h b/sql/field.h index 4036f032257..13d80099124 100644 --- a/sql/field.h +++ b/sql/field.h @@ -605,7 +605,7 @@ public: name.length= 0; }; Virtual_column_info* clone(THD *thd); - ~Virtual_column_info() {}; + ~Virtual_column_info() = default; enum_vcol_info_type get_vcol_type() const { return vcol_type; @@ -895,7 +895,7 @@ public: Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const LEX_CSTRING *field_name_arg); - virtual ~Field() {} + virtual ~Field() = default; virtual Type_numeric_attributes type_numeric_attributes() const { @@ -1845,7 +1845,14 @@ public: key_map get_possible_keys(); /* Hash value */ - virtual void hash(ulong *nr, ulong *nr2); + void hash(Hasher *hasher) + { + if (is_null()) + hasher->add_null(); + else + hash_not_null(hasher); + } + virtual void hash_not_null(Hasher *hasher); /** Get the upper limit of the MySQL integral and floating-point type. @@ -4221,7 +4228,7 @@ public: uchar *new_ptr, uint32 length, uchar *new_null_ptr, uint new_null_bit) override; bool is_equal(const Column_definition &new_field) const override; - void hash(ulong *nr, ulong *nr2) override; + void hash_not_null(Hasher *hasher) override; uint length_size() const override { return length_bytes; } void print_key_value(String *out, uint32 length) override; Binlog_type_info binlog_type_info() const override; @@ -4481,6 +4488,7 @@ public: bool make_empty_rec_store_default_value(THD *thd, Item *item) override; int store(const char *to, size_t length, CHARSET_INFO *charset) override; using Field_str::store; + void hash_not_null(Hasher *hasher) override; double val_real() override; longlong val_int() override; String *val_str(String *, String *) override; @@ -5051,7 +5059,7 @@ public: if (bit_ptr) bit_ptr= ADD_TO_PTR(bit_ptr, ptr_diff, uchar*); } - void hash(ulong *nr, ulong *nr2) override; + void hash_not_null(Hasher *hasher) override; SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *param, KEY_PART *key_part, const Item_bool_func *cond, @@ -5851,8 +5859,8 @@ public: Field *from_field,*to_field; String tmp; // For items - Copy_field() {} - ~Copy_field() {} + Copy_field() = default; + ~Copy_field() = default; void set(Field *to,Field *from,bool save); // Field to field void set(uchar *to,Field *from); // Field to string void (*do_copy)(Copy_field *); diff --git a/sql/filesort_utils.h b/sql/filesort_utils.h index 73aa2f76a18..776e986e14a 100644 --- a/sql/filesort_utils.h +++ b/sql/filesort_utils.h @@ -305,22 +305,11 @@ public: /** We need an assignment operator, see filesort(). This happens to have the same semantics as the one that would be - generated by the compiler. We still implement it here, to show shallow - assignment explicitly: we have two objects sharing the same array. + generated by the compiler. + Note that this is a shallow copy. We have two objects sharing the same + array. */ - Filesort_buffer &operator=(const Filesort_buffer &rhs) - { - m_next_rec_ptr= rhs.m_next_rec_ptr; - m_rawmem= rhs.m_rawmem; - m_record_pointers= rhs.m_record_pointers; - m_sort_keys= rhs.m_sort_keys; - m_num_records= rhs.m_num_records; - m_record_length= rhs.m_record_length; - m_sort_length= rhs.m_sort_length; - m_size_in_bytes= rhs.m_size_in_bytes; - m_idx= rhs.m_idx; - return *this; - } + Filesort_buffer &operator=(const Filesort_buffer &rhs) = default; uint get_sort_length() const { return m_sort_length; } void set_sort_length(uint val) { m_sort_length= val; } diff --git a/sql/gcalc_slicescan.h b/sql/gcalc_slicescan.h index b5188f29dfd..37e887e87e5 100644 --- a/sql/gcalc_slicescan.h +++ b/sql/gcalc_slicescan.h @@ -344,7 +344,7 @@ public: { return complete_ring() || complete_poly(); } - virtual ~Gcalc_shape_transporter() {} + virtual ~Gcalc_shape_transporter() = default; }; diff --git a/sql/group_by_handler.h b/sql/group_by_handler.h index ff3b204fa56..5457cb778f5 100644 --- a/sql/group_by_handler.h +++ b/sql/group_by_handler.h @@ -77,7 +77,7 @@ public: group_by_handler(THD *thd_arg, handlerton *ht_arg) : thd(thd_arg), ht(ht_arg), table(0) {} - virtual ~group_by_handler() {} + virtual ~group_by_handler() = default; /* Functions to scan data. All these returns 0 if ok, error code in case diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 08e3b45e02b..fdb4726a930 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -10034,8 +10034,7 @@ uint8 ha_partition::table_cache_type() uint32 ha_partition::calculate_key_hash_value(Field **field_array) { - ulong nr1= 1; - ulong nr2= 4; + Hasher hasher; bool use_51_hash; use_51_hash= MY_TEST((*field_array)->table->part_info->key_algorithm == partition_info::KEY_ALGORITHM_51); @@ -10062,12 +10061,12 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array) { if (field->is_null()) { - nr1^= (nr1 << 1) | 1; + hasher.add_null(); continue; } /* Force this to my_hash_sort_bin, which was used in 5.1! */ uint len= field->pack_length(); - my_charset_bin.hash_sort(field->ptr, len, &nr1, &nr2); + hasher.add(&my_charset_bin, field->ptr, len); /* Done with this field, continue with next one. */ continue; } @@ -10085,12 +10084,12 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array) { if (field->is_null()) { - nr1^= (nr1 << 1) | 1; + hasher.add_null(); continue; } /* Force this to my_hash_sort_bin, which was used in 5.1! */ uint len= field->pack_length(); - my_charset_latin1.hash_sort(field->ptr, len, &nr1, &nr2); + hasher.add(&my_charset_latin1, field->ptr, len); continue; } /* New types in mysql-5.6. */ @@ -10117,9 +10116,9 @@ uint32 ha_partition::calculate_key_hash_value(Field **field_array) } /* fall through, use collation based hashing. */ } - field->hash(&nr1, &nr2); + field->hash(&hasher); } while (*(++field_array)); - return (uint32) nr1; + return (uint32) hasher.finalize(); } diff --git a/sql/handler.cc b/sql/handler.cc index 5884339c809..1a4cc630a37 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4848,6 +4848,35 @@ int handler::check_collation_compatibility() } +int handler::check_long_hash_compatibility() const +{ + if (!table->s->old_long_hash_function()) + return 0; + KEY *key= table->key_info; + KEY *key_end= key + table->s->keys; + for ( ; key < key_end; key++) + { + if (key->algorithm == HA_KEY_ALG_LONG_HASH) + { + /* + The old (pre-MDEV-27653) hash function was wrong. + So the long hash unique constraint can have some + duplicate records. REPAIR TABLE can't fix this, + it will fail on a duplicate key error. + Only "ALTER IGNORE TABLE .. FORCE" can fix this. + So we need to return HA_ADMIN_NEEDS_ALTER here, + (not HA_ADMIN_NEEDS_UPGRADE which is used elsewhere), + to properly send the error message text corresponding + to ER_TABLE_NEEDS_REBUILD (rather than to ER_TABLE_NEEDS_UPGRADE) + to the user. + */ + return HA_ADMIN_NEEDS_ALTER; + } + } + return 0; +} + + int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt) { int error; @@ -4885,6 +4914,9 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt) if (unlikely((error= check_collation_compatibility()))) return error; + + if (unlikely((error= check_long_hash_compatibility()))) + return error; return check_for_upgrade(check_opt); } diff --git a/sql/handler.h b/sql/handler.h index 41bc50e52d4..0810d1a503a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -891,7 +891,7 @@ struct xid_t { long bqual_length; char data[XIDDATASIZE]; // not \0-terminated ! - xid_t() {} /* Remove gcc warning */ + xid_t() = default; /* Remove gcc warning */ bool eq(struct xid_t *xid) const { return !xid->is_null() && eq(xid->gtrid_length, xid->bqual_length, xid->data); } bool eq(long g, long b, const char *d) const @@ -1588,7 +1588,7 @@ struct handlerton public: virtual bool add_table(const char *tname, size_t tlen) = 0; virtual bool add_file(const char *fname) = 0; - protected: virtual ~discovered_list() {} + protected: virtual ~discovered_list() = default; }; /* @@ -1831,7 +1831,7 @@ struct THD_TRANS m_unsafe_rollback_flags= 0; } bool is_empty() const { return ha_list == NULL; } - THD_TRANS() {} /* Remove gcc warning */ + THD_TRANS() = default; /* Remove gcc warning */ unsigned int m_unsafe_rollback_flags; /* @@ -2072,7 +2072,7 @@ struct Table_period_info: Sql_alloc struct start_end_t { - start_end_t() {}; + start_end_t() = default; start_end_t(const LEX_CSTRING& _start, const LEX_CSTRING& _end) : start(_start), end(_end) {} @@ -2432,9 +2432,9 @@ struct KEY_PAIR class inplace_alter_handler_ctx : public Sql_alloc { public: - inplace_alter_handler_ctx() {} + inplace_alter_handler_ctx() = default; - virtual ~inplace_alter_handler_ctx() {} + virtual ~inplace_alter_handler_ctx() = default; virtual void set_shared_data(const inplace_alter_handler_ctx& ctx) {} }; @@ -2681,7 +2681,7 @@ typedef class Item COND; typedef struct st_ha_check_opt { - st_ha_check_opt() {} /* Remove gcc warning */ + st_ha_check_opt() = default; /* Remove gcc warning */ uint flags; /* isam layer flags (e.g. for myisamchk) */ uint sql_flags; /* sql layer flags - for something myisamchk cannot do */ time_t start_time; /* When check/repair starts */ @@ -3065,8 +3065,8 @@ uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map); class Handler_share { public: - Handler_share() {} - virtual ~Handler_share() {} + Handler_share() = default; + virtual ~Handler_share() = default; }; enum class Compare_keys : uint32_t @@ -3497,6 +3497,7 @@ public: } int check_collation_compatibility(); + int check_long_hash_compatibility() const; int ha_check_for_upgrade(HA_CHECK_OPT *check_opt); /** to be actually called to get 'check()' functionality*/ int ha_check(THD *thd, HA_CHECK_OPT *check_opt); @@ -5460,7 +5461,7 @@ public: const LEX_CSTRING *wild_arg); Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg) : thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {} - ~Discovered_table_list() {} + ~Discovered_table_list() = default; bool add_table(const char *tname, size_t tlen); bool add_file(const char *fname); diff --git a/sql/hash_filo.h b/sql/hash_filo.h index ac84e5ccb7b..4dba104f716 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -35,7 +35,7 @@ class hash_filo_element private: hash_filo_element *next_used,*prev_used; public: - hash_filo_element() {} + hash_filo_element() = default; hash_filo_element *next() { return next_used; } hash_filo_element *prev() diff --git a/sql/hostname.cc b/sql/hostname.cc index 35948db3d23..18164b32517 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -74,8 +74,7 @@ Host_errors::Host_errors() m_local(0) {} -Host_errors::~Host_errors() -{} +Host_errors::~Host_errors() = default; void Host_errors::reset() { diff --git a/sql/item.cc b/sql/item.cc index ce55d77eb4d..92f3d55fcf9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -10831,7 +10831,7 @@ table_map Item_direct_view_ref::used_tables() const table_map used= (*ref)->used_tables(); return (used ? used : - ((null_ref_table != NO_NULL_TABLE) ? + (null_ref_table != NO_NULL_TABLE && !null_ref_table->const_table ? null_ref_table->map : (table_map)0 )); } diff --git a/sql/item.h b/sql/item.h index e15d454c65f..0bbe65e4239 100644 --- a/sql/item.h +++ b/sql/item.h @@ -326,7 +326,7 @@ private: TABLE_LIST *save_next_local; public: - Name_resolution_context_state() {} /* Remove gcc warning */ + Name_resolution_context_state() = default; /* Remove gcc warning */ public: /* Save the state of a name resolution context. */ @@ -427,7 +427,7 @@ class sp_rcontext; class Sp_rcontext_handler { public: - virtual ~Sp_rcontext_handler() {} + virtual ~Sp_rcontext_handler() = default; /** A prefix used for SP variable names in queries: - EXPLAIN EXTENDED @@ -500,8 +500,8 @@ public: required, otherwise we only reading it and SELECT privilege might be required. */ - Settable_routine_parameter() {} - virtual ~Settable_routine_parameter() {} + Settable_routine_parameter() = default; + virtual ~Settable_routine_parameter() = default; virtual void set_required_privilege(bool rw) {}; /* @@ -583,7 +583,7 @@ class Rewritable_query_parameter limit_clause_param(false) { } - virtual ~Rewritable_query_parameter() { } + virtual ~Rewritable_query_parameter() = default; virtual bool append_for_log(THD *thd, String *str) = 0; }; @@ -743,7 +743,7 @@ public: class Item_const { public: - virtual ~Item_const() {} + virtual ~Item_const() = default; virtual const Type_all_attributes *get_type_all_attributes_from_const() const= 0; virtual bool const_is_null() const { return false; } virtual const longlong *const_ptr_longlong() const { return NULL; } @@ -1499,6 +1499,12 @@ public: */ inline ulonglong val_uint() { return (ulonglong) val_int(); } + virtual bool hash_not_null(Hasher *hasher) + { + DBUG_ASSERT(0); + return true; + } + /* Return string representation of this item object. @@ -2916,8 +2922,8 @@ class Field_enumerator { public: virtual void visit_field(Item_field *field)= 0; - virtual ~Field_enumerator() {}; /* purecov: inspected */ - Field_enumerator() {} /* Remove gcc warning */ + virtual ~Field_enumerator() = default;; /* purecov: inspected */ + Field_enumerator() = default; /* Remove gcc warning */ }; class Item_string; @@ -3449,7 +3455,7 @@ public: Item_result_field(THD *thd, Item_result_field *item): Item_fixed_hybrid(thd, item), result_field(item->result_field) {} - ~Item_result_field() {} /* Required with gcc 2.95 */ + ~Item_result_field() = default; Field *get_tmp_table_field() override { return result_field; } Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) override @@ -3691,6 +3697,13 @@ public: { return Sql_mode_dependency(0, field->value_depends_on_sql_mode()); } + bool hash_not_null(Hasher *hasher) override + { + if (field->is_null()) + return true; + field->hash_not_null(hasher); + return false; + } longlong val_int_endpoint(bool left_endp, bool *incl_endp) override; bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override; bool get_date_result(THD *thd, MYSQL_TIME *ltime,date_mode_t fuzzydate) @@ -7699,7 +7712,7 @@ public: */ virtual void close()= 0; - virtual ~Item_iterator() {} + virtual ~Item_iterator() = default; }; diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 05cef6871be..1079394e830 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -61,7 +61,7 @@ Cached_item *new_Cached_item(THD *thd, Item *item, bool pass_through_ref) } } -Cached_item::~Cached_item() {} +Cached_item::~Cached_item() = default; /** Compare with old value and replace value with new value. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8a1e6d9ffc3..fcdb2aaf2d4 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4909,38 +4909,18 @@ Item_cond::fix_fields(THD *thd, Item **ref) if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error flag is set! - /* - The following optimization reduces the depth of an AND-OR tree. - E.g. a WHERE clause like - F1 AND (F2 AND (F2 AND F4)) - is parsed into a tree with the same nested structure as defined - by braces. This optimization will transform such tree into - AND (F1, F2, F3, F4). - Trees of OR items are flattened as well: - ((F1 OR F2) OR (F3 OR F4)) => OR (F1, F2, F3, F4) - Items for removed AND/OR levels will dangle until the death of the - entire statement. - The optimization is currently prepared statements and stored procedures - friendly as it doesn't allocate any memory and its effects are durable - (i.e. do not depend on PS/SP arguments). - */ - while ((item=li++)) + + while (li++) { - while (item->type() == Item::COND_ITEM && - ((Item_cond*) item)->functype() == functype() && - !((Item_cond*) item)->list.is_empty()) - { // Identical function - li.replace(((Item_cond*) item)->list); - ((Item_cond*) item)->list.empty(); - item= *li.ref(); // new current item - } + merge_sub_condition(li); + item= *li.ref(); if (is_top_level_item()) item->top_level_item(); /* replace degraded condition: was: <field> - become: <field> = 1 + become: <field> != 0 */ Item::Type type= item->type(); if (type == Item::FIELD_ITEM || type == Item::REF_ITEM) @@ -4956,7 +4936,9 @@ Item_cond::fix_fields(THD *thd, Item **ref) if (item->fix_fields_if_needed_for_bool(thd, li.ref())) return TRUE; /* purecov: inspected */ - item= *li.ref(); // item can be substituted in fix_fields + merge_sub_condition(li); + item= *li.ref(); // may be substituted in fix_fields/merge_item_if_possible + used_tables_cache|= item->used_tables(); if (item->can_eval_in_optimize() && !item->with_sp_var() && !cond_has_datetime_is_null(item)) @@ -5003,6 +4985,55 @@ Item_cond::fix_fields(THD *thd, Item **ref) return FALSE; } +/** + @brief + Merge a lower-level condition pointed by the iterator into this Item_cond + if possible + + @param li list iterator pointing to condition that must be + examined and merged if possible. + + @details + If an item pointed by the iterator is an instance of Item_cond with the + same functype() as this Item_cond (i.e. both are Item_cond_and or both are + Item_cond_or) then the arguments of that lower-level item can be merged + into the list of arguments of this upper-level Item_cond. + + This optimization reduces the depth of an AND-OR tree. + E.g. a WHERE clause like + F1 AND (F2 AND (F2 AND F4)) + is parsed into a tree with the same nested structure as defined + by braces. This optimization will transform such tree into + AND (F1, F2, F3, F4). + Trees of OR items are flattened as well: + ((F1 OR F2) OR (F3 OR F4)) => OR (F1, F2, F3, F4) + Items for removed AND/OR levels will dangle until the death of the + entire statement. + + The optimization is currently prepared statements and stored procedures + friendly as it doesn't allocate any memory and its effects are durable + (i.e. do not depend on PS/SP arguments). +*/ +void Item_cond::merge_sub_condition(List_iterator<Item>& li) +{ + Item *item= *li.ref(); + + /* + The check for list.is_empty() is to catch empty Item_cond_and() items. + We may encounter Item_cond_and with an empty list, because optimizer code + strips multiple equalities, combines items, then adds multiple equalities + back + */ + while (item->type() == Item::COND_ITEM && + ((Item_cond*) item)->functype() == functype() && + !((Item_cond*) item)->list.is_empty()) + { + li.replace(((Item_cond*) item)->list); + ((Item_cond*) item)->list.empty(); + item= *li.ref(); + } +} + bool Item_cond::eval_not_null_tables(void *opt_arg) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 1422afb0fd0..efe0bf59559 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -252,8 +252,7 @@ protected: Item_bool_func(thd, a), value(a_value), affirmative(a_affirmative) {} - ~Item_func_truth() - {} + ~Item_func_truth() = default; private: /** True for <code>X IS [NOT] TRUE</code>, @@ -275,7 +274,7 @@ class Item_func_istrue : public Item_func_truth { public: Item_func_istrue(THD *thd, Item *a): Item_func_truth(thd, a, true, true) {} - ~Item_func_istrue() {} + ~Item_func_istrue() = default; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("istrue") }; @@ -295,7 +294,7 @@ class Item_func_isnottrue : public Item_func_truth public: Item_func_isnottrue(THD *thd, Item *a): Item_func_truth(thd, a, true, false) {} - ~Item_func_isnottrue() {} + ~Item_func_isnottrue() = default; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("isnottrue") }; @@ -317,7 +316,7 @@ class Item_func_isfalse : public Item_func_truth { public: Item_func_isfalse(THD *thd, Item *a): Item_func_truth(thd, a, false, true) {} - ~Item_func_isfalse() {} + ~Item_func_isfalse() = default; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("isfalse") }; @@ -337,7 +336,7 @@ class Item_func_isnotfalse : public Item_func_truth public: Item_func_isnotfalse(THD *thd, Item *a): Item_func_truth(thd, a, false, false) {} - ~Item_func_isnotfalse() {} + ~Item_func_isnotfalse() = default; LEX_CSTRING func_name_cstring() const override { static LEX_CSTRING name= {STRING_WITH_LEN("isnotfalse") }; @@ -1450,13 +1449,13 @@ public: CHARSET_INFO *collation; uint count; uint used_count; - in_vector() {} + in_vector() = default; in_vector(THD *thd, uint elements, uint element_length, qsort2_cmp cmp_func, CHARSET_INFO *cmp_coll) :base((char*) thd_calloc(thd, elements * element_length)), size(element_length), compare(cmp_func), collation(cmp_coll), count(elements), used_count(elements) {} - virtual ~in_vector() {} + virtual ~in_vector() = default; virtual void set(uint pos,Item *item)=0; virtual uchar *get_value(Item *item)=0; void sort() @@ -1662,7 +1661,7 @@ class cmp_item :public Sql_alloc public: CHARSET_INFO *cmp_charset; cmp_item() { cmp_charset= &my_charset_bin; } - virtual ~cmp_item() {} + virtual ~cmp_item() = default; virtual void store_value(Item *item)= 0; /** @returns result (TRUE, FALSE or UNKNOWN) of @@ -1691,7 +1690,7 @@ class cmp_item_string : public cmp_item_scalar protected: String *value_res; public: - cmp_item_string () {} + cmp_item_string () = default; cmp_item_string (CHARSET_INFO *cs) { cmp_charset= cs; } void set_charset(CHARSET_INFO *cs) { cmp_charset= cs; } friend class cmp_item_sort_string; @@ -1757,7 +1756,7 @@ class cmp_item_int : public cmp_item_scalar { longlong value; public: - cmp_item_int() {} /* Remove gcc warning */ + cmp_item_int() = default; /* Remove gcc warning */ void store_value(Item *item) { value= item->val_int(); @@ -1790,7 +1789,7 @@ class cmp_item_temporal: public cmp_item_scalar protected: longlong value; public: - cmp_item_temporal() {} + cmp_item_temporal() = default; int compare(cmp_item *ci); }; @@ -1846,7 +1845,7 @@ class cmp_item_real : public cmp_item_scalar { double value; public: - cmp_item_real() {} /* Remove gcc warning */ + cmp_item_real() = default; /* Remove gcc warning */ void store_value(Item *item) { value= item->val_real(); @@ -1876,7 +1875,7 @@ class cmp_item_decimal : public cmp_item_scalar { my_decimal value; public: - cmp_item_decimal() {} /* Remove gcc warning */ + cmp_item_decimal() = default; /* Remove gcc warning */ void store_value(Item *item); int cmp(Item *arg); int cmp_not_null(const Value *val); @@ -3212,6 +3211,9 @@ public: Item *build_clone(THD *thd) override; bool excl_dep_on_table(table_map tab_map) override; bool excl_dep_on_grouping_fields(st_select_lex *sel) override; + +private: + void merge_sub_condition(List_iterator<Item>& li); }; template <template<class> class LI, class T> class Item_equal_iterator; @@ -3715,8 +3717,8 @@ Item *and_expressions(Item *a, Item *b, Item **org_item); class Comp_creator { public: - Comp_creator() {} /* Remove gcc warning */ - virtual ~Comp_creator() {} /* Remove gcc warning */ + Comp_creator() = default; /* Remove gcc warning */ + virtual ~Comp_creator() = default; /* Remove gcc warning */ /** Create operation with given arguments. */ @@ -3735,8 +3737,8 @@ public: class Eq_creator :public Comp_creator { public: - Eq_creator() {} /* Remove gcc warning */ - virtual ~Eq_creator() {} /* Remove gcc warning */ + Eq_creator() = default; /* Remove gcc warning */ + virtual ~Eq_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<>" : "="; } @@ -3747,8 +3749,8 @@ public: class Ne_creator :public Comp_creator { public: - Ne_creator() {} /* Remove gcc warning */ - virtual ~Ne_creator() {} /* Remove gcc warning */ + Ne_creator() = default; /* Remove gcc warning */ + virtual ~Ne_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "=" : "<>"; } @@ -3759,8 +3761,8 @@ public: class Gt_creator :public Comp_creator { public: - Gt_creator() {} /* Remove gcc warning */ - virtual ~Gt_creator() {} /* Remove gcc warning */ + Gt_creator() = default; /* Remove gcc warning */ + virtual ~Gt_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<=" : ">"; } @@ -3771,8 +3773,8 @@ public: class Lt_creator :public Comp_creator { public: - Lt_creator() {} /* Remove gcc warning */ - virtual ~Lt_creator() {} /* Remove gcc warning */ + Lt_creator() = default; /* Remove gcc warning */ + virtual ~Lt_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? ">=" : "<"; } @@ -3783,8 +3785,8 @@ public: class Ge_creator :public Comp_creator { public: - Ge_creator() {} /* Remove gcc warning */ - virtual ~Ge_creator() {} /* Remove gcc warning */ + Ge_creator() = default; /* Remove gcc warning */ + virtual ~Ge_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<" : ">="; } @@ -3795,8 +3797,8 @@ public: class Le_creator :public Comp_creator { public: - Le_creator() {} /* Remove gcc warning */ - virtual ~Le_creator() {} /* Remove gcc warning */ + Le_creator() = default; /* Remove gcc warning */ + virtual ~Le_creator() = default; /* Remove gcc warning */ Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? ">" : "<="; } diff --git a/sql/item_create.cc b/sql/item_create.cc index 14731e3ddac..0e2bcc7b1be 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -90,9 +90,9 @@ public: protected: /** Constructor. */ - Create_sp_func() {} + Create_sp_func() = default; /** Destructor. */ - virtual ~Create_sp_func() {} + virtual ~Create_sp_func() = default; }; @@ -110,8 +110,8 @@ public: static Create_func_abs s_singleton; protected: - Create_func_abs() {} - virtual ~Create_func_abs() {} + Create_func_abs() = default; + virtual ~Create_func_abs() = default; }; @@ -123,8 +123,8 @@ public: static Create_func_acos s_singleton; protected: - Create_func_acos() {} - virtual ~Create_func_acos() {} + Create_func_acos() = default; + virtual ~Create_func_acos() = default; }; @@ -136,8 +136,8 @@ public: static Create_func_addtime s_singleton; protected: - Create_func_addtime() {} - virtual ~Create_func_addtime() {} + Create_func_addtime() = default; + virtual ~Create_func_addtime() = default; }; @@ -149,8 +149,8 @@ public: static Create_func_aes_encrypt s_singleton; protected: - Create_func_aes_encrypt() {} - virtual ~Create_func_aes_encrypt() {} + Create_func_aes_encrypt() = default; + virtual ~Create_func_aes_encrypt() = default; }; @@ -162,8 +162,8 @@ public: static Create_func_aes_decrypt s_singleton; protected: - Create_func_aes_decrypt() {} - virtual ~Create_func_aes_decrypt() {} + Create_func_aes_decrypt() = default; + virtual ~Create_func_aes_decrypt() = default; }; @@ -175,8 +175,8 @@ public: static Create_func_asin s_singleton; protected: - Create_func_asin() {} - virtual ~Create_func_asin() {} + Create_func_asin() = default; + virtual ~Create_func_asin() = default; }; @@ -189,8 +189,8 @@ public: static Create_func_atan s_singleton; protected: - Create_func_atan() {} - virtual ~Create_func_atan() {} + Create_func_atan() = default; + virtual ~Create_func_atan() = default; }; @@ -202,8 +202,8 @@ public: static Create_func_benchmark s_singleton; protected: - Create_func_benchmark() {} - virtual ~Create_func_benchmark() {} + Create_func_benchmark() = default; + virtual ~Create_func_benchmark() = default; }; @@ -215,8 +215,8 @@ public: static Create_func_bin s_singleton; protected: - Create_func_bin() {} - virtual ~Create_func_bin() {} + Create_func_bin() = default; + virtual ~Create_func_bin() = default; }; @@ -228,8 +228,8 @@ public: static Create_func_binlog_gtid_pos s_singleton; protected: - Create_func_binlog_gtid_pos() {} - virtual ~Create_func_binlog_gtid_pos() {} + Create_func_binlog_gtid_pos() = default; + virtual ~Create_func_binlog_gtid_pos() = default; }; @@ -241,8 +241,8 @@ public: static Create_func_bit_count s_singleton; protected: - Create_func_bit_count() {} - virtual ~Create_func_bit_count() {} + Create_func_bit_count() = default; + virtual ~Create_func_bit_count() = default; }; @@ -254,8 +254,8 @@ public: static Create_func_bit_length s_singleton; protected: - Create_func_bit_length() {} - virtual ~Create_func_bit_length() {} + Create_func_bit_length() = default; + virtual ~Create_func_bit_length() = default; }; @@ -267,8 +267,8 @@ public: static Create_func_ceiling s_singleton; protected: - Create_func_ceiling() {} - virtual ~Create_func_ceiling() {} + Create_func_ceiling() = default; + virtual ~Create_func_ceiling() = default; }; @@ -280,8 +280,8 @@ public: static Create_func_chr s_singleton; protected: - Create_func_chr() {} - virtual ~Create_func_chr() {} + Create_func_chr() = default; + virtual ~Create_func_chr() = default; }; @@ -293,8 +293,8 @@ public: static Create_func_char_length s_singleton; protected: - Create_func_char_length() {} - virtual ~Create_func_char_length() {} + Create_func_char_length() = default; + virtual ~Create_func_char_length() = default; }; @@ -306,8 +306,8 @@ public: static Create_func_coercibility s_singleton; protected: - Create_func_coercibility() {} - virtual ~Create_func_coercibility() {} + Create_func_coercibility() = default; + virtual ~Create_func_coercibility() = default; }; class Create_func_dyncol_check : public Create_func_arg1 @@ -318,8 +318,8 @@ public: static Create_func_dyncol_check s_singleton; protected: - Create_func_dyncol_check() {} - virtual ~Create_func_dyncol_check() {} + Create_func_dyncol_check() = default; + virtual ~Create_func_dyncol_check() = default; }; class Create_func_dyncol_exists : public Create_func_arg2 @@ -330,8 +330,8 @@ public: static Create_func_dyncol_exists s_singleton; protected: - Create_func_dyncol_exists() {} - virtual ~Create_func_dyncol_exists() {} + Create_func_dyncol_exists() = default; + virtual ~Create_func_dyncol_exists() = default; }; class Create_func_dyncol_list : public Create_func_arg1 @@ -342,8 +342,8 @@ public: static Create_func_dyncol_list s_singleton; protected: - Create_func_dyncol_list() {} - virtual ~Create_func_dyncol_list() {} + Create_func_dyncol_list() = default; + virtual ~Create_func_dyncol_list() = default; }; class Create_func_dyncol_json : public Create_func_arg1 @@ -354,8 +354,8 @@ public: static Create_func_dyncol_json s_singleton; protected: - Create_func_dyncol_json() {} - virtual ~Create_func_dyncol_json() {} + Create_func_dyncol_json() = default; + virtual ~Create_func_dyncol_json() = default; }; @@ -367,8 +367,8 @@ public: static Create_func_compress s_singleton; protected: - Create_func_compress() {} - virtual ~Create_func_compress() {} + Create_func_compress() = default; + virtual ~Create_func_compress() = default; }; @@ -381,8 +381,8 @@ public: static Create_func_concat s_singleton; protected: - Create_func_concat() {} - virtual ~Create_func_concat() {} + Create_func_concat() = default; + virtual ~Create_func_concat() = default; }; @@ -395,8 +395,8 @@ public: static Create_func_concat_operator_oracle s_singleton; protected: - Create_func_concat_operator_oracle() {} - virtual ~Create_func_concat_operator_oracle() {} + Create_func_concat_operator_oracle() = default; + virtual ~Create_func_concat_operator_oracle() = default; }; @@ -408,8 +408,8 @@ public: static Create_func_decode_histogram s_singleton; protected: - Create_func_decode_histogram() {} - virtual ~Create_func_decode_histogram() {} + Create_func_decode_histogram() = default; + virtual ~Create_func_decode_histogram() = default; }; @@ -422,8 +422,8 @@ public: static Create_func_decode_oracle s_singleton; protected: - Create_func_decode_oracle() {} - virtual ~Create_func_decode_oracle() {} + Create_func_decode_oracle() = default; + virtual ~Create_func_decode_oracle() = default; }; @@ -436,8 +436,8 @@ public: static Create_func_concat_ws s_singleton; protected: - Create_func_concat_ws() {} - virtual ~Create_func_concat_ws() {} + Create_func_concat_ws() = default; + virtual ~Create_func_concat_ws() = default; }; @@ -449,8 +449,8 @@ public: static Create_func_connection_id s_singleton; protected: - Create_func_connection_id() {} - virtual ~Create_func_connection_id() {} + Create_func_connection_id() = default; + virtual ~Create_func_connection_id() = default; }; @@ -462,8 +462,8 @@ public: static Create_func_nvl2 s_singleton; protected: - Create_func_nvl2() {} - virtual ~Create_func_nvl2() {} + Create_func_nvl2() = default; + virtual ~Create_func_nvl2() = default; }; @@ -475,8 +475,8 @@ public: static Create_func_conv s_singleton; protected: - Create_func_conv() {} - virtual ~Create_func_conv() {} + Create_func_conv() = default; + virtual ~Create_func_conv() = default; }; @@ -488,8 +488,8 @@ public: static Create_func_convert_tz s_singleton; protected: - Create_func_convert_tz() {} - virtual ~Create_func_convert_tz() {} + Create_func_convert_tz() = default; + virtual ~Create_func_convert_tz() = default; }; @@ -501,8 +501,8 @@ public: static Create_func_cos s_singleton; protected: - Create_func_cos() {} - virtual ~Create_func_cos() {} + Create_func_cos() = default; + virtual ~Create_func_cos() = default; }; @@ -514,8 +514,8 @@ public: static Create_func_cot s_singleton; protected: - Create_func_cot() {} - virtual ~Create_func_cot() {} + Create_func_cot() = default; + virtual ~Create_func_cot() = default; }; @@ -528,8 +528,8 @@ public: static Create_func_crc32 s_singleton; protected: - Create_func_crc32() {} - virtual ~Create_func_crc32() {} + Create_func_crc32() = default; + virtual ~Create_func_crc32() = default; }; @@ -542,8 +542,8 @@ public: static Create_func_crc32c s_singleton; protected: - Create_func_crc32c() {} - virtual ~Create_func_crc32c() {} + Create_func_crc32c() = default; + virtual ~Create_func_crc32c() = default; }; @@ -555,8 +555,8 @@ public: static Create_func_datediff s_singleton; protected: - Create_func_datediff() {} - virtual ~Create_func_datediff() {} + Create_func_datediff() = default; + virtual ~Create_func_datediff() = default; }; @@ -568,8 +568,8 @@ public: static Create_func_dayname s_singleton; protected: - Create_func_dayname() {} - virtual ~Create_func_dayname() {} + Create_func_dayname() = default; + virtual ~Create_func_dayname() = default; }; @@ -581,8 +581,8 @@ public: static Create_func_dayofmonth s_singleton; protected: - Create_func_dayofmonth() {} - virtual ~Create_func_dayofmonth() {} + Create_func_dayofmonth() = default; + virtual ~Create_func_dayofmonth() = default; }; @@ -594,8 +594,8 @@ public: static Create_func_dayofweek s_singleton; protected: - Create_func_dayofweek() {} - virtual ~Create_func_dayofweek() {} + Create_func_dayofweek() = default; + virtual ~Create_func_dayofweek() = default; }; @@ -607,8 +607,8 @@ public: static Create_func_dayofyear s_singleton; protected: - Create_func_dayofyear() {} - virtual ~Create_func_dayofyear() {} + Create_func_dayofyear() = default; + virtual ~Create_func_dayofyear() = default; }; @@ -620,8 +620,8 @@ public: static Create_func_degrees s_singleton; protected: - Create_func_degrees() {} - virtual ~Create_func_degrees() {} + Create_func_degrees() = default; + virtual ~Create_func_degrees() = default; }; @@ -634,8 +634,8 @@ public: static Create_func_des_decrypt s_singleton; protected: - Create_func_des_decrypt() {} - virtual ~Create_func_des_decrypt() {} + Create_func_des_decrypt() = default; + virtual ~Create_func_des_decrypt() = default; }; @@ -648,8 +648,8 @@ public: static Create_func_des_encrypt s_singleton; protected: - Create_func_des_encrypt() {} - virtual ~Create_func_des_encrypt() {} + Create_func_des_encrypt() = default; + virtual ~Create_func_des_encrypt() = default; }; @@ -662,8 +662,8 @@ public: static Create_func_elt s_singleton; protected: - Create_func_elt() {} - virtual ~Create_func_elt() {} + Create_func_elt() = default; + virtual ~Create_func_elt() = default; }; @@ -675,8 +675,8 @@ public: static Create_func_encode s_singleton; protected: - Create_func_encode() {} - virtual ~Create_func_encode() {} + Create_func_encode() = default; + virtual ~Create_func_encode() = default; }; @@ -689,8 +689,8 @@ public: static Create_func_encrypt s_singleton; protected: - Create_func_encrypt() {} - virtual ~Create_func_encrypt() {} + Create_func_encrypt() = default; + virtual ~Create_func_encrypt() = default; }; @@ -702,8 +702,8 @@ public: static Create_func_exp s_singleton; protected: - Create_func_exp() {} - virtual ~Create_func_exp() {} + Create_func_exp() = default; + virtual ~Create_func_exp() = default; }; @@ -716,8 +716,8 @@ public: static Create_func_export_set s_singleton; protected: - Create_func_export_set() {} - virtual ~Create_func_export_set() {} + Create_func_export_set() = default; + virtual ~Create_func_export_set() = default; }; @@ -730,8 +730,8 @@ public: static Create_func_field s_singleton; protected: - Create_func_field() {} - virtual ~Create_func_field() {} + Create_func_field() = default; + virtual ~Create_func_field() = default; }; @@ -743,8 +743,8 @@ public: static Create_func_find_in_set s_singleton; protected: - Create_func_find_in_set() {} - virtual ~Create_func_find_in_set() {} + Create_func_find_in_set() = default; + virtual ~Create_func_find_in_set() = default; }; @@ -756,8 +756,8 @@ public: static Create_func_floor s_singleton; protected: - Create_func_floor() {} - virtual ~Create_func_floor() {} + Create_func_floor() = default; + virtual ~Create_func_floor() = default; }; @@ -770,8 +770,8 @@ public: static Create_func_format s_singleton; protected: - Create_func_format() {} - virtual ~Create_func_format() {} + Create_func_format() = default; + virtual ~Create_func_format() = default; }; @@ -783,8 +783,8 @@ public: static Create_func_found_rows s_singleton; protected: - Create_func_found_rows() {} - virtual ~Create_func_found_rows() {} + Create_func_found_rows() = default; + virtual ~Create_func_found_rows() = default; }; @@ -796,8 +796,8 @@ public: static Create_func_from_base64 s_singleton; protected: - Create_func_from_base64() {} - virtual ~Create_func_from_base64() {} + Create_func_from_base64() = default; + virtual ~Create_func_from_base64() = default; }; @@ -809,8 +809,8 @@ public: static Create_func_from_days s_singleton; protected: - Create_func_from_days() {} - virtual ~Create_func_from_days() {} + Create_func_from_days() = default; + virtual ~Create_func_from_days() = default; }; @@ -823,8 +823,8 @@ public: static Create_func_from_unixtime s_singleton; protected: - Create_func_from_unixtime() {} - virtual ~Create_func_from_unixtime() {} + Create_func_from_unixtime() = default; + virtual ~Create_func_from_unixtime() = default; }; @@ -836,8 +836,8 @@ public: static Create_func_get_lock s_singleton; protected: - Create_func_get_lock() {} - virtual ~Create_func_get_lock() {} + Create_func_get_lock() = default; + virtual ~Create_func_get_lock() = default; }; @@ -850,8 +850,8 @@ public: static Create_func_greatest s_singleton; protected: - Create_func_greatest() {} - virtual ~Create_func_greatest() {} + Create_func_greatest() = default; + virtual ~Create_func_greatest() = default; }; @@ -863,8 +863,8 @@ public: static Create_func_hex s_singleton; protected: - Create_func_hex() {} - virtual ~Create_func_hex() {} + Create_func_hex() = default; + virtual ~Create_func_hex() = default; }; @@ -876,8 +876,8 @@ public: static Create_func_ifnull s_singleton; protected: - Create_func_ifnull() {} - virtual ~Create_func_ifnull() {} + Create_func_ifnull() = default; + virtual ~Create_func_ifnull() = default; }; @@ -889,8 +889,8 @@ public: static Create_func_instr s_singleton; protected: - Create_func_instr() {} - virtual ~Create_func_instr() {} + Create_func_instr() = default; + virtual ~Create_func_instr() = default; }; @@ -902,8 +902,8 @@ public: static Create_func_is_free_lock s_singleton; protected: - Create_func_is_free_lock() {} - virtual ~Create_func_is_free_lock() {} + Create_func_is_free_lock() = default; + virtual ~Create_func_is_free_lock() = default; }; @@ -915,8 +915,8 @@ public: static Create_func_is_used_lock s_singleton; protected: - Create_func_is_used_lock() {} - virtual ~Create_func_is_used_lock() {} + Create_func_is_used_lock() = default; + virtual ~Create_func_is_used_lock() = default; }; @@ -928,8 +928,8 @@ public: static Create_func_isnull s_singleton; protected: - Create_func_isnull() {} - virtual ~Create_func_isnull() {} + Create_func_isnull() = default; + virtual ~Create_func_isnull() = default; }; @@ -941,8 +941,8 @@ public: static Create_func_json_normalize s_singleton; protected: - Create_func_json_normalize() {} - virtual ~Create_func_json_normalize() {} + Create_func_json_normalize() = default; + virtual ~Create_func_json_normalize() = default; }; @@ -954,8 +954,8 @@ public: static Create_func_json_equals s_singleton; protected: - Create_func_json_equals() {} - virtual ~Create_func_json_equals() {} + Create_func_json_equals() = default; + virtual ~Create_func_json_equals() = default; }; @@ -967,8 +967,8 @@ public: static Create_func_json_exists s_singleton; protected: - Create_func_json_exists() {} - virtual ~Create_func_json_exists() {} + Create_func_json_exists() = default; + virtual ~Create_func_json_exists() = default; }; @@ -980,8 +980,8 @@ public: static Create_func_json_valid s_singleton; protected: - Create_func_json_valid() {} - virtual ~Create_func_json_valid() {} + Create_func_json_valid() = default; + virtual ~Create_func_json_valid() = default; }; @@ -993,8 +993,8 @@ public: static Create_func_json_compact s_singleton; protected: - Create_func_json_compact() {} - virtual ~Create_func_json_compact() {} + Create_func_json_compact() = default; + virtual ~Create_func_json_compact() = default; }; @@ -1006,8 +1006,8 @@ public: static Create_func_json_loose s_singleton; protected: - Create_func_json_loose() {} - virtual ~Create_func_json_loose() {} + Create_func_json_loose() = default; + virtual ~Create_func_json_loose() = default; }; @@ -1020,8 +1020,8 @@ public: static Create_func_json_detailed s_singleton; protected: - Create_func_json_detailed() {} - virtual ~Create_func_json_detailed() {} + Create_func_json_detailed() = default; + virtual ~Create_func_json_detailed() = default; }; @@ -1033,8 +1033,8 @@ public: static Create_func_json_type s_singleton; protected: - Create_func_json_type() {} - virtual ~Create_func_json_type() {} + Create_func_json_type() = default; + virtual ~Create_func_json_type() = default; }; @@ -1046,8 +1046,8 @@ public: static Create_func_json_depth s_singleton; protected: - Create_func_json_depth() {} - virtual ~Create_func_json_depth() {} + Create_func_json_depth() = default; + virtual ~Create_func_json_depth() = default; }; @@ -1059,8 +1059,8 @@ public: static Create_func_json_value s_singleton; protected: - Create_func_json_value() {} - virtual ~Create_func_json_value() {} + Create_func_json_value() = default; + virtual ~Create_func_json_value() = default; }; @@ -1072,8 +1072,8 @@ public: static Create_func_json_query s_singleton; protected: - Create_func_json_query() {} - virtual ~Create_func_json_query() {} + Create_func_json_query() = default; + virtual ~Create_func_json_query() = default; }; @@ -1086,8 +1086,8 @@ public: static Create_func_json_keys s_singleton; protected: - Create_func_json_keys() {} - virtual ~Create_func_json_keys() {} + Create_func_json_keys() = default; + virtual ~Create_func_json_keys() = default; }; @@ -1100,8 +1100,8 @@ public: static Create_func_json_contains s_singleton; protected: - Create_func_json_contains() {} - virtual ~Create_func_json_contains() {} + Create_func_json_contains() = default; + virtual ~Create_func_json_contains() = default; }; @@ -1114,8 +1114,8 @@ public: static Create_func_json_contains_path s_singleton; protected: - Create_func_json_contains_path() {} - virtual ~Create_func_json_contains_path() {} + Create_func_json_contains_path() = default; + virtual ~Create_func_json_contains_path() = default; }; @@ -1128,8 +1128,8 @@ public: static Create_func_json_extract s_singleton; protected: - Create_func_json_extract() {} - virtual ~Create_func_json_extract() {} + Create_func_json_extract() = default; + virtual ~Create_func_json_extract() = default; }; @@ -1142,8 +1142,8 @@ public: static Create_func_json_search s_singleton; protected: - Create_func_json_search() {} - virtual ~Create_func_json_search() {} + Create_func_json_search() = default; + virtual ~Create_func_json_search() = default; }; @@ -1156,8 +1156,8 @@ public: static Create_func_json_array s_singleton; protected: - Create_func_json_array() {} - virtual ~Create_func_json_array() {} + Create_func_json_array() = default; + virtual ~Create_func_json_array() = default; }; @@ -1170,8 +1170,8 @@ public: static Create_func_json_array_append s_singleton; protected: - Create_func_json_array_append() {} - virtual ~Create_func_json_array_append() {} + Create_func_json_array_append() = default; + virtual ~Create_func_json_array_append() = default; }; @@ -1184,8 +1184,8 @@ public: static Create_func_json_array_insert s_singleton; protected: - Create_func_json_array_insert() {} - virtual ~Create_func_json_array_insert() {} + Create_func_json_array_insert() = default; + virtual ~Create_func_json_array_insert() = default; }; @@ -1198,8 +1198,8 @@ public: static Create_func_json_insert s_singleton; protected: - Create_func_json_insert() {} - virtual ~Create_func_json_insert() {} + Create_func_json_insert() = default; + virtual ~Create_func_json_insert() = default; }; @@ -1212,8 +1212,8 @@ public: static Create_func_json_set s_singleton; protected: - Create_func_json_set() {} - virtual ~Create_func_json_set() {} + Create_func_json_set() = default; + virtual ~Create_func_json_set() = default; }; @@ -1226,8 +1226,8 @@ public: static Create_func_json_replace s_singleton; protected: - Create_func_json_replace() {} - virtual ~Create_func_json_replace() {} + Create_func_json_replace() = default; + virtual ~Create_func_json_replace() = default; }; @@ -1240,8 +1240,8 @@ public: static Create_func_json_remove s_singleton; protected: - Create_func_json_remove() {} - virtual ~Create_func_json_remove() {} + Create_func_json_remove() = default; + virtual ~Create_func_json_remove() = default; }; @@ -1254,8 +1254,8 @@ public: static Create_func_json_object s_singleton; protected: - Create_func_json_object() {} - virtual ~Create_func_json_object() {} + Create_func_json_object() = default; + virtual ~Create_func_json_object() = default; }; @@ -1268,8 +1268,8 @@ public: static Create_func_json_length s_singleton; protected: - Create_func_json_length() {} - virtual ~Create_func_json_length() {} + Create_func_json_length() = default; + virtual ~Create_func_json_length() = default; }; @@ -1282,8 +1282,8 @@ public: static Create_func_json_merge s_singleton; protected: - Create_func_json_merge() {} - virtual ~Create_func_json_merge() {} + Create_func_json_merge() = default; + virtual ~Create_func_json_merge() = default; }; @@ -1296,8 +1296,8 @@ public: static Create_func_json_merge_patch s_singleton; protected: - Create_func_json_merge_patch() {} - virtual ~Create_func_json_merge_patch() {} + Create_func_json_merge_patch() = default; + virtual ~Create_func_json_merge_patch() = default; }; @@ -1309,8 +1309,8 @@ public: static Create_func_json_quote s_singleton; protected: - Create_func_json_quote() {} - virtual ~Create_func_json_quote() {} + Create_func_json_quote() = default; + virtual ~Create_func_json_quote() = default; }; @@ -1322,8 +1322,8 @@ public: static Create_func_json_unquote s_singleton; protected: - Create_func_json_unquote() {} - virtual ~Create_func_json_unquote() {} + Create_func_json_unquote() = default; + virtual ~Create_func_json_unquote() = default; }; @@ -1348,8 +1348,8 @@ public: static Create_func_last_day s_singleton; protected: - Create_func_last_day() {} - virtual ~Create_func_last_day() {} + Create_func_last_day() = default; + virtual ~Create_func_last_day() = default; }; @@ -1362,8 +1362,8 @@ public: static Create_func_last_insert_id s_singleton; protected: - Create_func_last_insert_id() {} - virtual ~Create_func_last_insert_id() {} + Create_func_last_insert_id() = default; + virtual ~Create_func_last_insert_id() = default; }; @@ -1375,8 +1375,8 @@ public: static Create_func_lcase s_singleton; protected: - Create_func_lcase() {} - virtual ~Create_func_lcase() {} + Create_func_lcase() = default; + virtual ~Create_func_lcase() = default; }; @@ -1389,8 +1389,8 @@ public: static Create_func_least s_singleton; protected: - Create_func_least() {} - virtual ~Create_func_least() {} + Create_func_least() = default; + virtual ~Create_func_least() = default; }; @@ -1402,8 +1402,8 @@ public: static Create_func_length s_singleton; protected: - Create_func_length() {} - virtual ~Create_func_length() {} + Create_func_length() = default; + virtual ~Create_func_length() = default; }; class Create_func_octet_length : public Create_func_arg1 @@ -1414,8 +1414,8 @@ public: static Create_func_octet_length s_singleton; protected: - Create_func_octet_length() {} - virtual ~Create_func_octet_length() {} + Create_func_octet_length() = default; + virtual ~Create_func_octet_length() = default; }; @@ -1428,8 +1428,8 @@ public: static Create_func_like_range_min s_singleton; protected: - Create_func_like_range_min() {} - virtual ~Create_func_like_range_min() {} + Create_func_like_range_min() = default; + virtual ~Create_func_like_range_min() = default; }; @@ -1441,8 +1441,8 @@ public: static Create_func_like_range_max s_singleton; protected: - Create_func_like_range_max() {} - virtual ~Create_func_like_range_max() {} + Create_func_like_range_max() = default; + virtual ~Create_func_like_range_max() = default; }; #endif @@ -1455,8 +1455,8 @@ public: static Create_func_ln s_singleton; protected: - Create_func_ln() {} - virtual ~Create_func_ln() {} + Create_func_ln() = default; + virtual ~Create_func_ln() = default; }; @@ -1468,8 +1468,8 @@ public: static Create_func_load_file s_singleton; protected: - Create_func_load_file() {} - virtual ~Create_func_load_file() {} + Create_func_load_file() = default; + virtual ~Create_func_load_file() = default; }; @@ -1482,8 +1482,8 @@ public: static Create_func_locate s_singleton; protected: - Create_func_locate() {} - virtual ~Create_func_locate() {} + Create_func_locate() = default; + virtual ~Create_func_locate() = default; }; @@ -1496,8 +1496,8 @@ public: static Create_func_log s_singleton; protected: - Create_func_log() {} - virtual ~Create_func_log() {} + Create_func_log() = default; + virtual ~Create_func_log() = default; }; @@ -1509,8 +1509,8 @@ public: static Create_func_log10 s_singleton; protected: - Create_func_log10() {} - virtual ~Create_func_log10() {} + Create_func_log10() = default; + virtual ~Create_func_log10() = default; }; @@ -1522,8 +1522,8 @@ public: static Create_func_log2 s_singleton; protected: - Create_func_log2() {} - virtual ~Create_func_log2() {} + Create_func_log2() = default; + virtual ~Create_func_log2() = default; }; @@ -1540,8 +1540,8 @@ public: static Create_func_lpad s_singleton; protected: - Create_func_lpad() {} - virtual ~Create_func_lpad() {} + Create_func_lpad() = default; + virtual ~Create_func_lpad() = default; Item *create_native_std(THD *thd, const LEX_CSTRING *name, List<Item> *items); Item *create_native_oracle(THD *thd, const LEX_CSTRING *name, @@ -1569,8 +1569,8 @@ public: static Create_func_ltrim s_singleton; protected: - Create_func_ltrim() {} - virtual ~Create_func_ltrim() {} + Create_func_ltrim() = default; + virtual ~Create_func_ltrim() = default; }; @@ -1582,8 +1582,8 @@ public: static Create_func_ltrim_oracle s_singleton; protected: - Create_func_ltrim_oracle() {} - virtual ~Create_func_ltrim_oracle() {} + Create_func_ltrim_oracle() = default; + virtual ~Create_func_ltrim_oracle() = default; }; @@ -1595,8 +1595,8 @@ public: static Create_func_makedate s_singleton; protected: - Create_func_makedate() {} - virtual ~Create_func_makedate() {} + Create_func_makedate() = default; + virtual ~Create_func_makedate() = default; }; @@ -1608,8 +1608,8 @@ public: static Create_func_maketime s_singleton; protected: - Create_func_maketime() {} - virtual ~Create_func_maketime() {} + Create_func_maketime() = default; + virtual ~Create_func_maketime() = default; }; @@ -1622,8 +1622,8 @@ public: static Create_func_make_set s_singleton; protected: - Create_func_make_set() {} - virtual ~Create_func_make_set() {} + Create_func_make_set() = default; + virtual ~Create_func_make_set() = default; }; @@ -1636,8 +1636,8 @@ public: static Create_func_master_pos_wait s_singleton; protected: - Create_func_master_pos_wait() {} - virtual ~Create_func_master_pos_wait() {} + Create_func_master_pos_wait() = default; + virtual ~Create_func_master_pos_wait() = default; }; @@ -1650,8 +1650,8 @@ public: static Create_func_master_gtid_wait s_singleton; protected: - Create_func_master_gtid_wait() {} - virtual ~Create_func_master_gtid_wait() {} + Create_func_master_gtid_wait() = default; + virtual ~Create_func_master_gtid_wait() = default; }; @@ -1663,8 +1663,8 @@ public: static Create_func_md5 s_singleton; protected: - Create_func_md5() {} - virtual ~Create_func_md5() {} + Create_func_md5() = default; + virtual ~Create_func_md5() = default; }; @@ -1676,8 +1676,8 @@ public: static Create_func_monthname s_singleton; protected: - Create_func_monthname() {} - virtual ~Create_func_monthname() {} + Create_func_monthname() = default; + virtual ~Create_func_monthname() = default; }; @@ -1689,8 +1689,8 @@ public: static Create_func_name_const s_singleton; protected: - Create_func_name_const() {} - virtual ~Create_func_name_const() {} + Create_func_name_const() = default; + virtual ~Create_func_name_const() = default; }; class Create_func_natural_sort_key : public Create_func_arg1 @@ -1699,8 +1699,8 @@ public: virtual Item *create_1_arg(THD *thd, Item *arg1) override; static Create_func_natural_sort_key s_singleton; protected: - Create_func_natural_sort_key() {} - virtual ~Create_func_natural_sort_key() {} + Create_func_natural_sort_key() = default; + virtual ~Create_func_natural_sort_key() = default; }; class Create_func_nullif : public Create_func_arg2 @@ -1711,8 +1711,8 @@ public: static Create_func_nullif s_singleton; protected: - Create_func_nullif() {} - virtual ~Create_func_nullif() {} + Create_func_nullif() = default; + virtual ~Create_func_nullif() = default; }; @@ -1724,8 +1724,8 @@ public: static Create_func_oct s_singleton; protected: - Create_func_oct() {} - virtual ~Create_func_oct() {} + Create_func_oct() = default; + virtual ~Create_func_oct() = default; }; @@ -1737,8 +1737,8 @@ public: static Create_func_ord s_singleton; protected: - Create_func_ord() {} - virtual ~Create_func_ord() {} + Create_func_ord() = default; + virtual ~Create_func_ord() = default; }; @@ -1750,8 +1750,8 @@ public: static Create_func_period_add s_singleton; protected: - Create_func_period_add() {} - virtual ~Create_func_period_add() {} + Create_func_period_add() = default; + virtual ~Create_func_period_add() = default; }; @@ -1763,8 +1763,8 @@ public: static Create_func_period_diff s_singleton; protected: - Create_func_period_diff() {} - virtual ~Create_func_period_diff() {} + Create_func_period_diff() = default; + virtual ~Create_func_period_diff() = default; }; @@ -1776,8 +1776,8 @@ public: static Create_func_pi s_singleton; protected: - Create_func_pi() {} - virtual ~Create_func_pi() {} + Create_func_pi() = default; + virtual ~Create_func_pi() = default; }; @@ -1789,8 +1789,8 @@ public: static Create_func_pow s_singleton; protected: - Create_func_pow() {} - virtual ~Create_func_pow() {} + Create_func_pow() = default; + virtual ~Create_func_pow() = default; }; @@ -1802,8 +1802,8 @@ public: static Create_func_quote s_singleton; protected: - Create_func_quote() {} - virtual ~Create_func_quote() {} + Create_func_quote() = default; + virtual ~Create_func_quote() = default; }; @@ -1815,8 +1815,8 @@ public: static Create_func_regexp_instr s_singleton; protected: - Create_func_regexp_instr() {} - virtual ~Create_func_regexp_instr() {} + Create_func_regexp_instr() = default; + virtual ~Create_func_regexp_instr() = default; }; @@ -1828,8 +1828,8 @@ public: static Create_func_regexp_replace s_singleton; protected: - Create_func_regexp_replace() {} - virtual ~Create_func_regexp_replace() {} + Create_func_regexp_replace() = default; + virtual ~Create_func_regexp_replace() = default; }; @@ -1841,8 +1841,8 @@ public: static Create_func_regexp_substr s_singleton; protected: - Create_func_regexp_substr() {} - virtual ~Create_func_regexp_substr() {} + Create_func_regexp_substr() = default; + virtual ~Create_func_regexp_substr() = default; }; @@ -1854,8 +1854,8 @@ public: static Create_func_radians s_singleton; protected: - Create_func_radians() {} - virtual ~Create_func_radians() {} + Create_func_radians() = default; + virtual ~Create_func_radians() = default; }; @@ -1868,8 +1868,8 @@ public: static Create_func_rand s_singleton; protected: - Create_func_rand() {} - virtual ~Create_func_rand() {} + Create_func_rand() = default; + virtual ~Create_func_rand() = default; }; @@ -1903,8 +1903,8 @@ public: static Create_func_release_lock s_singleton; protected: - Create_func_release_lock() {} - virtual ~Create_func_release_lock() {} + Create_func_release_lock() = default; + virtual ~Create_func_release_lock() = default; }; @@ -1916,8 +1916,8 @@ public: static Create_func_replace_oracle s_singleton; protected: - Create_func_replace_oracle() {} - virtual ~Create_func_replace_oracle() {} + Create_func_replace_oracle() = default; + virtual ~Create_func_replace_oracle() = default; }; @@ -1929,8 +1929,8 @@ public: static Create_func_reverse s_singleton; protected: - Create_func_reverse() {} - virtual ~Create_func_reverse() {} + Create_func_reverse() = default; + virtual ~Create_func_reverse() = default; }; @@ -1943,8 +1943,8 @@ public: static Create_func_round s_singleton; protected: - Create_func_round() {} - virtual ~Create_func_round() {} + Create_func_round() = default; + virtual ~Create_func_round() = default; }; @@ -1961,8 +1961,8 @@ public: static Create_func_rpad s_singleton; protected: - Create_func_rpad() {} - virtual ~Create_func_rpad() {} + Create_func_rpad() = default; + virtual ~Create_func_rpad() = default; Item *create_native_std(THD *thd, const LEX_CSTRING *name, List<Item> *items); Item *create_native_oracle(THD *thd, const LEX_CSTRING *name, @@ -1990,8 +1990,8 @@ public: static Create_func_rtrim s_singleton; protected: - Create_func_rtrim() {} - virtual ~Create_func_rtrim() {} + Create_func_rtrim() = default; + virtual ~Create_func_rtrim() = default; }; @@ -2003,8 +2003,8 @@ public: static Create_func_rtrim_oracle s_singleton; protected: - Create_func_rtrim_oracle() {} - virtual ~Create_func_rtrim_oracle() {} + Create_func_rtrim_oracle() = default; + virtual ~Create_func_rtrim_oracle() = default; }; @@ -2016,8 +2016,8 @@ public: static Create_func_sec_to_time s_singleton; protected: - Create_func_sec_to_time() {} - virtual ~Create_func_sec_to_time() {} + Create_func_sec_to_time() = default; + virtual ~Create_func_sec_to_time() = default; }; class Create_func_sformat : public Create_native_func @@ -2027,8 +2027,8 @@ public: override; static Create_func_sformat s_singleton; protected: - Create_func_sformat() {} - virtual ~Create_func_sformat() {} + Create_func_sformat() = default; + virtual ~Create_func_sformat() = default; }; class Create_func_sha : public Create_func_arg1 @@ -2039,8 +2039,8 @@ public: static Create_func_sha s_singleton; protected: - Create_func_sha() {} - virtual ~Create_func_sha() {} + Create_func_sha() = default; + virtual ~Create_func_sha() = default; }; @@ -2052,8 +2052,8 @@ public: static Create_func_sha2 s_singleton; protected: - Create_func_sha2() {} - virtual ~Create_func_sha2() {} + Create_func_sha2() = default; + virtual ~Create_func_sha2() = default; }; @@ -2065,8 +2065,8 @@ public: static Create_func_sign s_singleton; protected: - Create_func_sign() {} - virtual ~Create_func_sign() {} + Create_func_sign() = default; + virtual ~Create_func_sign() = default; }; @@ -2078,8 +2078,8 @@ public: static Create_func_sin s_singleton; protected: - Create_func_sin() {} - virtual ~Create_func_sin() {} + Create_func_sin() = default; + virtual ~Create_func_sin() = default; }; @@ -2091,8 +2091,8 @@ public: static Create_func_sleep s_singleton; protected: - Create_func_sleep() {} - virtual ~Create_func_sleep() {} + Create_func_sleep() = default; + virtual ~Create_func_sleep() = default; }; @@ -2104,8 +2104,8 @@ public: static Create_func_soundex s_singleton; protected: - Create_func_soundex() {} - virtual ~Create_func_soundex() {} + Create_func_soundex() = default; + virtual ~Create_func_soundex() = default; }; @@ -2117,8 +2117,8 @@ public: static Create_func_space s_singleton; protected: - Create_func_space() {} - virtual ~Create_func_space() {} + Create_func_space() = default; + virtual ~Create_func_space() = default; }; @@ -2130,8 +2130,8 @@ public: static Create_func_sqrt s_singleton; protected: - Create_func_sqrt() {} - virtual ~Create_func_sqrt() {} + Create_func_sqrt() = default; + virtual ~Create_func_sqrt() = default; }; @@ -2143,8 +2143,8 @@ public: static Create_func_str_to_date s_singleton; protected: - Create_func_str_to_date() {} - virtual ~Create_func_str_to_date() {} + Create_func_str_to_date() = default; + virtual ~Create_func_str_to_date() = default; }; @@ -2156,8 +2156,8 @@ public: static Create_func_strcmp s_singleton; protected: - Create_func_strcmp() {} - virtual ~Create_func_strcmp() {} + Create_func_strcmp() = default; + virtual ~Create_func_strcmp() = default; }; @@ -2169,8 +2169,8 @@ public: static Create_func_substr_index s_singleton; protected: - Create_func_substr_index() {} - virtual ~Create_func_substr_index() {} + Create_func_substr_index() = default; + virtual ~Create_func_substr_index() = default; }; @@ -2183,8 +2183,8 @@ public: static Create_func_substr_oracle s_singleton; protected: - Create_func_substr_oracle() {} - virtual ~Create_func_substr_oracle() {} + Create_func_substr_oracle() = default; + virtual ~Create_func_substr_oracle() = default; }; @@ -2196,8 +2196,8 @@ public: static Create_func_subtime s_singleton; protected: - Create_func_subtime() {} - virtual ~Create_func_subtime() {} + Create_func_subtime() = default; + virtual ~Create_func_subtime() = default; }; @@ -2209,8 +2209,8 @@ public: static Create_func_tan s_singleton; protected: - Create_func_tan() {} - virtual ~Create_func_tan() {} + Create_func_tan() = default; + virtual ~Create_func_tan() = default; }; @@ -2222,8 +2222,8 @@ public: static Create_func_time_format s_singleton; protected: - Create_func_time_format() {} - virtual ~Create_func_time_format() {} + Create_func_time_format() = default; + virtual ~Create_func_time_format() = default; }; @@ -2235,8 +2235,8 @@ public: static Create_func_time_to_sec s_singleton; protected: - Create_func_time_to_sec() {} - virtual ~Create_func_time_to_sec() {} + Create_func_time_to_sec() = default; + virtual ~Create_func_time_to_sec() = default; }; @@ -2248,8 +2248,8 @@ public: static Create_func_timediff s_singleton; protected: - Create_func_timediff() {} - virtual ~Create_func_timediff() {} + Create_func_timediff() = default; + virtual ~Create_func_timediff() = default; }; @@ -2261,8 +2261,8 @@ public: static Create_func_to_base64 s_singleton; protected: - Create_func_to_base64() {} - virtual ~Create_func_to_base64() {} + Create_func_to_base64() = default; + virtual ~Create_func_to_base64() = default; }; @@ -2275,8 +2275,8 @@ public: static Create_func_to_char s_singleton; protected: - Create_func_to_char() {} - virtual ~Create_func_to_char() {} + Create_func_to_char() = default; + virtual ~Create_func_to_char() = default; }; @@ -2288,8 +2288,8 @@ public: static Create_func_to_days s_singleton; protected: - Create_func_to_days() {} - virtual ~Create_func_to_days() {} + Create_func_to_days() = default; + virtual ~Create_func_to_days() = default; }; class Create_func_to_seconds : public Create_func_arg1 @@ -2300,8 +2300,8 @@ public: static Create_func_to_seconds s_singleton; protected: - Create_func_to_seconds() {} - virtual ~Create_func_to_seconds() {} + Create_func_to_seconds() = default; + virtual ~Create_func_to_seconds() = default; }; @@ -2313,8 +2313,8 @@ public: static Create_func_ucase s_singleton; protected: - Create_func_ucase() {} - virtual ~Create_func_ucase() {} + Create_func_ucase() = default; + virtual ~Create_func_ucase() = default; }; @@ -2326,8 +2326,8 @@ public: static Create_func_uncompress s_singleton; protected: - Create_func_uncompress() {} - virtual ~Create_func_uncompress() {} + Create_func_uncompress() = default; + virtual ~Create_func_uncompress() = default; }; @@ -2339,8 +2339,8 @@ public: static Create_func_uncompressed_length s_singleton; protected: - Create_func_uncompressed_length() {} - virtual ~Create_func_uncompressed_length() {} + Create_func_uncompressed_length() = default; + virtual ~Create_func_uncompressed_length() = default; }; @@ -2352,8 +2352,8 @@ public: static Create_func_unhex s_singleton; protected: - Create_func_unhex() {} - virtual ~Create_func_unhex() {} + Create_func_unhex() = default; + virtual ~Create_func_unhex() = default; }; @@ -2366,8 +2366,8 @@ public: static Create_func_unix_timestamp s_singleton; protected: - Create_func_unix_timestamp() {} - virtual ~Create_func_unix_timestamp() {} + Create_func_unix_timestamp() = default; + virtual ~Create_func_unix_timestamp() = default; }; @@ -2379,8 +2379,8 @@ public: static Create_func_uuid_short s_singleton; protected: - Create_func_uuid_short() {} - virtual ~Create_func_uuid_short() {} + Create_func_uuid_short() = default; + virtual ~Create_func_uuid_short() = default; }; @@ -2392,8 +2392,8 @@ public: static Create_func_version s_singleton; protected: - Create_func_version() {} - virtual ~Create_func_version() {} + Create_func_version() = default; + virtual ~Create_func_version() = default; }; @@ -2405,8 +2405,8 @@ public: static Create_func_weekday s_singleton; protected: - Create_func_weekday() {} - virtual ~Create_func_weekday() {} + Create_func_weekday() = default; + virtual ~Create_func_weekday() = default; }; @@ -2418,8 +2418,8 @@ public: static Create_func_weekofyear s_singleton; protected: - Create_func_weekofyear() {} - virtual ~Create_func_weekofyear() {} + Create_func_weekofyear() = default; + virtual ~Create_func_weekofyear() = default; }; @@ -2432,8 +2432,8 @@ public: static Create_func_wsrep_last_written_gtid s_singleton; protected: - Create_func_wsrep_last_written_gtid() {} - virtual ~Create_func_wsrep_last_written_gtid() {} + Create_func_wsrep_last_written_gtid() = default; + virtual ~Create_func_wsrep_last_written_gtid() = default; }; @@ -2445,8 +2445,8 @@ public: static Create_func_wsrep_last_seen_gtid s_singleton; protected: - Create_func_wsrep_last_seen_gtid() {} - virtual ~Create_func_wsrep_last_seen_gtid() {} + Create_func_wsrep_last_seen_gtid() = default; + virtual ~Create_func_wsrep_last_seen_gtid() = default; }; @@ -2459,8 +2459,8 @@ public: static Create_func_wsrep_sync_wait_upto s_singleton; protected: - Create_func_wsrep_sync_wait_upto() {} - virtual ~Create_func_wsrep_sync_wait_upto() {} + Create_func_wsrep_sync_wait_upto() = default; + virtual ~Create_func_wsrep_sync_wait_upto() = default; }; #endif /* WITH_WSREP */ @@ -2473,8 +2473,8 @@ public: static Create_func_xml_extractvalue s_singleton; protected: - Create_func_xml_extractvalue() {} - virtual ~Create_func_xml_extractvalue() {} + Create_func_xml_extractvalue() = default; + virtual ~Create_func_xml_extractvalue() = default; }; @@ -2486,8 +2486,8 @@ public: static Create_func_xml_update s_singleton; protected: - Create_func_xml_update() {} - virtual ~Create_func_xml_update() {} + Create_func_xml_update() = default; + virtual ~Create_func_xml_update() = default; }; @@ -2500,8 +2500,8 @@ public: static Create_func_year_week s_singleton; protected: - Create_func_year_week() {} - virtual ~Create_func_year_week() {} + Create_func_year_week() = default; + virtual ~Create_func_year_week() = default; }; @@ -3679,6 +3679,13 @@ Create_func_get_lock Create_func_get_lock::s_singleton; Item* Create_func_get_lock::create_2_arg(THD *thd, Item *arg1, Item *arg2) { +#ifdef WITH_WSREP + if (WSREP_ON && WSREP(thd)) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "GET_LOCK in cluster (WSREP_ON=ON)"); + return NULL; + } +#endif /* WITH_WSREP */ thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return new (thd->mem_root) Item_func_get_lock(thd, arg1, arg2); @@ -5013,6 +5020,13 @@ Create_func_release_all_locks Create_func_release_all_locks::s_singleton; Item* Create_func_release_all_locks::create_builder(THD *thd) { +#ifdef WITH_WSREP + if (WSREP_ON && WSREP(thd)) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RELEASE_ALL_LOCKS in cluster (WSREP_ON=ON)"); + return NULL; + } +#endif /* WITH_WSREP */ thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return new (thd->mem_root) Item_func_release_all_locks(thd); @@ -5024,6 +5038,13 @@ Create_func_release_lock Create_func_release_lock::s_singleton; Item* Create_func_release_lock::create_1_arg(THD *thd, Item *arg1) { +#ifdef WITH_WSREP + if (WSREP_ON && WSREP(thd)) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), "RELEASE_LOCK in cluster (WSREP_ON=ON)"); + return NULL; + } +#endif /* WITH_WSREP */ thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return new (thd->mem_root) Item_func_release_lock(thd, arg1); diff --git a/sql/item_create.h b/sql/item_create.h index 48e1a14e7fc..7c248e81711 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -63,9 +63,9 @@ public: protected: /** Constructor */ - Create_func() {} + Create_func() = default; /** Destructor */ - virtual ~Create_func() {} + virtual ~Create_func() = default; }; @@ -88,9 +88,9 @@ public: protected: /** Constructor. */ - Create_func_arg0() {} + Create_func_arg0() = default; /** Destructor. */ - virtual ~Create_func_arg0() {} + virtual ~Create_func_arg0() = default; }; @@ -114,9 +114,9 @@ public: protected: /** Constructor. */ - Create_func_arg1() {} + Create_func_arg1() = default; /** Destructor. */ - virtual ~Create_func_arg1() {} + virtual ~Create_func_arg1() = default; }; @@ -141,9 +141,9 @@ public: protected: /** Constructor. */ - Create_func_arg2() {} + Create_func_arg2() = default; /** Destructor. */ - virtual ~Create_func_arg2() {} + virtual ~Create_func_arg2() = default; }; @@ -169,9 +169,9 @@ public: protected: /** Constructor. */ - Create_func_arg3() {} + Create_func_arg3() = default; /** Destructor. */ - virtual ~Create_func_arg3() {} + virtual ~Create_func_arg3() = default; }; @@ -203,9 +203,9 @@ public: protected: /** Constructor. */ - Create_native_func() {} + Create_native_func() = default; /** Destructor. */ - virtual ~Create_native_func() {} + virtual ~Create_native_func() = default; }; @@ -246,9 +246,9 @@ public: protected: /** Constructor. */ - Create_qfunc() {} + Create_qfunc() = default; /** Destructor. */ - virtual ~Create_qfunc() {} + virtual ~Create_qfunc() = default; }; @@ -295,9 +295,9 @@ public: protected: /** Constructor. */ - Create_udf_func() {} + Create_udf_func() = default; /** Destructor. */ - virtual ~Create_udf_func() {} + virtual ~Create_udf_func() = default; }; #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index a07595cbbd8..a94dcefe32f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1767,7 +1767,7 @@ static void calc_hash_for_unique(ulong &nr1, ulong &nr2, String *str) cs->hash_sort((uchar *)str->ptr(), str->length(), &nr1, &nr2); } -longlong Item_func_hash::val_int() +longlong Item_func_hash_mariadb_100403::val_int() { DBUG_EXECUTE_IF("same_long_unique_hash", return 9;); unsigned_flag= true; @@ -1788,6 +1788,24 @@ longlong Item_func_hash::val_int() } +longlong Item_func_hash::val_int() +{ + DBUG_EXECUTE_IF("same_long_unique_hash", return 9;); + unsigned_flag= true; + Hasher hasher; + for(uint i= 0;i<arg_count;i++) + { + if (args[i]->hash_not_null(&hasher)) + { + null_value= 1; + return 0; + } + } + null_value= 0; + return (longlong) hasher.finalize(); +} + + bool Item_func_hash::fix_length_and_dec(THD *thd) { decimals= 0; @@ -3976,7 +3994,7 @@ class Interruptible_wait Interruptible_wait(THD *thd) : m_thd(thd) {} - ~Interruptible_wait() {} + ~Interruptible_wait() = default; public: /** diff --git a/sql/item_func.h b/sql/item_func.h index 520dbdc90c7..6e714814526 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -469,7 +469,7 @@ public: class Handler { public: - virtual ~Handler() { } + virtual ~Handler() = default; virtual String *val_str(Item_handled_func *, String *) const= 0; virtual String *val_str_ascii(Item_handled_func *, String *) const= 0; virtual double val_real(Item_handled_func *) const= 0; @@ -1209,6 +1209,18 @@ public: } }; +class Item_func_hash_mariadb_100403: public Item_func_hash +{ +public: + Item_func_hash_mariadb_100403(THD *thd, List<Item> &item) + :Item_func_hash(thd, item) + {} + longlong val_int(); + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_hash_mariadb_100403>(thd, this); } + const char *func_name() const { return "<hash_mariadb_100403>"; } +}; + class Item_longlong_func: public Item_int_func { public: @@ -3854,8 +3866,7 @@ public: Item_func_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name, const Sp_handler *sph, List<Item> &list); - virtual ~Item_func_sp() - {} + virtual ~Item_func_sp() = default; void update_used_tables() override; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index fc1a4b20e8c..8714417a77d 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -1531,9 +1531,7 @@ exit: } -Item_func_spatial_operation::~Item_func_spatial_operation() -{ -} +Item_func_spatial_operation::~Item_func_spatial_operation() = default; String *Item_func_spatial_operation::val_str(String *str_value) @@ -2788,8 +2786,8 @@ public: static Create_func_area s_singleton; protected: - Create_func_area() {} - virtual ~Create_func_area() {} + Create_func_area() = default; + virtual ~Create_func_area() = default; }; @@ -2804,8 +2802,8 @@ public: static Create_func_as_wkb s_singleton; protected: - Create_func_as_wkb() {} - virtual ~Create_func_as_wkb() {} + Create_func_as_wkb() = default; + virtual ~Create_func_as_wkb() = default; }; @@ -2820,8 +2818,8 @@ public: static Create_func_as_wkt s_singleton; protected: - Create_func_as_wkt() {} - virtual ~Create_func_as_wkt() {} + Create_func_as_wkt() = default; + virtual ~Create_func_as_wkt() = default; }; @@ -2837,8 +2835,8 @@ public: static Create_func_centroid s_singleton; protected: - Create_func_centroid() {} - virtual ~Create_func_centroid() {} + Create_func_centroid() = default; + virtual ~Create_func_centroid() = default; }; @@ -2853,8 +2851,8 @@ public: static Create_func_convexhull s_singleton; protected: - Create_func_convexhull() {} - virtual ~Create_func_convexhull() {} + Create_func_convexhull() = default; + virtual ~Create_func_convexhull() = default; }; @@ -2869,8 +2867,8 @@ public: static Create_func_pointonsurface s_singleton; protected: - Create_func_pointonsurface() {} - virtual ~Create_func_pointonsurface() {} + Create_func_pointonsurface() = default; + virtual ~Create_func_pointonsurface() = default; }; @@ -2886,8 +2884,8 @@ public: static Create_func_mbr_contains s_singleton; protected: - Create_func_mbr_contains() {} - virtual ~Create_func_mbr_contains() {} + Create_func_mbr_contains() = default; + virtual ~Create_func_mbr_contains() = default; }; @@ -2902,8 +2900,8 @@ public: static Create_func_contains s_singleton; protected: - Create_func_contains() {} - virtual ~Create_func_contains() {} + Create_func_contains() = default; + virtual ~Create_func_contains() = default; }; @@ -2918,8 +2916,8 @@ public: static Create_func_crosses s_singleton; protected: - Create_func_crosses() {} - virtual ~Create_func_crosses() {} + Create_func_crosses() = default; + virtual ~Create_func_crosses() = default; }; @@ -2934,8 +2932,8 @@ public: static Create_func_dimension s_singleton; protected: - Create_func_dimension() {} - virtual ~Create_func_dimension() {} + Create_func_dimension() = default; + virtual ~Create_func_dimension() = default; }; @@ -2951,8 +2949,8 @@ public: static Create_func_mbr_disjoint s_singleton; protected: - Create_func_mbr_disjoint() {} - virtual ~Create_func_mbr_disjoint() {} + Create_func_mbr_disjoint() = default; + virtual ~Create_func_mbr_disjoint() = default; }; @@ -2967,8 +2965,8 @@ public: static Create_func_disjoint s_singleton; protected: - Create_func_disjoint() {} - virtual ~Create_func_disjoint() {} + Create_func_disjoint() = default; + virtual ~Create_func_disjoint() = default; }; @@ -2983,8 +2981,8 @@ public: static Create_func_distance s_singleton; protected: - Create_func_distance() {} - virtual ~Create_func_distance() {} + Create_func_distance() = default; + virtual ~Create_func_distance() = default; }; @@ -2996,8 +2994,8 @@ public: static Create_func_distance_sphere s_singleton; protected: - Create_func_distance_sphere() {} - virtual ~Create_func_distance_sphere() {} + Create_func_distance_sphere() = default; + virtual ~Create_func_distance_sphere() = default; }; @@ -3031,8 +3029,8 @@ public: static Create_func_endpoint s_singleton; protected: - Create_func_endpoint() {} - virtual ~Create_func_endpoint() {} + Create_func_endpoint() = default; + virtual ~Create_func_endpoint() = default; }; @@ -3047,8 +3045,8 @@ public: static Create_func_envelope s_singleton; protected: - Create_func_envelope() {} - virtual ~Create_func_envelope() {} + Create_func_envelope() = default; + virtual ~Create_func_envelope() = default; }; class Create_func_boundary : public Create_func_arg1 @@ -3062,8 +3060,8 @@ public: static Create_func_boundary s_singleton; protected: - Create_func_boundary() {} - virtual ~Create_func_boundary() {} + Create_func_boundary() = default; + virtual ~Create_func_boundary() = default; }; @@ -3079,8 +3077,8 @@ public: static Create_func_mbr_equals s_singleton; protected: - Create_func_mbr_equals() {} - virtual ~Create_func_mbr_equals() {} + Create_func_mbr_equals() = default; + virtual ~Create_func_mbr_equals() = default; }; @@ -3096,8 +3094,8 @@ public: static Create_func_equals s_singleton; protected: - Create_func_equals() {} - virtual ~Create_func_equals() {} + Create_func_equals() = default; + virtual ~Create_func_equals() = default; }; @@ -3113,8 +3111,8 @@ public: static Create_func_exteriorring s_singleton; protected: - Create_func_exteriorring() {} - virtual ~Create_func_exteriorring() {} + Create_func_exteriorring() = default; + virtual ~Create_func_exteriorring() = default; }; @@ -3128,8 +3126,8 @@ public: static Create_func_geometry_from_text s_singleton; protected: - Create_func_geometry_from_text() {} - virtual ~Create_func_geometry_from_text() {} + Create_func_geometry_from_text() = default; + virtual ~Create_func_geometry_from_text() = default; }; @@ -3179,8 +3177,8 @@ public: static Create_func_geometry_from_wkb s_singleton; protected: - Create_func_geometry_from_wkb() {} - virtual ~Create_func_geometry_from_wkb() {} + Create_func_geometry_from_wkb() = default; + virtual ~Create_func_geometry_from_wkb() = default; }; @@ -3229,8 +3227,8 @@ public: static Create_func_geometry_from_json s_singleton; protected: - Create_func_geometry_from_json() {} - virtual ~Create_func_geometry_from_json() {} + Create_func_geometry_from_json() = default; + virtual ~Create_func_geometry_from_json() = default; }; @@ -3289,8 +3287,8 @@ public: static Create_func_as_geojson s_singleton; protected: - Create_func_as_geojson() {} - virtual ~Create_func_as_geojson() {} + Create_func_as_geojson() = default; + virtual ~Create_func_as_geojson() = default; }; @@ -3349,8 +3347,8 @@ public: static Create_func_geometry_type s_singleton; protected: - Create_func_geometry_type() {} - virtual ~Create_func_geometry_type() {} + Create_func_geometry_type() = default; + virtual ~Create_func_geometry_type() = default; }; @@ -3366,8 +3364,8 @@ public: static Create_func_geometryn s_singleton; protected: - Create_func_geometryn() {} - virtual ~Create_func_geometryn() {} + Create_func_geometryn() = default; + virtual ~Create_func_geometryn() = default; }; @@ -3383,8 +3381,8 @@ public: static Create_func_gis_debug s_singleton; protected: - Create_func_gis_debug() {} - virtual ~Create_func_gis_debug() {} + Create_func_gis_debug() = default; + virtual ~Create_func_gis_debug() = default; }; #endif @@ -3400,8 +3398,8 @@ public: static Create_func_glength s_singleton; protected: - Create_func_glength() {} - virtual ~Create_func_glength() {} + Create_func_glength() = default; + virtual ~Create_func_glength() = default; }; @@ -3417,8 +3415,8 @@ public: static Create_func_interiorringn s_singleton; protected: - Create_func_interiorringn() {} - virtual ~Create_func_interiorringn() {} + Create_func_interiorringn() = default; + virtual ~Create_func_interiorringn() = default; }; @@ -3433,8 +3431,8 @@ public: static Create_func_relate s_singleton; protected: - Create_func_relate() {} - virtual ~Create_func_relate() {} + Create_func_relate() = default; + virtual ~Create_func_relate() = default; }; @@ -3450,8 +3448,8 @@ public: static Create_func_mbr_intersects s_singleton; protected: - Create_func_mbr_intersects() {} - virtual ~Create_func_mbr_intersects() {} + Create_func_mbr_intersects() = default; + virtual ~Create_func_mbr_intersects() = default; }; @@ -3467,8 +3465,8 @@ public: static Create_func_intersects s_singleton; protected: - Create_func_intersects() {} - virtual ~Create_func_intersects() {} + Create_func_intersects() = default; + virtual ~Create_func_intersects() = default; }; @@ -3484,8 +3482,8 @@ public: static Create_func_intersection s_singleton; protected: - Create_func_intersection() {} - virtual ~Create_func_intersection() {} + Create_func_intersection() = default; + virtual ~Create_func_intersection() = default; }; @@ -3501,8 +3499,8 @@ public: static Create_func_difference s_singleton; protected: - Create_func_difference() {} - virtual ~Create_func_difference() {} + Create_func_difference() = default; + virtual ~Create_func_difference() = default; }; @@ -3518,8 +3516,8 @@ public: static Create_func_union s_singleton; protected: - Create_func_union() {} - virtual ~Create_func_union() {} + Create_func_union() = default; + virtual ~Create_func_union() = default; }; @@ -3535,8 +3533,8 @@ public: static Create_func_symdifference s_singleton; protected: - Create_func_symdifference() {} - virtual ~Create_func_symdifference() {} + Create_func_symdifference() = default; + virtual ~Create_func_symdifference() = default; }; @@ -3551,8 +3549,8 @@ public: static Create_func_buffer s_singleton; protected: - Create_func_buffer() {} - virtual ~Create_func_buffer() {} + Create_func_buffer() = default; + virtual ~Create_func_buffer() = default; }; @@ -3567,8 +3565,8 @@ public: static Create_func_isclosed s_singleton; protected: - Create_func_isclosed() {} - virtual ~Create_func_isclosed() {} + Create_func_isclosed() = default; + virtual ~Create_func_isclosed() = default; }; @@ -3583,8 +3581,8 @@ public: static Create_func_isring s_singleton; protected: - Create_func_isring() {} - virtual ~Create_func_isring() {} + Create_func_isring() = default; + virtual ~Create_func_isring() = default; }; @@ -3599,8 +3597,8 @@ public: static Create_func_isempty s_singleton; protected: - Create_func_isempty() {} - virtual ~Create_func_isempty() {} + Create_func_isempty() = default; + virtual ~Create_func_isempty() = default; }; @@ -3615,8 +3613,8 @@ public: static Create_func_issimple s_singleton; protected: - Create_func_issimple() {} - virtual ~Create_func_issimple() {} + Create_func_issimple() = default; + virtual ~Create_func_issimple() = default; }; @@ -3632,8 +3630,8 @@ public: static Create_func_numgeometries s_singleton; protected: - Create_func_numgeometries() {} - virtual ~Create_func_numgeometries() {} + Create_func_numgeometries() = default; + virtual ~Create_func_numgeometries() = default; }; @@ -3648,8 +3646,8 @@ public: static Create_func_numinteriorring s_singleton; protected: - Create_func_numinteriorring() {} - virtual ~Create_func_numinteriorring() {} + Create_func_numinteriorring() = default; + virtual ~Create_func_numinteriorring() = default; }; @@ -3664,8 +3662,8 @@ public: static Create_func_numpoints s_singleton; protected: - Create_func_numpoints() {} - virtual ~Create_func_numpoints() {} + Create_func_numpoints() = default; + virtual ~Create_func_numpoints() = default; }; @@ -3681,8 +3679,8 @@ public: static Create_func_mbr_overlaps s_singleton; protected: - Create_func_mbr_overlaps() {} - virtual ~Create_func_mbr_overlaps() {} + Create_func_mbr_overlaps() = default; + virtual ~Create_func_mbr_overlaps() = default; }; @@ -3698,8 +3696,8 @@ public: static Create_func_overlaps s_singleton; protected: - Create_func_overlaps() {} - virtual ~Create_func_overlaps() {} + Create_func_overlaps() = default; + virtual ~Create_func_overlaps() = default; }; @@ -3717,8 +3715,8 @@ public: static Create_func_pointn s_singleton; protected: - Create_func_pointn() {} - virtual ~Create_func_pointn() {} + Create_func_pointn() = default; + virtual ~Create_func_pointn() = default; }; @@ -3735,8 +3733,8 @@ public: static Create_func_srid s_singleton; protected: - Create_func_srid() {} - virtual ~Create_func_srid() {} + Create_func_srid() = default; + virtual ~Create_func_srid() = default; }; @@ -3752,8 +3750,8 @@ public: static Create_func_startpoint s_singleton; protected: - Create_func_startpoint() {} - virtual ~Create_func_startpoint() {} + Create_func_startpoint() = default; + virtual ~Create_func_startpoint() = default; }; @@ -3770,8 +3768,8 @@ public: static Create_func_touches s_singleton; protected: - Create_func_touches() {} - virtual ~Create_func_touches() {} + Create_func_touches() = default; + virtual ~Create_func_touches() = default; }; @@ -3787,8 +3785,8 @@ public: static Create_func_mbr_within s_singleton; protected: - Create_func_mbr_within() {} - virtual ~Create_func_mbr_within() {} + Create_func_mbr_within() = default; + virtual ~Create_func_mbr_within() = default; }; @@ -3804,8 +3802,8 @@ public: static Create_func_within s_singleton; protected: - Create_func_within() {} - virtual ~Create_func_within() {} + Create_func_within() = default; + virtual ~Create_func_within() = default; }; @@ -3820,8 +3818,8 @@ public: static Create_func_x s_singleton; protected: - Create_func_x() {} - virtual ~Create_func_x() {} + Create_func_x() = default; + virtual ~Create_func_x() = default; }; @@ -3836,8 +3834,8 @@ public: static Create_func_y s_singleton; protected: - Create_func_y() {} - virtual ~Create_func_y() {} + Create_func_y() = default; + virtual ~Create_func_y() = default; }; diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 89f1c9c8221..590fde88a52 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -4239,7 +4239,7 @@ bool Item_func_json_objectagg::add() result.append(STRING_WITH_LEN(", ")); result.append('"'); - result.append(*key); + st_append_escaped(&result,key); result.append(STRING_WITH_LEN("\":")); buf.length(0); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4d69280cb98..eb9e167ca74 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1848,6 +1848,18 @@ bool Item_func_ucase::fix_length_and_dec(THD *thd) } +bool Item_func_left::hash_not_null(Hasher *hasher) +{ + StringBuffer<STRING_BUFFER_USUAL_SIZE> buf; + String *str= val_str(&buf); + DBUG_ASSERT((str == NULL) == null_value); + if (!str) + return true; + hasher->add(collation.collation, str->ptr(), str->length()); + return false; +} + + String *Item_func_left::val_str(String *str) { DBUG_ASSERT(fixed()); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 30e363e9428..3a3c53385b0 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -582,6 +582,7 @@ class Item_func_left :public Item_str_func String tmp_value; public: Item_func_left(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} + bool hash_not_null(Hasher *hasher) override; String *val_str(String *) override; bool fix_length_and_dec(THD *thd) override; LEX_CSTRING func_name_cstring() const override diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index f8e6a13ce97..30562b5c12c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -2951,7 +2951,9 @@ bool Item_exists_subselect::select_prepare_to_be_in() bool trans_res= FALSE; DBUG_ENTER("Item_exists_subselect::select_prepare_to_be_in"); if (!optimizer && - thd->lex->sql_command == SQLCOM_SELECT && + (thd->lex->sql_command == SQLCOM_SELECT || + thd->lex->sql_command == SQLCOM_UPDATE_MULTI || + thd->lex->sql_command == SQLCOM_DELETE_MULTI) && !unit->first_select()->is_part_of_union() && optimizer_flag(thd, OPTIMIZER_SWITCH_EXISTS_TO_IN) && (is_top_level_item() || diff --git a/sql/item_subselect.h b/sql/item_subselect.h index fdd0333adfd..8d58e16bb28 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -831,7 +831,7 @@ public: item= si; maybe_null= 0; } - virtual ~subselect_engine() {}; // to satisfy compiler + virtual ~subselect_engine() = default;; // to satisfy compiler virtual void cleanup()= 0; /* diff --git a/sql/item_sum.h b/sql/item_sum.h index b9bd99acac2..7308734070d 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -59,7 +59,7 @@ protected: public: Aggregator (Item_sum *arg): item_sum(arg) {} - virtual ~Aggregator () {} /* Keep gcc happy */ + virtual ~Aggregator () = default; /* Keep gcc happy */ enum Aggregator_type { SIMPLE_AGGREGATOR, DISTINCT_AGGREGATOR }; virtual Aggregator_type Aggrtype() = 0; @@ -367,7 +367,14 @@ public: int8 aggr_level; /* nesting level of the aggregating subquery */ int8 max_arg_level; /* max level of unbound column references */ int8 max_sum_func_level;/* max level of aggregation for embedded functions */ - bool quick_group; /* If incremental update of fields */ + + /* + true (the default value) means this aggregate function can be computed + with TemporaryTableWithPartialSums algorithm (see end_update()). + false means this aggregate function needs OrderedGroupBy algorithm (see + end_write_group()). + */ + bool quick_group; /* This list is used by the check for mixing non aggregated fields and sum functions in the ONLY_FULL_GROUP_BY_MODE. We save all outer fields diff --git a/sql/log.cc b/sql/log.cc index 4572b9cca82..48e5145210c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -215,7 +215,7 @@ public: m_message[0]= '\0'; } - virtual ~Silence_log_table_errors() {} + virtual ~Silence_log_table_errors() = default; virtual bool handle_condition(THD *thd, uint sql_errno, @@ -772,14 +772,10 @@ end: } -Log_to_csv_event_handler::Log_to_csv_event_handler() -{ -} +Log_to_csv_event_handler::Log_to_csv_event_handler() = default; -Log_to_csv_event_handler::~Log_to_csv_event_handler() -{ -} +Log_to_csv_event_handler::~Log_to_csv_event_handler() = default; void Log_to_csv_event_handler::cleanup() @@ -1801,6 +1797,7 @@ int binlog_init(void *p) binlog_hton->prepare= binlog_prepare; binlog_hton->start_consistent_snapshot= binlog_start_consistent_snapshot; } + binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN | HTON_NO_ROLLBACK; return 0; } @@ -2119,7 +2116,9 @@ int binlog_commit_by_xid(handlerton *hton, XID *xid) THD *thd= current_thd; if (thd->is_current_stmt_binlog_disabled()) - return 0; + { + return thd->wait_for_prior_commit(); + } /* the asserted state can't be reachable with xa commit */ DBUG_ASSERT(!thd->get_stmt_da()->is_error() || @@ -2151,7 +2150,9 @@ int binlog_rollback_by_xid(handlerton *hton, XID *xid) THD *thd= current_thd; if (thd->is_current_stmt_binlog_disabled()) - return 0; + { + return thd->wait_for_prior_commit(); + } if (thd->get_stmt_da()->is_error() && thd->get_stmt_da()->sql_errno() == ER_XA_RBROLLBACK) diff --git a/sql/log.h b/sql/log.h index 65f70712bbf..c20f0fe5a57 100644 --- a/sql/log.h +++ b/sql/log.h @@ -42,8 +42,8 @@ class TC_LOG { public: int using_heuristic_recover(); - TC_LOG() {} - virtual ~TC_LOG() {} + TC_LOG() = default; + virtual ~TC_LOG() = default; virtual int open(const char *opt_name)=0; virtual void close()=0; @@ -100,7 +100,7 @@ extern PSI_cond_key key_COND_prepare_ordered; class TC_LOG_DUMMY: public TC_LOG // use it to disable the logging { public: - TC_LOG_DUMMY() {} + TC_LOG_DUMMY() = default; int open(const char *opt_name) { return 0; } void close() { } /* @@ -308,7 +308,7 @@ class MYSQL_LOG { public: MYSQL_LOG(); - virtual ~MYSQL_LOG() {} + virtual ~MYSQL_LOG() = default; void init_pthread_objects(); void cleanup(); bool open( @@ -983,7 +983,7 @@ public: class Log_event_handler { public: - Log_event_handler() {} + Log_event_handler() = default; virtual bool init()= 0; virtual void cleanup()= 0; @@ -997,7 +997,7 @@ public: const char *command_type, size_t command_type_len, const char *sql_text, size_t sql_text_len, CHARSET_INFO *client_cs)= 0; - virtual ~Log_event_handler() {} + virtual ~Log_event_handler() = default; }; diff --git a/sql/log_event.cc b/sql/log_event.cc index 788b2509964..cabbfc472be 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -154,7 +154,7 @@ public: reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE); } - ~Write_on_release_cache() {} + ~Write_on_release_cache() = default; bool flush_data() { @@ -3839,9 +3839,7 @@ Ignorable_log_event::Ignorable_log_event(const uchar *buf, DBUG_VOID_RETURN; } -Ignorable_log_event::~Ignorable_log_event() -{ -} +Ignorable_log_event::~Ignorable_log_event() = default; bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, FILE *file) { diff --git a/sql/log_event.h b/sql/log_event.h index 40fdd65c171..6b8853493be 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -2599,7 +2599,7 @@ Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg, Intvar_log_event(const uchar *buf, const Format_description_log_event *description_event); - ~Intvar_log_event() {} + ~Intvar_log_event() = default; Log_event_type get_type_code() { return INTVAR_EVENT;} const char* get_var_type_name(); int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;} @@ -2680,7 +2680,7 @@ class Rand_log_event: public Log_event Rand_log_event(const uchar *buf, const Format_description_log_event *description_event); - ~Rand_log_event() {} + ~Rand_log_event() = default; Log_event_type get_type_code() { return RAND_EVENT;} int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ } #ifdef MYSQL_SERVER @@ -2709,7 +2709,7 @@ public: const Format_description_log_event *description_event): Log_event(buf, description_event) {} - ~Xid_apply_log_event() {} + ~Xid_apply_log_event() = default; bool is_valid() const { return 1; } private: #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) @@ -2760,7 +2760,7 @@ public: Xid_log_event(const uchar *buf, const Format_description_log_event *description_event); - ~Xid_log_event() {} + ~Xid_log_event() = default; Log_event_type get_type_code() { return XID_EVENT;} int get_data_size() { return sizeof(xid); } #ifdef MYSQL_SERVER @@ -2905,7 +2905,7 @@ public: #endif XA_prepare_log_event(const uchar *buf, const Format_description_log_event *description_event); - ~XA_prepare_log_event() {} + ~XA_prepare_log_event() = default; Log_event_type get_type_code() { return XA_PREPARE_LOG_EVENT; } bool is_valid() const { return m_xid.formatID != -1; } int get_data_size() @@ -2980,7 +2980,7 @@ public: User_var_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event); - ~User_var_log_event() {} + ~User_var_log_event() = default; Log_event_type get_type_code() { return USER_VAR_EVENT;} #ifdef MYSQL_SERVER bool write(); @@ -3030,7 +3030,7 @@ public: const Format_description_log_event *description_event): Log_event(buf, description_event) {} - ~Stop_log_event() {} + ~Stop_log_event() = default; Log_event_type get_type_code() { return STOP_EVENT;} bool is_valid() const { return 1; } @@ -3325,7 +3325,7 @@ public: #endif Gtid_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event); - ~Gtid_log_event() { } + ~Gtid_log_event() = default; Log_event_type get_type_code() { return GTID_EVENT; } enum_logged_status logged_status() { return LOGGED_NO_DATA; } int get_data_size() @@ -3500,7 +3500,7 @@ public: Append_block_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event); - ~Append_block_log_event() {} + ~Append_block_log_event() = default; Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;} int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;} bool is_valid() const { return block != 0; } @@ -3541,7 +3541,7 @@ public: Delete_file_log_event(const uchar *buf, uint event_len, const Format_description_log_event* description_event); - ~Delete_file_log_event() {} + ~Delete_file_log_event() = default; Log_event_type get_type_code() { return DELETE_FILE_EVENT;} int get_data_size() { return DELETE_FILE_HEADER_LEN ;} bool is_valid() const { return file_id != 0; } @@ -3581,7 +3581,7 @@ public: Begin_load_query_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event); - ~Begin_load_query_log_event() {} + ~Begin_load_query_log_event() = default; Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; } private: #if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) @@ -3639,7 +3639,7 @@ public: Execute_load_query_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event); - ~Execute_load_query_log_event() {} + ~Execute_load_query_log_event() = default; Log_event_type get_type_code() { return EXECUTE_LOAD_QUERY_EVENT; } bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; } @@ -3677,7 +3677,7 @@ public: {} /* constructor for hopelessly corrupted events */ Unknown_log_event(): Log_event(), what(ENCRYPTED) {} - ~Unknown_log_event() {} + ~Unknown_log_event() = default; bool print(FILE* file, PRINT_EVENT_INFO* print_event_info); Log_event_type get_type_code() { return UNKNOWN_EVENT;} bool is_valid() const { return 1; } diff --git a/sql/mdl.cc b/sql/mdl.cc index c426dbe143b..6cb27efba12 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -415,7 +415,7 @@ public: virtual bool needs_notification(const MDL_ticket *ticket) const = 0; virtual bool conflicting_locks(const MDL_ticket *ticket) const = 0; virtual bitmap_t hog_lock_types_bitmap() const = 0; - virtual ~MDL_lock_strategy() {} + virtual ~MDL_lock_strategy() = default; }; @@ -426,7 +426,7 @@ public: */ struct MDL_scoped_lock : public MDL_lock_strategy { - MDL_scoped_lock() {} + MDL_scoped_lock() = default; virtual const bitmap_t *incompatible_granted_types_bitmap() const { return m_granted_incompatible; } virtual const bitmap_t *incompatible_waiting_types_bitmap() const @@ -463,7 +463,7 @@ public: */ struct MDL_object_lock : public MDL_lock_strategy { - MDL_object_lock() {} + MDL_object_lock() = default; virtual const bitmap_t *incompatible_granted_types_bitmap() const { return m_granted_incompatible; } virtual const bitmap_t *incompatible_waiting_types_bitmap() const @@ -507,7 +507,7 @@ public: struct MDL_backup_lock: public MDL_lock_strategy { - MDL_backup_lock() {} + MDL_backup_lock() = default; virtual const bitmap_t *incompatible_granted_types_bitmap() const { return m_granted_incompatible; } virtual const bitmap_t *incompatible_waiting_types_bitmap() const @@ -1875,13 +1875,11 @@ bool MDL_lock::has_pending_conflicting_lock(enum_mdl_type type) MDL_wait_for_graph_visitor::~MDL_wait_for_graph_visitor() -{ -} += default; MDL_wait_for_subgraph::~MDL_wait_for_subgraph() -{ -} += default; /** Check if ticket represents metadata lock of "stronger" or equal type diff --git a/sql/mdl.h b/sql/mdl.h index 31ac4e81377..998f34ff2bb 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -60,7 +60,7 @@ typedef unsigned short mdl_bitmap_t; class MDL_context_owner { public: - virtual ~MDL_context_owner() {} + virtual ~MDL_context_owner() = default; /** Enter a condition wait. @@ -471,7 +471,7 @@ public: { mdl_key_init(namespace_arg, db_arg, name_arg); } - MDL_key() {} /* To use when part of MDL_request. */ + MDL_key() = default; /* To use when part of MDL_request. */ /** Get thread state name to be used in case when we have to @@ -640,7 +640,7 @@ public: virtual bool inspect_edge(MDL_context *dest) = 0; virtual ~MDL_wait_for_graph_visitor(); - MDL_wait_for_graph_visitor() {} + MDL_wait_for_graph_visitor() = default; }; /** @@ -799,7 +799,7 @@ private: class MDL_savepoint { public: - MDL_savepoint() {}; + MDL_savepoint() = default;; private: MDL_savepoint(MDL_ticket *stmt_ticket, MDL_ticket *trans_ticket) diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 76b026f994a..930ee3f238b 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -204,7 +204,7 @@ class Mrr_reader public: virtual int get_next(range_id_t *range_info) = 0; virtual int refill_buffer(bool initial) = 0; - virtual ~Mrr_reader() {}; /* just to remove compiler warning */ + virtual ~Mrr_reader() = default; /* just to remove compiler warning */ }; diff --git a/sql/my_apc.h b/sql/my_apc.h index cc98e36bbe4..2c0a9ade314 100644 --- a/sql/my_apc.h +++ b/sql/my_apc.h @@ -92,7 +92,7 @@ public: public: /* This function will be called in the target thread */ virtual void call_in_target_thread()= 0; - virtual ~Apc_call() {} + virtual ~Apc_call() = default; }; /* Make a call in the target thread (see function definition for details) */ diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index b16c7146a28..a581899aab2 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -398,12 +398,14 @@ protected: public: +#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS virtual ~Json_writer_struct() { -#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS named_items_expectation.pop_back(); -#endif } +#else + virtual ~Json_writer_struct() = default; +#endif inline bool trace_started() const { diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 100b4c25096..5294b91738b 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -313,7 +313,7 @@ static char *get_plugindir() { static char plugin_dir[2*MAX_PATH]; get_basedir(plugin_dir, sizeof(plugin_dir), mysqld_path, '/'); - strcat(plugin_dir, "/" STR(INSTALL_PLUGINDIR)); + safe_strcat(plugin_dir, sizeof(plugin_dir), "/" STR(INSTALL_PLUGINDIR)); if (access(plugin_dir, 0) == 0) return plugin_dir; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ff69af07f6e..ee368def9be 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1247,8 +1247,7 @@ class Buffered_log : public Sql_alloc public: Buffered_log(enum loglevel level, const char *message); - ~Buffered_log() - {} + ~Buffered_log() = default; void print(void); @@ -1308,11 +1307,9 @@ void Buffered_log::print() class Buffered_logs { public: - Buffered_logs() - {} + Buffered_logs() = default; - ~Buffered_logs() - {} + ~Buffered_logs() = default; void init(); void cleanup(); @@ -2782,11 +2779,9 @@ void close_connection(THD *thd, uint sql_errno) thd->protocol->net_send_error(thd, sql_errno, ER_DEFAULT(sql_errno), NULL); thd->print_aborted_warning(lvl, ER_DEFAULT(sql_errno)); } - else - thd->print_aborted_warning(lvl, (thd->main_security_ctx.user ? - "This connection closed normally" : - "This connection closed normally without" - " authentication")); + else if (!thd->main_security_ctx.user) + thd->print_aborted_warning(lvl, "This connection closed normally without" + " authentication"); thd->disconnect(); @@ -5140,12 +5135,11 @@ static int init_server_components() else // full wsrep initialization { // add basedir/bin to PATH to resolve wsrep script names - char* const tmp_path= (char*)my_alloca(strlen(mysql_home) + - strlen("/bin") + 1); + size_t tmp_path_size= strlen(mysql_home) + 5; /* including "/bin" */ + char* const tmp_path= (char*)my_alloca(tmp_path_size); if (tmp_path) { - strcpy(tmp_path, mysql_home); - strcat(tmp_path, "/bin"); + snprintf(tmp_path, tmp_path_size, "%s/bin", mysql_home); wsrep_prepend_PATH(tmp_path); } else @@ -5988,8 +5982,9 @@ int mysqld_main(int argc, char **argv) char real_server_version[2 * SERVER_VERSION_LENGTH + 10]; set_server_version(real_server_version, sizeof(real_server_version)); - strcat(real_server_version, "' as '"); - strcat(real_server_version, server_version); + safe_strcat(real_server_version, sizeof(real_server_version), "' as '"); + safe_strcat(real_server_version, sizeof(real_server_version), + server_version); sql_print_information(ER_DEFAULT(ER_STARTUP), my_progname, real_server_version, @@ -7982,7 +7977,8 @@ static int mysql_init_variables(void) } else my_path(prg_dev, my_progname, "mysql/bin"); - strcat(prg_dev,"/../"); // Remove 'bin' to get base dir + // Remove 'bin' to get base dir + safe_strcat(prg_dev, sizeof(prg_dev), "/../"); cleanup_dirname(mysql_home,prg_dev); } #else diff --git a/sql/opt_range.cc b/sql/opt_range.cc index f2696683124..0fad2d6e201 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2254,7 +2254,7 @@ public: { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) { TRASH_FREE(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ } - virtual ~TABLE_READ_PLAN() {} /* Remove gcc warning */ + virtual ~TABLE_READ_PLAN() = default; /* Remove gcc warning */ /** Add basic info for this TABLE_READ_PLAN to the optimizer trace. @@ -2289,7 +2289,7 @@ public: TRP_RANGE(SEL_ARG *key_arg, uint idx_arg, uint mrr_flags_arg) : key(key_arg), key_idx(idx_arg), mrr_flags(mrr_flags_arg) {} - virtual ~TRP_RANGE() {} /* Remove gcc warning */ + virtual ~TRP_RANGE() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc) @@ -2338,8 +2338,8 @@ void TRP_RANGE::trace_basic_info(PARAM *param, class TRP_ROR_INTERSECT : public TABLE_READ_PLAN { public: - TRP_ROR_INTERSECT() {} /* Remove gcc warning */ - virtual ~TRP_ROR_INTERSECT() {} /* Remove gcc warning */ + TRP_ROR_INTERSECT() = default; /* Remove gcc warning */ + virtual ~TRP_ROR_INTERSECT() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc); @@ -2365,8 +2365,8 @@ public: class TRP_ROR_UNION : public TABLE_READ_PLAN { public: - TRP_ROR_UNION() {} /* Remove gcc warning */ - virtual ~TRP_ROR_UNION() {} /* Remove gcc warning */ + TRP_ROR_UNION() = default; /* Remove gcc warning */ + virtual ~TRP_ROR_UNION() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc); TABLE_READ_PLAN **first_ror; /* array of ptrs to plans for merged scans */ @@ -2398,8 +2398,8 @@ void TRP_ROR_UNION::trace_basic_info(PARAM *param, class TRP_INDEX_INTERSECT : public TABLE_READ_PLAN { public: - TRP_INDEX_INTERSECT() {} /* Remove gcc warning */ - virtual ~TRP_INDEX_INTERSECT() {} /* Remove gcc warning */ + TRP_INDEX_INTERSECT() = default; /* Remove gcc warning */ + virtual ~TRP_INDEX_INTERSECT() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc); TRP_RANGE **range_scans; /* array of ptrs to plans of intersected scans */ @@ -2435,8 +2435,8 @@ void TRP_INDEX_INTERSECT::trace_basic_info(PARAM *param, class TRP_INDEX_MERGE : public TABLE_READ_PLAN { public: - TRP_INDEX_MERGE() {} /* Remove gcc warning */ - virtual ~TRP_INDEX_MERGE() {} /* Remove gcc warning */ + TRP_INDEX_MERGE() = default; /* Remove gcc warning */ + virtual ~TRP_INDEX_MERGE() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc); TRP_RANGE **range_scans; /* array of ptrs to plans of merged scans */ @@ -2506,7 +2506,7 @@ public: if (key_infix_len) memcpy(this->key_infix, key_infix_arg, key_infix_len); } - virtual ~TRP_GROUP_MIN_MAX() {} /* Remove gcc warning */ + virtual ~TRP_GROUP_MIN_MAX() = default; /* Remove gcc warning */ QUICK_SELECT_I *make_quick(PARAM *param, bool retrieve_full_rows, MEM_ROOT *parent_alloc); @@ -10002,7 +10002,6 @@ tree_or(RANGE_OPT_PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) DBUG_RETURN(tree2); SEL_TREE *result= NULL; - key_map result_keys; key_map ored_keys; SEL_TREE *rtree[2]= {NULL,NULL}; SEL_IMERGE *imerge[2]= {NULL, NULL}; diff --git a/sql/opt_range.h b/sql/opt_range.h index 91cbfb3412b..b3a7939c869 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -354,7 +354,7 @@ public: /* See RANGE_OPT_PARAM::alloced_sel_args */ enum { MAX_SEL_ARGS = 16000 }; - SEL_ARG() {} + SEL_ARG() = default; SEL_ARG(SEL_ARG &); SEL_ARG(Field *, const uchar *, const uchar *); SEL_ARG(Field *field, uint8 part, @@ -1119,7 +1119,7 @@ public: bool group_by_optimization_used; QUICK_SELECT_I(); - virtual ~QUICK_SELECT_I(){}; + virtual ~QUICK_SELECT_I() = default;; /* Do post-constructor initialization. diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index b8e046995e9..99e25a5338a 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -224,7 +224,7 @@ class Dep_value : public Sql_alloc { public: Dep_value(): bound(FALSE) {} - virtual ~Dep_value(){} /* purecov: inspected */ /* stop compiler warnings */ + virtual ~Dep_value() = default; /* purecov: inspected */ bool is_bound() { return bound; } void make_bound() { bound= TRUE; } @@ -358,7 +358,7 @@ const size_t Dep_value::iterator_size= class Dep_module : public Sql_alloc { public: - virtual ~Dep_module(){} /* purecov: inspected */ /* stop compiler warnings */ + virtual ~Dep_module() = default; /* purecov: inspected */ /* Mark as bound. Currently is non-virtual and does nothing */ void make_bound() {}; diff --git a/sql/parse_file.h b/sql/parse_file.h index cd26ffec91a..0589d628bfc 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -55,8 +55,8 @@ struct File_option class Unknown_key_hook { public: - Unknown_key_hook() {} /* Remove gcc warning */ - virtual ~Unknown_key_hook() {} /* Remove gcc warning */ + Unknown_key_hook() = default; /* Remove gcc warning */ + virtual ~Unknown_key_hook() = default; /* Remove gcc warning */ virtual bool process_unknown_string(const char *&unknown_key, uchar* base, MEM_ROOT *mem_root, const char *end)= 0; }; @@ -67,7 +67,7 @@ public: class File_parser_dummy_hook: public Unknown_key_hook { public: - File_parser_dummy_hook() {} /* Remove gcc warning */ + File_parser_dummy_hook() = default; /* Remove gcc warning */ virtual bool process_unknown_string(const char *&unknown_key, uchar* base, MEM_ROOT *mem_root, const char *end); }; diff --git a/sql/partition_element.h b/sql/partition_element.h index 756cab2b7f2..1abaa315218 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -164,7 +164,7 @@ public: option_list(part_elem->option_list), option_struct(part_elem->option_struct) {} - ~partition_element() {} + ~partition_element() = default; part_column_list_val& get_col_val(uint idx) { diff --git a/sql/partition_info.h b/sql/partition_info.h index 971ba92d776..833a231e6ce 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -343,7 +343,7 @@ public: part_field_list.empty(); subpart_field_list.empty(); } - ~partition_info() {} + ~partition_info() = default; partition_info *get_clone(THD *thd, bool empty_data_and_index_file= FALSE); bool set_named_partition_bitmap(const char *part_name, size_t length); diff --git a/sql/protocol.h b/sql/protocol.h index 39569a825d5..4fdfde3e007 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -90,7 +90,7 @@ protected: public: THD *thd; Protocol(THD *thd_arg) { init(thd_arg); } - virtual ~Protocol() {} + virtual ~Protocol() = default; void init(THD* thd_arg); enum { SEND_NUM_ROWS= 1, SEND_EOF= 2, SEND_FORCE_COLUMN_INFO= 4 }; diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h index c80281385ea..8f3f3a10925 100644 --- a/sql/rowid_filter.h +++ b/sql/rowid_filter.h @@ -191,7 +191,7 @@ public: virtual void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2), void *cmp_arg) = 0; - virtual ~Rowid_filter_container() {} + virtual ~Rowid_filter_container() = default; }; @@ -228,7 +228,7 @@ public: */ virtual bool check(char *elem) = 0; - virtual ~Rowid_filter() {} + virtual ~Rowid_filter() = default; bool is_empty() { return container->is_empty(); } diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc index 2319f69d67c..3080d92bf63 100644 --- a/sql/rpl_injector.cc +++ b/sql/rpl_injector.cc @@ -131,9 +131,7 @@ injector::transaction::binlog_pos injector::transaction::start_pos() const */ /* This constructor is called below */ -inline injector::injector() -{ -} +inline injector::injector() = default; static injector *s_injector= 0; injector *injector::instance() diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 28359d9555a..6a1c724809a 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -307,7 +307,7 @@ public: private: explicit injector(); - ~injector() { } /* Nothing needs to be done */ + ~injector() = default; /* Nothing needs to be done */ injector(injector const&); /* You're not allowed to copy injector instances. */ diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index d8510d7becd..24367897c89 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -56,8 +56,7 @@ rpt_handle_event(rpl_parallel_thread::queued_event *qev, rgi->event_relay_log_pos= qev->event_relay_log_pos; rgi->future_event_relay_log_pos= qev->future_event_relay_log_pos; strcpy(rgi->future_event_master_log_name, qev->future_event_master_log_name); - if (!(ev->is_artificial_event() || ev->is_relay_log_event() || - (ev->when == 0))) + if (event_can_update_last_master_timestamp(ev)) rgi->last_master_timestamp= ev->when + (time_t)ev->exec_time; err= apply_event_and_update_pos_for_parallel(ev, thd, rgi); diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index edbb630c781..a8af950fa08 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -2283,11 +2283,9 @@ void rpl_group_info::cleanup_context(THD *thd, bool error) if (unlikely(error)) { - /* - trans_rollback above does not rollback XA transactions - (todo/fixme consider to do so. - */ - if (thd->transaction->xid_state.is_explicit_XA()) + // leave alone any XA prepared transactions + if (thd->transaction->xid_state.is_explicit_XA() && + thd->transaction->xid_state.get_state_code() != XA_PREPARED) xa_trans_force_rollback(thd); thd->release_transactional_locks(); diff --git a/sql/semisync_master.h b/sql/semisync_master.h index 04fc0e5ce50..5451ad512c6 100644 --- a/sql/semisync_master.h +++ b/sql/semisync_master.h @@ -454,7 +454,7 @@ class Repl_semi_sync_master public: Repl_semi_sync_master(); - ~Repl_semi_sync_master() {} + ~Repl_semi_sync_master() = default; void cleanup(); diff --git a/sql/semisync_master_ack_receiver.h b/sql/semisync_master_ack_receiver.h index b75cb7b76cb..d869bd2e6d4 100644 --- a/sql/semisync_master_ack_receiver.h +++ b/sql/semisync_master_ack_receiver.h @@ -50,7 +50,7 @@ class Ack_receiver : public Repl_semi_sync_base { public: Ack_receiver(); - ~Ack_receiver() {} + ~Ack_receiver() = default; void cleanup(); /** Notify ack receiver to receive acks on the dump session. diff --git a/sql/semisync_slave.h b/sql/semisync_slave.h index f0b8eceeebf..a8229245ab1 100644 --- a/sql/semisync_slave.h +++ b/sql/semisync_slave.h @@ -34,7 +34,7 @@ class Repl_semi_sync_slave :public Repl_semi_sync_base { public: Repl_semi_sync_slave() :m_slave_enabled(false) {} - ~Repl_semi_sync_slave() {} + ~Repl_semi_sync_slave() = default; void set_trace_level(unsigned long trace_level) { m_trace_level = trace_level; diff --git a/sql/session_tracker.h b/sql/session_tracker.h index c78778ac73c..5715b5837b5 100644 --- a/sql/session_tracker.h +++ b/sql/session_tracker.h @@ -78,7 +78,7 @@ private: bool m_changed; public: - virtual ~State_tracker() {} + virtual ~State_tracker() = default; /** Getters */ bool is_enabled() const diff --git a/sql/set_var.h b/sql/set_var.h index 471d76129d4..70f2cb8ead2 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -99,7 +99,7 @@ public: on_check_function on_check_func, on_update_function on_update_func, const char *substitute); - virtual ~sys_var() {} + virtual ~sys_var() = default; /** All the cleanup procedures should be performed here @@ -280,8 +280,8 @@ protected: class set_var_base :public Sql_alloc { public: - set_var_base() {} - virtual ~set_var_base() {} + set_var_base() = default; + virtual ~set_var_base() = default; virtual int check(THD *thd)=0; /* To check privileges etc. */ virtual int update(THD *thd)=0; /* To set the value */ virtual int light_check(THD *thd) { return check(thd); } /* for PS */ diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 65a7e613b72..b66bd694207 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -8938,12 +8938,12 @@ ER_INVALID_DEFAULT_VALUE_FOR_FIELD 22007 hindi "गलत डिफ़ॉल्ट मान '%-.128T' कॉलम '%.192s' के लिए" spa "Valor por defecto incorrecto '%-.128T' para columna '%.192s'" ER_KILL_QUERY_DENIED_ERROR - chi "你不是查询%lu的所有者" - eng "You are not owner of query %lu" - ger "Sie sind nicht Eigentümer von Abfrage %lu" - hindi "आप क्वेरी %lu के OWNER नहीं हैं" - rus "Вы не являетесь владельцем запроса %lu" - spa "No eres el propietario de la consulta (query) %lu" + chi "你不是查询%lld的所有者" + eng "You are not owner of query %lld" + ger "Sie sind nicht Eigentümer von Abfrage %lld" + hindi "आप क्वेरी %lld के OWNER नहीं हैं" + rus "Вы не являетесь владельцем запроса %lld" + spa "No eres el propietario de la consulta (query) %lld" ER_NO_EIS_FOR_FIELD chi "没有收集无关的统计信息列'%s'" eng "Engine-independent statistics are not collected for column '%s'" diff --git a/sql/slave.cc b/sql/slave.cc index 7db5a31d439..86180af8aed 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4256,6 +4256,21 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, int exec_res; Log_event_type typ= ev->get_type_code(); + DBUG_EXECUTE_IF( + "pause_sql_thread_on_next_event", + { + /* + Temporarily unlock data_lock so we can check-in with the IO thread + */ + mysql_mutex_unlock(&rli->data_lock); + DBUG_ASSERT(!debug_sync_set_action( + thd, + STRING_WITH_LEN( + "now SIGNAL paused_on_event WAIT_FOR sql_thread_continue"))); + DBUG_SET("-d,pause_sql_thread_on_next_event"); + mysql_mutex_lock(&rli->data_lock); + }); + /* Even if we don't execute this event, we keep the master timestamp, so that seconds behind master shows correct delta (there are events @@ -4269,10 +4284,10 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, the user might be surprised to see a claim that the slave is up to date long before those queued events are actually executed. */ - if (!rli->mi->using_parallel() && - !(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0))) + if ((!rli->mi->using_parallel()) && event_can_update_last_master_timestamp(ev)) { rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; + rli->sql_thread_caught_up= false; DBUG_ASSERT(rli->last_master_timestamp >= 0); } @@ -4324,6 +4339,17 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, if (rli->mi->using_parallel()) { + if (unlikely((rli->last_master_timestamp == 0 || + rli->sql_thread_caught_up) && + event_can_update_last_master_timestamp(ev))) + { + if (rli->last_master_timestamp < ev->when) + { + rli->last_master_timestamp= ev->when; + rli->sql_thread_caught_up= false; + } + } + int res= rli->parallel.do_event(serial_rgi, ev, event_size); /* In parallel replication, we need to update the relay log position @@ -4344,7 +4370,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, This is the case for pre-10.0 events without GTID, and for handling slave_skip_counter. */ - if (!(ev->is_artificial_event() || ev->is_relay_log_event() || (ev->when == 0))) + if (event_can_update_last_master_timestamp(ev)) { /* Ignore FD's timestamp as it does not reflect the slave execution @@ -4352,7 +4378,8 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, data modification event execution last long all this time Seconds_Behind_Master is zero. */ - if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT) + if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT && + rli->last_master_timestamp < ev->when) rli->last_master_timestamp= ev->when + (time_t) ev->exec_time; DBUG_ASSERT(rli->last_master_timestamp >= 0); @@ -7406,7 +7433,6 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size) if (hot_log) mysql_mutex_unlock(log_lock); - rli->sql_thread_caught_up= false; DBUG_RETURN(ev); } if (opt_reckless_slave) // For mysql-test @@ -7570,7 +7596,6 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size) rli->relay_log.wait_for_update_relay_log(rli->sql_driver_thd); // re-acquire data lock since we released it earlier mysql_mutex_lock(&rli->data_lock); - rli->sql_thread_caught_up= false; continue; } /* @@ -7761,12 +7786,19 @@ event(errno: %d cur_log->error: %d)", { sql_print_information("Error reading relay log event: %s", "slave SQL thread was killed"); - DBUG_RETURN(0); + goto end; } err: if (errmsg) sql_print_error("Error reading relay log event: %s", errmsg); + +end: + /* + Set that we are not caught up so if there is a hang/problem on restart, + Seconds_Behind_Master will still grow. + */ + rli->sql_thread_caught_up= false; DBUG_RETURN(0); } #ifdef WITH_WSREP diff --git a/sql/slave.h b/sql/slave.h index 5ca6054a178..e2bd5cec1b9 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -49,6 +49,7 @@ #include "rpl_filter.h" #include "rpl_tblmap.h" #include "rpl_gtid.h" +#include "log_event.h" #define SLAVE_NET_TIMEOUT 60 @@ -293,6 +294,17 @@ extern char *report_host, *report_password; extern I_List<THD> threads; +/* + Check that a binlog event (read from the relay log) is valid to update + last_master_timestamp. That is, a valid event is one with a consistent + timestamp which originated from a primary server. +*/ +static inline bool event_can_update_last_master_timestamp(Log_event *ev) +{ + return ev && !(ev->is_artificial_event() || ev->is_relay_log_event() || + (ev->when == 0)); +} + #else #define close_active_mi() /* no-op */ #endif /* HAVE_REPLICATION */ @@ -119,7 +119,7 @@ public: // TODO: make it private or protected const; public: - virtual ~Sp_handler() {} + virtual ~Sp_handler() = default; static const Sp_handler *handler(enum enum_sql_command cmd); static const Sp_handler *handler(enum_sp_type type); static const Sp_handler *handler(MDL_key::enum_mdl_namespace ns); diff --git a/sql/sp_head.h b/sql/sp_head.h index 97ea4e7b89a..5b4aa36e518 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -124,8 +124,7 @@ public: /** Create temporary sp_name object from MDL key. Store in qname_buff */ sp_name(const MDL_key *key, char *qname_buff); - ~sp_name() - {} + ~sp_name() = default; }; @@ -1316,8 +1315,7 @@ public: m_query.length= 0; } - virtual ~sp_instr_stmt() - {}; + virtual ~sp_instr_stmt() = default; virtual int execute(THD *thd, uint *nextp); @@ -1352,8 +1350,7 @@ public: m_lex_keeper(lex, lex_resp) {} - virtual ~sp_instr_set() - {} + virtual ~sp_instr_set() = default; virtual int execute(THD *thd, uint *nextp); @@ -1396,8 +1393,7 @@ public: m_field_offset(field_offset) {} - virtual ~sp_instr_set_row_field() - {} + virtual ~sp_instr_set_row_field() = default; virtual int exec_core(THD *thd, uint *nextp); @@ -1439,8 +1435,7 @@ public: m_field_name(field_name) {} - virtual ~sp_instr_set_row_field_by_name() - {} + virtual ~sp_instr_set_row_field_by_name() = default; virtual int exec_core(THD *thd, uint *nextp); @@ -1466,8 +1461,7 @@ public: value(val), m_lex_keeper(lex, TRUE) {} - virtual ~sp_instr_set_trigger_field() - {} + virtual ~sp_instr_set_trigger_field() = default; virtual int execute(THD *thd, uint *nextp); @@ -1510,8 +1504,7 @@ public: m_dest(dest), m_cont_dest(0), m_optdest(0), m_cont_optdest(0) {} - virtual ~sp_instr_opt_meta() - {} + virtual ~sp_instr_opt_meta() = default; virtual void set_destination(uint old_dest, uint new_dest) = 0; @@ -1540,8 +1533,7 @@ public: : sp_instr_opt_meta(ip, ctx, dest) {} - virtual ~sp_instr_jump() - {} + virtual ~sp_instr_jump() = default; virtual int execute(THD *thd, uint *nextp); @@ -1592,8 +1584,7 @@ public: m_lex_keeper(lex, TRUE) {} - virtual ~sp_instr_jump_if_not() - {} + virtual ~sp_instr_jump_if_not() = default; virtual int execute(THD *thd, uint *nextp); @@ -1640,8 +1631,7 @@ public: : sp_instr(ip, ctx) {} - virtual ~sp_instr_preturn() - {} + virtual ~sp_instr_preturn() = default; virtual int execute(THD *thd, uint *nextp); @@ -1672,8 +1662,7 @@ public: m_lex_keeper(lex, TRUE) {} - virtual ~sp_instr_freturn() - {} + virtual ~sp_instr_freturn() = default; virtual int execute(THD *thd, uint *nextp); @@ -1778,8 +1767,7 @@ public: : sp_instr(ip, ctx), m_count(count) {} - virtual ~sp_instr_hpop() - {} + virtual ~sp_instr_hpop() = default; void update_count(uint count) { @@ -1812,8 +1800,7 @@ public: m_frame(ctx->current_var_count()) {} - virtual ~sp_instr_hreturn() - {} + virtual ~sp_instr_hreturn() = default; virtual int execute(THD *thd, uint *nextp); @@ -1849,8 +1836,7 @@ public: : sp_instr(ip, ctx), m_lex_keeper(lex, TRUE), m_cursor(offset) {} - virtual ~sp_instr_cpush() - {} + virtual ~sp_instr_cpush() = default; int execute(THD *thd, uint *nextp) override; @@ -1885,8 +1871,7 @@ public: : sp_instr(ip, ctx), m_count(count) {} - virtual ~sp_instr_cpop() - {} + virtual ~sp_instr_cpop() = default; void update_count(uint count) { @@ -1918,8 +1903,7 @@ public: : sp_instr(ip, ctx), m_cursor(c) {} - virtual ~sp_instr_copen() - {} + virtual ~sp_instr_copen() = default; virtual int execute(THD *thd, uint *nextp); @@ -1956,8 +1940,7 @@ public: m_cursor(coffs), m_var(voffs) {} - virtual ~sp_instr_cursor_copy_struct() - {} + virtual ~sp_instr_cursor_copy_struct() = default; virtual int execute(THD *thd, uint *nextp); virtual int exec_core(THD *thd, uint *nextp); virtual void print(String *str); @@ -1979,8 +1962,7 @@ public: : sp_instr(ip, ctx), m_cursor(c) {} - virtual ~sp_instr_cclose() - {} + virtual ~sp_instr_cclose() = default; virtual int execute(THD *thd, uint *nextp); @@ -2009,8 +1991,7 @@ public: m_varlist.empty(); } - virtual ~sp_instr_cfetch() - {} + virtual ~sp_instr_cfetch() = default; virtual int execute(THD *thd, uint *nextp); @@ -2048,8 +2029,7 @@ public: sp_instr_agg_cfetch(uint ip, sp_pcontext *ctx) : sp_instr(ip, ctx){} - virtual ~sp_instr_agg_cfetch() - {} + virtual ~sp_instr_agg_cfetch() = default; virtual int execute(THD *thd, uint *nextp); @@ -2074,8 +2054,7 @@ public: : sp_instr(ip, ctx), m_errcode(errcode) {} - virtual ~sp_instr_error() - {} + virtual ~sp_instr_error() = default; virtual int execute(THD *thd, uint *nextp); @@ -2108,8 +2087,7 @@ public: m_lex_keeper(lex, TRUE) {} - virtual ~sp_instr_set_case_expr() - {} + virtual ~sp_instr_set_case_expr() = default; virtual int execute(THD *thd, uint *nextp); diff --git a/sql/spatial.h b/sql/spatial.h index 8974511adf9..d85bdc86af4 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -214,8 +214,8 @@ struct Geometry_buffer; class Geometry { public: - Geometry() {} /* Remove gcc warning */ - virtual ~Geometry() {} /* Remove gcc warning */ + Geometry() = default; /* Remove gcc warning */ + virtual ~Geometry() = default; /* Remove gcc warning */ static void *operator new(size_t size, void *buffer) { return buffer; @@ -395,8 +395,8 @@ protected: class Gis_point: public Geometry { public: - Gis_point() {} /* Remove gcc warning */ - virtual ~Gis_point() {} /* Remove gcc warning */ + Gis_point() = default; /* Remove gcc warning */ + virtual ~Gis_point() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -465,8 +465,8 @@ public: class Gis_line_string: public Geometry { public: - Gis_line_string() {} /* Remove gcc warning */ - virtual ~Gis_line_string() {} /* Remove gcc warning */ + Gis_line_string() = default; /* Remove gcc warning */ + virtual ~Gis_line_string() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -498,8 +498,8 @@ public: class Gis_polygon: public Geometry { public: - Gis_polygon() {} /* Remove gcc warning */ - virtual ~Gis_polygon() {} /* Remove gcc warning */ + Gis_polygon() = default; /* Remove gcc warning */ + virtual ~Gis_polygon() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -535,8 +535,8 @@ class Gis_multi_point: public Geometry (uint32) (UINT_MAX32 - WKB_HEADER_SIZE - 4 /* n_points */) / (WKB_HEADER_SIZE + POINT_DATA_SIZE); public: - Gis_multi_point() {} /* Remove gcc warning */ - virtual ~Gis_multi_point() {} /* Remove gcc warning */ + Gis_multi_point() = default; /* Remove gcc warning */ + virtual ~Gis_multi_point() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -566,8 +566,8 @@ public: class Gis_multi_line_string: public Geometry { public: - Gis_multi_line_string() {} /* Remove gcc warning */ - virtual ~Gis_multi_line_string() {} /* Remove gcc warning */ + Gis_multi_line_string() = default; /* Remove gcc warning */ + virtual ~Gis_multi_line_string() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -597,8 +597,8 @@ public: class Gis_multi_polygon: public Geometry { public: - Gis_multi_polygon() {} /* Remove gcc warning */ - virtual ~Gis_multi_polygon() {} /* Remove gcc warning */ + Gis_multi_polygon() = default; /* Remove gcc warning */ + virtual ~Gis_multi_polygon() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); @@ -628,8 +628,8 @@ public: class Gis_geometry_collection: public Geometry { public: - Gis_geometry_collection() {} /* Remove gcc warning */ - virtual ~Gis_geometry_collection() {} /* Remove gcc warning */ + Gis_geometry_collection() = default; /* Remove gcc warning */ + virtual ~Gis_geometry_collection() = default; /* Remove gcc warning */ uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c2a9a99837e..6f2fa9bf672 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -206,7 +206,7 @@ class ACL_USER :public ACL_USER_BASE, { public: - ACL_USER() { } + ACL_USER() = default; ACL_USER(THD *thd, const LEX_USER &combo, const Account_options &options, const privilege_t privileges); @@ -351,7 +351,7 @@ class ACL_PROXY_USER :public ACL_ACCESS MYSQL_PROXIES_PRIV_GRANTOR, MYSQL_PROXIES_PRIV_TIMESTAMP } proxy_table_fields; public: - ACL_PROXY_USER () {}; + ACL_PROXY_USER () = default; void init(const char *host_arg, const char *user_arg, const char *proxied_host_arg, const char *proxied_user_arg, @@ -942,7 +942,7 @@ class User_table: public Grant_table_base virtual longlong get_password_lifetime () const = 0; virtual int set_password_lifetime (longlong x) const = 0; - virtual ~User_table() {} + virtual ~User_table() = default; private: friend class Grant_tables; virtual int setup_sysvars() const = 0; @@ -1291,7 +1291,7 @@ class User_table_tabular: public User_table return 1; } - virtual ~User_table_tabular() {} + virtual ~User_table_tabular() = default; private: friend class Grant_tables; @@ -1692,7 +1692,7 @@ class User_table_json: public User_table int set_password_expired (bool x) const { return x ? set_password_last_changed(0) : 0; } - ~User_table_json() {} + ~User_table_json() = default; private: friend class Grant_tables; static const uint JSON_SIZE=1024; @@ -5398,7 +5398,7 @@ public: GRANT_NAME(const char *h, const char *d,const char *u, const char *t, privilege_t p, bool is_routine); GRANT_NAME (TABLE *form, bool is_routine); - virtual ~GRANT_NAME() {}; + virtual ~GRANT_NAME() = default; virtual bool ok() { return privs != NO_ACL; } void set_user_details(const char *h, const char *d, const char *u, const char *t, @@ -11731,8 +11731,7 @@ public: : is_grave(FALSE) {} - virtual ~Silence_routine_definer_errors() - {} + virtual ~Silence_routine_definer_errors() = default; virtual bool handle_condition(THD *thd, uint sql_errno, diff --git a/sql/sql_acl.h b/sql/sql_acl.h index ab98cfff364..fb8dd2c3763 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -186,11 +186,9 @@ enum ACL_internal_access_result class ACL_internal_table_access { public: - ACL_internal_table_access() - {} + ACL_internal_table_access() = default; - virtual ~ACL_internal_table_access() - {} + virtual ~ACL_internal_table_access() = default; /** Check access to an internal table. @@ -225,11 +223,9 @@ public: class ACL_internal_schema_access { public: - ACL_internal_schema_access() - {} + ACL_internal_schema_access() = default; - virtual ~ACL_internal_schema_access() - {} + virtual ~ACL_internal_schema_access() = default; /** Check access to an internal schema. diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 71039affd2b..465145cf25f 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -44,7 +44,8 @@ const LEX_CSTRING msg_optimize= { STRING_WITH_LEN("optimize") }; /* Prepare, run and cleanup for mysql_recreate_table() */ -static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list) +static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list, + Recreate_info *recreate_info) { bool result_code; DBUG_ENTER("admin_recreate_table"); @@ -65,7 +66,7 @@ static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list) DEBUG_SYNC(thd, "ha_admin_try_alter"); tmp_disable_binlog(thd); // binlogging is done by caller if wanted result_code= (thd->open_temporary_tables(table_list) || - mysql_recreate_table(thd, table_list, false)); + mysql_recreate_table(thd, table_list, recreate_info, false)); reenable_binlog(thd); /* mysql_recreate_table() can push OK or ERROR. @@ -560,6 +561,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, bool open_error= 0; bool collect_eis= FALSE; bool open_for_modify= org_open_for_modify; + Recreate_info recreate_info; storage_engine_name[0]= 0; // Marker that's not used @@ -829,7 +831,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, { /* We use extra_open_options to be able to open crashed tables */ thd->open_options|= extra_open_options; - result_code= admin_recreate_table(thd, table); + result_code= admin_recreate_table(thd, table, &recreate_info) ? + HA_ADMIN_FAILED : HA_ADMIN_OK; thd->open_options&= ~extra_open_options; goto send_result; } @@ -1012,12 +1015,31 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, repair was not implemented and we need to upgrade the table to a new version so we recreate the table with ALTER TABLE */ - result_code= admin_recreate_table(thd, table); + result_code= admin_recreate_table(thd, table, &recreate_info); } send_result: lex->cleanup_after_one_table_open(); thd->clear_error(); // these errors shouldn't get client + + if (recreate_info.records_duplicate()) + { + protocol->prepare_for_resend(); + protocol->store(&table_name, system_charset_info); + protocol->store(operator_name, system_charset_info); + protocol->store(warning_level_names[Sql_condition::WARN_LEVEL_WARN].str, + warning_level_names[Sql_condition::WARN_LEVEL_WARN].length, + system_charset_info); + char buf[80]; + size_t length= my_snprintf(buf, sizeof(buf), + "Number of rows changed from %u to %u", + (uint) recreate_info.records_processed(), + (uint) recreate_info.records_copied()); + protocol->store(buf, length, system_charset_info); + if (protocol->write()) + goto err; + } + { Diagnostics_area::Sql_condition_iterator it= thd->get_stmt_da()->sql_conditions(); @@ -1128,7 +1150,7 @@ send_result_message: *save_next_global= table->next_global; table->next_local= table->next_global= 0; - result_code= admin_recreate_table(thd, table); + result_code= admin_recreate_table(thd, table, &recreate_info); trans_commit_stmt(thd); trans_commit(thd); close_thread_tables(thd); @@ -1340,6 +1362,8 @@ send_result_message: goto err; DEBUG_SYNC(thd, "admin_command_kill_after_modify"); } + thd->resume_subsequent_commits(suspended_wfc); + DBUG_EXECUTE_IF("inject_analyze_table_sleep", my_sleep(500000);); if (is_table_modified && is_cmd_replicated && (!opt_readonly || thd->slave_thread) && !thd->lex->no_write_to_binlog) { @@ -1349,10 +1373,8 @@ send_result_message: if (res) goto err; } - my_eof(thd); - thd->resume_subsequent_commits(suspended_wfc); - DBUG_EXECUTE_IF("inject_analyze_table_sleep", my_sleep(500000);); + DBUG_RETURN(FALSE); err: @@ -1501,6 +1523,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd) LEX *m_lex= thd->lex; TABLE_LIST *first_table= m_lex->first_select_lex()->table_list.first; bool res= TRUE; + Recreate_info recreate_info; DBUG_ENTER("Sql_cmd_optimize_table::execute"); if (check_table_access(thd, SELECT_ACL | INSERT_ACL, first_table, @@ -1509,7 +1532,7 @@ bool Sql_cmd_optimize_table::execute(THD *thd) WSREP_TO_ISOLATION_BEGIN_WRTCHK(NULL, NULL, first_table); res= (specialflag & SPECIAL_NO_NEW_FUNC) ? - mysql_recreate_table(thd, first_table, true) : + mysql_recreate_table(thd, first_table, &recreate_info, true) : mysql_admin_table(thd, first_table, &m_lex->check_opt, &msg_optimize, TL_WRITE, 1, 0, 0, 0, &handler::ha_optimize, 0, true); diff --git a/sql/sql_admin.h b/sql/sql_admin.h index 0c7f1c3cee5..1a237d4f616 100644 --- a/sql/sql_admin.h +++ b/sql/sql_admin.h @@ -34,11 +34,9 @@ public: /** Constructor, used to represent a ANALYZE TABLE statement. */ - Sql_cmd_analyze_table() - {} + Sql_cmd_analyze_table() = default; - ~Sql_cmd_analyze_table() - {} + ~Sql_cmd_analyze_table() = default; bool execute(THD *thd); @@ -59,11 +57,9 @@ public: /** Constructor, used to represent a CHECK TABLE statement. */ - Sql_cmd_check_table() - {} + Sql_cmd_check_table() = default; - ~Sql_cmd_check_table() - {} + ~Sql_cmd_check_table() = default; bool execute(THD *thd); @@ -83,11 +79,9 @@ public: /** Constructor, used to represent a OPTIMIZE TABLE statement. */ - Sql_cmd_optimize_table() - {} + Sql_cmd_optimize_table() = default; - ~Sql_cmd_optimize_table() - {} + ~Sql_cmd_optimize_table() = default; bool execute(THD *thd); @@ -108,11 +102,9 @@ public: /** Constructor, used to represent a REPAIR TABLE statement. */ - Sql_cmd_repair_table() - {} + Sql_cmd_repair_table() = default; - ~Sql_cmd_repair_table() - {} + ~Sql_cmd_repair_table() = default; bool execute(THD *thd); diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index ffcc7679273..5959203b36d 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -554,9 +554,11 @@ bool Sql_cmd_alter_table::execute(THD *thd) thd->work_part_info= 0; #endif + Recreate_info recreate_info; result= mysql_alter_table(thd, &select_lex->db, &lex->name, &create_info, first_table, + &recreate_info, &alter_info, select_lex->order_list.elements, select_lex->order_list.first, diff --git a/sql/sql_alter.h b/sql/sql_alter.h index bf1edd4c964..99e717d50b2 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -372,11 +372,9 @@ protected: /** Constructor. */ - Sql_cmd_common_alter_table() - {} + Sql_cmd_common_alter_table() = default; - virtual ~Sql_cmd_common_alter_table() - {} + virtual ~Sql_cmd_common_alter_table() = default; virtual enum_sql_command sql_command_code() const { @@ -395,11 +393,9 @@ public: /** Constructor, used to represent a ALTER TABLE statement. */ - Sql_cmd_alter_table() - {} + Sql_cmd_alter_table() = default; - ~Sql_cmd_alter_table() - {} + ~Sql_cmd_alter_table() = default; Storage_engine_name *option_storage_engine_name() { return this; } @@ -421,8 +417,7 @@ public: :DDL_options(options) {} - ~Sql_cmd_alter_sequence() - {} + ~Sql_cmd_alter_sequence() = default; enum_sql_command sql_command_code() const { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9634cd4bb48..fa2b144e06f 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1420,7 +1420,7 @@ public: : m_ot_ctx(ot_ctx_arg), m_is_active(FALSE) {} - virtual ~MDL_deadlock_handler() {} + virtual ~MDL_deadlock_handler() = default; virtual bool handle_condition(THD *thd, uint sql_errno, diff --git a/sql/sql_base.h b/sql/sql_base.h index 1b294a468a9..6e17d8214ad 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -395,7 +395,7 @@ inline bool setup_fields_with_no_wrap(THD *thd, Ref_ptr_array ref_pointer_array, class Prelocking_strategy { public: - virtual ~Prelocking_strategy() { } + virtual ~Prelocking_strategy() = default; virtual void reset(THD *thd) { }; virtual bool handle_routine(THD *thd, Query_tables_list *prelocking_ctx, diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 61b3df2d086..05b201a5d6e 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -90,7 +90,7 @@ public: or to call set_all()/clear_all()/set_prefix() to initialize bitmap. */ - Bitmap() { } + Bitmap() = default; explicit Bitmap(uint prefix) { diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 126693b9964..a02034764a7 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -91,7 +91,7 @@ typedef my_bool (*qc_engine_callback)(THD *thd, const char *table_key, */ struct Query_cache_block_table { - Query_cache_block_table() {} /* Remove gcc warning */ + Query_cache_block_table() = default; /* Remove gcc warning */ /** This node holds a position in a static table list belonging @@ -122,7 +122,7 @@ struct Query_cache_block_table struct Query_cache_block { - Query_cache_block() {} /* Remove gcc warning */ + Query_cache_block() = default; /* Remove gcc warning */ enum block_type {FREE, QUERY, RESULT, RES_CONT, RES_BEG, RES_INCOMPLETE, TABLE, INCOMPLETE}; @@ -161,7 +161,7 @@ struct Query_cache_query uint8 ready; ulonglong hit_count; - Query_cache_query() {} /* Remove gcc warning */ + Query_cache_query() = default; /* Remove gcc warning */ inline void init_n_lock(); void unlock_n_destroy(); inline ulonglong found_rows() { return limit_found_rows; } @@ -197,7 +197,7 @@ struct Query_cache_query struct Query_cache_table { - Query_cache_table() {} /* Remove gcc warning */ + Query_cache_table() = default; /* Remove gcc warning */ char *tbl; uint32 key_len; uint8 suffix_len; /* For partitioned tables */ @@ -240,7 +240,7 @@ struct Query_cache_table struct Query_cache_result { - Query_cache_result() {} /* Remove gcc warning */ + Query_cache_result() = default; /* Remove gcc warning */ Query_cache_block *query; inline uchar* data() @@ -266,7 +266,7 @@ extern "C" void query_cache_invalidate_by_MyISAM_filename(const char* filename); struct Query_cache_memory_bin { - Query_cache_memory_bin() {} /* Remove gcc warning */ + Query_cache_memory_bin() = default; /* Remove gcc warning */ #ifndef DBUG_OFF size_t size; #endif @@ -285,7 +285,7 @@ struct Query_cache_memory_bin struct Query_cache_memory_bin_step { - Query_cache_memory_bin_step() {} /* Remove gcc warning */ + Query_cache_memory_bin_step() = default; /* Remove gcc warning */ size_t size; size_t increment; size_t idx; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 17ce7b3c048..79db032c937 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4032,9 +4032,7 @@ void THD::restore_active_arena(Query_arena *set, Query_arena *backup) DBUG_VOID_RETURN; } -Statement::~Statement() -{ -} +Statement::~Statement() = default; C_MODE_START @@ -8335,6 +8333,20 @@ bool THD::timestamp_to_TIME(MYSQL_TIME *ltime, my_time_t ts, return 0; } + +void THD::my_ok_with_recreate_info(const Recreate_info &info, + ulong warn_count) +{ + char buf[80]; + my_snprintf(buf, sizeof(buf), + ER_THD(this, ER_INSERT_INFO), + (ulong) info.records_processed(), + (ulong) info.records_duplicate(), + warn_count); + my_ok(this, info.records_processed(), 0L, buf); +} + + THD_list_iterator *THD_list_iterator::iterator() { return &server_threads; diff --git a/sql/sql_class.h b/sql/sql_class.h index ef299e4eb12..bbadff29110 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -247,6 +247,29 @@ public: }; +class Recreate_info +{ + ha_rows m_records_copied; + ha_rows m_records_duplicate; +public: + Recreate_info() + :m_records_copied(0), + m_records_duplicate(0) + { } + Recreate_info(ha_rows records_copied, + ha_rows records_duplicate) + :m_records_copied(records_copied), + m_records_duplicate(records_duplicate) + { } + ha_rows records_copied() const { return m_records_copied; } + ha_rows records_duplicate() const { return m_records_duplicate; } + ha_rows records_processed() const + { + return m_records_copied + m_records_duplicate; + } +}; + + #define TC_HEURISTIC_RECOVER_COMMIT 1 #define TC_HEURISTIC_RECOVER_ROLLBACK 2 extern ulong tc_heuristic_recover; @@ -452,7 +475,7 @@ public: invisible(false), without_overlaps(false) {} Key(const Key &rhs, MEM_ROOT *mem_root); - virtual ~Key() {} + virtual ~Key() = default; /* Equality comparison of keys (ignoring name) */ friend bool foreign_key_prefix(Key *a, Key *b); /** @@ -1180,7 +1203,7 @@ public: Query_arena() { INIT_ARENA_DBUG_INFO; } virtual Type type() const; - virtual ~Query_arena() {}; + virtual ~Query_arena() = default; inline bool is_stmt_prepare() const { return state == STMT_INITIALIZED; } inline bool is_stmt_prepare_or_first_sp_execute() const @@ -1231,7 +1254,7 @@ public: Query_arena_memroot() : Query_arena() {} - virtual ~Query_arena_memroot() {} + virtual ~Query_arena_memroot() = default; }; @@ -1381,7 +1404,7 @@ public: my_bool query_cache_is_applicable; /* This constructor is called for backup statements */ - Statement() {} + Statement() = default; Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, enum enum_state state_arg, ulong id_arg); @@ -1893,7 +1916,7 @@ protected: m_prev_internal_handler(NULL) {} - virtual ~Internal_error_handler() {} + virtual ~Internal_error_handler() = default; public: /** @@ -1951,7 +1974,7 @@ public: /* Ignore error */ return TRUE; } - Dummy_error_handler() {} /* Remove gcc warning */ + Dummy_error_handler() = default; /* Remove gcc warning */ }; @@ -1988,7 +2011,7 @@ public: class Drop_table_error_handler : public Internal_error_handler { public: - Drop_table_error_handler() {} + Drop_table_error_handler() = default; public: bool handle_condition(THD *thd, @@ -2029,7 +2052,7 @@ private: class Turn_errors_to_warnings_handler : public Internal_error_handler { public: - Turn_errors_to_warnings_handler() {} + Turn_errors_to_warnings_handler() = default; bool handle_condition(THD *thd, uint sql_errno, const char* sqlstate, @@ -4364,6 +4387,8 @@ public: inline bool vio_ok() const { return TRUE; } inline bool is_connected() { return TRUE; } #endif + + void my_ok_with_recreate_info(const Recreate_info &info, ulong warn_count); /** Mark the current error as fatal. Warning: this does not set any error, it sets a property of the error, so must be @@ -5727,7 +5752,7 @@ public: example for a duplicate row entry written to a temp table. */ virtual int send_data(List<Item> &items)=0; - virtual ~select_result_sink() {}; + virtual ~select_result_sink() = default; void reset(THD *thd_arg) { thd= thd_arg; } }; @@ -5759,7 +5784,7 @@ public: ha_rows est_records; /* estimated number of records in the result */ select_result(THD *thd_arg): select_result_sink(thd_arg), est_records(0) {} void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; } - virtual ~select_result() {}; + virtual ~select_result() = default; /** Change wrapped select_result. @@ -6277,6 +6302,12 @@ public: uint sum_func_count; uint hidden_field_count; uint group_parts,group_length,group_null_parts; + + /* + If we're doing a GROUP BY operation, shows which one is used: + true TemporaryTableWithPartialSums algorithm (see end_update()). + false OrderedGroupBy algorithm (see end_write_group()). + */ uint quick_group; /** Enabled when we have atleast one outer_sum_func. Needed when used @@ -7000,7 +7031,7 @@ class user_var_entry { CHARSET_INFO *m_charset; public: - user_var_entry() {} /* Remove gcc warning */ + user_var_entry() = default; /* Remove gcc warning */ LEX_CSTRING name; char *value; size_t length; @@ -7121,7 +7152,7 @@ public: enum type { SESSION_VAR, LOCAL_VAR, PARAM_VAR }; type scope; my_var(const LEX_CSTRING *j, enum type s) : name(*j), scope(s) { } - virtual ~my_var() {} + virtual ~my_var() = default; virtual bool set(THD *thd, Item *val) = 0; virtual my_var_sp *get_my_var_sp() { return NULL; } }; @@ -7142,7 +7173,7 @@ public: : my_var(j, LOCAL_VAR), m_rcontext_handler(rcontext_handler), m_type_handler(type_handler), offset(o), sp(s) { } - ~my_var_sp() { } + ~my_var_sp() = default; bool set(THD *thd, Item *val); my_var_sp *get_my_var_sp() { return this; } const Type_handler *type_handler() const @@ -7172,7 +7203,7 @@ class my_var_user: public my_var { public: my_var_user(const LEX_CSTRING *j) : my_var(j, SESSION_VAR) { } - ~my_var_user() { } + ~my_var_user() = default; bool set(THD *thd, Item *val); }; @@ -7185,7 +7216,7 @@ public: select_dumpvar(THD *thd_arg) :select_result_interceptor(thd_arg), row_count(0), m_var_sp_row(NULL) { var_list.empty(); } - ~select_dumpvar() {} + ~select_dumpvar() = default; int prepare(List<Item> &list, SELECT_LEX_UNIT *u); int send_data(List<Item> &items); bool send_eof(); diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h index 1a01caa77dd..2623b3703d3 100644 --- a/sql/sql_cmd.h +++ b/sql/sql_cmd.h @@ -193,8 +193,7 @@ public: } protected: - Sql_cmd() - {} + Sql_cmd() = default; virtual ~Sql_cmd() { @@ -262,8 +261,7 @@ public: m_handler(handler) {} - virtual ~Sql_cmd_call() - {} + virtual ~Sql_cmd_call() = default; /** Execute a CALL statement at runtime. diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index 3c90550c944..aab97501b48 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -30,12 +30,12 @@ class SQL_CRYPT :public Sql_alloc char decode_buff[256],encode_buff[256]; uint shift; public: - SQL_CRYPT() {} + SQL_CRYPT() = default; SQL_CRYPT(ulong *seed) { init(seed); } - ~SQL_CRYPT() {} + ~SQL_CRYPT() = default; void init(ulong *seed); void reinit() { shift=0; rand=org_rand; } void encode(char *str, uint length); diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index a526bfee2d2..ad385128d8d 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -102,49 +102,6 @@ bool LEX::check_dependencies_in_with_clauses() /** @brief - Resolve references to CTE in specification of hanging CTE - - @details - A CTE to which there are no references in the query is called hanging CTE. - Although such CTE is not used for execution its specification must be - subject to context analysis. All errors concerning references to - non-existing tables or fields occurred in the specification must be - reported as well as all other errors caught at the prepare stage. - The specification of a hanging CTE might contain references to other - CTE outside of the specification and within it if the specification - contains a with clause. This function resolves all such references for - all hanging CTEs encountered in the processed query. - - @retval - false on success - true on failure -*/ - -bool -LEX::resolve_references_to_cte_in_hanging_cte() -{ - for (With_clause *with_clause= with_clauses_list; - with_clause; with_clause= with_clause->next_with_clause) - { - for (With_element *with_elem= with_clause->with_list.first; - with_elem; with_elem= with_elem->next) - { - if (!with_elem->is_referenced()) - { - TABLE_LIST *first_tbl= - with_elem->spec->first_select()->table_list.first; - TABLE_LIST **with_elem_end_pos= with_elem->head->tables_pos.end_pos; - if (first_tbl && resolve_references_to_cte(first_tbl, with_elem_end_pos)) - return true; - } - } - } - return false; -} - - -/** - @brief Resolve table references to CTE from a sub-chain of table references @param tables Points to the beginning of the sub-chain @@ -289,8 +246,6 @@ LEX::check_cte_dependencies_and_resolve_references() return false; if (resolve_references_to_cte(query_tables, query_tables_last)) return true; - if (resolve_references_to_cte_in_hanging_cte()) - return true; return false; } @@ -489,47 +444,33 @@ With_element *find_table_def_in_with_clauses(TABLE_LIST *tbl, st_unit_ctxt_elem *ctxt) { With_element *found= 0; + st_select_lex_unit *top_unit= 0; for (st_unit_ctxt_elem *unit_ctxt_elem= ctxt; unit_ctxt_elem; unit_ctxt_elem= unit_ctxt_elem->prev) { st_select_lex_unit *unit= unit_ctxt_elem->unit; With_clause *with_clause= unit->with_clause; - /* - First look for the table definition in the with clause attached to 'unit' - if there is any such clause. - */ if (with_clause) { - found= with_clause->find_table_def(tbl, NULL); + /* + If the reference to tbl that has to be resolved belongs to + the FROM clause of a descendant of top_unit->with_element + and this with element belongs to with_clause then this + element must be used as the barrier for the search in the + the list of CTEs from with_clause unless the clause contains + RECURSIVE. + */ + With_element *barrier= 0; + if (top_unit && !with_clause->with_recursive && + top_unit->with_element && + top_unit->with_element->get_owner() == with_clause) + barrier= top_unit->with_element; + found= with_clause->find_table_def(tbl, barrier); if (found) break; } - /* - If 'unit' is the unit that defines a with element then reset 'unit' - to the unit whose attached with clause contains this with element. - */ - With_element *with_elem= unit->with_element; - if (with_elem) - { - if (!(unit_ctxt_elem= unit_ctxt_elem->prev)) - break; - unit= unit_ctxt_elem->unit; - } - with_clause= unit->with_clause; - /* - Now look for the table definition in this with clause. If the with clause - contains RECURSIVE the search is performed through all CTE definitions in - clause, otherwise up to the definition of 'with_elem' unless it is NULL. - */ - if (with_clause) - { - found= with_clause->find_table_def(tbl, - with_clause->with_recursive ? - NULL : with_elem); - if (found) - break; - } + top_unit= unit; } return found; } diff --git a/sql/sql_cte.h b/sql/sql_cte.h index e0fbd79803b..6a1f67d3258 100644 --- a/sql/sql_cte.h +++ b/sql/sql_cte.h @@ -326,8 +326,6 @@ public: friend bool LEX::resolve_references_to_cte(TABLE_LIST *tables, TABLE_LIST **tables_last); - friend - bool LEX::resolve_references_to_cte_in_hanging_cte(); }; const uint max_number_of_elements_in_with_clause= sizeof(table_map)*8; @@ -441,9 +439,6 @@ public: friend bool LEX::check_dependencies_in_with_clauses(); - - friend - bool LEX::resolve_references_to_cte_in_hanging_cte(); }; inline diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index d45f2ac8777..cef8ac161df 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -197,9 +197,7 @@ end: Server_side_cursor ****************************************************************************/ -Server_side_cursor::~Server_side_cursor() -{ -} +Server_side_cursor::~Server_side_cursor() = default; void Server_side_cursor::operator delete(void *ptr, size_t size) diff --git a/sql/sql_debug.h b/sql/sql_debug.h index 6109ca38048..003caec5454 100644 --- a/sql/sql_debug.h +++ b/sql/sql_debug.h @@ -22,7 +22,7 @@ class Debug_key: public String { public: - Debug_key() { }; + Debug_key() = default; void print(THD *thd) const { push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, diff --git a/sql/sql_error.h b/sql/sql_error.h index d7c29c5f9a4..541b92b4531 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -245,8 +245,7 @@ class Sql_condition_identity: public Sql_state_errno_level, public Sql_user_condition_identity { public: - Sql_condition_identity() - { } + Sql_condition_identity() = default; Sql_condition_identity(const Sql_state_errno_level &st, const Sql_user_condition_identity &ucid) :Sql_state_errno_level(st), @@ -450,8 +449,7 @@ private: } /** Destructor. */ - ~Sql_condition() - {} + ~Sql_condition() = default; /** Copy optional condition items attributes. @@ -871,8 +869,8 @@ public: class ErrConv: public ErrBuff { public: - ErrConv() {} - virtual ~ErrConv() {} + ErrConv() = default; + virtual ~ErrConv() = default; virtual LEX_CSTRING lex_cstring() const= 0; inline const char *ptr() const { diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 67abfe2e9da..03eb8821a34 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -142,7 +142,7 @@ public: Json_writer *writer, bool is_analyze, bool no_tmp_tbl); bool print_explain_json_cache(Json_writer *writer, bool is_analyze); - virtual ~Explain_node(){} + virtual ~Explain_node() = default; }; @@ -291,7 +291,7 @@ class Explain_aggr_node : public Sql_alloc { public: virtual enum_explain_aggr_node_type get_type()= 0; - virtual ~Explain_aggr_node() {} + virtual ~Explain_aggr_node() = default; Explain_aggr_node *child; }; diff --git a/sql/sql_expression_cache.h b/sql/sql_expression_cache.h index 9c618a5ae9b..88436837a2d 100644 --- a/sql/sql_expression_cache.h +++ b/sql/sql_expression_cache.h @@ -36,8 +36,8 @@ class Expression_cache :public Sql_alloc public: enum result {ERROR, HIT, MISS}; - Expression_cache(){}; - virtual ~Expression_cache() {}; + Expression_cache()= default; + virtual ~Expression_cache() = default; /** Shall check the presence of expression value in the cache for a given set of values of the expression parameters. Return the result of the diff --git a/sql/sql_hset.h b/sql/sql_hset.h index b3d8165f6f6..41573fb5f03 100644 --- a/sql/sql_hset.h +++ b/sql/sql_hset.h @@ -15,6 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ +#include "my_global.h" #include "hash.h" @@ -28,17 +29,15 @@ class Hash_set public: enum { START_SIZE= 8 }; /** - Constructs an empty hash. Does not allocate memory, it is done upon - the first insert. Thus does not cause or return errors. + Constructs an empty unique hash. */ Hash_set(PSI_memory_key psi_key, uchar *(*K)(const T *, size_t *, my_bool), CHARSET_INFO *cs= &my_charset_bin) { - my_hash_clear(&m_hash); - m_hash.get_key= (my_hash_get_key)K; - m_hash.charset= cs; - m_hash.array.m_psi_key= psi_key; + my_hash_init(psi_key, &m_hash, cs, START_SIZE, 0, 0, (my_hash_get_key)K, 0, + HASH_UNIQUE); } + Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements, size_t key_offset, size_t key_length, my_hash_get_key get_key, void (*free_element)(void*), uint flags) @@ -65,8 +64,6 @@ public: */ bool insert(T *value) { - my_hash_init_opt(m_hash.array.m_psi_key, &m_hash, m_hash.charset, - START_SIZE, 0, 0, m_hash.get_key, 0, HASH_UNIQUE); return my_hash_insert(&m_hash, reinterpret_cast<const uchar*>(value)); } bool remove(T *value) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5d713d2176e..6e042d25805 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4038,7 +4038,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) lex->current_select->join->select_options|= OPTION_BUFFER_RESULT; } else if (!(lex->current_select->options & OPTION_BUFFER_RESULT) && - thd->locked_tables_mode <= LTM_LOCK_TABLES) + thd->locked_tables_mode <= LTM_LOCK_TABLES && + !table->s->long_unique_table) { /* We must not yet prepare the result table if it is the same as one of the diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h index 2c3bf4022ca..393b3e309d3 100644 --- a/sql/sql_join_cache.h +++ b/sql/sql_join_cache.h @@ -678,7 +678,7 @@ public: THD *thd(); - virtual ~JOIN_CACHE() {} + virtual ~JOIN_CACHE() = default; void reset_join(JOIN *j) { join= j; } void free() { @@ -1075,7 +1075,7 @@ public: cache= join_tab->cache; } - virtual ~JOIN_TAB_SCAN() {} + virtual ~JOIN_TAB_SCAN() = default; /* Shall calculate the increment of the auxiliary buffer for a record diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5e85d1d0902..ab16a9d0b8b 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1291,8 +1291,6 @@ void LEX::start(THD *thd_arg) stmt_var_list.empty(); proc_list.elements=0; - save_group_list.empty(); - save_order_list.empty(); win_ref= NULL; win_frame= NULL; frame_top_bound= NULL; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 95ed308103d..2ddd40568f9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1204,12 +1204,14 @@ public: group_list_ptrs, and re-establish the original list before each execution. */ SQL_I_List<ORDER> group_list; + SQL_I_List<ORDER> save_group_list; Group_list_ptrs *group_list_ptrs; List<Item> item_list; /* list of fields & expressions */ List<Item> pre_fix; /* above list before fix_fields */ List<Item> fix_after_optimize; SQL_I_List<ORDER> order_list; /* ORDER clause */ + SQL_I_List<ORDER> save_order_list; SQL_I_List<ORDER> gorder_list; Lex_select_limit limit_params; /* LIMIT clause parameters */ @@ -1756,8 +1758,8 @@ public: These constructor and destructor serve for creation/destruction of Query_tables_list instances which are used as backup storage. */ - Query_tables_list() {} - ~Query_tables_list() {} + Query_tables_list() = default; + ~Query_tables_list() = default; /* Initializes (or resets) Query_tables_list object for "real" use. */ void reset_query_tables_list(bool init); @@ -2422,13 +2424,9 @@ class Lex_input_stream const char *str, const char *end, int sep); my_charset_conv_wc_mb get_escape_func(THD *thd, my_wc_t sep) const; public: - Lex_input_stream() - { - } + Lex_input_stream() = default; - ~Lex_input_stream() - { - } + ~Lex_input_stream() = default; /** Object initializer. Must be called before usage. @@ -3011,7 +3009,7 @@ public: protected: bool save_explain_data_intern(MEM_ROOT *mem_root, Explain_update *eu, bool is_analyze); public: - virtual ~Update_plan() {} + virtual ~Update_plan() = default; Update_plan(MEM_ROOT *mem_root_arg) : impossible_where(false), no_partitions(false), @@ -3065,7 +3063,7 @@ enum password_exp_type struct Account_options: public USER_RESOURCES { - Account_options() { } + Account_options() = default; void reset() { @@ -3559,8 +3557,6 @@ public: } - SQL_I_List<ORDER> save_group_list; - SQL_I_List<ORDER> save_order_list; LEX_CSTRING *win_ref; Window_frame *win_frame; Window_frame_bound *frame_top_bound; @@ -4823,8 +4819,8 @@ public: const LEX_CSTRING *constraint_name, Table_ident *ref_table_name, DDL_options ddl_options); + bool check_dependencies_in_with_clauses(); - bool resolve_references_to_cte_in_hanging_cte(); bool check_cte_dependencies_and_resolve_references(); bool resolve_references_to_cte(TABLE_LIST *tables, TABLE_LIST **tables_last); @@ -4854,14 +4850,13 @@ class Set_signal_information { public: /** Empty default constructor, use clear() */ - Set_signal_information() {} + Set_signal_information() = default; /** Copy constructor. */ Set_signal_information(const Set_signal_information& set); /** Destructor. */ - ~Set_signal_information() - {} + ~Set_signal_information() = default; /** Clear all items. */ void clear(); @@ -4984,8 +4979,7 @@ public: return m_lip.init(thd, buff, length); } - ~Parser_state() - {} + ~Parser_state() = default; Lex_input_stream m_lip; Yacc_state m_yacc; diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h index 0347030e4c6..2d648271898 100644 --- a/sql/sql_lifo_buffer.h +++ b/sql/sql_lifo_buffer.h @@ -138,7 +138,7 @@ public: virtual void remove_unused_space(uchar **unused_start, uchar **unused_end)=0; virtual uchar *used_area() = 0; - virtual ~Lifo_buffer() {}; + virtual ~Lifo_buffer() = default; }; diff --git a/sql/sql_list.h b/sql/sql_list.h index edecb0f0be4..5a57c86ef9d 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -54,7 +54,7 @@ public: { elements= tmp.elements; first= tmp.first; - next= tmp.next; + next= elements ? tmp.next : &first;; return *this; } diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc index fb7fa26f245..dd19807dd6d 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -1919,7 +1919,7 @@ MY_LOCALE my_locale_th_TH ); /***** LOCALE END th_TH *****/ -/***** LOCALE BEGIN tr_TR: Turkish - Turkey *****/ +/***** LOCALE BEGIN tr_TR: Turkish - Türkiye *****/ static const char *my_locale_month_names_tr_TR[13] = {"Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık", NullS }; static const char *my_locale_ab_month_names_tr_TR[13] = @@ -1940,7 +1940,7 @@ MY_LOCALE my_locale_tr_TR ( 52, "tr_TR", - "Turkish - Turkey", + "Turkish - Türkiye", FALSE, &my_locale_typelib_month_names_tr_TR, &my_locale_typelib_ab_month_names_tr_TR, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 579e4cd27f7..3b0ef4a7d47 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -118,7 +118,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, */ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables); -static void sql_kill(THD *thd, longlong id, killed_state state, killed_type type); +static void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type); static void sql_kill_user(THD *thd, LEX_USER *user, killed_state state); static bool lock_tables_precheck(THD *thd, TABLE_LIST *tables); static bool execute_show_status(THD *, TABLE_LIST *); @@ -4210,8 +4210,10 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); + Recreate_info recreate_info; res= mysql_alter_table(thd, &first_table->db, &first_table->table_name, - &create_info, first_table, &alter_info, + &create_info, first_table, + &recreate_info, &alter_info, 0, (ORDER*) 0, 0, lex->if_exists()); break; } @@ -5536,7 +5538,7 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) MYF(0)); goto error; } - sql_kill(thd, it->val_int(), lex->kill_signal, lex->kill_type); + sql_kill(thd, (my_thread_id) it->val_int(), lex->kill_signal, lex->kill_type); } else sql_kill_user(thd, get_current_user(thd, lex->users_list.head()), @@ -8806,8 +8808,8 @@ TABLE_LIST *st_select_lex::convert_right_join() void st_select_lex::prepare_add_window_spec(THD *thd) { LEX *lex= thd->lex; - lex->save_group_list= group_list; - lex->save_order_list= order_list; + save_group_list= group_list; + save_order_list= order_list; lex->win_ref= NULL; lex->win_frame= NULL; lex->frame_top_bound= NULL; @@ -8834,8 +8836,8 @@ bool st_select_lex::add_window_def(THD *thd, win_part_list_ptr, win_order_list_ptr, win_frame); - group_list= thd->lex->save_group_list; - order_list= thd->lex->save_order_list; + group_list= save_group_list; + order_list= save_order_list; if (parsing_place != SELECT_LIST) { fields_in_window_functions+= win_part_list_ptr->elements + @@ -8861,8 +8863,8 @@ bool st_select_lex::add_window_spec(THD *thd, win_part_list_ptr, win_order_list_ptr, win_frame); - group_list= thd->lex->save_group_list; - order_list= thd->lex->save_order_list; + group_list= save_group_list; + order_list= save_order_list; if (parsing_place != SELECT_LIST) { fields_in_window_functions+= win_part_list_ptr->elements + @@ -9166,12 +9168,12 @@ THD *find_thread_by_id(longlong id, bool query_id) */ uint -kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type type) +kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type type) { THD *tmp; uint error= (type == KILL_TYPE_QUERY ? ER_NO_SUCH_QUERY : ER_NO_SUCH_THREAD); DBUG_ENTER("kill_one_thread"); - DBUG_PRINT("enter", ("id: %lld signal: %d", id, kill_signal)); + DBUG_PRINT("enter", ("id: %lld signal: %d", (long long) id, kill_signal)); tmp= find_thread_by_id(id, type == KILL_TYPE_QUERY); if (!tmp) DBUG_RETURN(error); @@ -9344,7 +9346,7 @@ static uint kill_threads_for_user(THD *thd, LEX_USER *user, */ static -void sql_kill(THD *thd, longlong id, killed_state state, killed_type type) +void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type) { uint error; #ifdef WITH_WSREP diff --git a/sql/sql_partition_admin.h b/sql/sql_partition_admin.h index 4be9e56e359..b50c3555bcb 100644 --- a/sql/sql_partition_admin.h +++ b/sql/sql_partition_admin.h @@ -127,8 +127,7 @@ public: : Sql_cmd_common_alter_table() {} - ~Sql_cmd_alter_table_exchange_partition() - {} + ~Sql_cmd_alter_table_exchange_partition() = default; bool execute(THD *thd); @@ -150,8 +149,7 @@ public: : Sql_cmd_analyze_table() {} - ~Sql_cmd_alter_table_analyze_partition() - {} + ~Sql_cmd_alter_table_analyze_partition() = default; bool execute(THD *thd); @@ -176,8 +174,7 @@ public: : Sql_cmd_check_table() {} - ~Sql_cmd_alter_table_check_partition() - {} + ~Sql_cmd_alter_table_check_partition() = default; bool execute(THD *thd); @@ -202,8 +199,7 @@ public: : Sql_cmd_optimize_table() {} - ~Sql_cmd_alter_table_optimize_partition() - {} + ~Sql_cmd_alter_table_optimize_partition() = default; bool execute(THD *thd); @@ -228,8 +224,7 @@ public: : Sql_cmd_repair_table() {} - ~Sql_cmd_alter_table_repair_partition() - {} + ~Sql_cmd_alter_table_repair_partition() = default; bool execute(THD *thd); @@ -250,11 +245,9 @@ public: /** Constructor, used to represent a ALTER TABLE TRUNCATE PARTITION statement. */ - Sql_cmd_alter_table_truncate_partition() - {} + Sql_cmd_alter_table_truncate_partition() = default; - virtual ~Sql_cmd_alter_table_truncate_partition() - {} + virtual ~Sql_cmd_alter_table_truncate_partition() = default; bool execute(THD *thd); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index f8b4948a3ac..094ff52a4ea 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -342,7 +342,7 @@ static bool register_builtin(struct st_maria_plugin *, struct st_plugin_int *, struct st_plugin_int **); static void unlock_variables(THD *thd, struct system_variables *vars); static void cleanup_variables(struct system_variables *vars); -static void plugin_vars_free_values(sys_var *vars); +static void plugin_vars_free_values(st_mysql_sys_var **vars); static void restore_ptr_backup(uint n, st_ptr_backup *backup); static void intern_plugin_unlock(LEX *lex, plugin_ref plugin); static void reap_plugins(void); @@ -1293,7 +1293,7 @@ static void plugin_del(struct st_plugin_int *plugin, uint del_mask) if (!(plugin->state & del_mask)) DBUG_VOID_RETURN; /* Free allocated strings before deleting the plugin. */ - plugin_vars_free_values(plugin->system_vars); + plugin_vars_free_values(plugin->plugin->system_vars); restore_ptr_backup(plugin->nbackups, plugin->ptr_backup); if (plugin->plugin_dl) { @@ -2948,6 +2948,7 @@ sys_var *find_sys_var(THD *thd, const char *str, size_t length, /* called by register_var, construct_options and test_plugin_options. Returns the 'bookmark' for the named variable. + returns null for non thd-local variables. LOCK_system_variables_hash should be at least read locked */ static st_bookmark *find_bookmark(const char *plugin, const char *name, @@ -3004,7 +3005,6 @@ static size_t var_storage_size(int flags) /* returns a bookmark for thd-local variables, creating if neccessary. - returns null for non thd-local variables. Requires that a write lock is obtained on LOCK_system_variables_hash */ static st_bookmark *register_var(const char *plugin, const char *name, @@ -3358,27 +3358,35 @@ void plugin_thdvar_cleanup(THD *thd) variables are no longer accessible and the value space is lost. Note that only string values with PLUGIN_VAR_MEMALLOC are allocated and must be freed. - - @param[in] vars Chain of system variables of a plugin */ -static void plugin_vars_free_values(sys_var *vars) +static void plugin_vars_free_values(st_mysql_sys_var **vars) { DBUG_ENTER("plugin_vars_free_values"); - for (sys_var *var= vars; var; var= var->next) + if (!vars) + DBUG_VOID_RETURN; + + while(st_mysql_sys_var *var= *vars++) { - sys_var_pluginvar *piv= var->cast_pluginvar(); - if (piv && - ((piv->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR) && - (piv->plugin_var->flags & PLUGIN_VAR_MEMALLOC)) + if ((var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && + var->flags & PLUGIN_VAR_MEMALLOC) { - /* Free the string from global_system_variables. */ - char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL); + char **val; + if (var->flags & PLUGIN_VAR_THDLOCAL) + { + st_bookmark *v= find_bookmark(0, var->name, var->flags); + if (!v) + continue; + val= (char**)(global_system_variables.dynamic_variables_ptr + v->offset); + } + else + val= *(char***) (var + 1); + DBUG_PRINT("plugin", ("freeing value for: '%s' addr: %p", - var->name.str, valptr)); - my_free(*valptr); - *valptr= NULL; + var->name, val)); + my_free(*val); + *val= NULL; } } DBUG_VOID_RETURN; @@ -4038,7 +4046,7 @@ static my_option *construct_help_options(MEM_ROOT *mem_root, bzero(opts, sizeof(my_option) * count); /** - some plugin variables (those that don't have PLUGIN_VAR_NOSYSVAR flag) + some plugin variables have their names prefixed with the plugin name. Restore the names here to get the correct (not double-prefixed) help text. We won't need @@sysvars anymore and don't care about their proper names. @@ -4150,9 +4158,6 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, char *varname; sys_var *v; - if (o->flags & PLUGIN_VAR_NOSYSVAR) - continue; - tmp_backup[tmp->nbackups++].save(&o->name); if ((var= find_bookmark(tmp->name.str, o->name, o->flags))) { @@ -4168,6 +4173,12 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, my_casedn_str(&my_charset_latin1, varname); convert_dash_to_underscore(varname, len-1); } + if (o->flags & PLUGIN_VAR_NOSYSVAR) + { + o->name= varname; + continue; + } + const char *s= o->flags & PLUGIN_VAR_DEPRECATED ? "" : NULL; v= new (mem_root) sys_var_pluginvar(&chain, varname, tmp, o, s); v->test_load= (var ? &var->loaded : &static_unload); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c57e76da52c..1e84471eef2 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4035,9 +4035,7 @@ Reprepare_observer::report_error(THD *thd) * Server_runnable *******************************************************************/ -Server_runnable::~Server_runnable() -{ -} +Server_runnable::~Server_runnable() = default; /////////////////////////////////////////////////////////////////////////// diff --git a/sql/sql_prepare.h b/sql/sql_prepare.h index 1a96df85a19..ff6e986ec87 100644 --- a/sql/sql_prepare.h +++ b/sql/sql_prepare.h @@ -125,7 +125,7 @@ public: MEM_ROOT *mem_root_arg); /** We don't call member destructors, they all are POD types. */ - ~Ed_result_set() {} + ~Ed_result_set() = default; size_t get_field_count() const { return m_column_count; } diff --git a/sql/sql_schema.h b/sql/sql_schema.h index 886a115cbc5..37f8ceb7250 100644 --- a/sql/sql_schema.h +++ b/sql/sql_schema.h @@ -26,7 +26,7 @@ public: Schema(const LEX_CSTRING &name) :m_name(name) { } - virtual ~Schema() { } + virtual ~Schema() = default; const LEX_CSTRING &name() const { return m_name; } virtual const Type_handler *map_data_type(THD *thd, const Type_handler *src) const diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a88b8a54a08..ccec6f1215b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3801,15 +3801,26 @@ bool JOIN::make_aggr_tables_info() /* If we have different sort & group then we must sort the data by group - and copy it to another tmp table + and copy it to another tmp table. + This code is also used if we are using distinct something we haven't been able to store in the temporary table yet like SEC_TO_TIME(SUM(...)). + + 3. Also, this is used when + - the query has Window functions, + - the GROUP BY operation is done with OrderedGroupBy algorithm. + In this case, the first temptable will contain pre-GROUP-BY data. Force + the creation of the second temporary table. Post-GROUP-BY dataset will be + written there, and then Window Function processing code will be able to + process it. */ if ((group_list && (!test_if_subpart(group_list, order) || select_distinct)) || - (select_distinct && tmp_table_param.using_outer_summary_function)) - { /* Must copy to another table */ + (select_distinct && tmp_table_param.using_outer_summary_function) || + (group_list && !tmp_table_param.quick_group && // (3) + select_lex->have_window_funcs())) // (3) + { /* Must copy to another table */ DBUG_PRINT("info",("Creating group table")); calc_group_buffer(this, group_list); @@ -4235,7 +4246,7 @@ JOIN::optimize_distinct() } /* Optimize "select distinct b from t1 order by key_part_1 limit #" */ - if (order && skip_sort_order) + if (order && skip_sort_order && !unit->lim.is_with_ties()) { /* Should already have been optimized away */ DBUG_ASSERT(ordered_index_usage == ordered_index_order_by); @@ -24138,11 +24149,17 @@ end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records) /* @brief - Perform a GROUP BY operation over a stream of rows ordered by their group. - The result is sent into join->result. + Perform OrderedGroupBy operation and write the output into join->result. @detail - Also applies HAVING, etc. + The input stream is ordered by the GROUP BY expression, so groups come + one after another. We only need to accumulate the aggregate value, when + a GROUP BY group ends, check the HAVING and send the group. + + Note that the output comes in the GROUP BY order, which is required by + the MySQL's GROUP BY semantics. No further sorting is needed. + + @seealso end_write_group() also implements SortAndGroup */ enum_nested_loop_state @@ -24339,13 +24356,26 @@ end: /* @brief - Perform a GROUP BY operation over rows coming in arbitrary order. - - This is done by looking up the group in a temp.table and updating group - values. + Perform GROUP BY operation over rows coming in arbitrary order: use + TemporaryTableWithPartialSums algorithm. + + @detail + The TemporaryTableWithPartialSums algorithm is: + + CREATE TEMPORARY TABLE tmp ( + group_by_columns PRIMARY KEY, + partial_sum + ); + + for each row R in join output { + INSERT INTO tmp (R.group_by_columns, R.sum_value) + ON DUPLICATE KEY UPDATE partial_sum=partial_sum + R.sum_value; + } @detail Also applies HAVING, etc. + + @seealso end_unique_update() */ static enum_nested_loop_state @@ -24498,13 +24528,15 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), /* @brief - Perform a GROUP BY operation over a stream of rows ordered by their group. - Write the result into a temporary table. + Perform OrderedGroupBy operation and write the output into the temporary + table (join_tab->table). @detail - Also applies HAVING, etc. + The input stream is ordered by the GROUP BY expression, so groups come + one after another. We only need to accumulate the aggregate value, when + a GROUP BY group ends, check the HAVING and write the group. - The rows are written into temptable so e.g. filesort can read them. + @seealso end_send_group() also implements OrderedGroupBy */ enum_nested_loop_state @@ -30493,7 +30525,9 @@ static bool get_range_limit_read_cost(const POSITION *pos, cond_selectivity= best_rows / range_rows; else cond_selectivity= 1.0; +#if 0 // FIXME: cond_selectivity=8/4 = 2 in main.update_use_source DBUG_ASSERT(cond_selectivity <= 1.000000001); +#endif set_if_smaller(cond_selectivity, 1.0); /* @@ -31435,7 +31469,6 @@ void JOIN::make_notnull_conds_for_range_scans() { DBUG_ENTER("JOIN::make_notnull_conds_for_range_scans"); - if (impossible_where || !optimizer_flag(thd, OPTIMIZER_SWITCH_NOT_NULL_RANGE_SCAN)) { @@ -31515,7 +31548,6 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond, table_map allowed) { THD *thd= join->thd; - DBUG_ENTER("build_notnull_conds_for_range_scans"); for (JOIN_TAB *s= join->join_tab; @@ -31523,13 +31555,13 @@ bool build_notnull_conds_for_range_scans(JOIN *join, Item *cond, { /* Clear all needed bitmaps to mark found fields */ if ((allowed & s->table->map) && - !(s->table->map && join->const_table_map)) + !(s->table->map & join->const_table_map)) bitmap_clear_all(&s->table->tmp_set); } /* Find all null-rejected fields assuming that cond is null-rejected and - only formulas over tables from 'allowed' are to be taken into account + only formulas over tables from 'allowed' are to be taken into account */ if (cond->find_not_null_fields(allowed)) DBUG_RETURN(true); diff --git a/sql/sql_select.h b/sql/sql_select.h index 4b64243e1c9..a45c4b8ffc2 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -777,7 +777,7 @@ public: virtual void mark_used() = 0; - virtual ~Semi_join_strategy_picker() {} + virtual ~Semi_join_strategy_picker() = default; }; @@ -1559,12 +1559,30 @@ public: (set in make_join_statistics()) */ bool impossible_where; - List<Item> all_fields; ///< to store all fields that used in query + + /* + All fields used in the query processing. + + Initially this is a list of fields from the query's SQL text. + + Then, ORDER/GROUP BY and Window Function code add columns that need to + be saved to be available in the post-group-by context. These extra columns + are added to the front, because this->all_fields points to the suffix of + this list. + */ + List<Item> all_fields; ///Above list changed to use temporary table List<Item> tmp_all_fields1, tmp_all_fields2, tmp_all_fields3; ///Part, shared with list above, emulate following list List<Item> tmp_fields_list1, tmp_fields_list2, tmp_fields_list3; - List<Item> &fields_list; ///< hold field list passed to mysql_select + + /* + The original field list as it was passed to mysql_select(). This refers + to select_lex->item_list. + CAUTION: this list is a suffix of this->all_fields list, that is, it shares + elements with that list! + */ + List<Item> &fields_list; List<Item> procedure_fields_list; int error; @@ -1960,7 +1978,7 @@ public: null_ptr(arg.null_ptr), err(arg.err) {} - virtual ~store_key() {} /** Not actually needed */ + virtual ~store_key() = default; /** Not actually needed */ virtual enum Type type() const=0; virtual const char *name() const=0; virtual bool store_key_is_const() { return false; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6ffa4da955a..e4bef08f314 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -10441,11 +10441,9 @@ exit: class IS_internal_schema_access : public ACL_internal_schema_access { public: - IS_internal_schema_access() - {} + IS_internal_schema_access() = default; - ~IS_internal_schema_access() - {} + ~IS_internal_schema_access() = default; ACL_internal_access_result check(privilege_t want_access, privilege_t *save_priv) const; diff --git a/sql/sql_signal.h b/sql/sql_signal.h index 433cee21d58..abc9905aefb 100644 --- a/sql/sql_signal.h +++ b/sql/sql_signal.h @@ -36,8 +36,7 @@ protected: m_set_signal_information(set) {} - virtual ~Sql_cmd_common_signal() - {} + virtual ~Sql_cmd_common_signal() = default; /** Evaluate each signal condition items for this statement. @@ -84,8 +83,7 @@ public: : Sql_cmd_common_signal(cond, set) {} - virtual ~Sql_cmd_signal() - {} + virtual ~Sql_cmd_signal() = default; virtual enum_sql_command sql_command_code() const { @@ -111,8 +109,7 @@ public: : Sql_cmd_common_signal(cond, set) {} - virtual ~Sql_cmd_resignal() - {} + virtual ~Sql_cmd_resignal() = default; virtual enum_sql_command sql_command_code() const { diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 5930ebd8256..ecde847c8d4 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -519,7 +519,7 @@ public: } - virtual ~Stat_table() {} + virtual ~Stat_table() = default; /** @brief @@ -1705,7 +1705,7 @@ protected: public: - Count_distinct_field() {} + Count_distinct_field() = default; /** @param diff --git a/sql/sql_string.cc b/sql/sql_string.cc index f4586d530c9..14db5ad7c7d 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -677,33 +677,37 @@ bool String::append_with_prefill(const char *s,uint32 arg_length, } -int Binary_string::strstr(const Binary_string &s, uint32 offset) +int Binary_string::strstr(const char *search, uint32 search_length, uint32 offset) { - if (s.length()+offset <= str_length) + if (search_length + offset <= str_length) { - if (!s.length()) + if (!search_length) return ((int) offset); // Empty string is always found - const char *str = Ptr+offset; - const char *search=s.ptr(); - const char *end=Ptr+str_length-s.length()+1; - const char *search_end=s.ptr()+s.length(); + const char *str= Ptr + offset; + const char *end= Ptr + str_length - search_length + 1; + const char *search_end= search + search_length; skip: while (str != end) { if (*str++ == *search) { - char *i,*j; - i=(char*) str; j=(char*) search+1; - while (j != search_end) - if (*i++ != *j++) goto skip; - return (int) (str-Ptr) -1; + char *i= (char*) str; + char *j= (char*) search + 1 ; + while (j != search_end) + if (*i++ != *j++) goto skip; + return (int) (str-Ptr) -1; } } } return -1; } +int Binary_string::strstr(const Binary_string &s, uint32 offset) +{ + return strstr(s.ptr(), s.length(), offset); +} + /* ** Search string from end. Offset is offset to the end of string */ diff --git a/sql/sql_string.h b/sql/sql_string.h index b1f02bdb43b..9729d9e85fd 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -330,6 +330,7 @@ public: // Returns offset to substring or -1 int strstr(const Binary_string &search, uint32 offset=0); + int strstr(const char *search, uint32 search_length, uint32 offset=0); // Returns offset to substring or -1 int strrstr(const Binary_string &search, uint32 offset=0); @@ -803,7 +804,7 @@ public: class String: public Charset, public Binary_string { public: - String() { } + String() = default; String(size_t length_arg) :Binary_string(length_arg) { } /* @@ -817,9 +818,7 @@ public: String(char *str, size_t len, CHARSET_INFO *cs) :Charset(cs), Binary_string(str, len) { } - String(const String &str) - :Charset(str), Binary_string(str) - { } + String(const String &str) = default; void set(String &str,size_t offset,size_t arg_length) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index db9a67da094..94371b53303 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7673,7 +7673,7 @@ static bool mysql_inplace_alter_table(THD *thd, THD_STAGE_INFO(thd, stage_alter_inplace); DBUG_EXECUTE_IF("start_alter_delay_master", { debug_sync_set_action(thd, - STRING_WITH_LEN("now wait_for alter_cont")); + STRING_WITH_LEN("now wait_for alter_cont NO_CLEAR_EVENT")); }); /* We can abort alter table for any table type */ @@ -9823,6 +9823,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, Table_specification_st *create_info, TABLE_LIST *table_list, + Recreate_info *recreate_info, Alter_info *alter_info, uint order_num, ORDER *order, bool ignore, bool if_exists) @@ -10856,7 +10857,7 @@ do_continue:; DBUG_EXECUTE_IF("start_alter_delay_master", { debug_sync_set_action(thd, - STRING_WITH_LEN("now wait_for alter_cont")); + STRING_WITH_LEN("now wait_for alter_cont NO_CLEAR_EVENT")); }); // It's now safe to take the table level lock. if (lock_tables(thd, table_list, alter_ctx.tables_opened, @@ -11333,11 +11334,10 @@ end_temporary: thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; - my_snprintf(alter_ctx.tmp_buff, sizeof(alter_ctx.tmp_buff), - ER_THD(thd, ER_INSERT_INFO), - (ulong) (copied + deleted), (ulong) deleted, - (ulong) thd->get_stmt_da()->current_statement_warn_count()); - my_ok(thd, copied + deleted, 0L, alter_ctx.tmp_buff); + *recreate_info= Recreate_info(copied, deleted); + thd->my_ok_with_recreate_info(*recreate_info, + (ulong) thd->get_stmt_da()-> + current_statement_warn_count()); DEBUG_SYNC(thd, "alter_table_inplace_trans_commit"); DBUG_RETURN(false); @@ -11852,7 +11852,8 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, Like mysql_alter_table(). */ -bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) +bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, + Recreate_info *recreate_info, bool table_copy) { Table_specification_st create_info; Alter_info alter_info; @@ -11877,8 +11878,11 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) Alter_info::ALTER_TABLE_ALGORITHM_COPY); bool res= mysql_alter_table(thd, &null_clex_str, &null_clex_str, &create_info, - table_list, &alter_info, 0, - (ORDER *) 0, 0, 0); + table_list, recreate_info, &alter_info, 0, + (ORDER *) 0, + // Ignore duplicate records on REPAIR + thd->lex->sql_command == SQLCOM_REPAIR, + 0); table_list->next_global= next_table; DBUG_RETURN(res); } diff --git a/sql/sql_table.h b/sql/sql_table.h index c9e4d969482..ccde7d87120 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -163,6 +163,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, Table_specification_st *create_info, TABLE_LIST *table_list, + class Recreate_info *recreate_info, Alter_info *alter_info, uint order_num, ORDER *order, bool ignore, bool if_exists); @@ -170,7 +171,8 @@ bool mysql_compare_tables(TABLE *table, Alter_info *alter_info, HA_CREATE_INFO *create_info, bool *metadata_equal); -bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy); +bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, + class Recreate_info *recreate_info, bool table_copy); bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, const LEX_CSTRING *old_name, const LEX_CSTRING *new_db, const LEX_CSTRING *new_name, LEX_CUSTRING *id, diff --git a/sql/sql_truncate.h b/sql/sql_truncate.h index 7d2ff4b6050..5704da1dd7b 100644 --- a/sql/sql_truncate.h +++ b/sql/sql_truncate.h @@ -31,11 +31,9 @@ public: /** Constructor, used to represent a TRUNCATE statement. */ - Sql_cmd_truncate_table() - {} + Sql_cmd_truncate_table() = default; - virtual ~Sql_cmd_truncate_table() - {} + virtual ~Sql_cmd_truncate_table() = default; /** Execute a TRUNCATE statement at runtime. diff --git a/sql/sql_type.h b/sql/sql_type.h index dcdf6438fd9..741e0c9bb96 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -124,6 +124,32 @@ enum scalar_comparison_op }; +class Hasher +{ + ulong m_nr1; + ulong m_nr2; +public: + Hasher(): m_nr1(1), m_nr2(4) + { } + void add_null() + { + m_nr1^= (m_nr1 << 1) | 1; + } + void add(CHARSET_INFO *cs, const uchar *str, size_t length) + { + cs->coll->hash_sort(cs, str, length, &m_nr1, &m_nr2); + } + void add(CHARSET_INFO *cs, const char *str, size_t length) + { + add(cs, (const uchar *) str, length); + } + uint32 finalize() const + { + return (uint32) m_nr1; + } +}; + + enum partition_value_print_mode_t { PARTITION_VALUE_PRINT_MODE_SHOW= 0, @@ -367,7 +393,7 @@ class Dec_ptr { protected: my_decimal *m_ptr; - Dec_ptr() { } + Dec_ptr() = default; public: Dec_ptr(my_decimal *ptr) :m_ptr(ptr) { } bool is_null() const { return m_ptr == NULL; } @@ -515,7 +541,7 @@ protected: { m_sec= m_usec= m_neg= m_truncated= 0; } - Sec6() { } + Sec6() = default; bool add_nanoseconds(uint nanoseconds) { DBUG_ASSERT(nanoseconds <= 1000000000); @@ -675,7 +701,7 @@ protected: Sec6::make_from_int(nr); m_nsec= 0; } - Sec9() { } + Sec9() = default; public: Sec9(const my_decimal *d) { @@ -2828,7 +2854,7 @@ class Timestamp_or_zero_datetime_native: public NativeBuffer<STRING_BUFFER_TIMESTAMP_BINARY_SIZE> { public: - Timestamp_or_zero_datetime_native() { } + Timestamp_or_zero_datetime_native() = default; Timestamp_or_zero_datetime_native(const Timestamp_or_zero_datetime &ts, uint decimals) { @@ -3305,13 +3331,9 @@ public: class Type_all_attributes: public Type_std_attributes { public: - Type_all_attributes() - :Type_std_attributes() - { } - Type_all_attributes(const Type_all_attributes &other) - :Type_std_attributes(other) - { } - virtual ~Type_all_attributes() {} + Type_all_attributes() = default; + Type_all_attributes(const Type_all_attributes &) = default; + virtual ~Type_all_attributes() = default; virtual void set_type_maybe_null(bool maybe_null_arg)= 0; // Returns total number of decimal digits virtual decimal_digits_t decimal_precision() const= 0; @@ -3323,7 +3345,7 @@ public: class Type_cmp_attributes { public: - virtual ~Type_cmp_attributes() { } + virtual ~Type_cmp_attributes() = default; virtual CHARSET_INFO *compare_collation() const= 0; }; @@ -3527,9 +3549,9 @@ enum vers_kind_t class Vers_type_handler { protected: - Vers_type_handler() {} + Vers_type_handler() = default; public: - virtual ~Vers_type_handler() {} + virtual ~Vers_type_handler() = default; virtual vers_kind_t kind() const { DBUG_ASSERT(0); @@ -3826,7 +3848,7 @@ public: return false; } Type_handler() : m_name(0,0) {} - virtual ~Type_handler() {} + virtual ~Type_handler() = default; /** Determines MariaDB traditional scalar data types that always present in the server. @@ -4342,7 +4364,7 @@ public: class Type_handler_row: public Type_handler { public: - virtual ~Type_handler_row() {} + virtual ~Type_handler_row() = default; const Name &default_value() const override; bool validate_implicit_default_value(THD *, const Column_definition &) const override @@ -4746,7 +4768,7 @@ public: bool Item_func_min_max_get_date(THD *thd, Item_func_min_max*, MYSQL_TIME *, date_mode_t fuzzydate) const override; - virtual ~Type_handler_numeric() { } + virtual ~Type_handler_numeric() = default; bool can_change_cond_ref_to_const(Item_bool_func2 *target, Item *target_expr, Item *target_value, Item_bool_func2 *source, @@ -4771,7 +4793,7 @@ public: { return DYN_COL_DOUBLE; } - virtual ~Type_handler_real_result() {} + virtual ~Type_handler_real_result() = default; const Type_handler *type_handler_for_comparison() const override; Field *make_table_field(MEM_ROOT *root, const LEX_CSTRING *name, @@ -4892,7 +4914,7 @@ public: { return DYN_COL_DECIMAL; } - virtual ~Type_handler_decimal_result() {}; + virtual ~Type_handler_decimal_result() = default; const Type_handler *type_handler_for_comparison() const override; int stored_field_cmp_to_item(THD *, Field *field, Item *item) const override { @@ -5152,7 +5174,7 @@ public: } bool is_order_clause_position_type() const override { return true; } bool is_limit_clause_valid_type() const override { return true; } - virtual ~Type_handler_int_result() {} + virtual ~Type_handler_int_result() = default; const Type_handler *type_handler_for_comparison() const override; int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const override; bool subquery_type_allows_materialization(const Item *inner, @@ -5272,7 +5294,7 @@ protected: public: Item_result result_type() const override { return STRING_RESULT; } Item_result cmp_type() const override { return TIME_RESULT; } - virtual ~Type_handler_temporal_result() {} + virtual ~Type_handler_temporal_result() = default; void Column_definition_attributes_frm_pack(const Column_definition_attributes *at, uchar *buff) const override; @@ -5370,7 +5392,7 @@ public: return DYN_COL_STRING; } CHARSET_INFO *charset_for_protocol(const Item *item) const override; - virtual ~Type_handler_string_result() {} + virtual ~Type_handler_string_result() = default; const Type_handler *type_handler_for_comparison() const override; int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const override; @@ -5560,7 +5582,7 @@ public: class Type_handler_tiny: public Type_handler_general_purpose_int { public: - virtual ~Type_handler_tiny() {} + virtual ~Type_handler_tiny() = default; enum_field_types field_type() const override { return MYSQL_TYPE_TINY; } const Type_handler *type_handler_unsigned() const override; const Type_handler *type_handler_signed() const override; @@ -5611,7 +5633,7 @@ public: class Type_handler_short: public Type_handler_general_purpose_int { public: - virtual ~Type_handler_short() {} + virtual ~Type_handler_short() = default; enum_field_types field_type() const override { return MYSQL_TYPE_SHORT; } const Type_handler *type_handler_unsigned() const override; const Type_handler *type_handler_signed() const override; @@ -5662,7 +5684,7 @@ public: class Type_handler_long: public Type_handler_general_purpose_int { public: - virtual ~Type_handler_long() {} + virtual ~Type_handler_long() = default; enum_field_types field_type() const override { return MYSQL_TYPE_LONG; } const Type_handler *type_handler_unsigned() const override; const Type_handler *type_handler_signed() const override; @@ -5724,7 +5746,7 @@ public: class Type_handler_longlong: public Type_handler_general_purpose_int { public: - virtual ~Type_handler_longlong() {} + virtual ~Type_handler_longlong() = default; enum_field_types field_type() const override{ return MYSQL_TYPE_LONGLONG; } const Type_handler *type_handler_unsigned() const override; const Type_handler *type_handler_signed() const override; @@ -5779,7 +5801,7 @@ public: class Type_handler_vers_trx_id: public Type_handler_ulonglong { public: - virtual ~Type_handler_vers_trx_id() {} + virtual ~Type_handler_vers_trx_id() = default; Field *make_table_field(MEM_ROOT *root, const LEX_CSTRING *name, const Record_addr &addr, @@ -5791,7 +5813,7 @@ public: class Type_handler_int24: public Type_handler_general_purpose_int { public: - virtual ~Type_handler_int24() {} + virtual ~Type_handler_int24() = default; enum_field_types field_type() const override { return MYSQL_TYPE_INT24; } const Type_handler *type_handler_unsigned() const override; const Type_handler *type_handler_signed() const override; @@ -5836,7 +5858,7 @@ public: class Type_handler_year: public Type_handler_int_result { public: - virtual ~Type_handler_year() {} + virtual ~Type_handler_year() = default; enum_field_types field_type() const override { return MYSQL_TYPE_YEAR; } uint flags() const override { return UNSIGNED_FLAG; } protocol_send_type_t protocol_send_type() const override @@ -5890,7 +5912,7 @@ public: class Type_handler_bit: public Type_handler_int_result { public: - virtual ~Type_handler_bit() {} + virtual ~Type_handler_bit() = default; enum_field_types field_type() const override { return MYSQL_TYPE_BIT; } uint flags() const override { return UNSIGNED_FLAG; } protocol_send_type_t protocol_send_type() const override @@ -5955,7 +5977,7 @@ public: class Type_handler_float: public Type_handler_real_result { public: - virtual ~Type_handler_float() {} + virtual ~Type_handler_float() = default; enum_field_types field_type() const override { return MYSQL_TYPE_FLOAT; } protocol_send_type_t protocol_send_type() const override { @@ -6009,7 +6031,7 @@ public: class Type_handler_double: public Type_handler_real_result { public: - virtual ~Type_handler_double() {} + virtual ~Type_handler_double() = default; enum_field_types field_type() const override { return MYSQL_TYPE_DOUBLE; } protocol_send_type_t protocol_send_type() const override { @@ -6064,7 +6086,7 @@ public: class Type_handler_time_common: public Type_handler_temporal_result { public: - virtual ~Type_handler_time_common() { } + virtual ~Type_handler_time_common() = default; const Name &default_value() const override; enum_field_types field_type() const override { return MYSQL_TYPE_TIME; } enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr) @@ -6186,7 +6208,7 @@ class Type_handler_time: public Type_handler_time_common static uint m_hires_bytes[MAX_DATETIME_PRECISION+1]; public: static uint hires_bytes(uint dec) { return m_hires_bytes[dec]; } - virtual ~Type_handler_time() {} + virtual ~Type_handler_time() = default; const Name version() const override { return version_mariadb53(); } uint32 max_display_length_for_field(const Conv_source &src) const override { return MIN_TIME_WIDTH; } @@ -6216,7 +6238,7 @@ public: class Type_handler_time2: public Type_handler_time_common { public: - virtual ~Type_handler_time2() {} + virtual ~Type_handler_time2() = default; const Name version() const override { return version_mysql56(); } enum_field_types real_field_type() const override { return MYSQL_TYPE_TIME2; } uint32 max_display_length_for_field(const Conv_source &src) const override; @@ -6246,7 +6268,7 @@ public: class Type_handler_temporal_with_date: public Type_handler_temporal_result { public: - virtual ~Type_handler_temporal_with_date() {} + virtual ~Type_handler_temporal_with_date() = default; Item_literal *create_literal_item(THD *thd, const char *str, size_t length, CHARSET_INFO *cs, bool send_error) const override; @@ -6276,7 +6298,7 @@ public: class Type_handler_date_common: public Type_handler_temporal_with_date { public: - virtual ~Type_handler_date_common() {} + virtual ~Type_handler_date_common() = default; const Name &default_value() const override; const Type_handler *type_handler_for_comparison() const override; enum_field_types field_type() const override { return MYSQL_TYPE_DATE; } @@ -6347,7 +6369,7 @@ public: class Type_handler_date: public Type_handler_date_common { public: - virtual ~Type_handler_date() {} + virtual ~Type_handler_date() = default; uint32 calc_pack_length(uint32 length) const override { return 4; } Field *make_conversion_table_field(MEM_ROOT *root, TABLE *table, uint metadata, @@ -6374,7 +6396,7 @@ public: class Type_handler_newdate: public Type_handler_date_common { public: - virtual ~Type_handler_newdate() {} + virtual ~Type_handler_newdate() = default; enum_field_types real_field_type() const override { return MYSQL_TYPE_NEWDATE; @@ -6405,7 +6427,7 @@ public: class Type_handler_datetime_common: public Type_handler_temporal_with_date { public: - virtual ~Type_handler_datetime_common() {} + virtual ~Type_handler_datetime_common() = default; const Name &default_value() const override; const Type_handler *type_handler_for_comparison() const override; enum_field_types field_type() const override @@ -6489,7 +6511,7 @@ class Type_handler_datetime: public Type_handler_datetime_common static uint m_hires_bytes[MAX_DATETIME_PRECISION + 1]; public: static uint hires_bytes(uint dec) { return m_hires_bytes[dec]; } - virtual ~Type_handler_datetime() {} + virtual ~Type_handler_datetime() = default; const Name version() const override { return version_mariadb53(); } uint32 max_display_length_for_field(const Conv_source &src) const override { return MAX_DATETIME_WIDTH; } @@ -6519,7 +6541,7 @@ public: class Type_handler_datetime2: public Type_handler_datetime_common { public: - virtual ~Type_handler_datetime2() {} + virtual ~Type_handler_datetime2() = default; const Name version() const override { return version_mysql56(); } enum_field_types real_field_type() const override { @@ -6554,7 +6576,7 @@ class Type_handler_timestamp_common: public Type_handler_temporal_with_date protected: bool TIME_to_native(THD *, const MYSQL_TIME *from, Native *to, uint dec) const; public: - virtual ~Type_handler_timestamp_common() {} + virtual ~Type_handler_timestamp_common() = default; const Name &default_value() const override; const Type_handler *type_handler_for_comparison() const override; const Type_handler *type_handler_for_native_format() const override; @@ -6656,7 +6678,7 @@ class Type_handler_timestamp: public Type_handler_timestamp_common static uint m_sec_part_bytes[MAX_DATETIME_PRECISION + 1]; public: static uint sec_part_bytes(uint dec) { return m_sec_part_bytes[dec]; } - virtual ~Type_handler_timestamp() {} + virtual ~Type_handler_timestamp() = default; const Name version() const override { return version_mariadb53(); } uint32 max_display_length_for_field(const Conv_source &src) const override { return MAX_DATETIME_WIDTH; } @@ -6686,7 +6708,7 @@ public: class Type_handler_timestamp2: public Type_handler_timestamp_common { public: - virtual ~Type_handler_timestamp2() {} + virtual ~Type_handler_timestamp2() = default; const Name version() const override { return version_mysql56(); } enum_field_types real_field_type() const override { @@ -6721,7 +6743,7 @@ public: class Type_handler_olddecimal: public Type_handler_decimal_result { public: - virtual ~Type_handler_olddecimal() {} + virtual ~Type_handler_olddecimal() = default; enum_field_types field_type() const override { return MYSQL_TYPE_DECIMAL; } uint32 max_display_length_for_field(const Conv_source &src) const override; uint32 calc_pack_length(uint32 length) const override { return length; } @@ -6755,7 +6777,7 @@ public: class Type_handler_newdecimal: public Type_handler_decimal_result { public: - virtual ~Type_handler_newdecimal() {} + virtual ~Type_handler_newdecimal() = default; enum_field_types field_type() const override { return MYSQL_TYPE_NEWDECIMAL; } uint32 max_display_length_for_field(const Conv_source &src) const override; uint32 calc_pack_length(uint32 length) const override; @@ -6799,7 +6821,7 @@ public: class Type_handler_null: public Type_handler_general_purpose_string { public: - virtual ~Type_handler_null() {} + virtual ~Type_handler_null() = default; enum_field_types field_type() const override { return MYSQL_TYPE_NULL; } enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr) const override @@ -6871,7 +6893,7 @@ public: class Type_handler_string: public Type_handler_longstr { public: - virtual ~Type_handler_string() {} + virtual ~Type_handler_string() = default; enum_field_types field_type() const override { return MYSQL_TYPE_STRING; } ulong KEY_pack_flags(uint column_nr) const override { @@ -6925,7 +6947,7 @@ public: class Type_handler_var_string: public Type_handler_string { public: - virtual ~Type_handler_var_string() {} + virtual ~Type_handler_var_string() = default; enum_field_types field_type() const override { return MYSQL_TYPE_VAR_STRING; } enum_field_types real_field_type() const override { return MYSQL_TYPE_STRING; } enum_field_types traditional_merge_field_type() const override @@ -6955,7 +6977,7 @@ public: class Type_handler_varchar: public Type_handler_longstr { public: - virtual ~Type_handler_varchar() {} + virtual ~Type_handler_varchar() = default; enum_field_types field_type() const override { return MYSQL_TYPE_VARCHAR; } ulong KEY_pack_flags(uint column_nr) const override { @@ -7026,7 +7048,7 @@ public: class Type_handler_hex_hybrid: public Type_handler_varchar { public: - virtual ~Type_handler_hex_hybrid() {} + virtual ~Type_handler_hex_hybrid() = default; const Type_handler *cast_to_int_type_handler() const override; bool Item_func_round_fix_length_and_dec(Item_func_round *) const override; bool Item_func_int_val_fix_length_and_dec(Item_func_int_val*) const override; @@ -7069,7 +7091,7 @@ public: class Type_handler_blob_common: public Type_handler_longstr { public: - virtual ~Type_handler_blob_common() { } + virtual ~Type_handler_blob_common() = default; virtual uint length_bytes() const= 0; ulong KEY_pack_flags(uint column_nr) const override { @@ -7146,7 +7168,7 @@ public: class Type_handler_tiny_blob: public Type_handler_blob_common { public: - virtual ~Type_handler_tiny_blob() {} + virtual ~Type_handler_tiny_blob() = default; uint length_bytes() const override { return 1; } enum_field_types field_type() const override { return MYSQL_TYPE_TINY_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const override; @@ -7163,7 +7185,7 @@ public: class Type_handler_medium_blob: public Type_handler_blob_common { public: - virtual ~Type_handler_medium_blob() {} + virtual ~Type_handler_medium_blob() = default; uint length_bytes() const override { return 3; } enum_field_types field_type() const override { return MYSQL_TYPE_MEDIUM_BLOB; } @@ -7181,7 +7203,7 @@ public: class Type_handler_long_blob: public Type_handler_blob_common { public: - virtual ~Type_handler_long_blob() {} + virtual ~Type_handler_long_blob() = default; uint length_bytes() const override { return 4; } enum_field_types field_type() const override { return MYSQL_TYPE_LONG_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const override; @@ -7200,7 +7222,7 @@ public: class Type_handler_blob: public Type_handler_blob_common { public: - virtual ~Type_handler_blob() {} + virtual ~Type_handler_blob() = default; uint length_bytes() const override { return 2; } enum_field_types field_type() const override { return MYSQL_TYPE_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const override; @@ -7244,7 +7266,7 @@ public: class Type_handler_typelib: public Type_handler_general_purpose_string { public: - virtual ~Type_handler_typelib() { } + virtual ~Type_handler_typelib() = default; enum_field_types field_type() const override { return MYSQL_TYPE_STRING; } const Type_handler *type_handler_for_item_field() const override; const Type_handler *cast_to_int_type_handler() const override; @@ -7282,7 +7304,7 @@ public: class Type_handler_enum: public Type_handler_typelib { public: - virtual ~Type_handler_enum() {} + virtual ~Type_handler_enum() = default; enum_field_types real_field_type() const override { return MYSQL_TYPE_ENUM; } enum_field_types traditional_merge_field_type() const override { @@ -7323,7 +7345,7 @@ public: class Type_handler_set: public Type_handler_typelib { public: - virtual ~Type_handler_set() {} + virtual ~Type_handler_set() = default; enum_field_types real_field_type() const override { return MYSQL_TYPE_SET; } enum_field_types traditional_merge_field_type() const override { @@ -7369,7 +7391,7 @@ public: class Function_collection { public: - virtual ~Function_collection() {} + virtual ~Function_collection() = default; virtual bool init()= 0; virtual void cleanup()= 0; virtual Create_func *find_native_function_builder(THD *thd, @@ -7381,11 +7403,8 @@ public: class Type_collection { public: - virtual ~Type_collection() {} - virtual bool init(Type_handler_data *data) - { - return false; - } + virtual ~Type_collection() = default; + virtual bool init(Type_handler_data *) { return false; } virtual const Type_handler *handler_by_name(const LEX_CSTRING &name) const= 0; virtual const Type_handler *aggregate_for_result(const Type_handler *h1, const Type_handler *h2) @@ -7579,7 +7598,7 @@ public: const Type_handler *m_handler1; const Type_handler *m_handler2; const Type_handler *m_result; - Pair() { } + Pair() = default; Pair(const Type_handler *handler1, const Type_handler *handler2, const Type_handler *result) diff --git a/sql/sql_type_fixedbin.h b/sql/sql_type_fixedbin.h index 077e4039643..223bf2cf398 100644 --- a/sql/sql_type_fixedbin.h +++ b/sql/sql_type_fixedbin.h @@ -1428,12 +1428,9 @@ public: item->type_handler() == type_handler()); return true; } - void hash(ulong *nr, ulong *nr2) override + void hash_not_null(Hasher *hasher) override { - if (is_null()) - *nr^= (*nr << 1) | 1; - else - FbtImpl::hash_record(ptr, nr, nr2); + FbtImpl::hash_record(ptr, hasher); } SEL_ARG *get_mm_leaf(RANGE_OPT_PARAM *prm, KEY_PART *key_part, const Item_bool_func *cond, diff --git a/sql/sql_type_fixedbin_storage.h b/sql/sql_type_fixedbin_storage.h index 6e18335bd4c..3a4e74a8cdb 100644 --- a/sql/sql_type_fixedbin_storage.h +++ b/sql/sql_type_fixedbin_storage.h @@ -64,9 +64,7 @@ protected: // The buffer that stores the in-memory binary representation char m_buffer[NATIVE_LEN]; - // Non-initializing constructor - FixedBinTypeStorage() - { } + FixedBinTypeStorage() = default; FixedBinTypeStorage & set_zero() { @@ -122,9 +120,9 @@ public: Hash the in-record representation Used in Field::hash(). */ - static void hash_record(const uchar *ptr, ulong *nr, ulong *nr2) + static void hash_record(uchar *ptr, Hasher *hasher) { - my_charset_bin.hash_sort(ptr, binary_length(), nr, nr2); + hasher->add(&my_charset_bin, ptr, binary_length()); } static bool only_zero_bytes(const char *ptr, size_t length) diff --git a/sql/sql_window.cc b/sql/sql_window.cc index c9f2256ff16..436a8db948d 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -954,7 +954,7 @@ protected: class Table_read_cursor : public Rowid_seq_cursor { public: - virtual ~Table_read_cursor() {} + virtual ~Table_read_cursor() = default; void init(READ_RECORD *info) { @@ -1138,7 +1138,7 @@ public: virtual bool is_outside_computation_bounds() const { return false; }; - virtual ~Frame_cursor() {} + virtual ~Frame_cursor() = default; /* Regular frame cursors add or remove values from the sum functions they diff --git a/sql/sql_window.h b/sql/sql_window.h index 66ea8c7dd4d..1c02740e769 100644 --- a/sql/sql_window.h +++ b/sql/sql_window.h @@ -106,7 +106,7 @@ class Window_spec : public Sql_alloc { bool window_names_are_checked; public: - virtual ~Window_spec() {} + virtual ~Window_spec() = default; LEX_CSTRING *window_ref; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0c3aaf79c6f..2927b6ce8de 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13365,6 +13365,8 @@ delete_part2: { Lex->last_table()->vers_conditions= Lex->vers_conditions; Lex->pop_select(); //main select + if (Lex->check_main_unit_semantics()) + MYSQL_YYABORT; } ; @@ -13401,6 +13403,8 @@ single_multi: if ($3) Select->order_list= *($3); Lex->pop_select(); //main select + if (Lex->check_main_unit_semantics()) + MYSQL_YYABORT; } | table_wild_list { diff --git a/sql/structs.h b/sql/structs.h index 1da50522991..214fcb242ff 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -981,7 +981,7 @@ public: class Load_data_outvar { public: - virtual ~Load_data_outvar() {} + virtual ~Load_data_outvar() = default; virtual bool load_data_set_null(THD *thd, const Load_data_param *param)= 0; virtual bool load_data_set_value(THD *thd, const char *pos, uint length, const Load_data_param *param)= 0; @@ -995,7 +995,7 @@ public: class Timeval: public timeval { protected: - Timeval() { } + Timeval() = default; public: Timeval(my_time_t sec, ulong usec) { diff --git a/sql/sys_vars_shared.h b/sql/sys_vars_shared.h index bc48d1f7fff..508a0a70c8f 100644 --- a/sql/sys_vars_shared.h +++ b/sql/sys_vars_shared.h @@ -44,7 +44,7 @@ public: virtual void rdlock()= 0; virtual void wrlock()= 0; virtual void unlock()= 0; - virtual ~PolyLock() {} + virtual ~PolyLock() = default; }; class PolyLock_mutex: public PolyLock diff --git a/sql/table.cc b/sql/table.cc index 3fffb974f0c..e0189401906 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1101,6 +1101,18 @@ static void mysql57_calculate_null_position(TABLE_SHARE *share, } } + +Item_func_hash *TABLE_SHARE::make_long_hash_func(THD *thd, + MEM_ROOT *mem_root, + List<Item> *field_list) + const +{ + if (old_long_hash_function()) + return new (mem_root) Item_func_hash_mariadb_100403(thd, *field_list); + return new (mem_root) Item_func_hash(thd, *field_list); +} + + /** Parse TABLE_SHARE::vcol_defs unpack_vcol_info_from_frm @@ -1306,7 +1318,10 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, list_item= new (mem_root) Item_field(thd, keypart->field); field_list->push_back(list_item, mem_root); } - Item_func_hash *hash_item= new(mem_root)Item_func_hash(thd, *field_list); + + Item_func_hash *hash_item= table->s->make_long_hash_func(thd, mem_root, + field_list); + Virtual_column_info *v= new (mem_root) Virtual_column_info(); field->vcol_info= v; field->vcol_info->expr= hash_item; diff --git a/sql/table.h b/sql/table.h index add1871e899..13b8b1a9dc4 100644 --- a/sql/table.h +++ b/sql/table.h @@ -55,6 +55,7 @@ class Item; /* Needed by ORDER */ typedef Item (*Item_ptr); class Item_subselect; class Item_field; +class Item_func_hash; class GRANT_TABLE; class st_select_lex_unit; class st_select_lex; @@ -137,14 +138,13 @@ public: void restore_env(THD *thd, Object_creation_ctx *backup_ctx); protected: - Object_creation_ctx() {} + Object_creation_ctx() = default; virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0; virtual void change_env(THD *thd) const = 0; public: - virtual ~Object_creation_ctx() - { } + virtual ~Object_creation_ctx() = default; }; /*************************************************************************/ @@ -560,7 +560,7 @@ protected: public: Table_check_intact(bool keys= false) : has_keys(keys) {} - virtual ~Table_check_intact() {} + virtual ~Table_check_intact() = default; /** Checks whether a table is intact. */ bool check(TABLE *table, const TABLE_FIELD_DEF *table_def); @@ -737,7 +737,7 @@ public: struct TABLE_SHARE { - TABLE_SHARE() {} /* Remove gcc warning */ + TABLE_SHARE() = default; /* Remove gcc warning */ /** Category of this table. */ TABLE_CATEGORY table_category; @@ -1197,6 +1197,22 @@ struct TABLE_SHARE void set_overlapped_keys(); void set_ignored_indexes(); key_map usable_indexes(THD *thd); + + bool old_long_hash_function() const + { + return mysql_version < 100428 || + (mysql_version >= 100500 && mysql_version < 100519) || + (mysql_version >= 100600 && mysql_version < 100612) || + (mysql_version >= 100700 && mysql_version < 100708) || + (mysql_version >= 100800 && mysql_version < 100807) || + (mysql_version >= 100900 && mysql_version < 100905) || + (mysql_version >= 101000 && mysql_version < 101003) || + (mysql_version >= 101100 && mysql_version < 101102); + } + Item_func_hash *make_long_hash_func(THD *thd, + MEM_ROOT *mem_root, + List<Item> *field_list) const; + void update_optimizer_costs(handlerton *hton); }; @@ -1274,7 +1290,7 @@ struct vers_select_conds_t; struct TABLE { - TABLE() {} /* Remove gcc warning */ + TABLE() = default; /* Remove gcc warning */ TABLE_SHARE *s; handler *file; @@ -2274,7 +2290,7 @@ class Index_hint; struct TABLE_CHAIN { - TABLE_CHAIN() {} + TABLE_CHAIN() = default; TABLE_LIST **start_pos; TABLE_LIST ** end_pos; @@ -2285,7 +2301,7 @@ struct TABLE_CHAIN struct TABLE_LIST { - TABLE_LIST() {} /* Remove gcc warning */ + TABLE_LIST() = default; /* Remove gcc warning */ enum prelocking_types { @@ -3056,8 +3072,8 @@ class Item; class Field_iterator: public Sql_alloc { public: - Field_iterator() {} /* Remove gcc warning */ - virtual ~Field_iterator() {} + Field_iterator() = default; /* Remove gcc warning */ + virtual ~Field_iterator() = default; virtual void set(TABLE_LIST *)= 0; virtual void next()= 0; virtual bool end_of_fields()= 0; /* Return 1 at end of list */ @@ -3118,7 +3134,7 @@ class Field_iterator_natural_join: public Field_iterator Natural_join_column *cur_column_ref; public: Field_iterator_natural_join() :cur_column_ref(NULL) {} - ~Field_iterator_natural_join() {} + ~Field_iterator_natural_join() = default; void set(TABLE_LIST *table); void next(); bool end_of_fields() { return !cur_column_ref; } diff --git a/sql/threadpool.h b/sql/threadpool.h index 7737d056b4a..d815d538cde 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -102,8 +102,7 @@ struct TP_connection priority(TP_PRIORITY_HIGH) {} - virtual ~TP_connection() - {}; + virtual ~TP_connection() = default; /* Initialize io structures windows threadpool, epoll etc */ virtual int init() = 0; @@ -121,7 +120,7 @@ struct TP_connection struct TP_pool { - virtual ~TP_pool(){}; + virtual ~TP_pool() = default; virtual int init()= 0; virtual TP_connection *new_connection(CONNECT *)= 0; virtual void add(TP_connection *c)= 0; diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index eb08441a4d5..7261eabfd82 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -1574,8 +1574,7 @@ static void *worker_main(void *param) } -TP_pool_generic::TP_pool_generic() -{} +TP_pool_generic::TP_pool_generic() = default; int TP_pool_generic::init() { diff --git a/sql/tztime.cc b/sql/tztime.cc index 4d94054541d..a2add055deb 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1027,7 +1027,7 @@ static const String tz_SYSTEM_name("SYSTEM", 6, &my_charset_latin1); class Time_zone_system : public Time_zone { public: - Time_zone_system() {} /* Remove gcc warning */ + Time_zone_system() = default; /* Remove gcc warning */ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; virtual const String * get_name() const; @@ -1123,7 +1123,7 @@ Time_zone_system::get_name() const class Time_zone_utc : public Time_zone { public: - Time_zone_utc() {} /* Remove gcc warning */ + Time_zone_utc() = default; /* Remove gcc warning */ virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t, uint *error_code) const; virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const; diff --git a/sql/tztime.h b/sql/tztime.h index 9e5d469925f..6d8af62ecd4 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -41,7 +41,7 @@ class THD; class Time_zone: public Sql_alloc { public: - Time_zone() {} /* Remove gcc warning */ + Time_zone() = default; /* Remove gcc warning */ /** Converts local time in broken down MYSQL_TIME representation to my_time_t (UTC seconds since Epoch) represenation. @@ -66,7 +66,7 @@ public: We need this only for surpressing warnings, objects of this type are allocated on MEM_ROOT and should not require destruction. */ - virtual ~Time_zone() {}; + virtual ~Time_zone() = default; protected: static inline void adjust_leap_second(MYSQL_TIME *t); diff --git a/sql/vers_string.h b/sql/vers_string.h index 67fd421500e..c5be9c359e3 100644 --- a/sql/vers_string.h +++ b/sql/vers_string.h @@ -53,7 +53,7 @@ template <class Compare> struct Lex_cstring_with_compare : public Lex_cstring { public: - Lex_cstring_with_compare() {} + Lex_cstring_with_compare() = default; Lex_cstring_with_compare(const char *_str, size_t _len) : Lex_cstring(_str, _len) { } diff --git a/sql/win_tzname_data.h b/sql/win_tzname_data.h index 792cdbc7a13..8a240118ac3 100644 --- a/sql/win_tzname_data.h +++ b/sql/win_tzname_data.h @@ -44,7 +44,7 @@ {L"UTC-02","Etc/GMT+2"}, {L"Azores Standard Time","Atlantic/Azores"}, {L"Cape Verde Standard Time","Atlantic/Cape_Verde"}, -{L"UTC","Etc/GMT"}, +{L"UTC","Etc/UTC"}, {L"GMT Standard Time","Europe/London"}, {L"Greenwich Standard Time","Atlantic/Reykjavik"}, {L"Sao Tome Standard Time","Africa/Sao_Tome"}, @@ -64,6 +64,7 @@ {L"South Africa Standard Time","Africa/Johannesburg"}, {L"FLE Standard Time","Europe/Kiev"}, {L"Israel Standard Time","Asia/Jerusalem"}, +{L"South Sudan Standard Time","Africa/Juba"}, {L"Kaliningrad Standard Time","Europe/Kaliningrad"}, {L"Sudan Standard Time","Africa/Khartoum"}, {L"Libya Standard Time","Africa/Tripoli"}, diff --git a/sql/wsrep_client_service.cc b/sql/wsrep_client_service.cc index 7ab5ba0c1e2..628a408b49b 100644 --- a/sql/wsrep_client_service.cc +++ b/sql/wsrep_client_service.cc @@ -1,4 +1,4 @@ -/* Copyright 2018-2022 Codership Oy <info@codership.com> +/* Copyright 2018-2023 Codership Oy <info@codership.com> 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 @@ -347,22 +347,36 @@ void Wsrep_client_service::debug_crash(const char* crash_point) int Wsrep_client_service::bf_rollback() { DBUG_ASSERT(m_thd == current_thd); - DBUG_ENTER("Wsrep_client_service::rollback"); + DBUG_ENTER("Wsrep_client_service::bf_rollback"); int ret= (trans_rollback_stmt(m_thd) || trans_rollback(m_thd)); - if (m_thd->locked_tables_mode && m_thd->lock) - { - if (m_thd->locked_tables_list.unlock_locked_tables(m_thd)) - ret= 1; - m_thd->variables.option_bits&= ~OPTION_TABLE_LOCK; - } - if (m_thd->global_read_lock.is_acquired()) + + WSREP_DEBUG("::bf_rollback() thread: %lu, client_state %s " + "client_mode %s trans_state %s killed %d", + thd_get_thread_id(m_thd), + wsrep_thd_client_state_str(m_thd), + wsrep_thd_client_mode_str(m_thd), + wsrep_thd_transaction_state_str(m_thd), + m_thd->killed); + + /* If client is quiting all below will be done in THD::cleanup() + TODO: why we need this any other case? */ + if (m_thd->wsrep_cs().state() != wsrep::client_state::s_quitting) { - m_thd->global_read_lock.unlock_global_read_lock(m_thd); + if (m_thd->locked_tables_mode && m_thd->lock) + { + if (m_thd->locked_tables_list.unlock_locked_tables(m_thd)) + ret= 1; + m_thd->variables.option_bits&= ~OPTION_TABLE_LOCK; + } + if (m_thd->global_read_lock.is_acquired()) + { + m_thd->global_read_lock.unlock_global_read_lock(m_thd); + } + m_thd->release_transactional_locks(); + mysql_ull_cleanup(m_thd); + m_thd->mdl_context.release_explicit_locks(); } - m_thd->release_transactional_locks(); - mysql_ull_cleanup(m_thd); - m_thd->mdl_context.release_explicit_locks(); DBUG_RETURN(ret); } diff --git a/sql/wsrep_condition_variable.h b/sql/wsrep_condition_variable.h index c97b47378f7..d9798bb9548 100644 --- a/sql/wsrep_condition_variable.h +++ b/sql/wsrep_condition_variable.h @@ -29,8 +29,7 @@ public: Wsrep_condition_variable(mysql_cond_t* cond) : m_cond(cond) { } - ~Wsrep_condition_variable() - { } + ~Wsrep_condition_variable() = default; void notify_one() { diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index 93d4738212d..7d8296a75a1 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -292,6 +292,7 @@ int Wsrep_high_priority_service::append_fragment_and_commit( ret= ret || trans_commit(m_thd); ret= ret || (m_thd->wsrep_cs().after_applying(), 0); + m_thd->release_transactional_locks(); free_root(m_thd->mem_root, MYF(MY_KEEP_PREALLOC)); @@ -380,6 +381,15 @@ int Wsrep_high_priority_service::rollback(const wsrep::ws_handle& ws_handle, assert(ws_handle == wsrep::ws_handle()); } int ret= (trans_rollback_stmt(m_thd) || trans_rollback(m_thd)); + + WSREP_DEBUG("::rollback() thread: %lu, client_state %s " + "client_mode %s trans_state %s killed %d", + thd_get_thread_id(m_thd), + wsrep_thd_client_state_str(m_thd), + wsrep_thd_client_mode_str(m_thd), + wsrep_thd_transaction_state_str(m_thd), + m_thd->killed); + m_thd->release_transactional_locks(); mysql_ull_cleanup(m_thd); m_thd->mdl_context.release_explicit_locks(); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 110062defe3..3a8bfe3532d 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1020,13 +1020,19 @@ void wsrep_init_startup (bool sst_first) With mysqldump SST (!sst_first) wait until the server reaches joiner state and procedd to accepting connections. */ + int err= 0; if (sst_first) { - server_state.wait_until_state(Wsrep_server_state::s_initializing); + err= server_state.wait_until_state(Wsrep_server_state::s_initializing); } else { - server_state.wait_until_state(Wsrep_server_state::s_joiner); + err= server_state.wait_until_state(Wsrep_server_state::s_joiner); + } + if (err) + { + WSREP_ERROR("Wsrep startup was interrupted"); + unireg_abort(1); } } @@ -1133,7 +1139,11 @@ void wsrep_stop_replication(THD *thd) { WSREP_DEBUG("Disconnect provider"); Wsrep_server_state::instance().disconnect(); - Wsrep_server_state::instance().wait_until_state(Wsrep_server_state::s_disconnected); + if (Wsrep_server_state::instance().wait_until_state( + Wsrep_server_state::s_disconnected)) + { + WSREP_WARN("Wsrep interrupted while waiting for disconnected state"); + } } /* my connection, should not terminate with wsrep_close_client_connection(), @@ -1155,7 +1165,11 @@ void wsrep_shutdown_replication() { WSREP_DEBUG("Disconnect provider"); Wsrep_server_state::instance().disconnect(); - Wsrep_server_state::instance().wait_until_state(Wsrep_server_state::s_disconnected); + if (Wsrep_server_state::instance().wait_until_state( + Wsrep_server_state::s_disconnected)) + { + WSREP_WARN("Wsrep interrupted while waiting for disconnected state"); + } } wsrep_close_client_connections(TRUE); @@ -3232,7 +3246,9 @@ static my_bool have_client_connections(THD *thd, void*) { DBUG_PRINT("quit",("Informing thread %lld that it's time to die", (longlong) thd->thread_id)); - if (is_client_connection(thd) && thd->killed == KILL_CONNECTION) + if (is_client_connection(thd) && + (thd->killed == KILL_CONNECTION || + thd->killed == KILL_CONNECTION_HARD)) { (void)abort_replicated(thd); return 1; @@ -3242,7 +3258,7 @@ static my_bool have_client_connections(THD *thd, void*) static void wsrep_close_thread(THD *thd) { - thd->set_killed(KILL_CONNECTION); + thd->set_killed(KILL_CONNECTION_HARD); MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (thd)); mysql_mutex_lock(&thd->LOCK_thd_kill); thd->abort_current_cond_wait(true); @@ -3276,13 +3292,13 @@ static my_bool kill_all_threads(THD *thd, THD *caller_thd) if (is_client_connection(thd) && thd != caller_thd) { if (is_replaying_connection(thd)) - thd->set_killed(KILL_CONNECTION); + thd->set_killed(KILL_CONNECTION_HARD); else if (!abort_replicated(thd)) { /* replicated transactions must be skipped */ WSREP_DEBUG("closing connection %lld", (longlong) thd->thread_id); /* instead of wsrep_close_thread() we do now soft kill by THD::awake */ - thd->awake(KILL_CONNECTION); + thd->awake(KILL_CONNECTION_HARD); } } return 0; diff --git a/sql/wsrep_schema.cc b/sql/wsrep_schema.cc index 5595e0a090c..3634d636e7c 100644 --- a/sql/wsrep_schema.cc +++ b/sql/wsrep_schema.cc @@ -670,12 +670,9 @@ static void make_key(TABLE* table, uchar** key, key_part_map* map, int parts) { } /* namespace Wsrep_schema_impl */ -Wsrep_schema::Wsrep_schema() -{ -} +Wsrep_schema::Wsrep_schema() = default; -Wsrep_schema::~Wsrep_schema() -{ } +Wsrep_schema::~Wsrep_schema() = default; static void wsrep_init_thd_for_schema(THD *thd) { diff --git a/sql/wsrep_server_state.cc b/sql/wsrep_server_state.cc index b49302790e7..f80320fe216 100644 --- a/sql/wsrep_server_state.cc +++ b/sql/wsrep_server_state.cc @@ -57,8 +57,7 @@ Wsrep_server_state::Wsrep_server_state(const std::string& name, , m_service(*this) { } -Wsrep_server_state::~Wsrep_server_state() -{ } +Wsrep_server_state::~Wsrep_server_state() = default; void Wsrep_server_state::init_once(const std::string& name, const std::string& incoming_address, diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 03ca34992c8..b007357dbc3 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -337,9 +337,14 @@ static bool wsrep_sst_complete (THD* thd, if ((state == Wsrep_server_state::s_joiner || state == Wsrep_server_state::s_initialized)) { - Wsrep_server_state::instance().sst_received(client_service, - rcode); - WSREP_INFO("SST succeeded for position %s", start_pos_buf); + if (Wsrep_server_state::instance().sst_received(client_service, rcode)) + { + failed= true; + } + else + { + WSREP_INFO("SST succeeded for position %s", start_pos_buf); + } } else { diff --git a/sql/xa.cc b/sql/xa.cc index 457aacfeb30..0e421ac62f5 100644 --- a/sql/xa.cc +++ b/sql/xa.cc @@ -600,6 +600,7 @@ bool trans_xa_commit(THD *thd) if (auto xs= xid_cache_search(thd, thd->lex->xid)) { + bool xid_deleted= false; res= xa_trans_rolled_back(xs); /* Acquire metadata lock which will ensure that COMMIT is blocked @@ -610,7 +611,7 @@ bool trans_xa_commit(THD *thd) */ MDL_request mdl_request; MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, - MDL_STATEMENT); + MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, thd->variables.lock_wait_timeout)) { @@ -621,25 +622,37 @@ bool trans_xa_commit(THD *thd) */ DBUG_ASSERT(thd->is_error()); - xs->acquired_to_recovered(); - DBUG_RETURN(true); + res= true; + goto _end_external_xid; } - DBUG_ASSERT(!xid_state.xid_cache_element); - - if (thd->wait_for_prior_commit()) + else { - DBUG_ASSERT(thd->is_error()); - - xs->acquired_to_recovered(); - DBUG_RETURN(true); + thd->backup_commit_lock= &mdl_request; } + DBUG_ASSERT(!xid_state.xid_cache_element); xid_state.xid_cache_element= xs; ha_commit_or_rollback_by_xid(thd->lex->xid, !res); - xid_state.xid_cache_element= 0; + if (!res && thd->is_error()) + { + // hton completion error retains xs/xid in the cache, + // unless there had been already one as reflected by `res`. + res= true; + goto _end_external_xid; + } + xid_cache_delete(thd, xs); + xid_deleted= true; + _end_external_xid: + xid_state.xid_cache_element= 0; res= res || thd->is_error(); - xid_cache_delete(thd, xs); + if (!xid_deleted) + xs->acquired_to_recovered(); + if (mdl_request.ticket) + { + thd->mdl_context.release_lock(mdl_request.ticket); + thd->backup_commit_lock= 0; + } } else my_error(ER_XAER_NOTA, MYF(0)); @@ -761,9 +774,11 @@ bool trans_xa_rollback(THD *thd) if (auto xs= xid_cache_search(thd, thd->lex->xid)) { + bool res; + bool xid_deleted= false; MDL_request mdl_request; MDL_REQUEST_INIT(&mdl_request, MDL_key::BACKUP, "", "", MDL_BACKUP_COMMIT, - MDL_STATEMENT); + MDL_EXPLICIT); if (thd->mdl_context.acquire_lock(&mdl_request, thd->variables.lock_wait_timeout)) { @@ -774,23 +789,33 @@ bool trans_xa_rollback(THD *thd) */ DBUG_ASSERT(thd->is_error()); - xs->acquired_to_recovered(); - DBUG_RETURN(true); + goto _end_external_xid; } - xa_trans_rolled_back(xs); - DBUG_ASSERT(!xid_state.xid_cache_element); - - if (thd->wait_for_prior_commit()) + else { - DBUG_ASSERT(thd->is_error()); - xs->acquired_to_recovered(); - DBUG_RETURN(true); + thd->backup_commit_lock= &mdl_request; } + res= xa_trans_rolled_back(xs); + DBUG_ASSERT(!xid_state.xid_cache_element); xid_state.xid_cache_element= xs; ha_commit_or_rollback_by_xid(thd->lex->xid, 0); - xid_state.xid_cache_element= 0; + if (!res && thd->is_error()) + { + goto _end_external_xid; + } xid_cache_delete(thd, xs); + xid_deleted= true; + + _end_external_xid: + xid_state.xid_cache_element= 0; + if (!xid_deleted) + xs->acquired_to_recovered(); + if (mdl_request.ticket) + { + thd->mdl_context.release_lock(mdl_request.ticket); + thd->backup_commit_lock= 0; + } } else my_error(ER_XAER_NOTA, MYF(0)); |