Commit 047d12d7 authored by Anurag Shekhar's avatar Anurag Shekhar

merging with local bugfix branch.

parents fcbd5f89 f8f60edd
......@@ -2115,4 +2115,16 @@ insert into m1 (col1) values (1);
insert into m1 (col1) values (1);
ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
drop table m1, t1;
CREATE TABLE t1 (
col1 INT(10)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE m1 (
col1 INT(10)
)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
#Select should detect that the child table is a view and fail.
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
DROP VIEW v1;
DROP TABLE m1, t1;
End of 5.1 tests
......@@ -1514,4 +1514,25 @@ insert into m1 (col1) values (1);
insert into m1 (col1) values (1);
drop table m1, t1;
#
#Bug #44040 MySQL allows creating a MERGE table upon VIEWs but crashes
#when using it
#
CREATE TABLE t1 (
col1 INT(10)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE VIEW v1 as SELECT * FROM t1;
CREATE TABLE m1 (
col1 INT(10)
)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1);
--echo #Select should detect that the child table is a view and fail.
--error ER_WRONG_MRG_TABLE
SELECT * FROM m1;
DROP VIEW v1;
DROP TABLE m1, t1;
--echo End of 5.1 tests
......@@ -3843,6 +3843,16 @@ static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
if (share->is_view)
{
/*
If parent_l of the table_list is non null then a merge table
has this view as child table, which is not supported.
*/
if (table_list->parent_l)
{
my_error(ER_WRONG_MRG_TABLE, MYF(0));
goto err;
}
/*
This table is a view. Validate its metadata version: in particular,
that it was a view when the statement was prepared.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment