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)
break;
case STRING_RESULT:
{
CHARSET_INFO *fromcs= entry->collation.collation;
CHARSET_INFO *fromcs= entry->charset();
CHARSET_INFO *tocs= thd->variables.collation_connection;
uint32 dummy_offset;
......
......@@ -4647,7 +4647,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
entry->value=0;
entry->length=0;
entry->update_query_id=0;
entry->collation.set(NULL, DERIVATION_IMPLICIT, 0);
entry->set_charset(NULL);
entry->unsigned_flag= 0;
/*
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)
and the variable has previously been initialized.
*/
null_item= (args[0]->type() == NULL_ITEM);
if (!entry->collation.collation || !null_item)
entry->collation.set(args[0]->collation.derivation == DERIVATION_NUMERIC ?
default_charset() : args[0]->collation.collation,
DERIVATION_IMPLICIT);
collation.set(entry->collation.collation, DERIVATION_IMPLICIT);
if (!entry->charset() || !null_item)
entry->set_charset(args[0]->collation.derivation == DERIVATION_NUMERIC ?
default_charset() : args[0]->collation.collation);
collation.set(entry->charset(), DERIVATION_IMPLICIT);
cached_result_type= args[0]->result_type();
if (thd->lex->current_select)
{
......@@ -4831,7 +4830,7 @@ bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg)
static bool
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)
{
if (set_null)
......@@ -4882,7 +4881,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
if (type == DECIMAL_RESULT)
((my_decimal*)entry->value)->fix_buffer_pointer();
entry->length= length;
entry->collation.set(cs, dv);
entry->set_charset(cs);
entry->unsigned_flag= unsigned_arg;
}
entry->type=type;
......@@ -4893,7 +4892,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
bool
Item_func_set_user_var::update_hash(void *ptr, uint length,
Item_result res_type,
CHARSET_INFO *cs, Derivation dv,
CHARSET_INFO *cs,
bool unsigned_arg)
{
/*
......@@ -4903,7 +4902,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length,
if ((null_value= args[0]->null_value) && null_item)
res_type= entry->type; // Don't change type of item
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;
return 1;
......@@ -4983,19 +4982,19 @@ String *user_var_entry::val_str(bool *null_value, String *str,
switch (type) {
case REAL_RESULT:
str->set_real(*(double*) value, decimals, collation.collation);
str->set_real(*(double*) value, decimals, charset());
break;
case INT_RESULT:
if (!unsigned_flag)
str->set(*(longlong*) value, collation.collation);
str->set(*(longlong*) value, charset());
else
str->set(*(ulonglong*) value, collation.collation);
str->set(*(ulonglong*) value, charset());
break;
case DECIMAL_RESULT:
str_set_decimal((my_decimal *) value, str, collation.collation);
str_set_decimal((my_decimal *) value, str, charset());
break;
case STRING_RESULT:
if (str->copy(value, length, collation.collation))
if (str->copy(value, length, charset()))
str= 0; // EOM error
break;
case ROW_RESULT:
......@@ -5024,7 +5023,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
my_decimal2decimal((my_decimal *) value, val);
break;
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;
case ROW_RESULT:
case TIME_RESULT:
......@@ -5152,37 +5151,33 @@ Item_func_set_user_var::update()
case REAL_RESULT:
{
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
REAL_RESULT, default_charset(), DERIVATION_IMPLICIT, 0);
REAL_RESULT, default_charset(), 0);
break;
}
case INT_RESULT:
{
res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
INT_RESULT, default_charset(), DERIVATION_IMPLICIT,
unsigned_flag);
INT_RESULT, default_charset(), unsigned_flag);
break;
}
case STRING_RESULT:
{
if (!save_result.vstr) // Null value
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
DERIVATION_IMPLICIT, 0);
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, 0);
else
res= update_hash((void*) save_result.vstr->ptr(),
save_result.vstr->length(), STRING_RESULT,
save_result.vstr->charset(),
DERIVATION_IMPLICIT, 0);
save_result.vstr->charset(), 0);
break;
}
case DECIMAL_RESULT:
{
if (!save_result.vdec) // Null value
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
DERIVATION_IMPLICIT, 0);
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin, 0);
else
res= update_hash((void*) save_result.vdec,
sizeof(my_decimal), DECIMAL_RESULT,
default_charset(), DERIVATION_IMPLICIT, 0);
default_charset(), 0);
break;
}
case ROW_RESULT:
......@@ -5576,7 +5571,7 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command,
ALIGN_SIZE(sizeof(BINLOG_USER_VAR_EVENT));
user_var_event->user_var_event= var_entry;
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;
if (!var_entry->value)
{
......@@ -5624,7 +5619,7 @@ void Item_func_get_user_var::fix_length_and_dec()
unsigned_flag= var_entry->unsigned_flag;
max_length= var_entry->length;
collation.set(var_entry->collation);
collation.set(var_entry->charset(), DERIVATION_IMPLICIT);
switch (m_cached_result_type) {
case REAL_RESULT:
fix_char_length(DBL_DIG + 8);
......@@ -5716,9 +5711,9 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
of fields in LOAD DATA INFILE.
(Since Item_user_var_as_out_param is used only there).
*/
entry->collation.set(thd->lex->exchange->cs ?
thd->lex->exchange->cs :
thd->variables.collation_database);
entry->set_charset(thd->lex->exchange->cs ?
thd->lex->exchange->cs :
thd->variables.collation_database);
entry->update_query_id= thd->query_id;
return FALSE;
}
......@@ -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)
{
::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs,
DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, 0 /* unsigned_arg */);
}
......@@ -5735,7 +5729,7 @@ void Item_user_var_as_out_param::set_value(const char *str, uint length,
CHARSET_INFO* 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
my_decimal *val_decimal_result(my_decimal *);
bool is_null_result();
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);
void make_field(Send_field *tmp_field);
bool check(bool use_result_field);
......
......@@ -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 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));
if (!is_deferred())
free_root(thd->mem_root, 0);
......
......@@ -4949,6 +4949,7 @@ class Table_ident :public Sql_alloc
// this is needed for user_vars hash
class user_var_entry
{
CHARSET_INFO *m_charset;
public:
user_var_entry() {} /* Remove gcc warning */
LEX_STRING name;
......@@ -4962,7 +4963,8 @@ class user_var_entry
longlong val_int(bool *null_value) const;
String *val_str(bool *null_value, String *str, uint decimals);
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,
......
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