diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-06-07 06:43:14 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-06-07 06:43:14 +0400 |
commit | 9d6d37b5d0ec1e6f1e37b904704c18baab1f8ac5 (patch) | |
tree | 280555d93daad87e73a7387dd5ae65a15e0a4298 | |
parent | bf70430ead122649fd22f0d4c52f49451569d6c3 (diff) | |
download | mariadb-git-9d6d37b5d0ec1e6f1e37b904704c18baab1f8ac5.tar.gz |
Cleanup: adding "const" qualifiers to methods in Field
- Field::compatible_field_size(), and its "Relay_log_info *rli" argument
- Field::pack_length_from_metadata
-rw-r--r-- | sql/field.cc | 22 | ||||
-rw-r--r-- | sql/field.h | 35 |
2 files changed, 29 insertions, 28 deletions
diff --git a/sql/field.cc b/sql/field.cc index 92c3f997186..2c35a48e81f 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1824,9 +1824,9 @@ bool Field::send_binary(Protocol *protocol) master's field size, @c false otherwise. */ bool Field::compatible_field_size(uint field_metadata, - Relay_log_info *rli_arg __attribute__((unused)), + const Relay_log_info *rli_arg __attribute__((unused)), uint16 mflags __attribute__((unused)), - int *order_var) + int *order_var) const { uint const source_size= pack_length_from_metadata(field_metadata); uint const destination_size= row_pack_length(); @@ -3469,7 +3469,7 @@ int Field_new_decimal::save_field_metadata(uchar *metadata_ptr) @returns The size of the field based on the field metadata. */ -uint Field_new_decimal::pack_length_from_metadata(uint field_metadata) +uint Field_new_decimal::pack_length_from_metadata(uint field_metadata) const { uint const source_precision= (field_metadata >> 8U) & 0x00ff; uint const source_decimal= field_metadata & 0x00ff; @@ -3480,9 +3480,9 @@ uint Field_new_decimal::pack_length_from_metadata(uint field_metadata) bool Field_new_decimal::compatible_field_size(uint field_metadata, - Relay_log_info * __attribute__((unused)), + const Relay_log_info * __attribute__((unused)), uint16 mflags __attribute__((unused)), - int *order_var) + int *order_var) const { uint const source_precision= (field_metadata >> 8U) & 0x00ff; uint const source_decimal= field_metadata & 0x00ff; @@ -7247,7 +7247,7 @@ my_decimal *Field_string::val_decimal(my_decimal *decimal_value) struct Check_field_param { - Field *field; + const Field *field; }; #ifdef HAVE_REPLICATION @@ -7266,9 +7266,9 @@ check_field_for_37426(const void *param_arg) bool Field_string::compatible_field_size(uint field_metadata, - Relay_log_info *rli_arg, + const Relay_log_info *rli_arg, uint16 mflags __attribute__((unused)), - int *order_var) + int *order_var) const { #ifdef HAVE_REPLICATION const Check_field_param check_param = { this }; @@ -9991,7 +9991,7 @@ int Field_bit::save_field_metadata(uchar *metadata_ptr) @returns The size of the field based on the field metadata. */ -uint Field_bit::pack_length_from_metadata(uint field_metadata) +uint Field_bit::pack_length_from_metadata(uint field_metadata) const { uint const from_len= (field_metadata >> 8U) & 0x00ff; uint const from_bit_len= field_metadata & 0x00ff; @@ -10002,9 +10002,9 @@ uint Field_bit::pack_length_from_metadata(uint field_metadata) bool Field_bit::compatible_field_size(uint field_metadata, - Relay_log_info * __attribute__((unused)), + const Relay_log_info * __attribute__((unused)), uint16 mflags, - int *order_var) + int *order_var) const { DBUG_ENTER("Field_bit::compatible_field_size"); DBUG_ASSERT((field_metadata >> 16) == 0); diff --git a/sql/field.h b/sql/field.h index 77cf5f972cd..66f911778ea 100644 --- a/sql/field.h +++ b/sql/field.h @@ -910,9 +910,9 @@ public: table, which is located on disk). */ virtual uint32 pack_length_in_rec() const { return pack_length(); } - virtual bool compatible_field_size(uint metadata, Relay_log_info *rli, - uint16 mflags, int *order); - virtual uint pack_length_from_metadata(uint field_metadata) + virtual bool compatible_field_size(uint metadata, const Relay_log_info *rli, + uint16 mflags, int *order) const; + virtual uint pack_length_from_metadata(uint field_metadata) const { DBUG_ENTER("Field::pack_length_from_metadata"); DBUG_RETURN(field_metadata); @@ -1813,7 +1813,8 @@ public: } uint is_equal(Create_field *new_field); uint row_pack_length() const { return pack_length(); } - uint32 pack_length_from_metadata(uint field_metadata) { + uint32 pack_length_from_metadata(uint field_metadata) const + { uint32 length= pack_length(); DBUG_PRINT("result", ("pack_length_from_metadata(%d): %u", field_metadata, length)); @@ -2139,10 +2140,10 @@ public: } uint size_of() const { return sizeof(*this); } uint32 pack_length() const { return (uint32) bin_size; } - uint pack_length_from_metadata(uint field_metadata); + uint pack_length_from_metadata(uint field_metadata) const; uint row_pack_length() const { return pack_length(); } - bool compatible_field_size(uint field_metadata, Relay_log_info *rli, - uint16 mflags, int *order_var); + bool compatible_field_size(uint field_metadata, const Relay_log_info *rli, + uint16 mflags, int *order_var) const; uint is_equal(Create_field *new_field); virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data); Item *get_equal_const_item(THD *thd, const Context &ctx, Item *const_item); @@ -2971,7 +2972,7 @@ public: return my_timestamp_binary_length(dec); } uint row_pack_length() const { return pack_length(); } - uint pack_length_from_metadata(uint field_metadata) + uint pack_length_from_metadata(uint field_metadata) const { DBUG_ENTER("Field_timestampf::pack_length_from_metadata"); uint tmp= my_timestamp_binary_length(field_metadata); @@ -3284,7 +3285,7 @@ public: return my_time_binary_length(dec); } uint row_pack_length() const { return pack_length(); } - uint pack_length_from_metadata(uint field_metadata) + uint pack_length_from_metadata(uint field_metadata) const { DBUG_ENTER("Field_timef::pack_length_from_metadata"); uint tmp= my_time_binary_length(field_metadata); @@ -3451,7 +3452,7 @@ public: return my_datetime_binary_length(dec); } uint row_pack_length() const { return pack_length(); } - uint pack_length_from_metadata(uint field_metadata) + uint pack_length_from_metadata(uint field_metadata) const { DBUG_ENTER("Field_datetimef::pack_length_from_metadata"); uint tmp= my_datetime_binary_length(field_metadata); @@ -3581,15 +3582,15 @@ public: uint max_length); virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end,uint param_data); - uint pack_length_from_metadata(uint field_metadata) + uint pack_length_from_metadata(uint field_metadata) const { DBUG_PRINT("debug", ("field_metadata: 0x%04x", field_metadata)); if (field_metadata == 0) return row_pack_length(); return (((field_metadata >> 4) & 0x300) ^ 0x300) + (field_metadata & 0x00ff); } - bool compatible_field_size(uint field_metadata, Relay_log_info *rli, - uint16 mflags, int *order_var); + bool compatible_field_size(uint field_metadata, const Relay_log_info *rli, + uint16 mflags, int *order_var) const; uint row_pack_length() const { return field_length; } int pack_cmp(const uchar *a,const uchar *b,uint key_length, bool insert_or_update); @@ -4260,7 +4261,7 @@ public: void store_type(ulonglong value); void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } - uint pack_length_from_metadata(uint field_metadata) + uint pack_length_from_metadata(uint field_metadata) const { return (field_metadata & 0x00ff); } uint row_pack_length() const { return pack_length(); } virtual bool zero_pack() const { return 0; } @@ -4454,11 +4455,11 @@ public: { get_key_image(buff, length, itRAW); } uint32 pack_length() const { return (uint32) (field_length + 7) / 8; } uint32 pack_length_in_rec() const { return bytes_in_rec; } - uint pack_length_from_metadata(uint field_metadata); + uint pack_length_from_metadata(uint field_metadata) const; uint row_pack_length() const { return (bytes_in_rec + ((bit_len > 0) ? 1 : 0)); } - bool compatible_field_size(uint metadata, Relay_log_info *rli, - uint16 mflags, int *order_var); + bool compatible_field_size(uint metadata, const Relay_log_info *rli, + uint16 mflags, int *order_var) const; void sql_type(String &str) const; virtual uchar *pack(uchar *to, const uchar *from, uint max_length); virtual const uchar *unpack(uchar *to, const uchar *from, |