Commit 0b66d3f7 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-11426 Remove InnoDB INFORMATION_SCHEMA.FILES implementation

MySQL 5.7 introduced WL#7943: InnoDB: Implement Information_Schema.Files
to provide a long-term alternative for accessing tablespace metadata.
The INFORMATION_SCHEMA.INNODB_* views are considered internal interfaces
that are subject to change or removal between releases. So, users should
refer to I_S.FILES instead of I_S.INNODB_SYS_TABLESPACES to fetch metadata
about CREATE TABLESPACE.

Because MariaDB 10.2 does not support CREATE TABLESPACE or
CREATE TABLE…TABLESPACE for InnoDB, it does not make sense to support
I_S.FILES either. So, let MariaDB 10.2 omit the code that was added in
MySQL 5.7. After this change, I_S.FILES will report the empty result,
unless some other storage engine in MariaDB 10.2 implements the interface.
(The I_S.FILES interface was originally created for the NDB Cluster.)
parent 943baa3b
--echo === information_schema.innodb_sys_tables and innodb_sys_tablespaces ===
--disable_query_log
--replace_result #P# #p# #SP# #sp#
--replace_regex /FTS_([0-9a-f_]+)([A-Z0-9_]+)/FTS_AUX_\2/
SELECT t.name 'Table Name',
s.name 'Tablespace',
t.flag 'Table Flags',
t.n_cols 'Columns',
t.row_format 'Row Format',
t.zip_page_size 'Zip Size',
t.space_type 'Space Type'
FROM information_schema.innodb_sys_tables t LEFT JOIN
information_schema.innodb_sys_tablespaces s
ON t.space = s.space
WHERE t.name not like 'SYS_%'
AND t.name NOT LIKE 'mysql/%'
AND t.name NOT LIKE 'sys/%'
ORDER BY t.name;
--enable_query_log
......@@ -17,22 +17,4 @@ SELECT s.name 'Space_Name',
AND s.name NOT LIKE 'mysql/%'
AND s.name NOT LIKE 'sys/%'
ORDER BY s.space;
# This SELECT will not show UNDO or TEMPORARY tablespaces since
# they are only in FILES, not SYS_TABLESPACES.
--echo === information_schema.files ===
--replace_regex /innodb_file_per_table.[0-9]+/innodb_file_per_table.##/ /#P#/#p#/ /#SP#/#sp#/
--replace_result ./ MYSQLD_DATADIR/ $MYSQLD_DATADIR/ MYSQLD_DATADIR/ $MYSQLD_DATADIR MYSQLD_DATADIR/ $MYSQL_TMP_DIR MYSQL_TMP_DIR $INNODB_PAGE_SIZE DEFAULT
SELECT s.name 'Space_Name',
f.file_type 'File_Type',
f.engine 'Engine',
f.status 'Status',
f.tablespace_name 'Tablespace_Name',
f.file_name 'Path'
FROM information_schema.files f,
information_schema.innodb_sys_tablespaces s
WHERE f.file_id = s.space
AND s.name NOT LIKE 'mysql/%'
AND s.name NOT LIKE 'sys/%'
ORDER BY f.file_id;
--enable_query_log
......@@ -41,12 +41,6 @@ test/t1 Single DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t1.ibd
test/t2 Single DEFAULT 0 Compact or Redundant MYSQLD_DATADIR/test/t2.ibd
test/t3 Single DEFAULT 8192 Compressed MYSQLD_DATADIR/test/t3.ibd
test/t4 Single DEFAULT 0 Dynamic MYSQLD_DATADIR/test/t4.ibd
=== information_schema.files ===
Space_Name File_Type Engine Status Tablespace_Name Path
test/t1 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t1.ibd
test/t2 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t2.ibd
test/t3 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t3.ibd
test/t4 TABLESPACE InnoDB NORMAL innodb_file_per_table.## MYSQLD_DATADIR/test/t4.ibd
DROP TABLE t1, t2, t3, t4;
# Test 4) The maximum row size is dependent upon the page size.
# Redundant: 8123, Compact: 8126.
......
This diff is collapsed.
This diff is collapsed.
--loose-innodb-sys-indexes
--loose-innodb-sys-tablespaces
--loose-innodb-sys-datafiles
......@@ -169,11 +169,11 @@ CREATE TABLE t1 (a varchar(64) character set utf8,
SET SESSION innodb_strict_mode = ON;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
......@@ -240,18 +240,18 @@ DROP TABLE t1;
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
SHOW VARIABLES LIKE 'innodb_file_per_table';
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_per_table = ON;
SET GLOBAL innodb_file_format = `Antelope`;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_format = `Barracuda`;
......
--loose-innodb-sys-indexes
--loose-innodb-sys-tablespaces
--loose-innodb-sys-datafiles
......@@ -185,7 +185,7 @@ CREATE TABLE t1 (a varchar(128) character set utf8,
SET SESSION innodb_strict_mode = ON;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
......@@ -257,18 +257,18 @@ DROP TABLE t1;
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
SHOW VARIABLES LIKE 'innodb_file_per_table';
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_per_table = ON;
SET GLOBAL innodb_file_format = `Antelope`;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
--error ER_CANT_CREATE_TABLE
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_format = `Barracuda`;
......
......@@ -10,7 +10,5 @@
#
##############################################################################
restart : Not supported by MariaDB 10.2 2/9/2016 jplindst
wl6650 : Not supported by MariaDB 10.2
wl6560 : Very long, timeout
--loose-innodb-sys-tables
--loose-innodb-sys-tablespaces
--loose-innodb-sys-datafiles
......@@ -152,29 +152,6 @@ INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart);
SHOW CREATE TABLE t7_restart;
SELECT count(*) FROM t7_restart;
--echo #
--echo # Create and insert records into a table that uses a general tablespace.
--echo #
CREATE TABLESPACE s1_restart ADD DATAFILE 's1_restart.ibd';
CREATE TABLE t8_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT)
ROW_FORMAT=COMPACT ENGINE=InnoDB TABLESPACE=s1_restart;
INSERT INTO t8_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot');
INSERT INTO t8_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t8_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t8_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t8_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
SHOW CREATE TABLE t8_restart;
SELECT count(*) FROM t8_restart;
CREATE TABLE t9_restart(c1 DOUBLE AUTO_INCREMENT KEY, c2 CHAR(10), c3 VARCHAR(100), c4 DATE, c5 TEXT)
ROW_FORMAT=DYNAMIC ENGINE=InnoDB TABLESPACE=s1_restart;
INSERT INTO t9_restart VALUES (1000000000, 'MySQL', 'InnoDB', '2011-11-11', 'Read this after reboot');
INSERT INTO t9_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t9_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t9_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
INSERT INTO t9_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
SHOW CREATE TABLE t9_restart;
SELECT count(*) FROM t9_restart;
--echo #
--echo # Show these tables in information_schema.
--echo #
......@@ -211,8 +188,6 @@ SHOW CREATE TABLE t5_restart;
SHOW CREATE TABLE t6_restart;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SHOW CREATE TABLE t7_restart;
SHOW CREATE TABLE t8_restart;
SHOW CREATE TABLE t9_restart;
INSERT INTO t1_restart (SELECT 0, c2, c3, c4, c5 FROM t1_restart);
INSERT INTO t2_restart (SELECT 0, c2, c3, c4, c5 FROM t2_restart);
......@@ -221,8 +196,6 @@ INSERT INTO t4_restart (SELECT 0, c2, c3, c4, c5 FROM t4_restart);
INSERT INTO t5_restart (SELECT 0, c2, c3, c4, c5 FROM t5_restart);
INSERT INTO t6_restart (SELECT 0, c2, c3, c4, c5 FROM t6_restart);
INSERT INTO t7_restart (SELECT 0, c2, c3, c4, c5 FROM t7_restart);
INSERT INTO t8_restart (SELECT 0, c2, c3, c4, c5 FROM t8_restart);
INSERT INTO t9_restart (SELECT 0, c2, c3, c4, c5 FROM t9_restart);
SELECT count(*) FROM t1_restart;
SELECT count(*) FROM t2_restart;
......@@ -231,8 +204,6 @@ SELECT count(*) FROM t4_restart;
SELECT count(*) FROM t5_restart;
SELECT count(*) FROM t6_restart;
SELECT count(*) FROM t7_restart;
SELECT count(*) FROM t8_restart;
SELECT count(*) FROM t9_restart;
--echo #
--echo # Show these tables in information_schema.
......@@ -247,9 +218,6 @@ DROP TABLE t3_restart;
# and an ISL file will be created not using InnoDB.
# Table t5_restart will be expanded.
# Tables t6_restart and t7_restart will be truncated.
DROP TABLE t8_restart;
DROP TABLE t9_restart;
DROP TABLESPACE s1_restart;
--echo #
--echo # Truncate the remote tablespaces.
......
......@@ -6798,62 +6798,6 @@ fil_get_space_names(
}
#ifndef UNIV_HOTBACKUP
/** Return the next fil_node_t in the current or next fil_space_t.
Once started, the caller must keep calling this until it returns NULL.
fil_space_acquire() and fil_space_release() are invoked here which
blocks a concurrent operation from dropping the tablespace.
@param[in] prev_node Pointer to the previous fil_node_t.
If NULL, use the first fil_space_t on fil_system->space_list.
@return pointer to the next fil_node_t.
@retval NULL if this was the last file node */
const fil_node_t*
fil_node_next(
const fil_node_t* prev_node)
{
fil_space_t* space;
const fil_node_t* node = prev_node;
mutex_enter(&fil_system->mutex);
if (node == NULL) {
space = UT_LIST_GET_FIRST(fil_system->space_list);
/* We can trust that space is not NULL because at least the
system tablespace is always present and loaded first. */
space->n_pending_ops++;
node = UT_LIST_GET_FIRST(space->chain);
ut_ad(node != NULL);
} else {
space = node->space;
ut_ad(space->n_pending_ops > 0);
node = UT_LIST_GET_NEXT(chain, node);
if (node == NULL) {
/* Move on to the next fil_space_t */
space->n_pending_ops--;
space = UT_LIST_GET_NEXT(space_list, space);
/* Skip spaces that are being dropped or truncated. */
while (space != NULL
&& (space->stop_new_ops
|| space->is_being_truncated)) {
space = UT_LIST_GET_NEXT(space_list, space);
}
if (space != NULL) {
space->n_pending_ops++;
node = UT_LIST_GET_FIRST(space->chain);
ut_ad(node != NULL);
}
}
}
mutex_exit(&fil_system->mutex);
return(node);
}
/** Generate redo log for swapping two .ibd files
@param[in] old_table old table
@param[in] new_table new table
......
......@@ -1544,31 +1544,6 @@ innodb_enable_monitor_at_startup(
/*=============================*/
char* str); /*!< in: monitor counter enable list */
/** Fill handlerton based INFORMATION_SCHEMA tables.
@param[in] (unused) Handle to the handlerton structure
@param[in] thd Thread/connection descriptor
@param[in,out] tables Information Schema tables to fill
@param[in] (unused) Intended for conditional pushdown
@param[in] idx Table id that indicates which I_S table to fill
@return Operation status */
static
int
innobase_fill_i_s_table(
handlerton*,
THD* thd,
TABLE_LIST* tables,
Item*,
enum_schema_tables idx)
{
int ret = 0;
if (idx == SCH_FILES) {
ret = i_s_files_table_fill(thd, tables);
}
return(ret);
}
#ifdef MYSQL_STORE_FTS_DOC_ID
/** Store doc_id value into FTS_DOC_ID field
@param[in,out] tbl table containing FULLTEXT index
......@@ -4092,7 +4067,6 @@ innobase_init(
innobase_hton->flush_logs = innobase_flush_logs;
innobase_hton->show_status = innobase_show_status;
innobase_hton->fill_is_table = innobase_fill_i_s_table;
innobase_hton->flags =
HTON_SUPPORTS_EXTENDED_KEYS | HTON_SUPPORTS_FOREIGN_KEYS;
......
......@@ -9845,147 +9845,3 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_semaphore_waits =
STRUCT_FLD(version_info, INNODB_VERSION_STR),
STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE),
};
/** Fill handlerton based INFORMATION_SCHEMA.FILES table.
@param[in,out] thd thread/connection descriptor
@param[in,out] tables information schema tables to fill
@retval 0 for success
@retval HA_ERR_OUT_OF_MEM when running out of memory
@return nonzero for failure */
int
i_s_files_table_fill(
THD* thd,
TABLE_LIST* tables)
{
TABLE* table_to_fill = tables->table;
Field** fields = table_to_fill->field;
/* Use this class so that if the OK() macro returns,
fil_space_release() is called. */
FilSpace space;
DBUG_ENTER("i_s_files_table_fill");
/* Gather information reportable to information_schema.files
for the first or next file in fil_system. */
for (const fil_node_t* node = fil_node_next(NULL);
node != NULL;
node = fil_node_next(node)) {
const char* type = "TABLESPACE";
const char* space_name;
/** Buffer to build file-per-table tablespace names.
Even though a space_id is often stored in a ulint, it cannot
be larger than 1<<32-1, which is 10 numeric characters. */
char file_per_table_name[
sizeof("innodb_file_per_table_1234567890")];
uintmax_t avail_space;
ulint extent_pages;
ulint extend_pages;
space = node->space;
fil_type_t purpose = space()->purpose;
switch (purpose) {
case FIL_TYPE_LOG:
/* Do not report REDO LOGs to I_S.FILES */
space = NULL;
continue;
case FIL_TYPE_TABLESPACE:
if (!is_system_tablespace(space()->id)
&& space()->id <= srv_undo_tablespaces_open) {
type = "UNDO LOG";
break;
} /* else fall through for TABLESPACE */
case FIL_TYPE_IMPORT:
/* 'IMPORTING'is a status. The type is TABLESPACE. */
break;
case FIL_TYPE_TEMPORARY:
type = "TEMPORARY";
break;
};
page_size_t page_size(space()->flags);
/* Single-table tablespaces are assigned to a schema. */
if (!is_predefined_tablespace(space()->id)
&& !FSP_FLAGS_GET_SHARED(space()->flags)) {
/* Their names will be like "test/t1" */
ut_ad(NULL != strchr(space()->name, '/'));
/* File-per-table tablespace names are generated
internally and certain non-file-system-allowed
characters are expanded which can make the space
name too long. In order to avoid that problem,
use a modified tablespace name.
Since we are not returning dbname and tablename,
the user must match the space_id to i_s_table.space
in order find the single table that is in it or the
schema it belongs to. */
ut_snprintf(
file_per_table_name,
sizeof(file_per_table_name),
"innodb_file_per_table_" ULINTPF,
space()->id);
space_name = file_per_table_name;
} else {
/* Only file-per-table space names contain '/'.
This is not file-per-table . */
ut_ad(NULL == strchr(space()->name, '/'));
space_name = space()->name;
}
init_fill_schema_files_row(table_to_fill);
OK(field_store_ulint(fields[IS_FILES_FILE_ID],
space()->id));
OK(field_store_string(fields[IS_FILES_FILE_NAME],
node->name));
OK(field_store_string(fields[IS_FILES_FILE_TYPE],
type));
OK(field_store_string(fields[IS_FILES_TABLESPACE_NAME],
space_name));
OK(field_store_string(fields[IS_FILES_ENGINE],
"InnoDB"));
OK(field_store_ulint(fields[IS_FILES_FREE_EXTENTS],
space()->free_len));
extent_pages = fsp_get_extent_size_in_pages(page_size);
OK(field_store_ulint(fields[IS_FILES_TOTAL_EXTENTS],
space()->size_in_header / extent_pages));
OK(field_store_ulint(fields[IS_FILES_EXTENT_SIZE],
extent_pages * page_size.physical()));
OK(field_store_ulint(fields[IS_FILES_INITIAL_SIZE],
node->init_size * page_size.physical()));
if (node->max_size >= ULINT_MAX) {
fields[IS_FILES_MAXIMUM_SIZE]->set_null();
} else {
OK(field_store_ulint(fields[IS_FILES_MAXIMUM_SIZE],
node->max_size * page_size.physical()));
}
if (space()->id == srv_sys_space.space_id()) {
extend_pages = srv_sys_space.get_increment();
} else if (space()->id == srv_tmp_space.space_id()) {
extend_pages = srv_tmp_space.get_increment();
} else {
extend_pages = fsp_get_pages_to_extend_ibd(
page_size, node->size);
}
OK(field_store_ulint(fields[IS_FILES_AUTOEXTEND_SIZE],
extend_pages * page_size.physical()));
avail_space = fsp_get_available_space_in_free_extents(space());
OK(field_store_ulint(fields[IS_FILES_DATA_FREE],
static_cast<ulint>(avail_space * 1024)));
OK(field_store_string(fields[IS_FILES_STATUS],
(purpose == FIL_TYPE_IMPORT)
? "IMPORTING" : "NORMAL"));
schema_table_store_record(thd, table_to_fill);
space = NULL;
}
DBUG_RETURN(0);
}
/*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyrigth (c) 2014, 2015, MariaDB Corporation
Copyrigth (c) 2014, 2016, MariaDB Corporation
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -66,17 +66,6 @@ extern struct st_maria_plugin i_s_innodb_tablespaces_encryption;
extern struct st_maria_plugin i_s_innodb_tablespaces_scrubbing;
extern struct st_maria_plugin i_s_innodb_sys_semaphore_waits;
/** Fill handlerton based INFORMATION_SCHEMA.FILES table.
@param[in,out] thd thread/connection descriptor
@param[in,out] tables information schema tables to fill
@retval 0 for success
@retval HA_ERR_OUT_OF_MEM when running out of memory
@return nonzero for failure */
int
i_s_files_table_fill(
THD *thd,
TABLE_LIST *tables);
/** maximum number of buffer page info we would cache. */
#define MAX_BUF_INFO_CACHED 10000
......
......@@ -1609,18 +1609,6 @@ fil_get_space_names(
/*!< in/out: Vector for collecting the names. */
MY_ATTRIBUTE((warn_unused_result));
/** Return the next fil_node_t in the current or next fil_space_t.
Once started, the caller must keep calling this until it returns NULL.
fil_space_acquire() and fil_space_release() are invoked here which
blocks a concurrent operation from dropping the tablespace.
@param[in] prev_node Pointer to the previous fil_node_t.
If NULL, use the first fil_space_t on fil_system->space_list.
@return pointer to the next fil_node_t.
@retval NULL if this was the last file node */
const fil_node_t*
fil_node_next(
const fil_node_t* prev_node);
/** Generate redo log for swapping two .ibd files
@param[in] old_table old table
@param[in] new_table new table
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment