summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-06-07 18:13:02 +0200
committerSergei Golubchik <sergii@pisem.net>2011-06-07 18:13:02 +0200
commit9b98cae4cc44fa39813675b361b7aa65d129b29d (patch)
tree7f4baeea245f91006e88c62508c2859ed9390c2d /sql/field.h
parent29af1aefe914da6aca73498c077f7e37a36d7de4 (diff)
parent4d128777dde904c5f0adab9b093e854c9c580d41 (diff)
downloadmariadb-git-9b98cae4cc44fa39813675b361b7aa65d129b29d.tar.gz
merge with 5.1-micro
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h82
1 files changed, 31 insertions, 51 deletions
diff --git a/sql/field.h b/sql/field.h
index f5dd5d5ea3f..7a552bf0012 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -204,7 +204,9 @@ public:
virtual int store(double nr)=0;
virtual int store(longlong nr, bool unsigned_val)=0;
virtual int store_decimal(const my_decimal *d)=0;
- virtual int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
+ virtual int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ int store_time(MYSQL_TIME *ltime)
+ { return store_time_dec(ltime, TIME_SECOND_PART_DIGITS); }
int store(const char *to, uint length, CHARSET_INFO *cs,
enum_check_fields check_level);
virtual double val_real(void)=0;
@@ -386,7 +388,6 @@ public:
virtual void make_field(Send_field *);
virtual void sort_string(uchar *buff,uint length)=0;
virtual bool optimize_range(uint idx, uint part);
- virtual bool special_const_compare() const { return FALSE; }
virtual void free() {}
virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table,
bool keep_type);
@@ -531,7 +532,7 @@ public:
{ return DERIVATION_IMPLICIT; }
virtual void set_derivation(enum Derivation derivation_arg) { }
virtual int set_time() { return 1; }
- bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
+ void set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
int cuted_increment);
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
const Lazy_string *str, timestamp_type ts_type,
@@ -628,49 +629,26 @@ private:
{ return 0; }
protected:
- /*
- Helper function to pack()/unpack() int32 values
- */
- static void handle_int32(uchar *to, const uchar *from)
+ uchar *pack_int(uchar *to, const uchar *from, size_t size)
{
- int32 val;
- val = sint4korr(from);
- int4store(to, val);
+ memcpy(to, from, size);
+ return to + size;
}
- /*
- Helper function to pack()/unpack() int64 values
- */
- static void handle_int64(uchar* to, const uchar *from)
+ const uchar *unpack_int(uchar* to, const uchar *from, size_t size)
{
- int64 val;
- val = sint8korr(from);
- int8store(to, val);
+ memcpy(to, from, size);
+ return from + size;
}
uchar *pack_int32(uchar *to, const uchar *from)
- {
- handle_int32(to, from);
- return to + sizeof(int32);
- }
-
+ { return pack_int(to, from, 4); }
const uchar *unpack_int32(uchar* to, const uchar *from)
- {
- handle_int32(to, from);
- return from + sizeof(int32);
- }
-
+ { return unpack_int(to, from, 4); }
uchar *pack_int64(uchar* to, const uchar *from)
- {
- handle_int64(to, from);
- return to + sizeof(int64);
- }
-
+ { return pack_int(to, from, 8); }
const uchar *unpack_int64(uchar* to, const uchar *from)
- {
- handle_int64(to, from);
- return from + sizeof(int64);
- }
+ { return unpack_int(to, from, 8); }
bool field_flags_are_binary()
{
@@ -688,7 +666,7 @@ public:
uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
- Item_result result_type () const { return REAL_RESULT; }
+ enum Item_result result_type () const { return INT_RESULT; }
void prepend_zeros(String *value);
void add_zerofill_and_unsigned(String &res) const;
friend class Create_field;
@@ -699,6 +677,7 @@ public:
int store_decimal(const my_decimal *);
my_decimal *val_decimal(my_decimal *);
uint is_equal(Create_field *new_field);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int check_int(CHARSET_INFO *cs, const char *str, int length,
const char *int_end, int error);
bool get_int(CHARSET_INFO *cs, const char *from, uint len,
@@ -768,7 +747,10 @@ public:
field_name_arg, dec_arg, zero_arg, unsigned_arg),
not_fixed(dec_arg >= NOT_FIXED_DEC)
{}
+ Item_result result_type () const { return REAL_RESULT; }
int store_decimal(const my_decimal *);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
my_decimal *val_decimal(my_decimal *);
uint32 max_display_length() { return field_length; }
uint size_of() const { return sizeof(*this); }
@@ -841,7 +823,7 @@ public:
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type t_type);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int store_decimal(const my_decimal *);
double val_real(void);
longlong val_int(void);
@@ -874,7 +856,6 @@ public:
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_TINY;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_BINARY : HA_KEYTYPE_INT8; }
@@ -921,7 +902,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, 0, 0, unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_SHORT;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_USHORT_INT : HA_KEYTYPE_SHORT_INT;}
@@ -966,7 +946,6 @@ public:
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_INT24;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_UINT24 : HA_KEYTYPE_INT24; }
@@ -1011,7 +990,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_LONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONG_INT : HA_KEYTYPE_LONG_INT; }
@@ -1057,7 +1035,6 @@ public:
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
{}
- enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return MYSQL_TYPE_LONGLONG;}
enum ha_base_keytype key_type() const
{ return unsigned_flag ? HA_KEYTYPE_ULONGLONG : HA_KEYTYPE_LONGLONG; }
@@ -1200,6 +1177,7 @@ public:
class Field_timestamp :public Field_str {
+protected:
int store_TIME_with_warning(THD *, MYSQL_TIME *, const Lazy_string *,
bool, bool);
public:
@@ -1215,7 +1193,7 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1274,6 +1252,7 @@ public:
my_time_t get_timestamp(ulong *sec_part) const;
void store_TIME(my_time_t timestamp, ulong sec_part);
int store_decimal(const my_decimal *d);
+ my_decimal* val_decimal(my_decimal*);
double val_real(void);
String *val_str(String*,String *);
bool send_binary(Protocol *protocol);
@@ -1309,13 +1288,13 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool send_binary(Protocol *protocol);
uint32 max_display_length() { return field_length; }
- /* 99 should compare with 1999 */
- bool special_const_compare() const { return TRUE; }
void sql_type(String &str) const;
};
@@ -1336,8 +1315,8 @@ public:
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
- bool special_const_compare() const { return TRUE; }
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
+ my_decimal *val_decimal(my_decimal*);
};
class Field_date :public Field_temporal {
@@ -1418,7 +1397,7 @@ public:
{}
enum_field_types type() const { return MYSQL_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
- int store_time(MYSQL_TIME *ltime, timestamp_type type);
+ int store_time_dec(MYSQL_TIME *ltime, uint dec);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
@@ -1451,7 +1430,8 @@ public:
}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint decimals() const { return dec; }
- longlong val_int(void) { return (longlong)floor(val_real()); }
+ int store_decimal(const my_decimal *d);
+ longlong val_int(void);
double val_real(void);
String *val_str(String*,String *);
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
@@ -1522,9 +1502,9 @@ public:
DBUG_ASSERT(dec <= TIME_SECOND_PART_DIGITS);
}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
- int store_decimal(const my_decimal *d);
uint decimals() const { return dec; }
void make_field(Send_field *field);
+ int store_decimal(const my_decimal *d);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);