summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2015-10-07 20:19:29 +0400
committerAlexander Barkov <bar@mariadb.org>2015-10-07 20:19:29 +0400
commit87777249017b691ac9a114ae134afa7bbf8d8591 (patch)
tree413875a525faa62a2651cf6ab7f25ba804d30bf6 /sql/item_func.h
parent8afe96f011eb8037a92b4b3aab16118b0771ad50 (diff)
downloadmariadb-git-87777249017b691ac9a114ae134afa7bbf8d8591.tar.gz
MDEV-8912 Wrong metadata or type for @c:=string_or_blob_field
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h71
1 files changed, 51 insertions, 20 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 917ae0ed02e..921063f8809 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -175,6 +175,12 @@ public:
friend class udf_handler;
Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg);
+ Field *create_field_for_create_select(THD *thd, TABLE *table)
+ {
+ return result_type() != STRING_RESULT ?
+ tmp_table_field(table) :
+ tmp_table_field_from_field_type(table, false, false);
+ }
Item *get_tmp_table_item(THD *thd);
my_decimal *val_decimal(my_decimal *);
@@ -1618,10 +1624,39 @@ public:
class user_var_entry;
-class Item_func_set_user_var :public Item_func
+
+/**
+ A class to set and get user variables
+*/
+class Item_func_user_var :public Item_func,
+ public Type_handler_hybrid_field_type
+{
+protected:
+ user_var_entry *m_var_entry;
+public:
+ LEX_STRING name; // keep it public
+ Item_func_user_var(THD *thd, LEX_STRING a)
+ :Item_func(thd), m_var_entry(NULL), name(a) { }
+ Item_func_user_var(THD *thd, LEX_STRING a, Item *b)
+ :Item_func(thd, b), m_var_entry(NULL), name(a) { }
+ Item_func_user_var(THD *thd, Item_func_user_var *item)
+ :Item_func(thd, item),
+ m_var_entry(item->m_var_entry), name(item->name)
+ {
+ set_handler_by_result_type(item->result_type());
+ }
+ enum Item_result cmp_type() const
+ { return Type_handler_hybrid_field_type::cmp_type(); }
+ enum Item_result result_type() const
+ { return Type_handler_hybrid_field_type::result_type(); }
+ enum_field_types field_type() const
+ { return Type_handler_hybrid_field_type::field_type(); }
+ bool check_vcol_func_processor(uchar *int_arg) { return true; }
+};
+
+
+class Item_func_set_user_var :public Item_func_user_var
{
- enum Item_result cached_result_type;
- user_var_entry *entry;
/*
The entry_thread_id variable is used:
1) to skip unnecessary updates of the entry field (see above);
@@ -1646,17 +1681,15 @@ class Item_func_set_user_var :public Item_func
} save_result;
public:
- LEX_STRING name; // keep it public
Item_func_set_user_var(THD *thd, LEX_STRING a, Item *b):
- Item_func(thd, b), cached_result_type(INT_RESULT),
- entry(NULL), entry_thread_id(0), name(a)
+ Item_func_user_var(thd, a, b),
+ entry_thread_id(0)
{}
Item_func_set_user_var(THD *thd, Item_func_set_user_var *item)
- :Item_func(thd, item), cached_result_type(item->cached_result_type),
- entry(item->entry), entry_thread_id(item->entry_thread_id),
+ :Item_func_user_var(thd, item),
+ entry_thread_id(item->entry_thread_id),
value(item->value), decimal_buff(item->decimal_buff),
- null_item(item->null_item), save_result(item->save_result),
- name(item->name)
+ null_item(item->null_item), save_result(item->save_result)
{}
enum Functype functype() const { return SUSERVAR_FUNC; }
@@ -1677,9 +1710,14 @@ public:
bool check(bool use_result_field);
void save_item_result(Item *item);
bool update();
- enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
+ Field *create_field_for_create_select(THD *thd, TABLE *table)
+ {
+ return result_type() != STRING_RESULT ?
+ tmp_table_field(table) :
+ tmp_table_field_from_field_type(table, false, true);
+ }
table_map used_tables() const
{
return Item_func::used_tables() | RAND_TABLE_BIT;
@@ -1702,20 +1740,15 @@ public:
bool register_field_in_bitmap(uchar *arg);
bool set_entry(THD *thd, bool create_if_not_exists);
void cleanup();
- bool check_vcol_func_processor(uchar *int_arg) {return TRUE;}
};
-class Item_func_get_user_var :public Item_func,
+class Item_func_get_user_var :public Item_func_user_var,
private Settable_routine_parameter
{
- user_var_entry *var_entry;
- Item_result m_cached_result_type;
-
public:
- LEX_STRING name; // keep it public
Item_func_get_user_var(THD *thd, LEX_STRING a):
- Item_func(thd), m_cached_result_type(STRING_RESULT), name(a) {}
+ Item_func_user_var(thd, a) {}
enum Functype functype() const { return GUSERVAR_FUNC; }
LEX_STRING get_name() { return name; }
double val_real();
@@ -1724,7 +1757,6 @@ public:
String *val_str(String* str);
void fix_length_and_dec();
virtual void print(String *str, enum_query_type query_type);
- enum Item_result result_type() const;
/*
We must always return variables as strings to guard against selects of type
select @t1:=1,@t1,@t:="hello",@t from foo where (@t1:= t2.b)
@@ -1742,7 +1774,6 @@ public:
{
return this;
}
- bool check_vcol_func_processor(uchar *int_arg) { return TRUE;}
};