mirror of
https://github.com/MariaDB/server.git
synced 2025-09-03 20:43:11 +03:00
MDEV-15824 innodb_defragment=ON trumps innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
ha_innobase::optimize(): If both innodb_defragment and innodb_optimize_fulltext_only are at their default settings (OFF), fall back to ALTER TABLE. Else process one or both options.
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
|
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
|
||||||
|
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
|
||||||
SET GLOBAL innodb_defragment = 1;
|
SET GLOBAL innodb_defragment = 1;
|
||||||
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB;
|
SET GLOBAL innodb_optimize_fulltext_only = 0;
|
||||||
|
#
|
||||||
|
# MDEV-12198 innodb_defragment=1 crashes server on
|
||||||
|
# OPTIMIZE TABLE when FULLTEXT index exists
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256),
|
||||||
|
KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB;
|
||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 optimize status OK
|
test.t1 optimize status OK
|
||||||
@@ -11,14 +18,18 @@ INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
|
|||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 optimize status OK
|
test.t1 optimize status OK
|
||||||
DROP TABLE t1;
|
|
||||||
#
|
#
|
||||||
# MDEV-12198 innodb_defragment=1 crashes server on
|
# MDEV-15824 innodb_defragment=ON trumps
|
||||||
# OPTIMIZE TABLE when FULLTEXT index exists
|
# innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
|
||||||
#
|
#
|
||||||
CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB;
|
SET GLOBAL innodb_optimize_fulltext_only = 1;
|
||||||
|
OPTIMIZE TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 optimize status OK
|
||||||
|
SET GLOBAL innodb_defragment = 0;
|
||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 optimize status OK
|
test.t1 optimize status OK
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
||||||
|
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;
|
||||||
|
@@ -1,10 +1,17 @@
|
|||||||
--source include/have_innodb.inc
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
|
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
|
||||||
|
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
|
||||||
SET GLOBAL innodb_defragment = 1;
|
SET GLOBAL innodb_defragment = 1;
|
||||||
|
SET GLOBAL innodb_optimize_fulltext_only = 0;
|
||||||
|
|
||||||
# Small tests copied from innodb.innodb_defragment
|
--echo #
|
||||||
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB;
|
--echo # MDEV-12198 innodb_defragment=1 crashes server on
|
||||||
|
--echo # OPTIMIZE TABLE when FULLTEXT index exists
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256),
|
||||||
|
KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB;
|
||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
|
|
||||||
INSERT INTO t1 VALUES (100000, REPEAT('A', 256));
|
INSERT INTO t1 VALUES (100000, REPEAT('A', 256));
|
||||||
@@ -13,16 +20,18 @@ INSERT INTO t1 VALUES (300000, REPEAT('A', 256));
|
|||||||
INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
|
INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
|
||||||
|
|
||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
DROP TABLE t1;
|
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-12198 innodb_defragment=1 crashes server on
|
--echo # MDEV-15824 innodb_defragment=ON trumps
|
||||||
--echo # OPTIMIZE TABLE when FULLTEXT index exists
|
--echo # innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
|
||||||
--echo #
|
--echo #
|
||||||
|
|
||||||
CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB;
|
SET GLOBAL innodb_optimize_fulltext_only = 1;
|
||||||
|
|
||||||
OPTIMIZE TABLE t1;
|
OPTIMIZE TABLE t1;
|
||||||
|
SET GLOBAL innodb_defragment = 0;
|
||||||
|
OPTIMIZE TABLE t1;
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
||||||
|
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;
|
||||||
|
@@ -13904,6 +13904,7 @@ ha_innobase::optimize(
|
|||||||
|
|
||||||
This works OK otherwise, but MySQL locks the entire table during
|
This works OK otherwise, but MySQL locks the entire table during
|
||||||
calls to OPTIMIZE, which is undesirable. */
|
calls to OPTIMIZE, which is undesirable. */
|
||||||
|
bool try_alter = true;
|
||||||
|
|
||||||
if (srv_defragment) {
|
if (srv_defragment) {
|
||||||
int err;
|
int err;
|
||||||
@@ -13911,7 +13912,7 @@ ha_innobase::optimize(
|
|||||||
err = defragment_table(prebuilt->table->name, NULL, false);
|
err = defragment_table(prebuilt->table->name, NULL, false);
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
return (HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
} else {
|
||||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||||
err,
|
err,
|
||||||
@@ -13919,9 +13920,7 @@ ha_innobase::optimize(
|
|||||||
prebuilt->table->name, err);
|
prebuilt->table->name, err);
|
||||||
|
|
||||||
if(err == ER_SP_ALREADY_EXISTS) {
|
if(err == ER_SP_ALREADY_EXISTS) {
|
||||||
return (HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
|
||||||
return (HA_ADMIN_TRY_ALTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13932,11 +13931,10 @@ ha_innobase::optimize(
|
|||||||
fts_sync_table(prebuilt->table, false, true, false);
|
fts_sync_table(prebuilt->table, false, true, false);
|
||||||
fts_optimize_table(prebuilt->table);
|
fts_optimize_table(prebuilt->table);
|
||||||
}
|
}
|
||||||
return(HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
|
||||||
|
|
||||||
return(HA_ADMIN_TRY_ALTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************//**
|
/*******************************************************************//**
|
||||||
|
@@ -14522,6 +14522,7 @@ ha_innobase::optimize(
|
|||||||
|
|
||||||
This works OK otherwise, but MySQL locks the entire table during
|
This works OK otherwise, but MySQL locks the entire table during
|
||||||
calls to OPTIMIZE, which is undesirable. */
|
calls to OPTIMIZE, which is undesirable. */
|
||||||
|
bool try_alter = true;
|
||||||
|
|
||||||
if (srv_defragment) {
|
if (srv_defragment) {
|
||||||
int err;
|
int err;
|
||||||
@@ -14529,7 +14530,7 @@ ha_innobase::optimize(
|
|||||||
err = defragment_table(prebuilt->table->name, NULL, false);
|
err = defragment_table(prebuilt->table->name, NULL, false);
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
return (HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
} else {
|
||||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||||
err,
|
err,
|
||||||
@@ -14537,9 +14538,7 @@ ha_innobase::optimize(
|
|||||||
prebuilt->table->name, err);
|
prebuilt->table->name, err);
|
||||||
|
|
||||||
if(err == ER_SP_ALREADY_EXISTS) {
|
if(err == ER_SP_ALREADY_EXISTS) {
|
||||||
return (HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
|
||||||
return (HA_ADMIN_TRY_ALTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14550,11 +14549,10 @@ ha_innobase::optimize(
|
|||||||
fts_sync_table(prebuilt->table, false, true, false);
|
fts_sync_table(prebuilt->table, false, true, false);
|
||||||
fts_optimize_table(prebuilt->table);
|
fts_optimize_table(prebuilt->table);
|
||||||
}
|
}
|
||||||
return(HA_ADMIN_OK);
|
try_alter = false;
|
||||||
} else {
|
|
||||||
|
|
||||||
return(HA_ADMIN_TRY_ALTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************//**
|
/*******************************************************************//**
|
||||||
|
Reference in New Issue
Block a user