Commit bf268802 authored by unknown's avatar unknown
Browse files

A fix (Bug #5232: CREATE TABLE ... SELECT can deadlock itself).

parent 1176c175
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -610,3 +610,12 @@ x y
1	3
1	2
drop table t1,t2,t3;
create table t1 (a int);
create table t2 (a int);
insert into t1 values (0);
insert into t2 values (1);
create table t3 engine=merge union=(t1, t2) select * from t1;
INSERT TABLE 't1' isn't allowed in FROM table list
create table t3 engine=merge union=(t1, t2) select * from t2;
INSERT TABLE 't2' isn't allowed in FROM table list
drop table t1, t2;
+14 −0
Original line number Diff line number Diff line
@@ -250,3 +250,17 @@ select * from t3 where x = 1 and y < 5 order by y;
# Bug is that followng query returns empty set while it must be same as above
select * from t3 where x = 1 and y < 5 order by y desc;
drop table t1,t2,t3;

#
# Bug#5232: CREATE TABLE ... SELECT
#

create table t1 (a int);
create table t2 (a int);
insert into t1 values (0);
insert into t2 values (1);
--error 1093
create table t3 engine=merge union=(t1, t2) select * from t1;
--error 1093
create table t3 engine=merge union=(t1, t2) select * from t2;
drop table t1, t2;
+13 −0
Original line number Diff line number Diff line
@@ -1655,6 +1655,19 @@ mysql_execute_command(void)
	net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name);
	DBUG_VOID_RETURN;
      }
      if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
      {
        TABLE_LIST *tab;
        for (tab= tables; tab; tab= tab->next)
        {
          if (check_dup(tables->db, tab->real_name,
                        (TABLE_LIST*)lex->create_info.merge_list.first))
          {
            net_printf(&thd->net, ER_INSERT_TABLE_USED, tab->real_name);
            DBUG_VOID_RETURN;
          }
        }  
      }    
      if (tables->next)
      {
	TABLE_LIST *table;