Skip to content

Commit 2464ee7

Browse files
montywivuvova
authored andcommitted
MDEV-33655 Remove alter_algorithm
Remove alter_algorithm but keep the variable as no-op (with a warning). The reasons for removing alter_algorithm are: - alter_algorithm was introduced as a replacement for the old_alter_table that was used to force the usage of the original alter table algorithm (copy) in the cases where the new alter algorithm did not work. The new option was added as a way to force the usage of a specific algorithm when it should instead have made it possible to disable algorithms that would not work for some reason. - alter_algorithm introduced some cases where ALTER TABLE would not work without specifying the ALGORITHM=XXX option together with ALTER TABLE. - Having different values of alter_algorithm on master and slave could cause slave to stop unexpectedly. - ALTER TABLE FORCE, as used by mariadb-upgrade, would not always work if alter_algorithm was set for the server. - As part of the MDEV-33449 "improving repair of tables" it become clear that alter- algorithm made it harder to provide a better and more consistent ALTER TABLE FORCE and REPAIR TABLE and it would be better to remove it.
1 parent 6254fcf commit 2464ee7

File tree

58 files changed

+1157
-2191
lines changed

Some content is hidden

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

58 files changed

+1157
-2191
lines changed

mysql-test/main/alter_table.result

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,13 +1654,11 @@ ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE;
16541654
affected rows: 0
16551655
ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
16561656
#
1657-
# 2: Test ALGORITHM + alter_algorithm
1657+
# 2: Test ALGORITHM keywords
16581658
#
1659-
SET SESSION alter_algorithm= 1;
1660-
affected rows: 0
16611659
ALTER TABLE t1 ADD INDEX i1(b);
1662-
affected rows: 2
1663-
info: Records: 2 Duplicates: 0 Warnings: 0
1660+
affected rows: 0
1661+
info: Records: 0 Duplicates: 0 Warnings: 0
16641662
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= DEFAULT;
16651663
affected rows: 0
16661664
info: Records: 0 Duplicates: 0 Warnings: 1
@@ -1676,8 +1674,6 @@ affected rows: 0
16761674
info: Records: 0 Duplicates: 0 Warnings: 1
16771675
Warnings:
16781676
Note 1831 Duplicate index `i4`. This is deprecated and will be disallowed in a future release
1679-
SET SESSION alter_algorithm= 0;
1680-
affected rows: 0
16811677
ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
16821678
#
16831679
# 3: Test unsupported in-place operation
@@ -3123,3 +3119,13 @@ DROP TABLE t;
31233119
#
31243120
# End of 10.7 tests
31253121
#
3122+
#
3123+
# MDEV-33655 Remove alter_algorithm
3124+
#
3125+
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
3126+
CREATE TABLE t2 (a INT) ENGINE=MERGE, UNION(t1);
3127+
ALTER TABLE t2 COMMENT 'x', LOCK=SHARED;
3128+
DROP TABLE t2,t1;
3129+
#
3130+
# End of 11.5 tests
3131+
#

mysql-test/main/alter_table.test

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,16 +1462,14 @@ ALTER TABLE m1 ENABLE KEYS, ALGORITHM= INPLACE;
14621462
ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
14631463

14641464
--echo #
1465-
--echo # 2: Test ALGORITHM + alter_algorithm
1465+
--echo # 2: Test ALGORITHM keywords
14661466
--echo #
14671467

14681468
--enable_info
1469-
SET SESSION alter_algorithm= 1;
14701469
ALTER TABLE t1 ADD INDEX i1(b);
14711470
ALTER TABLE t1 ADD INDEX i2(b), ALGORITHM= DEFAULT;
14721471
ALTER TABLE t1 ADD INDEX i3(b), ALGORITHM= COPY;
14731472
ALTER TABLE t1 ADD INDEX i4(b), ALGORITHM= INPLACE;
1474-
SET SESSION alter_algorithm= 0;
14751473
--disable_info
14761474

14771475
ALTER TABLE t1 DROP INDEX i1, DROP INDEX i2, DROP INDEX i3, DROP INDEX i4;
@@ -2428,3 +2426,16 @@ DROP TABLE t;
24282426
--echo #
24292427
--echo # End of 10.7 tests
24302428
--echo #
2429+
2430+
--echo #
2431+
--echo # MDEV-33655 Remove alter_algorithm
2432+
--echo #
2433+
2434+
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
2435+
CREATE TABLE t2 (a INT) ENGINE=MERGE, UNION(t1);
2436+
ALTER TABLE t2 COMMENT 'x', LOCK=SHARED;
2437+
DROP TABLE t2,t1;
2438+
2439+
--echo #
2440+
--echo # End of 11.5 tests
2441+
--echo #
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
create table t1 (a int, b int, key a1(a)) engine=innodb;
22
insert into t1 values (1,1),(2,2),(3,3);
3-
set alter_algorithm='instant';
4-
alter table t1 alter index a1 ignored;
5-
alter table t1 alter index a1 not ignored;
6-
set alter_algorithm=default;
3+
alter table t1 alter index a1 ignored, algorithm=instant;
4+
show create table t1;
5+
Table Create Table
6+
t1 CREATE TABLE `t1` (
7+
`a` int(11) DEFAULT NULL,
8+
`b` int(11) DEFAULT NULL,
9+
KEY `a1` (`a`) IGNORED
10+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
11+
alter table t1 alter index a1 not ignored, algorithm=instant;
12+
show create table t1;
13+
Table Create Table
14+
t1 CREATE TABLE `t1` (
15+
`a` int(11) DEFAULT NULL,
16+
`b` int(11) DEFAULT NULL,
17+
KEY `a1` (`a`)
18+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
719
drop table t1;

mysql-test/main/ignored_index_innodb.test

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
create table t1 (a int, b int, key a1(a)) engine=innodb;
77
insert into t1 values (1,1),(2,2),(3,3);
88

9-
set alter_algorithm='instant';
10-
alter table t1 alter index a1 ignored;
9+
alter table t1 alter index a1 ignored, algorithm=instant;
10+
show create table t1;
11+
alter table t1 alter index a1 not ignored, algorithm=instant;
12+
show create table t1;
1113

12-
alter table t1 alter index a1 not ignored;
13-
14-
set alter_algorithm=default;
1514
drop table t1;
16-

mysql-test/main/innodb_mysql_sync.result

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -449,63 +449,14 @@ info: Records: 0 Duplicates: 0 Warnings: 0
449449
ALTER TABLE t1 ENGINE=INNODB;
450450
affected rows: 0
451451
info: Records: 0 Duplicates: 0 Warnings: 0
452-
#ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE uses
453-
#table copy when the alter_algorithm enabled.
454-
SET SESSION alter_algorithm= TRUE;
455-
affected rows: 0
456-
ALTER TABLE t1 FORCE;
452+
# ALTER TABLE FORCE and ALTER TABLE ENGINE uses table copy
453+
# when ALGORITHM COPY is used.
454+
ALTER TABLE t1 FORCE, ALGORITHM= COPY;
457455
affected rows: 1
458456
info: Records: 1 Duplicates: 0 Warnings: 0
459-
ALTER TABLE t1 ENGINE= INNODB;
457+
ALTER TABLE t1 ENGINE= INNODB, ALGORITHM= COPY;
460458
affected rows: 1
461459
info: Records: 1 Duplicates: 0 Warnings: 0
462-
SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
463-
affected rows: 0
464-
#OPTIMIZE TABLE operation using table copy.
465-
OPTIMIZE TABLE t1;
466-
connection con1;
467-
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
468-
affected rows: 0
469-
INSERT INTO t1 VALUES(10, 20);
470-
affected rows: 1
471-
connection default;
472-
Table Op Msg_type Msg_text
473-
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
474-
test.t1 optimize status OK
475-
affected rows: 2
476-
SET DEBUG_SYNC= 'RESET';
477-
affected rows: 0
478-
SET SESSION alter_algorithm= FALSE;
479-
affected rows: 0
480-
#ALTER TABLE FORCE and ALTER TABLE ENGINE uses table copy
481-
#when ALGORITHM COPY is used.
482-
ALTER TABLE t1 FORCE, ALGORITHM= COPY;
483-
affected rows: 2
484-
info: Records: 2 Duplicates: 0 Warnings: 0
485-
ALTER TABLE t1 ENGINE= INNODB, ALGORITHM= COPY;
486-
affected rows: 2
487-
info: Records: 2 Duplicates: 0 Warnings: 0
488-
DROP TABLE t1;
489-
#OPTIMIZE TABLE on a table with FULLTEXT index uses
490-
#ALTER TABLE FORCE using COPY algorithm here. This
491-
#test case ensures the COPY table debug sync point is hit.
492-
SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
493-
#Setup a table with FULLTEXT index.
494-
connection default;
495-
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1), FULLTEXT(fld1)) ENGINE= INNODB;
496-
Warnings:
497-
Note 1831 Duplicate index `fld1_2`. This is deprecated and will be disallowed in a future release
498-
INSERT INTO t1 VALUES("String1");
499-
#OPTIMIZE TABLE operation.
500-
OPTIMIZE TABLE t1;
501-
connection con1;
502-
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
503-
INSERT INTO t1 VALUES("String2");
504-
connection default;
505-
Table Op Msg_type Msg_text
506-
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
507-
test.t1 optimize status OK
508-
SET DEBUG_SYNC= 'RESET';
509460
DROP TABLE t1;
510461
#Test which demonstrates that ALTER TABLE, OPTIMIZE PARTITION
511462
#takes OPTIMIZE TABLE code path, hence does an online rebuild

mysql-test/main/innodb_mysql_sync.test

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -611,57 +611,15 @@ INSERT INTO t1 VALUES(10, 20);
611611
ALTER TABLE t1 FORCE;
612612
ALTER TABLE t1 ENGINE=INNODB;
613613

614-
--echo #ALTER TABLE FORCE, ALTER TABLE ENGINE and OPTIMIZE TABLE uses
615-
--echo #table copy when the alter_algorithm enabled.
616-
SET SESSION alter_algorithm= TRUE;
617-
ALTER TABLE t1 FORCE;
618-
ALTER TABLE t1 ENGINE= INNODB;
619-
620-
SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
621-
--echo #OPTIMIZE TABLE operation using table copy.
622-
--send OPTIMIZE TABLE t1
623-
624-
--connection con1
625-
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
626-
INSERT INTO t1 VALUES(10, 20);
627-
628-
--connection default
629-
--reap
630-
SET DEBUG_SYNC= 'RESET';
631-
SET SESSION alter_algorithm= FALSE;
632-
633-
--echo #ALTER TABLE FORCE and ALTER TABLE ENGINE uses table copy
634-
--echo #when ALGORITHM COPY is used.
614+
--echo # ALTER TABLE FORCE and ALTER TABLE ENGINE uses table copy
615+
--echo # when ALGORITHM COPY is used.
635616
ALTER TABLE t1 FORCE, ALGORITHM= COPY;
636617
ALTER TABLE t1 ENGINE= INNODB, ALGORITHM= COPY;
637618
--disable_info
638619

639620
#cleanup
640621
DROP TABLE t1;
641622

642-
--echo #OPTIMIZE TABLE on a table with FULLTEXT index uses
643-
--echo #ALTER TABLE FORCE using COPY algorithm here. This
644-
--echo #test case ensures the COPY table debug sync point is hit.
645-
646-
SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
647-
648-
--echo #Setup a table with FULLTEXT index.
649-
--connection default
650-
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1), FULLTEXT(fld1)) ENGINE= INNODB;
651-
INSERT INTO t1 VALUES("String1");
652-
653-
--echo #OPTIMIZE TABLE operation.
654-
--send OPTIMIZE TABLE t1
655-
656-
--connection con1
657-
SET DEBUG_SYNC= 'now WAIT_FOR upgraded';
658-
INSERT INTO t1 VALUES("String2");
659-
660-
--connection default
661-
--reap
662-
SET DEBUG_SYNC= 'RESET';
663-
DROP TABLE t1;
664-
665623
--echo #Test which demonstrates that ALTER TABLE, OPTIMIZE PARTITION
666624
--echo #takes OPTIMIZE TABLE code path, hence does an online rebuild
667625
--echo #of the table with the patch.

mysql-test/main/load_timezones_with_alter_algorithm_inplace.result

Lines changed: 0 additions & 18 deletions
This file was deleted.

mysql-test/main/load_timezones_with_alter_algorithm_inplace.test

Lines changed: 0 additions & 40 deletions
This file was deleted.

mysql-test/main/mysql_tzinfo_to_sql_symlink.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_n
104104
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0');
105105
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition_type ENGINE=', @time_zone_transition_type_engine, ', ORDER BY Time_zone_id, Transition_type_id'), 'do 0');
106106
SET session alter_algorithm=@old_alter_alg;
107+
Warnings:
108+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
109+
Warnings:
110+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
107111
SELECT COUNT(*) FROM time_zone;
108112
COUNT(*)
109113
2
@@ -161,6 +165,10 @@ execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_t
161165
SET SESSION SQL_LOG_BIN=@save_sql_log_bin;
162166
execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0');
163167
SET session alter_algorithm=@old_alter_alg;
168+
Warnings:
169+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
170+
Warnings:
171+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
164172
SELECT COUNT(*) FROM time_zone;
165173
COUNT(*)
166174
2
@@ -481,6 +489,10 @@ execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0'
481489
# MDEV-29347 MariaDB 10.6.8 fails to start when ONLY_FULL_GROUP_BY gets provided
482490
#
483491
set sql_mode=only_full_group_by;
492+
Warnings:
493+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
494+
Warnings:
495+
Warning 4200 The variable '@@alter_algorithm' is deleted and ignored. It it only exists for compatiblity with old installations
484496
SELECT COUNT(*) FROM time_zone;
485497
COUNT(*)
486498
2

0 commit comments

Comments
 (0)