Commit bba224dd authored by Rasmus Johansson's avatar Rasmus Johansson

Added server variable compression_default, which if 1/ON sets compression on...

Added server variable compression_default, which if 1/ON sets compression on for all new InnoDB/XtraDB tables by default by setting PAGE_COMPRESSED=1
parent 0c15d1a6
......@@ -123,5 +123,31 @@ drop procedure innodb_insert_proc;
drop table innodb_normal;
drop table innodb_compact;
drop table innodb_dynamic;
CREATE TABLE no_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB;
SET SESSION innodb_compression_default = 1;
CREATE TABLE default_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB;
CREATE TABLE explicit_no_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB PAGE_COMPRESSED=0;
SHOW CREATE TABLE no_compression;
Table Create Table
no_compression CREATE TABLE `no_compression` (
`id` int(11) NOT NULL,
`name` varchar(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE default_compression;
Table Create Table
default_compression CREATE TABLE `default_compression` (
`id` int(11) NOT NULL,
`name` varchar(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `PAGE_COMPRESSED`='ON'
SHOW CREATE TABLE explicit_no_compression;
Table Create Table
explicit_no_compression CREATE TABLE `explicit_no_compression` (
`id` int(11) NOT NULL,
`name` varchar(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 `PAGE_COMPRESSED`=0
DROP TABLE no_compression;
DROP TABLE default_compression;
DROP TABLE explicit_no_compression;
SET SESSION innodb_compression_default = 0;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
......@@ -95,6 +95,20 @@ drop table innodb_normal;
drop table innodb_compact;
drop table innodb_dynamic;
# MDEV-9820 introducing variable for having page compression turned on by default on InnoDB tables
# test that innodb_compression_default works as expected, i.e. if it has a value of 1 (ON) tables are by default created with page_compressed=1;
CREATE TABLE no_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB;
SET SESSION innodb_compression_default = 1;
CREATE TABLE default_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB;
CREATE TABLE explicit_no_compression (id INT NOT NULL, name VARCHAR(200)) ENGINE=InnoDB PAGE_COMPRESSED=0;
SHOW CREATE TABLE no_compression;
SHOW CREATE TABLE default_compression;
SHOW CREATE TABLE explicit_no_compression;
DROP TABLE no_compression;
DROP TABLE default_compression;
DROP TABLE explicit_no_compression;
SET SESSION innodb_compression_default = 0;
# reset system
--disable_query_log
EVAL SET GLOBAL innodb_compression_algorithm = $innodb_compression_algorithm_orig;
......
......@@ -684,6 +684,11 @@ srv_mbr_debug(const byte* data)
static void innodb_remember_check_sysvar_funcs();
mysql_var_check_func check_sysvar_enum;
// should page compression be used by default for new tables
static MYSQL_THDVAR_BOOL(compression_default, PLUGIN_VAR_OPCMDARG,
"Is compression the default for new tables",
NULL, NULL, FALSE);
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.",
NULL, NULL,
......@@ -701,7 +706,7 @@ ha_create_table_option innodb_table_option_list[]=
{
/* With this option user can enable page compression feature for the
table */
HA_TOPTION_BOOL("PAGE_COMPRESSED", page_compressed, 0),
HA_TOPTION_SYSVAR("PAGE_COMPRESSED", page_compressed, compression_default),
/* With this option user can set zip compression level for page
compression for this table*/
HA_TOPTION_NUMBER("PAGE_COMPRESSION_LEVEL", page_compression_level, 0, 1, 9, 1),
......@@ -23810,6 +23815,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(fatal_semaphore_wait_threshold),
/* Table page compression feature */
MYSQL_SYSVAR(use_trim),
MYSQL_SYSVAR(compression_default),
MYSQL_SYSVAR(compression_algorithm),
MYSQL_SYSVAR(mtflush_threads),
MYSQL_SYSVAR(use_mtflush),
......
......@@ -620,6 +620,11 @@ ib_cb_t innodb_api_cb[] = {
static void innodb_remember_check_sysvar_funcs();
mysql_var_check_func check_sysvar_enum;
// should page compression be used by default for new tables
static MYSQL_THDVAR_BOOL(compression_default, PLUGIN_VAR_OPCMDARG,
"Is compression the default for new tables",
NULL, NULL, FALSE);
static MYSQL_THDVAR_UINT(default_encryption_key_id, PLUGIN_VAR_RQCMDARG,
"Default encryption key id used for table encryption.",
NULL, NULL,
......@@ -637,7 +642,7 @@ ha_create_table_option innodb_table_option_list[]=
{
/* With this option user can enable page compression feature for the
table */
HA_TOPTION_BOOL("PAGE_COMPRESSED", page_compressed, 0),
HA_TOPTION_BOOL("PAGE_COMPRESSED", page_compressed, compression_default),
/* With this option user can set zip compression level for page
compression for this table*/
HA_TOPTION_NUMBER("PAGE_COMPRESSION_LEVEL", page_compression_level, 0, 1, 9, 1),
......@@ -21433,6 +21438,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(fatal_semaphore_wait_threshold),
/* Table page compression feature */
MYSQL_SYSVAR(use_trim),
MYSQL_SYSVAR(compression_default),
MYSQL_SYSVAR(compression_algorithm),
MYSQL_SYSVAR(mtflush_threads),
MYSQL_SYSVAR(use_mtflush),
......
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