MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:gluh Date:July 21 2005 8:50am
Subject:bk commit into 4.1 tree (gluh:1.2349) BUG#6172
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2349 05/07/21 13:50:44 gluh@stripped +5 -0
  Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
    Argument of RAND function can be constant value only

  sql/item_func.cc
    1.256 05/07/21 13:50:41 gluh@stripped +5 -0
    Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
      Argument of RAND function can be constant value only

  mysql-test/t/ps.test
    1.42 05/07/21 13:50:40 gluh@stripped +1 -3
    Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
      Argument of RAND function can be constant value only

  mysql-test/t/func_math.test
    1.15 05/07/21 13:50:40 gluh@stripped +9 -0
    Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
      Argument of RAND function can be constant value only

  mysql-test/r/ps.result
    1.42 05/07/21 13:50:40 gluh@stripped +21 -23
    Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
      Argument of RAND function can be constant value only

  mysql-test/r/func_math.result
    1.23 05/07/21 13:50:40 gluh@stripped +5 -0
    Bug #6172 RAND(a) should only accept constant values as arguments(2nd version)
      Argument of RAND function can be constant value only

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gluh
# Host:	eagle.intranet.mysql.r18.ru
# Root:	/home/gluh/MySQL/Bugs/4.1.6172

--- 1.255/sql/item_func.cc	Tue Jul 19 21:24:59 2005
+++ 1.256/sql/item_func.cc	Thu Jul 21 13:50:41 2005
@@ -1203,6 +1203,11 @@
   used_tables_cache|= RAND_TABLE_BIT;
   if (arg_count)
   {					// Only use argument once in query
+    if (!args[0]->const_during_execution())
+    {
+      my_error(ER_WRONG_ARGUMENTS, MYF(0), "RAND");
+      return TRUE;
+    }
     /*
       Allocate rand structure once: we must use thd->current_arena
       to create rand in proper mem_root if it's a prepared statement or

--- 1.22/mysql-test/r/func_math.result	Tue Apr 19 14:44:50 2005
+++ 1.23/mysql-test/r/func_math.result	Thu Jul 21 13:50:40 2005
@@ -137,3 +137,8 @@
 round(1, 6)
 1.000000
 drop table t1;
+create table t1 (i int);
+insert into t1 values (1);
+select rand(i) from t1;
+ERROR HY000: Incorrect arguments to RAND
+drop table t1;

--- 1.14/mysql-test/t/func_math.test	Tue Apr 19 14:44:50 2005
+++ 1.15/mysql-test/t/func_math.test	Thu Jul 21 13:50:40 2005
@@ -71,3 +71,12 @@
 show create table t1;
 select * from t1;
 drop table t1;
+
+#
+# Bug #6172 RAND(a) should only accept constant values as arguments
+#
+create table t1 (i int);
+insert into t1 values (1);
+--error 1210
+select rand(i) from t1;
+drop table t1;

--- 1.41/mysql-test/r/ps.result	Sat Jul 16 00:43:48 2005
+++ 1.42/mysql-test/r/ps.result	Thu Jul 21 13:50:40 2005
@@ -334,39 +334,37 @@
 insert into t1 (a) values (1), (2), (3), (4);
 set @precision=10000000000;
 select rand(), 
-cast(rand(10)*@precision as unsigned integer),
-cast(rand(a)*@precision as unsigned integer) from t1;
-rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(a)*@precision as unsigned integer)
--	6570515219	-
--	1282061302	-
--	6698761160	-
--	9647622201	-
+cast(rand(10)*@precision as unsigned integer) from t1;
+rand()	cast(rand(10)*@precision as unsigned integer)
+-	6570515219
+-	1282061302
+-	6698761160
+-	9647622201
 prepare stmt from
 "select rand(), 
         cast(rand(10)*@precision as unsigned integer),
-        cast(rand(a)*@precision as unsigned integer),
         cast(rand(?)*@precision as unsigned integer) from t1";
 set @var=1;
 execute stmt using @var;
-rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(a)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
--	6570515219	-	4054035371
--	1282061302	-	8716141803
--	6698761160	-	1418603212
--	9647622201	-	944590960
+rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
+-	6570515219	-
+-	1282061302	-
+-	6698761160	-
+-	9647622201	-
 set @var=2;
 execute stmt using @var;
-rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(a)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
--	6570515219	1559528654	6555866465
--	1282061302	6238114970	1223466192
--	6698761160	6511989195	6449731873
--	9647622201	3845601374	8578261098
+rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
+-	6570515219	6555866465
+-	1282061302	1223466192
+-	6698761160	6449731873
+-	9647622201	8578261098
 set @var=3;
 execute stmt using @var;
-rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(a)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
--	6570515219	1559528654	9057697559
--	1282061302	6238114970	3730790581
--	6698761160	6511989195	1480860534
--	9647622201	3845601374	6211931236
+rand()	cast(rand(10)*@precision as unsigned integer)	cast(rand(?)*@precision as unsigned integer)
+-	6570515219	9057697559
+-	1282061302	3730790581
+-	6698761160	1480860534
+-	9647622201	6211931236
 drop table t1;
 deallocate prepare stmt;
 create database mysqltest1;

--- 1.41/mysql-test/t/ps.test	Sat Jul 16 00:43:48 2005
+++ 1.42/mysql-test/t/ps.test	Thu Jul 21 13:50:40 2005
@@ -368,12 +368,10 @@
 set @precision=10000000000;
 --replace_column 1 - 3 -
 select rand(), 
-       cast(rand(10)*@precision as unsigned integer),
-       cast(rand(a)*@precision as unsigned integer) from t1;
+       cast(rand(10)*@precision as unsigned integer) from t1;
 prepare stmt from
 "select rand(), 
         cast(rand(10)*@precision as unsigned integer),
-        cast(rand(a)*@precision as unsigned integer),
         cast(rand(?)*@precision as unsigned integer) from t1";
 set @var=1;
 --replace_column 1 - 3 -
Thread
bk commit into 4.1 tree (gluh:1.2349) BUG#6172gluh21 Jul