diff options
author | unknown <malff/marcsql@weblab.(none)> | 2006-11-16 09:03:47 -0700 |
---|---|---|
committer | unknown <malff/marcsql@weblab.(none)> | 2006-11-16 09:03:47 -0700 |
commit | 2975d65cd86dea288d968c55fd0ffd177a92f390 (patch) | |
tree | 97166381743b2b830ba8d62a7acf0f37382a39ac /sql/item_create.cc | |
parent | 12ed25e7e38c40c231b4752b918bcb5937d900bd (diff) | |
download | mariadb-git-2975d65cd86dea288d968c55fd0ffd177a92f390.tar.gz |
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
Before this change, the functions BENCHMARK, ENCODE, DECODE and FORMAT could
only accept a constant for some parameters.
After this change, this restriction has been removed. An implication is that
these functions can also be used in prepared statements.
The change consist of changing the following classes:
- Item_func_benchmark
- Item_func_encode
- Item_func_decode
- Item_func_format
to:
- only accept Item* in the constructor,
- and evaluate arguments during calls to val_xxx()
which fits the general design of all the other functions.
The 'TODO' items identified in item_create.cc during the work done for
Bug 21114 are addressed by this fix, as a natural consequence of aligning
the design.
In the 'func_str' test, a single very long test line involving an explain
extended select with many functions has been rewritten into multiple
separate tests, to improve maintainability.
The result of explain extended select decode(encode(...)) has changed,
since the encode and decode functions now print all their parameters.
mysql-test/r/func_str.result:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
mysql-test/r/parser.result:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
mysql-test/r/ps.result:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
mysql-test/t/func_str.test:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
mysql-test/t/parser.test:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
mysql-test/t/ps.test:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
sql/item_create.cc:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
sql/item_func.cc:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
sql/item_func.h:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
sql/item_strfunc.cc:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
sql/item_strfunc.h:
Bug#22684 (BENCHMARK, ENCODE, DECODE and FORMAT are not real functions)
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r-- | sql/item_create.cc | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc index 7722ce28d4a..da8954910c8 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -2612,15 +2612,8 @@ Create_func_benchmark Create_func_benchmark::s_singleton; Item* Create_func_benchmark::create(THD *thd, Item *arg1, Item *arg2) { - /* TODO: Known limitation, see Bug#22684 */ - if ((arg1->type() != Item::INT_ITEM) || ! arg1->basic_const_item()) - { - my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), "BENCHMARK"); - return NULL; - } - thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_benchmark(arg1->val_int(), arg2); + return new (thd->mem_root) Item_func_benchmark(arg1, arg2); } @@ -2887,17 +2880,7 @@ Create_func_decode Create_func_decode::s_singleton; Item* Create_func_decode::create(THD *thd, Item *arg1, Item *arg2) { - /* TODO: Known limitation, see Bug#22684 */ - if ((arg2->type() != Item::STRING_ITEM) || ! arg2->basic_const_item()) - { - my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), "DECODE"); - return NULL; - } - - String dummy; - String *val = arg2->val_str(& dummy); - DBUG_ASSERT(val); - return new (thd->mem_root) Item_func_decode(arg1, val->c_ptr()); + return new (thd->mem_root) Item_func_decode(arg1, arg2); } @@ -3033,17 +3016,7 @@ Create_func_encode Create_func_encode::s_singleton; Item* Create_func_encode::create(THD *thd, Item *arg1, Item *arg2) { - /* TODO: Known limitation, see Bug#22684 */ - if ((arg2->type() != Item::STRING_ITEM) || ! arg2->basic_const_item()) - { - my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), "ENCODE"); - return NULL; - } - - String dummy; - String *val = arg2->val_str(& dummy); - DBUG_ASSERT(val); - return new (thd->mem_root) Item_func_encode(arg1, val->c_ptr()); + return new (thd->mem_root) Item_func_encode(arg1, arg2); } @@ -3235,14 +3208,7 @@ Create_func_format Create_func_format::s_singleton; Item* Create_func_format::create(THD *thd, Item *arg1, Item *arg2) { - /* TODO: Known limitation, see Bug#22684 */ - if ((arg2->type() != Item::INT_ITEM) || ! arg2->basic_const_item()) - { - my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), "FORMAT"); - return NULL; - } - - return new (thd->mem_root) Item_func_format(arg1, arg2->val_int()); + return new (thd->mem_root) Item_func_format(arg1, arg2); } |