summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorEvgeny Potemkin <epotemkin@mysql.com>2009-12-01 22:41:39 +0300
committerEvgeny Potemkin <epotemkin@mysql.com>2009-12-01 22:41:39 +0300
commit9e5d1bb6647c88e5a60c2a3e7eadc76fd1089135 (patch)
tree1d06fec7c3a7a43683dba7f07e68c2d244161127 /sql/item.h
parentad36684576874b2eecdc2b1055e017285cae0f75 (diff)
parentc81e23457aca99ea760fbd9143e22b95bb1a7cf2 (diff)
downloadmariadb-git-9e5d1bb6647c88e5a60c2a3e7eadc76fd1089135.tar.gz
Auto-merged fix for the bug#34384.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h50
1 files changed, 35 insertions, 15 deletions
diff --git a/sql/item.h b/sql/item.h
index 72e4e37342a..f69fa742744 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1032,7 +1032,11 @@ class sp_head;
class Item_basic_constant :public Item
{
+ table_map used_table_map;
public:
+ Item_basic_constant(): Item(), used_table_map(0) {};
+ void set_used_tables(table_map map) { used_table_map= map; }
+ table_map used_tables() const { return used_table_map; }
/* to prevent drop fixed flag (no need parent cleanup call) */
void cleanup()
{
@@ -2918,15 +2922,25 @@ protected:
*/
Field *cached_field;
enum enum_field_types cached_field_type;
+ /*
+ TRUE <=> cache holds value of the last stored item (i.e actual value).
+ store() stores item to be cached and sets this flag to FALSE.
+ On the first call of val_xxx function if this flag is set to FALSE the
+ cache_value() will be called to actually cache value of saved item.
+ cache_value() will set this flag to TRUE.
+ */
+ bool value_cached;
public:
- Item_cache():
- example(0), used_table_map(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING)
+ Item_cache():
+ example(0), used_table_map(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING),
+ value_cached(0)
{
fixed= 1;
null_value= 1;
}
Item_cache(enum_field_types field_type_arg):
- example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg)
+ example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg),
+ value_cached(0)
{
fixed= 1;
null_value= 1;
@@ -2946,10 +2960,10 @@ public:
cached_field= ((Item_field *)item)->field;
return 0;
};
- virtual void store(Item *)= 0;
enum Type type() const { return CACHE_ITEM; }
enum_field_types field_type() const { return cached_field_type; }
static Item_cache* get_cache(const Item *item);
+ static Item_cache* get_cache(const Item* item, const Item_result type);
table_map used_tables() const { return used_table_map; }
virtual void keep_array() {}
virtual void print(String *str, enum_query_type query_type);
@@ -2961,6 +2975,8 @@ public:
{
return this == item;
}
+ virtual void store(Item *item);
+ virtual void cache_value()= 0;
};
@@ -2969,18 +2985,19 @@ class Item_cache_int: public Item_cache
protected:
longlong value;
public:
- Item_cache_int(): Item_cache(), value(0) {}
+ Item_cache_int(): Item_cache(),
+ value(0) {}
Item_cache_int(enum_field_types field_type_arg):
Item_cache(field_type_arg), value(0) {}
- void store(Item *item);
void store(Item *item, longlong val_arg);
- double val_real() { DBUG_ASSERT(fixed == 1); return (double) value; }
- longlong val_int() { DBUG_ASSERT(fixed == 1); return value; }
+ double val_real();
+ longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return INT_RESULT; }
bool result_as_longlong() { return TRUE; }
+ void cache_value();
};
@@ -2988,14 +3005,15 @@ class Item_cache_real: public Item_cache
{
double value;
public:
- Item_cache_real(): Item_cache(), value(0) {}
+ Item_cache_real(): Item_cache(),
+ value(0) {}
- void store(Item *item);
- double val_real() { DBUG_ASSERT(fixed == 1); return value; }
+ double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return REAL_RESULT; }
+ void cache_value();
};
@@ -3006,12 +3024,12 @@ protected:
public:
Item_cache_decimal(): Item_cache() {}
- void store(Item *item);
double val_real();
longlong val_int();
String* val_str(String *str);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return DECIMAL_RESULT; }
+ void cache_value();
};
@@ -3029,14 +3047,14 @@ public:
MYSQL_TYPE_VARCHAR &&
!((const Item_field *) item)->field->has_charset())
{}
- void store(Item *item);
double val_real();
longlong val_int();
- String* val_str(String *) { DBUG_ASSERT(fixed == 1); return value; }
+ String* val_str(String *);
my_decimal *val_decimal(my_decimal *);
enum Item_result result_type() const { return STRING_RESULT; }
CHARSET_INFO *charset() const { return value->charset(); };
int save_in_field(Field *field, bool no_conversions);
+ void cache_value();
};
class Item_cache_row: public Item_cache
@@ -3046,7 +3064,8 @@ class Item_cache_row: public Item_cache
bool save_array;
public:
Item_cache_row()
- :Item_cache(), values(0), item_count(2), save_array(0) {}
+ :Item_cache(), values(0), item_count(2),
+ save_array(0) {}
/*
'allocate' used only in row transformer, to preallocate space for row
@@ -3104,6 +3123,7 @@ public:
values= 0;
DBUG_VOID_RETURN;
}
+ void cache_value();
};