Commit 2dc32c02 authored by Alexander Barkov's avatar Alexander Barkov

Removing "DTCollation user_var_entry::collation", using a CHARSET_INFO

pointer instread, as the "derivation" and "repertoire" parts of
DTCollation were not really used by user_var_entry.
parent afa17734
...@@ -3327,7 +3327,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) ...@@ -3327,7 +3327,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry)
break; break;
case STRING_RESULT: case STRING_RESULT:
{ {
CHARSET_INFO *fromcs= entry->collation.collation; CHARSET_INFO *fromcs= entry->charset();
CHARSET_INFO *tocs= thd->variables.collation_connection; CHARSET_INFO *tocs= thd->variables.collation_connection;
uint32 dummy_offset; uint32 dummy_offset;
......
...@@ -4647,7 +4647,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name, ...@@ -4647,7 +4647,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
entry->value=0; entry->value=0;
entry->length=0; entry->length=0;
entry->update_query_id=0; entry->update_query_id=0;
entry->collation.set(NULL, DERIVATION_IMPLICIT, 0); entry->set_charset(NULL);
entry->unsigned_flag= 0; entry->unsigned_flag= 0;
/* /*
If we are here, we were called from a SET or a query which sets a If we are here, we were called from a SET or a query which sets a
...@@ -4727,11 +4727,10 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref) ...@@ -4727,11 +4727,10 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
and the variable has previously been initialized. and the variable has previously been initialized.
*/ */
null_item= (args[0]->type() == NULL_ITEM); null_item= (args[0]->type() == NULL_ITEM);
if (!entry->collation.collation || !null_item) if (!entry->charset() || !null_item)
entry->collation.set(args[0]->collation.derivation == DERIVATION_NUMERIC ? entry->set_charset(args[0]->collation.derivation == DERIVATION_NUMERIC ?
default_charset() : args[0]->collation.collation, default_charset() : args[0]->collation.collation);
DERIVATION_IMPLICIT); collation.set(entry->charset(), DERIVATION_IMPLICIT);
collation.set(entry->collation.collation, DERIVATION_IMPLICIT);
cached_result_type= args[0]->result_type(); cached_result_type= args[0]->result_type();
if (thd->lex->current_select) if (thd->lex->current_select)
{ {
...@@ -4831,7 +4830,7 @@ bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg) ...@@ -4831,7 +4830,7 @@ bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg)
static bool static bool
update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
Item_result type, CHARSET_INFO *cs, Derivation dv, Item_result type, CHARSET_INFO *cs,
bool unsigned_arg) bool unsigned_arg)
{ {
if (set_null) if (set_null)
...@@ -4882,7 +4881,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, ...@@ -4882,7 +4881,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
if (type == DECIMAL_RESULT) if (type == DECIMAL_RESULT)
((my_decimal*)entry->value)->fix_buffer_pointer(); ((my_decimal*)entry->value)->fix_buffer_pointer();
entry->length= length; entry->length= length;
entry->collation.set(cs, dv); entry->set_charset(cs);
entry->unsigned_flag= unsigned_arg; entry->unsigned_flag= unsigned_arg;
} }
entry->type=type; entry->type=type;
...@@ -4893,7 +4892,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, ...@@ -4893,7 +4892,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
bool bool
Item_func_set_user_var::update_hash(void *ptr, uint length, Item_func_set_user_var::update_hash(void *ptr, uint length,
Item_result res_type, Item_result res_type,
CHARSET_INFO *cs, Derivation dv, CHARSET_INFO *cs,
bool unsigned_arg) bool unsigned_arg)
{ {
/* /*
...@@ -4903,7 +4902,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length, ...@@ -4903,7 +4902,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length,
if ((null_value= args[0]->null_value) && null_item) if ((null_value= args[0]->null_value) && null_item)
res_type= entry->type; // Don't change type of item res_type= entry->type; // Don't change type of item
if (::update_hash(entry, (null_value= args[0]->null_value), if (::update_hash(entry, (null_value= args[0]->null_value),
ptr, length, res_type, cs, dv, unsigned_arg)) ptr, length, res_type, cs, unsigned_arg))
{ {
null_value= 1; null_value= 1;
return 1; return 1;
...@@ -4983,19 +4982,19 @@ String *user_var_entry::val_str(bool *null_value, String *str, ...@@ -4983,19 +4982,19 @@ String *user_var_entry::val_str(bool *null_value, String *str,
switch (type) { switch (type) {
case REAL_RESULT: case REAL_RESULT:
str->set_real(*(double*) value, decimals, collation.collation); str->set_real(*(double*) value, decimals, charset());
break; break;
case INT_RESULT: case INT_RESULT:
if (!unsigned_flag) if (!unsigned_flag)
str->set(*(longlong*) value, collation.collation); str->set(*(longlong*) value, charset());
else else
str->set(*(ulonglong*) value, collation.collation); str->set(*(ulonglong*) value, charset());
break; break;
case DECIMAL_RESULT: case DECIMAL_RESULT:
str_set_decimal((my_decimal *) value, str, collation.collation); str_set_decimal((my_decimal *) value, str, charset());
break; break;
case STRING_RESULT: case STRING_RESULT:
if (str->copy(value, length, collation.collation)) if (str->copy(value, length, charset()))
str= 0; // EOM error str= 0; // EOM error
break; break;
case ROW_RESULT: case ROW_RESULT:
...@@ -5024,7 +5023,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val) ...@@ -5024,7 +5023,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
my_decimal2decimal((my_decimal *) value, val); my_decimal2decimal((my_decimal *) value, val);
break; break;
case STRING_RESULT: case STRING_RESULT:
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val); str2my_decimal(E_DEC_FATAL_ERROR, value, length, charset(), val);
break; break;
case ROW_RESULT: case ROW_RESULT:
case TIME_RESULT: case TIME_RESULT:
...@@ -5152,37 +5151,33 @@ Item_func_set_user_var::update() ...@@ -5152,37 +5151,33 @@ Item_func_set_user_var::update()
case REAL_RESULT: case REAL_RESULT:
{ {
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal), res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
REAL_RESULT, default_charset(), DERIVATION_IMPLICIT, 0); REAL_RESULT, default_charset(), 0);
break; break;
} }
case INT_RESULT: case INT_RESULT:
{ {
res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
INT_RESULT, default_charset(), DERIVATION_IMPLICIT, INT_RESULT, default_charset(), unsigned_flag);
unsigned_flag);
break; break;
} }
case STRING_RESULT: case STRING_RESULT:
{ {
if (!save_result.vstr) // Null value if (!save_result.vstr) // Null value
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, 0);
DERIVATION_IMPLICIT, 0);
else else
res= update_hash((void*) save_result.vstr->ptr(), res= update_hash((void*) save_result.vstr->ptr(),
save_result.vstr->length(), STRING_RESULT, save_result.vstr->length(), STRING_RESULT,
save_result.vstr->charset(), save_result.vstr->charset(), 0);
DERIVATION_IMPLICIT, 0);
break; break;
} }
case DECIMAL_RESULT: case DECIMAL_RESULT:
{ {
if (!save_result.vdec) // Null value if (!save_result.vdec) // Null value
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin, res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin, 0);
DERIVATION_IMPLICIT, 0);
else else
res= update_hash((void*) save_result.vdec, res= update_hash((void*) save_result.vdec,
sizeof(my_decimal), DECIMAL_RESULT, sizeof(my_decimal), DECIMAL_RESULT,
default_charset(), DERIVATION_IMPLICIT, 0); default_charset(), 0);
break; break;
} }
case ROW_RESULT: case ROW_RESULT:
...@@ -5576,7 +5571,7 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command, ...@@ -5576,7 +5571,7 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command,
ALIGN_SIZE(sizeof(BINLOG_USER_VAR_EVENT)); ALIGN_SIZE(sizeof(BINLOG_USER_VAR_EVENT));
user_var_event->user_var_event= var_entry; user_var_event->user_var_event= var_entry;
user_var_event->type= var_entry->type; user_var_event->type= var_entry->type;
user_var_event->charset_number= var_entry->collation.collation->number; user_var_event->charset_number= var_entry->charset()->number;
user_var_event->unsigned_flag= var_entry->unsigned_flag; user_var_event->unsigned_flag= var_entry->unsigned_flag;
if (!var_entry->value) if (!var_entry->value)
{ {
...@@ -5624,7 +5619,7 @@ void Item_func_get_user_var::fix_length_and_dec() ...@@ -5624,7 +5619,7 @@ void Item_func_get_user_var::fix_length_and_dec()
unsigned_flag= var_entry->unsigned_flag; unsigned_flag= var_entry->unsigned_flag;
max_length= var_entry->length; max_length= var_entry->length;
collation.set(var_entry->collation); collation.set(var_entry->charset(), DERIVATION_IMPLICIT);
switch (m_cached_result_type) { switch (m_cached_result_type) {
case REAL_RESULT: case REAL_RESULT:
fix_char_length(DBL_DIG + 8); fix_char_length(DBL_DIG + 8);
...@@ -5716,7 +5711,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) ...@@ -5716,7 +5711,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
of fields in LOAD DATA INFILE. of fields in LOAD DATA INFILE.
(Since Item_user_var_as_out_param is used only there). (Since Item_user_var_as_out_param is used only there).
*/ */
entry->collation.set(thd->lex->exchange->cs ? entry->set_charset(thd->lex->exchange->cs ?
thd->lex->exchange->cs : thd->lex->exchange->cs :
thd->variables.collation_database); thd->variables.collation_database);
entry->update_query_id= thd->query_id; entry->update_query_id= thd->query_id;
...@@ -5726,8 +5721,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) ...@@ -5726,8 +5721,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs) void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs)
{ {
::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, ::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, 0 /* unsigned_arg */);
DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
} }
...@@ -5735,7 +5729,7 @@ void Item_user_var_as_out_param::set_value(const char *str, uint length, ...@@ -5735,7 +5729,7 @@ void Item_user_var_as_out_param::set_value(const char *str, uint length,
CHARSET_INFO* cs) CHARSET_INFO* cs)
{ {
::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs, ::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs,
DERIVATION_IMPLICIT, 0 /* unsigned_arg */); 0 /* unsigned_arg */);
} }
......
...@@ -1696,7 +1696,7 @@ class Item_func_set_user_var :public Item_func ...@@ -1696,7 +1696,7 @@ class Item_func_set_user_var :public Item_func
my_decimal *val_decimal_result(my_decimal *); my_decimal *val_decimal_result(my_decimal *);
bool is_null_result(); bool is_null_result();
bool update_hash(void *ptr, uint length, enum Item_result type, bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg); CHARSET_INFO *cs, bool unsigned_arg);
bool send(Protocol *protocol, String *str_arg); bool send(Protocol *protocol, String *str_arg);
void make_field(Send_field *tmp_field); void make_field(Send_field *tmp_field);
bool check(bool use_result_field); bool check(bool use_result_field);
......
...@@ -7997,7 +7997,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) ...@@ -7997,7 +7997,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
a single record and with a single column. Thus, like a single record and with a single column. Thus, like
a column value, it could always have IMPLICIT derivation. a column value, it could always have IMPLICIT derivation.
*/ */
e->update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT, e->update_hash(val, val_len, type, charset,
(flags & User_var_log_event::UNSIGNED_F)); (flags & User_var_log_event::UNSIGNED_F));
if (!is_deferred()) if (!is_deferred())
free_root(thd->mem_root, 0); free_root(thd->mem_root, 0);
......
...@@ -4949,6 +4949,7 @@ class Table_ident :public Sql_alloc ...@@ -4949,6 +4949,7 @@ class Table_ident :public Sql_alloc
// this is needed for user_vars hash // this is needed for user_vars hash
class user_var_entry class user_var_entry
{ {
CHARSET_INFO *m_charset;
public: public:
user_var_entry() {} /* Remove gcc warning */ user_var_entry() {} /* Remove gcc warning */
LEX_STRING name; LEX_STRING name;
...@@ -4962,7 +4963,8 @@ class user_var_entry ...@@ -4962,7 +4963,8 @@ class user_var_entry
longlong val_int(bool *null_value) const; longlong val_int(bool *null_value) const;
String *val_str(bool *null_value, String *str, uint decimals); String *val_str(bool *null_value, String *str, uint decimals);
my_decimal *val_decimal(bool *null_value, my_decimal *result); my_decimal *val_decimal(bool *null_value, my_decimal *result);
DTCollation collation; CHARSET_INFO *charset() const { return m_charset; }
void set_charset(CHARSET_INFO *cs) { m_charset= cs; }
}; };
user_var_entry *get_variable(HASH *hash, LEX_STRING &name, user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment