From d8b8f55af3eda9e884ce341805174578a5c3a58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 3 Jul 2019 09:04:29 +0300 Subject: [PATCH] MDEV-19908: Add override keywords Fix the build on clang. GCC only checks that a member function with the C++11 override keyword is actually overriding a virtual member function in a base class. In clang, you will get a warning for overridden member functions that lack the keyword, if any overridden member function of the class is declared with the keyword. --- sql/sql_type.h | 291 ++++++++++++++++++++++++++----------------------- 1 file changed, 157 insertions(+), 134 deletions(-) diff --git a/sql/sql_type.h b/sql/sql_type.h index e3318707be8..8cef59f23ae 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -4749,135 +4749,150 @@ class Type_handler_string_result: public Type_handler { uint Item_temporal_precision(THD *thd, Item *item, bool is_time) const; public: - const Name &default_value() const; - protocol_send_type_t protocol_send_type() const + const Name &default_value() const override; + protocol_send_type_t protocol_send_type() const override { return PROTOCOL_SEND_STRING; } - Item_result result_type() const { return STRING_RESULT; } - Item_result cmp_type() const { return STRING_RESULT; } - enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr) const + Item_result result_type() const override { return STRING_RESULT; } + Item_result cmp_type() const override { return STRING_RESULT; } + enum_dynamic_column_type dyncol_type(const Type_all_attributes *) const + override { return DYN_COL_STRING; } - CHARSET_INFO *charset_for_protocol(const Item *item) const; + CHARSET_INFO *charset_for_protocol(const Item *item) const override; virtual ~Type_handler_string_result() {} - const Type_handler *type_handler_for_comparison() const; - int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const; + const Type_handler *type_handler_for_comparison() const override; + int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) const + override; const Type_handler * type_handler_adjusted_to_max_octet_length(uint max_octet_length, - CHARSET_INFO *cs) const; + CHARSET_INFO *cs) const override; void make_sort_key(uchar *to, Item *item, const SORT_FIELD_ATTR *sort_field, - Sort_param *param) const; + Sort_param *param) const override; void sortlength(THD *thd, const Type_std_attributes *item, - SORT_FIELD_ATTR *attr) const; - bool union_element_finalize(const Item * item) const; + SORT_FIELD_ATTR *attr) const override; + bool union_element_finalize(const Item * item) const override; bool Column_definition_prepare_stage1(THD *thd, MEM_ROOT *mem_root, Column_definition *c, handler *file, - ulonglong table_flags) const; + ulonglong table_flags) const override; bool Column_definition_redefine_stage1(Column_definition *def, const Column_definition *dup, const handler *file, const Schema_specification_st *schema) - const; - uint32 max_display_length(const Item *item) const; + const override; + uint32 max_display_length(const Item *item) const override; bool Item_const_eq(const Item_const *a, const Item_const *b, - bool binary_cmp) const; + bool binary_cmp) const override; bool Item_eq_value(THD *thd, const Type_cmp_attributes *attr, - Item *a, Item *b) const; - uint Item_time_precision(THD *thd, Item *item) const + Item *a, Item *b) const override; + uint Item_time_precision(THD *thd, Item *item) const override { return Item_temporal_precision(thd, item, true); } - uint Item_datetime_precision(THD *thd, Item *item) const + uint Item_datetime_precision(THD *thd, Item *item) const override { return Item_temporal_precision(thd, item, false); } - uint Item_decimal_precision(const Item *item) const; - void Item_update_null_value(Item *item) const; - bool Item_save_in_value(THD *thd, Item *item, st_value *value) const; - void Item_param_setup_conversion(THD *thd, Item_param *) const; + uint Item_decimal_precision(const Item *item) const override; + void Item_update_null_value(Item *item) const override; + bool Item_save_in_value(THD *thd, Item *item, st_value *value) const override; + void Item_param_setup_conversion(THD *thd, Item_param *) const override; void Item_param_set_param_func(Item_param *param, - uchar **pos, ulong len) const; + uchar **pos, ulong len) const override; bool Item_param_set_from_value(THD *thd, Item_param *param, const Type_all_attributes *attr, - const st_value *value) const; - bool Item_send(Item *item, Protocol *protocol, st_value *buf) const + const st_value *value) const override; + bool Item_send(Item *item, Protocol *protocol, st_value *buf) const override { return Item_send_str(item, protocol, buf); } - int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; - String *print_item_value(THD *thd, Item *item, String *str) const + int Item_save_in_field(Item *item, Field *field, bool no_conversions) const + override; + String *print_item_value(THD *thd, Item *item, String *str) const override { return print_item_value_csstr(thd, item, str); } bool can_change_cond_ref_to_const(Item_bool_func2 *target, Item *target_expr, Item *target_value, Item_bool_func2 *source, - Item *source_expr, Item *source_const) const; + Item *source_expr, Item *source_const) const + override; bool subquery_type_allows_materialization(const Item *inner, - const Item *outer) const; - Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const; - Item_cache *Item_get_cache(THD *thd, const Item *item) const; - bool set_comparator_func(Arg_comparator *cmp) const; + const Item *outer) const override; + Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const + override; + Item_cache *Item_get_cache(THD *thd, const Item *item) const override; + bool set_comparator_func(Arg_comparator *cmp) const override; bool Item_hybrid_func_fix_attributes(THD *thd, const char *name, Type_handler_hybrid_field_type *, Type_all_attributes *atrr, - Item **items, uint nitems) const; - bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const; - bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const; - bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const; - bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; - bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const; - bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const; - bool Item_val_bool(Item *item) const; + Item **items, uint nitems) const + override; + bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const override; + bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const override; + bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const override; + bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const override; + bool Item_func_signed_fix_length_and_dec(Item_func_signed *item) const + override; + bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *item) const + override; + bool Item_val_bool(Item *item) const override; void Item_get_date(THD *thd, Item *item, Temporal::Warn *warn, - MYSQL_TIME *ltime, date_mode_t fuzzydate) const; - longlong Item_val_int_signed_typecast(Item *item) const; - longlong Item_val_int_unsigned_typecast(Item *item) const; - String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; + MYSQL_TIME *ltime, date_mode_t fuzzydate) const override; + longlong Item_val_int_signed_typecast(Item *item) const override; + longlong Item_val_int_unsigned_typecast(Item *item) const override; + String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const + override; String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *, - String *) const; + String *) const override; double Item_func_hybrid_field_type_val_real(Item_func_hybrid_field_type *) - const; + const override; longlong Item_func_hybrid_field_type_val_int(Item_func_hybrid_field_type *) - const; + const override; my_decimal *Item_func_hybrid_field_type_val_decimal( Item_func_hybrid_field_type *, - my_decimal *) const; + my_decimal *) const override; void Item_func_hybrid_field_type_get_date(THD *, Item_func_hybrid_field_type *, Temporal::Warn *, MYSQL_TIME *, - date_mode_t fuzzydate) const; - String *Item_func_min_max_val_str(Item_func_min_max *, String *) const; - double Item_func_min_max_val_real(Item_func_min_max *) const; - longlong Item_func_min_max_val_int(Item_func_min_max *) const; + date_mode_t fuzzydate) + const override; + String *Item_func_min_max_val_str(Item_func_min_max *, String *) const + override; + double Item_func_min_max_val_real(Item_func_min_max *) const override; + longlong Item_func_min_max_val_int(Item_func_min_max *) const override; my_decimal *Item_func_min_max_val_decimal(Item_func_min_max *, - my_decimal *) const; + my_decimal *) const override; bool Item_func_min_max_get_date(THD *thd, Item_func_min_max*, - MYSQL_TIME *, date_mode_t fuzzydate) const; - bool Item_func_between_fix_length_and_dec(Item_func_between *func) const; - longlong Item_func_between_val_int(Item_func_between *func) const; - bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const; - cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const; - in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const; - bool Item_func_in_fix_comparator_compatible_types(THD *thd, - Item_func_in *) const; - bool Item_func_round_fix_length_and_dec(Item_func_round *) const; - bool Item_func_int_val_fix_length_and_dec(Item_func_int_val *) const; - bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const; - bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const; - bool Item_func_plus_fix_length_and_dec(Item_func_plus *) const; - bool Item_func_minus_fix_length_and_dec(Item_func_minus *) const; - bool Item_func_mul_fix_length_and_dec(Item_func_mul *) const; - bool Item_func_div_fix_length_and_dec(Item_func_div *) const; - bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const; + MYSQL_TIME *, date_mode_t fuzzydate) const + override; + bool Item_func_between_fix_length_and_dec(Item_func_between *func) const + override; + longlong Item_func_between_val_int(Item_func_between *func) const override; + bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const + override; + cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const override; + in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const + override; + bool Item_func_in_fix_comparator_compatible_types(THD *thd, Item_func_in *) + 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; + bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override; + bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const override; + bool Item_func_plus_fix_length_and_dec(Item_func_plus *) const override; + bool Item_func_minus_fix_length_and_dec(Item_func_minus *) const override; + bool Item_func_mul_fix_length_and_dec(Item_func_mul *) const override; + bool Item_func_div_fix_length_and_dec(Item_func_div *) const override; + bool Item_func_mod_fix_length_and_dec(Item_func_mod *) const override; }; @@ -6233,30 +6248,32 @@ public: virtual ~Type_handler_blob_common() { } virtual uint length_bytes() const= 0; Field *make_conversion_table_field(TABLE *, uint metadata, - const Field *target) const; + const Field *target) const override; const Type_handler *type_handler_for_tmp_table(const Item *item) const + override { return blob_type_handler(item); } - const Type_handler *type_handler_for_union(const Item *item) const + const Type_handler *type_handler_for_union(const Item *item) const override { return blob_type_handler(item); } bool subquery_type_allows_materialization(const Item *inner, - const Item *outer) const + const Item *outer) const override { return false; // Materialization does not work with BLOB columns } - bool is_param_long_data_type() const { return true; } - bool Column_definition_fix_attributes(Column_definition *c) const; + bool is_param_long_data_type() const override { return true; } + bool Column_definition_fix_attributes(Column_definition *c) const override; void Column_definition_reuse_fix_attributes(THD *thd, Column_definition *c, - const Field *field) const; + const Field *field) const + override; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, - ulonglong table_flags) const; + ulonglong table_flags) const override; bool Key_part_spec_init_ft(Key_part_spec *part, - const Column_definition &def) const; + const Column_definition &def) const override; bool Key_part_spec_init_primary(Key_part_spec *part, const Column_definition &def, const handler *file) const override; @@ -6274,20 +6291,21 @@ public: const char *name, Type_handler_hybrid_field_type *, Type_all_attributes *atrr, - Item **items, uint nitems) const; - void Item_param_setup_conversion(THD *thd, Item_param *) const; + Item **items, uint nitems) const + override; + void Item_param_setup_conversion(THD *thd, Item_param *) const override; Field *make_schema_field(TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, - bool show_field) const; + bool show_field) const override; Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root, const LEX_CSTRING *name, const Record_addr &addr, const Bit_addr &bit, const Column_definition_attributes *attr, - uint32 flags) const; + uint32 flags) const override; }; @@ -6402,13 +6420,13 @@ public: static const Type_handler_geometry *type_handler_geom_by_type(uint type); public: virtual ~Type_handler_geometry() {} - const Name name() const { return m_name_geometry; } - enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } - bool is_param_long_data_type() const { return true; } - uint32 max_display_length_for_field(const Conv_source &src) const; - uint32 calc_pack_length(uint32 length) const; + const Name name() const override { return m_name_geometry; } + enum_field_types field_type() const override { return MYSQL_TYPE_GEOMETRY; } + bool is_param_long_data_type() const override { return true; } + uint32 max_display_length_for_field(const Conv_source &src) const override; + uint32 calc_pack_length(uint32 length) const override; const Type_collection *type_collection() const override; - const Type_handler *type_handler_for_comparison() const; + const Type_handler *type_handler_for_comparison() const override; virtual geometry_types geometry_type() const { return GEOM_GEOMETRY; } const Type_handler *type_handler_frm_unpack(const uchar *buffer) const override; @@ -6418,43 +6436,42 @@ public: return geometry_type() == GEOM_GEOMETRY || geometry_type() == th->geometry_type(); } - bool type_can_have_key_part() const - { - return true; - } + bool type_can_have_key_part() const override { return true; } bool subquery_type_allows_materialization(const Item *inner, - const Item *outer) const + const Item *outer) const override { return false; // Materialization does not work with GEOMETRY columns } void Item_param_set_param_func(Item_param *param, - uchar **pos, ulong len) const; + uchar **pos, ulong len) const override; bool Item_param_set_from_value(THD *thd, Item_param *param, const Type_all_attributes *attr, - const st_value *value) const; + const st_value *value) const override; Field *make_conversion_table_field(TABLE *, uint metadata, - const Field *target) const; + const Field *target) const override; void Column_definition_attributes_frm_pack(const Column_definition_attributes *at, - uchar *buff) const; + uchar *buff) const override; bool Column_definition_attributes_frm_unpack(Column_definition_attributes *attr, TABLE_SHARE *share, const uchar *buffer, - LEX_CUSTRING *gis_options) const; - bool Column_definition_fix_attributes(Column_definition *c) const; + LEX_CUSTRING *gis_options) const + override; + bool Column_definition_fix_attributes(Column_definition *c) const override; void Column_definition_reuse_fix_attributes(THD *thd, Column_definition *c, - const Field *field) const; + const Field *field) const + override; bool Column_definition_prepare_stage1(THD *thd, MEM_ROOT *mem_root, Column_definition *c, handler *file, - ulonglong table_flags) const; + ulonglong table_flags) const override; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, - ulonglong table_flags) const; + ulonglong table_flags) const override; bool Key_part_spec_init_primary(Key_part_spec *part, const Column_definition &def, const handler *file) const override; @@ -6473,7 +6490,7 @@ public: Field *make_table_field(const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, - TABLE *table) const; + TABLE *table) const override; Field *make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root, @@ -6481,40 +6498,46 @@ public: const Record_addr &addr, const Bit_addr &bit, const Column_definition_attributes *attr, - uint32 flags) const; + uint32 flags) const override; - bool can_return_int() const { return false; } - bool can_return_decimal() const { return false; } - bool can_return_real() const { return false; } - bool can_return_text() const { return false; } - bool can_return_date() const { return false; } - bool can_return_time() const { return false; } - bool is_traditional_type() const - { - return false; - } - bool Item_func_round_fix_length_and_dec(Item_func_round *) const; - bool Item_func_int_val_fix_length_and_dec(Item_func_int_val *) const; - bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const; - bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const; + bool can_return_int() const override { return false; } + bool can_return_decimal() const override { return false; } + bool can_return_real() const override { return false; } + bool can_return_text() const override { return false; } + bool can_return_date() const override { return false; } + bool can_return_time() const override { return false; } + bool is_traditional_type() const override { return false; } + 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; + bool Item_func_abs_fix_length_and_dec(Item_func_abs *) const override; + bool Item_func_neg_fix_length_and_dec(Item_func_neg *) const override; bool Item_hybrid_func_fix_attributes(THD *thd, const char *name, Type_handler_hybrid_field_type *h, Type_all_attributes *attr, - Item **items, uint nitems) const; - bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const; - bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const; - bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const; + Item **items, uint nitems) const + override; + bool Item_sum_sum_fix_length_and_dec(Item_sum_sum *) const override; + bool Item_sum_avg_fix_length_and_dec(Item_sum_avg *) const override; + bool Item_sum_variance_fix_length_and_dec(Item_sum_variance *) const override; - bool Item_func_signed_fix_length_and_dec(Item_func_signed *) const; - bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const; - bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *) const; - bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const; - bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const; - bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const; - bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *) const; - bool Item_date_typecast_fix_length_and_dec(Item_date_typecast *) const; - bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *) const; + bool Item_func_signed_fix_length_and_dec(Item_func_signed *) const override; + bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const + override; + bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *) const + override; + bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const + override; + bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const + override; + bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const + override; + bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *) const + override; + bool Item_date_typecast_fix_length_and_dec(Item_date_typecast *) const + override; + bool Item_datetime_typecast_fix_length_and_dec(Item_datetime_typecast *) const + override; }; @@ -6524,8 +6547,8 @@ class Type_handler_point: public Type_handler_geometry // Binary length of a POINT value: 4 byte SRID + 21 byte WKB POINT static uint octet_length() { return 25; } public: - geometry_types geometry_type() const { return GEOM_POINT; } - const Name name() const { return m_name_point; } + geometry_types geometry_type() const override { return GEOM_POINT; } + const Name name() const override { return m_name_point; } bool Key_part_spec_init_primary(Key_part_spec *part, const Column_definition &def, const handler *file) const override;