summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorbar@mysql.com <>2004-11-05 13:37:36 +0400
committerbar@mysql.com <>2004-11-05 13:37:36 +0400
commit5543f312b046045d7cdbd0e3357ba4ea0efe3842 (patch)
tree2dc75c5933d9dbd60558ce6c8f7a9fbaf9e0499d /sql/item_func.cc
parent4fa3d8eb0d5746801d84bd29d56b864adb07c96b (diff)
downloadmariadb-git-5543f312b046045d7cdbd0e3357ba4ea0efe3842.tar.gz
As it is wrong and confusing to associate any
character set with NULL, @a should be latin2 after this query sequence: SET @a=_latin2'string'; SET @a=NULL; I.e. the second query should not change the charset to the current default value, but should keep the original value assigned during the first query. In order to do it, we don't copy charset from the argument if the argument is NULL and the variable has previously been initialized.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 09d7e50eaa3..b382dbf7bf9 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -2340,6 +2340,7 @@ static 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_NONE);
/*
If we are here, we were called from a SET or a query which sets a
variable. Imagine it is this:
@@ -2381,7 +2382,24 @@ bool Item_func_set_user_var::fix_fields(THD *thd, TABLE_LIST *tables,
is different from query_id).
*/
entry->update_query_id= thd->query_id;
- entry->collation.set(args[0]->collation);
+ /*
+ As it is wrong and confusing to associate any
+ character set with NULL, @a should be latin2
+ after this query sequence:
+
+ SET @a=_latin2'string';
+ SET @a=NULL;
+
+ I.e. the second query should not change the charset
+ to the current default value, but should keep the
+ original value assigned during the first query.
+ In order to do it, we don't copy charset
+ from the argument if the argument is NULL
+ and the variable has previously been initialized.
+ */
+ if (!entry->collation.collation || !args[0]->null_value)
+ entry->collation.set(args[0]->collation);
+ collation.set(entry->collation);
cached_result_type= args[0]->result_type();
return 0;
}
@@ -2409,7 +2427,6 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length,
my_free(entry->value,MYF(0));
entry->value=0;
entry->length=0;
- entry->collation.set(cs, dv);
}
else
{