1407
class Field_blob :public Field_longstr {
1410
String value; // For temporaries
1412
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
1413
enum utype unireg_check_arg, const char *field_name_arg,
1414
TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
1415
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
1417
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1418
NONE, field_name_arg, cs),
1423
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
1424
CHARSET_INFO *cs, bool set_packlength)
1425
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
1426
NONE, field_name_arg, cs)
1432
uint32 l_char_length= len_arg/cs->mbmaxlen;
1433
packlength= l_char_length <= 255 ? 1 :
1434
l_char_length <= 65535 ? 2 :
1435
l_char_length <= 16777215 ? 3 : 4;
1438
Field_blob(uint32 packlength_arg)
1439
:Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
1440
packlength(packlength_arg) {}
1441
enum_field_types type() const { return MYSQL_TYPE_BLOB;}
1442
enum ha_base_keytype key_type() const
1443
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
1444
int store(const char *to,uint length,CHARSET_INFO *charset);
1445
int store(double nr);
1446
int store(int64_t nr, bool unsigned_val);
1447
double val_real(void);
1448
int64_t val_int(void);
1449
String *val_str(String*,String *);
1450
my_decimal *val_decimal(my_decimal *);
1451
int cmp_max(const uchar *, const uchar *, uint max_length);
1452
int cmp(const uchar *a,const uchar *b)
1453
{ return cmp_max(a, b, ~0L); }
1454
int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length);
1455
int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
1456
int key_cmp(const uchar *,const uchar*);
1457
int key_cmp(const uchar *str, uint length);
1458
uint32 key_length() const { return 0; }
1459
void sort_string(uchar *buff,uint length);
1460
uint32 pack_length() const
1461
{ return (uint32) (packlength+table->s->blob_ptr_size); }
1464
Return the packed length without the pointer size added.
1466
This is used to determine the size of the actual data in the row
1469
@returns The length of the raw data itself without the pointer.
1471
uint32 pack_length_no_ptr() const
1472
{ return (uint32) (packlength); }
1473
uint row_pack_length() { return pack_length_no_ptr(); }
1474
uint32 sort_length() const;
1475
virtual uint32 max_data_length() const
1477
return (uint32) (((uint64_t) 1 << (packlength*8)) -1);
1479
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
1480
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
1481
#ifndef WORDS_BIGENDIAN
1484
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number, bool low_byte_first);
1485
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
1487
store_length(i_ptr, i_packlength, i_number, table->s->db_low_byte_first);
1489
inline void store_length(uint32 number)
1491
store_length(ptr, packlength, number);
1495
Return the packed length plus the length of the data.
1497
This is used to determine the size of the data plus the
1498
packed length portion in the row data.
1500
@returns The length in the row plus the size of the data.
1502
uint32 get_packed_size(const uchar *ptr_arg, bool low_byte_first)
1503
{return packlength + get_length(ptr_arg, packlength, low_byte_first);}
1505
inline uint32 get_length(uint row_offset= 0)
1506
{ return get_length(ptr+row_offset, this->packlength, table->s->db_low_byte_first); }
1507
uint32 get_length(const uchar *ptr, uint packlength, bool low_byte_first);
1508
uint32 get_length(const uchar *ptr_arg)
1509
{ return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
1510
void put_length(uchar *pos, uint32 length);
1511
inline void get_ptr(uchar **str)
1513
memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));
1515
inline void get_ptr(uchar **str, uint row_offset)
1517
memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*));
1519
inline void set_ptr(uchar *length, uchar *data)
1521
memcpy(ptr,length,packlength);
1522
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
1524
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data)
1526
uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*);
1527
store_length(ptr_ofs, packlength, length);
1528
memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*));
1530
inline void set_ptr(uint32 length, uchar *data)
1532
set_ptr_offset(0, length, data);
1534
uint get_key_image(uchar *buff,uint length, imagetype type);
1535
void set_key_image(const uchar *buff,uint length);
1536
void sql_type(String &str) const;
1541
if (value.copy((char*) tmp, get_length(), charset()))
1543
Field_blob::reset();
1546
tmp=(uchar*) value.ptr();
1547
memcpy_fixed(ptr+packlength,&tmp,sizeof(char*));
1550
virtual uchar *pack(uchar *to, const uchar *from,
1551
uint max_length, bool low_byte_first);
1552
uchar *pack_key(uchar *to, const uchar *from,
1553
uint max_length, bool low_byte_first);
1554
uchar *pack_key_from_key_image(uchar* to, const uchar *from,
1555
uint max_length, bool low_byte_first);
1556
virtual const uchar *unpack(uchar *to, const uchar *from,
1557
uint param_data, bool low_byte_first);
1558
const uchar *unpack_key(uchar* to, const uchar *from,
1559
uint max_length, bool low_byte_first);
1560
int pack_cmp(const uchar *a, const uchar *b, uint key_length,
1561
my_bool insert_or_update);
1562
int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update);
1563
uint packed_col_length(const uchar *col_ptr, uint length);
1564
uint max_packed_col_length(uint max_length);
1565
void free() { value.free(); }
1566
inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); }
1567
friend int field_conv(Field *to,Field *from);
1568
uint size_of() const { return sizeof(*this); }
1569
bool has_charset(void) const
1570
{ return charset() == &my_charset_bin ? false : true; }
1571
uint32 max_display_length();
1572
uint is_equal(Create_field *new_field);
1573
inline bool in_read_set() { return bitmap_is_set(table->read_set, field_index); }
1574
inline bool in_write_set() { return bitmap_is_set(table->write_set, field_index); }
1576
int do_save_field_metadata(uchar *first_byte);
1580
1407
class Field_enum :public Field_str {
1582
1409
uint packlength;