1 drop table if exists t1, t2;
3 # Bug #36676: multiupdate using LEFT JOIN updates only
4 # first row or fails with an error:
5 # ERROR 1022 (23000): Can't write; duplicate key in table ''
9 # Multiupdate creates MyISAM temporary table without MEMORY table
11 CREATE TABLE t1 (ID INT);
12 CREATE TABLE t2 (ID INT,
13 s1 TEXT, s2 TEXT, s3 VARCHAR(10), s4 TEXT, s5 VARCHAR(10));
14 INSERT INTO t1 VALUES (1),(2);
15 INSERT INTO t2 VALUES (1,'test', 'test', 'test', 'test', 'test'),
16 (2,'test', 'test', 'test', 'test', 'test');
17 SELECT * FROM t1 LEFT JOIN t2 USING(ID);
19 1 test test test test test
20 2 test test test test test
21 UPDATE t1 LEFT JOIN t2 USING(ID) SET s1 = 'changed';
22 UPDATE t1 JOIN t2 USING(ID) SET s2 = 'changed';
23 UPDATE t1 LEFT JOIN t2 USING(ID) SET s3 = 'changed';
24 UPDATE t1 LEFT JOIN t2 USING(ID) SET s4 = 'changed', s5 = 'changed';
25 SELECT * FROM t1 LEFT JOIN t2 USING(ID);
27 1 changed changed changed changed changed
28 2 changed changed changed changed changed
31 # Multiupdate creates temporary MyISAM table from MEMORY table
33 CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
34 CREATE TABLE t2 (id INT, s1 CHAR(255));
35 INSERT INTO t1 VALUES (0), (0), (0), (0), (0), (0), (0), (0);
36 INSERT INTO t1 (SELECT 0 FROM t1);
37 INSERT INTO t1 (SELECT 0 FROM t1);
38 INSERT INTO t1 (SELECT 0 FROM t1);
39 INSERT INTO t2 (SELECT ID, 'a' FROM t1);
40 UPDATE t1 LEFT JOIN t2 USING(id) SET s1 = 'b';
41 SELECT DISTINCT s1 FROM t1 LEFT JOIN t2 USING(id);