summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-03-07 22:11:57 +0300
committerunknown <evgen@moonbone.local>2007-03-07 22:11:57 +0300
commit11b533b8be4a9b4d8e35dd457dea3240614a13a6 (patch)
tree73c940c0964ba2fb7693501a744126263a1ec8e0
parent4b40ed9532c28605a19fd9cd0ed27da3746fa430 (diff)
downloadmariadb-git-11b533b8be4a9b4d8e35dd457dea3240614a13a6.tar.gz
Bug#25373: Stored functions wasn't compared correctly which leads to a wrong
result. For built-in functions like sqrt() function names are hard-coded and can be compared by pointer. But this isn't the case for a used-defined stored functions - names there are dynamical and should be compared as strings. Now the Item_func::eq() function employs my_strcasecmp() function to compare used-defined stored functions names. mysql-test/t/sp.test: Added a test case for bug#25373: Stored functions wasn't compared correctly which leads to a wrong result. mysql-test/r/sp.result: Added a test case for bug#25373: Stored functions wasn't compared correctly which leads to a wrong result. sql/item_func.cc: Bug#25373: Stored functions wasn't compared correctly which leads to a wrong result. Now the Item_func::eq() function employs my_strcasecmp() function to compare used-defined stored functions names.
-rw-r--r--mysql-test/r/sp.result13
-rw-r--r--mysql-test/t/sp.test15
-rw-r--r--sql/item_func.cc9
3 files changed, 35 insertions, 2 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 8e3c057cc62..81e2db70357 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -5741,4 +5741,17 @@ END|
CALL bug24117()|
DROP PROCEDURE bug24117|
DROP TABLE t3|
+DROP FUNCTION IF EXISTS bug25373|
+CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER
+LANGUAGE SQL DETERMINISTIC
+RETURN p1;|
+CREATE TABLE t3 (f1 INT, f2 FLOAT)|
+INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
+SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
+SUM(f2) bug25373(f1)
+6.3000000715256 1
+15 2
+21.300000071526 NULL
+DROP FUNCTION bug25373|
+DROP TABLE t3|
drop table t1,t2;
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index cfa4937e050..5da29454b08 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -6715,6 +6715,21 @@ DROP PROCEDURE bug24117|
DROP TABLE t3|
#
+# Bug#25373: Stored functions wasn't compared correctly which leads to a wrong
+# result.
+#
+--disable_warnings
+DROP FUNCTION IF EXISTS bug25373|
+--disable_warnings
+CREATE FUNCTION bug25373(p1 INTEGER) RETURNS INTEGER
+LANGUAGE SQL DETERMINISTIC
+RETURN p1;|
+CREATE TABLE t3 (f1 INT, f2 FLOAT)|
+INSERT INTO t3 VALUES (1, 3.4), (1, 2), (1, 0.9), (2, 8), (2, 7)|
+SELECT SUM(f2), bug25373(f1) FROM t3 GROUP BY bug25373(f1) WITH ROLLUP|
+DROP FUNCTION bug25373|
+DROP TABLE t3|
+#
# NOTE: The delimiter is `|`, and not `;`. It is changed to `;`
# at the end of the file!
#
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 638d8903dcb..c8c0671ae1d 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -409,8 +409,13 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const
if (item->type() != FUNC_ITEM)
return 0;
Item_func *item_func=(Item_func*) item;
- if (arg_count != item_func->arg_count ||
- func_name() != item_func->func_name())
+ Item_func::Functype func_type;
+ if ((func_type= functype()) != item_func->functype() ||
+ arg_count != item_func->arg_count ||
+ (func_type != Item_func::FUNC_SP &&
+ func_name() != item_func->func_name()) ||
+ (func_type == Item_func::FUNC_SP &&
+ my_strcasecmp(system_charset_info, func_name(), item_func->func_name())))
return 0;
for (uint i=0; i < arg_count ; i++)
if (!args[i]->eq(item_func->args[i], binary_cmp))