@@ -1463,8 +1463,11 @@ class Field: public Value_source
1463
1463
if (null_ptr)
1464
1464
null_ptr=ADD_TO_PTR (null_ptr,ptr_diff,uchar*);
1465
1465
}
1466
- virtual void get_image (uchar *buff, uint length, CHARSET_INFO *cs)
1467
- { memcpy (buff,ptr,length); }
1466
+ void get_image (uchar *buff, uint length, CHARSET_INFO *cs) const
1467
+ { get_image (buff, length, ptr, cs); }
1468
+ virtual void get_image (uchar *buff, uint length,
1469
+ const uchar *ptr_arg, CHARSET_INFO *cs) const
1470
+ { memcpy (buff,ptr_arg,length); }
1468
1471
virtual void set_image (const uchar *buff,uint length, CHARSET_INFO *cs)
1469
1472
{ memcpy (ptr,buff,length); }
1470
1473
@@ -1495,9 +1498,11 @@ class Field: public Value_source
1495
1498
Number of copied bytes (excluding padded zero bytes -- see above).
1496
1499
*/
1497
1500
1498
- virtual uint get_key_image (uchar *buff, uint length, imagetype type_arg)
1501
+ uint get_key_image (uchar *buff, uint length, imagetype type_arg) const
1502
+ { return get_key_image (buff, length, ptr, type_arg); }
1503
+ virtual uint get_key_image (uchar *buff, uint length, const uchar *ptr_arg, imagetype type_arg) const
1499
1504
{
1500
- get_image (buff, length, &my_charset_bin);
1505
+ get_image (buff, length, ptr_arg, &my_charset_bin);
1501
1506
return length;
1502
1507
}
1503
1508
virtual void set_key_image (const uchar *buff,uint length)
@@ -3993,7 +3998,8 @@ class Field_string :public Field_longstr {
3993
3998
bool has_charset () const override { return charset () != &my_charset_bin; }
3994
3999
Field *make_new_field (MEM_ROOT *root, TABLE *new_table, bool keep_type)
3995
4000
override ;
3996
- uint get_key_image (uchar *buff,uint length, imagetype type) override ;
4001
+ uint get_key_image (uchar *buff, uint length,
4002
+ const uchar *ptr_arg, imagetype type) const override ;
3997
4003
sql_mode_t value_depends_on_sql_mode () const override ;
3998
4004
sql_mode_t can_handle_sql_mode_dependency_on_store () const override ;
3999
4005
void print_key_value (String *out, uint32 length) override ;
@@ -4003,13 +4009,21 @@ class Field_string :public Field_longstr {
4003
4009
4004
4010
class Field_varstring :public Field_longstr {
4005
4011
public:
4006
- uchar *get_data () const
4012
+ const uchar *get_data () const
4007
4013
{
4008
- return ptr + length_bytes;
4014
+ return get_data (ptr);
4015
+ }
4016
+ const uchar *get_data (const uchar *ptr_arg) const
4017
+ {
4018
+ return ptr_arg + length_bytes;
4009
4019
}
4010
4020
uint get_length () const
4011
4021
{
4012
- return length_bytes == 1 ? (uint) *ptr : uint2korr (ptr);
4022
+ return get_length (ptr);
4023
+ }
4024
+ uint get_length (const uchar *ptr_arg) const
4025
+ {
4026
+ return length_bytes == 1 ? (uint) *ptr_arg : uint2korr (ptr_arg);
4013
4027
}
4014
4028
protected:
4015
4029
void store_length (uint32 number)
@@ -4019,6 +4033,7 @@ class Field_varstring :public Field_longstr {
4019
4033
else
4020
4034
int2store (ptr, number);
4021
4035
}
4036
+ virtual void val_str_from_ptr (String *val, const uchar *ptr) const ;
4022
4037
public:
4023
4038
/*
4024
4039
The maximum space available in a Field_varstring, in bytes. See
@@ -4090,7 +4105,8 @@ class Field_varstring :public Field_longstr {
4090
4105
return cmp_max (a, b, ~0U );
4091
4106
}
4092
4107
void sort_string (uchar *buff,uint length) override ;
4093
- uint get_key_image (uchar *buff,uint length, imagetype type) override ;
4108
+ uint get_key_image (uchar *buff, uint length,
4109
+ const uchar *ptr_arg, imagetype type) const override ;
4094
4110
void set_key_image (const uchar *buff,uint length) override ;
4095
4111
void sql_type (String &str) const override ;
4096
4112
void sql_rpl_type (String*) const override ;
@@ -4142,6 +4158,7 @@ class Field_varstring_compressed: public Field_varstring {
4142
4158
{ return compression_method_ptr; }
4143
4159
private:
4144
4160
Compression_method *compression_method_ptr;
4161
+ void val_str_from_ptr (String *val, const uchar *ptr) const override ;
4145
4162
int store (const char *to, size_t length, CHARSET_INFO *charset) override ;
4146
4163
using Field_str::store;
4147
4164
String *val_str (String *, String *) override ;
@@ -4260,7 +4277,7 @@ class Field_blob :public Field_longstr {
4260
4277
4261
4278
static void do_copy_blob (Copy_field *copy);
4262
4279
static void do_conv_blob (Copy_field *copy);
4263
- uint get_key_image_itRAW (uchar *buff, uint length);
4280
+ uint get_key_image_itRAW (const uchar *ptr_arg, uchar * buff, uint length) const ;
4264
4281
public:
4265
4282
Field_blob (uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
4266
4283
enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
@@ -4427,11 +4444,11 @@ class Field_blob :public Field_longstr {
4427
4444
uint32 get_length (const uchar *ptr, uint packlength) const ;
4428
4445
uint32 get_length (const uchar *ptr_arg) const
4429
4446
{ return get_length (ptr_arg, this ->packlength ); }
4430
- inline uchar *get_ptr () const { return get_ptr (0 ); }
4431
- inline uchar *get_ptr (my_ptrdiff_t row_offset ) const
4447
+ inline uchar *get_ptr () const { return get_ptr (ptr ); }
4448
+ inline uchar *get_ptr (const uchar *ptr_arg ) const
4432
4449
{
4433
4450
uchar *s;
4434
- memcpy (&s, ptr + packlength + row_offset , sizeof (uchar*));
4451
+ memcpy (&s, ptr_arg + packlength, sizeof (uchar*));
4435
4452
return s;
4436
4453
}
4437
4454
inline void set_ptr (uchar *length, uchar *data)
@@ -4450,10 +4467,11 @@ class Field_blob :public Field_longstr {
4450
4467
set_ptr_offset (0 , length, data);
4451
4468
}
4452
4469
int copy_value (Field_blob *from);
4453
- uint get_key_image (uchar *buff, uint length, imagetype type) override
4470
+ uint get_key_image (uchar *buff, uint length,
4471
+ const uchar *ptr_arg, imagetype type) const override
4454
4472
{
4455
4473
DBUG_ASSERT (type == itRAW);
4456
- return get_key_image_itRAW (buff, length);
4474
+ return get_key_image_itRAW (ptr_arg, buff, length);
4457
4475
}
4458
4476
void set_key_image (const uchar *buff,uint length) override ;
4459
4477
Field *new_key_field (MEM_ROOT *root, TABLE *new_table,
@@ -4559,7 +4577,8 @@ class Field_blob_compressed: public Field_blob {
4559
4577
compression methods or compression levels.
4560
4578
*/
4561
4579
4562
- uint get_key_image (uchar *, uint, imagetype) override
4580
+ uint get_key_image (uchar *buff, uint length,
4581
+ const uchar *ptr_arg, imagetype type_arg) const override
4563
4582
{ DBUG_ASSERT (0 ); return 0 ; }
4564
4583
void set_key_image (const uchar *, uint) override
4565
4584
{ DBUG_ASSERT (0 ); }
@@ -4846,15 +4865,17 @@ class Field_bit :public Field {
4846
4865
{
4847
4866
return pos_in_interval_val_real (min, max);
4848
4867
}
4849
- void get_image (uchar *buff, uint length, CHARSET_INFO *) override
4850
- { get_key_image (buff, length, itRAW); }
4868
+ void get_image (uchar *buff, uint length,
4869
+ const uchar *ptr_arg, CHARSET_INFO *cs) const override
4870
+ { get_key_image (buff, length, ptr_arg, itRAW); }
4851
4871
void set_image (const uchar *buff,uint length, CHARSET_INFO *cs) override
4852
4872
{ Field_bit::store ((char *) buff, length, cs); }
4853
- uint get_key_image (uchar *buff, uint length, imagetype type) override ;
4873
+ uint get_key_image (uchar *buff, uint length,
4874
+ const uchar *ptr_arg, imagetype type) const override ;
4854
4875
void set_key_image (const uchar *buff, uint length) override
4855
4876
{ Field_bit::store ((char *) buff, length, &my_charset_bin); }
4856
4877
void sort_string (uchar *buff, uint length) override
4857
- { get_key_image (buff, length, itRAW); }
4878
+ { get_key_image (buff, length, ptr, itRAW); }
4858
4879
uint32 pack_length () const override
4859
4880
{ return (uint32) (field_length + 7 ) / 8 ; }
4860
4881
uint32 pack_length_in_rec () const override { return bytes_in_rec; }
0 commit comments