List:Bugs« Previous MessageNext Message »
From:jpate Date:March 19 2003 12:56am
Subject:RAND() function does not have documented behaviour with seed
View as plain text  
>Description:
	when supplying one parameter to RAND() ie: RAND(20) it will always return the same value
for the first row, (not dependant on seed)
mysql> select rand(20) from table;

| rand(20)         |
| 0.18109056370434 | <-- first row always returns this number, no matter what the seed
is
| 0.75023236568107 | <-- all rows after always return these numbers in this order 
| 0.20789016802599 | <-| (the further down the number, the further it will change with
different seeds)
| 0.78875377382036 | <-|
| 0.32009839575747 | <-|
| 0.23423068805992 | <-|
| 0.21085828376083 | <-|
| 0.35159938535802 | <-|

rand(20) should always return the same number
rand(21) should always return a different number than rand(20) but the same for all calls
of rand(21)



>How-To-Repeat:
	create table if not exists test (field1 integer);
	insert into test (field1) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(0);
	select round(rand(20),5) from test;
	select round(rand(20),5) from test;
	select round(rand(21),5) from test;
	select round(rand(21),5) from test;
	#etc


>Fix:
	Unknown

>Submitter-Id: jpate@stripped
>Originator:	Jamie Pate
>Organization:
	Maximum Overdrive Software
>MySQL support: none 
>Synopsis:	RAND(SEED) behaves differently than documented
>Severity:	non-critical 
>Priority:	medium
>Category:	mysql
>Class:		sw-bug
>Release:	mysql-3.23.54 (Source distribution)

>Environment:
	Same problem on Win2k server 3.23.55,3.23.56 binary

System: Linux ilyana 2.4.18 #5 SMP Thu Jun 27 16:25:10 PDT 2002 i586 unknown
Architecture: i586

Some paths:  /usr/bin/perl /usr/local/bin/make /usr/bin/gcc /usr/local/bin/cc
GCC: Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/pgcc-2.95.2.1/specs
gcc version pgcc-2.95.2.1 20001224 (release)
Compilation info: CC='gcc'  CFLAGS=''  CXX='g++'  CXXFLAGS=''  LDFLAGS=''
LIBC: 
lrwxrwxrwx   1 root     root           13 Dec 18 13:26 /lib/libc.so.6 -> libc-2.1.3.so
-rwxr-xr-x   1 root     root       978488 Jun 30  2000 /lib/libc-2.1.2.so
-rwxr-xr-x   1 root     root       968948 Jul 11  2000 /lib/libc-2.1.3.so
-rwxr-xr-x   1 root     root      1211890 Feb  7  1999 /lib/libc-2.1.so
-rw-r--r--   1 root     root      2227280 Feb  7  1999 /usr/lib/libc.a
-rw-r--r--   1 root     root          178 Feb  7  1999 /usr/lib/libc.so
Configure command: ./configure 

Thread
RAND() function does not have documented behaviour with seedjpate19 Mar
  • Re: RAND() function does not have documented behaviour with seedPeter Zaitsev19 Mar