summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h356
1 files changed, 218 insertions, 138 deletions
diff --git a/sql/field.h b/sql/field.h
index cbdfa686ff8..9475e28bc0f 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -22,8 +22,13 @@
#pragma interface /* gcc class implementation */
#endif
+#ifdef WORDS_BIGENDIAN
+#define BIGENDIAN 1
+#else
+#define BIGENDIAN 0
+#endif
+
#define NOT_FIXED_DEC 31
-#define DATETIME_DEC 6
const uint32 max_field_size= (uint32) 4294967295U;
class Send_field;
@@ -299,14 +304,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);
- /*
- This should be true for fields which, when compared with constant
- items, can be casted to longlong. In this case we will at 'fix_fields'
- stage cast the constant items to longlongs and at the execution stage
- use field->val_int() for comparison. Used to optimize clauses like
- 'a_column BETWEEN date_const, date_const'.
- */
- virtual bool can_be_compared_as_longlong() const { return FALSE; }
virtual void free() {}
virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table,
bool keep_type);
@@ -447,7 +444,7 @@ public:
void copy_from_tmp(int offset);
uint fill_cache_field(struct st_cache_field *copy);
virtual bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- virtual bool get_time(MYSQL_TIME *ltime);
+ bool get_time(MYSQL_TIME *ltime) { return get_date(ltime, TIME_TIME_ONLY); }
virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
virtual bool has_charset(void) const { return FALSE; }
@@ -455,16 +452,12 @@ public:
virtual enum Derivation derivation(void) const
{ 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,
int cuted_increment);
void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
- const char *str, uint str_len,
- timestamp_type ts_type, int cuted_increment);
- void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code,
- longlong nr, timestamp_type ts_type,
+ const Lazy_string *str, timestamp_type ts_type,
int cuted_increment);
- void set_datetime_warning(MYSQL_ERROR::enum_warning_level, const uint code,
- double nr, timestamp_type ts_type);
inline bool check_overflow(int op_result)
{
return (op_result == E_DEC_OVERFLOW);
@@ -555,18 +548,14 @@ protected:
bool low_byte_first_from, bool low_byte_first_to)
{
int32 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_from)
+ if (BIGENDIAN && low_byte_first_from)
val = sint4korr(from);
else
-#endif
longget(val, from);
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_to)
+ if (BIGENDIAN && low_byte_first_to)
int4store(to, val);
else
-#endif
longstore(to, val);
}
@@ -577,18 +566,14 @@ protected:
bool low_byte_first_from, bool low_byte_first_to)
{
int64 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_from)
+ if (BIGENDIAN && low_byte_first_from)
val = sint8korr(from);
else
-#endif
longlongget(val, from);
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first_to)
+ if (BIGENDIAN && low_byte_first_to)
int8store(to, val);
else
-#endif
longlongstore(to, val);
}
@@ -681,7 +666,6 @@ public:
uint is_equal(Create_field *new_field);
};
-
/* base class for Field_string, Field_varstring and Field_blob */
class Field_longstr :public Field_str
@@ -899,18 +883,14 @@ public:
uint max_length, bool low_byte_first)
{
int16 val;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
+ if (BIGENDIAN && table->s->db_low_byte_first)
val = sint2korr(from);
else
-#endif
shortget(val, from);
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
+ if (BIGENDIAN && low_byte_first)
int2store(to, val);
else
-#endif
shortstore(to, val);
return to + sizeof(val);
}
@@ -919,18 +899,14 @@ public:
uint param_data, bool low_byte_first)
{
int16 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
+ if (BIGENDIAN && low_byte_first)
val = sint2korr(from);
else
-#endif
shortget(val, from);
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
+ if (BIGENDIAN && table->s->db_low_byte_first)
int2store(to, val);
else
-#endif
shortstore(to, val);
return from + sizeof(val);
}
@@ -1025,7 +1001,6 @@ public:
};
-#ifdef HAVE_LONG_LONG
class Field_longlong :public Field_num {
public:
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
@@ -1062,7 +1037,6 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
uint32 max_display_length() { return 20; }
virtual uchar *pack(uchar* to, const uchar *from,
uint max_length __attribute__((unused)),
@@ -1077,7 +1051,6 @@ public:
return unpack_int64(to, from, low_byte_first);
}
};
-#endif
class Field_float :public Field_real {
@@ -1188,6 +1161,8 @@ public:
class Field_timestamp :public Field_str {
+ int store_TIME_with_warning(THD *, MYSQL_TIME *, const Lazy_string *,
+ bool, bool);
public:
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
@@ -1197,11 +1172,11 @@ public:
CHARSET_INFO *cs);
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
- enum Item_result cmp_type () const { return INT_RESULT; }
+ enum Item_result cmp_type () const { return TIME_RESULT; }
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
+ int store_time(MYSQL_TIME *ltime, timestamp_type type);
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1210,9 +1185,9 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 0; }
- void set_time();
+ uint decimals() const { return 0; }
+ virtual int set_time();
virtual void set_default()
{
if (table->timestamp_field == this &&
@@ -1222,31 +1197,15 @@ public:
Field::set_default();
}
/* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
- inline long get_timestamp(my_bool *null_value)
+ virtual long get_timestamp(ulong *sec_part) const;
+ virtual void store_TIME(my_time_t timestamp, ulong sec_part)
{
- if ((*null_value= is_null()))
- return 0;
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- return sint4korr(ptr);
-#endif
- long tmp;
- longget(tmp,ptr);
- return tmp;
- }
- inline void store_timestamp(my_time_t timestamp)
- {
-#ifdef WORDS_BIGENDIAN
- if (table && table->s->db_low_byte_first)
- {
+ if (BIGENDIAN && table && table->s->db_low_byte_first)
int4store(ptr,timestamp);
- }
else
-#endif
longstore(ptr,(uint32) timestamp);
}
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
timestamp_auto_set_type get_auto_set_type() const;
uchar *pack(uchar *to, const uchar *from,
uint max_length __attribute__((unused)), bool low_byte_first)
@@ -1262,6 +1221,43 @@ public:
};
+class Field_timestamp_hires :public Field_timestamp {
+ uint dec;
+public:
+ Field_timestamp_hires(uchar *ptr_arg,
+ uchar *null_ptr_arg, uchar null_bit_arg,
+ enum utype unireg_check_arg, const char *field_name_arg,
+ TABLE_SHARE *share, uint dec_arg, CHARSET_INFO *cs) :
+ Field_timestamp(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1, null_ptr_arg,
+ null_bit_arg, unireg_check_arg, field_name_arg, share, cs),
+ dec(dec_arg)
+ {
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= MAX_SEC_PART_DIGITS);
+ }
+ void sql_type(String &str) const;
+ long get_timestamp(ulong *sec_part) const;
+ void store_TIME(my_time_t timestamp, ulong sec_part);
+ int store_decimal(const my_decimal *d);
+ double val_real(void);
+ String *val_str(String*,String *);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint decimals() const { return dec; }
+ int set_time();
+ enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
+ void make_field(Send_field *field);
+ uint32 pack_length() const;
+ uchar *pack(uchar *to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ { return Field::pack(to, from, max_length, low_byte_first); }
+ const uchar *unpack(uchar* to, const uchar *from, uint param_data,
+ bool low_byte_first)
+ { return Field::unpack(to, from, param_data, low_byte_first); }
+};
+
+
class Field_year :public Field_tiny {
public:
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
@@ -1279,39 +1275,51 @@ public:
String *val_str(String*,String *);
bool send_binary(Protocol *protocol);
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
};
-class Field_date :public Field_str {
+class Field_temporal: public Field_str {
+protected:
+ int store_TIME_with_warning(MYSQL_TIME *ltime, const Lazy_string *str,
+ int was_cut, int have_smth_to_conv);
+ virtual void store_TIME(MYSQL_TIME *ltime) = 0;
+ virtual timestamp_type temporal_type() = 0;
+public:
+ Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *charset_arg)
+ :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
+ field_name_arg, charset_arg) { }
+ enum Item_result cmp_type () const { return TIME_RESULT; }
+ 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);
+};
+
+class Field_date :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_DATE; }
public:
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
CHARSET_INFO *cs)
- :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_date(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- int store(const char *to,uint length,CHARSET_INFO *charset);
- int store(double nr);
- int store(longlong nr, bool unsigned_val);
int reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
- bool get_time(MYSQL_TIME *ltime);
+ uint decimals() const { return 0; }
bool send_binary(Protocol *protocol);
int cmp(const uchar *,const uchar *);
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
uchar *pack(uchar* to, const uchar *from,
uint max_length __attribute__((unused)), bool low_byte_first)
@@ -1327,27 +1335,21 @@ public:
};
-class Field_newdate :public Field_str {
+class Field_newdate :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type() { return MYSQL_TIMESTAMP_DATE; }
public:
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
CHARSET_INFO *cs)
- :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ :Field_temporal(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_newdate(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_UINT24; }
- enum Item_result cmp_type () const { return INT_RESULT; }
- 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 reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
+ uint decimals() const { return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1356,75 +1358,84 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
};
-class Field_time :public Field_str {
+class Field_time :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_TIME; }
public:
- Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *cs)
+ :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_time(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
- enum Item_result cmp_type () const { return INT_RESULT; }
int store_time(MYSQL_TIME *ltime, timestamp_type type);
int store(const char *to,uint length,CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
- int reset(void) { ptr[0]=ptr[1]=ptr[2]=0; return 0; }
+ uint decimals() const { return 0; }
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);
- bool get_time(MYSQL_TIME *ltime);
int cmp(const uchar *,const uchar *);
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
};
+class Field_time_hires :public Field_time {
+ uint dec;
+ void store_TIME(MYSQL_TIME *ltime);
+public:
+ Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
+ enum utype unireg_check_arg, const char *field_name_arg,
+ uint dec_arg, CHARSET_INFO *cs)
+ :Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + 1, null_ptr_arg,
+ null_bit_arg, unireg_check_arg, field_name_arg, cs),
+ dec(dec_arg)
+ {
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= MAX_SEC_PART_DIGITS);
+ }
+ 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()); }
+ double val_real(void);
+ String *val_str(String*,String *);
+ bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint32 pack_length() const;
+ void sql_type(String &str) const;
+ void make_field(Send_field *);
+};
-class Field_datetime :public Field_str {
+class Field_datetime :public Field_temporal {
+ void store_TIME(MYSQL_TIME *ltime);
+ timestamp_type temporal_type()
+ { return MYSQL_TIMESTAMP_DATETIME; }
public:
- Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
- unireg_check_arg, field_name_arg, cs)
+ Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, CHARSET_INFO *cs)
+ :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
+ unireg_check_arg, field_name_arg, cs)
{}
- Field_datetime(bool maybe_null_arg, const char *field_name_arg,
- CHARSET_INFO *cs)
- :Field_str((uchar*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
- NONE, field_name_arg, cs) {}
enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
-#ifdef HAVE_LONG_LONG
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
-#endif
- enum Item_result cmp_type () const { return INT_RESULT; }
- uint decimals() const { return DATETIME_DEC; }
- 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 reset(void)
- {
- ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0;
- return 0;
- }
+ enum Item_result cmp_type () const { return TIME_RESULT; }
+ uint decimals() const { return 0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -1433,10 +1444,8 @@ public:
void sort_string(uchar *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
- bool get_time(MYSQL_TIME *ltime);
uchar *pack(uchar* to, const uchar *from,
uint max_length __attribute__((unused)), bool low_byte_first)
{
@@ -1451,6 +1460,81 @@ public:
};
+class Field_datetime_hires :public Field_datetime {
+ void store_TIME(MYSQL_TIME *ltime);
+ uint dec;
+public:
+ Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
+ uchar null_bit_arg, enum utype unireg_check_arg,
+ const char *field_name_arg, uint dec_arg,
+ CHARSET_INFO *cs)
+ :Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + 1,
+ null_ptr_arg, null_bit_arg, unireg_check_arg,
+ field_name_arg, cs), dec(dec_arg)
+ {
+ DBUG_ASSERT(dec);
+ DBUG_ASSERT(dec <= MAX_SEC_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);
+ double val_real(void);
+ longlong val_int(void);
+ String *val_str(String*,String *);
+ bool send_binary(Protocol *protocol);
+ int cmp(const uchar *,const uchar *);
+ void sort_string(uchar *buff,uint length);
+ uint32 pack_length() const;
+ void sql_type(String &str) const;
+ bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
+ uchar *pack(uchar *to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ { return Field::pack(to, from, max_length, low_byte_first); }
+ const uchar *unpack(uchar* to, const uchar *from, uint param_data,
+ bool low_byte_first)
+ { return Field::unpack(to, from, param_data, low_byte_first); }
+};
+
+static inline Field_timestamp *
+new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check, const char *field_name,
+ TABLE_SHARE *share, uint dec, CHARSET_INFO *cs)
+{
+ if (dec==0 || dec == NOT_FIXED_DEC)
+ return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, share, cs);
+ else
+ return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check,
+ field_name, share, dec, cs);
+}
+
+static inline Field_time *
+new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check, const char *field_name,
+ uint dec, CHARSET_INFO *cs)
+{
+ if (dec == 0 || dec == NOT_FIXED_DEC)
+ return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, cs);
+ else
+ return new Field_time_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
+}
+
+static inline Field_datetime *
+new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit,
+ enum Field::utype unireg_check,
+ const char *field_name, uint dec, CHARSET_INFO *cs)
+{
+ if (dec == 0 || dec == NOT_FIXED_DEC)
+ return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit,
+ unireg_check, field_name, cs);
+ else
+ return new Field_datetime_hires(ptr, null_ptr, null_bit,
+ unireg_check, field_name, dec, cs);
+}
+
class Field_string :public Field_longstr {
public:
bool can_alter_field_type;
@@ -1698,9 +1782,6 @@ public:
int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; }
void reset_fields() { bzero((uchar*) &value,sizeof(value)); }
uint32 get_field_buffer_size(void) { return value.alloced_length(); }
-#ifndef WORDS_BIGENDIAN
- static
-#endif
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number, bool low_byte_first);
void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number)
{
@@ -1727,7 +1808,6 @@ public:
uint32 get_length(const uchar *ptr, uint packlength, bool low_byte_first);
uint32 get_length(const uchar *ptr_arg)
{ return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
- void put_length(uchar *pos, uint32 length);
inline void get_ptr(uchar **str)
{
memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*));