Bug #111252 order by random_bytes has no effect
Submitted: 2 Jun 2023 2:10 Modified: 8 Jun 2023 19:06
Reporter: Josh Josh Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:8.0.23, 5.7, 8.0 OS:Any
Assigned to: CPU Architecture:Any

[2 Jun 2023 2:10] Josh Josh
Description:
order by random_bytes(8) has no effect

How to repeat:
See:

https://stackoverflow.com/questions/76383778/why-does-mysql-order-by-random-bytes-have-no-...

Preview:

create procedure Test()
begin

    create temporary table Meow (Id bigint);
    insert into Meow (Id) values (1);
    insert into Meow (Id) values (2);
    insert into Meow (Id) values (3);
    insert into Meow (Id) values (4);
    insert into Meow (Id) values (5);

    select * from Meow order by random_bytes(8);
   
    drop temporary table Meow;

end
[2 Jun 2023 9:16] MySQL Verification Team
Hello Josh,

Thank you for the report and feedback.

regards,
Umesh
[5 Jun 2023 7:31] Roy Lyseng
Posted by developer:
 
Fixed in 8.0.34 by the patch for Bug#35148945.
[8 Jun 2023 19:06] Jon Stephens
Documented fix as follows in the MySQL 8.0.34 changelog:

    ORDER BY RANDOM_BYTES() had no effect on the query output.

Closed.