Bug #163 rand(x) is repeatable for the first call for any X
Submitted: 19 Mar 2003 5:07 Modified: 19 Mar 2003 12:11
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:3.23 OS:Any (all)
Assigned to: CPU Architecture:Any

[19 Mar 2003 5:07] Peter Zaitsev
Description:
Rand() is not seeded properly with initialization parameter, resulting in
almost the same number for close seed values.

The behavior is different in MySQL 4.0 so we likely just should backport fix.

How to repeat:
mysql> select round(rand(20),5),round(rand(21),5),round(rand(22),5);
+-------------------+-------------------+-------------------+
| round(rand(20),5) | round(rand(21),5) | round(rand(22),5) |
+-------------------+-------------------+-------------------+
|           0.18109 |           0.18109 |           0.18109 |
+-------------------+-------------------+-------------------+
1 row in set (0.00 sec)

mysql> select rand(20),rand(21),rand(22);
+------------------+------------------+-----------------+
| rand(20)         | rand(21)         | rand(22)        |
+------------------+------------------+-----------------+
| 0.18109056370434 | 0.18109056742963 | 0.1810905702236 |
+------------------+------------------+-----------------+
1 row in set (0.01 sec)
[19 Mar 2003 12:11] Michael Widenius
This should not be backported as it may crash old applications.