Skip to content

Commit 0a10fc8

Browse files
gopshankphulakun
authored andcommitted
WL#6599 - New Data Dictionary and I_S integration.
This WL defines INFORMATION_SCHEMA (I_S) system view over DD tables, representing a I_S table. This will eliminate the need of preparing a temporary table for each I_S table during execution and enable faster execution of I_S queries. A. Functional changes introduced: --------------------------------- A.1) Implements following I_S tables as a system view. CHARACTER_SETS COLLATIONS COLLATION_CHARACTER_SET_APPLICABILITY SCHEMATA TABLE_NAMES TABLES VIEWS COLUMNS STATISTICS KEY_COLUMN_USAGE TABLE_CONSTRAINTS A.2) Implements following SHOW commands to use A.1). SHOW CHARSET SHOW COLLATION SHOW DATABASES SHOW TABLES SHOW TABLE STATUS SHOW COLUMNS SHOW KEYS/INDEXES SHOW STATISTICS DESCRIBE A.3) Introduces a session variable 'information_schema_stats' that enables use to decide how to get the table/index dynamic statistics. Setting it to 'latest' would get latest statistics from storage engine. And setting it to 'cached' would get statistics stored in mysql.table_stats/index_stats. These are two new DD tables introduced by this WL. These tables are updated when user runs ANALYZE TABLE on a table. For more details see HLS 2.1.4) and 2.1.12). A.4) Introduced following new DD columns, see HLS 2.1.8) for more details. COLUMNS.COLUMN_KEY COLUMNS.COLUMN_TYPE COLUMNS.DEFAULT_VALUE_UTF8 TABLES.ROW_FORMAT A.5) Implements special handling for SHOW COLUMNS/KEYS for temporary tables as the meta data of temporary tables are not stored in DD. A.6) I_S tables are temporary tables on 5.7. This make them possible to access under LOCK TABLE mode with explicitly locking I_S tables. Now with this WL, the query execution procedure fails to process I_S system view as the under laying DD table are not locked. So, this WL makes the SQL server to open the DD tables used by a I_S system view without requiring them to be locked explicitly. B. Performance improvements: ---------------------------- See mysql wiki page WL6599_I_S_performance_with_data_dictionary for more details. (HLS section 5) C. Compatibility issues: ------------------------ There are few differences in the way mysql server would behave after this WL. The detailed list of these change in behavior is listed under HLS section 6). D. Source files: ---------------- Most of code changes are placed in sql/dd/info_schema folder. * Refer code in sql/dd/info_schema/show.* to know how SHOW commands are implemented. * Refer code in sql/dd/info_schema/stats.* to know how the retrieval of dynamic statistics are implemented. E. Related WL's and Bugs: ------------------------- * WL#7167 Change DDL to update rows for view columns in DD.COLUMNS and other dependent values. I_S.COLUMNS will get column meta data for views from mysql.columns. The view's column meta data are stored in mysql.columns by this WL. The WL takes care of enabling several test cases that is disabled by this WL#6599. So WL#6599 and WL#7167 would be pushed together. They are QA'ed together. * WL#7464 - InnoDB: provide a way to do non-locking reads. This WL enables execution of I_S queries do to non-locking reads. * WL#8232 - New data-dictionary: change approach to table row_format and index algorithm validation/handling Upcoming WL: * WL#9494 Implement INFORMATION_SCHEMA system views for SP/TRIGGERS/EVENTS/REFERENTIAL_CONSTRAINTS * WL#9495 Update schema tables of dynamic plugins into data dictionary. The following bugs would be fixed by this WL: Bug#11748044 Bug#13878164 F. Disabled tests: ------------------ thread_pool.thread_pool_i_s : Would be fixed by WL#9495. i_innodb.innodb_bug14150372 : WL6599_INNODB_SPORADIC
1 parent e7879a8 commit 0a10fc8

File tree

541 files changed

+20644
-9939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

541 files changed

+20644
-9939
lines changed

client/dump/mysql_crawler.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ void Mysql_crawler::enumerate_database_objects(const Database& db)
122122
void Mysql_crawler::enumerate_tables(const Database& db)
123123
{
124124
Mysql::Tools::Base::Mysql_query_runner* runner= this->get_runner();
125+
126+
/*
127+
Get statistics from SE by setting information_schema_stats=LATEST
128+
for this session. This makes the queries IS queries retrieve latest
129+
statistics and avoids getting outdated statistics.
130+
*/
131+
std::vector<const Mysql::Tools::Base::Mysql_query_runner::Row*> t;
132+
runner->run_query_store("SET SESSION information_schema_stats=latest", &t);
133+
125134
std::vector<const Mysql::Tools::Base::Mysql_query_runner::Row*> tables;
126135

127136
runner->run_query_store("SHOW TABLE STATUS FROM "

client/dump/mysqldump_tool_chain_maker_options.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,28 @@ void Mysqldump_tool_chain_maker_options::process_positional_options(
137137
db_name, positional_options[i]));
138138
}
139139

140+
/*
141+
INFORMATION_SCHEMA DB content dump is only used to reload the data
142+
into another tables for analysis purpose. This feature is not the
143+
core responsibility of mysqlpump tool. INFORMATION_SCHEMA DB
144+
content can even be dumped using other methods like SELECT INTO
145+
OUTFILE... for such purpose.
146+
Hence reporting error if INFORMATION_SCHEMA DB is in databases list.
147+
*/
148+
for (auto database : m_object_filter.m_databases_included)
149+
{
150+
auto db_name= std::get<1>(database);
151+
152+
if (!my_strcasecmp(&my_charset_latin1, db_name.c_str(),
153+
INFORMATION_SCHEMA_DB_NAME))
154+
{
155+
m_mysql_chain_element_options->get_program()->error(
156+
Mysql::Tools::Base::Message_data(1, "Dumping "
157+
"\'INFORMATION_SCHEMA\' DB content is not supported.",
158+
Mysql::Tools::Base::Message_type_error));
159+
}
160+
}
161+
140162
/*
141163
We add standard exclusions only if objects are included by default, i.e.
142164
there are exclusions or there is no exclusions and inclusions.

client/mysqldump.cc

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ static int dump_databases(char **);
588588
static int dump_all_databases();
589589
static char *quote_name(const char *name, char *buff, my_bool force);
590590
char check_if_ignore_table(const char *table_name, char *table_type);
591+
bool is_infoschema_db(const char *db);
591592
static char *primary_key_fields(const char *table_name);
592593
static my_bool get_view_structure(char *table, char* db);
593594
static my_bool dump_all_views_in_db(char *database);
@@ -2872,9 +2873,12 @@ static uint get_table_structure(char *table, char *db, char *table_type,
28722873
*/
28732874
while ((row= mysql_fetch_row(result)))
28742875
{
2875-
complete_insert|=
2876-
strcmp(row[SHOW_EXTRA], "STORED GENERATED") == 0 ||
2877-
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") == 0;
2876+
if (row[SHOW_EXTRA])
2877+
{
2878+
complete_insert|=
2879+
strcmp(row[SHOW_EXTRA], "STORED GENERATED") == 0 ||
2880+
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") == 0;
2881+
}
28782882
}
28792883
mysql_free_result(result);
28802884

@@ -2915,9 +2919,14 @@ static uint get_table_structure(char *table, char *db, char *table_type,
29152919
colno= 0;
29162920
while ((row= mysql_fetch_row(result)))
29172921
{
2918-
real_columns[colno]=
2919-
strcmp(row[SHOW_EXTRA], "STORED GENERATED") != 0 &&
2920-
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") != 0;
2922+
if (row[SHOW_EXTRA])
2923+
{
2924+
real_columns[colno]=
2925+
strcmp(row[SHOW_EXTRA], "STORED GENERATED") != 0 &&
2926+
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") != 0;
2927+
}
2928+
else
2929+
real_columns[colno]= TRUE;
29212930

29222931
if (real_columns[colno++] && complete_insert)
29232932
{
@@ -2953,9 +2962,12 @@ static uint get_table_structure(char *table, char *db, char *table_type,
29532962
*/
29542963
while ((row= mysql_fetch_row(result)))
29552964
{
2956-
complete_insert|=
2957-
strcmp(row[SHOW_EXTRA], "STORED GENERATED") == 0 ||
2958-
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") == 0;
2965+
if (row[SHOW_EXTRA])
2966+
{
2967+
complete_insert|=
2968+
strcmp(row[SHOW_EXTRA], "STORED GENERATED") == 0 ||
2969+
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") == 0;
2970+
}
29592971
}
29602972
mysql_free_result(result);
29612973

@@ -3013,9 +3025,14 @@ static uint get_table_structure(char *table, char *db, char *table_type,
30133025
{
30143026
ulong *lengths= mysql_fetch_lengths(result);
30153027

3016-
real_columns[colno]=
3017-
strcmp(row[SHOW_EXTRA], "STORED GENERATED") != 0 &&
3018-
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") != 0;
3028+
if (row[SHOW_EXTRA])
3029+
{
3030+
real_columns[colno]=
3031+
strcmp(row[SHOW_EXTRA], "STORED GENERATED") != 0 &&
3032+
strcmp(row[SHOW_EXTRA], "VIRTUAL GENERATED") != 0;
3033+
}
3034+
else
3035+
real_columns[colno]= TRUE;
30193036

30203037
if (!real_columns[colno++])
30213038
continue;
@@ -3057,7 +3074,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
30573074
}
30583075
if (!row[SHOW_NULL][0])
30593076
fputs(" NOT NULL", sql_file);
3060-
if (row[SHOW_EXTRA][0])
3077+
if (row[SHOW_EXTRA] && row[SHOW_EXTRA][0])
30613078
fprintf(sql_file, " %s",row[SHOW_EXTRA]);
30623079
check_io(sql_file);
30633080
}
@@ -4435,6 +4452,9 @@ static int dump_databases(char **db_names)
44354452

44364453
for (db= db_names ; *db ; db++)
44374454
{
4455+
if (is_infoschema_db(*db))
4456+
die(EX_USAGE, "Dumping \'%s\' DB content is not supported", *db);
4457+
44384458
if (dump_all_tables_in_db(*db))
44394459
result=1;
44404460
}
@@ -4860,6 +4880,9 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
48604880
char **dump_tables, **pos, **end;
48614881
DBUG_ENTER("dump_selected_tables");
48624882

4883+
if (is_infoschema_db(db))
4884+
die(EX_USAGE, "Dumping \'%s\' DB content is not supported", db);
4885+
48634886
if (init_dumping(db, init_dumping_tables))
48644887
DBUG_RETURN(1);
48654888

@@ -5425,6 +5448,38 @@ char check_if_ignore_table(const char *table_name, char *table_type)
54255448
}
54265449

54275450

5451+
/**
5452+
Check if the database is 'information_schema' and write a verbose message
5453+
stating that dumping the database is not supported.
5454+
5455+
@param db Database Name.
5456+
5457+
@retval true If database should be ignored.
5458+
@retval false If database shouldn't be ignored.
5459+
*/
5460+
5461+
bool is_infoschema_db(const char *db)
5462+
{
5463+
DBUG_ENTER("is_infoschema_db");
5464+
5465+
/*
5466+
INFORMATION_SCHEMA DB content dump is only used to reload the data into
5467+
another tables for analysis purpose. This feature is not the core
5468+
responsibility of mysqldump tool. INFORMATION_SCHEMA DB content can even be
5469+
dumped using other methods like SELECT INTO OUTFILE... for such purpose.
5470+
Hence ignoring INFORMATION_SCHEMA DB here.
5471+
*/
5472+
if (mysql_get_server_version(mysql) >= FIRST_INFORMATION_SCHEMA_VERSION &&
5473+
!my_strcasecmp(&my_charset_latin1, db, INFORMATION_SCHEMA_DB_NAME))
5474+
{
5475+
verbose_msg("Dumping \'%s\' DB content is not supported", db);
5476+
DBUG_RETURN(true);
5477+
}
5478+
5479+
DBUG_RETURN(false);
5480+
}
5481+
5482+
54285483
/*
54295484
Get string of comma-separated primary key field names
54305485

mysql-test/extra/binlog_tests/blackhole.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
9494
('Only MyISAM tables','support collections'),
9595
('Function MATCH ... AGAINST()','is used to do a search'),
9696
('Full-text search in MySQL', 'implements vector space model');
97+
ANALYZE TABLE t1;
9798
SHOW INDEX FROM t1;
9899

99100
# nl search

mysql-test/include/commit.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ drop table t2;
653653
set sql_mode=no_engine_substitution;
654654
create temporary table t2 (a int);
655655
--disable_warnings
656-
call p_verify_status_increment(3, 0, 0, 0);
656+
call p_verify_status_increment(5, 0, 0, 0);
657657
--enable_warnings
658658
set sql_mode=default;
659659
--echo # 19. A function changes temp-trans-table.
@@ -878,7 +878,7 @@ call p_verify_status_increment(6, 0, 6, 0);
878878
commit;
879879
call p_verify_status_increment(0, 0, 0, 0);
880880
drop view v1;
881-
call p_verify_status_increment(3, 0, 3, 0);
881+
call p_verify_status_increment(5, 0, 3, 0);
882882
--enable_warnings
883883

884884
--echo #

mysql-test/include/common-tests.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@ show full columns from t2;
18041804
show full columns from t2 from test like 'f%';
18051805
--replace_column 8 #
18061806
show full columns from t2 from test like 's%';
1807+
analyze table t2;
18071808
--replace_column 7 #
18081809
show keys from t2;
18091810

mysql-test/include/handler.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ connection default;
786786
# Bug#44151 using handler commands on information_schema tables crashes server
787787
#
788788
USE information_schema;
789-
--error ER_WRONG_USAGE
789+
--replace_result columns COLUMNS
790+
--error ER_WRONG_OBJECT
790791
HANDLER COLUMNS OPEN;
791792
USE test;
792793

mysql-test/include/mtr_check.sql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
1+
-- Copyright (c) 2008, 2016 Oracle and/or its affiliates. All rights reserved.
22
--
33
-- This program is free software; you can redistribute it and/or modify
44
-- it under the terms of the GNU General Public License as published by
@@ -68,15 +68,16 @@ BEGIN
6868

6969
-- Dump all databases, there should be none
7070
-- except those that was created during bootstrap
71-
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA;
71+
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME;
7272

7373
-- Dump all tablespaces, there should be none
7474
SELECT * FROM INFORMATION_SCHEMA.FILES WHERE
7575
FILE_TYPE !='TEMPORARY' AND TABLE_SCHEMA='test' ORDER BY FILE_ID;
7676

7777
-- The test database should not contain any tables
7878
SELECT table_name AS tables_in_test FROM INFORMATION_SCHEMA.TABLES
79-
WHERE table_schema='test';
79+
WHERE table_schema='test'
80+
ORDER BY TABLE_NAME;
8081

8182
-- Show "mysql" database, tables and columns
8283
SELECT CONCAT(table_schema, '.', table_name) AS tables_in_mysql
@@ -90,7 +91,7 @@ BEGIN
9091
collation_name, column_type, column_key, extra, column_comment
9192
FROM INFORMATION_SCHEMA.COLUMNS
9293
WHERE table_schema='mysql' AND table_name != 'ndb_apply_status'
93-
ORDER BY columns_in_mysql;
94+
ORDER BY columns_in_mysql, column_name;
9495

9596
-- Dump all events, there should be none
9697
SELECT * FROM INFORMATION_SCHEMA.EVENTS;
@@ -112,7 +113,8 @@ BEGIN
112113
CHARACTER_SET_CLIENT,COLLATION_CONNECTION,DATABASE_COLLATION
113114
FROM INFORMATION_SCHEMA.ROUTINES;
114115
-- Dump all views, only those in the sys schema should exist
115-
SELECT * FROM INFORMATION_SCHEMA.VIEWS;
116+
SELECT * FROM INFORMATION_SCHEMA.VIEWS
117+
ORDER BY TABLE_SCHEMA, TABLE_NAME;
116118

117119
SHOW GLOBAL STATUS LIKE 'slave_open_temp_tables';
118120

File renamed without changes.

mysql-test/include/select.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,7 @@ show full columns from t2;
17821782
show full columns from t2 from test like 'f%';
17831783
--replace_column 8 #
17841784
show full columns from t2 from test like 's%';
1785+
analyze table t2;
17851786
show keys from t2;
17861787

17871788
drop table t4, t3, t2, t1;
@@ -2235,6 +2236,7 @@ drop table t1,t2;
22352236
create table t1 (f1 int not null auto_increment primary key, f2 varchar(10));
22362237
create table t11 like t1;
22372238
insert into t1 values(1,""),(2,"");
2239+
analyze table t1, t11;
22382240
--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X
22392241
show table status like 't1%';
22402242
select 123 as a from t1 where f1 is null;

mysql-test/r/1st.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
select schema_name from information_schema.schemata where schema_name not in ('sys', 'performance_schema');
2-
schema_name
3-
information_schema
4-
mtr
2+
SCHEMA_NAME
53
mysql
4+
information_schema
65
test
6+
mtr
77
show tables in mysql where Tables_in_mysql != 'ndb_binlog_index';
88
Tables_in_mysql
99
column_stats

0 commit comments

Comments
 (0)