Merge 10.6 into 10.11

This commit is contained in:
Marko Mäkelä 2025-09-24 12:48:56 +03:00
commit 990b44495c
27 changed files with 565 additions and 201 deletions

View file

@ -81,6 +81,7 @@ my %debuggers = (
options => '_RR_TRACE_DIR={log} rr record {exe} {args} --loose-skip-innodb-use-native-aio --loose-innodb-flush-method=fsync', options => '_RR_TRACE_DIR={log} rr record {exe} {args} --loose-skip-innodb-use-native-aio --loose-innodb-flush-method=fsync',
run => 'env', run => 'env',
pre => sub { pre => sub {
push @::global_suppressions, qr/InnoDB: native AIO failed/;
::mtr_error('rr requires kernel.perf_event_paranoid <= 1') ::mtr_error('rr requires kernel.perf_event_paranoid <= 1')
if ::mtr_grab_file('/proc/sys/kernel/perf_event_paranoid') > 1; if ::mtr_grab_file('/proc/sys/kernel/perf_event_paranoid') > 1;
} }

View file

@ -46,70 +46,23 @@ ALTER TABLE t1 MODIFY a DECIMAL(10,0);
SELECT * FROM t1,t2 WHERE a=d; SELECT * FROM t1,t2 WHERE a=d;
a b c pk d e a b c pk d e
Warnings: Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'd' Warning 1292 Truncated incorrect DECIMAL value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd' Warning 1292 Truncated incorrect DECIMAL value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f' Warning 1292 Truncated incorrect DECIMAL value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f' Warning 1292 Truncated incorrect DECIMAL value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g' Warning 1292 Truncated incorrect DECIMAL value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k' Warning 1292 Truncated incorrect DECIMAL value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm' Warning 1292 Truncated incorrect DECIMAL value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm' Warning 1292 Truncated incorrect DECIMAL value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm' Warning 1292 Truncated incorrect DECIMAL value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o' Warning 1292 Truncated incorrect DECIMAL value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q' Warning 1292 Truncated incorrect DECIMAL value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r' Warning 1292 Truncated incorrect DECIMAL value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u' Warning 1292 Truncated incorrect DECIMAL value: 'u'
Warning 1292 Truncated incorrect DOUBLE value: 'w' Warning 1292 Truncated incorrect DECIMAL value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x' Warning 1292 Truncated incorrect DECIMAL value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x' Warning 1292 Truncated incorrect DECIMAL value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y' Warning 1292 Truncated incorrect DECIMAL value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
Warning 1292 Truncated incorrect DOUBLE value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
Warning 1292 Truncated incorrect DOUBLE value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
ALTER TABLE t1 MODIFY a DOUBLE; ALTER TABLE t1 MODIFY a DOUBLE;
SELECT * FROM t1,t2 WHERE a=d; SELECT * FROM t1,t2 WHERE a=d;
a b c pk d e a b c pk d e
@ -131,53 +84,6 @@ Warning 1292 Truncated incorrect DOUBLE value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x' Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x' Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y' Warning 1292 Truncated incorrect DOUBLE value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
Warning 1292 Truncated incorrect DOUBLE value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
Warning 1292 Truncated incorrect DOUBLE value: 'w'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'x'
Warning 1292 Truncated incorrect DOUBLE value: 'y'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'd'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'g'
Warning 1292 Truncated incorrect DOUBLE value: 'k'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'm'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: 'q'
Warning 1292 Truncated incorrect DOUBLE value: 'r'
Warning 1292 Truncated incorrect DOUBLE value: 'u'
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# End of 10.2 tests # End of 10.2 tests

View file

@ -0,0 +1,70 @@
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 BLOB) ENGINE=InnoDB;
connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3;
connection node_3;
SET GLOBAL wsrep_on=OFF;
ALTER TABLE t1 MODIFY f2 LONGTEXT;
SET GLOBAL wsrep_on=ON;
INSERT INTO t1 VALUES (3, 'a');
connection node_1;
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status Primary
connection node_2;
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status Primary
INSERT INTO t1 VALUES (2, 'a');
connection node_3;
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_on=OFF;
# restart
SET SESSION wsrep_on=ON;
INSERT INTO t1 VALUES (3, 'a');
connection node_1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
`f2` blob DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM t1;
f1 f2
2 a
3 a
connection node_2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
`f2` blob DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM t1;
f1 f2
2 a
3 a
connection node_3;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f1` int(11) NOT NULL,
`f2` blob DEFAULT NULL,
PRIMARY KEY (`f1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM t1;
f1 f2
2 a
3 a
DROP TABLE t1;
connection node_1;
CALL mtr.add_suppression("Replica SQL: Column 1 of table 'test.t1' cannot be converted from type 'longblob' to type 'blob', Error_code: MY-013146");
CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 3, seqno");
connection node_2;
CALL mtr.add_suppression("Replica SQL: Column 1 of table 'test.t1' cannot be converted from type 'longblob' to type 'blob', Error_code: MY-013146");
CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 3, seqno");
connection node_3;
CALL mtr.add_suppression("Vote 0 \\(success\\) on (.*) is inconsistent with group. Leaving cluster.");
CALL mtr.add_suppression("Plugin 'InnoDB' will be forced to shutdown");

View file

@ -0,0 +1,5 @@
!include ../galera_3nodes.cnf
[mysqld]
wsrep-ignore-apply-errors=0

View file

@ -0,0 +1,67 @@
#
# MDEV-37494: Inconsistency voting: create conditions where applying would
# fail on replicas in table_def::compatible_with() and check that
# that replicas survive and the primary (trx source) bails out.
#
--source include/galera_cluster.inc
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 BLOB) ENGINE=InnoDB;
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
--connection node_3
SET GLOBAL wsrep_on=OFF;
ALTER TABLE t1 MODIFY f2 LONGTEXT; # Introducing schema inconsistency
SET GLOBAL wsrep_on=ON;
INSERT INTO t1 VALUES (3, 'a'); # Nodes 1 and 2 should fail to apply this
--connection node_1
# Wait until node #3 leaves the cluster
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
SHOW STATUS LIKE 'wsrep_cluster_status';
--connection node_2
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_size'
# Wait until node #3 leaves the cluster
--source include/wait_condition.inc
SHOW STATUS LIKE 'wsrep_cluster_status';
INSERT INTO t1 VALUES (2, 'a'); # Nodes 1 and 2 should successfully apply this
--connection node_3
SET SESSION wsrep_sync_wait=0;
--let $wait_condition = SELECT VARIABLE_VALUE = 'Disconnected' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
SET SESSION wsrep_on=OFF;
--source include/restart_mysqld.inc
--source include/wait_wsrep_ready.inc
SET SESSION wsrep_on=ON;
INSERT INTO t1 VALUES (3, 'a'); # All nodes should successfully apply this
# Check that consistency is restored
--connection node_1
SHOW CREATE TABLE t1;
SELECT * FROM t1;
--connection node_2
SHOW CREATE TABLE t1;
SELECT * FROM t1;
--connection node_3
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
--connection node_1
CALL mtr.add_suppression("Replica SQL: Column 1 of table 'test.t1' cannot be converted from type 'longblob' to type 'blob', Error_code: MY-013146");
CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 3, seqno");
--connection node_2
CALL mtr.add_suppression("Replica SQL: Column 1 of table 'test.t1' cannot be converted from type 'longblob' to type 'blob', Error_code: MY-013146");
CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 3, seqno");
--connection node_3
CALL mtr.add_suppression("Vote 0 \\(success\\) on (.*) is inconsistent with group. Leaving cluster.");
CALL mtr.add_suppression("Plugin 'InnoDB' will be forced to shutdown");

View file

@ -0,0 +1,105 @@
CREATE TABLE t1 (
c1 INT PRIMARY KEY,
c2 VARCHAR(50),
c3 VARCHAR(50),
c4 VARCHAR(50))ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 'AAA_2', 'AAA_3', 'AAA_4'),
(2, 'BBB_2', 'BBB_3', 'BBB_4'),
(3, 'CCC_2', 'CCC_3', 'CCC_4'),
(4, 'DDD_2', 'DDD_3', 'DDD_4'),
(5, 'EEE_2', 'EEE_3', 'EEE_4');
ALTER TABLE t1 CONVERT TO CHARACTER SET 'utf8mb4',ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (c4), ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (c1), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = INPLACE;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = INPLACE;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
n_rows database_name lower(table_name)
5 test t1
CREATE TABLE t2 (
c1 INT PRIMARY KEY,
c2 VARCHAR(50),
c3 VARCHAR(50),
c4 VARCHAR(50)
) ENGINE=InnoDB PARTITION BY RANGE (c1) (
PARTITION p1 VALUES LESS THAN (6),
PARTITION p2 VALUES LESS THAN (11),
PARTITION p3 VALUES LESS THAN (16),
PARTITION p4 VALUES LESS THAN (21)
);
INSERT INTO t2 VALUES(1, 'AAA_2', 'AAA_3', 'AAA_4'),
(2, 'BBB_2', 'BBB_3', 'BBB_4'),
(3, 'CCC_2', 'CCC_3', 'CCC_4'),
(4, 'DDD_2', 'DDD_3', 'DDD_4'),
(5, 'EEE_2', 'EEE_3', 'EEE_4'),
(6, 'FFF_2', 'DDD_3', 'DDD_4'),
(7, 'GGG_2', 'DDD_3', 'DDD_4'),
(8, 'HHH_2', 'DDD_3', 'DDD_4'),
(9, 'III_2', 'DDD_3', 'DDD_4'),
(10, 'JJJ_2', 'DDD_3', 'DDD_4'),
(13, 'KKK_2', 'DDD_3', 'DDD_4'),
(20, 'LLL_2', 'DDD_3', 'DDD_4');
ALTER TABLE t2 CONVERT TO CHARACTER SET 'utf8mb4',ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
n_rows database_name lower(table_name)
5 test t2#p#p1
5 test t2#p#p2
1 test t2#p#p3
1 test t2#p#p4
ALTER TABLE t2 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
n_rows database_name lower(table_name)
5 test t2#p#p1
5 test t2#p#p2
1 test t2#p#p3
1 test t2#p#p4
ALTER TABLE t2 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
n_rows database_name lower(table_name)
5 test t2#p#p1
5 test t2#p#p2
1 test t2#p#p3
1 test t2#p#p4
# Test Cleanup.
DROP TABLE t1;
DROP TABLE t2;

View file

@ -117,8 +117,9 @@ ALTER TABLE t1 FORCE, ALGORITHM=COPY;
connection default; connection default;
SET DEBUG_SYNC='now WAIT_FOR blocked'; SET DEBUG_SYNC='now WAIT_FOR blocked';
BEGIN; BEGIN;
SELECT * FROM mysql.innodb_table_stats FOR UPDATE; SELECT database_name, table_name FROM mysql.innodb_table_stats FOR UPDATE;
database_name table_name last_update n_rows clustered_index_size sum_of_other_index_sizes database_name table_name
test t1
SET DEBUG_SYNC='now SIGNAL go'; SET DEBUG_SYNC='now SIGNAL go';
connection con1; connection con1;
connection default; connection default;

View file

@ -6,7 +6,7 @@ SET @old_debug_dbug = @@global.debug_dbug;
XA START 'a'; XA START 'a';
INSERT INTO mysql.innodb_index_stats SELECT '','' AS table_name,index_name,LAST_UPDATE,stat_name,0 AS stat_value,sample_size,stat_description FROM mysql.innodb_index_stats WHERE table_name='dummy' FOR UPDATE; INSERT INTO mysql.innodb_index_stats SELECT '','' AS table_name,index_name,LAST_UPDATE,stat_name,0 AS stat_value,sample_size,stat_description FROM mysql.innodb_index_stats WHERE table_name='dummy' FOR UPDATE;
SET GLOBAL debug_dbug = "+d,dict_stats_save_exit_notify"; SET GLOBAL debug_dbug = "+d,dict_stats_save_exit_notify";
INSERT INTO t VALUES (1); INSERT INTO t VALUES (1), (2);
XA END 'a'; XA END 'a';
XA PREPARE 'a'; XA PREPARE 'a';
SET DEBUG_SYNC="now WAIT_FOR dict_stats_save_finished"; SET DEBUG_SYNC="now WAIT_FOR dict_stats_save_finished";

View file

@ -0,0 +1,90 @@
--source include/have_innodb.inc
--source include/have_partition.inc
CREATE TABLE t1 (
c1 INT PRIMARY KEY,
c2 VARCHAR(50),
c3 VARCHAR(50),
c4 VARCHAR(50))ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 'AAA_2', 'AAA_3', 'AAA_4'),
(2, 'BBB_2', 'BBB_3', 'BBB_4'),
(3, 'CCC_2', 'CCC_3', 'CCC_4'),
(4, 'DDD_2', 'DDD_3', 'DDD_4'),
(5, 'EEE_2', 'EEE_3', 'EEE_4');
ALTER TABLE t1 CONVERT TO CHARACTER SET 'utf8mb4',ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (c4), ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 DROP PRIMARY KEY, ADD PRIMARY KEY (c1), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 ADD COLUMN c5 VARCHAR(15), ALGORITHM = INPLACE;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
ALTER TABLE t1 DROP COLUMN c5, ALGORITHM = INPLACE;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name IN ('t1');
CREATE TABLE t2 (
c1 INT PRIMARY KEY,
c2 VARCHAR(50),
c3 VARCHAR(50),
c4 VARCHAR(50)
) ENGINE=InnoDB PARTITION BY RANGE (c1) (
PARTITION p1 VALUES LESS THAN (6),
PARTITION p2 VALUES LESS THAN (11),
PARTITION p3 VALUES LESS THAN (16),
PARTITION p4 VALUES LESS THAN (21)
);
INSERT INTO t2 VALUES(1, 'AAA_2', 'AAA_3', 'AAA_4'),
(2, 'BBB_2', 'BBB_3', 'BBB_4'),
(3, 'CCC_2', 'CCC_3', 'CCC_4'),
(4, 'DDD_2', 'DDD_3', 'DDD_4'),
(5, 'EEE_2', 'EEE_3', 'EEE_4'),
(6, 'FFF_2', 'DDD_3', 'DDD_4'),
(7, 'GGG_2', 'DDD_3', 'DDD_4'),
(8, 'HHH_2', 'DDD_3', 'DDD_4'),
(9, 'III_2', 'DDD_3', 'DDD_4'),
(10, 'JJJ_2', 'DDD_3', 'DDD_4'),
(13, 'KKK_2', 'DDD_3', 'DDD_4'),
(20, 'LLL_2', 'DDD_3', 'DDD_4');
ALTER TABLE t2 CONVERT TO CHARACTER SET 'utf8mb4',ALGORITHM=COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
ALTER TABLE t2 ADD COLUMN c5 VARCHAR(15), ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
ALTER TABLE t2 DROP COLUMN c5, ALGORITHM = COPY;
SELECT n_rows, database_name, lower(table_name)
FROM mysql.innodb_table_stats WHERE table_name LIKE '%t2%';
--echo # Test Cleanup.
DROP TABLE t1;
DROP TABLE t2;

View file

@ -156,7 +156,7 @@ ALTER TABLE t1 FORCE, ALGORITHM=COPY;
connection default; connection default;
SET DEBUG_SYNC='now WAIT_FOR blocked'; SET DEBUG_SYNC='now WAIT_FOR blocked';
BEGIN; BEGIN;
SELECT * FROM mysql.innodb_table_stats FOR UPDATE; SELECT database_name, table_name FROM mysql.innodb_table_stats FOR UPDATE;
SET DEBUG_SYNC='now SIGNAL go'; SET DEBUG_SYNC='now SIGNAL go';
connection con1; connection con1;

View file

@ -20,7 +20,7 @@ SET @old_debug_dbug = @@global.debug_dbug;
XA START 'a'; XA START 'a';
INSERT INTO mysql.innodb_index_stats SELECT '','' AS table_name,index_name,LAST_UPDATE,stat_name,0 AS stat_value,sample_size,stat_description FROM mysql.innodb_index_stats WHERE table_name='dummy' FOR UPDATE; # Note the SELECT is empty INSERT INTO mysql.innodb_index_stats SELECT '','' AS table_name,index_name,LAST_UPDATE,stat_name,0 AS stat_value,sample_size,stat_description FROM mysql.innodb_index_stats WHERE table_name='dummy' FOR UPDATE; # Note the SELECT is empty
SET GLOBAL debug_dbug = "+d,dict_stats_save_exit_notify"; SET GLOBAL debug_dbug = "+d,dict_stats_save_exit_notify";
INSERT INTO t VALUES (1); INSERT INTO t VALUES (1), (2);
XA END 'a'; XA END 'a';
XA PREPARE 'a'; XA PREPARE 'a';

View file

@ -313,4 +313,37 @@ insert v1 values (default);
ERROR HY000: The target table v1 of the INSERT is not insertable-into ERROR HY000: The target table v1 of the INSERT is not insertable-into
drop view v1; drop view v1;
drop table t1; drop table t1;
#
# MDEV-37172 Server crashes in Item_func_nextval::update_table after
# INSERT to the table, that uses expression with nextval() as default
#
create sequence s1;
create sequence s2;
create table t1 (id int default(nextval(s1)));
create table t2 (id int default(nextval(s1)+nextval(s1)));
create table t3 (id1 int default(nextval(s1)+nextval(s1)),
id2 int default(nextval(s2)));
insert t1 values ();
select lastval(s1);
lastval(s1)
1
select * from t1;
id
1
insert t2 values ();
select lastval(s1);
lastval(s1)
3
select * from t2;
id
5
insert t3 values ();
select lastval(s1), lastval(s2);
lastval(s1) lastval(s2)
5 1
select * from t3;
id1 id2
9 1
drop table t1,t2,t3;
drop sequence s1,s2;
# End of 10.6 tests # End of 10.6 tests

View file

@ -240,4 +240,27 @@ insert v1 values (default);
drop view v1; drop view v1;
drop table t1; drop table t1;
--echo #
--echo # MDEV-37172 Server crashes in Item_func_nextval::update_table after
--echo # INSERT to the table, that uses expression with nextval() as default
--echo #
create sequence s1;
create sequence s2;
create table t1 (id int default(nextval(s1)));
create table t2 (id int default(nextval(s1)+nextval(s1)));
create table t3 (id1 int default(nextval(s1)+nextval(s1)),
id2 int default(nextval(s2)));
insert t1 values ();
select lastval(s1);
select * from t1;
insert t2 values ();
select lastval(s1);
select * from t2;
insert t3 values ();
select lastval(s1), lastval(s2);
select * from t3;
drop table t1,t2,t3;
drop sequence s1,s2;
--echo # End of 10.6 tests --echo # End of 10.6 tests

View file

@ -63,6 +63,8 @@ void* my_once_alloc(size_t Size, myf MyFlags)
return((uchar*) 0); return((uchar*) 0);
} }
DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size)); DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size));
my_once_allocated+= get_size;
update_malloc_size(get_size, 0);
next->next= 0; next->next= 0;
next->size= get_size; next->size= get_size;
next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM));
@ -113,7 +115,9 @@ void my_once_free(void)
old=next; next= next->next ; old=next; next= next->next ;
free((uchar*) old); free((uchar*) old);
} }
update_malloc_size(- (longlong) my_once_allocated, 0);
my_once_root_block=0; my_once_root_block=0;
my_once_allocated= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} /* my_once_free */ } /* my_once_free */

View file

@ -94,6 +94,7 @@ const char *soundex_map= "01230120022455012623010202";
/* from my_malloc */ /* from my_malloc */
USED_MEM* my_once_root_block=0; /* pointer to first block */ USED_MEM* my_once_root_block=0; /* pointer to first block */
uint my_once_extra=ONCE_ALLOC_INIT; /* Memory to alloc / block */ uint my_once_extra=ONCE_ALLOC_INIT; /* Memory to alloc / block */
size_t my_once_allocated= 0;
/* from my_alarm */ /* from my_alarm */
int volatile my_have_got_alarm=0; /* declare variable to reset */ int volatile my_have_got_alarm=0; /* declare variable to reset */

View file

@ -40,6 +40,7 @@ extern const char *soundex_map;
extern USED_MEM* my_once_root_block; extern USED_MEM* my_once_root_block;
extern uint my_once_extra; extern uint my_once_extra;
extern size_t my_once_allocated;
extern struct st_my_file_info my_file_info_default[MY_NFILE]; extern struct st_my_file_info my_file_info_default[MY_NFILE];

View file

@ -1071,7 +1071,10 @@ enum enum_schema_tables
SCH_TABLE_PRIVILEGES, SCH_TABLE_PRIVILEGES,
SCH_TRIGGERS, SCH_TRIGGERS,
SCH_USER_PRIVILEGES, SCH_USER_PRIVILEGES,
SCH_VIEWS SCH_VIEWS,
SCH_N_SERVER_TABLES, /* How many SCHEMA tables in the server. */
SCH_PLUGIN_TABLE /* Schema table defined in plugin. */
}; };
struct TABLE_SHARE; struct TABLE_SHARE;

View file

@ -4996,11 +4996,12 @@ bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_CSTRING *db,
static TABLE_LIST *internal_table_exists(TABLE_LIST *global_list, static TABLE_LIST *internal_table_exists(TABLE_LIST *global_list,
const char *table_name) TABLE_LIST *table)
{ {
do do
{ {
if (global_list->table_name.str == table_name) if (global_list->table_name.str == table->table_name.str &&
global_list->db.str == table->db.str)
return global_list; return global_list;
} while ((global_list= global_list->next_global)); } while ((global_list= global_list->next_global));
return 0; return 0;
@ -5021,8 +5022,7 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx,
/* /*
Skip table if already in the list. Can happen with prepared statements Skip table if already in the list. Can happen with prepared statements
*/ */
if ((tmp= internal_table_exists(global_table_list, if ((tmp= internal_table_exists(global_table_list, tables)))
tables->table_name.str)))
{ {
/* /*
Use the original value for the next local, used by the Use the original value for the next local, used by the

View file

@ -8418,8 +8418,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
} }
} }
} }
/* Store the table reference preceding the current one. */ /* Store the table reference preceding the current in previous_table_ref */
TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */ TABLE_LIST *UNINIT_VAR(previous_table_ref);
if (table_list.elements > 0 && likely(!ptr->sequence)) if (table_list.elements > 0 && likely(!ptr->sequence))
{ {
/* /*

View file

@ -4370,6 +4370,12 @@ bool get_lookup_field_values(THD *thd, COND *cond, bool fix_table_name_case,
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table) enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table)
{ {
if (schema_table < schema_tables ||
schema_table > &schema_tables[SCH_N_SERVER_TABLES])
{
return SCH_PLUGIN_TABLE;
}
return (enum enum_schema_tables) (schema_table - &schema_tables[0]); return (enum enum_schema_tables) (schema_table - &schema_tables[0]);
} }

View file

@ -3938,6 +3938,7 @@ unpack_vcol_info_from_frm(THD *thd, TABLE *table,
LEX *old_lex= thd->lex; LEX *old_lex= thd->lex;
LEX lex; LEX lex;
bool error; bool error;
TABLE_LIST *sequence, *last;
DBUG_ENTER("unpack_vcol_info_from_frm"); DBUG_ENTER("unpack_vcol_info_from_frm");
DBUG_ASSERT(vcol->expr == NULL); DBUG_ASSERT(vcol->expr == NULL);
@ -3955,11 +3956,12 @@ unpack_vcol_info_from_frm(THD *thd, TABLE *table,
if (unlikely(error)) if (unlikely(error))
goto end; goto end;
if (lex.current_select->table_list.first[0].next_global) if ((sequence= lex.current_select->table_list.first[0].next_global))
{ {
/* We are using NEXT VALUE FOR sequence. Remember table name for open */ /* We are using NEXT VALUE FOR sequence. Remember table for open */
TABLE_LIST *sequence= lex.current_select->table_list.first[0].next_global; for (last= sequence ; last->next_global ; last= last->next_global)
sequence->next_global= table->internal_tables; ;
last->next_global= table->internal_tables;
table->internal_tables= sequence; table->internal_tables= sequence;
} }

View file

@ -83,9 +83,35 @@ wsrep_get_apply_format(THD* thd)
return thd->wsrep_rgi->rli->relay_log.description_event_for_exec; return thd->wsrep_rgi->rli->relay_log.description_event_for_exec;
} }
void wsrep_store_error(const THD* const thd, /* store error from rli */
wsrep::mutable_buffer& dst, static void wsrep_store_error_rli(const THD* const thd,
bool const include_msg) wsrep::mutable_buffer& dst,
bool const include_msg)
{
Slave_reporting_capability* const rli= thd->wsrep_rgi->rli;
if (rli && rli->last_error().number != 0)
{
auto error= rli->last_error();
std::ostringstream os;
if (include_msg)
{
os << error.message << ",";
}
os << " Error_code: " << error.number << ';';
std::string const err_str= os.str();
dst.resize(err_str.length() + 1);
sprintf(dst.data(), "%s", err_str.c_str());
WSREP_DEBUG("Error buffer (RLI) for thd %u seqno %lld, %zu bytes: '%s'",
thd->thread_id, (long long)wsrep_thd_trx_seqno(thd),
dst.size(), dst.size() ? dst.data() : "(null)");
}
}
/* store error from diagnostic area */
static void wsrep_store_error_da(const THD* const thd,
wsrep::mutable_buffer& dst,
bool const include_msg)
{ {
Diagnostics_area::Sql_condition_iterator it= Diagnostics_area::Sql_condition_iterator it=
thd->get_stmt_da()->sql_conditions(); thd->get_stmt_da()->sql_conditions();
@ -123,11 +149,35 @@ void wsrep_store_error(const THD* const thd,
dst.resize(slider - dst.data()); dst.resize(slider - dst.data());
WSREP_DEBUG("Error buffer for thd %llu seqno %lld, %zu bytes: '%s'", WSREP_DEBUG("Error buffer (DA) for thd %llu seqno %lld, %zu bytes: '%s'",
thd->thread_id, (long long)wsrep_thd_trx_seqno(thd), thd->thread_id, (long long)wsrep_thd_trx_seqno(thd),
dst.size(), dst.size() ? dst.data() : "(null)"); dst.size(), dst.size() ? dst.data() : "(null)");
} }
/* store error info after applying error */
void wsrep_store_error(const THD* const thd,
wsrep::mutable_buffer& dst,
bool const include_msg)
{
dst.clear();
wsrep_store_error_da(thd, dst, include_msg);
if (dst.size() == 0)
{
wsrep_store_error_rli(thd, dst, include_msg);
}
if (dst.size() == 0)
{
WSREP_WARN("Failed to get apply error description from either "
"Relay_log_info or Diagnostics_area, will use random data.");
DBUG_ASSERT(0);
uintptr_t const n1= reinterpret_cast<uintptr_t>(&dst);
uintptr_t const n2= reinterpret_cast<uintptr_t>(thd);
uintptr_t const data= n1 ^ (n2 < 1);
const char* const data_ptr= reinterpret_cast<const char*>(&data);
dst.push_back(data_ptr, data_ptr + sizeof(data));
}
}
int wsrep_apply_events(THD* thd, int wsrep_apply_events(THD* thd,
Relay_log_info* rli, Relay_log_info* rli,
const void* events_buf, const void* events_buf,

View file

@ -379,7 +379,15 @@ dict_table_schema_check(
return DB_STATS_DO_NOT_EXIST; return DB_STATS_DO_NOT_EXIST;
} }
if (!table->is_readable() || !table->space) { if (!table->is_readable()) {
/* table is not readable */
snprintf(errstr, errstr_sz,
"Table %s is not readable.",
req_schema->table_name_sql);
return DB_ERROR;
}
if (!table->space) {
/* missing tablespace */ /* missing tablespace */
snprintf(errstr, errstr_sz, snprintf(errstr, errstr_sz,
"Tablespace for table %s is missing.", "Tablespace for table %s is missing.",
@ -3714,8 +3722,9 @@ dberr_t dict_stats_rename_table(const char *old_name, const char *new_name,
dict_fs2utf8(old_name, old_db, sizeof old_db, old_table, sizeof old_table); dict_fs2utf8(old_name, old_db, sizeof old_db, old_table, sizeof old_table);
dict_fs2utf8(new_name, new_db, sizeof new_db, new_table, sizeof new_table); dict_fs2utf8(new_name, new_db, sizeof new_db, new_table, sizeof new_table);
if (dict_table_t::is_temporary_name(old_name) || /* Delete the stats only if renaming the table from old table to
dict_table_t::is_temporary_name(new_name)) intermediate table during COPY algorithm */
if (dict_table_t::is_temporary_name(new_name))
{ {
if (dberr_t e= dict_stats_delete_from_table_stats(old_db, old_table, trx)) if (dberr_t e= dict_stats_delete_from_table_stats(old_db, old_table, trx))
return e; return e;

View file

@ -15834,16 +15834,17 @@ ha_innobase::extra(
/* Warning: since it is not sure that MariaDB calls external_lock() /* Warning: since it is not sure that MariaDB calls external_lock()
before calling this function, m_prebuilt->trx can be obsolete! */ before calling this function, m_prebuilt->trx can be obsolete! */
trx_t* trx; trx_t* trx;
THD* thd = ha_thd();
switch (operation) { switch (operation) {
case HA_EXTRA_FLUSH: case HA_EXTRA_FLUSH:
(void)check_trx_exists(ha_thd()); (void)check_trx_exists(thd);
if (m_prebuilt->blob_heap) { if (m_prebuilt->blob_heap) {
row_mysql_prebuilt_free_blob_heap(m_prebuilt); row_mysql_prebuilt_free_blob_heap(m_prebuilt);
} }
break; break;
case HA_EXTRA_RESET_STATE: case HA_EXTRA_RESET_STATE:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
reset_template(); reset_template();
trx->duplicates = 0; trx->duplicates = 0;
stmt_boundary: stmt_boundary:
@ -15852,23 +15853,23 @@ ha_innobase::extra(
trx->bulk_insert &= TRX_DDL_BULK; trx->bulk_insert &= TRX_DDL_BULK;
break; break;
case HA_EXTRA_NO_KEYREAD: case HA_EXTRA_NO_KEYREAD:
(void)check_trx_exists(ha_thd()); (void)check_trx_exists(thd);
m_prebuilt->read_just_key = 0; m_prebuilt->read_just_key = 0;
break; break;
case HA_EXTRA_KEYREAD: case HA_EXTRA_KEYREAD:
(void)check_trx_exists(ha_thd()); (void)check_trx_exists(thd);
m_prebuilt->read_just_key = 1; m_prebuilt->read_just_key = 1;
break; break;
case HA_EXTRA_KEYREAD_PRESERVE_FIELDS: case HA_EXTRA_KEYREAD_PRESERVE_FIELDS:
(void)check_trx_exists(ha_thd()); (void)check_trx_exists(thd);
m_prebuilt->keep_other_fields_on_keyread = 1; m_prebuilt->keep_other_fields_on_keyread = 1;
break; break;
case HA_EXTRA_INSERT_WITH_UPDATE: case HA_EXTRA_INSERT_WITH_UPDATE:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
trx->duplicates |= TRX_DUP_IGNORE; trx->duplicates |= TRX_DUP_IGNORE;
goto stmt_boundary; goto stmt_boundary;
case HA_EXTRA_NO_IGNORE_DUP_KEY: case HA_EXTRA_NO_IGNORE_DUP_KEY:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
trx->duplicates &= ~TRX_DUP_IGNORE; trx->duplicates &= ~TRX_DUP_IGNORE;
if (trx->is_bulk_insert()) { if (trx->is_bulk_insert()) {
/* Allow a subsequent INSERT into an empty table /* Allow a subsequent INSERT into an empty table
@ -15881,11 +15882,11 @@ ha_innobase::extra(
} }
goto stmt_boundary; goto stmt_boundary;
case HA_EXTRA_WRITE_CAN_REPLACE: case HA_EXTRA_WRITE_CAN_REPLACE:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
trx->duplicates |= TRX_DUP_REPLACE; trx->duplicates |= TRX_DUP_REPLACE;
goto stmt_boundary; goto stmt_boundary;
case HA_EXTRA_WRITE_CANNOT_REPLACE: case HA_EXTRA_WRITE_CANNOT_REPLACE:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
trx->duplicates &= ~TRX_DUP_REPLACE; trx->duplicates &= ~TRX_DUP_REPLACE;
if (trx->is_bulk_insert()) { if (trx->is_bulk_insert()) {
/* Allow a subsequent INSERT into an empty table /* Allow a subsequent INSERT into an empty table
@ -15894,7 +15895,7 @@ ha_innobase::extra(
} }
goto stmt_boundary; goto stmt_boundary;
case HA_EXTRA_BEGIN_ALTER_COPY: case HA_EXTRA_BEGIN_ALTER_COPY:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
m_prebuilt->table->skip_alter_undo = 1; m_prebuilt->table->skip_alter_undo = 1;
if (m_prebuilt->table->is_temporary() if (m_prebuilt->table->is_temporary()
|| !m_prebuilt->table->versioned_by_id()) { || !m_prebuilt->table->versioned_by_id()) {
@ -15907,7 +15908,7 @@ ha_innobase::extra(
.first->second.set_versioned(0); .first->second.set_versioned(0);
break; break;
case HA_EXTRA_END_ALTER_COPY: case HA_EXTRA_END_ALTER_COPY:
trx = check_trx_exists(ha_thd()); trx = check_trx_exists(thd);
if (!m_prebuilt->table->skip_alter_undo) { if (!m_prebuilt->table->skip_alter_undo) {
/* This could be invoked inside INSERT...SELECT. /* This could be invoked inside INSERT...SELECT.
We do not want any extra log writes, because We do not want any extra log writes, because
@ -15941,6 +15942,7 @@ ha_innobase::extra(
handler::extra(HA_EXTRA_BEGIN_ALTER_COPY). */ handler::extra(HA_EXTRA_BEGIN_ALTER_COPY). */
log_buffer_flush_to_disk(); log_buffer_flush_to_disk();
} }
alter_stats_rebuild(m_prebuilt->table, thd);
break; break;
case HA_EXTRA_ABORT_ALTER_COPY: case HA_EXTRA_ABORT_ALTER_COPY:
if (m_prebuilt->table->skip_alter_undo) { if (m_prebuilt->table->skip_alter_undo) {
@ -21335,3 +21337,25 @@ void ins_node_t::vers_update_end(row_prebuilt_t *prebuilt, bool history_row)
if (UNIV_LIKELY_NULL(local_heap)) if (UNIV_LIKELY_NULL(local_heap))
mem_heap_free(local_heap); mem_heap_free(local_heap);
} }
/** Adjust the persistent statistics after rebuilding ALTER TABLE.
Remove statistics for dropped indexes, add statistics for created indexes
and rename statistics for renamed indexes.
@param table InnoDB table that was rebuilt by ALTER TABLE
@param thd alter table thread */
void alter_stats_rebuild(dict_table_t *table, THD *thd)
{
DBUG_ENTER("alter_stats_rebuild");
if (!table->space || !table->stats_is_persistent()
|| dict_stats_persistent_storage_check(false) != SCHEMA_OK)
DBUG_VOID_RETURN;
dberr_t ret= dict_stats_update_persistent(table);
if (ret == DB_SUCCESS)
ret= dict_stats_save(table);
if (ret != DB_SUCCESS)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_ALTER_INFO, "Error updating stats for table after"
" table rebuild: %s", ut_strerr(ret));
DBUG_VOID_RETURN;
}

View file

@ -914,3 +914,10 @@ ib_push_frm_error(
@return true if index column length exceeds limit */ @return true if index column length exceeds limit */
MY_ATTRIBUTE((warn_unused_result)) MY_ATTRIBUTE((warn_unused_result))
bool too_big_key_part_length(size_t max_field_len, const KEY& key); bool too_big_key_part_length(size_t max_field_len, const KEY& key);
/** Adjust the persistent statistics after rebuilding ALTER TABLE.
Remove statistics for dropped indexes, add statistics for created indexes
and rename statistics for renamed indexes.
@param table_name Table name in MySQL
@param thd alter table thread */
void alter_stats_rebuild(dict_table_t *table, THD *thd);

View file

@ -11199,7 +11199,7 @@ Remove statistics for dropped indexes, add statistics for created indexes
and rename statistics for renamed indexes. and rename statistics for renamed indexes.
@param ha_alter_info Data used during in-place alter @param ha_alter_info Data used during in-place alter
@param ctx In-place ALTER TABLE context @param ctx In-place ALTER TABLE context
@param thd MySQL connection @param thd alter table thread
*/ */
static static
void void
@ -11231,46 +11231,6 @@ alter_stats_norebuild(
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/** Adjust the persistent statistics after rebuilding ALTER TABLE.
Remove statistics for dropped indexes, add statistics for created indexes
and rename statistics for renamed indexes.
@param table InnoDB table that was rebuilt by ALTER TABLE
@param table_name Table name in MySQL
@param thd MySQL connection
*/
static
void
alter_stats_rebuild(
/*================*/
dict_table_t* table,
const char* table_name,
THD* thd)
{
DBUG_ENTER("alter_stats_rebuild");
if (!table->space || !table->stats_is_persistent()
|| dict_stats_persistent_storage_check(false) != SCHEMA_OK) {
DBUG_VOID_RETURN;
}
dberr_t ret = dict_stats_update_persistent(table);
if (ret == DB_SUCCESS) {
ret = dict_stats_save(table);
}
if (ret != DB_SUCCESS) {
push_warning_printf(
thd,
Sql_condition::WARN_LEVEL_WARN,
ER_ALTER_INFO,
"Error updating stats for table '%s'"
" after table rebuild: %s",
table_name, ut_strerr(ret));
}
DBUG_VOID_RETURN;
}
/** Apply the log for the table rebuild operation. /** Apply the log for the table rebuild operation.
@param[in] ctx Inplace Alter table context @param[in] ctx Inplace Alter table context
@param[in] altered_table MySQL table that is being altered @param[in] altered_table MySQL table that is being altered
@ -11941,9 +11901,7 @@ foreign_fail:
(*pctx); (*pctx);
DBUG_ASSERT(ctx->need_rebuild()); DBUG_ASSERT(ctx->need_rebuild());
alter_stats_rebuild( alter_stats_rebuild(ctx->new_table, m_user_thd);
ctx->new_table, table->s->table_name.str,
m_user_thd);
} }
} else { } else {
for (inplace_alter_handler_ctx** pctx = ctx_array; for (inplace_alter_handler_ctx** pctx = ctx_array;

View file

@ -2691,9 +2691,8 @@ all_done:
ut_ad((mrec == NULL) == (index->online_log->head.bytes == 0)); ut_ad((mrec == NULL) == (index->online_log->head.bytes == 0));
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (index->online_log->head.block && if (next_mrec_end - srv_sort_buf_size
next_mrec_end == index->online_log->head.block == index->online_log->head.block) {
+ srv_sort_buf_size) {
/* If tail.bytes == 0, next_mrec_end can also be at /* If tail.bytes == 0, next_mrec_end can also be at
the end of tail.block. */ the end of tail.block. */
if (index->online_log->tail.bytes == 0) { if (index->online_log->tail.bytes == 0) {
@ -2707,9 +2706,8 @@ all_done:
ut_ad(index->online_log->tail.blocks ut_ad(index->online_log->tail.blocks
> index->online_log->head.blocks); > index->online_log->head.blocks);
} }
} else if (index->online_log->tail.block && } else if (next_mrec_end - index->online_log->tail.bytes
next_mrec_end == index->online_log->tail.block == index->online_log->tail.block) {
+ index->online_log->tail.bytes) {
ut_ad(next_mrec == index->online_log->tail.block ut_ad(next_mrec == index->online_log->tail.block
+ index->online_log->head.bytes); + index->online_log->head.bytes);
ut_ad(index->online_log->tail.blocks == 0); ut_ad(index->online_log->tail.blocks == 0);
@ -2810,7 +2808,7 @@ process_next_block:
} else { } else {
memcpy(index->online_log->head.buf, mrec, memcpy(index->online_log->head.buf, mrec,
ulint(mrec_end - mrec)); ulint(mrec_end - mrec));
mrec_end += ulint(index->online_log->head.buf - mrec); mrec_end -= ulint(mrec - index->online_log->head.buf);
mrec = index->online_log->head.buf; mrec = index->online_log->head.buf;
goto process_next_block; goto process_next_block;
} }
@ -3603,8 +3601,8 @@ all_done:
ut_ad((mrec == NULL) == (index->online_log->head.bytes == 0)); ut_ad((mrec == NULL) == (index->online_log->head.bytes == 0));
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (next_mrec_end == index->online_log->head.block if (next_mrec_end - srv_sort_buf_size
+ srv_sort_buf_size) { == index->online_log->head.block) {
/* If tail.bytes == 0, next_mrec_end can also be at /* If tail.bytes == 0, next_mrec_end can also be at
the end of tail.block. */ the end of tail.block. */
if (index->online_log->tail.bytes == 0) { if (index->online_log->tail.bytes == 0) {
@ -3618,8 +3616,8 @@ all_done:
ut_ad(index->online_log->tail.blocks ut_ad(index->online_log->tail.blocks
> index->online_log->head.blocks); > index->online_log->head.blocks);
} }
} else if (next_mrec_end == index->online_log->tail.block } else if (next_mrec_end - index->online_log->tail.bytes
+ index->online_log->tail.bytes) { == index->online_log->tail.block) {
ut_ad(next_mrec == index->online_log->tail.block ut_ad(next_mrec == index->online_log->tail.block
+ index->online_log->head.bytes); + index->online_log->head.bytes);
ut_ad(index->online_log->tail.blocks == 0); ut_ad(index->online_log->tail.blocks == 0);
@ -3702,7 +3700,7 @@ process_next_block:
} else { } else {
memcpy(index->online_log->head.buf, mrec, memcpy(index->online_log->head.buf, mrec,
ulint(mrec_end - mrec)); ulint(mrec_end - mrec));
mrec_end += ulint(index->online_log->head.buf - mrec); mrec_end -= ulint(mrec - index->online_log->head.buf);
mrec = index->online_log->head.buf; mrec = index->online_log->head.buf;
goto process_next_block; goto process_next_block;
} }