summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/sql/field.h b/sql/field.h
index 725e962ca07..50ea1450085 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -179,7 +179,14 @@ public:
virtual void make_field(Send_field *)=0;
virtual void sort_string(char *buff,uint length)=0;
virtual bool optimize_range(uint idx, uint part);
- virtual bool store_for_compare() { return 0; }
+ /*
+ 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() {}
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
{
@@ -568,7 +575,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
uint32 max_length() { return 20; }
field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; }
};
@@ -678,6 +685,7 @@ public:
class Field_timestamp :public Field_str {
public:
Field_timestamp(char *ptr_arg, uint32 len_arg,
+ uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg,
CHARSET_INFO *cs);
@@ -696,7 +704,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 0; }
void set_time();
virtual void set_default()
@@ -707,8 +715,11 @@ public:
else
Field::set_default();
}
- inline long get_timestamp()
+ /* Get TIMESTAMP field value as seconds since begging of Unix Epoch */
+ inline long get_timestamp(my_bool *null_value)
{
+ if ((*null_value= is_null()))
+ return 0;
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
return sint4korr(ptr);
@@ -720,7 +731,7 @@ public:
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
field_cast_enum field_cast_type() { return FIELD_CAST_TIMESTAMP; }
- void set_timestamp_offsets();
+ timestamp_auto_set_type get_auto_set_type() const;
};
@@ -742,7 +753,7 @@ public:
String *val_str(String*,String *);
bool send_binary(Protocol *protocol);
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; }
};
@@ -774,7 +785,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 4; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
field_cast_enum field_cast_type() { return FIELD_CAST_DATE; }
};
@@ -804,7 +815,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
@@ -841,7 +852,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 3; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
field_cast_enum field_cast_type() { return FIELD_CAST_TIME; }
};
@@ -877,7 +888,7 @@ public:
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
- bool store_for_compare() { return 1; }
+ bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
bool get_date(TIME *ltime,uint fuzzydate);
bool get_time(TIME *ltime);
@@ -918,7 +929,6 @@ public:
void sort_string(char *buff,uint length);
void sql_type(String &str) const;
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
- char *pack_key(char *to, const char *from, uint max_length);
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 *b,uint key_length);