mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
WL1424 Multiple MySQL Servers: SHOW TABLES etc. should detect new and delete old tables.
include/my_base.h: Added new bit to table create options Removed old error code HA_ERR_OLD_METADAT and reused it for HA_ERR_NO_SUCH_TABLE. mysql-test/r/ndb_autodiscover.result: Updated test cases mysql-test/t/ndb_autodiscover.test: Updated test cases mysql-test/t/ndb_autodiscover2.test: Updated test cases sql/discover.cc: Moved function create_table_from_handler to handler.cc sql/ha_ndbcluster.cc: Improved discover functionality Added .ndb file Changed error code mappings for a table that does not exist in engine Check for ndb object in THD Updated ndbcluster_discover, ndbcluster_list_tables and ndbcluster_can_discover sql/ha_ndbcluster.h: Improved discover sql/handler.cc: Added new error message mapping. Moved function ha_create_table_from_engine to handler level Added new functions ha_can_discover, ha_list_tables and ha_table_exists sql/handler.h: Added new error message mapping. Moved function ha_create_table_from_engine to handler level Added new functions ha_can_discover, ha_list_tables and ha_table_exists sql/mysql_priv.h: Removed create_table_from_handler, moved to handler.h sql/sql_base.cc: Renamed function create_table_from_handler sql/sql_show.cc: Added new function mysql_discover_files and mysql_list_files. Modified mysql_find_files to discover new and delete "old" files/tables. sql/sql_table.cc: Renamed create_table_from_handler Call ha_create_table_from_engine, in order to discover the the frm file before it can be dropped. sql/table.cc: Added mapping of the error code HA_ERR_NO_SUCH_TABLE
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t9;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t9;
|
||||
flush status;
|
||||
create table t1(
|
||||
id int not null primary key,
|
||||
@ -94,8 +94,6 @@ ERROR 42S01: Table 't3' already exists
|
||||
show status like 'handler_discover%';
|
||||
Variable_name Value
|
||||
Handler_discover 1
|
||||
SHOW TABLES FROM test;
|
||||
Tables_in_test
|
||||
create table IF NOT EXISTS t3(
|
||||
id int not null primary key,
|
||||
id2 int not null,
|
||||
@ -119,6 +117,40 @@ Variable_name Value
|
||||
Handler_discover 2
|
||||
drop table t3;
|
||||
flush status;
|
||||
create table t7(
|
||||
id int not null primary key,
|
||||
name char(255)
|
||||
) engine=ndb;
|
||||
create table t6(
|
||||
id int not null primary key,
|
||||
name char(255)
|
||||
) engine=MyISAM;
|
||||
insert into t7 values (1, "Explorer");
|
||||
insert into t6 values (2, "MyISAM table");
|
||||
select * from t7;
|
||||
id name
|
||||
1 Explorer
|
||||
show status like 'handler_discover%';
|
||||
Variable_name Value
|
||||
Handler_discover 0
|
||||
flush tables;
|
||||
show tables from test;
|
||||
Tables_in_test
|
||||
t6
|
||||
t7
|
||||
show status like 'handler_discover%';
|
||||
Variable_name Value
|
||||
Handler_discover 1
|
||||
flush tables;
|
||||
show table status;
|
||||
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
||||
t6 MyISAM 9 Fixed 1 260 # # # 0 NULL # # NULL # NULL
|
||||
t7 ndbcluster 9 Fixed 100 0 # # # 0 NULL # # NULL # NULL
|
||||
show status like 'handler_discover%';
|
||||
Variable_name Value
|
||||
Handler_discover 2
|
||||
drop table t6, t7;
|
||||
flush status;
|
||||
show status like 'handler_discover%';
|
||||
Variable_name Value
|
||||
Handler_discover 0
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- source include/have_ndb.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t9;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t9;
|
||||
--enable_warnings
|
||||
|
||||
################################################
|
||||
@ -122,7 +122,6 @@ create table t3(
|
||||
# IF NOT EXISTS wasn't specified
|
||||
|
||||
show status like 'handler_discover%';
|
||||
SHOW TABLES FROM test;
|
||||
|
||||
# now it should be discovered
|
||||
create table IF NOT EXISTS t3(
|
||||
@ -145,38 +144,76 @@ show status like 'handler_discover%';
|
||||
|
||||
drop table t3;
|
||||
|
||||
#######################################################
|
||||
# Test that a table that already exists as frm file
|
||||
# but not in NDB can be deleted from disk.
|
||||
##################################################
|
||||
# Test that a table that already exists in NDB
|
||||
# is discovered when SHOW TABLES
|
||||
# is used
|
||||
#
|
||||
|
||||
# Manual test
|
||||
#flush status;
|
||||
#
|
||||
#create table t4(
|
||||
# id int not null primary key,
|
||||
# name char(27)
|
||||
#) engine=ndb;
|
||||
#insert into t4 values (1, "Automatic");
|
||||
#select * from t4;
|
||||
flush status;
|
||||
|
||||
create table t7(
|
||||
id int not null primary key,
|
||||
name char(255)
|
||||
) engine=ndb;
|
||||
create table t6(
|
||||
id int not null primary key,
|
||||
name char(255)
|
||||
) engine=MyISAM;
|
||||
insert into t7 values (1, "Explorer");
|
||||
insert into t6 values (2, "MyISAM table");
|
||||
select * from t7;
|
||||
show status like 'handler_discover%';
|
||||
|
||||
# Remove the frm file from disk
|
||||
flush tables;
|
||||
system rm var/master-data/test/t7.frm ;
|
||||
|
||||
show tables from test;
|
||||
show status like 'handler_discover%';
|
||||
|
||||
# Remove the frm file from disk again
|
||||
flush tables;
|
||||
system rm var/master-data/test/t7.frm ;
|
||||
|
||||
--replace_column 7 # 8 # 9 # 12 # 13 # 15 #
|
||||
show table status;
|
||||
show status like 'handler_discover%';
|
||||
|
||||
drop table t6, t7;
|
||||
|
||||
|
||||
#######################################################
|
||||
# Test that a table that has been dropped from NDB
|
||||
# but still exists on disk, get a consistent error message
|
||||
# saying "No such table existed"
|
||||
#
|
||||
|
||||
flush status;
|
||||
|
||||
create table t4(
|
||||
id int not null primary key,
|
||||
name char(27)
|
||||
) engine=ndb;
|
||||
insert into t4 values (1, "Automatic");
|
||||
select * from t4;
|
||||
|
||||
# Remove the table from NDB
|
||||
#system drop_tab -c "$NDB_CONNECTSTRING2" -d test t4 > /dev/null ;
|
||||
#system drop_tab -c "host=localhost:2200;nodeid=5" -d test t4 > /dev/null ;
|
||||
#
|
||||
#--error 1296
|
||||
#select * from t4;
|
||||
#
|
||||
#flush table t4;
|
||||
#--error 1016
|
||||
#select * from t4;
|
||||
#
|
||||
#show status like 'handler_discover%';
|
||||
#drop table t4;
|
||||
#flush tables;
|
||||
#show tables;
|
||||
#--error 1146
|
||||
#select * from t4;
|
||||
system exec $NDB_TOOLS_DIR/ndb_drop_table -d test t4;
|
||||
|
||||
system exec ../ndb/tools/ndb_show_tables > show_tables.log;
|
||||
|
||||
# Test that correct error is returned
|
||||
--error 1146
|
||||
select * from t4;
|
||||
--error 1146
|
||||
select * from t4;
|
||||
|
||||
show status like 'handler_discover%';
|
||||
drop table t4;
|
||||
|
||||
show tables;
|
||||
|
||||
|
||||
|
||||
#########################################################
|
||||
@ -241,7 +278,6 @@ show status like 'handler_discover%';
|
||||
drop table t6;
|
||||
|
||||
######################################################
|
||||
# Simple test to show use of discover on startup
|
||||
# Note! This should always be the last step in this
|
||||
# file, the table t9 will be used and dropped
|
||||
# by ndb_autodiscover2
|
||||
@ -259,8 +295,7 @@ system rm var/master-data/test/t9.frm ;
|
||||
|
||||
# Now leave test case, when ndb_autodiscover2 will run, this
|
||||
# MySQL Server will have been restarted because it has a
|
||||
# ndb_autodiscover2-master.opt file. And thus the table should
|
||||
# have been discovered by the "discover on startup" function.
|
||||
# ndb_autodiscover2-master.opt file.
|
||||
|
||||
#TODO
|
||||
#SLECT * FROM t1, t2, t4;
|
||||
|
@ -1,14 +1,16 @@
|
||||
-- source include/have_ndb.inc
|
||||
|
||||
#
|
||||
# Simple test to show use of discover on startup
|
||||
# Simple test to show use of discover when the server has been restarted
|
||||
# The previous step has simply removed the frm file
|
||||
# from disk, but left the table in NDB
|
||||
#
|
||||
--sleep 3;
|
||||
select * from t9 order by a;
|
||||
|
||||
# handler_discover should be zero
|
||||
# handler_discover should be 1
|
||||
show status like 'handler_discover%';
|
||||
|
||||
drop table t9;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user