summaryrefslogtreecommitdiff
path: root/mysql-test/r/func_math.result
diff options
context:
space:
mode:
authorGleb Shchepa <gshchepa@mysql.com>2009-05-18 09:21:25 +0500
committerGleb Shchepa <gshchepa@mysql.com>2009-05-18 09:21:25 +0500
commit405bd2af117384e009c3feffe1fd7d9019bf9d2b (patch)
tree0cc46a52d78c3e50ef405932673b7269b7af6590 /mysql-test/r/func_math.result
parentbaeac8762396a181440368c9413d617f0f49aacc (diff)
downloadmariadb-git-405bd2af117384e009c3feffe1fd7d9019bf9d2b.tar.gz
Bug #44768: SIGFPE crash when selecting rand from a view containing null
The RAND(N) function where the N is a field of "constant" table (table of single row) failed with a SIGFPE. Evaluation of RAND(N) rely on constant status of its argument. Current server "seeded" random value for each constant argument only once, in the Item_func_rand::fix_fields method. Then the server skipped a call to seed_random() in the Item_func_rand::val_real method for such constant arguments. However, non-constant state of an argument may be changed after the call to fix_fields, if an argument is a field of "constant" table. Thus, pre-initialization of random value in the fix_fields method is too early. Initialization of random value by seed_random() has been removed from Item_func_rand::fix_fields method. The Item_func_rand::val_real method has been modified to call seed_random() on the first evaluation of this method if an argument is a function. mysql-test/r/func_math.result: Added test case for bug #44768. mysql-test/t/func_math.test: Added test case for bug #44768. sql/item_func.cc: Bug #44768: SIGFPE crash when selecting rand from a view containing null 1. Initialization of random value by seed_random() has been removed from Item_func_rand::fix_fields method. 2. The Item_func_rand::val_real method has been modified to call seed_random() on the first evaluation of this method if an argument is a function. sql/item_func.h: Bug #44768: SIGFPE crash when selecting rand from a view containing null 1. The Item_func_rand::first_eval has been added to trace the first evaluation of the val_real method. 2. The Item_func_rand::cleanup method has been added to cleanup the first_eval flag.
Diffstat (limited to 'mysql-test/r/func_math.result')
-rw-r--r--mysql-test/r/func_math.result19
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index c3d2db2d553..9bc83087232 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -456,4 +456,23 @@ NULL
SELECT POW(10, 309);
POW(10, 309)
NULL
+#
+# Bug #44768: SIGFPE crash when selecting rand from a view
+# containing null
+#
+CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
+SELECT RAND(a) FROM v1;
+RAND(a)
+0.155220427694936
+DROP VIEW v1;
+SELECT RAND(a) FROM (SELECT NULL AS a) b;
+RAND(a)
+0.155220427694936
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (NULL);
+SELECT RAND(i) FROM t1;
+RAND(i)
+0.155220427694936
+DROP TABLE t1;
+#
End of 5.1 tests