mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Merge jbruehe@bk-internal.mysql.com:/home/bk/mysql-5.1-build
into trift2.:/MySQL/M51/push-5.1
This commit is contained in:
commit
126a403278
18 changed files with 1650 additions and 942 deletions
|
@ -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 (!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;
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
|
|
@ -289,8 +289,8 @@ explain select a.ROUTINE_NAME from information_schema.ROUTINES a,
|
|||
information_schema.SCHEMATA b where
|
||||
a.ROUTINE_SCHEMA = b.SCHEMA_NAME;
|
||||
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 2 Using where; Using join buffer
|
||||
1 SIMPLE # ALL NULL NULL NULL NULL NULL
|
||||
1 SIMPLE # ALL NULL NULL NULL NULL NULL Using where; Using join buffer
|
||||
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;
|
||||
ROUTINE_NAME name
|
||||
|
@ -355,7 +355,7 @@ mysql
|
|||
test
|
||||
explain select * from v0;
|
||||
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
|
||||
where table_name="v1";
|
||||
select * from v1;
|
||||
|
@ -679,17 +679,11 @@ where table_schema='test';
|
|||
table_name
|
||||
v2
|
||||
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
|
||||
where table_schema='test';
|
||||
table_name
|
||||
v2
|
||||
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
|
||||
where table_schema='test';
|
||||
column_name
|
||||
|
@ -1337,11 +1331,11 @@ from information_schema.tables
|
|||
order by object_schema;
|
||||
explain select * from v1;
|
||||
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;
|
||||
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
|
||||
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;
|
||||
create table t1 (f1 int(11));
|
||||
create table t2 (f1 int(11), f2 int(11));
|
||||
|
@ -1445,4 +1439,28 @@ ABORTED_CONNECTS
|
|||
BINLOG_CACHE_DISK_USE
|
||||
DROP TABLE server_status;
|
||||
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.
|
||||
|
|
|
@ -74,11 +74,11 @@ drop table t1;
|
|||
select table_name, table_type, table_comment from information_schema.tables
|
||||
where table_schema='inf%' and func2();
|
||||
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
|
||||
where table_schema='inf%' and func2();
|
||||
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 function func1;
|
||||
drop function func2;
|
||||
|
|
|
@ -34,13 +34,13 @@ col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
|
|||
col6 int not null, to_be_deleted int) ENGINE=ndbcluster;
|
||||
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
|
||||
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;
|
||||
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);
|
||||
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
|
||||
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;
|
||||
col1 col2 col3 col4 col5 col6 to_be_deleted
|
||||
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;
|
||||
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
|
||||
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;
|
||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||
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');
|
||||
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
|
||||
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;
|
||||
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
|
||||
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);
|
||||
select engine from information_schema.tables where table_name = 't1';
|
||||
engine
|
||||
NDBCLUSTER
|
||||
ndbcluster
|
||||
drop table t1;
|
||||
create temporary table t1 (a int key);
|
||||
show create table t1;
|
||||
|
|
|
@ -1100,4 +1100,24 @@ SELECT variable_name FROM server_status;
|
|||
DROP TABLE server_status;
|
||||
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.
|
||||
|
|
|
@ -6883,7 +6883,7 @@ int ndbcluster_find_all_files(THD *thd)
|
|||
int ndbcluster_find_files(handlerton *hton, 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)
|
||||
{
|
||||
DBUG_ENTER("ndbcluster_find_files");
|
||||
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));
|
||||
}
|
||||
|
||||
char *file_name;
|
||||
List_iterator<char> it(*files);
|
||||
LEX_STRING *file_name;
|
||||
List_iterator<LEX_STRING> it(*files);
|
||||
List<char> delete_list;
|
||||
char *file_name_str;
|
||||
while ((file_name=it++))
|
||||
{
|
||||
bool file_on_disk= FALSE;
|
||||
DBUG_PRINT("info", ("%s", file_name));
|
||||
if (hash_search(&ndb_tables, (uchar*) file_name, strlen(file_name)))
|
||||
DBUG_PRINT("info", ("%s", file_name->str));
|
||||
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;
|
||||
}
|
||||
|
||||
// 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));
|
||||
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
|
||||
if (file_on_disk)
|
||||
{
|
||||
// Ignore this ndb table
|
||||
uchar *record= hash_search(&ndb_tables, (uchar*) file_name,
|
||||
strlen(file_name));
|
||||
// Ignore this ndb table
|
||||
uchar *record= hash_search(&ndb_tables, (uchar*) file_name->str,
|
||||
file_name->length);
|
||||
DBUG_ASSERT(record);
|
||||
hash_delete(&ndb_tables, record);
|
||||
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_TABLE_EXISTS_ERROR,
|
||||
"Local table %s.%s shadows ndb table",
|
||||
db, file_name);
|
||||
db, file_name->str);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (file_on_disk)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
DBUG_PRINT("info", ("%s existed on disk", name));
|
||||
// The .ndb file exists on disk, but it's not in list of tables in ndb
|
||||
// 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();
|
||||
// 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);
|
||||
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 +
|
||||
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);
|
||||
ndbcluster_create_binlog_setup(ndb, name, end-name,
|
||||
db, file_name, TRUE);
|
||||
db, file_name_str, TRUE);
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
}
|
||||
}
|
||||
|
@ -7025,16 +7027,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||
List<char> create_list;
|
||||
for (i= 0 ; i < ndb_tables.records ; i++)
|
||||
{
|
||||
file_name= (char*) hash_element(&ndb_tables, i);
|
||||
if (!hash_search(&ok_tables, (uchar*) file_name, strlen(file_name)))
|
||||
file_name_str= (char*) hash_element(&ndb_tables, i);
|
||||
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))
|
||||
{
|
||||
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
|
||||
// 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
|
||||
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
|
||||
TABLE_LIST table_list;
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
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,
|
||||
FALSE, /* if_exists */
|
||||
FALSE, /* drop_temporary */
|
||||
|
@ -7065,11 +7067,16 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||
pthread_mutex_lock(&LOCK_open);
|
||||
// Create new files
|
||||
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));
|
||||
if (ndb_create_table_from_engine(thd, db, file_name) == 0)
|
||||
files->push_back(thd->strdup(file_name));
|
||||
DBUG_PRINT("info", ("Table %s need discovery", file_name_str));
|
||||
if (ndb_create_table_from_engine(thd, db, file_name_str) == 0)
|
||||
{
|
||||
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);
|
||||
|
@ -7083,8 +7090,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
|
|||
uint count = 0;
|
||||
while (count++ < files->elements)
|
||||
{
|
||||
file_name = (char *)files->pop();
|
||||
if (!strcmp(file_name, NDB_SCHEMA_TABLE))
|
||||
file_name = (LEX_STRING *)files->pop();
|
||||
if (!strcmp(file_name->str, NDB_SCHEMA_TABLE))
|
||||
{
|
||||
DBUG_PRINT("info", ("skip %s.%s table, it should be hidden to user",
|
||||
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,
|
||||
const void** frmblob, uint* frmlen);
|
||||
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,
|
||||
const char *db, const char *name);
|
||||
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_PRINT("info", ("Looking for files in directory %s", dbname));
|
||||
char *tabname;
|
||||
List<char> files;
|
||||
LEX_STRING *tabname;
|
||||
List<LEX_STRING> files;
|
||||
char path[FN_REFLEN];
|
||||
|
||||
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));
|
||||
while ((tabname= files.pop()))
|
||||
{
|
||||
DBUG_PRINT("info", ("Found table %s", tabname));
|
||||
if (ndbcluster_check_if_local_table(dbname, tabname))
|
||||
DBUG_PRINT("info", ("Found table %s", tabname->str));
|
||||
if (ndbcluster_check_if_local_table(dbname, tabname->str))
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -2834,7 +2834,7 @@ struct st_find_files_args
|
|||
const char *path;
|
||||
const char *wild;
|
||||
bool dir;
|
||||
List<char> *files;
|
||||
List<LEX_STRING> *files;
|
||||
};
|
||||
|
||||
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
|
||||
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;
|
||||
DBUG_ENTER("ha_find_files");
|
||||
|
|
|
@ -700,7 +700,7 @@ struct handlerton
|
|||
int (*find_files)(handlerton *hton, 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 (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
|
||||
const char *name);
|
||||
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,
|
||||
uchar** frmblob, size_t* frmlen);
|
||||
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);
|
||||
|
||||
/* key cache */
|
||||
|
|
|
@ -2759,11 +2759,10 @@ bool reopen_table(TABLE *table)
|
|||
sql_print_error("Table %s had a open data handler in reopen_table",
|
||||
table->alias);
|
||||
#endif
|
||||
bzero((char*) &table_list, sizeof(TABLE_LIST));
|
||||
table_list.db= table->s->db.str;
|
||||
table_list.table_name= table->s->table_name.str;
|
||||
table_list.table= table;
|
||||
table_list.belong_to_view= 0;
|
||||
table_list.next_local= 0;
|
||||
|
||||
if (wait_for_locked_table_names(thd, &table_list))
|
||||
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");
|
||||
|
||||
safe_mutex_assert_owner(&LOCK_open);
|
||||
|
||||
retry:
|
||||
if (!(share= get_table_share_with_create(thd, table_list, cache_key,
|
||||
cache_key_length,
|
||||
OPEN_VIEW, &error)))
|
||||
OPEN_VIEW |
|
||||
table_list->i_s_requested_object,
|
||||
&error)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (share->is_view)
|
||||
{
|
||||
if (table_list->i_s_requested_object & OPEN_TABLE_ONLY)
|
||||
goto err;
|
||||
|
||||
/* Open view */
|
||||
error= (int) open_new_frm(thd, share, alias,
|
||||
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
|
||||
|
@ -3319,6 +3322,9 @@ retry:
|
|||
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,
|
||||
(uint) (HA_OPEN_KEYFILE |
|
||||
HA_OPEN_RNDFILE |
|
||||
|
|
|
@ -1625,6 +1625,10 @@ JOIN::exec()
|
|||
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)
|
||||
{
|
||||
/*
|
||||
|
@ -1670,13 +1674,6 @@ JOIN::exec()
|
|||
*/
|
||||
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 */
|
||||
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 */
|
||||
if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
|
||||
!thd->lex->describe &&
|
||||
get_schema_tables_result(join, PROCESSED_BY_CREATE_SORT_INDEX))
|
||||
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;
|
||||
TABLE *table=tab->table;
|
||||
TABLE_LIST *table_list= tab->table->pos_in_table_list;
|
||||
char buff[512];
|
||||
char buff1[512], buff2[512], buff3[512];
|
||||
char keylen_str_buf[64];
|
||||
|
@ -15517,37 +15514,68 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/* Add "rows" field to item_list. */
|
||||
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)
|
||||
if (table_list->schema_table)
|
||||
{
|
||||
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;
|
||||
item_list.push_back(item_null);
|
||||
}
|
||||
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. */
|
||||
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"));
|
||||
}
|
||||
}
|
||||
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 (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_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);
|
||||
|
||||
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 ||
|
||||
(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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
|
||||
/* Allocate handler */
|
||||
if (!(outparam->file= get_new_handler(share, &outparam->mem_root,
|
||||
share->db_type())))
|
||||
goto err;
|
||||
outparam->file= 0;
|
||||
if (!(prgflag & OPEN_FRM_FILE_ONLY))
|
||||
{
|
||||
if (!(outparam->file= get_new_handler(share, &outparam->mem_root,
|
||||
share->db_type())))
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(!db_stat);
|
||||
}
|
||||
|
||||
error= 4;
|
||||
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 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
|
||||
{
|
||||
const char* field_name;
|
||||
|
@ -727,6 +731,7 @@ typedef struct st_field_info
|
|||
int value;
|
||||
uint field_flags; // Field atributes(maybe_null, signed, unsigned etc.)
|
||||
const char* old_name;
|
||||
uint open_method;
|
||||
} ST_FIELD_INFO;
|
||||
|
||||
|
||||
|
@ -743,11 +748,11 @@ typedef struct st_schema_table
|
|||
int (*fill_table) (THD *thd, TABLE_LIST *tables, COND *cond);
|
||||
/* Handle fileds for old SHOW */
|
||||
int (*old_format) (THD *thd, struct st_schema_table *schema_table);
|
||||
int (*process_table) (THD *thd, TABLE_LIST *tables,
|
||||
TABLE *table, bool res, const char *base_name,
|
||||
const char *file_name);
|
||||
int (*process_table) (THD *thd, TABLE_LIST *tables, TABLE *table,
|
||||
bool res, LEX_STRING *db_name, LEX_STRING *table_name);
|
||||
int idx_field1, idx_field2;
|
||||
bool hidden;
|
||||
uint i_s_requested_object; /* the object we need to open(TABLE | VIEW) */
|
||||
} ST_SCHEMA_TABLE;
|
||||
|
||||
|
||||
|
@ -1091,6 +1096,10 @@ struct TABLE_LIST
|
|||
*/
|
||||
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;
|
||||
void calc_md5(char *buffer);
|
||||
void set_underlying_merge();
|
||||
|
|
|
@ -153,6 +153,11 @@
|
|||
#define OPEN_VIEW 8192 /* Allow open on view */
|
||||
#define OPEN_VIEW_NO_PARSE 16384 /* Open frm only if it's a view,
|
||||
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 TE_INFO_LENGTH 3
|
||||
#define MTYP_NOEMPTY_BIT 128
|
||||
|
|
Loading…
Reference in a new issue