1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00

Merge 10.0 -> 10.1

This commit is contained in:
Kristian Nielsen
2015-04-20 13:21:58 +02:00
41 changed files with 1196 additions and 156 deletions

View File

@@ -0,0 +1,57 @@
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
SET @old_count= @@GLOBAL.binlog_commit_wait_count;
SET GLOBAL binlog_commit_wait_count= 3;
SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
SET GLOBAL binlog_commit_wait_usec= 20000000;
SET @a= current_timestamp();
BEGIN;
INSERT INTO t1 VALUES (1,0);
COMMIT;
INSERT INTO t1 VALUES (1,1);
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
Ok
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
SET @a= current_timestamp();
INSERT INTO t1 VALUES (2,0);
INSERT INTO t1 VALUES (3,0);
INSERT INTO t1 VALUES (4,0);
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
Ok
SET @a= current_timestamp();
INSERT INTO t1 VALUES (6,0);
BEGIN;
UPDATE t1 SET b=b+1 WHERE a=1;
UPDATE t1 SET b=b+10 WHERE a=1;
SELECT SLEEP(0.25);
SLEEP(0.25)
0
UPDATE t1 SET b=b+1 WHERE a=3;
COMMIT;
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
Ok
SET @a= current_timestamp();
INSERT INTO t1 VALUES (7,0);
INSERT INTO t1 VALUES (8,0);
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"))
Ok
SELECT * FROM t1 ORDER BY a;
a b
1 11
2 0
3 1
4 0
6 0
7 0
8 0
DROP TABLE t1;
SET GLOBAL binlog_commit_wait_count= @old_count;
SET GLOBAL binlog_commit_wait_usec= @old_usec;

View File

@@ -0,0 +1,123 @@
--source include/have_innodb.inc
--source include/have_log_bin.inc
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
SET @old_count= @@GLOBAL.binlog_commit_wait_count;
SET GLOBAL binlog_commit_wait_count= 3;
SET @old_usec= @@GLOBAL.binlog_commit_wait_usec;
SET GLOBAL binlog_commit_wait_usec= 20000000;
connect(con1,localhost,root,,test);
connect(con2,localhost,root,,test);
connect(con3,localhost,root,,test);
# Check that if T2 goes to wait for a row lock of T1 while T1 is waiting for
# more transactions to arrive for group commit, the commit of T1 will complete
# immediately.
# We test this by setting a very high timeout (20 seconds), and testing that
# that much time does not elapse.
--connection default
SET @a= current_timestamp();
--connection con1
BEGIN;
INSERT INTO t1 VALUES (1,0);
send COMMIT;
--connection con2
send INSERT INTO t1 VALUES (1,1);
--connection con1
reap;
--connection default
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
--connection con2
--error ER_DUP_ENTRY
reap;
# Test that the commit triggers when sufficient commits have queued up.
--connection default
SET @a= current_timestamp();
--connection con1
send INSERT INTO t1 VALUES (2,0);
--connection con2
send INSERT INTO t1 VALUES (3,0);
--connection con3
INSERT INTO t1 VALUES (4,0);
--connection con1
reap;
--connection con2
reap;
--connection default
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
# Test that commit triggers immediately if there is already a transaction
# waiting on another transaction that reaches its commit.
--connection default
SET @a= current_timestamp();
--connection con1
send INSERT INTO t1 VALUES (6,0);
--connection con2
BEGIN;
UPDATE t1 SET b=b+1 WHERE a=1;
--connection con3
send UPDATE t1 SET b=b+10 WHERE a=1;
--connection con2
# A small sleep to let con3 have time to wait on con2.
# The sleep might be too small on loaded host, but that is not a big problem;
# it only means we will trigger a different code path (con3 waits after con2
# is ready to commit rather than before); and either path should work the same.
# So we will not get false positive in case of different timing; at worst false
# negative.
SELECT SLEEP(0.25);
UPDATE t1 SET b=b+1 WHERE a=3;
COMMIT;
--connection con1
reap;
--connection default
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
--connection default
SET @a= current_timestamp();
# Now con3 will be waiting for a following group commit to trigger.
--connection con1
send INSERT INTO t1 VALUES (7,0);
--connection con2
INSERT INTO t1 VALUES (8,0);
--connection con3
reap;
--connection default
SET @b= unix_timestamp(current_timestamp()) - unix_timestamp(@a);
SELECT IF(@b < 20, "Ok", CONCAT("Error: too much time elapsed: ", @b, " seconds >= 20"));
--connection default
SELECT * FROM t1 ORDER BY a;
--connection default
DROP TABLE t1;
SET GLOBAL binlog_commit_wait_count= @old_count;
SET GLOBAL binlog_commit_wait_usec= @old_usec;

View File

@@ -0,0 +1,7 @@
call mtr.add_suppression("Resizing redo log from *");
call mtr.add_suppression("Starting to delete and rewrite log files.");
call mtr.add_suppression("New log files created, LSN=*");
create table foo (id varchar(37) not null, content longblob) engine=INNODB;
insert into foo (id, content) values('xyz', '');
update foo set content=repeat('a', 43941888) where id='xyz';
drop table foo;

View File

@@ -0,0 +1,322 @@
CREATE TABLE IF NOT EXISTS gso_grad_supr (
term char(4) NOT NULL DEFAULT '',
uw_id int(8) UNSIGNED NOT NULL DEFAULT 0,
plan varchar(10) NOT NULL DEFAULT '',
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
admit_term char(4) NOT NULL DEFAULT '',
CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `gso_grad_supr` VALUES ('1031',2,'CSM','','1009');
INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009');
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
drop table grad_degree;
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
ofis_deg_status2 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress2'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2'
ELSE 'Not Completed2'
END) VIRTUAL,
ofis_deg_status3 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress3'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3'
ELSE 'Not Completed3'
END) VIRTUAL,
ofis_deg_status4 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress4'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4'
ELSE 'Not Completed4'
END) VIRTUAL,
ofis_deg_status5 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress5'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5'
ELSE 'Not Completed5'
END) VIRTUAL,
ofis_deg_status6 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress6'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6'
ELSE 'Not Completed6'
END) VIRTUAL,
ofis_deg_status7 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress7'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7'
ELSE 'Not Completed7'
END) VIRTUAL,
ofis_deg_status8 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress8'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8'
ELSE 'Not Completed8'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
ALTER TABLE grad_degree DROP INDEX grad_degree_wdraw_rsn_ndx;
ALTER TABLE grad_degree DROP COLUMN deg_start_term;
SHOW CREATE TABLE grad_degree;
Table Create Table
grad_degree CREATE TABLE `grad_degree` (
`student_id` int(8) unsigned NOT NULL,
`plan` varchar(10) NOT NULL,
`admit_term` char(4) NOT NULL,
`wdraw_rsn` varchar(4) NOT NULL DEFAULT '',
`ofis_deg_status` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
`ofis_deg_status2` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress2'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2'
ELSE 'Not Completed2'
END) VIRTUAL,
`ofis_deg_status3` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress3'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3'
ELSE 'Not Completed3'
END) VIRTUAL,
`ofis_deg_status4` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress4'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4'
ELSE 'Not Completed4'
END) VIRTUAL,
`ofis_deg_status5` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress5'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5'
ELSE 'Not Completed5'
END) VIRTUAL,
`ofis_deg_status6` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress6'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6'
ELSE 'Not Completed6'
END) VIRTUAL,
`ofis_deg_status7` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress7'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7'
ELSE 'Not Completed7'
END) VIRTUAL,
`ofis_deg_status8` varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress8'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8'
ELSE 'Not Completed8'
END) VIRTUAL,
`deg_as_of_term` char(4) NOT NULL COMMENT 'In most cases also end term',
PRIMARY KEY (`student_id`,`plan`,`admit_term`),
KEY `grad_degree_as_of_term_ndx` (`deg_as_of_term`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
DROP TABLE grad_degree;
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
ofis_deg_status2 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress2'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2'
ELSE 'Not Completed2'
END) VIRTUAL,
ofis_deg_status3 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress3'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3'
ELSE 'Not Completed3'
END) VIRTUAL,
ofis_deg_status4 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress4'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4'
ELSE 'Not Completed4'
END) VIRTUAL,
ofis_deg_status5 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress5'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5'
ELSE 'Not Completed5'
END) VIRTUAL,
ofis_deg_status6 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress6'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6'
ELSE 'Not Completed6'
END) VIRTUAL,
ofis_deg_status7 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress7'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7'
ELSE 'Not Completed7'
END) VIRTUAL,
ofis_deg_status8 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress8'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8'
ELSE 'Not Completed8'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
ALTER TABLE grad_degree DROP COLUMN ofis_deg_status2, DROP COLUMN ofis_deg_status3,
DROP COLUMN ofis_deg_status4, DROP COLUMN ofis_deg_status5, DROP COLUMN ofis_deg_status6,
DROP COLUMN ofis_deg_status7, DROP COLUMN ofis_deg_status8;
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
select * from grad_degree;
student_id plan admit_term wdraw_rsn ofis_deg_status deg_start_term deg_as_of_term
2 CSM 1009 ACAD Not Completed 1009 1035
select * from gso_grad_supr;
term uw_id plan wdraw_rsn admit_term
1031 2 CSM 1009
1035 2 CSM ACAD 1009
drop table grad_degree;
drop table gso_grad_supr;

View File

@@ -0,0 +1,17 @@
xa rollback 'xid2';
ERROR XAE04: XAER_NOTA: Unknown XID
drop table if exists t1;
Warnings:
Note 1051 Unknown table 'test.t1'
create table t1(a int)engine=innodb;
rollback;
xa start 'xid2';
insert into `t1` values (1);
savepoint `sv1`;
xa end 'xid2';
start transaction;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
xa prepare 'xid2';
release savepoint `sv1`;
xa commit 'xid2';
drop table t1;

View File

@@ -0,0 +1,2 @@
--max-allowed-packet=128M
--innodb-log-file-size=210M

View File

@@ -0,0 +1,20 @@
-- source include/have_innodb.inc
-- source include/big_test.inc
-- source include/not_embedded.inc
--disable_query_log
let $status_orig=`SELECT @@innodb_status_output`;
--enable_query_log
call mtr.add_suppression("Resizing redo log from *");
call mtr.add_suppression("Starting to delete and rewrite log files.");
call mtr.add_suppression("New log files created, LSN=*");
create table foo (id varchar(37) not null, content longblob) engine=INNODB;
insert into foo (id, content) values('xyz', '');
update foo set content=repeat('a', 43941888) where id='xyz';
drop table foo;
--disable_query_log
EVAL SET GLOBAL innodb_status_output = $status_orig;
--enable_query_log

View File

@@ -0,0 +1,302 @@
--source include/have_innodb.inc
#
# MDEV-7367: Updating a virtual column corrupts table which crashes server
# MySQL table columns contains virtual columns but InnoDB table
# definition does not.
#
CREATE TABLE IF NOT EXISTS gso_grad_supr (
term char(4) NOT NULL DEFAULT '',
uw_id int(8) UNSIGNED NOT NULL DEFAULT 0,
plan varchar(10) NOT NULL DEFAULT '',
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
admit_term char(4) NOT NULL DEFAULT '',
CONSTRAINT gso_grad_supr_pky PRIMARY KEY (uw_id, term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `gso_grad_supr` VALUES ('1031',2,'CSM','','1009');
INSERT INTO `gso_grad_supr` VALUES ('1035',2,'CSM','ACAD','1009');
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
drop table grad_degree;
#
# Test with more virtual columns so that MySQL table has
# more columns than InnoDB and index definition is out
# of number of actual InnoDB columns.
#
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
ofis_deg_status2 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress2'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2'
ELSE 'Not Completed2'
END) VIRTUAL,
ofis_deg_status3 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress3'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3'
ELSE 'Not Completed3'
END) VIRTUAL,
ofis_deg_status4 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress4'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4'
ELSE 'Not Completed4'
END) VIRTUAL,
ofis_deg_status5 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress5'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5'
ELSE 'Not Completed5'
END) VIRTUAL,
ofis_deg_status6 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress6'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6'
ELSE 'Not Completed6'
END) VIRTUAL,
ofis_deg_status7 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress7'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7'
ELSE 'Not Completed7'
END) VIRTUAL,
ofis_deg_status8 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress8'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8'
ELSE 'Not Completed8'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
#
# Verify that indexes can be dropped
#
ALTER TABLE grad_degree DROP INDEX grad_degree_wdraw_rsn_ndx;
#
# Verify that we can drop columns
#
ALTER TABLE grad_degree DROP COLUMN deg_start_term;
SHOW CREATE TABLE grad_degree;
DROP TABLE grad_degree;
#
# Verify after dropping virtual columns
#
CREATE TABLE IF NOT EXISTS grad_degree (
student_id int(8) UNSIGNED NOT NULL,
plan varchar(10) NOT NULL,
admit_term char(4) NOT NULL,
wdraw_rsn varchar(4) NOT NULL DEFAULT '',
ofis_deg_status varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed'
ELSE 'Not Completed'
END) VIRTUAL,
ofis_deg_status2 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress2'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed2'
ELSE 'Not Completed2'
END) VIRTUAL,
ofis_deg_status3 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress3'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed3'
ELSE 'Not Completed3'
END) VIRTUAL,
ofis_deg_status4 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress4'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed4'
ELSE 'Not Completed4'
END) VIRTUAL,
ofis_deg_status5 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress5'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed5'
ELSE 'Not Completed5'
END) VIRTUAL,
ofis_deg_status6 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress6'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed6'
ELSE 'Not Completed6'
END) VIRTUAL,
ofis_deg_status7 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress7'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed7'
ELSE 'Not Completed7'
END) VIRTUAL,
ofis_deg_status8 varchar(15) AS (
CASE
WHEN wdraw_rsn = '' THEN 'In progress8'
WHEN wdraw_rsn = 'DCMP' OR wdraw_rsn = 'TRDC' THEN 'Completed8'
ELSE 'Not Completed8'
END) VIRTUAL,
deg_start_term char(4) NOT NULL DEFAULT '' COMMENT 'Educated guess at the beginning of the data',
deg_as_of_term char(4) NOT NULL COMMENT 'In most cases also end term',
CONSTRAINT grad_degree_stu_plan_admit_pky PRIMARY KEY (student_id, plan, admit_term)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE INDEX grad_degree_wdraw_rsn_ndx ON grad_degree (wdraw_rsn);
ALTER TABLE grad_degree DROP COLUMN ofis_deg_status2, DROP COLUMN ofis_deg_status3,
DROP COLUMN ofis_deg_status4, DROP COLUMN ofis_deg_status5, DROP COLUMN ofis_deg_status6,
DROP COLUMN ofis_deg_status7, DROP COLUMN ofis_deg_status8;
CREATE INDEX grad_degree_as_of_term_ndx ON grad_degree (deg_as_of_term);
INSERT IGNORE grad_degree (
student_id,
plan,
admit_term,
wdraw_rsn,
deg_start_term,
deg_as_of_term
)
SELECT
ggs.uw_id AS c_student_id,
ggs.plan,
ggs.admit_term,
ggs.wdraw_rsn,
IF( (SELECT COUNT(*) FROM grad_degree AS gd WHERE gd.student_id = ggs.uw_id AND gd.admit_term = ggs.admit_term) > 0, ggs.term, ggs.admit_term ) AS c_deg_start_term,
ggs.term AS c_as_of_term
FROM gso_grad_supr AS ggs
LEFT OUTER JOIN
grad_degree AS gd
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
WHERE
ggs.term = 1031 AND
gd.student_id IS NULL
;
UPDATE grad_degree AS gd
INNER JOIN
gso_grad_supr AS ggs
ON ( gd.student_id = ggs.uw_id AND gd.plan = ggs.plan AND gd.admit_term = ggs.admit_term )
SET
gd.wdraw_rsn = ggs.wdraw_rsn,
gd.deg_as_of_term = 1035
WHERE
gd.wdraw_rsn NOT IN ('DCMP', 'TRDC') AND
ggs.term = 1035
;
select * from grad_degree;
select * from gso_grad_supr;
drop table grad_degree;
drop table gso_grad_supr;

View File

@@ -0,0 +1,17 @@
--source include/have_innodb.inc
--disable_abort_on_error
xa rollback 'xid2';
drop table if exists t1;
create table t1(a int)engine=innodb;
rollback;
xa start 'xid2';
insert into `t1` values (1);
savepoint `sv1`;
xa end 'xid2';
start transaction;
xa prepare 'xid2';
release savepoint `sv1`;
xa commit 'xid2';
drop table t1;

View File

@@ -179,7 +179,7 @@ a
SET sql_log_bin=0;
CALL mtr.add_suppression("Slave: Could not update replication slave gtid state");
SET sql_log_bin=1;
*** MDEV-4906: When event apply fails, next SQL thread start errorneously commits the failing GTID to gtid_slave_pos ***
*** MDEV-4906: When event apply fails, next SQL thread start erroneously commits the failing GTID to gtid_slave_pos ***
include/stop_slave.inc
SET sql_log_bin=0;
DELETE FROM t2;

View File

@@ -39,7 +39,12 @@ sum(n)
show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
*** MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS ***
INSERT INTO t2 VALUES (2000), (2001);
CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
CREATE TEMPORARY TABLE t3 AS SELECT f() AS col FROM t2;
drop table if exists t1,t2;
Warnings:
Note 1051 Unknown table 'test.t1'
drop function f;
include/rpl_end.inc

View File

@@ -550,8 +550,8 @@ SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
--save_master_pos
--connection server_4
SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
--sync_with_master
SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
# Clean up.

View File

@@ -230,7 +230,7 @@ CALL mtr.add_suppression("Slave: Could not update replication slave gtid state")
SET sql_log_bin=1;
--echo *** MDEV-4906: When event apply fails, next SQL thread start errorneously commits the failing GTID to gtid_slave_pos ***
--echo *** MDEV-4906: When event apply fails, next SQL thread start erroneously commits the failing GTID to gtid_slave_pos ***
--connection slave
--source include/stop_slave.inc

View File

@@ -57,12 +57,28 @@ select count(*) from t2;
select sum(n) from t2;
show status like 'Slave_open_temp_tables';
--echo *** MDEV-8016: Replication aborts on DROP /*!40005 TEMPORARY */ TABLE IF EXISTS ***
connect (master2,localhost,root,,);
INSERT INTO t2 VALUES (2000), (2001);
CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
CREATE TEMPORARY TABLE t3 AS SELECT f() AS col FROM t2;
--let $gtid=`SELECT @@gtid_binlog_pos`
--disconnect master2
--connection default
# Wait for implicit DROP TEMPORARY TABLE tmp to be binlogged.
--let $wait_condition= SELECT @@gtid_binlog_pos != '$gtid'
--source include/wait_condition.inc
--sync_slave_with_master
#
# Clean up
#
connect (master2,localhost,root,,);
connection master2;
drop table if exists t1,t2;
drop function f;
sync_slave_with_master;

View File

@@ -1577,7 +1577,10 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans)
}
/* Free resources and perform other cleanup even for 'empty' transactions. */
if (is_real_trans)
{
thd->has_waiter= false;
thd->transaction.cleanup();
}
DBUG_RETURN(error);
}
@@ -1658,7 +1661,10 @@ int ha_rollback_trans(THD *thd, bool all)
/* Always cleanup. Even if nht==0. There may be savepoints. */
if (is_real_trans)
{
thd->has_waiter= false;
thd->transaction.cleanup();
}
if (all)
thd->transaction_rollback_request= FALSE;

View File

@@ -7169,6 +7169,14 @@ MYSQL_BIN_LOG::queue_for_group_commit(group_commit_entry *orig_entry)
}
}
/*
Handle the heuristics that if another transaction is waiting for this
transaction (or if it does so later), then we want to trigger group
commit immediately, without waiting for the binlog_commit_wait_usec
timeout to expire.
*/
entry->thd->waiting_on_group_commit= true;
/* Add the entry to the group commit queue. */
next_entry= entry->next;
entry->next= group_commit_queue;
@@ -7184,7 +7192,7 @@ MYSQL_BIN_LOG::queue_for_group_commit(group_commit_entry *orig_entry)
cur= entry->thd->wait_for_commit_ptr;
}
if (opt_binlog_commit_wait_count > 0)
if (opt_binlog_commit_wait_count > 0 && orig_queue != NULL)
mysql_cond_signal(&COND_prepare_ordered);
mysql_mutex_unlock(&LOCK_prepare_ordered);
DEBUG_SYNC(orig_entry->thd, "commit_after_release_LOCK_prepare_ordered");
@@ -7357,6 +7365,11 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
while (current)
{
group_commit_entry *next= current->next;
/*
Now that group commit is started, we can clear the flag; there is no
longer any use in waiters on this commit trying to trigger it early.
*/
current->thd->waiting_on_group_commit= false;
current->next= queue;
queue= current;
current= next;
@@ -7732,7 +7745,7 @@ MYSQL_BIN_LOG::wait_for_sufficient_commits()
mysql_mutex_assert_owner(&LOCK_prepare_ordered);
for (e= last_head= group_commit_queue, count= 0; e; e= e->next)
if (++count >= opt_binlog_commit_wait_count)
if (++count >= opt_binlog_commit_wait_count || unlikely(e->thd->has_waiter))
return;
mysql_mutex_unlock(&LOCK_log);
@@ -7747,13 +7760,20 @@ MYSQL_BIN_LOG::wait_for_sufficient_commits()
&wait_until);
if (err == ETIMEDOUT)
break;
if (unlikely(last_head->thd->has_waiter))
break;
head= group_commit_queue;
for (e= head; e && e != last_head; e= e->next)
{
++count;
if (unlikely(e->thd->has_waiter))
goto after_loop;
}
if (count >= opt_binlog_commit_wait_count)
break;
last_head= head;
}
after_loop:
/*
We must not wait for LOCK_log while holding LOCK_prepare_ordered.
@@ -7777,6 +7797,42 @@ MYSQL_BIN_LOG::wait_for_sufficient_commits()
}
void
MYSQL_BIN_LOG::binlog_trigger_immediate_group_commit()
{
group_commit_entry *head;
mysql_mutex_lock(&LOCK_prepare_ordered);
head= group_commit_queue;
if (head)
{
head->thd->has_waiter= true;
mysql_cond_signal(&COND_prepare_ordered);
}
mysql_mutex_unlock(&LOCK_prepare_ordered);
}
/*
This function is called when a transaction T1 goes to wait for another
transaction T2. It is used to cut short any binlog group commit delay from
--binlog-commit-wait-count in the case where another transaction is stalled
on the wait due to conflicting row locks.
If T2 is already ready to group commit, any waiting group commit will be
signalled to proceed immediately. Otherwise, a flag will be set in T2, and
when T2 later becomes ready, immediate group commit will be triggered.
*/
void
binlog_report_wait_for(THD *thd1, THD *thd2)
{
if (opt_binlog_commit_wait_count == 0)
return;
thd2->has_waiter= true;
if (thd2->waiting_on_group_commit)
mysql_bin_log.binlog_trigger_immediate_group_commit();
}
/**
Wait until we get a signal that the relay log has been updated.

View File

@@ -695,6 +695,7 @@ public:
void set_max_size(ulong max_size_arg);
void signal_update();
void wait_for_sufficient_commits();
void binlog_trigger_immediate_group_commit();
void wait_for_update_relay_log(THD* thd);
int wait_for_update_bin_log(THD* thd, const struct timespec * timeout);
void init(ulong max_size);
@@ -1071,6 +1072,7 @@ bool general_log_print(THD *thd, enum enum_server_command command,
bool general_log_write(THD *thd, enum enum_server_command command,
const char *query, uint query_length);
void binlog_report_wait_for(THD *thd, THD *other_thd);
void sql_perror(const char *message);
bool flush_error_log();

View File

@@ -1769,7 +1769,7 @@ void rpl_group_info::cleanup_context(THD *thd, bool error)
trans_rollback(thd); // if a "real transaction"
/*
Now that we have rolled back the transaction, make sure we do not
errorneously update the GTID position.
erroneously update the GTID position.
*/
gtid_pending= false;
}

View File

@@ -7078,7 +7078,7 @@ ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
ER_STORED_FUNCTION_PREVENTS_SWITCH_GTID_DOMAIN_ID_SEQ_NO
eng "Cannot modify @@session.gtid_domain_id or @@session.gtid_seq_no inside a stored function or trigger"
ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2
eng "Connecting slave requested to start from GTID %u-%u-%llu, which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged due to executing extra errorneous transactions"
eng "Connecting slave requested to start from GTID %u-%u-%llu, which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged due to executing extra erroneous transactions"
ER_BINLOG_MUST_BE_EMPTY
eng "This operation is not allowed if any GTID has been logged to the binary log. Run RESET MASTER first to erase the log"
ER_NO_SUCH_QUERY

View File

@@ -3337,7 +3337,7 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd,
else
{
/*
Make sure we do not errorneously update gtid_slave_pos with a lingering
Make sure we do not erroneously update gtid_slave_pos with a lingering
GTID from this failed event group (MDEV-4906).
*/
rgi->gtid_pending= false;

View File

@@ -696,6 +696,7 @@ bool close_cached_connection_tables(THD *thd, LEX_STRING *connection)
static void mark_temp_tables_as_free_for_reuse(THD *thd)
{
rpl_group_info *rgi_slave;
DBUG_ENTER("mark_temp_tables_as_free_for_reuse");
if (thd->query_id == 0)
@@ -704,7 +705,9 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd)
DBUG_VOID_RETURN;
}
if (thd->temporary_tables)
rgi_slave=thd->rgi_slave;
if ((!rgi_slave && thd->temporary_tables) ||
(rgi_slave && unlikely(rgi_slave->rli->save_temporary_tables)))
{
thd->lock_temporary_tables();
for (TABLE *table= thd->temporary_tables ; table ; table= table->next)
@@ -713,7 +716,7 @@ static void mark_temp_tables_as_free_for_reuse(THD *thd)
mark_tmp_table_for_reuse(table);
}
thd->unlock_temporary_tables();
if (thd->rgi_slave)
if (rgi_slave)
{
/*
Temporary tables are shared with other by sql execution threads.

View File

@@ -905,6 +905,7 @@ THD::THD(bool is_wsrep_applier)
in_lock_tables(0),
bootstrap(0),
derived_tables_processing(FALSE),
waiting_on_group_commit(FALSE), has_waiter(FALSE),
spcont(NULL),
m_parser_state(NULL),
#if defined(ENABLED_DEBUG_SYNC)
@@ -4508,6 +4509,7 @@ thd_report_wait_for(MYSQL_THD thd, MYSQL_THD other_thd)
thd->transaction.stmt.mark_trans_did_wait();
if (!other_thd)
return;
binlog_report_wait_for(thd, other_thd);
rgi= thd->rgi_slave;
other_rgi= other_thd->rgi_slave;
if (!rgi || !other_rgi)

View File

@@ -2719,6 +2719,18 @@ public:
it returned an error on master, and this is OK on the slave.
*/
bool is_slave_error;
/*
True when a transaction is queued up for binlog group commit.
Used so that if another transaction needs to wait for a row lock held by
this transaction, it can signal to trigger the group commit immediately,
skipping the normal --binlog-commit-wait-count wait.
*/
bool waiting_on_group_commit;
/*
Set true when another transaction goes to wait on a row lock held by this
transaction. Used together with waiting_on_group_commit.
*/
bool has_waiter;
/*
In case of a slave, set to the error code the master got when executing
the query. 0 if no error on the master.

View File

@@ -1013,7 +1013,7 @@ give_error_start_pos_missing_in_binlog(int *err, const char **errormsg,
binlog_gtid.seq_no >= error_gtid->seq_no)
{
*errormsg= "Requested slave GTID state not found in binlog. The slave has "
"probably diverged due to executing errorneous transactions";
"probably diverged due to executing erroneous transactions";
*err= ER_GTID_POSITION_NOT_FOUND_IN_BINLOG2;
}
else
@@ -2908,7 +2908,7 @@ err:
"%u-%u-%llu, which is not in the master's binlog. Since the "
"master's binlog contains GTIDs with higher sequence numbers, "
"it probably means that the slave has diverged due to "
"executing extra errorneous transactions",
"executing extra erroneous transactions",
info->error_gtid.domain_id,
info->error_gtid.server_id,
info->error_gtid.seq_no);

View File

@@ -156,6 +156,8 @@ bool trans_begin(THD *thd, uint flags)
*/
thd->transaction.all.modified_non_trans_table= FALSE;
thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT;
thd->has_waiter= false;
thd->waiting_on_group_commit= false;
if (res)
DBUG_RETURN(TRUE);

View File

@@ -649,6 +649,40 @@ dict_table_get_col_name(
return(s);
}
/**********************************************************************//**
Returns a column's name.
@return column name. NOTE: not guaranteed to stay valid if table is
modified in any way (columns added, etc.). */
UNIV_INTERN
const char*
dict_table_get_col_name_for_mysql(
/*==============================*/
const dict_table_t* table, /*!< in: table */
const char* col_name)/*! in: MySQL table column name */
{
ulint i;
const char* s;
ut_ad(table);
ut_ad(col_name);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
s = table->col_names;
if (s) {
/* If we have many virtual columns MySQL key_part->fieldnr
could be larger than number of columns in InnoDB table
when creating new indexes. */
for (i = 0; i < table->n_def; i++) {
if (!innobase_strcasecmp(s, col_name)) {
break; /* Found */
}
s += strlen(s) + 1;
}
}
return(s);
}
#ifndef UNIV_HOTBACKUP
/********************************************************************//**
Acquire the autoinc lock. */

View File

@@ -4432,7 +4432,10 @@ innobase_release_savepoint(
DBUG_ASSERT(hton == innodb_hton_ptr);
trx = check_trx_exists(thd);
trx_start_if_not_started(trx);
if (trx->state == TRX_STATE_NOT_STARTED) {
trx_start_if_not_started(trx);
}
/* TODO: use provided savepoint data area to store savepoint data */
@@ -5119,6 +5122,8 @@ innobase_match_index_columns(
if (innodb_idx_fld >= innodb_idx_fld_end) {
DBUG_RETURN(FALSE);
}
mtype = innodb_idx_fld->col->mtype;
}
// MariaDB-5.5 compatibility

View File

@@ -1467,8 +1467,9 @@ innobase_create_index_field_def(
if a new clustered index is
not being created */
const KEY_PART_INFO* key_part, /*!< in: MySQL key definition */
index_field_t* index_field) /*!< out: index field
index_field_t* index_field, /*!< out: index field
definition for key_part */
const Field** fields) /*!< in: MySQL table fields */
{
const Field* field;
ibool is_unsigned;
@@ -1485,6 +1486,7 @@ innobase_create_index_field_def(
ut_a(field);
index_field->col_no = key_part->fieldnr;
index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
@@ -1519,8 +1521,9 @@ innobase_create_index_def(
bool key_clustered, /*!< in: true if this is
the new clustered index */
index_def_t* index, /*!< out: index definition */
mem_heap_t* heap) /*!< in: heap where memory
mem_heap_t* heap, /*!< in: heap where memory
is allocated */
const Field** fields) /*!z in: MySQL table fields */
{
const KEY* key = &keys[key_number];
ulint i;
@@ -1533,6 +1536,7 @@ innobase_create_index_def(
index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, n_fields * sizeof *index->fields));
memset(index->fields, 0, n_fields * sizeof *index->fields);
index->ind_type = 0;
index->key_number = key_number;
@@ -1570,7 +1574,7 @@ innobase_create_index_def(
for (i = 0; i < n_fields; i++) {
innobase_create_index_field_def(
altered_table, &key->key_part[i], &index->fields[i]);
altered_table, &key->key_part[i], &index->fields[i], fields);
}
DBUG_VOID_RETURN;
@@ -1901,7 +1905,7 @@ innobase_create_key_defs(
/* Create the PRIMARY key index definition */
innobase_create_index_def(
altered_table, key_info, primary_key_number,
TRUE, TRUE, indexdef++, heap);
TRUE, TRUE, indexdef++, heap, (const Field **)altered_table->field);
created_clustered:
n_add = 1;
@@ -1913,7 +1917,7 @@ created_clustered:
/* Copy the index definitions. */
innobase_create_index_def(
altered_table, key_info, i, TRUE, FALSE,
indexdef, heap);
indexdef, heap, (const Field **)altered_table->field);
if (indexdef->ind_type & DICT_FTS) {
n_fts_add++;
@@ -1958,7 +1962,7 @@ created_clustered:
for (ulint i = 0; i < n_add; i++) {
innobase_create_index_def(
altered_table, key_info, add[i], FALSE, FALSE,
indexdef, heap);
indexdef, heap, (const Field **)altered_table->field);
if (indexdef->ind_type & DICT_FTS) {
n_fts_add++;
@@ -1975,6 +1979,7 @@ created_clustered:
index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, sizeof *index->fields));
memset(index->fields, 0, sizeof *index->fields);
index->n_fields = 1;
index->fields->col_no = fts_doc_id_col;
index->fields->prefix_len = 0;

View File

@@ -613,6 +613,17 @@ dict_table_get_col_name(
ulint col_nr) /*!< in: column number */
__attribute__((nonnull, warn_unused_result));
/**********************************************************************//**
Returns a column's name.
@return column name. NOTE: not guaranteed to stay valid if table is
modified in any way (columns added, etc.). */
UNIV_INTERN
const char*
dict_table_get_col_name_for_mysql(
/*==============================*/
const dict_table_t* table, /*!< in: table */
const char* col_name)/*!< in: MySQL table column name */
__attribute__((nonnull, warn_unused_result));
/**********************************************************************//**
Prints a table data. */
UNIV_INTERN
void

View File

@@ -107,6 +107,7 @@ struct index_field_t {
ulint col_no; /*!< column offset */
ulint prefix_len; /*!< column prefix length, or 0
if indexing the whole column */
const char* col_name; /*!< column name or NULL */
};
/** Definition of an index being created */

View File

@@ -3429,9 +3429,13 @@ row_merge_create_index(
for (i = 0; i < n_fields; i++) {
index_field_t* ifield = &index_def->fields[i];
const char * col_name = ifield->col_name ?
dict_table_get_col_name_for_mysql(table, ifield->col_name) :
dict_table_get_col_name(table, ifield->col_no);
dict_mem_index_add_field(
index, dict_table_get_col_name(table, ifield->col_no),
index,
col_name,
ifield->prefix_len);
}

View File

@@ -47,6 +47,29 @@ Created 9/5/1995 Heikki Tuuri
#include "ha_prototypes.h"
#include "my_cpu.h"
#include <vector>
/* There is a bug in Visual Studio 2010.
Visual Studio has a feature "Checked Iterators". In a debug build, every
iterator operation is checked at runtime for errors, e.g., out of range.
Because of bug there is runtime error on following code
for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it !=
array->elems.end(); ++it) and runtime check fails on comparison
it != array->elems.end() that is correct and standard way to do end
of range comparison.
Disable this "Checked Iterators" for Windows and Debug if defined.
*/
#ifdef UNIV_DEBUG
#ifdef __WIN__
#ifdef _ITERATOR_DEBUG_LEVEL
#undef _ITERATOR_DEBUG_LEVEL
#define _ITERATOR_DEBUG_LEVEL 0
#endif /* _ITERATOR_DEBUG_LEVEL */
#endif /* __WIN__*/
#endif /* UNIV_DEBUG */
#include <vector>
/*
REASONS FOR IMPLEMENTING THE SPIN LOCK MUTEX
============================================
@@ -225,12 +248,9 @@ static const ulint SYNC_THREAD_N_LEVELS = 10000;
/** Array for tracking sync levels per thread. */
struct sync_arr_t {
ulint in_use; /*!< Number of active cells */
ulint n_elems; /*!< Number of elements in the array */
ulint max_elems; /*!< Maximum elements */
ulint next_free; /*!< ULINT_UNDEFINED or index of next
free slot */
sync_level_t* elems; /*!< Array elements */
std::vector<sync_level_t> elems; /*!< Vector of elements */
};
/** Mutexes or rw-locks held by a thread */
@@ -1084,10 +1104,9 @@ sync_thread_add_level(
SYNC_LEVEL_VARYING, nothing is done */
ibool relock) /*!< in: TRUE if re-entering an x-lock */
{
ulint i;
sync_level_t* slot;
sync_arr_t* array;
sync_thread_t* thread_slot;
sync_level_t sync_level;
if (!sync_order_checks_on) {
@@ -1112,21 +1131,11 @@ sync_thread_add_level(
thread_slot = sync_thread_level_arrays_find_slot();
if (thread_slot == NULL) {
ulint sz;
sz = sizeof(*array)
+ (sizeof(*array->elems) * SYNC_THREAD_N_LEVELS);
/* We have to allocate the level array for a new thread */
array = static_cast<sync_arr_t*>(calloc(sz, sizeof(char)));
array = static_cast<sync_arr_t*>(calloc(1, sizeof(sync_arr_t)));
ut_a(array != NULL);
array->next_free = ULINT_UNDEFINED;
array->max_elems = SYNC_THREAD_N_LEVELS;
array->elems = (sync_level_t*) &array[1];
thread_slot = sync_thread_level_arrays_find_free();
thread_slot->levels = array;
thread_slot->id = os_thread_get_curr_id();
}
@@ -1337,26 +1346,11 @@ sync_thread_add_level(
}
levels_ok:
if (array->next_free == ULINT_UNDEFINED) {
ut_a(array->n_elems < array->max_elems);
i = array->n_elems++;
} else {
i = array->next_free;
array->next_free = array->elems[i].level;
}
ut_a(i < array->n_elems);
ut_a(i != ULINT_UNDEFINED);
++array->in_use;
slot = &array->elems[i];
ut_a(slot->latch == NULL);
slot->latch = latch;
slot->level = level;
array->n_elems++;
sync_level.latch = latch;
sync_level.level = level;
array->elems.push_back(sync_level);
mutex_exit(&sync_thread_mutex);
}
@@ -1374,7 +1368,6 @@ sync_thread_reset_level(
{
sync_arr_t* array;
sync_thread_t* thread_slot;
ulint i;
if (!sync_order_checks_on) {
@@ -1403,36 +1396,16 @@ sync_thread_reset_level(
array = thread_slot->levels;
for (i = 0; i < array->n_elems; i++) {
sync_level_t* slot;
for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it != array->elems.end(); ++it) {
sync_level_t level = *it;
slot = &array->elems[i];
if (slot->latch != latch) {
if (level.latch != latch) {
continue;
}
slot->latch = NULL;
/* Update the free slot list. See comment in sync_level_t
for the level field. */
slot->level = array->next_free;
array->next_free = i;
ut_a(array->in_use >= 1);
--array->in_use;
/* If all cells are idle then reset the free
list. The assumption is that this will save
time when we need to scan up to n_elems. */
if (array->in_use == 0) {
array->n_elems = 0;
array->next_free = ULINT_UNDEFINED;
}
array->elems.erase(it);
array->n_elems--;
mutex_exit(&sync_thread_mutex);
return(TRUE);
}
@@ -1518,6 +1491,7 @@ sync_thread_level_arrays_free(void)
/* If this slot was allocated then free the slot memory too. */
if (slot->levels != NULL) {
slot->levels->elems.erase(slot->levels->elems.begin(),slot->levels->elems.end());
free(slot->levels);
slot->levels = NULL;
}

View File

@@ -495,7 +495,7 @@ trx_release_savepoint_for_mysql(
{
trx_named_savept_t* savep;
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) || trx_state_eq(trx, TRX_STATE_PREPARED));
ut_ad(trx->in_mysql_trx_list);
savep = trx_savepoint_find(trx, savepoint_name);

View File

@@ -649,6 +649,40 @@ dict_table_get_col_name(
return(s);
}
/**********************************************************************//**
Returns a column's name.
@return column name. NOTE: not guaranteed to stay valid if table is
modified in any way (columns added, etc.). */
UNIV_INTERN
const char*
dict_table_get_col_name_for_mysql(
/*==============================*/
const dict_table_t* table, /*!< in: table */
const char* col_name)/*! in: MySQL table column name */
{
ulint i;
const char* s;
ut_ad(table);
ut_ad(col_name);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
s = table->col_names;
if (s) {
/* If we have many virtual columns MySQL key_part->fieldnr
could be larger than number of columns in InnoDB table
when creating new indexes. */
for (i = 0; i < table->n_def; i++) {
if (!innobase_strcasecmp(s, col_name)) {
break; /* Found */
}
s += strlen(s) + 1;
}
}
return(s);
}
#ifndef UNIV_HOTBACKUP
/********************************************************************//**
Acquire the autoinc lock. */

View File

@@ -4884,7 +4884,10 @@ innobase_release_savepoint(
DBUG_ASSERT(hton == innodb_hton_ptr);
trx = check_trx_exists(thd);
trx_start_if_not_started(trx);
if (trx->state == TRX_STATE_NOT_STARTED) {
trx_start_if_not_started(trx);
}
/* TODO: use provided savepoint data area to store savepoint data */
@@ -5556,6 +5559,8 @@ innobase_match_index_columns(
if (innodb_idx_fld >= innodb_idx_fld_end) {
DBUG_RETURN(FALSE);
}
mtype = innodb_idx_fld->col->mtype;
}
if (col_type != mtype) {

View File

@@ -1472,8 +1472,9 @@ innobase_create_index_field_def(
if a new clustered index is
not being created */
const KEY_PART_INFO* key_part, /*!< in: MySQL key definition */
index_field_t* index_field) /*!< out: index field
index_field_t* index_field, /*!< out: index field
definition for key_part */
const Field** fields) /*!< in: MySQL table fields */
{
const Field* field;
ibool is_unsigned;
@@ -1490,6 +1491,7 @@ innobase_create_index_field_def(
ut_a(field);
index_field->col_no = key_part->fieldnr;
index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
@@ -1524,8 +1526,9 @@ innobase_create_index_def(
bool key_clustered, /*!< in: true if this is
the new clustered index */
index_def_t* index, /*!< out: index definition */
mem_heap_t* heap) /*!< in: heap where memory
mem_heap_t* heap, /*!< in: heap where memory
is allocated */
const Field** fields) /*!z in: MySQL table fields */
{
const KEY* key = &keys[key_number];
ulint i;
@@ -1539,6 +1542,8 @@ innobase_create_index_def(
index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, n_fields * sizeof *index->fields));
memset(index->fields, 0, n_fields * sizeof *index->fields);
index->ind_type = 0;
index->key_number = key_number;
index->n_fields = n_fields;
@@ -1575,7 +1580,7 @@ innobase_create_index_def(
for (i = 0; i < n_fields; i++) {
innobase_create_index_field_def(
altered_table, &key->key_part[i], &index->fields[i]);
altered_table, &key->key_part[i], &index->fields[i], fields);
}
DBUG_VOID_RETURN;
@@ -1906,7 +1911,7 @@ innobase_create_key_defs(
/* Create the PRIMARY key index definition */
innobase_create_index_def(
altered_table, key_info, primary_key_number,
TRUE, TRUE, indexdef++, heap);
TRUE, TRUE, indexdef++, heap, (const Field **)altered_table->field);
created_clustered:
n_add = 1;
@@ -1918,7 +1923,7 @@ created_clustered:
/* Copy the index definitions. */
innobase_create_index_def(
altered_table, key_info, i, TRUE, FALSE,
indexdef, heap);
indexdef, heap, (const Field **)altered_table->field);
if (indexdef->ind_type & DICT_FTS) {
n_fts_add++;
@@ -1963,7 +1968,7 @@ created_clustered:
for (ulint i = 0; i < n_add; i++) {
innobase_create_index_def(
altered_table, key_info, add[i], FALSE, FALSE,
indexdef, heap);
indexdef, heap, (const Field **)altered_table->field);
if (indexdef->ind_type & DICT_FTS) {
n_fts_add++;
@@ -1980,6 +1985,7 @@ created_clustered:
index->fields = static_cast<index_field_t*>(
mem_heap_alloc(heap, sizeof *index->fields));
memset(index->fields, 0, sizeof *index->fields);
index->n_fields = 1;
index->fields->col_no = fts_doc_id_col;
index->fields->prefix_len = 0;

View File

@@ -613,6 +613,17 @@ dict_table_get_col_name(
ulint col_nr) /*!< in: column number */
__attribute__((nonnull, warn_unused_result));
/**********************************************************************//**
Returns a column's name.
@return column name. NOTE: not guaranteed to stay valid if table is
modified in any way (columns added, etc.). */
UNIV_INTERN
const char*
dict_table_get_col_name_for_mysql(
/*==============================*/
const dict_table_t* table, /*!< in: table */
const char* col_name)/*!< in: MySQL table column name */
__attribute__((nonnull, warn_unused_result));
/**********************************************************************//**
Prints a table data. */
UNIV_INTERN
void

View File

@@ -107,6 +107,7 @@ struct index_field_t {
ulint col_no; /*!< column offset */
ulint prefix_len; /*!< column prefix length, or 0
if indexing the whole column */
const char* col_name; /*!< column name or NULL */
};
/** Definition of an index being created */

View File

@@ -3435,9 +3435,13 @@ row_merge_create_index(
for (i = 0; i < n_fields; i++) {
index_field_t* ifield = &index_def->fields[i];
const char * col_name = ifield->col_name ?
dict_table_get_col_name_for_mysql(table, ifield->col_name) :
dict_table_get_col_name(table, ifield->col_no);
dict_mem_index_add_field(
index, dict_table_get_col_name(table, ifield->col_no),
index,
col_name,
ifield->prefix_len);
}

View File

@@ -48,6 +48,29 @@ Created 9/5/1995 Heikki Tuuri
#include "ha_prototypes.h"
#include "my_cpu.h"
#include <vector>
/* There is a bug in Visual Studio 2010.
Visual Studio has a feature "Checked Iterators". In a debug build, every
iterator operation is checked at runtime for errors, e.g., out of range.
Because of bug there is runtime error on following code
for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it !=
array->elems.end(); ++it) and runtime check fails on comparison
it != array->elems.end() that is correct and standard way to do end
of range comparison.
Disable this "Checked Iterators" for Windows and Debug if defined.
*/
#ifdef UNIV_DEBUG
#ifdef __WIN__
#ifdef _ITERATOR_DEBUG_LEVEL
#undef _ITERATOR_DEBUG_LEVEL
#define _ITERATOR_DEBUG_LEVEL 0
#endif /* _ITERATOR_DEBUG_LEVEL */
#endif /* __WIN__*/
#endif /* UNIV_DEBUG */
#include <vector>
/*
REASONS FOR IMPLEMENTING THE SPIN LOCK MUTEX
============================================
@@ -229,12 +252,9 @@ static const ulint SYNC_THREAD_N_LEVELS = 10000;
/** Array for tracking sync levels per thread. */
struct sync_arr_t {
ulint in_use; /*!< Number of active cells */
ulint n_elems; /*!< Number of elements in the array */
ulint max_elems; /*!< Maximum elements */
ulint next_free; /*!< ULINT_UNDEFINED or index of next
free slot */
sync_level_t* elems; /*!< Array elements */
std::vector<sync_level_t> elems; /*!< Vector of elements */
};
/** Mutexes or rw-locks held by a thread */
@@ -1187,10 +1207,9 @@ sync_thread_add_level(
SYNC_LEVEL_VARYING, nothing is done */
ibool relock) /*!< in: TRUE if re-entering an x-lock */
{
ulint i;
sync_level_t* slot;
sync_arr_t* array;
sync_thread_t* thread_slot;
sync_level_t sync_level;
if (!sync_order_checks_on) {
@@ -1215,21 +1234,11 @@ sync_thread_add_level(
thread_slot = sync_thread_level_arrays_find_slot();
if (thread_slot == NULL) {
ulint sz;
sz = sizeof(*array)
+ (sizeof(*array->elems) * SYNC_THREAD_N_LEVELS);
/* We have to allocate the level array for a new thread */
array = static_cast<sync_arr_t*>(calloc(sz, sizeof(char)));
array = static_cast<sync_arr_t*>(calloc(1, sizeof(sync_arr_t)));
ut_a(array != NULL);
array->next_free = ULINT_UNDEFINED;
array->max_elems = SYNC_THREAD_N_LEVELS;
array->elems = (sync_level_t*) &array[1];
thread_slot = sync_thread_level_arrays_find_free();
thread_slot->levels = array;
thread_slot->id = os_thread_get_curr_id();
}
@@ -1457,26 +1466,11 @@ sync_thread_add_level(
}
levels_ok:
if (array->next_free == ULINT_UNDEFINED) {
ut_a(array->n_elems < array->max_elems);
i = array->n_elems++;
} else {
i = array->next_free;
array->next_free = array->elems[i].level;
}
ut_a(i < array->n_elems);
ut_a(i != ULINT_UNDEFINED);
++array->in_use;
slot = &array->elems[i];
ut_a(slot->latch == NULL);
slot->latch = latch;
slot->level = level;
array->n_elems++;
sync_level.latch = latch;
sync_level.level = level;
array->elems.push_back(sync_level);
mutex_exit(&sync_thread_mutex);
}
@@ -1494,7 +1488,6 @@ sync_thread_reset_level(
{
sync_arr_t* array;
sync_thread_t* thread_slot;
ulint i;
if (!sync_order_checks_on) {
@@ -1523,36 +1516,16 @@ sync_thread_reset_level(
array = thread_slot->levels;
for (i = 0; i < array->n_elems; i++) {
sync_level_t* slot;
for (std::vector<sync_level_t>::iterator it = array->elems.begin(); it != array->elems.end(); ++it) {
sync_level_t level = *it;
slot = &array->elems[i];
if (slot->latch != latch) {
if (level.latch != latch) {
continue;
}
slot->latch = NULL;
/* Update the free slot list. See comment in sync_level_t
for the level field. */
slot->level = array->next_free;
array->next_free = i;
ut_a(array->in_use >= 1);
--array->in_use;
/* If all cells are idle then reset the free
list. The assumption is that this will save
time when we need to scan up to n_elems. */
if (array->in_use == 0) {
array->n_elems = 0;
array->next_free = ULINT_UNDEFINED;
}
array->elems.erase(it);
array->n_elems--;
mutex_exit(&sync_thread_mutex);
return(TRUE);
}
@@ -1639,6 +1612,7 @@ sync_thread_level_arrays_free(void)
/* If this slot was allocated then free the slot memory too. */
if (slot->levels != NULL) {
slot->levels->elems.erase(slot->levels->elems.begin(),slot->levels->elems.end());
free(slot->levels);
slot->levels = NULL;
}

View File

@@ -504,7 +504,7 @@ trx_release_savepoint_for_mysql(
{
trx_named_savept_t* savep;
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) || trx_state_eq(trx, TRX_STATE_PREPARED));
ut_ad(trx->in_mysql_trx_list);
savep = trx_savepoint_find(trx, savepoint_name);