diff options
author | unknown <bell@sanja.is.com.ua> | 2004-03-18 15:14:36 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-03-18 15:14:36 +0200 |
commit | 1a81e0414515cef6275b5d2f3f27b950aa1ff91f (patch) | |
tree | cd9a05b7a39b8aa75fa136b3e98ef798762bbcb8 /sql/item.h | |
parent | f83cf4144065c12cad4007767e2e70d444fd0e05 (diff) | |
download | mariadb-git-1a81e0414515cef6275b5d2f3f27b950aa1ff91f.tar.gz |
DBUG_ASSERT(fixed == 1); added to val*
small optimisation in signed_literal
sql/field.cc:
layout fixed
sql/item.cc:
DBUG_ASSERT(fixed == 1); added to val*
layout fixed
fixed= 1; added where it was forgoten in fix_fields
Item_string can be used without fix_fields
sql/item.h:
DBUG_ASSERT(fixed == 1); added to val*
Item_string can be used without fix_fields
sql/item_cmpfunc.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_cmpfunc.h:
fixed layout and getting Item statistic
sql/item_func.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_func.h:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_geofunc.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_strfunc.cc:
DBUG_ASSERT(fixed == 1); added to val*
layout fixed
sql/item_strfunc.h:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_subselect.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_sum.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_sum.h:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_timefunc.cc:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_timefunc.h:
DBUG_ASSERT(fixed == 1); added to val*
sql/item_uniq.h:
DBUG_ASSERT(fixed == 1); added to val*
sql/sql_base.cc:
Item creation revised
sql/sql_help.cc:
Item creation revised
sql/sql_load.cc:
Item creation revised
sql/sql_parse.cc:
fix_field call added
sql/sql_select.cc:
Item creation revised
sql/sql_show.cc:
Item creation revised
sql/sql_union.cc:
Item creation revised
sql/sql_update.cc:
Item creation revised
sql/sql_yacc.yy:
Item creation revised
small optimisation in signed_literal
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/sql/item.h b/sql/item.h index 27f427c1ef4..7bf3bd07436 100644 --- a/sql/item.h +++ b/sql/item.h @@ -281,7 +281,7 @@ public: { collation.set(DERIVATION_IMPLICIT); } // Constructor need to process subselect with temporary tables (see Item) Item_field(THD *thd, Item_field *item); - Item_field(Field *field); + Item_field(Field *field, bool already_fixed); enum Type type() const { return FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; double val(); @@ -417,8 +417,8 @@ public: enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } - longlong val_int() { return value; } - double val() { return (double) value; } + longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } + double val() { DBUG_ASSERT(fixed == 1); return (double) value; } String *val_str(String*); int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } @@ -437,7 +437,8 @@ public: { fixed= 0; } Item_uint(uint32 i) :Item_int((longlong) i, 10) { fixed= 0; } - double val() { return ulonglong2double((ulonglong)value); } + double val() + { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); } String *val_str(String*); Item *new_item() { return new Item_uint(name,max_length); } int save_in_field(Field *field, bool no_conversions); @@ -474,8 +475,12 @@ public: int save_in_field(Field *field, bool no_conversions); enum Type type() const { return REAL_ITEM; } enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; } - double val() { return value; } - longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5));} + double val() { DBUG_ASSERT(fixed == 1); return value; } + longlong val_int() + { + DBUG_ASSERT(fixed == 1); + return (longlong) (value+(value > 0 ? 0.5 : -0.5)); + } String *val_str(String*); bool basic_const_item() const { return 1; } Item *new_item() { return new Item_real(name,value,decimals,max_length); } @@ -510,6 +515,8 @@ public: max_length= str_value.numchars()*cs->mbmaxlen; set_name(str, length, cs); decimals=NOT_FIXED_DEC; + // it is constant => can be used without fix_fields (and frequently used) + fixed= 1; } Item_string(const char *name_par, const char *str, uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) @@ -519,21 +526,29 @@ public: max_length= str_value.numchars()*cs->mbmaxlen; set_name(name_par,0,cs); decimals=NOT_FIXED_DEC; + // it is constant => can be used without fix_fields (and frequently used) + fixed= 1; } enum Type type() const { return STRING_ITEM; } double val() - { + { + DBUG_ASSERT(fixed == 1); int err; return my_strntod(str_value.charset(), (char*) str_value.ptr(), str_value.length(), (char**) 0, &err); } longlong val_int() { + DBUG_ASSERT(fixed == 1); int err; return my_strntoll(str_value.charset(), str_value.ptr(), str_value.length(), 10, (char**) 0, &err); } - String *val_str(String*) { return (String*) &str_value; } + String *val_str(String*) + { + DBUG_ASSERT(fixed == 1); + return (String*) &str_value; + } int save_in_field(Field *field, bool no_conversions); enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_STRING; } @@ -547,6 +562,11 @@ public: String *const_string() { return &str_value; } inline void append(char *str, uint length) { str_value.append(str, length); } void print(String *str); + void cleanup() + { + // it is constant => can be used without fix_fields (and frequently used) + fixed= 1; + } }; /* for show tables */ @@ -588,9 +608,10 @@ class Item_varbinary :public Item public: Item_varbinary(const char *str,uint str_length); enum Type type() const { return VARBIN_ITEM; } - double val() { return (double) Item_varbinary::val_int(); } + double val() + { DBUG_ASSERT(fixed == 1); return (double) Item_varbinary::val_int(); } longlong val_int(); - String *val_str(String*) { return &str_value; } + String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; } int save_in_field(Field *field, bool no_conversions); enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_STRING; } @@ -929,9 +950,14 @@ public: Item_cache_int(): Item_cache() {} void store(Item *item); - double val() { return (double) value; } - longlong val_int() { return value; } - String* val_str(String *str) { str->set(value, default_charset()); return str; } + double val() { DBUG_ASSERT(fixed == 1); return (double) value; } + longlong val_int() { DBUG_ASSERT(fixed == 1); return value; } + String* val_str(String *str) + { + DBUG_ASSERT(fixed == 1); + str->set(value, default_charset()); + return str; + } enum Item_result result_type() const { return INT_RESULT; } }; @@ -942,8 +968,12 @@ public: Item_cache_real(): Item_cache() {} void store(Item *item); - double val() { return value; } - longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } + double val() { DBUG_ASSERT(fixed == 1); return value; } + longlong val_int() + { + DBUG_ASSERT(fixed == 1); + return (longlong) (value+(value > 0 ? 0.5 : -0.5)); + } String* val_str(String *str) { str->set(value, decimals, default_charset()); @@ -962,7 +992,7 @@ public: void store(Item *item); double val(); longlong val_int(); - String* val_str(String *) { return value; } + String* val_str(String *) { DBUG_ASSERT(fixed == 1); return value; } enum Item_result result_type() const { return STRING_RESULT; } CHARSET_INFO *charset() const { return value->charset(); }; }; |