1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-14016 Allow instant ADD COLUMN, ADD INDEX, LOCK=NONE

Ideally, we would move some code from
ha_innobase::prepare_inplace_alter_table() to
ha_innobase::check_if_supported_inplace_alter(),
but the API does not really allow us to return errors; it can
only inform which forms of ALGORITHM and LOCK are allowed.

So, we have to duplicate some logic between the "check" and "prepare"
phases. We do the duplication by calling common functions.

instant_alter_column_possible(): Check if instant column operation
is possible. Invoked from both
ha_innobase::check_if_supported_inplace_alter() and
prepare_inplace_alter_table_dict().

ha_innobase::check_if_supported_inplace_alter(): Before refusing
certain operations if FULLTEXT INDEX exist, check if instant ALTER TABLE
is possible and return early if it is the case.

prepare_inplace_alter_table_dict(): Before checking the limitations
on FULLTEXT INDEX, check if instant ALTER TABLE is possible, and suppress
the checks if it is the case. If instant ADD COLUMN is used when the
table already contains FULLTEXT INDEX, do account for a
hidden FTS_DOC_ID_INDEX in a debug assertion.
This commit is contained in:
Marko Mäkelä
2017-11-01 22:26:25 +02:00
parent 5603a5842b
commit 6402ca7870
5 changed files with 303 additions and 180 deletions

View File

@ -476,25 +476,24 @@ ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
# ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
# --error ER_INVALID_USE_OF_NULL
# ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
--disable_info
# instant add, supported
#ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
#SELECT HEX(c8) FROM tab;
#BEGIN;
#INSERT INTO tab SELECT 0,c2,c3,c4,c5,ST_GeomFromText('POINT(67 89)')
#FROM tab LIMIT 1;
#SELECT HEX(c8) FROM tab;
#ROLLBACK;
ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
SELECT HEX(c8) FROM tab;
BEGIN;
INSERT INTO tab SELECT 0,c2,c3,c4,c5,
ST_GeomFromText('POINT(67 89)'),ST_GeomFromText('POINT(67 89)')
FROM tab LIMIT 1;
SELECT HEX(c8) FROM tab;
ROLLBACK;
# not instant, not supported
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE tab add COLUMN c8 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
--disable_info
ALTER TABLE tab add COLUMN c9 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
SHOW CREATE TABLE tab;