WL#3732 Information schema optimization
client/mysqldump.c: table type compare is changed to case insensitive mysql-test/r/information_schema.result: test result mysql-test/r/information_schema_db.result: result fix mysql-test/suite/ndb/r/ndb_alter_table.result: result fix mysql-test/suite/ndb/r/ndb_temporary.result: result fix mysql-test/t/information_schema.test: test case sql/ha_ndbcluster.cc: char* variables are changed to LEX_STRING sql/ha_ndbcluster.h: char* variables are changed to LEX_STRING sql/ha_ndbcluster_binlog.cc: char* variables are changed to LEX_STRING sql/handler.cc: char* variables are changed to LEX_STRING sql/handler.h: char* variables are changed to LEX_STRING sql/sql_base.cc: Modified functions which are used during open table process according to table opening method and requested_object. sql/sql_select.cc: Add support for I_S tables into select_describe() function sql/sql_show.cc: 1. Added initialization of 'open_method' to 'st_field_info' structs. 2. Added initialization of 'i_s_requested_object' to 'ST_SCHEMA_TABLE' structs. 3. New function which calculates database name and table name values from 'where' condition if it's possible void get_lookup_field_values(THD *thd, COND *cond, TABLE_LIST *table, LOOKUP_FIELD_VALUES *lookup_field_vals); 4. New function which set table open method setup_table_open_method(TABLE_LIST *tables, ST_SCHEMA_TABLE *schema_table, enum enum_schema_tables schema_table_idx) 5. New function int make_db_list(THD *thd, List<LEX_STRING> *files, LOOKUP_FIELD_VALUES *lookup_field_vals, bool *with_i_schema) 6. New function int make_table_name_list(THD *thd, List<LEX_STRING> *files, LEX *lex, LOOKUP_FIELD_VALUES *lookup_field_vals, bool with_i_schema, LEX_STRING *db_name) 7. Modified 'get_all_tables' function according to new schema(see wl#3732). sql/sql_show.h: char* variables are changed to LEX_STRING sql/table.cc: Modified functions which are used during open table process according to table opening method and requested_object. sql/table.h: 1. added new constants(open_method) #define SKIP_OPEN_TABLE 0 #define OPEN_FRM_ONLY 1 #define OPEN_FULL_TABLE 2 2. Added new field 'open_method' into struct st_field_info; uint open_method; 3. Added new field into ST_SCHEMA_TABLE struct uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */. 4. Added new field to TABLE_LIST struct. uint i_s_requested_object; This field is set from ST_SCHEMA_TABLE.i_s_requested_object for processed table before opening. 5. Added new fields to TABLE_LIST struct, used for 'explain select' for I_S table bool has_db_lookup_value; bool has_table_lookup_value; uint table_open_method; sql/unireg.h: added new constants
This commit is contained in:
parent
8df5a067c3
commit
82d28fada7
@ -4288,7 +4288,8 @@ char check_if_ignore_table(const char *table_name, char *table_type)
|
|||||||
If these two types, we do want to skip dumping the table
|
If these two types, we do want to skip dumping the table
|
||||||
*/
|
*/
|
||||||
if (!opt_no_data &&
|
if (!opt_no_data &&
|
||||||
(!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM")))
|
(!my_strcasecmp(&my_charset_latin1, table_type, "MRG_MyISAM") ||
|
||||||
|
!strcmp(table_type,"MRG_ISAM")))
|
||||||
result= IGNORE_DATA;
|
result= IGNORE_DATA;
|
||||||
}
|
}
|
||||||
mysql_free_result(res);
|
mysql_free_result(res);
|
||||||
|
@ -289,8 +289,8 @@ explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
|
|||||||
information_schema.SCHEMATA b where
|
information_schema.SCHEMATA b where
|
||||||
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
|
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE # ALL NULL NULL NULL NULL 2
|
1 SIMPLE # ALL NULL NULL NULL NULL NULL
|
||||||
1 SIMPLE # ALL NULL NULL NULL NULL 2 Using where; Using join buffer
|
1 SIMPLE # ALL NULL NULL NULL NULL NULL Using where; Using join buffer
|
||||||
select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
|
select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a,
|
||||||
mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1;
|
mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1;
|
||||||
ROUTINE_NAME name
|
ROUTINE_NAME name
|
||||||
@ -355,7 +355,7 @@ mysql
|
|||||||
test
|
test
|
||||||
explain select * from v0;
|
explain select * from v0;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE # ALL NULL NULL NULL NULL 2
|
1 SIMPLE # ALL NULL NULL NULL NULL NULL
|
||||||
create view v1 (c) as select table_name from information_schema.tables
|
create view v1 (c) as select table_name from information_schema.tables
|
||||||
where table_name="v1";
|
where table_name="v1";
|
||||||
select * from v1;
|
select * from v1;
|
||||||
@ -679,17 +679,11 @@ where table_schema='test';
|
|||||||
table_name
|
table_name
|
||||||
v2
|
v2
|
||||||
v3
|
v3
|
||||||
Warnings:
|
|
||||||
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
|
||||||
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
|
||||||
select table_name from information_schema.views
|
select table_name from information_schema.views
|
||||||
where table_schema='test';
|
where table_schema='test';
|
||||||
table_name
|
table_name
|
||||||
v2
|
v2
|
||||||
v3
|
v3
|
||||||
Warnings:
|
|
||||||
Warning 1356 View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
|
||||||
Warning 1356 View 'test.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
|
||||||
select column_name from information_schema.columns
|
select column_name from information_schema.columns
|
||||||
where table_schema='test';
|
where table_schema='test';
|
||||||
column_name
|
column_name
|
||||||
@ -1337,11 +1331,11 @@ from information_schema.tables
|
|||||||
order by object_schema;
|
order by object_schema;
|
||||||
explain select * from v1;
|
explain select * from v1;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE tables ALL NULL NULL NULL NULL 2 Using filesort
|
1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_frm_only; Scanned all databases; Using filesort
|
||||||
explain select * from (select table_name from information_schema.tables) as a;
|
explain select * from (select table_name from information_schema.tables) as a;
|
||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
|
1 PRIMARY <derived2> system NULL NULL NULL NULL 0 const row not found
|
||||||
2 DERIVED tables ALL NULL NULL NULL NULL 2
|
2 DERIVED tables ALL NULL NULL NULL NULL NULL Skip_open_table; Scanned all databases
|
||||||
drop view v1;
|
drop view v1;
|
||||||
create table t1 (f1 int(11));
|
create table t1 (f1 int(11));
|
||||||
create table t2 (f1 int(11), f2 int(11));
|
create table t2 (f1 int(11), f2 int(11));
|
||||||
@ -1445,4 +1439,28 @@ ABORTED_CONNECTS
|
|||||||
BINLOG_CACHE_DISK_USE
|
BINLOG_CACHE_DISK_USE
|
||||||
DROP TABLE server_status;
|
DROP TABLE server_status;
|
||||||
SET GLOBAL event_scheduler=0;
|
SET GLOBAL event_scheduler=0;
|
||||||
|
explain select table_name from information_schema.views where
|
||||||
|
table_schema='test' and table_name='v1';
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE views ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_frm_only; Scanned 0 databases
|
||||||
|
explain select * from information_schema.tables;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE tables ALL NULL NULL NULL NULL NULL Open_full_table; Scanned all databases
|
||||||
|
explain select * from information_schema.collations;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE collations ALL NULL NULL NULL NULL NULL
|
||||||
|
explain select * from information_schema.tables where
|
||||||
|
table_schema='test' and table_name= 't1';
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE tables ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Open_full_table; Scanned 0 databases
|
||||||
|
explain select table_name, table_type from information_schema.tables
|
||||||
|
where table_schema='test';
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE tables ALL NULL TABLE_SCHEMA NULL NULL NULL Using where; Open_frm_only; Scanned 1 database
|
||||||
|
explain select b.table_name
|
||||||
|
from information_schema.tables a, information_schema.columns b
|
||||||
|
where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE a ALL NULL TABLE_SCHEMA,TABLE_NAME NULL NULL NULL Using where; Skip_open_table; Scanned 0 databases
|
||||||
|
1 SIMPLE b ALL NULL NULL NULL NULL NULL Using where; Open_frm_only; Scanned all databases; Using join buffer
|
||||||
End of 5.1 tests.
|
End of 5.1 tests.
|
||||||
|
@ -74,11 +74,11 @@ drop table t1;
|
|||||||
select table_name, table_type, table_comment from information_schema.tables
|
select table_name, table_type, table_comment from information_schema.tables
|
||||||
where table_schema='inf%' and func2();
|
where table_schema='inf%' and func2();
|
||||||
table_name table_type table_comment
|
table_name table_type table_comment
|
||||||
v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define
|
v1 VIEW VIEW
|
||||||
select table_name, table_type, table_comment from information_schema.tables
|
select table_name, table_type, table_comment from information_schema.tables
|
||||||
where table_schema='inf%' and func2();
|
where table_schema='inf%' and func2();
|
||||||
table_name table_type table_comment
|
table_name table_type table_comment
|
||||||
v1 VIEW View 'inf%.v1' references invalid table(s) or column(s) or function(s) or define
|
v1 VIEW VIEW
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop function func1;
|
drop function func1;
|
||||||
drop function func2;
|
drop function func2;
|
||||||
|
@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
|
|||||||
col6 int not null, to_be_deleted int) ENGINE=ndbcluster;
|
col6 int not null, to_be_deleted int) ENGINE=ndbcluster;
|
||||||
show table status;
|
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
|
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
|
||||||
t1 NDBCLUSTER 10 Dynamic 0 # # # 0 # 1 # # # latin1_swedish_ci NULL #
|
t1 ndbcluster 10 Dynamic 0 # # # 0 # 1 # # # latin1_swedish_ci NULL #
|
||||||
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
|
SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
|
||||||
insert into t1 values
|
insert into t1 values
|
||||||
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
|
(0,4,3,5,"PENDING",1,7),(NULL,4,3,5,"PENDING",1,7),(31,4,3,5,"PENDING",1,7), (7,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7), (100,4,3,5,"PENDING",1,7), (99,4,3,5,"PENDING",1,7), (8,4,3,5,"PENDING",1,7), (NULL,4,3,5,"PENDING",1,7);
|
||||||
show table status;
|
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
|
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
|
||||||
t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL #
|
t1 ndbcluster 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL #
|
||||||
select * from t1 order by col1;
|
select * from t1 order by col1;
|
||||||
col1 col2 col3 col4 col5 col6 to_be_deleted
|
col1 col2 col3 col4 col5 col6 to_be_deleted
|
||||||
0 4 3 5 PENDING 1 7
|
0 4 3 5 PENDING 1 7
|
||||||
@ -60,7 +60,7 @@ change column col2 fourth varchar(30) not null after col3,
|
|||||||
modify column col6 int not null first;
|
modify column col6 int not null first;
|
||||||
show table status;
|
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
|
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
|
||||||
t1 NDBCLUSTER 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL #
|
t1 ndbcluster 10 Dynamic 9 # # # 0 # 102 # # # latin1_swedish_ci NULL #
|
||||||
select * from t1 order by col1;
|
select * from t1 order by col1;
|
||||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||||
1 0 3 4 5 PENDING 0000-00-00 00:00:00
|
1 0 3 4 5 PENDING 0000-00-00 00:00:00
|
||||||
@ -75,7 +75,7 @@ col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
|||||||
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
|
insert into t1 values (2, NULL,4,3,5,99,"PENDING","EXTRA",'2004-01-01 00:00:00');
|
||||||
show table status;
|
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
|
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
|
||||||
t1 NDBCLUSTER 10 Dynamic 10 # # # 0 # 103 # # # latin1_swedish_ci NULL #
|
t1 ndbcluster 10 Dynamic 10 # # # 0 # 103 # # # latin1_swedish_ci NULL #
|
||||||
select * from t1 order by col1;
|
select * from t1 order by col1;
|
||||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||||
1 0 3 4 5 PENDING 0000-00-00 00:00:00
|
1 0 3 4 5 PENDING 0000-00-00 00:00:00
|
||||||
|
@ -9,7 +9,7 @@ SET SESSION storage_engine=NDBCLUSTER;
|
|||||||
create table t1 (a int key);
|
create table t1 (a int key);
|
||||||
select engine from information_schema.tables where table_name = 't1';
|
select engine from information_schema.tables where table_name = 't1';
|
||||||
engine
|
engine
|
||||||
NDBCLUSTER
|
ndbcluster
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create temporary table t1 (a int key);
|
create temporary table t1 (a int key);
|
||||||
show create table t1;
|
show create table t1;
|
||||||
|
@ -1100,4 +1100,24 @@ SELECT variable_name FROM server_status;
|
|||||||
DROP TABLE server_status;
|
DROP TABLE server_status;
|
||||||
SET GLOBAL event_scheduler=0;
|
SET GLOBAL event_scheduler=0;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# WL#3732 Information schema optimization
|
||||||
|
#
|
||||||
|
|
||||||
|
explain select table_name from information_schema.views where
|
||||||
|
table_schema='test' and table_name='v1';
|
||||||
|
|
||||||
|
explain select * from information_schema.tables;
|
||||||
|
explain select * from information_schema.collations;
|
||||||
|
|
||||||
|
explain select * from information_schema.tables where
|
||||||
|
table_schema='test' and table_name= 't1';
|
||||||
|
explain select table_name, table_type from information_schema.tables
|
||||||
|
where table_schema='test';
|
||||||
|
|
||||||
|
explain select b.table_name
|
||||||
|
from information_schema.tables a, information_schema.columns b
|
||||||
|
where a.table_name='t1' and a.table_schema='test' and b.table_name=a.table_name;
|
||||||
|
|
||||||
--echo End of 5.1 tests.
|
--echo End of 5.1 tests.
|
||||||
|
@ -6883,7 +6883,7 @@ int ndbcluster_find_all_files(THD *thd)
|
|||||||
int ndbcluster_find_files(handlerton *hton, THD *thd,
|
int ndbcluster_find_files(handlerton *hton, THD *thd,
|
||||||
const char *db,
|
const char *db,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *wild, bool dir, List<char> *files)
|
const char *wild, bool dir, List<LEX_STRING> *files)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("ndbcluster_find_files");
|
DBUG_ENTER("ndbcluster_find_files");
|
||||||
DBUG_PRINT("enter", ("db: %s", db));
|
DBUG_PRINT("enter", ("db: %s", db));
|
||||||
@ -6950,21 +6950,22 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
my_hash_insert(&ndb_tables, (uchar*)thd->strdup(elmt.name));
|
my_hash_insert(&ndb_tables, (uchar*)thd->strdup(elmt.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *file_name;
|
LEX_STRING *file_name;
|
||||||
List_iterator<char> it(*files);
|
List_iterator<LEX_STRING> it(*files);
|
||||||
List<char> delete_list;
|
List<char> delete_list;
|
||||||
|
char *file_name_str;
|
||||||
while ((file_name=it++))
|
while ((file_name=it++))
|
||||||
{
|
{
|
||||||
bool file_on_disk= FALSE;
|
bool file_on_disk= FALSE;
|
||||||
DBUG_PRINT("info", ("%s", file_name));
|
DBUG_PRINT("info", ("%s", file_name->str));
|
||||||
if (hash_search(&ndb_tables, (uchar*) file_name, strlen(file_name)))
|
if (hash_search(&ndb_tables, (uchar*) file_name->str, file_name->length))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name));
|
DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
|
||||||
file_on_disk= TRUE;
|
file_on_disk= TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for .ndb file with this name
|
// Check for .ndb file with this name
|
||||||
build_table_filename(name, sizeof(name), db, file_name, ha_ndb_ext, 0);
|
build_table_filename(name, sizeof(name), db, file_name->str, ha_ndb_ext, 0);
|
||||||
DBUG_PRINT("info", ("Check access for %s", name));
|
DBUG_PRINT("info", ("Check access for %s", name));
|
||||||
if (my_access(name, F_OK))
|
if (my_access(name, F_OK))
|
||||||
{
|
{
|
||||||
@ -6972,33 +6973,34 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
// .ndb file did not exist on disk, another table type
|
// .ndb file did not exist on disk, another table type
|
||||||
if (file_on_disk)
|
if (file_on_disk)
|
||||||
{
|
{
|
||||||
// Ignore this ndb table
|
// Ignore this ndb table
|
||||||
uchar *record= hash_search(&ndb_tables, (uchar*) file_name,
|
uchar *record= hash_search(&ndb_tables, (uchar*) file_name->str,
|
||||||
strlen(file_name));
|
file_name->length);
|
||||||
DBUG_ASSERT(record);
|
DBUG_ASSERT(record);
|
||||||
hash_delete(&ndb_tables, record);
|
hash_delete(&ndb_tables, record);
|
||||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
ER_TABLE_EXISTS_ERROR,
|
ER_TABLE_EXISTS_ERROR,
|
||||||
"Local table %s.%s shadows ndb table",
|
"Local table %s.%s shadows ndb table",
|
||||||
db, file_name);
|
db, file_name->str);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (file_on_disk)
|
if (file_on_disk)
|
||||||
{
|
{
|
||||||
// File existed in NDB and as frm file, put in ok_tables list
|
// File existed in NDB and as frm file, put in ok_tables list
|
||||||
my_hash_insert(&ok_tables, (uchar*)file_name);
|
my_hash_insert(&ok_tables, (uchar*) file_name->str);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("%s existed on disk", name));
|
DBUG_PRINT("info", ("%s existed on disk", name));
|
||||||
// The .ndb file exists on disk, but it's not in list of tables in ndb
|
// The .ndb file exists on disk, but it's not in list of tables in ndb
|
||||||
// Verify that handler agrees table is gone.
|
// Verify that handler agrees table is gone.
|
||||||
if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == HA_ERR_NO_SUCH_TABLE)
|
if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name->str) ==
|
||||||
|
HA_ERR_NO_SUCH_TABLE)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
|
DBUG_PRINT("info", ("NDB says %s does not exists", file_name->str));
|
||||||
it.remove();
|
it.remove();
|
||||||
// Put in list of tables to remove from disk
|
// Put in list of tables to remove from disk
|
||||||
delete_list.push_back(thd->strdup(file_name));
|
delete_list.push_back(thd->strdup(file_name->str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7009,12 +7011,12 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
build_table_filename(name, sizeof(name), db, "", "", 0);
|
build_table_filename(name, sizeof(name), db, "", "", 0);
|
||||||
for (i= 0; i < ok_tables.records; i++)
|
for (i= 0; i < ok_tables.records; i++)
|
||||||
{
|
{
|
||||||
file_name= (char*)hash_element(&ok_tables, i);
|
file_name_str= (char*)hash_element(&ok_tables, i);
|
||||||
end= end1 +
|
end= end1 +
|
||||||
tablename_to_filename(file_name, end1, sizeof(name) - (end1 - name));
|
tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
ndbcluster_create_binlog_setup(ndb, name, end-name,
|
ndbcluster_create_binlog_setup(ndb, name, end-name,
|
||||||
db, file_name, TRUE);
|
db, file_name_str, TRUE);
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7025,16 +7027,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
List<char> create_list;
|
List<char> create_list;
|
||||||
for (i= 0 ; i < ndb_tables.records ; i++)
|
for (i= 0 ; i < ndb_tables.records ; i++)
|
||||||
{
|
{
|
||||||
file_name= (char*) hash_element(&ndb_tables, i);
|
file_name_str= (char*) hash_element(&ndb_tables, i);
|
||||||
if (!hash_search(&ok_tables, (uchar*) file_name, strlen(file_name)))
|
if (!hash_search(&ok_tables, (uchar*) file_name_str, strlen(file_name_str)))
|
||||||
{
|
{
|
||||||
build_table_filename(name, sizeof(name), db, file_name, reg_ext, 0);
|
build_table_filename(name, sizeof(name), db, file_name_str, reg_ext, 0);
|
||||||
if (my_access(name, F_OK))
|
if (my_access(name, F_OK))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("%s must be discovered", file_name));
|
DBUG_PRINT("info", ("%s must be discovered", file_name_str));
|
||||||
// File is in list of ndb tables and not in ok_tables
|
// File is in list of ndb tables and not in ok_tables
|
||||||
// This table need to be created
|
// This table need to be created
|
||||||
create_list.push_back(thd->strdup(file_name));
|
create_list.push_back(thd->strdup(file_name_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7043,14 +7045,14 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
{
|
{
|
||||||
// Delete old files
|
// Delete old files
|
||||||
List_iterator_fast<char> it3(delete_list);
|
List_iterator_fast<char> it3(delete_list);
|
||||||
while ((file_name=it3++))
|
while ((file_name_str= it3++))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Remove table %s/%s", db, file_name));
|
DBUG_PRINT("info", ("Remove table %s/%s", db, file_name_str));
|
||||||
// Delete the table and all related files
|
// Delete the table and all related files
|
||||||
TABLE_LIST table_list;
|
TABLE_LIST table_list;
|
||||||
bzero((char*) &table_list,sizeof(table_list));
|
bzero((char*) &table_list,sizeof(table_list));
|
||||||
table_list.db= (char*) db;
|
table_list.db= (char*) db;
|
||||||
table_list.alias= table_list.table_name= (char*)file_name;
|
table_list.alias= table_list.table_name= (char*)file_name_str;
|
||||||
(void)mysql_rm_table_part2(thd, &table_list,
|
(void)mysql_rm_table_part2(thd, &table_list,
|
||||||
FALSE, /* if_exists */
|
FALSE, /* if_exists */
|
||||||
FALSE, /* drop_temporary */
|
FALSE, /* drop_temporary */
|
||||||
@ -7065,11 +7067,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
// Create new files
|
// Create new files
|
||||||
List_iterator_fast<char> it2(create_list);
|
List_iterator_fast<char> it2(create_list);
|
||||||
while ((file_name=it2++))
|
while ((file_name_str=it2++))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Table %s need discovery", file_name));
|
DBUG_PRINT("info", ("Table %s need discovery", file_name_str));
|
||||||
if (ndb_create_table_from_engine(thd, db, file_name) == 0)
|
if (ndb_create_table_from_engine(thd, db, file_name_str) == 0)
|
||||||
files->push_back(thd->strdup(file_name));
|
{
|
||||||
|
LEX_STRING *tmp_file_name= 0;
|
||||||
|
tmp_file_name= thd->make_lex_string(tmp_file_name, file_name_str,
|
||||||
|
strlen(file_name_str), TRUE);
|
||||||
|
files->push_back(tmp_file_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
@ -7083,8 +7090,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||||||
uint count = 0;
|
uint count = 0;
|
||||||
while (count++ < files->elements)
|
while (count++ < files->elements)
|
||||||
{
|
{
|
||||||
file_name = (char *)files->pop();
|
file_name = (LEX_STRING *)files->pop();
|
||||||
if (!strcmp(file_name, NDB_SCHEMA_TABLE))
|
if (!strcmp(file_name->str, NDB_SCHEMA_TABLE))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("skip %s.%s table, it should be hidden to user",
|
DBUG_PRINT("info", ("skip %s.%s table, it should be hidden to user",
|
||||||
NDB_REP_DB, NDB_SCHEMA_TABLE));
|
NDB_REP_DB, NDB_SCHEMA_TABLE));
|
||||||
|
@ -563,7 +563,7 @@ extern SHOW_VAR ndb_status_variables[];
|
|||||||
int ndbcluster_discover(THD* thd, const char* dbname, const char* name,
|
int ndbcluster_discover(THD* thd, const char* dbname, const char* name,
|
||||||
const void** frmblob, uint* frmlen);
|
const void** frmblob, uint* frmlen);
|
||||||
int ndbcluster_find_files(THD *thd,const char *db,const char *path,
|
int ndbcluster_find_files(THD *thd,const char *db,const char *path,
|
||||||
const char *wild, bool dir, List<char> *files);
|
const char *wild, bool dir, List<LEX_STRING> *files);
|
||||||
int ndbcluster_table_exists_in_engine(THD* thd,
|
int ndbcluster_table_exists_in_engine(THD* thd,
|
||||||
const char *db, const char *name);
|
const char *db, const char *name);
|
||||||
void ndbcluster_print_error(int error, const NdbOperation *error_op);
|
void ndbcluster_print_error(int error, const NdbOperation *error_op);
|
||||||
|
@ -2480,8 +2480,8 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("ndbcluster_check_if_local_tables_in_db");
|
DBUG_ENTER("ndbcluster_check_if_local_tables_in_db");
|
||||||
DBUG_PRINT("info", ("Looking for files in directory %s", dbname));
|
DBUG_PRINT("info", ("Looking for files in directory %s", dbname));
|
||||||
char *tabname;
|
LEX_STRING *tabname;
|
||||||
List<char> files;
|
List<LEX_STRING> files;
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
|
|
||||||
build_table_filename(path, sizeof(path), dbname, "", "", 0);
|
build_table_filename(path, sizeof(path), dbname, "", "", 0);
|
||||||
@ -2493,8 +2493,8 @@ ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname)
|
|||||||
DBUG_PRINT("info",("found: %d files", files.elements));
|
DBUG_PRINT("info",("found: %d files", files.elements));
|
||||||
while ((tabname= files.pop()))
|
while ((tabname= files.pop()))
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Found table %s", tabname));
|
DBUG_PRINT("info", ("Found table %s", tabname->str));
|
||||||
if (ndbcluster_check_if_local_table(dbname, tabname))
|
if (ndbcluster_check_if_local_table(dbname, tabname->str))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2834,7 +2834,7 @@ struct st_find_files_args
|
|||||||
const char *path;
|
const char *path;
|
||||||
const char *wild;
|
const char *wild;
|
||||||
bool dir;
|
bool dir;
|
||||||
List<char> *files;
|
List<LEX_STRING> *files;
|
||||||
};
|
};
|
||||||
|
|
||||||
static my_bool find_files_handlerton(THD *thd, plugin_ref plugin,
|
static my_bool find_files_handlerton(THD *thd, plugin_ref plugin,
|
||||||
@ -2854,7 +2854,7 @@ static my_bool find_files_handlerton(THD *thd, plugin_ref plugin,
|
|||||||
|
|
||||||
int
|
int
|
||||||
ha_find_files(THD *thd,const char *db,const char *path,
|
ha_find_files(THD *thd,const char *db,const char *path,
|
||||||
const char *wild, bool dir, List<char> *files)
|
const char *wild, bool dir, List<LEX_STRING> *files)
|
||||||
{
|
{
|
||||||
int error= 0;
|
int error= 0;
|
||||||
DBUG_ENTER("ha_find_files");
|
DBUG_ENTER("ha_find_files");
|
||||||
|
@ -700,7 +700,7 @@ struct handlerton
|
|||||||
int (*find_files)(handlerton *hton, THD *thd,
|
int (*find_files)(handlerton *hton, THD *thd,
|
||||||
const char *db,
|
const char *db,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *wild, bool dir, List<char> *files);
|
const char *wild, bool dir, List<LEX_STRING> *files);
|
||||||
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
|
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
|
||||||
const char *name);
|
const char *name);
|
||||||
uint32 license; /* Flag for Engine License */
|
uint32 license; /* Flag for Engine License */
|
||||||
@ -1860,7 +1860,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
|
|||||||
int ha_discover(THD* thd, const char* dbname, const char* name,
|
int ha_discover(THD* thd, const char* dbname, const char* name,
|
||||||
uchar** frmblob, size_t* frmlen);
|
uchar** frmblob, size_t* frmlen);
|
||||||
int ha_find_files(THD *thd,const char *db,const char *path,
|
int ha_find_files(THD *thd,const char *db,const char *path,
|
||||||
const char *wild, bool dir,List<char>* files);
|
const char *wild, bool dir, List<LEX_STRING>* files);
|
||||||
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
|
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
|
||||||
|
|
||||||
/* key cache */
|
/* key cache */
|
||||||
|
@ -2759,11 +2759,10 @@ bool reopen_table(TABLE *table)
|
|||||||
sql_print_error("Table %s had a open data handler in reopen_table",
|
sql_print_error("Table %s had a open data handler in reopen_table",
|
||||||
table->alias);
|
table->alias);
|
||||||
#endif
|
#endif
|
||||||
|
bzero((char*) &table_list, sizeof(TABLE_LIST));
|
||||||
table_list.db= table->s->db.str;
|
table_list.db= table->s->db.str;
|
||||||
table_list.table_name= table->s->table_name.str;
|
table_list.table_name= table->s->table_name.str;
|
||||||
table_list.table= table;
|
table_list.table= table;
|
||||||
table_list.belong_to_view= 0;
|
|
||||||
table_list.next_local= 0;
|
|
||||||
|
|
||||||
if (wait_for_locked_table_names(thd, &table_list))
|
if (wait_for_locked_table_names(thd, &table_list))
|
||||||
DBUG_RETURN(1); // Thread was killed
|
DBUG_RETURN(1); // Thread was killed
|
||||||
@ -3295,15 +3294,19 @@ static int open_unireg_entry(THD *thd, TABLE *entry, TABLE_LIST *table_list,
|
|||||||
DBUG_ENTER("open_unireg_entry");
|
DBUG_ENTER("open_unireg_entry");
|
||||||
|
|
||||||
safe_mutex_assert_owner(&LOCK_open);
|
safe_mutex_assert_owner(&LOCK_open);
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
|
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
|
||||||
cache_key_length,
|
cache_key_length,
|
||||||
OPEN_VIEW, &error)))
|
OPEN_VIEW |
|
||||||
|
table_list->i_s_requested_object,
|
||||||
|
&error)))
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
if (share->is_view)
|
if (share->is_view)
|
||||||
{
|
{
|
||||||
|
if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
|
||||||
|
goto err;
|
||||||
|
|
||||||
/* Open view */
|
/* Open view */
|
||||||
error= (int) open_new_frm(thd, share, alias,
|
error= (int) open_new_frm(thd, share, alias,
|
||||||
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
|
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
|
||||||
@ -3319,6 +3322,9 @@ retry:
|
|||||||
DBUG_RETURN((flags & OPEN_VIEW_NO_PARSE)? -1 : 0);
|
DBUG_RETURN((flags & OPEN_VIEW_NO_PARSE)? -1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (table_list->i_s_requested_object & OPEN_VIEW_ONLY)
|
||||||
|
goto err;
|
||||||
|
|
||||||
while ((error= open_table_from_share(thd, share, alias,
|
while ((error= open_table_from_share(thd, share, alias,
|
||||||
(uint) (HA_OPEN_KEYFILE |
|
(uint) (HA_OPEN_KEYFILE |
|
||||||
HA_OPEN_RNDFILE |
|
HA_OPEN_RNDFILE |
|
||||||
|
@ -1625,6 +1625,10 @@ JOIN::exec()
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((this->select_lex->options & OPTION_SCHEMA_TABLE) &&
|
||||||
|
get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC))
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
|
||||||
if (select_options & SELECT_DESCRIBE)
|
if (select_options & SELECT_DESCRIBE)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1670,13 +1674,6 @@ JOIN::exec()
|
|||||||
*/
|
*/
|
||||||
curr_join->examined_rows= 0;
|
curr_join->examined_rows= 0;
|
||||||
|
|
||||||
if ((curr_join->select_lex->options & OPTION_SCHEMA_TABLE) &&
|
|
||||||
!thd->lex->describe &&
|
|
||||||
get_schema_tables_result(curr_join, PROCESSED_BY_JOIN_EXEC))
|
|
||||||
{
|
|
||||||
DBUG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a tmp table if distinct or if the sort is too complicated */
|
/* Create a tmp table if distinct or if the sort is too complicated */
|
||||||
if (need_tmp)
|
if (need_tmp)
|
||||||
{
|
{
|
||||||
@ -12929,7 +12926,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
|
|||||||
|
|
||||||
/* Fill schema tables with data before filesort if it's necessary */
|
/* Fill schema tables with data before filesort if it's necessary */
|
||||||
if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
|
if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
|
||||||
!thd->lex->describe &&
|
|
||||||
get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
|
get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@ -15382,6 +15378,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
{
|
{
|
||||||
JOIN_TAB *tab=join->join_tab+i;
|
JOIN_TAB *tab=join->join_tab+i;
|
||||||
TABLE *table=tab->table;
|
TABLE *table=tab->table;
|
||||||
|
TABLE_LIST *table_list= tab->table->pos_in_table_list;
|
||||||
char buff[512];
|
char buff[512];
|
||||||
char buff1[512], buff2[512], buff3[512];
|
char buff1[512], buff2[512], buff3[512];
|
||||||
char keylen_str_buf[64];
|
char keylen_str_buf[64];
|
||||||
@ -15517,37 +15514,68 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item_list.push_back(item_null);
|
if (table_list->schema_table &&
|
||||||
|
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
|
||||||
|
{
|
||||||
|
const char *tmp_buff;
|
||||||
|
int f_idx;
|
||||||
|
if (table_list->has_db_lookup_value)
|
||||||
|
{
|
||||||
|
f_idx= table_list->schema_table->idx_field1;
|
||||||
|
tmp_buff= table_list->schema_table->fields_info[f_idx].field_name;
|
||||||
|
tmp2.append(tmp_buff, strlen(tmp_buff), cs);
|
||||||
|
}
|
||||||
|
if (table_list->has_table_lookup_value)
|
||||||
|
{
|
||||||
|
if (table_list->has_db_lookup_value)
|
||||||
|
tmp2.append(',');
|
||||||
|
f_idx= table_list->schema_table->idx_field2;
|
||||||
|
tmp_buff= table_list->schema_table->fields_info[f_idx].field_name;
|
||||||
|
tmp2.append(tmp_buff, strlen(tmp_buff), cs);
|
||||||
|
}
|
||||||
|
if (tmp2.length())
|
||||||
|
item_list.push_back(new Item_string(tmp2.ptr(),tmp2.length(),cs));
|
||||||
|
else
|
||||||
|
item_list.push_back(item_null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
item_list.push_back(item_null);
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
item_list.push_back(item_null);
|
item_list.push_back(item_null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add "rows" field to item_list. */
|
/* Add "rows" field to item_list. */
|
||||||
ha_rows examined_rows;
|
if (table_list->schema_table)
|
||||||
if (tab->select && tab->select->quick)
|
|
||||||
examined_rows= tab->select->quick->records;
|
|
||||||
else if (tab->type == JT_NEXT || tab->type == JT_ALL)
|
|
||||||
examined_rows= tab->table->file->records();
|
|
||||||
else
|
|
||||||
examined_rows=(ha_rows)join->best_positions[i].records_read;
|
|
||||||
|
|
||||||
item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows,
|
|
||||||
MY_INT64_NUM_DECIMAL_DIGITS));
|
|
||||||
|
|
||||||
/* Add "filtered" field to item_list. */
|
|
||||||
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
|
|
||||||
{
|
{
|
||||||
Item_float *filtered;
|
item_list.push_back(item_null);
|
||||||
float f;
|
|
||||||
if (examined_rows)
|
|
||||||
f= (float) (100.0 * join->best_positions[i].records_read /
|
|
||||||
examined_rows);
|
|
||||||
else
|
|
||||||
f= 0.0;
|
|
||||||
item_list.push_back((filtered= new Item_float(f)));
|
|
||||||
filtered->decimals= 2;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ha_rows examined_rows;
|
||||||
|
if (tab->select && tab->select->quick)
|
||||||
|
examined_rows= tab->select->quick->records;
|
||||||
|
else if (tab->type == JT_NEXT || tab->type == JT_ALL)
|
||||||
|
examined_rows= tab->table->file->records();
|
||||||
|
else
|
||||||
|
examined_rows=(ha_rows)join->best_positions[i].records_read;
|
||||||
|
|
||||||
|
item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows,
|
||||||
|
MY_INT64_NUM_DECIMAL_DIGITS));
|
||||||
|
|
||||||
|
/* Add "filtered" field to item_list. */
|
||||||
|
if (join->thd->lex->describe & DESCRIBE_EXTENDED)
|
||||||
|
{
|
||||||
|
Item_float *filtered;
|
||||||
|
float f;
|
||||||
|
if (examined_rows)
|
||||||
|
f= (float) (100.0 * join->best_positions[i].records_read /
|
||||||
|
examined_rows);
|
||||||
|
else
|
||||||
|
f= 0.0;
|
||||||
|
item_list.push_back((filtered= new Item_float(f)));
|
||||||
|
filtered->decimals= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Build "Extra" field and add it to item_list. */
|
/* Build "Extra" field and add it to item_list. */
|
||||||
my_bool key_read=table->key_read;
|
my_bool key_read=table->key_read;
|
||||||
@ -15615,6 +15643,24 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||||||
extra.append(STRING_WITH_LEN("; Using where"));
|
extra.append(STRING_WITH_LEN("; Using where"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (table_list->schema_table &&
|
||||||
|
table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE)
|
||||||
|
{
|
||||||
|
if (!table_list->table_open_method)
|
||||||
|
extra.append(STRING_WITH_LEN("; Skip_open_table"));
|
||||||
|
else if (table_list->table_open_method == OPEN_FRM_ONLY)
|
||||||
|
extra.append(STRING_WITH_LEN("; Open_frm_only"));
|
||||||
|
else
|
||||||
|
extra.append(STRING_WITH_LEN("; Open_full_table"));
|
||||||
|
if (table_list->has_db_lookup_value &&
|
||||||
|
table_list->has_table_lookup_value)
|
||||||
|
extra.append(STRING_WITH_LEN("; Scanned 0 databases"));
|
||||||
|
else if (table_list->has_db_lookup_value ||
|
||||||
|
table_list->has_table_lookup_value)
|
||||||
|
extra.append(STRING_WITH_LEN("; Scanned 1 database"));
|
||||||
|
else
|
||||||
|
extra.append(STRING_WITH_LEN("; Scanned all databases"));
|
||||||
|
}
|
||||||
if (key_read)
|
if (key_read)
|
||||||
{
|
{
|
||||||
if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
|
if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)
|
||||||
|
2260
sql/sql_show.cc
2260
sql/sql_show.cc
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ enum find_files_result {
|
|||||||
FIND_FILES_DIR
|
FIND_FILES_DIR
|
||||||
};
|
};
|
||||||
|
|
||||||
find_files_result find_files(THD *thd, List<char> *files, const char *db,
|
find_files_result find_files(THD *thd, List<LEX_STRING> *files, const char *db,
|
||||||
const char *path, const char *wild, bool dir);
|
const char *path, const char *wild, bool dir);
|
||||||
|
|
||||||
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
|
||||||
|
22
sql/table.cc
22
sql/table.cc
@ -572,7 +572,15 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags)
|
|||||||
{
|
{
|
||||||
if (head[2] == FRM_VER || head[2] == FRM_VER+1 ||
|
if (head[2] == FRM_VER || head[2] == FRM_VER+1 ||
|
||||||
(head[2] >= FRM_VER+3 && head[2] <= FRM_VER+4))
|
(head[2] >= FRM_VER+3 && head[2] <= FRM_VER+4))
|
||||||
|
{
|
||||||
|
/* Open view only */
|
||||||
|
if (db_flags & OPEN_VIEW_ONLY)
|
||||||
|
{
|
||||||
|
error_given= 1;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
table_type= 1;
|
table_type= 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error= 6; // Unkown .frm version
|
error= 6; // Unkown .frm version
|
||||||
@ -1612,9 +1620,17 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
|
|||||||
outparam->keys_in_use_for_query.init();
|
outparam->keys_in_use_for_query.init();
|
||||||
|
|
||||||
/* Allocate handler */
|
/* Allocate handler */
|
||||||
if (!(outparam->file= get_new_handler(share, &outparam->mem_root,
|
outparam->file= 0;
|
||||||
share->db_type())))
|
if (!(prgflag & OPEN_FRM_FILE_ONLY))
|
||||||
goto err;
|
{
|
||||||
|
if (!(outparam->file= get_new_handler(share, &outparam->mem_root,
|
||||||
|
share->db_type())))
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(!db_stat);
|
||||||
|
}
|
||||||
|
|
||||||
error= 4;
|
error= 4;
|
||||||
outparam->reginfo.lock_type= TL_UNLOCK;
|
outparam->reginfo.lock_type= TL_UNLOCK;
|
||||||
|
15
sql/table.h
15
sql/table.h
@ -719,6 +719,10 @@ enum enum_schema_tables
|
|||||||
#define MY_I_S_UNSIGNED 2
|
#define MY_I_S_UNSIGNED 2
|
||||||
|
|
||||||
|
|
||||||
|
#define SKIP_OPEN_TABLE 0 // do not open table
|
||||||
|
#define OPEN_FRM_ONLY 1 // open FRM file only
|
||||||
|
#define OPEN_FULL_TABLE 2 // open FRM,MYD, MYI files
|
||||||
|
|
||||||
typedef struct st_field_info
|
typedef struct st_field_info
|
||||||
{
|
{
|
||||||
const char* field_name;
|
const char* field_name;
|
||||||
@ -727,6 +731,7 @@ typedef struct st_field_info
|
|||||||
int value;
|
int value;
|
||||||
uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.)
|
uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.)
|
||||||
const char* old_name;
|
const char* old_name;
|
||||||
|
uint open_method;
|
||||||
} ST_FIELD_INFO;
|
} ST_FIELD_INFO;
|
||||||
|
|
||||||
|
|
||||||
@ -743,11 +748,11 @@ typedef struct st_schema_table
|
|||||||
int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
|
int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
|
||||||
/* Handle fileds for old SHOW */
|
/* Handle fileds for old SHOW */
|
||||||
int (*old_format) (THD *thd, struct st_schema_table *schema_table);
|
int (*old_format) (THD *thd, struct st_schema_table *schema_table);
|
||||||
int (*process_table) (THD *thd, TABLE_LIST *tables,
|
int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
|
||||||
TABLE *table, bool res, const char *base_name,
|
bool res, LEX_STRING *db_name, LEX_STRING *table_name);
|
||||||
const char *file_name);
|
|
||||||
int idx_field1, idx_field2;
|
int idx_field1, idx_field2;
|
||||||
bool hidden;
|
bool hidden;
|
||||||
|
uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */
|
||||||
} ST_SCHEMA_TABLE;
|
} ST_SCHEMA_TABLE;
|
||||||
|
|
||||||
|
|
||||||
@ -1091,6 +1096,10 @@ struct TABLE_LIST
|
|||||||
*/
|
*/
|
||||||
uint8 trg_event_map;
|
uint8 trg_event_map;
|
||||||
|
|
||||||
|
uint i_s_requested_object;
|
||||||
|
bool has_db_lookup_value;
|
||||||
|
bool has_table_lookup_value;
|
||||||
|
uint table_open_method;
|
||||||
enum enum_schema_table_state schema_table_state;
|
enum enum_schema_table_state schema_table_state;
|
||||||
void calc_md5(char *buffer);
|
void calc_md5(char *buffer);
|
||||||
void set_underlying_merge();
|
void set_underlying_merge();
|
||||||
|
@ -153,6 +153,11 @@
|
|||||||
#define OPEN_VIEW 8192 /* Allow open on view */
|
#define OPEN_VIEW 8192 /* Allow open on view */
|
||||||
#define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view,
|
#define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view,
|
||||||
but do not parse view itself */
|
but do not parse view itself */
|
||||||
|
#define OPEN_FRM_FILE_ONLY 32768 /* Open frm file only */
|
||||||
|
#define OPEN_TABLE_ONLY OPEN_FRM_FILE_ONLY*2 /* Open view only */
|
||||||
|
#define OPEN_VIEW_ONLY OPEN_TABLE_ONLY*2 /* Open table only */
|
||||||
|
#define OPEN_TABLE_FROM_SHARE OPEN_VIEW_ONLY*2 /* For I_S tables*/
|
||||||
|
#define OPTIMIZE_I_S_TABLE OPEN_TABLE_FROM_SHARE*2 /* For I_S tables*/
|
||||||
#define SC_INFO_LENGTH 4 /* Form format constant */
|
#define SC_INFO_LENGTH 4 /* Form format constant */
|
||||||
#define TE_INFO_LENGTH 3
|
#define TE_INFO_LENGTH 3
|
||||||
#define MTYP_NOEMPTY_BIT 128
|
#define MTYP_NOEMPTY_BIT 128
|
||||||
|
Loading…
x
Reference in New Issue
Block a user