The value for BIT fields in the statistical fields are stored as strings.
To get the value from the statistical field we enter the function
Field_varstring::val_str
(lldb) p val.ptr()
(constchar *) $5 = 0x000061e000031b6d "80"
(lldb) p val.length()
(uint32) $6 = 2
So the statistical field has value 80, stored in string representation
In the function Field_bit::store we have:
(lldb) p ptr[6]
(uchar) $18 = '8'
(lldb) p ptr[7]
(uchar) $19 = '0'
So the value 80 is stored as 2 bytes in the byte field which is not correct,
the value used was 80 so that can fit it one byte itself.
For BIT fields while getting the values from the statistical fields we should
get the integral value from the text representation.
This would make it consistent with the values being stored into the stat tables
and retrieving the values from the stat tables.
Varun Gupta (Inactive)
added a comment - The value for BIT fields in the statistical fields are stored as strings.
To get the value from the statistical field we enter the function
Field_varstring::val_str
(lldb) p val.ptr()
( const char *) $5 = 0x000061e000031b6d "80"
(lldb) p val.length()
(uint32) $6 = 2
So the statistical field has value 80, stored in string representation
In the function Field_bit::store we have:
(lldb) p ptr[6]
(uchar) $18 = '8'
(lldb) p ptr[7]
(uchar) $19 = '0'
So the value 80 is stored as 2 bytes in the byte field which is not correct,
the value used was 80 so that can fit it one byte itself.
For BIT fields while getting the values from the statistical fields we should
get the integral value from the text representation.
This would make it consistent with the values being stored into the stat tables
and retrieving the values from the stat tables.
I have created a new patch where Varun's idea us used, but done with virtual functions instead of 'if (field_type == Field_bit).
If Varun accepts this, it's ok to push. However, please fix commit message so that the first row is not split into two rows. Better to have the full MDEV message on the first row
Michael Widenius
added a comment - I have created a new patch where Varun's idea us used, but done with virtual functions instead of 'if (field_type == Field_bit).
If Varun accepts this, it's ok to push. However, please fix commit message so that the first row is not split into two rows. Better to have the full MDEV message on the first row
The reason bit fields are different is that they are basically a string type but used by statistics as a numerical type.
The fix in my patch handles that by creating a specialized Field_bit version of
Field_bit::store_to_statistical_minmax_field(Field *field, String *val)
int Field_bit::store_from_statistical_minmax_field(Field *stat_field, String *str)
that takes care of this.
Michael Widenius
added a comment - The reason bit fields are different is that they are basically a string type but used by statistics as a numerical type.
The fix in my patch handles that by creating a specialized Field_bit version of
Field_bit::store_to_statistical_minmax_field(Field *field, String *val)
int Field_bit::store_from_statistical_minmax_field(Field *stat_field, String *str)
that takes care of this.
Have pushed my patch to 10.2. Will use monty patch for 10.5 as there will be conflicts when this code is merged upwards.
Varun Gupta (Inactive)
added a comment - Have pushed my patch to 10.2. Will use monty patch for 10.5 as there will be conflicts when this code is merged upwards.
The value for BIT fields in the statistical fields are stored as strings.
To get the value from the statistical field we enter the function
Field_varstring::val_str
(lldb) p val.ptr()
(lldb) p val.length()
(uint32) $6 = 2
So the statistical field has value 80, stored in string representation
In the function Field_bit::store we have:
(lldb) p ptr[6]
(lldb) p ptr[7]
So the value 80 is stored as 2 bytes in the byte field which is not correct,
the value used was 80 so that can fit it one byte itself.
For BIT fields while getting the values from the statistical fields we should
get the integral value from the text representation.
This would make it consistent with the values being stored into the stat tables
and retrieving the values from the stat tables.