1 # Bug38499 flush tables and multitable table update with derived table cause crash
5 # Save the initial number of concurrent sessions
6 --source include/count_sessions.inc
8 SET @odl_sync_frm = @@global.sync_frm;
9 SET @@global.sync_frm = OFF;
11 connect (locker,localhost,root,,);
12 connect (writer,localhost,root,,);
16 DROP TABLE IF EXISTS t1;
18 CREATE TABLE t1( a INT, b INT );
19 INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4);
21 --echo # 1. test regular tables
22 --echo # 1.1. test altering of columns that multiupdate doesn't use
23 --echo # 1.1.1. normal mode
31 send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
34 ALTER TABLE t1 ADD COLUMN (c INT);
35 ALTER TABLE t1 DROP COLUMN c;
41 --echo # 1.1.2. PS mode
44 PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
54 ALTER TABLE t1 ADD COLUMN (c INT);
55 ALTER TABLE t1 DROP COLUMN c;
62 --echo # 1.2. test altering of columns that multiupdate uses
63 --echo # 1.2.1. normal mode
73 --error 0,ER_DUP_FIELDNAME
74 ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
78 --send UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0;
81 --error 0,ER_CANT_DROP_FIELD_OR_KEY
82 ALTER TABLE t1 DROP COLUMN a;
85 --error 0,ER_BAD_FIELD_ERROR # unknown column error
90 --echo # 1.2.2. PS mode
98 --error 0,ER_DUP_FIELDNAME
99 ALTER TABLE t1 ADD COLUMN a INT;
103 PREPARE stmt FROM 'UPDATE t1, (SELECT 1 FROM t1 t1i) d SET a = 0 WHERE 1=0';
107 --error 0,ER_CANT_DROP_FIELD_OR_KEY
108 ALTER TABLE t1 DROP COLUMN a;
111 --error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
116 ALTER TABLE t1 ADD COLUMN a INT;
118 --echo # 2. test UNIONs
119 --echo # 2.1. test altering of columns that multiupdate doesn't use
120 --echo # 2.1.1. normal mode
128 send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
131 ALTER TABLE t1 ADD COLUMN (c INT);
132 ALTER TABLE t1 DROP COLUMN c;
138 --echo # 2.1.2. PS mode
141 PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
151 ALTER TABLE t1 ADD COLUMN (c INT);
152 ALTER TABLE t1 DROP COLUMN c;
159 --echo # 2.2. test altering of columns that multiupdate uses
160 --echo # 2.2.1. normal mode
170 --error 0,ER_DUP_FIELDNAME
171 ALTER TABLE t1 ADD COLUMN a int(11) unsigned default NULL;
175 --send UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0;
178 --error 0,ER_CANT_DROP_FIELD_OR_KEY
179 ALTER TABLE t1 DROP COLUMN a;
182 --error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
187 --echo # 2.2.2. PS mode
195 --error 0,ER_DUP_FIELDNAME
196 ALTER TABLE t1 ADD COLUMN a INT;
200 PREPARE stmt FROM 'UPDATE t1, ((SELECT 1 FROM t1 t1i) UNION (SELECT 2 FROM t1 t1ii)) e SET a = 0 WHERE 1=0';
204 --error 0,ER_CANT_DROP_FIELD_OR_KEY
205 ALTER TABLE t1 DROP COLUMN a;
208 --error 0,ER_BAD_FIELD_ERROR # Unknown column 'a' in 'field list'
220 SET @@global.sync_frm = @odl_sync_frm;
224 # Wait till all disconnects are completed
225 --source include/wait_until_count_sessions.inc