summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-07-16 00:01:44 +0300
committerunknown <bell@sanja.is.com.ua>2005-07-16 00:01:44 +0300
commite84229b010b279802efca085d689de105fdcf0ad (patch)
treede6fdc4eef81f0fdbebcb593058845bff65263d0 /sql/item.cc
parent5ae3967c878ac7cfb8475eeeb50c2ebd81f39cf6 (diff)
downloadmariadb-git-e84229b010b279802efca085d689de105fdcf0ad.tar.gz
stop evaluation constant functions in WHERE (BUG#4663)
correct value of CURRENT_USER() in SP with "security definer" (BUG#7291) BitKeeper/etc/config: switch off open logging mysql-test/r/sp-security.result: correct value from current_user() in function run from "security definer" mysql-test/r/view.result: evaluation constant functions in WHERE (BUG#4663) mysql-test/t/sp-security.test: correct value from current_user() in function run from "security definer" mysql-test/t/view.test: evaluation constant functions in WHERE (BUG#4663) sql/item.cc: Item_static_string_func creation if it is need sql/item.h: support of Item_static_string_func creation sql/item_cmpfunc.cc: do not evaluate items during view creation sql/item_create.cc: create Item_func_user sql/item_strfunc.cc: Item_func_sysconst in case of converting value still have to correctly print itself => use Item_static_string_func instead of Item_string Item_func_user return USER() or CURRENT_USER() sql/item_strfunc.h: support of correct charset conversion procedure in Item_func_sysconst sql/sql_class.h: new method sql/sql_yacc.yy: Item_func_user now support both USER() and CURRENT_USER(), so we have to pass parametr what it is
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index d3888cef9d5..7fbeb6f15db 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -635,6 +635,33 @@ Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
}
+Item *Item_static_string_func::safe_charset_converter(CHARSET_INFO *tocs)
+{
+ Item_string *conv;
+ uint conv_errors;
+ String tmp, cstr, *ostr= val_str(&tmp);
+ cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
+ if (conv_errors ||
+ !(conv= new Item_static_string_func(func_name,
+ cstr.ptr(), cstr.length(),
+ cstr.charset(),
+ collation.derivation)))
+ {
+ /*
+ Safe conversion is not possible (or EOM).
+ We could not convert a string into the requested character set
+ without data loss. The target charset does not cover all the
+ characters from the string. Operation cannot be done correctly.
+ */
+ return NULL;
+ }
+ conv->str_value.copy();
+ /* Ensure that no one is going to change the result string */
+ conv->str_value.mark_as_const();
+ return conv;
+}
+
+
bool Item_string::eq(const Item *item, bool binary_cmp) const
{
if (type() == item->type() && item->basic_const_item())