MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:gluh Date:September 6 2005 11:20am
Subject:bk commit into 4.1 tree (gluh:1.2403) 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.2403 05/09/06 16:19:59 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.254 05/09/06 16:19:16 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.43 05/09/06 16:19:16 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.17 05/09/06 16:19:16 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/09/06 16:19:16 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.24 05/09/06 16:19:16 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/Merge/4.1

--- 1.253/sql/item_func.cc	Tue Aug  2 05:11:21 2005
+++ 1.254/sql/item_func.cc	Tue Sep  6 16:19:16 2005
@@ -1038,6 +1038,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.23/mysql-test/r/func_math.result	Thu Jun 23 08:00:19 2005
+++ 1.24/mysql-test/r/func_math.result	Tue Sep  6 16:19:16 2005
@@ -140,3 +140,8 @@
 select abs(-2) * -2;
 abs(-2) * -2
 -4
+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.16/mysql-test/t/func_math.test	Tue Aug  2 05:11:48 2005
+++ 1.17/mysql-test/t/func_math.test	Tue Sep  6 16:19:16 2005
@@ -77,4 +77,13 @@
 #
 select abs(-2) * -2;
 
+#
+# 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;
+
 # End of 4.1 tests

--- 1.41/mysql-test/r/ps.result	Sat Jul 16 00:43:48 2005
+++ 1.42/mysql-test/r/ps.result	Tue Sep  6 16:19:16 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.42/mysql-test/t/ps.test	Thu Jul 28 05:21:46 2005
+++ 1.43/mysql-test/t/ps.test	Tue Sep  6 16:19:16 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.2403) BUG#6172gluh6 Sep