BUG#10974 - No error message if merge table based on union of innodb, memory

Fixed confusing error message from the storage engine when
it fails to open underlying table. The error message is issued
when a table is _opened_ (not when it is created).
parent 43097593
...@@ -89,7 +89,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -89,7 +89,10 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
else else
fn_format(buff, buff, "", "", 0); fn_format(buff, buff, "", "", 0);
if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
{
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err; goto err;
}
if (!m_info) /* First file */ if (!m_info) /* First file */
{ {
key_parts=isam->s->base.key_parts; key_parts=isam->s->base.key_parts;
......
...@@ -178,9 +178,9 @@ t3 CREATE TABLE `t3` ( ...@@ -178,9 +178,9 @@ t3 CREATE TABLE `t3` (
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
select * from t4; select * from t4;
ERROR HY000: Can't open file: 't4.MRG' (errno: 143) ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
alter table t4 add column c int; alter table t4 add column c int;
ERROR HY000: Can't open file: 't4.MRG' (errno: 143) ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
create database mysqltest; create database mysqltest;
create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);
...@@ -766,3 +766,12 @@ Table Op Msg_type Msg_text ...@@ -766,3 +766,12 @@ Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
test.t2 check status OK test.t2 check status OK
drop table t1, t2, t3; drop table t1, t2, t3;
CREATE TABLE t1(a INT) ENGINE=MEMORY;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t2;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
DROP TABLE t1, t2;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
SELECT * FROM t2;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists
DROP TABLE t2;
...@@ -31,7 +31,7 @@ create table t1 engine=myisam SELECT 1,"table 1"; ...@@ -31,7 +31,7 @@ create table t1 engine=myisam SELECT 1,"table 1";
flush tables; flush tables;
repair table t1; repair table t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair error Can't open file: 't1.MYI' (errno: 130) test.t1 repair error Got error 130 from storage engine
repair table t1 use_frm; repair table t1 use_frm;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1 test.t1 repair warning Number of rows changed from 0 to 1
......
...@@ -47,9 +47,9 @@ show create table t3; ...@@ -47,9 +47,9 @@ show create table t3;
# The following should give errors # The following should give errors
create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
--error 1016 --error 1168
select * from t4; select * from t4;
--error 1016 --error 1168
alter table t4 add column c int; alter table t4 add column c int;
# #
...@@ -376,4 +376,18 @@ select * from t3; ...@@ -376,4 +376,18 @@ select * from t3;
check table t1, t2; check table t1, t2;
drop table t1, t2, t3; drop table t1, t2, t3;
#
# BUG#10974 - No error message if merge table based on union of innodb,
# memory
#
CREATE TABLE t1(a INT) ENGINE=MEMORY;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
--error 1168
SELECT * FROM t2;
DROP TABLE t1, t2;
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
--error 1168
SELECT * FROM t2;
DROP TABLE t2;
# End of 4.1 tests # End of 4.1 tests
...@@ -184,7 +184,7 @@ character-set=latin1 ...@@ -184,7 +184,7 @@ character-set=latin1
"INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", "INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES",
"Incorrect column name '%-.100s'", "Incorrect column name '%-.100s'",
"The used storage engine can't index column '%-.64s'", "The used storage engine can't index column '%-.64s'",
"All tables in the MERGE table are not identically defined", "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists",
"Can't write, because of unique constraint, to table '%-.64s'", "Can't write, because of unique constraint, to table '%-.64s'",
"BLOB/TEXT column '%-.64s' used in key specification without a key length", "BLOB/TEXT column '%-.64s' used in key specification without a key length",
"All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead", "All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead",
......
...@@ -77,6 +77,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -77,6 +77,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
my_string record; my_string record;
const char **int_array; const char **int_array;
bool use_hash, null_field_first; bool use_hash, null_field_first;
bool error_reported= FALSE;
File file; File file;
Field **field_ptr,*reg_field; Field **field_ptr,*reg_field;
KEY *keyinfo; KEY *keyinfo;
...@@ -791,6 +792,11 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -791,6 +792,11 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
error= 1; error= 1;
my_errno= ENOENT; my_errno= ENOENT;
} }
else
{
outparam->file->print_error(err, MYF(0));
error_reported= TRUE;
}
goto err_not_open; /* purecov: inspected */ goto err_not_open; /* purecov: inspected */
} }
} }
...@@ -812,6 +818,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -812,6 +818,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
err_end: /* Here when no file */ err_end: /* Here when no file */
delete crypted; delete crypted;
*root_ptr= old_root; *root_ptr= old_root;
if (!error_reported)
frm_error(error, outparam, name, ME_ERROR + ME_WAITTANG, errarg); frm_error(error, outparam, name, ME_ERROR + ME_WAITTANG, errarg);
delete outparam->file; delete outparam->file;
outparam->file=0; // For easyer errorchecking outparam->file=0; // For easyer errorchecking
......
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