Skip to content

Commit b2f3755

Browse files
committed
Merge 10.1 into 10.2
2 parents 136a27d + 3e8cab5 commit b2f3755

Some content is hidden

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

41 files changed

+851
-986
lines changed

mysql-test/suite/innodb/r/foreign-keys.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,30 @@ CREATE TABLE t2 (b INT, KEY(b)) ENGINE=InnoDB;
100100
INSERT INTO t2 VALUES(2);
101101
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
102102
DROP TABLE t2, t1;
103+
#
104+
# MDEV-16060 - InnoDB: Failing assertion: ut_strcmp(index->name, key->name)
105+
#
106+
CREATE TABLE t1 (`pk` INT PRIMARY KEY) ENGINE=InnoDB;
107+
CREATE TABLE t2 LIKE t1;
108+
FLUSH TABLES;
109+
SET debug_sync='alter_table_intermediate_table_created SIGNAL ready WAIT_FOR go';
110+
ALTER TABLE t1 ADD FOREIGN KEY(pk) REFERENCES t2(pk) ON UPDATE CASCADE;
111+
connect con1, localhost, root;
112+
SET debug_sync='now WAIT_FOR ready';
113+
SET lock_wait_timeout=1;
114+
UPDATE t2 SET pk=10 WHERE pk=1;
115+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
116+
PREPARE stmt FROM 'UPDATE t2 SET pk=10 WHERE pk=1';
117+
DEALLOCATE PREPARE stmt;
118+
FLUSH TABLE t2;
119+
SET debug_sync='now SIGNAL go';
120+
connection default;
121+
disconnect con1;
122+
connection default;
123+
SET debug_sync='reset';
124+
SHOW OPEN TABLES FROM test;
125+
Database Table In_use Name_locked
126+
DROP TABLE t1, t2;
103127
create table t1 (a int primary key, b int) engine=innodb;
104128
create table t2 (c int primary key, d int,
105129
foreign key (d) references t1 (a) on update cascade) engine=innodb;

mysql-test/suite/innodb/t/foreign-keys.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,38 @@ INSERT INTO t2 VALUES(2);
127127
ALTER TABLE t2 ADD FOREIGN KEY(b) REFERENCES t1(a), LOCK=EXCLUSIVE;
128128
DROP TABLE t2, t1;
129129

130+
131+
--echo #
132+
--echo # MDEV-16060 - InnoDB: Failing assertion: ut_strcmp(index->name, key->name)
133+
--echo #
134+
CREATE TABLE t1 (`pk` INT PRIMARY KEY) ENGINE=InnoDB;
135+
CREATE TABLE t2 LIKE t1;
136+
FLUSH TABLES;
137+
138+
SET debug_sync='alter_table_intermediate_table_created SIGNAL ready WAIT_FOR go';
139+
send ALTER TABLE t1 ADD FOREIGN KEY(pk) REFERENCES t2(pk) ON UPDATE CASCADE;
140+
141+
connect con1, localhost, root;
142+
SET debug_sync='now WAIT_FOR ready';
143+
SET lock_wait_timeout=1; # change to 0 in 10.3
144+
--error ER_LOCK_WAIT_TIMEOUT
145+
UPDATE t2 SET pk=10 WHERE pk=1;
146+
PREPARE stmt FROM 'UPDATE t2 SET pk=10 WHERE pk=1';
147+
DEALLOCATE PREPARE stmt;
148+
FLUSH TABLE t2;
149+
SET debug_sync='now SIGNAL go';
150+
151+
connection default;
152+
reap;
153+
154+
# Cleanup
155+
disconnect con1;
156+
157+
connection default;
158+
SET debug_sync='reset';
159+
SHOW OPEN TABLES FROM test;
160+
DROP TABLE t1, t2;
161+
130162
#
131163
# FK and prelocking:
132164
# child table accesses (reads and writes) wait for locks.

sql/mysql_upgrade_service.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ static void die(const char *fmt, ...)
148148

149149
#define WRITE_LOG(fmt,...) {\
150150
char log_buf[1024]; \
151+
DWORD nbytes; \
151152
snprintf(log_buf,sizeof(log_buf), fmt, __VA_ARGS__);\
152-
WriteFile(logfile_handle,log_buf, strlen(log_buf), 0 , 0);\
153+
WriteFile(logfile_handle,log_buf, strlen(log_buf), &nbytes , 0);\
153154
}
154155

155156
/*

sql/mysqld.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
6666
#define OPT_SESSION SHOW_OPT_SESSION
6767
#define OPT_GLOBAL SHOW_OPT_GLOBAL
6868

69-
extern MY_TIMER_INFO sys_timer_info;
69+
extern MYSQL_PLUGIN_IMPORT MY_TIMER_INFO sys_timer_info;
7070

7171
/*
7272
Values for --slave-parallel-mode

sql/sql_table.cc

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2018, MariaDB
3+
Copyright (c) 2010, 2019, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -8504,6 +8504,50 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table,
85048504
}
85058505
}
85068506

8507+
/*
8508+
Normally, an attempt to modify an FK parent table will cause
8509+
FK children to be prelocked, so the table-being-altered cannot
8510+
be modified by a cascade FK action, because ALTER holds a lock
8511+
and prelocking will wait.
8512+
8513+
But if a new FK is being added by this very ALTER, then the target
8514+
table is not locked yet (it's a temporary table). So, we have to
8515+
lock FK parents explicitly.
8516+
*/
8517+
if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
8518+
{
8519+
List_iterator<Key> fk_list_it(alter_info->key_list);
8520+
8521+
while (Key *key= fk_list_it++)
8522+
{
8523+
if (key->type != Key::FOREIGN_KEY)
8524+
continue;
8525+
8526+
Foreign_key *fk= static_cast<Foreign_key*>(key);
8527+
char dbuf[NAME_LEN];
8528+
char tbuf[NAME_LEN];
8529+
const char *ref_db= fk->ref_db.str ? fk->ref_db.str : alter_ctx->new_db;
8530+
const char *ref_table= fk->ref_table.str;
8531+
MDL_request mdl_request;
8532+
8533+
if (lower_case_table_names)
8534+
{
8535+
strmake_buf(dbuf, ref_db);
8536+
my_casedn_str(system_charset_info, dbuf);
8537+
strmake_buf(tbuf, ref_table);
8538+
my_casedn_str(system_charset_info, tbuf);
8539+
ref_db= dbuf;
8540+
ref_table= tbuf;
8541+
}
8542+
8543+
mdl_request.init(MDL_key::TABLE, ref_db, ref_table, MDL_SHARED_NO_WRITE,
8544+
MDL_TRANSACTION);
8545+
if (thd->mdl_context.acquire_lock(&mdl_request,
8546+
thd->variables.lock_wait_timeout))
8547+
DBUG_RETURN(true);
8548+
}
8549+
}
8550+
85078551
DBUG_RETURN(false);
85088552
}
85098553

@@ -9504,6 +9548,7 @@ do_continue:;
95049548

95059549
/* Mark that we have created table in storage engine. */
95069550
no_ha_table= false;
9551+
DEBUG_SYNC(thd, "alter_table_intermediate_table_created");
95079552

95089553
new_table=
95099554
thd->create_and_open_tmp_table(new_db_type, &frm, alter_ctx.get_tmp_path(),
@@ -9517,54 +9562,6 @@ do_continue:;
95179562
/* in case of alter temp table send the tracker in OK packet */
95189563
SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL);
95199564
}
9520-
else
9521-
{
9522-
/*
9523-
Normally, an attempt to modify an FK parent table will cause
9524-
FK children to be prelocked, so the table-being-altered cannot
9525-
be modified by a cascade FK action, because ALTER holds a lock
9526-
and prelocking will wait.
9527-
9528-
But if a new FK is being added by this very ALTER, then the target
9529-
table is not locked yet (it's a temporary table). So, we have to
9530-
lock FK parents explicitly.
9531-
*/
9532-
if (alter_info->flags & Alter_info::ADD_FOREIGN_KEY)
9533-
{
9534-
List <FOREIGN_KEY_INFO> fk_list;
9535-
List_iterator<FOREIGN_KEY_INFO> fk_list_it(fk_list);
9536-
FOREIGN_KEY_INFO *fk;
9537-
9538-
/* tables_opened can be > 1 only for MERGE tables */
9539-
DBUG_ASSERT(tables_opened == 1);
9540-
DBUG_ASSERT(&table_list->next_global == thd->lex->query_tables_last);
9541-
9542-
new_table->file->get_foreign_key_list(thd, &fk_list);
9543-
while ((fk= fk_list_it++))
9544-
{
9545-
MDL_request mdl_request;
9546-
9547-
if (lower_case_table_names)
9548-
{
9549-
char buf[NAME_LEN];
9550-
uint len;
9551-
strmake_buf(buf, fk->referenced_db->str);
9552-
len = my_casedn_str(files_charset_info, buf);
9553-
thd->make_lex_string(fk->referenced_db, buf, len);
9554-
strmake_buf(buf, fk->referenced_table->str);
9555-
len = my_casedn_str(files_charset_info, buf);
9556-
thd->make_lex_string(fk->referenced_table, buf, len);
9557-
}
9558-
9559-
mdl_request.init(MDL_key::TABLE,
9560-
fk->referenced_db->str, fk->referenced_table->str,
9561-
MDL_SHARED_NO_WRITE, MDL_TRANSACTION);
9562-
if (thd->mdl_context.acquire_lock(&mdl_request,
9563-
thd->variables.lock_wait_timeout))
9564-
goto err_new_table_cleanup;
9565-
}
9566-
}
9567-
}
95689565

95699566
/*
95709567
Note: In case of MERGE table, we do not attach children. We do not

storage/innobase/buf/buf0dblwr.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,18 +652,13 @@ buf_dblwr_process()
652652
ulint decomp = fil_page_decompress(buf, page);
653653
if (!decomp || (decomp != srv_page_size
654654
&& page_size.is_compressed())) {
655-
goto bad_doublewrite;
655+
continue;
656656
}
657657

658658
if (expect_encrypted && mach_read_from_4(
659659
page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
660660
? !fil_space_verify_crypt_checksum(page, page_size)
661661
: buf_page_is_corrupted(true, page, page_size, space)) {
662-
if (!is_all_zero) {
663-
bad_doublewrite:
664-
ib::warn() << "A doublewrite copy of page "
665-
<< page_id << " is corrupted.";
666-
}
667662
/* Theoretically we could have another good
668663
copy for this page in the doublewrite
669664
buffer. If not, we will report a fatal error

storage/innobase/fil/fil0fil.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,8 +2849,7 @@ but only by InnoDB table locks, which may be broken by
28492849
lock_remove_all_on_table().)
28502850
@param[in] table persistent table
28512851
checked @return whether the table is accessible */
2852-
bool
2853-
fil_table_accessible(const dict_table_t* table)
2852+
bool fil_table_accessible(const dict_table_t* table)
28542853
{
28552854
if (UNIV_UNLIKELY(!table->is_readable() || table->corrupted)) {
28562855
return(false);

storage/innobase/fts/fts0config.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, MariaDB Corporation.
4+
Copyright (c) 2017, 2019, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -215,8 +215,11 @@ fts_config_set_value(
215215
pars_info_bind_varchar_literal(info, "value",
216216
value->f_str, value->f_len);
217217

218+
const bool dict_locked = fts_table->table->fts->fts_status
219+
& TABLE_DICT_LOCKED;
220+
218221
fts_table->suffix = "CONFIG";
219-
fts_get_table_name(fts_table, table_name);
222+
fts_get_table_name(fts_table, table_name, dict_locked);
220223
pars_info_bind_id(info, true, "table_name", table_name);
221224

222225
graph = fts_parse_sql(
@@ -244,7 +247,7 @@ fts_config_set_value(
244247
pars_info_bind_varchar_literal(
245248
info, "value", value->f_str, value->f_len);
246249

247-
fts_get_table_name(fts_table, table_name);
250+
fts_get_table_name(fts_table, table_name, dict_locked);
248251
pars_info_bind_id(info, true, "table_name", table_name);
249252

250253
graph = fts_parse_sql(

0 commit comments

Comments
 (0)