Bug #104345 Unexpected cross join select error (#1022 can't write; duplicate key in table)
Submitted: 16 Jul 2021 23:45 Modified: 17 Jul 2021 2:28
Reporter: Roman Roman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: error #1022

[16 Jul 2021 23:45] Roman Roman
Description:
SELECT generate unexpected error #1022 - Can't write; duplicate key in table '/tmp/#sql1_37b43c_1'

How to repeat:
CREATE TABLE IF NOT EXISTS `-uni_nums` (
  `num` tinyint unsigned NOT NULL,
    PRIMARY KEY `num` (`num`)
) ENGINE=MEMORY
AS
SELECT * FROM (VALUES ROW(0), ROW(1), ROW(2), ROW(3), ROW(4), ROW(5), ROW(6), ROW(7)) AS t(num);

SELECT FLOOR(RAND() * 6) AS rand, COUNT(*) FROM `-uni_nums` AS a, `-uni_nums` AS b GROUP BY rand;
[17 Jul 2021 2:28] MySQL Verification Team
Thank you for the bug report.