mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 23:25:34 +02:00
Give store_for_compare a more meaningful name, cleanup and comment the
call. sql/item_cmpfunc.cc: Rename: Field::store_for_compare -> Field::can_be_compared_as_longlong
This commit is contained in:
parent
34ac282efd
commit
9131bd2404
2 changed files with 18 additions and 11 deletions
23
sql/field.h
23
sql/field.h
|
|
@ -179,7 +179,14 @@ public:
|
||||||
virtual void make_field(Send_field *)=0;
|
virtual void make_field(Send_field *)=0;
|
||||||
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);
|
||||||
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() {}
|
virtual void free() {}
|
||||||
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
|
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
|
||||||
{
|
{
|
||||||
|
|
@ -566,7 +573,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 8; }
|
uint32 pack_length() const { return 8; }
|
||||||
void sql_type(String &str) const;
|
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; }
|
uint32 max_length() { return 20; }
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_LONGLONG; }
|
||||||
};
|
};
|
||||||
|
|
@ -694,7 +701,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 4; }
|
uint32 pack_length() const { return 4; }
|
||||||
void sql_type(String &str) const;
|
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; }
|
bool zero_pack() const { return 0; }
|
||||||
void set_time();
|
void set_time();
|
||||||
virtual void set_default()
|
virtual void set_default()
|
||||||
|
|
@ -740,7 +747,7 @@ public:
|
||||||
String *val_str(String*,String *);
|
String *val_str(String*,String *);
|
||||||
bool send_binary(Protocol *protocol);
|
bool send_binary(Protocol *protocol);
|
||||||
void sql_type(String &str) const;
|
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; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_YEAR; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -772,7 +779,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 4; }
|
uint32 pack_length() const { return 4; }
|
||||||
void sql_type(String &str) const;
|
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 zero_pack() const { return 1; }
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_DATE; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_DATE; }
|
||||||
};
|
};
|
||||||
|
|
@ -802,7 +809,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 3; }
|
uint32 pack_length() const { return 3; }
|
||||||
void sql_type(String &str) const;
|
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 zero_pack() const { return 1; }
|
||||||
bool get_date(TIME *ltime,uint fuzzydate);
|
bool get_date(TIME *ltime,uint fuzzydate);
|
||||||
bool get_time(TIME *ltime);
|
bool get_time(TIME *ltime);
|
||||||
|
|
@ -839,7 +846,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 3; }
|
uint32 pack_length() const { return 3; }
|
||||||
void sql_type(String &str) const;
|
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 zero_pack() const { return 1; }
|
||||||
field_cast_enum field_cast_type() { return FIELD_CAST_TIME; }
|
field_cast_enum field_cast_type() { return FIELD_CAST_TIME; }
|
||||||
};
|
};
|
||||||
|
|
@ -875,7 +882,7 @@ public:
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return 8; }
|
uint32 pack_length() const { return 8; }
|
||||||
void sql_type(String &str) const;
|
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 zero_pack() const { return 1; }
|
||||||
bool get_date(TIME *ltime,uint fuzzydate);
|
bool get_date(TIME *ltime,uint fuzzydate);
|
||||||
bool get_time(TIME *ltime);
|
bool get_time(TIME *ltime);
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ void Item_bool_func2::fix_length_and_dec()
|
||||||
if (args[0]->type() == FIELD_ITEM)
|
if (args[0]->type() == FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Field *field=((Item_field*) args[0])->field;
|
Field *field=((Item_field*) args[0])->field;
|
||||||
if (field->store_for_compare())
|
if (field->can_be_compared_as_longlong())
|
||||||
{
|
{
|
||||||
if (convert_constant_item(field,&args[1]))
|
if (convert_constant_item(field,&args[1]))
|
||||||
{
|
{
|
||||||
|
|
@ -256,7 +256,7 @@ void Item_bool_func2::fix_length_and_dec()
|
||||||
if (args[1]->type() == FIELD_ITEM)
|
if (args[1]->type() == FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Field *field=((Item_field*) args[1])->field;
|
Field *field=((Item_field*) args[1])->field;
|
||||||
if (field->store_for_compare())
|
if (field->can_be_compared_as_longlong())
|
||||||
{
|
{
|
||||||
if (convert_constant_item(field,&args[0]))
|
if (convert_constant_item(field,&args[0]))
|
||||||
{
|
{
|
||||||
|
|
@ -856,7 +856,7 @@ void Item_func_between::fix_length_and_dec()
|
||||||
if (args[0]->type() == FIELD_ITEM)
|
if (args[0]->type() == FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Field *field=((Item_field*) args[0])->field;
|
Field *field=((Item_field*) args[0])->field;
|
||||||
if (field->store_for_compare())
|
if (field->can_be_compared_as_longlong())
|
||||||
{
|
{
|
||||||
if (convert_constant_item(field,&args[1]))
|
if (convert_constant_item(field,&args[1]))
|
||||||
cmp_type=INT_RESULT; // Works for all types.
|
cmp_type=INT_RESULT; // Works for all types.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue