Commit 55c76592 authored by unknown's avatar unknown

BUG#26976 - Missing table in merge not noted in related error msg +

            SHOW CREATE TABLE fails

Underlying table names, that merge engine fails to open were not
reported.

With this fix CHECK TABLE issued against merge table reports all
underlying table names that it fails to open. Other statements
are unaffected, that is underlying table names are not included
into error message.

This fix doesn't solve SHOW CREATE TABLE issue.


myisammrg/myrg_def.h:
  Added myrg_print_wrong_table declaration.
myisammrg/myrg_open.c:
  If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
  report names of tables that we fail to open.
mysql-test/r/backup.result:
  Updated test result.
mysql-test/r/key_cache.result:
  Updated test result - removed duplicate error.
mysql-test/r/lock.result:
  Updated test result - added summary row.
mysql-test/r/merge.result:
  A test case for BUG#26976.
mysql-test/r/preload.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/r/ps.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/r/repair.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/r/rpl_failed_optimize.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/r/sp.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/r/view.result:
  Updated test result - removed duplicate error, added summary row.
mysql-test/t/merge.test:
  A test case for BUG#26976.
sql/ha_myisam.cc:
  Do not report same error twice.
sql/ha_myisammrg.cc:
  If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
  report names of tables that we fail to open.
  
  Added dummy ha_myisammrg::check to not confuse users with
  "not implemented" error in case all underlying tables are
  fine.
sql/ha_myisammrg.h:
   Added ha_myisammrg::check declaration.
sql/share/errmsg.txt:
  Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
  of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
  passed to merge engine handler open function.
sql/sql_error.cc:
  warning_level_* are now public. It is required by mysql_admin_table to
  report message level.
sql/sql_error.h:
  warning_level_* are now public. It is required by mysql_admin_table to
  report message level.
sql/sql_table.cc:
  Reorder mysql_admin_table arguments to meet it's definition.
  
  Report errors that are pending in thd->warn_list as results of
  admin function.
parent 12d55a8c
...@@ -29,4 +29,7 @@ extern pthread_mutex_t THR_LOCK_open; ...@@ -29,4 +29,7 @@ extern pthread_mutex_t THR_LOCK_open;
int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag);
int _myrg_mi_read_record(MI_INFO *info, byte *buf); int _myrg_mi_read_record(MI_INFO *info, byte *buf);
#ifdef __cplusplus
extern "C"
#endif
void myrg_print_wrong_table(const char *table_name);
...@@ -90,6 +90,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -90,6 +90,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
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; my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR)
{
myrg_print_wrong_table(buff);
continue;
}
goto err; goto err;
} }
if (!m_info) /* First file */ if (!m_info) /* First file */
...@@ -118,6 +123,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -118,6 +123,11 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
if (m_info->reclength != isam->s->base.reclength) if (m_info->reclength != isam->s->base.reclength)
{ {
my_errno=HA_ERR_WRONG_MRG_TABLE_DEF; my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR)
{
myrg_print_wrong_table(buff);
continue;
}
goto err; goto err;
} }
m_info->options|= isam->s->options; m_info->options|= isam->s->options;
...@@ -131,6 +141,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -131,6 +141,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)
goto err;
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;
......
...@@ -4,18 +4,16 @@ create table t4(n int); ...@@ -4,18 +4,16 @@ create table t4(n int);
backup table t4 to '../bogus'; backup table t4 to '../bogus';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
test.t4 backup status Operation failed test.t4 backup status Operation failed
Warnings:
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
backup table t4 to '../tmp'; backup table t4 to '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup status OK test.t4 backup status OK
backup table t4 to '../tmp'; backup table t4 to '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 backup error Failed copying .frm file (errno: X) test.t4 backup error Failed copying .frm file (errno: X)
test.t4 backup Error Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
test.t4 backup status Operation failed test.t4 backup status Operation failed
Warnings:
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
drop table t4; drop table t4;
restore table t4 from '../tmp'; restore table t4 from '../tmp';
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
......
...@@ -191,10 +191,8 @@ cache index t1 in unknown_key_cache; ...@@ -191,10 +191,8 @@ cache index t1 in unknown_key_cache;
ERROR HY000: Unknown key cache 'unknown_key_cache' ERROR HY000: Unknown key cache 'unknown_key_cache'
cache index t1 key (unknown_key) in keycache1; cache index t1 key (unknown_key) in keycache1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 assign_to_keycache error Key 'unknown_key' doesn't exist in table 't1' test.t1 assign_to_keycache Error Key 'unknown_key' doesn't exist in table 't1'
test.t1 assign_to_keycache status Operation failed test.t1 assign_to_keycache status Operation failed
Warnings:
Error 1176 Key 'unknown_key' doesn't exist in table 't1'
select @@keycache2.key_buffer_size; select @@keycache2.key_buffer_size;
@@keycache2.key_buffer_size @@keycache2.key_buffer_size
4194304 4194304
......
...@@ -40,7 +40,8 @@ test.t1 check status OK ...@@ -40,7 +40,8 @@ test.t1 check status OK
lock tables t1 write; lock tables t1 write;
check table t2; check table t2;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t2 check error Table 't2' was not locked with LOCK TABLES test.t2 check Error Table 't2' was not locked with LOCK TABLES
test.t2 check error Corrupt
insert into t1 select index1,nr from t1; insert into t1 select index1,nr from t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES ERROR HY000: Table 't1' was not locked with LOCK TABLES
unlock tables; unlock tables;
......
...@@ -844,4 +844,36 @@ insert into t1 values (1); ...@@ -844,4 +844,36 @@ insert into t1 values (1);
ERROR HY000: Table 't1' is read only ERROR HY000: Table 't1' is read only
drop table t2; drop table t2;
drop table t1; drop table t1;
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
CHECK TABLE tm1;
Table Op Msg_type Msg_text
test.tm1 check Error Table './test/t1' is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check error Corrupt
CREATE TABLE t1(a INT);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
CHECK TABLE tm1;
Table Op Msg_type Msg_text
test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check error Corrupt
CREATE TABLE t2(a BLOB);
SELECT * FROM tm1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
CHECK TABLE tm1;
Table Op Msg_type Msg_text
test.tm1 check Error Table './test/t2' is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
test.tm1 check error Corrupt
ALTER TABLE t2 MODIFY a INT;
SELECT * FROM tm1;
a
CHECK TABLE tm1;
Table Op Msg_type Msg_text
test.tm1 check status OK
DROP TABLE tm1, t1, t2;
End of 5.0 tests End of 5.0 tests
...@@ -143,10 +143,9 @@ Key_read_requests 0 ...@@ -143,10 +143,9 @@ Key_read_requests 0
Key_reads 0 Key_reads 0
load index into cache t3, t2 key (primary,b) ; load index into cache t3, t2 key (primary,b) ;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t3 preload_keys error Table 'test.t3' doesn't exist test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t3 preload_keys error Corrupt
test.t2 preload_keys status OK test.t2 preload_keys status OK
Warnings:
Error 1146 Table 'test.t3' doesn't exist
show status like "key_read%"; show status like "key_read%";
Variable_name Value Variable_name Value
Key_read_requests 478 Key_read_requests 478
...@@ -159,12 +158,10 @@ Key_read_requests 0 ...@@ -159,12 +158,10 @@ Key_read_requests 0
Key_reads 0 Key_reads 0
load index into cache t3 key (b), t2 key (c) ; load index into cache t3 key (b), t2 key (c) ;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t3 preload_keys error Table 'test.t3' doesn't exist test.t3 preload_keys Error Table 'test.t3' doesn't exist
test.t2 preload_keys error Key 'c' doesn't exist in table 't2' test.t3 preload_keys error Corrupt
test.t2 preload_keys Error Key 'c' doesn't exist in table 't2'
test.t2 preload_keys status Operation failed test.t2 preload_keys status Operation failed
Warnings:
Error 1146 Table 'test.t3' doesn't exist
Error 1176 Key 'c' doesn't exist in table 't2'
show status like "key_read%"; show status like "key_read%";
Variable_name Value Variable_name Value
Key_read_requests 0 Key_read_requests 0
......
...@@ -1378,45 +1378,39 @@ prepare stmt from "repair table t1, t4, t3"; ...@@ -1378,45 +1378,39 @@ prepare stmt from "repair table t1, t4, t3";
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair status OK test.t1 repair status OK
test.t4 repair error Table 'test.t4' doesn't exist test.t4 repair Error Table 'test.t4' doesn't exist
test.t4 repair error Corrupt
test.t3 repair status OK test.t3 repair status OK
Warnings:
Error 1146 Table 'test.t4' doesn't exist
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair status OK test.t1 repair status OK
test.t4 repair error Table 'test.t4' doesn't exist test.t4 repair Error Table 'test.t4' doesn't exist
test.t4 repair error Corrupt
test.t3 repair status OK test.t3 repair status OK
Warnings:
Error 1146 Table 'test.t4' doesn't exist
prepare stmt from "optimize table t1, t3, t4"; prepare stmt from "optimize table t1, t3, t4";
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
test.t3 optimize status OK test.t3 optimize status OK
test.t4 optimize error Table 'test.t4' doesn't exist test.t4 optimize Error Table 'test.t4' doesn't exist
Warnings: test.t4 optimize error Corrupt
Error 1146 Table 'test.t4' doesn't exist
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status Table is already up to date test.t1 optimize status Table is already up to date
test.t3 optimize status Table is already up to date test.t3 optimize status Table is already up to date
test.t4 optimize error Table 'test.t4' doesn't exist test.t4 optimize Error Table 'test.t4' doesn't exist
Warnings: test.t4 optimize error Corrupt
Error 1146 Table 'test.t4' doesn't exist
prepare stmt from "analyze table t4, t1"; prepare stmt from "analyze table t4, t1";
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 analyze error Table 'test.t4' doesn't exist test.t4 analyze Error Table 'test.t4' doesn't exist
test.t4 analyze error Corrupt
test.t1 analyze status Table is already up to date test.t1 analyze status Table is already up to date
Warnings:
Error 1146 Table 'test.t4' doesn't exist
execute stmt; execute stmt;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t4 analyze error Table 'test.t4' doesn't exist test.t4 analyze Error Table 'test.t4' doesn't exist
test.t4 analyze error Corrupt
test.t1 analyze status Table is already up to date test.t1 analyze status Table is already up to date
Warnings:
Error 1146 Table 'test.t4' doesn't exist
deallocate prepare stmt; deallocate prepare stmt;
drop table t1, t2, t3; drop table t1, t2, t3;
create database mysqltest_long_database_name_to_thrash_heap; create database mysqltest_long_database_name_to_thrash_heap;
......
...@@ -26,16 +26,14 @@ t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled ...@@ -26,16 +26,14 @@ t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled
drop table t1; drop table t1;
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 error Table 'test.t1' doesn't exist test.t1 repair Error Table 'test.t1' doesn't exist
Warnings: test.t1 repair error Corrupt
Error 1146 Table 'test.t1' doesn't exist
create table t1 engine=myisam SELECT 1,"table 1"; 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 Incorrect file format 't1' test.t1 repair Error Incorrect file format 't1'
Warnings: test.t1 repair error Corrupt
Error 130 Incorrect file format 't1'
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
......
...@@ -15,7 +15,6 @@ Warnings: ...@@ -15,7 +15,6 @@ Warnings:
Error 1205 Lock wait timeout exceeded; try restarting transaction Error 1205 Lock wait timeout exceeded; try restarting transaction
OPTIMIZE TABLE non_existing; OPTIMIZE TABLE non_existing;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.non_existing optimize error Table 'test.non_existing' doesn't exist test.non_existing optimize Error Table 'test.non_existing' doesn't exist
Warnings: test.non_existing optimize error Corrupt
Error 1146 Table 'test.non_existing' doesn't exist
drop table t1; drop table t1;
...@@ -4409,55 +4409,58 @@ Table Op Msg_type Msg_text ...@@ -4409,55 +4409,58 @@ Table Op Msg_type Msg_text
test.t1 repair status OK test.t1 repair status OK
test.t2 repair status OK test.t2 repair status OK
test.t3 repair status OK test.t3 repair status OK
test.v1 repair error 'test.v1' is not BASE TABLE test.v1 repair Error 'test.v1' is not BASE TABLE
test.v1 repair error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
test.t2 optimize status OK test.t2 optimize status OK
test.t3 optimize status OK test.t3 optimize status OK
test.v1 optimize error 'test.v1' is not BASE TABLE test.v1 optimize Error 'test.v1' is not BASE TABLE
test.v1 optimize error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date test.t2 analyze status Table is already up to date
test.t3 analyze status Table is already up to date test.t3 analyze status Table is already up to date
test.v1 analyze error 'test.v1' is not BASE TABLE test.v1 analyze Error 'test.v1' is not BASE TABLE
Warnings: test.v1 analyze error Corrupt
Error 1347 'test.v1' is not BASE TABLE
call bug13012()| call bug13012()|
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair status OK test.t1 repair status OK
test.t2 repair status OK test.t2 repair status OK
test.t3 repair status OK test.t3 repair status OK
test.v1 repair error 'test.v1' is not BASE TABLE test.v1 repair Error 'test.v1' is not BASE TABLE
test.v1 repair error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
test.t2 optimize status OK test.t2 optimize status OK
test.t3 optimize status OK test.t3 optimize status OK
test.v1 optimize error 'test.v1' is not BASE TABLE test.v1 optimize Error 'test.v1' is not BASE TABLE
test.v1 optimize error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date test.t2 analyze status Table is already up to date
test.t3 analyze status Table is already up to date test.t3 analyze status Table is already up to date
test.v1 analyze error 'test.v1' is not BASE TABLE test.v1 analyze Error 'test.v1' is not BASE TABLE
Warnings: test.v1 analyze error Corrupt
Error 1347 'test.v1' is not BASE TABLE
call bug13012()| call bug13012()|
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair status OK test.t1 repair status OK
test.t2 repair status OK test.t2 repair status OK
test.t3 repair status OK test.t3 repair status OK
test.v1 repair error 'test.v1' is not BASE TABLE test.v1 repair Error 'test.v1' is not BASE TABLE
test.v1 repair error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
test.t2 optimize status OK test.t2 optimize status OK
test.t3 optimize status OK test.t3 optimize status OK
test.v1 optimize error 'test.v1' is not BASE TABLE test.v1 optimize Error 'test.v1' is not BASE TABLE
test.v1 optimize error Corrupt
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date test.t1 analyze status Table is already up to date
test.t2 analyze status Table is already up to date test.t2 analyze status Table is already up to date
test.t3 analyze status Table is already up to date test.t3 analyze status Table is already up to date
test.v1 analyze error 'test.v1' is not BASE TABLE test.v1 analyze Error 'test.v1' is not BASE TABLE
Warnings: test.v1 analyze error Corrupt
Error 1347 'test.v1' is not BASE TABLE
drop procedure bug13012| drop procedure bug13012|
drop view v1; drop view v1;
select * from t1| select * from t1|
......
...@@ -1377,7 +1377,9 @@ test.t1 check status OK ...@@ -1377,7 +1377,9 @@ test.t1 check status OK
drop table t1; drop table t1;
check table v1; check table v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v1 check Error Table 'test.t1' doesn't exist
test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v1 check error Corrupt
drop view v1; drop view v1;
create table t1 (a int); create table t1 (a int);
create table t2 (a int); create table t2 (a int);
...@@ -1901,11 +1903,17 @@ CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2; ...@@ -1901,11 +1903,17 @@ CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
DROP TABLE t1; DROP TABLE t1;
CHECK TABLE v1, v2, v3, v4, v5, v6; CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v1 check Error Table 'test.t1' doesn't exist
test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v1 check error Corrupt
test.v2 check status OK test.v2 check status OK
test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v3 check Error Table 'test.t1' doesn't exist
test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v3 check error Corrupt
test.v4 check status OK test.v4 check status OK
test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v5 check Error Table 'test.t1' doesn't exist
test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v5 check error Corrupt
test.v6 check status OK test.v6 check status OK
drop view v1, v2, v3, v4, v5, v6; drop view v1, v2, v3, v4, v5, v6;
drop table t2; drop table t2;
...@@ -1925,11 +1933,17 @@ CREATE VIEW v6 AS SELECT f2() FROM t3; ...@@ -1925,11 +1933,17 @@ CREATE VIEW v6 AS SELECT f2() FROM t3;
drop function f1; drop function f1;
CHECK TABLE v1, v2, v3, v4, v5, v6; CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v1 check Error FUNCTION test.f1 does not exist
test.v1 check Error View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v1 check error Corrupt
test.v2 check status OK test.v2 check status OK
test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v3 check Error FUNCTION test.f1 does not exist
test.v3 check Error View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v3 check error Corrupt
test.v4 check status OK test.v4 check status OK
test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them test.v5 check Error FUNCTION test.f1 does not exist
test.v5 check Error View 'test.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
test.v5 check error Corrupt
test.v6 check status OK test.v6 check status OK
create function f1 () returns int return (select max(col1) from t1); create function f1 () returns int return (select max(col1) from t1);
DROP TABLE t1; DROP TABLE t1;
...@@ -2376,35 +2390,29 @@ CREATE TABLE t1(id INT); ...@@ -2376,35 +2390,29 @@ CREATE TABLE t1(id INT);
CREATE VIEW v1 AS SELECT id FROM t1; CREATE VIEW v1 AS SELECT id FROM t1;
OPTIMIZE TABLE v1; OPTIMIZE TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 optimize error 'test.v1' is not BASE TABLE test.v1 optimize Error 'test.v1' is not BASE TABLE
Warnings: test.v1 optimize error Corrupt
Error 1347 'test.v1' is not BASE TABLE
ANALYZE TABLE v1; ANALYZE TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 analyze error 'test.v1' is not BASE TABLE test.v1 analyze Error 'test.v1' is not BASE TABLE
Warnings: test.v1 analyze error Corrupt
Error 1347 'test.v1' is not BASE TABLE
REPAIR TABLE v1; REPAIR TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 repair error 'test.v1' is not BASE TABLE test.v1 repair Error 'test.v1' is not BASE TABLE
Warnings: test.v1 repair error Corrupt
Error 1347 'test.v1' is not BASE TABLE
DROP TABLE t1; DROP TABLE t1;
OPTIMIZE TABLE v1; OPTIMIZE TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 optimize error 'test.v1' is not BASE TABLE test.v1 optimize Error 'test.v1' is not BASE TABLE
Warnings: test.v1 optimize error Corrupt
Error 1347 'test.v1' is not BASE TABLE
ANALYZE TABLE v1; ANALYZE TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 analyze error 'test.v1' is not BASE TABLE test.v1 analyze Error 'test.v1' is not BASE TABLE
Warnings: test.v1 analyze error Corrupt
Error 1347 'test.v1' is not BASE TABLE
REPAIR TABLE v1; REPAIR TABLE v1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.v1 repair error 'test.v1' is not BASE TABLE test.v1 repair Error 'test.v1' is not BASE TABLE
Warnings: test.v1 repair error Corrupt
Error 1347 'test.v1' is not BASE TABLE
DROP VIEW v1; DROP VIEW v1;
create definer = current_user() sql security invoker view v1 as select 1; create definer = current_user() sql security invoker view v1 as select 1;
show create view v1; show create view v1;
......
...@@ -486,4 +486,25 @@ insert into t1 values (1); ...@@ -486,4 +486,25 @@ insert into t1 values (1);
drop table t2; drop table t2;
drop table t1; drop table t1;
#
# BUG#26976 - Missing table in merge not noted in related error msg + SHOW
# CREATE TABLE fails
#
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
--error 1168
SELECT * FROM tm1;
CHECK TABLE tm1;
CREATE TABLE t1(a INT);
--error 1168
SELECT * FROM tm1;
CHECK TABLE tm1;
CREATE TABLE t2(a BLOB);
--error 1168
SELECT * FROM tm1;
CHECK TABLE tm1;
ALTER TABLE t2 MODIFY a INT;
SELECT * FROM tm1;
CHECK TABLE tm1;
DROP TABLE tm1, t1, t2;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -109,6 +109,14 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, ...@@ -109,6 +109,14 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
} }
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) - length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
name); name);
/*
TODO: switch from protocol to push_warning here. The main reason we didn't
it yet is parallel repair. Due to following trace:
mi_check_print_msg/push_warning/sql_alloc/my_pthread_getspecific_ptr.
Also we likely need to lock mutex here (in both cases with protocol and
push_warning).
*/
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(name, length, system_charset_info); protocol->store(name, length, system_charset_info);
protocol->store(param->op_name, system_charset_info); protocol->store(param->op_name, system_charset_info);
...@@ -1138,11 +1146,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -1138,11 +1146,7 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
/* We only come here when the user did specify an index map */ /* We only come here when the user did specify an index map */
key_map kmap; key_map kmap;
if (get_key_map_from_key_list(&kmap, table, table_list->use_index)) if (get_key_map_from_key_list(&kmap, table, table_list->use_index))
{ DBUG_RETURN(HA_ADMIN_FAILED);
errmsg= thd->net.last_error;
error= HA_ADMIN_FAILED;
goto err;
}
map= kmap.to_ulonglong(); map= kmap.to_ulonglong();
} }
...@@ -1155,7 +1159,6 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -1155,7 +1159,6 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
error= HA_ADMIN_CORRUPT; error= HA_ADMIN_CORRUPT;
} }
err:
if (error != HA_ADMIN_OK) if (error != HA_ADMIN_OK)
{ {
/* Send error to user */ /* Send error to user */
...@@ -1192,11 +1195,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt) ...@@ -1192,11 +1195,7 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
key_map kmap; key_map kmap;
get_key_map_from_key_list(&kmap, table, table_list->use_index); get_key_map_from_key_list(&kmap, table, table_list->use_index);
if (kmap.is_set_all()) if (kmap.is_set_all())
{ DBUG_RETURN(HA_ADMIN_FAILED);
errmsg= thd->net.last_error;
error= HA_ADMIN_FAILED;
goto err;
}
if (!kmap.is_clear_all()) if (!kmap.is_clear_all())
map= kmap.to_ulonglong(); map= kmap.to_ulonglong();
} }
......
...@@ -72,6 +72,13 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, ...@@ -72,6 +72,13 @@ extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo,
uint t1_keys, uint t1_recs, uint t1_keys, uint t1_recs,
MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo,
uint t2_keys, uint t2_recs, bool strict); uint t2_keys, uint t2_recs, bool strict);
extern "C" void myrg_print_wrong_table(const char *table_name)
{
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ADMIN_WRONG_MRG_TABLE, ER(ER_ADMIN_WRONG_MRG_TABLE),
table_name);
}
const char **ha_myisammrg::bas_ext() const const char **ha_myisammrg::bas_ext() const
{ {
...@@ -121,6 +128,8 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) ...@@ -121,6 +128,8 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
{ {
DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu", DBUG_PRINT("error",("reclength: %lu mean_rec_length: %lu",
table->s->reclength, mean_rec_length)); table->s->reclength, mean_rec_length));
if (test_if_locked & HA_OPEN_FOR_REPAIR)
myrg_print_wrong_table(file->open_tables->table->filename);
error= HA_ERR_WRONG_MRG_TABLE_DEF; error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err; goto err;
} }
...@@ -139,12 +148,19 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) ...@@ -139,12 +148,19 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
u_table->table->s->base.keys, u_table->table->s->base.keys,
u_table->table->s->base.fields, false)) u_table->table->s->base.fields, false))
{ {
my_free((gptr) recinfo, MYF(0));
error= HA_ERR_WRONG_MRG_TABLE_DEF; error= HA_ERR_WRONG_MRG_TABLE_DEF;
goto err; if (test_if_locked & HA_OPEN_FOR_REPAIR)
myrg_print_wrong_table(u_table->table->filename);
else
{
my_free((gptr) recinfo, MYF(0));
goto err;
}
} }
} }
my_free((gptr) recinfo, MYF(0)); my_free((gptr) recinfo, MYF(0));
if (error == HA_ERR_WRONG_MRG_TABLE_DEF)
goto err;
#if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4
/* Merge table has more than 2G rows */ /* Merge table has more than 2G rows */
if (table->s->crashed) if (table->s->crashed)
...@@ -597,3 +613,9 @@ void ha_myisammrg::append_create_info(String *packet) ...@@ -597,3 +613,9 @@ void ha_myisammrg::append_create_info(String *packet)
} }
packet->append(')'); packet->append(')');
} }
int ha_myisammrg::check(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_OK;
}
...@@ -81,4 +81,5 @@ class ha_myisammrg: public handler ...@@ -81,4 +81,5 @@ class ha_myisammrg: public handler
void update_create_info(HA_CREATE_INFO *create_info); void update_create_info(HA_CREATE_INFO *create_info);
void append_create_info(String *packet); void append_create_info(String *packet);
MYRG_INFO *myrg_info() { return file; } MYRG_INFO *myrg_info() { return file; }
int check(THD* thd, HA_CHECK_OPT* check_opt);
}; };
...@@ -5633,4 +5633,5 @@ ER_WRONG_STRING_LENGTH ...@@ -5633,4 +5633,5 @@ ER_WRONG_STRING_LENGTH
eng "String '%-.70s' is too long for %s (should be no longer than %d)" eng "String '%-.70s' is too long for %s (should be no longer than %d)"
ER_NON_INSERTABLE_TABLE ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into" eng "The target table %-.100s of the %s is not insertable-into"
ER_ADMIN_WRONG_MRG_TABLE
eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"
...@@ -205,8 +205,8 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, ...@@ -205,8 +205,8 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
TRUE Error sending data to client TRUE Error sending data to client
*/ */
static const char *warning_level_names[]= {"Note", "Warning", "Error", "?"}; const char *warning_level_names[]= {"Note", "Warning", "Error", "?"};
static int warning_level_length[]= { 4, 7, 5, 1 }; int warning_level_length[]= { 4, 7, 5, 1 };
bool mysqld_show_warnings(THD *thd, ulong levels_to_show) bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
{ {
......
...@@ -39,3 +39,5 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level, ...@@ -39,3 +39,5 @@ void push_warning_printf(THD *thd, MYSQL_ERROR::enum_warning_level level,
uint code, const char *format, ...); uint code, const char *format, ...);
void mysql_reset_errors(THD *thd, bool force); void mysql_reset_errors(THD *thd, bool force);
bool mysqld_show_warnings(THD *thd, ulong levels_to_show); bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
extern const char *warning_level_names[];
extern int warning_level_length[];
...@@ -2283,33 +2283,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2283,33 +2283,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
*/ */
if (!table->table) if (!table->table)
{ {
char buf[ERRMSGSIZE+ERRMSGSIZE+2]; if (!thd->warn_list.elements)
const char *err_msg; push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
protocol->prepare_for_resend(); ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE));
protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info);
protocol->store(STRING_WITH_LEN("error"), system_charset_info);
if (!(err_msg=thd->net.last_error))
err_msg=ER(ER_CHECK_NO_SUCH_TABLE);
/* if it was a view will check md5 sum */ /* if it was a view will check md5 sum */
if (table->view && if (table->view &&
view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM) view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
{ push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
strxmov(buf, err_msg, "; ", ER(ER_VIEW_CHECKSUM), NullS); ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
err_msg= (const char *)buf; result_code= HA_ADMIN_CORRUPT;
} goto send_result;
protocol->store(err_msg, system_charset_info);
lex->cleanup_after_one_table_open();
thd->clear_error();
/*
View opening can be interrupted in the middle of process so some
tables can be left opening
*/
close_thread_tables(thd);
lex->reset_query_tables_list(FALSE);
if (protocol->write())
goto err;
continue;
} }
if (table->view) if (table->view)
...@@ -2391,6 +2374,22 @@ send_result: ...@@ -2391,6 +2374,22 @@ send_result:
lex->cleanup_after_one_table_open(); lex->cleanup_after_one_table_open();
thd->clear_error(); // these errors shouldn't get client thd->clear_error(); // these errors shouldn't get client
{
List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
MYSQL_ERROR *err;
while ((err= it++))
{
protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info);
protocol->store((char*) operator_name, system_charset_info);
protocol->store(warning_level_names[err->level],
warning_level_length[err->level], system_charset_info);
protocol->store(err->msg, system_charset_info);
if (protocol->write())
goto err;
}
mysql_reset_errors(thd, true);
}
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info); protocol->store(table_name, system_charset_info);
protocol->store(operator_name, system_charset_info); protocol->store(operator_name, system_charset_info);
...@@ -2924,7 +2923,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) ...@@ -2924,7 +2923,7 @@ bool mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
DBUG_ENTER("mysql_check_table"); DBUG_ENTER("mysql_check_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
"check", lock_type, "check", lock_type,
0, HA_OPEN_FOR_REPAIR, 0, 0, 0, 0, HA_OPEN_FOR_REPAIR, 0,
&handler::ha_check, &view_checksum)); &handler::ha_check, &view_checksum));
} }
......
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