mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge
This commit is contained in:
240
sql/field.h
240
sql/field.h
@ -37,11 +37,7 @@ class Field
|
|||||||
void operator=(Field &);
|
void operator=(Field &);
|
||||||
public:
|
public:
|
||||||
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
|
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
|
||||||
static void operator delete(void *ptr_arg, size_t size) {
|
static void operator delete(void *ptr_arg, size_t size) { TRASH(ptr_arg, size); }
|
||||||
#ifdef SAFEMALLOC
|
|
||||||
bfill(ptr_arg, size, 0x8F);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ptr; // Position to field in record
|
char *ptr; // Position to field in record
|
||||||
uchar *null_ptr; // Byte where null_bit is
|
uchar *null_ptr; // Byte where null_bit is
|
||||||
@ -51,7 +47,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
struct st_table *table; // Pointer for table
|
struct st_table *table; // Pointer for table
|
||||||
struct st_table *orig_table; // Pointer to original table
|
struct st_table *orig_table; // Pointer to original table
|
||||||
const char *table_name,*field_name;
|
const char **table_name, *field_name;
|
||||||
LEX_STRING comment;
|
LEX_STRING comment;
|
||||||
ulong query_id; // For quick test of used fields
|
ulong query_id; // For quick test of used fields
|
||||||
/* Field is part of the following keys */
|
/* Field is part of the following keys */
|
||||||
@ -84,7 +80,7 @@ public:
|
|||||||
FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE,
|
FIELD_CAST_TIMESTAMP, FIELD_CAST_YEAR, FIELD_CAST_DATE, FIELD_CAST_NEWDATE,
|
||||||
FIELD_CAST_TIME, FIELD_CAST_DATETIME,
|
FIELD_CAST_TIME, FIELD_CAST_DATETIME,
|
||||||
FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB,
|
FIELD_CAST_STRING, FIELD_CAST_VARSTRING, FIELD_CAST_BLOB,
|
||||||
FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET
|
FIELD_CAST_GEOM, FIELD_CAST_ENUM, FIELD_CAST_SET, FIELD_CAST_BIT
|
||||||
};
|
};
|
||||||
|
|
||||||
utype unireg_check;
|
utype unireg_check;
|
||||||
@ -100,7 +96,7 @@ public:
|
|||||||
virtual int store(const char *to,uint length,CHARSET_INFO *cs)=0;
|
virtual int store(const char *to,uint length,CHARSET_INFO *cs)=0;
|
||||||
virtual int store(double nr)=0;
|
virtual int store(double nr)=0;
|
||||||
virtual int store(longlong nr)=0;
|
virtual int store(longlong nr)=0;
|
||||||
virtual void store_time(TIME *ltime,timestamp_type t_type);
|
virtual int store_time(TIME *ltime, timestamp_type t_type);
|
||||||
virtual double val_real(void)=0;
|
virtual double val_real(void)=0;
|
||||||
virtual longlong val_int(void)=0;
|
virtual longlong val_int(void)=0;
|
||||||
inline String *val_str(String *str) { return val_str(str, str); }
|
inline String *val_str(String *str) { return val_str(str, str); }
|
||||||
@ -117,16 +113,22 @@ public:
|
|||||||
This trickery is used to decrease a number of malloc calls.
|
This trickery is used to decrease a number of malloc calls.
|
||||||
*/
|
*/
|
||||||
virtual String *val_str(String*,String *)=0;
|
virtual String *val_str(String*,String *)=0;
|
||||||
|
String *val_int_as_str(String *val_buffer, my_bool unsigned_flag);
|
||||||
virtual Item_result result_type () const=0;
|
virtual Item_result result_type () const=0;
|
||||||
virtual Item_result cmp_type () const { return result_type(); }
|
virtual Item_result cmp_type () const { return result_type(); }
|
||||||
bool eq(Field *field) { return ptr == field->ptr && null_ptr == field->null_ptr; }
|
bool eq(Field *field)
|
||||||
|
{
|
||||||
|
return (ptr == field->ptr && null_ptr == field->null_ptr &&
|
||||||
|
null_bit == field->null_bit);
|
||||||
|
}
|
||||||
virtual bool eq_def(Field *field);
|
virtual bool eq_def(Field *field);
|
||||||
virtual uint32 pack_length() const { return (uint32) field_length; }
|
virtual uint32 pack_length() const { return (uint32) field_length; }
|
||||||
|
virtual uint32 pack_length_in_rec() const { return pack_length(); }
|
||||||
virtual void reset(void) { bzero(ptr,pack_length()); }
|
virtual void reset(void) { bzero(ptr,pack_length()); }
|
||||||
virtual void reset_fields() {}
|
virtual void reset_fields() {}
|
||||||
virtual void set_default()
|
virtual void set_default()
|
||||||
{
|
{
|
||||||
my_ptrdiff_t offset = (my_ptrdiff_t) (table->default_values -
|
my_ptrdiff_t offset = (my_ptrdiff_t) (table->s->default_values -
|
||||||
table->record[0]);
|
table->record[0]);
|
||||||
memcpy(ptr, ptr + offset, pack_length());
|
memcpy(ptr, ptr + offset, pack_length());
|
||||||
if (null_ptr)
|
if (null_ptr)
|
||||||
@ -143,10 +145,9 @@ public:
|
|||||||
virtual int cmp(const char *,const char *)=0;
|
virtual int cmp(const char *,const char *)=0;
|
||||||
virtual int cmp_binary(const char *a,const char *b, uint32 max_length=~0L)
|
virtual int cmp_binary(const char *a,const char *b, uint32 max_length=~0L)
|
||||||
{ return memcmp(a,b,pack_length()); }
|
{ return memcmp(a,b,pack_length()); }
|
||||||
virtual int cmp_offset(uint row_offset)
|
int cmp_offset(uint row_offset) { return cmp(ptr,ptr+row_offset); }
|
||||||
{ return memcmp(ptr,ptr+row_offset,pack_length()); }
|
int cmp_binary_offset(uint row_offset)
|
||||||
virtual int cmp_binary_offset(uint row_offset)
|
{ return cmp_binary(ptr, ptr+row_offset); };
|
||||||
{ return memcmp(ptr,ptr+row_offset,pack_length()); }
|
|
||||||
virtual int key_cmp(const byte *a,const byte *b)
|
virtual int key_cmp(const byte *a,const byte *b)
|
||||||
{ return cmp((char*) a,(char*) b); }
|
{ return cmp((char*) a,(char*) b); }
|
||||||
virtual int key_cmp(const byte *str, uint length)
|
virtual int key_cmp(const byte *str, uint length)
|
||||||
@ -176,7 +177,7 @@ public:
|
|||||||
{ if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; }
|
{ if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; }
|
||||||
inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
|
inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
|
||||||
inline bool real_maybe_null(void) { return null_ptr != 0; }
|
inline bool real_maybe_null(void) { return null_ptr != 0; }
|
||||||
virtual void make_field(Send_field *)=0;
|
virtual void make_field(Send_field *);
|
||||||
virtual void sort_string(char *buff,uint length)=0;
|
virtual void sort_string(char *buff,uint length)=0;
|
||||||
virtual bool optimize_range(uint idx, uint part);
|
virtual bool optimize_range(uint idx, uint part);
|
||||||
/*
|
/*
|
||||||
@ -188,28 +189,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool can_be_compared_as_longlong() const { return FALSE; }
|
virtual bool can_be_compared_as_longlong() const { return FALSE; }
|
||||||
virtual void free() {}
|
virtual void free() {}
|
||||||
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
|
virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table);
|
||||||
{
|
virtual Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
|
||||||
Field *tmp= (Field*) memdup_root(root,(char*) this,size_of());
|
char *new_ptr, uchar *new_null_ptr,
|
||||||
if (tmp)
|
uint new_null_bit);
|
||||||
{
|
virtual void move_field(char *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
|
||||||
if (tmp->table->maybe_null)
|
|
||||||
tmp->flags&= ~NOT_NULL_FLAG;
|
|
||||||
tmp->table= new_table;
|
|
||||||
tmp->key_start.init(0);
|
|
||||||
tmp->part_of_key.init(0);
|
|
||||||
tmp->part_of_sortkey.init(0);
|
|
||||||
tmp->unireg_check=Field::NONE;
|
|
||||||
tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
|
|
||||||
ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG);
|
|
||||||
#ifdef PROBABLY_WRONG
|
|
||||||
tmp->table_name= new_table->table_name;
|
|
||||||
#endif
|
|
||||||
tmp->reset_fields();
|
|
||||||
}
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
inline void move_field(char *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
|
|
||||||
{
|
{
|
||||||
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
|
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
|
||||||
}
|
}
|
||||||
@ -224,11 +208,10 @@ public:
|
|||||||
{ memcpy(buff,ptr,length); }
|
{ memcpy(buff,ptr,length); }
|
||||||
inline void set_image(char *buff,uint length, CHARSET_INFO *cs)
|
inline void set_image(char *buff,uint length, CHARSET_INFO *cs)
|
||||||
{ memcpy(ptr,buff,length); }
|
{ memcpy(ptr,buff,length); }
|
||||||
virtual void get_key_image(char *buff,uint length, CHARSET_INFO *cs,
|
virtual void get_key_image(char *buff, uint length, imagetype type)
|
||||||
imagetype type)
|
{ get_image(buff,length, &my_charset_bin); }
|
||||||
{ get_image(buff,length,cs); }
|
virtual void set_key_image(char *buff,uint length)
|
||||||
virtual void set_key_image(char *buff,uint length, CHARSET_INFO *cs)
|
{ set_image(buff,length, &my_charset_bin); }
|
||||||
{ set_image(buff,length,cs); }
|
|
||||||
inline longlong val_int_offset(uint row_offset)
|
inline longlong val_int_offset(uint row_offset)
|
||||||
{
|
{
|
||||||
ptr+=row_offset;
|
ptr+=row_offset;
|
||||||
@ -236,6 +219,17 @@ public:
|
|||||||
ptr-=row_offset;
|
ptr-=row_offset;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline String *val_str(String *str, char *new_ptr)
|
||||||
|
{
|
||||||
|
char *old_ptr= ptr;
|
||||||
|
ptr= new_ptr;
|
||||||
|
val_str(str);
|
||||||
|
ptr= old_ptr;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
bool quote_data(String *unquoted_string);
|
||||||
|
bool needs_quotes(void);
|
||||||
virtual bool send_binary(Protocol *protocol);
|
virtual bool send_binary(Protocol *protocol);
|
||||||
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
|
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
|
||||||
{
|
{
|
||||||
@ -267,9 +261,11 @@ public:
|
|||||||
virtual uint max_packed_col_length(uint max_length)
|
virtual uint max_packed_col_length(uint max_length)
|
||||||
{ return max_length;}
|
{ return max_length;}
|
||||||
|
|
||||||
virtual int pack_cmp(const char *a,const char *b, uint key_length_arg)
|
virtual int pack_cmp(const char *a,const char *b, uint key_length_arg,
|
||||||
|
my_bool insert_or_update)
|
||||||
{ return cmp(a,b); }
|
{ return cmp(a,b); }
|
||||||
virtual int pack_cmp(const char *b, uint key_length_arg)
|
virtual int pack_cmp(const char *b, uint key_length_arg,
|
||||||
|
my_bool insert_or_update)
|
||||||
{ return cmp(ptr,b); }
|
{ return cmp(ptr,b); }
|
||||||
uint offset(); // Should be inline ...
|
uint offset(); // Should be inline ...
|
||||||
void copy_from_tmp(int offset);
|
void copy_from_tmp(int offset);
|
||||||
@ -281,6 +277,8 @@ public:
|
|||||||
virtual void set_charset(CHARSET_INFO *charset) { }
|
virtual void set_charset(CHARSET_INFO *charset) { }
|
||||||
bool set_warning(const unsigned int level, const unsigned int code,
|
bool set_warning(const unsigned int level, const unsigned int code,
|
||||||
int cuted_increment);
|
int cuted_increment);
|
||||||
|
bool check_int(const char *str, int length, const char *int_end,
|
||||||
|
CHARSET_INFO *cs);
|
||||||
void set_datetime_warning(const uint level, const uint code,
|
void set_datetime_warning(const uint level, const uint code,
|
||||||
const char *str, uint str_len,
|
const char *str, uint str_len,
|
||||||
timestamp_type ts_type, int cuted_increment);
|
timestamp_type ts_type, int cuted_increment);
|
||||||
@ -360,7 +358,6 @@ public:
|
|||||||
int store(double nr);
|
int store(double nr);
|
||||||
int store(longlong nr)=0;
|
int store(longlong nr)=0;
|
||||||
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
|
int store(const char *to,uint length,CHARSET_INFO *cs)=0;
|
||||||
void make_field(Send_field *);
|
|
||||||
uint size_of() const { return sizeof(*this); }
|
uint size_of() const { return sizeof(*this); }
|
||||||
CHARSET_INFO *charset(void) const { return field_charset; }
|
CHARSET_INFO *charset(void) const { return field_charset; }
|
||||||
void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
|
void set_charset(CHARSET_INFO *charset) { field_charset=charset; }
|
||||||
@ -719,7 +716,7 @@ public:
|
|||||||
if ((*null_value= is_null()))
|
if ((*null_value= is_null()))
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
if (table->db_low_byte_first)
|
if (table->s->db_low_byte_first)
|
||||||
return sint4korr(ptr);
|
return sint4korr(ptr);
|
||||||
#endif
|
#endif
|
||||||
long tmp;
|
long tmp;
|
||||||
@ -803,7 +800,7 @@ public:
|
|||||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||||
int store(double nr);
|
int store(double nr);
|
||||||
int store(longlong nr);
|
int store(longlong nr);
|
||||||
void store_time(TIME *ltime,timestamp_type type);
|
int store_time(TIME *ltime, timestamp_type type);
|
||||||
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
|
void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
|
||||||
double val_real(void);
|
double val_real(void);
|
||||||
longlong val_int(void);
|
longlong val_int(void);
|
||||||
@ -836,6 +833,7 @@ public:
|
|||||||
enum_field_types type() const { return FIELD_TYPE_TIME;}
|
enum_field_types type() const { return FIELD_TYPE_TIME;}
|
||||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
|
||||||
enum Item_result cmp_type () const { return INT_RESULT; }
|
enum Item_result cmp_type () const { return INT_RESULT; }
|
||||||
|
int store_time(TIME *ltime, timestamp_type type);
|
||||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||||
int store(double nr);
|
int store(double nr);
|
||||||
int store(longlong nr);
|
int store(longlong nr);
|
||||||
@ -876,7 +874,7 @@ public:
|
|||||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||||
int store(double nr);
|
int store(double nr);
|
||||||
int store(longlong nr);
|
int store(longlong nr);
|
||||||
void store_time(TIME *ltime,timestamp_type type);
|
int store_time(TIME *ltime, timestamp_type type);
|
||||||
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
|
void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
|
||||||
double val_real(void);
|
double val_real(void);
|
||||||
longlong val_int(void);
|
longlong val_int(void);
|
||||||
@ -909,9 +907,11 @@ public:
|
|||||||
|
|
||||||
enum_field_types type() const
|
enum_field_types type() const
|
||||||
{
|
{
|
||||||
return ((table && table->db_create_options & HA_OPTION_PACK_RECORD &&
|
return ((orig_table &&
|
||||||
field_length >= 4) ?
|
orig_table->s->db_create_options & HA_OPTION_PACK_RECORD &&
|
||||||
FIELD_TYPE_VAR_STRING : FIELD_TYPE_STRING);
|
field_length >= 4) &&
|
||||||
|
orig_table->s->frm_version < FRM_VER_TRUE_VARCHAR ?
|
||||||
|
MYSQL_TYPE_VAR_STRING : MYSQL_TYPE_STRING);
|
||||||
}
|
}
|
||||||
enum ha_base_keytype key_type() const
|
enum ha_base_keytype key_type() const
|
||||||
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
|
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
|
||||||
@ -928,8 +928,9 @@ public:
|
|||||||
void sql_type(String &str) const;
|
void sql_type(String &str) const;
|
||||||
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
||||||
const char *unpack(char* to, const char *from);
|
const char *unpack(char* to, const char *from);
|
||||||
int pack_cmp(const char *a,const char *b,uint key_length);
|
int pack_cmp(const char *a,const char *b,uint key_length,
|
||||||
int pack_cmp(const char *b,uint key_length);
|
my_bool insert_or_update);
|
||||||
|
int pack_cmp(const char *b,uint key_length,my_bool insert_or_update);
|
||||||
uint packed_col_length(const char *to, uint length);
|
uint packed_col_length(const char *to, uint length);
|
||||||
uint max_packed_col_length(uint max_length);
|
uint max_packed_col_length(uint max_length);
|
||||||
uint size_of() const { return sizeof(*this); }
|
uint size_of() const { return sizeof(*this); }
|
||||||
@ -937,31 +938,43 @@ public:
|
|||||||
bool has_charset(void) const
|
bool has_charset(void) const
|
||||||
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
|
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_STRING; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_STRING; }
|
||||||
|
Field *new_field(MEM_ROOT *root, struct st_table *new_table);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Field_varstring :public Field_str {
|
class Field_varstring :public Field_str {
|
||||||
public:
|
public:
|
||||||
Field_varstring(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
|
/* Store number of bytes used to store length (1 or 2) */
|
||||||
|
uint32 length_bytes;
|
||||||
|
Field_varstring(char *ptr_arg,
|
||||||
|
uint32 len_arg, uint length_bytes_arg,
|
||||||
|
uchar *null_ptr_arg,
|
||||||
uchar null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg, CHARSET_INFO *cs)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg, cs)
|
unireg_check_arg, field_name_arg, table_arg, cs),
|
||||||
{}
|
length_bytes(length_bytes_arg)
|
||||||
|
{
|
||||||
|
if (table)
|
||||||
|
table->s->varchar_fields++;
|
||||||
|
}
|
||||||
Field_varstring(uint32 len_arg,bool maybe_null_arg,
|
Field_varstring(uint32 len_arg,bool maybe_null_arg,
|
||||||
const char *field_name_arg,
|
const char *field_name_arg,
|
||||||
struct st_table *table_arg, CHARSET_INFO *cs)
|
struct st_table *table_arg, CHARSET_INFO *cs)
|
||||||
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
|
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
|
||||||
NONE, field_name_arg, table_arg, cs)
|
NONE, field_name_arg, table_arg, cs),
|
||||||
{}
|
length_bytes(len_arg < 256 ? 1 :2)
|
||||||
|
{
|
||||||
|
if (table)
|
||||||
|
table->s->varchar_fields++;
|
||||||
|
}
|
||||||
|
|
||||||
enum_field_types type() const { return FIELD_TYPE_VAR_STRING; }
|
enum_field_types type() const { return MYSQL_TYPE_VARCHAR; }
|
||||||
enum ha_base_keytype key_type() const
|
enum ha_base_keytype key_type() const;
|
||||||
{ return binary() ? HA_KEYTYPE_VARBINARY : HA_KEYTYPE_VARTEXT; }
|
|
||||||
bool zero_pack() const { return 0; }
|
bool zero_pack() const { return 0; }
|
||||||
void reset(void) { bzero(ptr,field_length+2); }
|
void reset(void) { bzero(ptr,field_length+length_bytes); }
|
||||||
uint32 pack_length() const { return (uint32) field_length+2; }
|
uint32 pack_length() const { return (uint32) field_length+length_bytes; }
|
||||||
uint32 key_length() const { return (uint32) field_length; }
|
uint32 key_length() const { return (uint32) field_length; }
|
||||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||||
int store(longlong nr);
|
int store(longlong nr);
|
||||||
@ -971,21 +984,31 @@ public:
|
|||||||
String *val_str(String*,String *);
|
String *val_str(String*,String *);
|
||||||
int cmp(const char *,const char*);
|
int cmp(const char *,const char*);
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
void get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type);
|
void get_key_image(char *buff,uint length, imagetype type);
|
||||||
void set_key_image(char *buff,uint length, CHARSET_INFO *cs);
|
void set_key_image(char *buff,uint length);
|
||||||
void sql_type(String &str) const;
|
void sql_type(String &str) const;
|
||||||
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
||||||
char *pack_key(char *to, const char *from, uint max_length);
|
char *pack_key(char *to, const char *from, uint max_length);
|
||||||
|
char *pack_key_from_key_image(char* to, const char *from, uint max_length);
|
||||||
const char *unpack(char* to, const char *from);
|
const char *unpack(char* to, const char *from);
|
||||||
int pack_cmp(const char *a, const char *b, uint key_length);
|
const char *unpack_key(char* to, const char *from, uint max_length);
|
||||||
int pack_cmp(const char *b, uint key_length);
|
int pack_cmp(const char *a, const char *b, uint key_length,
|
||||||
|
my_bool insert_or_update);
|
||||||
|
int pack_cmp(const char *b, uint key_length,my_bool insert_or_update);
|
||||||
|
int cmp_binary(const char *a,const char *b, uint32 max_length=~0L);
|
||||||
|
int key_cmp(const byte *,const byte*);
|
||||||
|
int key_cmp(const byte *str, uint length);
|
||||||
uint packed_col_length(const char *to, uint length);
|
uint packed_col_length(const char *to, uint length);
|
||||||
uint max_packed_col_length(uint max_length);
|
uint max_packed_col_length(uint max_length);
|
||||||
uint size_of() const { return sizeof(*this); }
|
uint size_of() const { return sizeof(*this); }
|
||||||
enum_field_types real_type() const { return FIELD_TYPE_VAR_STRING; }
|
enum_field_types real_type() const { return MYSQL_TYPE_VARCHAR; }
|
||||||
bool has_charset(void) const
|
bool has_charset(void) const
|
||||||
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
|
{ return charset() == &my_charset_bin ? FALSE : TRUE; }
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_VARSTRING; }
|
||||||
|
Field *new_field(MEM_ROOT *root, struct st_table *new_table);
|
||||||
|
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
|
||||||
|
char *new_ptr, uchar *new_null_ptr,
|
||||||
|
uint new_null_bit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -1008,7 +1031,7 @@ public:
|
|||||||
}
|
}
|
||||||
enum_field_types type() const { return FIELD_TYPE_BLOB;}
|
enum_field_types type() const { return FIELD_TYPE_BLOB;}
|
||||||
enum ha_base_keytype key_type() const
|
enum ha_base_keytype key_type() const
|
||||||
{ return binary() ? HA_KEYTYPE_VARBINARY : HA_KEYTYPE_VARTEXT; }
|
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
|
||||||
int store(const char *to,uint length,CHARSET_INFO *charset);
|
int store(const char *to,uint length,CHARSET_INFO *charset);
|
||||||
int store(double nr);
|
int store(double nr);
|
||||||
int store(longlong nr);
|
int store(longlong nr);
|
||||||
@ -1017,15 +1040,13 @@ public:
|
|||||||
String *val_str(String*,String *);
|
String *val_str(String*,String *);
|
||||||
int cmp(const char *,const char*);
|
int cmp(const char *,const char*);
|
||||||
int cmp(const char *a, uint32 a_length, const char *b, uint32 b_length);
|
int cmp(const char *a, uint32 a_length, const char *b, uint32 b_length);
|
||||||
int cmp_offset(uint offset);
|
|
||||||
int cmp_binary(const char *a,const char *b, uint32 max_length=~0L);
|
int cmp_binary(const char *a,const char *b, uint32 max_length=~0L);
|
||||||
int cmp_binary_offset(uint row_offset);
|
|
||||||
int key_cmp(const byte *,const byte*);
|
int key_cmp(const byte *,const byte*);
|
||||||
int key_cmp(const byte *str, uint length);
|
int key_cmp(const byte *str, uint length);
|
||||||
uint32 key_length() const { return 0; }
|
uint32 key_length() const { return 0; }
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const
|
uint32 pack_length() const
|
||||||
{ return (uint32) (packlength+table->blob_ptr_size); }
|
{ return (uint32) (packlength+table->s->blob_ptr_size); }
|
||||||
inline uint32 max_data_length() const
|
inline uint32 max_data_length() const
|
||||||
{
|
{
|
||||||
return (uint32) (((ulonglong) 1 << (packlength*8)) -1);
|
return (uint32) (((ulonglong) 1 << (packlength*8)) -1);
|
||||||
@ -1051,8 +1072,8 @@ public:
|
|||||||
store_length(length);
|
store_length(length);
|
||||||
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
||||||
}
|
}
|
||||||
void get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type);
|
void get_key_image(char *buff,uint length, imagetype type);
|
||||||
void set_key_image(char *buff,uint length, CHARSET_INFO *cs);
|
void set_key_image(char *buff,uint length);
|
||||||
void sql_type(String &str) const;
|
void sql_type(String &str) const;
|
||||||
inline bool copy()
|
inline bool copy()
|
||||||
{ char *tmp;
|
{ char *tmp;
|
||||||
@ -1066,12 +1087,13 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char *pack(char *to, const char *from, uint max_length= ~(uint) 0);
|
char *pack(char *to, const char *from, uint max_length= ~(uint) 0);
|
||||||
const char *unpack(char *to, const char *from);
|
|
||||||
char *pack_key(char *to, const char *from, uint max_length);
|
char *pack_key(char *to, const char *from, uint max_length);
|
||||||
char *pack_key_from_key_image(char* to, const char *from, uint max_length);
|
char *pack_key_from_key_image(char* to, const char *from, uint max_length);
|
||||||
|
const char *unpack(char *to, const char *from);
|
||||||
const char *unpack_key(char* to, const char *from, uint max_length);
|
const char *unpack_key(char* to, const char *from, uint max_length);
|
||||||
int pack_cmp(const char *a, const char *b, uint key_length);
|
int pack_cmp(const char *a, const char *b, uint key_length,
|
||||||
int pack_cmp(const char *b, uint key_length);
|
my_bool insert_or_update);
|
||||||
|
int pack_cmp(const char *b, uint key_length,my_bool insert_or_update);
|
||||||
uint packed_col_length(const char *col_ptr, uint length);
|
uint packed_col_length(const char *col_ptr, uint length);
|
||||||
uint max_packed_col_length(uint max_length);
|
uint max_packed_col_length(uint max_length);
|
||||||
void free() { value.free(); }
|
void free() { value.free(); }
|
||||||
@ -1084,6 +1106,7 @@ public:
|
|||||||
uint32 max_length();
|
uint32 max_length();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_SPATIAL
|
#ifdef HAVE_SPATIAL
|
||||||
class Field_geom :public Field_blob {
|
class Field_geom :public Field_blob {
|
||||||
public:
|
public:
|
||||||
@ -1101,19 +1124,19 @@ public:
|
|||||||
:Field_blob(len_arg, maybe_null_arg, field_name_arg,
|
:Field_blob(len_arg, maybe_null_arg, field_name_arg,
|
||||||
table_arg, &my_charset_bin)
|
table_arg, &my_charset_bin)
|
||||||
{ geom_type= geom_type_arg; }
|
{ geom_type= geom_type_arg; }
|
||||||
enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY; }
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY2; }
|
||||||
enum_field_types type() const { return FIELD_TYPE_GEOMETRY; }
|
enum_field_types type() const { return FIELD_TYPE_GEOMETRY; }
|
||||||
void sql_type(String &str) const;
|
void sql_type(String &str) const;
|
||||||
int store(const char *to, uint length, CHARSET_INFO *charset);
|
int store(const char *to, uint length, CHARSET_INFO *charset);
|
||||||
int store(double nr) { return 1; }
|
int store(double nr) { return 1; }
|
||||||
int store(longlong nr) { return 1; }
|
int store(longlong nr) { return 1; }
|
||||||
|
|
||||||
void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type);
|
void get_key_image(char *buff,uint length,imagetype type);
|
||||||
void set_key_image(char *buff,uint length, CHARSET_INFO *cs);
|
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; }
|
||||||
};
|
};
|
||||||
#endif /*HAVE_SPATIAL*/
|
#endif /*HAVE_SPATIAL*/
|
||||||
|
|
||||||
|
|
||||||
class Field_enum :public Field_str {
|
class Field_enum :public Field_str {
|
||||||
protected:
|
protected:
|
||||||
uint packlength;
|
uint packlength;
|
||||||
@ -1182,6 +1205,52 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Field_bit :public Field {
|
||||||
|
public:
|
||||||
|
uchar *bit_ptr; // position in record where 'uneven' bits store
|
||||||
|
uchar bit_ofs; // offset to 'uneven' high bits
|
||||||
|
uint bit_len; // number of 'uneven' high bits
|
||||||
|
Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
|
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
|
||||||
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
|
struct st_table *table_arg);
|
||||||
|
enum_field_types type() const { return FIELD_TYPE_BIT; }
|
||||||
|
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
|
||||||
|
uint32 key_length() const { return (uint32) field_length + (bit_len > 0); }
|
||||||
|
uint32 max_length() { return (uint32) field_length + (bit_len > 0); }
|
||||||
|
uint size_of() const { return sizeof(*this); }
|
||||||
|
Item_result result_type () const { return INT_RESULT; }
|
||||||
|
void reset(void) { bzero(ptr, field_length); }
|
||||||
|
int store(const char *to, uint length, CHARSET_INFO *charset);
|
||||||
|
int store(double nr);
|
||||||
|
int store(longlong nr);
|
||||||
|
double val_real(void);
|
||||||
|
longlong val_int(void);
|
||||||
|
String *val_str(String*, String *);
|
||||||
|
int cmp(const char *a, const char *b)
|
||||||
|
{ return cmp_binary(a, b); }
|
||||||
|
int key_cmp(const byte *a, const byte *b)
|
||||||
|
{ return cmp_binary((char *) a, (char *) b); }
|
||||||
|
int key_cmp(const byte *str, uint length);
|
||||||
|
int cmp_offset(uint row_offset);
|
||||||
|
void get_key_image(char *buff, uint length, imagetype type);
|
||||||
|
void set_key_image(char *buff, uint length)
|
||||||
|
{ Field_bit::store(buff, length, &my_charset_bin); }
|
||||||
|
void sort_string(char *buff, uint length)
|
||||||
|
{ get_key_image(buff, length, itRAW); }
|
||||||
|
uint32 pack_length() const
|
||||||
|
{ return (uint32) field_length + (bit_len > 0); }
|
||||||
|
uint32 pack_length_in_rec() const { return field_length; }
|
||||||
|
void sql_type(String &str) const;
|
||||||
|
field_cast_enum field_cast_type() { return FIELD_CAST_BIT; }
|
||||||
|
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
|
||||||
|
const char *unpack(char* to, const char *from);
|
||||||
|
Field *new_key_field(MEM_ROOT *root, struct st_table *new_table,
|
||||||
|
char *new_ptr, uchar *new_null_ptr,
|
||||||
|
uint new_null_bit);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create field class for CREATE TABLE
|
Create field class for CREATE TABLE
|
||||||
*/
|
*/
|
||||||
@ -1194,8 +1263,8 @@ public:
|
|||||||
LEX_STRING comment; // Comment for field
|
LEX_STRING comment; // Comment for field
|
||||||
Item *def; // Default value
|
Item *def; // Default value
|
||||||
enum enum_field_types sql_type;
|
enum enum_field_types sql_type;
|
||||||
uint32 length;
|
ulong length;
|
||||||
uint decimals,flags,pack_length;
|
uint decimals, flags, pack_length, key_length;
|
||||||
Field::utype unireg_check;
|
Field::utype unireg_check;
|
||||||
TYPELIB *interval; // Which interval to use
|
TYPELIB *interval; // Which interval to use
|
||||||
List<String> interval_list;
|
List<String> interval_list;
|
||||||
@ -1260,11 +1329,10 @@ Field *make_field(char *ptr, uint32 field_length,
|
|||||||
TYPELIB *interval, const char *field_name,
|
TYPELIB *interval, const char *field_name,
|
||||||
struct st_table *table);
|
struct st_table *table);
|
||||||
uint pack_length_to_packflag(uint type);
|
uint pack_length_to_packflag(uint type);
|
||||||
|
enum_field_types get_blob_type_from_length(ulong length);
|
||||||
uint32 calc_pack_length(enum_field_types type,uint32 length);
|
uint32 calc_pack_length(enum_field_types type,uint32 length);
|
||||||
int set_field_to_null(Field *field);
|
int set_field_to_null(Field *field);
|
||||||
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
|
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
|
||||||
bool test_if_int(const char *str, int length, const char *int_end,
|
|
||||||
CHARSET_INFO *cs);
|
|
||||||
bool field_types_to_be_kept(enum_field_types field_type);
|
bool field_types_to_be_kept(enum_field_types field_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1284,6 +1352,7 @@ bool field_types_to_be_kept(enum_field_types field_type);
|
|||||||
#define FIELDFLAG_LEFT_FULLSCREEN 8192
|
#define FIELDFLAG_LEFT_FULLSCREEN 8192
|
||||||
#define FIELDFLAG_RIGHT_FULLSCREEN 16384
|
#define FIELDFLAG_RIGHT_FULLSCREEN 16384
|
||||||
#define FIELDFLAG_FORMAT_NUMBER 16384 // predit: ###,,## in output
|
#define FIELDFLAG_FORMAT_NUMBER 16384 // predit: ###,,## in output
|
||||||
|
#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
|
||||||
#define FIELDFLAG_SUM ((uint) 32768)// predit: +#fieldflag
|
#define FIELDFLAG_SUM ((uint) 32768)// predit: +#fieldflag
|
||||||
#define FIELDFLAG_MAYBE_NULL ((uint) 32768)// sql
|
#define FIELDFLAG_MAYBE_NULL ((uint) 32768)// sql
|
||||||
#define FIELDFLAG_PACK_SHIFT 3
|
#define FIELDFLAG_PACK_SHIFT 3
|
||||||
@ -1292,8 +1361,6 @@ bool field_types_to_be_kept(enum_field_types field_type);
|
|||||||
#define FIELDFLAG_NUM_SCREEN_TYPE 0x7F01
|
#define FIELDFLAG_NUM_SCREEN_TYPE 0x7F01
|
||||||
#define FIELDFLAG_ALFA_SCREEN_TYPE 0x7800
|
#define FIELDFLAG_ALFA_SCREEN_TYPE 0x7800
|
||||||
|
|
||||||
#define FIELD_SORT_REVERSE 16384
|
|
||||||
|
|
||||||
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
|
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
|
||||||
|
|
||||||
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
|
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
|
||||||
@ -1311,3 +1378,4 @@ bool field_types_to_be_kept(enum_field_types field_type);
|
|||||||
#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
|
#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
|
||||||
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
|
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
|
||||||
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
|
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
|
||||||
|
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
|
||||||
|
Reference in New Issue
Block a user