Commit aa13a4b9 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Merge 5.0-bugteam -> 5.1-bugteam.

parents 7957622b 97bd7635
...@@ -988,6 +988,17 @@ m1 CREATE TABLE `m1` ( ...@@ -988,6 +988,17 @@ m1 CREATE TABLE `m1` (
`a` int(11) DEFAULT NULL `a` int(11) DEFAULT NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, m1; DROP TABLE t1, m1;
CREATE TABLE t1(a INT);
CREATE TABLE t2(a VARCHAR(10));
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t1;
a
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m2;
a
DROP TABLE t1, t2, m1, m2;
End of 5.0 tests End of 5.0 tests
create table t1 (c1 int, index(c1)); create table t1 (c1 int, index(c1));
create table t2 (c1 int, index(c1)) engine=merge union=(t1); create table t2 (c1 int, index(c1)) engine=merge union=(t1);
......
...@@ -613,6 +613,19 @@ ALTER TABLE m1 UNION=(); ...@@ -613,6 +613,19 @@ ALTER TABLE m1 UNION=();
SHOW CREATE TABLE m1; SHOW CREATE TABLE m1;
DROP TABLE t1, m1; DROP TABLE t1, m1;
#
# BUG#32047 - 'Spurious' errors while opening MERGE tables
#
CREATE TABLE t1(a INT);
CREATE TABLE t2(a VARCHAR(10));
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t1;
--error ER_WRONG_MRG_TABLE
SELECT * FROM m1;
SELECT * FROM m2;
DROP TABLE t1, t2, m1, m2;
--echo End of 5.0 tests --echo End of 5.0 tests
# #
......
...@@ -47,6 +47,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -47,6 +47,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
MI_INFO *isam=0; MI_INFO *isam=0;
uint found_merge_insert_method= 0; uint found_merge_insert_method= 0;
size_t name_buff_length; size_t name_buff_length;
my_bool bad_children= FALSE;
DBUG_ENTER("myrg_open"); DBUG_ENTER("myrg_open");
LINT_INIT(key_parts); LINT_INIT(key_parts);
...@@ -97,13 +98,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -97,13 +98,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
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;
if (handle_locking & HA_OPEN_FOR_REPAIR) if (handle_locking & HA_OPEN_FOR_REPAIR)
{ {
myrg_print_wrong_table(buff); myrg_print_wrong_table(buff);
bad_children= TRUE;
continue; continue;
} }
goto err; goto bad_children;
} }
if (!m_info) /* First file */ if (!m_info) /* First file */
{ {
...@@ -128,13 +129,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -128,13 +129,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
files++; files++;
if (m_info->reclength != isam->s->base.reclength) if (m_info->reclength != isam->s->base.reclength)
{ {
my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR) if (handle_locking & HA_OPEN_FOR_REPAIR)
{ {
myrg_print_wrong_table(buff); myrg_print_wrong_table(buff);
bad_children= TRUE;
continue; continue;
} }
goto err; goto bad_children;
} }
m_info->options|= isam->s->options; m_info->options|= isam->s->options;
m_info->records+= isam->state->records; m_info->records+= isam->state->records;
...@@ -147,8 +148,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -147,8 +148,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->tables); m_info->tables);
} }
if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF) if (bad_children)
goto err; goto bad_children;
if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
...@@ -178,12 +179,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -178,12 +179,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
pthread_mutex_unlock(&THR_LOCK_open); pthread_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
bad_children:
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
err: err:
save_errno=my_errno; save_errno=my_errno;
switch (errpos) { switch (errpos) {
case 3: case 3:
while (files) while (files)
mi_close(m_info->open_tables[--files].table); (void) mi_close(m_info->open_tables[--files].table);
my_free((char*) m_info,MYF(0)); my_free((char*) m_info,MYF(0));
/* Fall through */ /* Fall through */
case 2: case 2:
...@@ -392,6 +395,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -392,6 +395,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
uint child_nr; uint child_nr;
uint key_parts; uint key_parts;
uint min_keys; uint min_keys;
my_bool bad_children= FALSE;
DBUG_ENTER("myrg_attach_children"); DBUG_ENTER("myrg_attach_children");
DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking)); DBUG_PRINT("myrg", ("handle_locking: %d", handle_locking));
...@@ -441,13 +445,13 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -441,13 +445,13 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
DBUG_PRINT("error", ("definition mismatch table: '%s' repair: %d", DBUG_PRINT("error", ("definition mismatch table: '%s' repair: %d",
myisam->filename, myisam->filename,
(handle_locking & HA_OPEN_FOR_REPAIR))); (handle_locking & HA_OPEN_FOR_REPAIR)));
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR) if (handle_locking & HA_OPEN_FOR_REPAIR)
{ {
myrg_print_wrong_table(myisam->filename); myrg_print_wrong_table(myisam->filename);
bad_children= TRUE;
continue; continue;
} }
goto err; goto bad_children;
} }
m_info->options|= myisam->s->options; m_info->options|= myisam->s->options;
...@@ -462,6 +466,9 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -462,6 +466,9 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
child_nr++; child_nr++;
} }
if (bad_children)
goto bad_children;
/* Note: callback() resets my_errno, so it is safe to check it here */
if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF) if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF)
goto err; goto err;
if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L) if (sizeof(my_off_t) == 4 && file_offset > (ulonglong) (ulong) ~0L)
...@@ -477,6 +484,8 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking, ...@@ -477,6 +484,8 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
pthread_mutex_unlock(&m_info->mutex); pthread_mutex_unlock(&m_info->mutex);
DBUG_RETURN(0); DBUG_RETURN(0);
bad_children:
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
err: err:
save_errno= my_errno; save_errno= my_errno;
switch (errpos) { switch (errpos) {
......
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