RAND() function does not have documented behaviour with seed

RAND() function does not have documented behaviour with seed

am 19.03.2003 01:56:22 von jpate

>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@moscore.com
>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


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13991@lists.mysql.com
To unsubscribe, e-mail

Re: RAND() function does not have documented behaviour with seed

am 19.03.2003 13:43:48 von Peter Zaitsev

On Wed, 2003-03-19 at 03:56, jpate@moscore.com wrote:
> >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)
>


Thank you for good bug report,
with your test case I was able to repeat the issue.
It exists only in MySQL 3.23 tree but not 4.0 tree.

As current solution I would recommend upgrading to MySQL 4.0.12
which is now qualified as stable.

We'll decide if this bug will be fixed in MySQL 3.23 tree - as old
stable tree this tree is to receive only critical bug fixes.




--
MySQL 2003 Users Conf. -> http://www.mysql.com/events/uc2003/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Peter Zaitsev
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Moscow, Russia
<___/ www.mysql.com


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13992@lists.mysql.com
To unsubscribe, e-mail