Skip to content

Commit

Permalink
Merge 10.1 into 10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Sep 29, 2020
2 parents 8426165 + 83a520d commit a441b06
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/r/foreign_key.result
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,20 @@ Opened_table_definitions 2
Opened_tables 2
drop function foo;
drop table t2, t1;
CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk)) ENGINE=InnoDB;
XA START 'xid';
INSERT INTO t1 VALUES (1,2);
CREATE TABLE x AS SELECT * FROM t1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
connect con1,localhost,root,,test;
SET foreign_key_checks= OFF, innodb_lock_wait_timeout= 1;
ALTER TABLE t1 ADD FOREIGN KEY f (a) REFERENCES t1 (pk), LOCK=EXCLUSIVE;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
disconnect con1;
connection default;
XA END 'xid';
XA ROLLBACK 'xid';
DROP TABLE t1;
# Start of 10.2 tests
#
# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
Expand Down
14 changes: 14 additions & 0 deletions mysql-test/suite/innodb/t/foreign_key.test
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,20 @@ show status like '%opened_tab%';
drop function foo;
drop table t2, t1;

CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk)) ENGINE=InnoDB;
XA START 'xid';
INSERT INTO t1 VALUES (1,2);
--error ER_XAER_RMFAIL
CREATE TABLE x AS SELECT * FROM t1;
--connect (con1,localhost,root,,test)
SET foreign_key_checks= OFF, innodb_lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD FOREIGN KEY f (a) REFERENCES t1 (pk), LOCK=EXCLUSIVE;# Cleanup
--disconnect con1
--connection default
XA END 'xid';
XA ROLLBACK 'xid';
DROP TABLE t1;
#
# End of 10.1 tests
#
Expand Down
6 changes: 6 additions & 0 deletions storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5148,6 +5148,12 @@ prepare_inplace_alter_table_dict(
trx_free_for_mysql(ctx->trx);
trx_commit_for_mysql(ctx->prebuilt->trx);

for (uint i = 0; i < ctx->num_to_add_fk; i++) {
if (ctx->add_fk[i]) {
dict_foreign_free(ctx->add_fk[i]);
}
}

delete ctx;
ha_alter_info->handler_ctx = NULL;

Expand Down
8 changes: 1 addition & 7 deletions storage/innobase/include/sync0rw.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2017, 2019, MariaDB Corporation.
Copyright (c) 2017, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -577,12 +577,6 @@ struct rw_lock_t
/** number of granted SX locks. */
volatile ulint sx_recursive;

/** This is TRUE if the writer field is RW_LOCK_X_WAIT; this field
is located far from the memory update hotspot fields which are at
the start of this struct, thus we can peek this field without
causing much memory bus traffic */
bool writer_is_wait_ex;

/** The value is typically set to thread id of a writer thread making
normal rw_locks recursive. In case of asynchronous IO, when a non-zero
value of 'pass' is passed then we keep the lock non-recursive.
Expand Down
6 changes: 6 additions & 0 deletions storage/xtradb/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,12 @@ prepare_inplace_alter_table_dict(
trx_free_for_mysql(ctx->trx);
trx_commit_for_mysql(ctx->prebuilt->trx);

for (uint i = 0; i < ctx->num_to_add_fk; i++) {
if (ctx->add_fk[i]) {
dict_foreign_free(ctx->add_fk[i]);
}
}

delete ctx;
ha_alter_info->handler_ctx = NULL;

Expand Down
8 changes: 1 addition & 7 deletions storage/xtradb/include/sync0rw.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -763,13 +764,6 @@ struct rw_lock_t {
/* last s-lock file/line is not guaranteed to be correct */
const char* last_s_file_name;/*!< File name where last s-locked */
const char* last_x_file_name;/*!< File name where last x-locked */
ibool writer_is_wait_ex;
/*!< This is TRUE if the writer field is
RW_LOCK_WAIT_EX; this field is located far
from the memory update hotspot fields which
are at the start of this struct, thus we can
peek this field without causing much memory
bus traffic */
unsigned cline:14; /*!< Line where created */
unsigned last_s_line:14; /*!< Line number where last time s-locked */
unsigned last_x_line:14; /*!< Line number where last time x-locked */
Expand Down

0 comments on commit a441b06

Please sign in to comment.