@@ -9703,17 +9703,9 @@ bool Field::is_part_of_actual_key(THD *thd, uint cur_index,
9703
9703
9704
9704
Field_typed_array::Field_typed_array (const Field_typed_array &other)
9705
9705
: Field_json(other),
9706
- m_conv_field(other.m_conv_field),
9707
9706
m_elt_type(other.m_elt_type),
9708
9707
m_elt_decimals(other.m_elt_decimals),
9709
- m_elt_charset(other.m_elt_charset) {
9710
- /*
9711
- When conv_field is null the field is cloned from share and isn't
9712
- attached to any table yet (this will happen later).
9713
- */
9714
- // DBUG_ASSERT(!m_conv_field);
9715
- m_conv_field = nullptr ;
9716
- }
9708
+ m_elt_charset(other.m_elt_charset) {}
9717
9709
9718
9710
Field_typed_array::Field_typed_array (
9719
9711
enum_field_types elt_type, bool elt_is_unsigned, size_t elt_length,
@@ -9722,7 +9714,6 @@ Field_typed_array::Field_typed_array(
9722
9714
uint blob_pack_length, const CHARSET_INFO *cs)
9723
9715
: Field_json(ptr_arg, null_ptr_arg, null_bit_arg, auto_flags_arg,
9724
9716
field_name_arg, share, blob_pack_length),
9725
- m_conv_field(nullptr ),
9726
9717
m_elt_type(elt_type),
9727
9718
m_elt_decimals(elt_decimals),
9728
9719
m_elt_charset(cs) {
@@ -9892,7 +9883,6 @@ type_conversion_status Field_typed_array::store_array(const Json_wrapper *data,
9892
9883
}
9893
9884
9894
9885
void Field_typed_array::init (TABLE *table_arg) {
9895
- uint fld_length = field_length;
9896
9886
Field::init (table_arg);
9897
9887
9898
9888
switch (type ()) {
@@ -9908,22 +9898,22 @@ void Field_typed_array::init(TABLE *table_arg) {
9908
9898
default :
9909
9899
// Shouldn't happen
9910
9900
DBUG_ASSERT (0 ); /* purecov: inspected */
9911
-
9912
9901
return ;
9913
9902
}
9903
+
9914
9904
// Create field for data conversion
9915
9905
m_conv_field = ::make_field (
9916
9906
// Allocate conversion field in table's mem_root
9917
9907
&table_arg->mem_root ,
9918
- nullptr , // TABLE_SHARE, not needed
9919
- nullptr , // data buffer, isn't allocated yet
9920
- fld_length, // field_length
9921
- &null_byte , 0 , // null_pos, nul_bit
9922
- real_type (), // field_type
9908
+ nullptr , // TABLE_SHARE, not needed
9909
+ nullptr , // data buffer, isn't allocated yet
9910
+ field_length, // field_length
9911
+ nullptr , 0 , // null_pos, nul_bit
9912
+ real_type (), // field_type
9923
9913
m_elt_charset,
9924
9914
Field::GEOM_GEOMETRY, // geom type
9925
9915
Field::NONE, // auto_flags
9926
- nullptr , // itervals aren't supported in array
9916
+ nullptr , // intervals aren't supported in array
9927
9917
field_name, is_nullable (),
9928
9918
false , // zerofill is meaningless with JSON
9929
9919
unsigned_flag, m_elt_decimals,
@@ -9932,27 +9922,27 @@ void Field_typed_array::init(TABLE *table_arg) {
9932
9922
{}, // srid
9933
9923
false // is_array
9934
9924
);
9935
- if (! m_conv_field ||
9936
- !(m_conv_buf = static_cast < uchar *>(
9937
- table_arg->mem_root .Alloc (m_conv_field->pack_length ()))))
9938
- return ; /* purecov: inspected */
9925
+ if (m_conv_field == nullptr ) return ;
9926
+ uchar *buf =
9927
+ table_arg->mem_root .ArrayAlloc <uchar> (m_conv_field->pack_length () + 1 );
9928
+ if (buf == nullptr ) return ;
9939
9929
if (type () == MYSQL_TYPE_NEWDECIMAL)
9940
9930
(down_cast<Field_new_decimal *>(m_conv_field))->set_keep_precision (true );
9941
- m_conv_field->move_field (m_conv_buf );
9931
+ m_conv_field->move_field (buf + 1 , buf, 0 );
9942
9932
// Allow conv_field to use table->in_use
9943
9933
m_conv_field->table = table;
9944
9934
m_conv_field->field_index = field_index;
9945
9935
m_conv_field->table_name = table_name;
9946
9936
}
9947
9937
9948
- const char *Field_typed_array::get_index_name () {
9938
+ const char *Field_typed_array::get_index_name () const {
9949
9939
uint key = part_of_key.get_first_set ();
9950
9940
DBUG_ASSERT (key != MY_BIT_NONE);
9951
9941
return table->s ->key_info [key].name ;
9952
9942
}
9953
9943
9954
9944
size_t Field_typed_array::make_sort_key (Json_wrapper *wr, uchar *to,
9955
- size_t length) {
9945
+ size_t length) const {
9956
9946
#ifndef DBUG_OFF
9957
9947
switch (wr->type ()) {
9958
9948
case enum_json_type::J_ERROR:
0 commit comments