Skip to content

Commit 0474be0

Browse files
committed
Merge 10.3 into 10.4
2 parents 937c90c + 4e75bfc commit 0474be0

File tree

10 files changed

+83
-79
lines changed

10 files changed

+83
-79
lines changed

mysql-test/main/innodb_mysql_sync.result

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ DROP TABLE t1;
489489
SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
490490
#Setup a table with FULLTEXT index.
491491
connection default;
492-
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1)) ENGINE= INNODB;
492+
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1), FULLTEXT(fld1)) ENGINE= INNODB;
493+
Warnings:
494+
Note 1831 Duplicate index `fld1_2`. This is deprecated and will be disallowed in a future release
493495
INSERT INTO t1 VALUES("String1");
494496
#OPTIMIZE TABLE operation.
495497
OPTIMIZE TABLE t1;

mysql-test/main/innodb_mysql_sync.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ SET DEBUG_SYNC= 'alter_table_copy_after_lock_upgrade SIGNAL upgraded';
650650

651651
--echo #Setup a table with FULLTEXT index.
652652
--connection default
653-
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1)) ENGINE= INNODB;
653+
CREATE TABLE t1(fld1 CHAR(10), FULLTEXT(fld1), FULLTEXT(fld1)) ENGINE= INNODB;
654654
INSERT INTO t1 VALUES("String1");
655655

656656
--echo #OPTIMIZE TABLE operation.

mysql-test/suite/innodb/r/innodb-alter.result

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,27 +439,27 @@ tt CREATE TABLE `tt` (
439439
FULLTEXT KEY `ct` (`ct`)
440440
) ENGINE=InnoDB DEFAULT CHARSET=latin1
441441
ALTER TABLE tt ADD COLUMN c CHAR(1) NOT NULL FIRST, LOCK=NONE;
442-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
442+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
443443
ALTER TABLE tt ADD COLUMN c CHAR(1) NOT NULL, LOCK=NONE;
444-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
444+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
445445
CREATE TABLE tu (
446446
pk INT PRIMARY KEY, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, t TEXT,
447447
FULLTEXT INDEX(t)
448448
) ENGINE=InnoDB;
449449
ALTER TABLE tu ADD COLUMN c CHAR(1) NOT NULL FIRST, LOCK=NONE;
450-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
450+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
451451
ALTER TABLE tu ADD COLUMN c CHAR(1) NOT NULL, LOCK=NONE;
452-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
452+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
453453
DROP TABLE tu;
454454
CREATE TABLE tv (
455455
pk INT PRIMARY KEY, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, t TEXT,
456456
UNIQUE INDEX FTS_DOC_ID_INDEX(FTS_DOC_ID),
457457
FULLTEXT INDEX(t)
458458
) ENGINE=InnoDB;
459459
ALTER TABLE tv ADD COLUMN c CHAR(1) NOT NULL FIRST, LOCK=NONE;
460-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
460+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
461461
ALTER TABLE tv ADD COLUMN c CHAR(1) NOT NULL, LOCK=NONE;
462-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
462+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
463463
DROP TABLE tv;
464464
ALTER TABLE t1o CHANGE c1 dB_row_Id INT, ALGORITHM=COPY;
465465
ERROR 42000: Incorrect column name 'dB_row_Id'
@@ -500,8 +500,6 @@ ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
500500
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY
501501
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
502502
ALGORITHM=INPLACE;
503-
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY
504-
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
505503
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID, ALGORITHM=INPLACE;
506504
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY
507505
ALTER TABLE t1o DROP COLUMN FTS_DOC_ID;

mysql-test/suite/innodb/t/innodb-alter.test

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,8 @@ ALTER TABLE t1o ADD FULLTEXT INDEX(cu),
272272
ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE;
273273

274274
# Replace the hidden FTS_DOC_ID column with a user-visible one.
275-
# This used to work if there is at most one fulltext index.
276-
# Currently, we disallow native ALTER TABLE if the table
277-
# contains any FULLTEXT indexes.
278-
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
279275
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
280276
ALGORITHM=INPLACE;
281-
ALTER TABLE t1o ADD COLUMN FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
282277
# Replace the user-visible FTS_DOC_ID column with a hidden one.
283278
# We do not support this in-place.
284279
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON

mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ CREATE FULLTEXT INDEX idx on fts_test (title, body) LOCK=NONE;
7979
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
8080
ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY;
8181
ALTER TABLE fts_test ROW_FORMAT=REDUNDANT, LOCK=NONE;
82-
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
82+
ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED
8383
ALTER TABLE fts_test ROW_FORMAT=REDUNDANT;
8484
SELECT * FROM fts_test WHERE MATCH (title, body)
8585
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE);
@@ -228,3 +228,12 @@ DROP TABLE articles;
228228
CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB;
229229
ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b);
230230
DROP TABLE t1;
231+
#
232+
# MDEV-18152 Assertion 'num_fts_index <= 1' failed
233+
# in prepare_inplace_alter_table_dict
234+
#
235+
CREATE TABLE t1
236+
(a VARCHAR(128), b VARCHAR(128), FULLTEXT INDEX(a), FULLTEXT INDEX(b))
237+
ENGINE=InnoDB;
238+
ALTER TABLE t1 ADD c SERIAL;
239+
DROP TABLE t1;

mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,13 @@ ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b)
276276

277277
# Cleanup
278278
DROP TABLE t1;
279+
280+
--echo #
281+
--echo # MDEV-18152 Assertion 'num_fts_index <= 1' failed
282+
--echo # in prepare_inplace_alter_table_dict
283+
--echo #
284+
CREATE TABLE t1
285+
(a VARCHAR(128), b VARCHAR(128), FULLTEXT INDEX(a), FULLTEXT INDEX(b))
286+
ENGINE=InnoDB;
287+
ALTER TABLE t1 ADD c SERIAL;
288+
DROP TABLE t1;

storage/innobase/handler/ha_innodb.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,12 @@ thd_destructor_proxy(void *)
290290
mysql_cond_init(PSI_NOT_INSTRUMENTED, &thd_destructor_cond, 0);
291291

292292
st_my_thread_var *myvar= _my_thread_var();
293+
myvar->current_mutex = &thd_destructor_mutex;
294+
myvar->current_cond = &thd_destructor_cond;
295+
293296
THD *thd= create_thd();
294297
thd_proc_info(thd, "InnoDB shutdown handler");
295298

296-
myvar->current_mutex = &thd_destructor_mutex;
297-
myvar->current_cond = &thd_destructor_cond;
298299

299300
mysql_mutex_lock(&thd_destructor_mutex);
300301
srv_running.store(myvar, std::memory_order_relaxed);

storage/innobase/handler/handler0alter.cc

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,20 +1242,18 @@ my_error_innodb(
12421242

12431243
/** Determine if fulltext indexes exist in a given table.
12441244
@param table MySQL table
1245-
@return whether fulltext indexes exist on the table */
1246-
static
1247-
bool
1248-
innobase_fulltext_exist(
1249-
/*====================*/
1250-
const TABLE* table)
1245+
@return number of fulltext indexes */
1246+
static uint innobase_fulltext_exist(const TABLE* table)
12511247
{
1248+
uint count = 0;
1249+
12521250
for (uint i = 0; i < table->s->keys; i++) {
12531251
if (table->key_info[i].flags & HA_FULLTEXT) {
1254-
return(true);
1252+
count++;
12551253
}
12561254
}
12571255

1258-
return(false);
1256+
return count;
12591257
}
12601258

12611259
/** Determine whether indexed virtual columns exist in a table.
@@ -1807,11 +1805,14 @@ ha_innobase::check_if_supported_inplace_alter(
18071805
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
18081806
}
18091807

1808+
const char* reason_rebuild = NULL;
1809+
18101810
switch (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) {
18111811
case ALTER_OPTIONS:
18121812
if (alter_options_need_rebuild(ha_alter_info, table)) {
1813-
ha_alter_info->unsupported_reason = my_get_err_msg(
1813+
reason_rebuild = my_get_err_msg(
18141814
ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD);
1815+
ha_alter_info->unsupported_reason = reason_rebuild;
18151816
break;
18161817
}
18171818
/* fall through */
@@ -1946,8 +1947,9 @@ ha_innobase::check_if_supported_inplace_alter(
19461947
}
19471948

19481949
/* We should be able to do the operation in-place.
1949-
See if we can do it online (LOCK=NONE). */
1950-
bool online = true;
1950+
See if we can do it online (LOCK=NONE) or without rebuild. */
1951+
bool online = true, need_rebuild = false;
1952+
const uint fulltext_indexes = innobase_fulltext_exist(altered_table);
19511953

19521954
List_iterator_fast<Create_field> cf_it(
19531955
ha_alter_info->alter_info->create_list);
@@ -2008,8 +2010,7 @@ ha_innobase::check_if_supported_inplace_alter(
20082010

20092011
/* We cannot replace a hidden FTS_DOC_ID
20102012
with a user-visible FTS_DOC_ID. */
2011-
if (m_prebuilt->table->fts
2012-
&& innobase_fulltext_exist(altered_table)
2013+
if (fulltext_indexes && m_prebuilt->table->fts
20132014
&& !my_strcasecmp(
20142015
system_charset_info,
20152016
key_part->field->field_name.str,
@@ -2025,8 +2026,8 @@ ha_innobase::check_if_supported_inplace_alter(
20252026
& AUTO_INCREMENT_FLAG));
20262027

20272028
if (key_part->field->flags & AUTO_INCREMENT_FLAG) {
2028-
/* We cannot assign an AUTO_INCREMENT
2029-
column values during online ALTER. */
2029+
/* We cannot assign AUTO_INCREMENT values
2030+
during online or instant ALTER. */
20302031
DBUG_ASSERT(key_part->field == altered_table
20312032
-> found_next_number_field);
20322033

@@ -2036,6 +2037,7 @@ ha_innobase::check_if_supported_inplace_alter(
20362037
}
20372038

20382039
online = false;
2040+
need_rebuild = true;
20392041
}
20402042

20412043
if (innobase_is_v_fld(key_part->field)) {
@@ -2068,7 +2070,7 @@ ha_innobase::check_if_supported_inplace_alter(
20682070
|| (m_prebuilt->table->fts->doc_col
20692071
< dict_table_get_n_user_cols(m_prebuilt->table)));
20702072

2071-
if (m_prebuilt->table->fts && innobase_fulltext_exist(altered_table)) {
2073+
if (fulltext_indexes && m_prebuilt->table->fts) {
20722074
/* FULLTEXT indexes are supposed to remain. */
20732075
/* Disallow DROP INDEX FTS_DOC_ID_INDEX */
20742076

@@ -2113,7 +2115,8 @@ ha_innobase::check_if_supported_inplace_alter(
21132115
cf_it.rewind();
21142116
Field **af = altered_table->field;
21152117
bool fts_need_rebuild = false;
2116-
const bool need_rebuild = innobase_need_rebuild(ha_alter_info, table);
2118+
need_rebuild = need_rebuild
2119+
|| innobase_need_rebuild(ha_alter_info, table);
21172120

21182121
while (Create_field* cf = cf_it++) {
21192122
DBUG_ASSERT(cf->field
@@ -2165,8 +2168,7 @@ ha_innobase::check_if_supported_inplace_alter(
21652168
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_NOT_NULL);
21662169
} else if (!is_non_const_value(*af)
21672170
&& set_default_value(*af)) {
2168-
if (m_prebuilt->table->fts
2169-
&& innobase_fulltext_exist(altered_table)
2171+
if (fulltext_indexes > 1
21702172
&& !my_strcasecmp(system_charset_info,
21712173
(*af)->field_name.str,
21722174
FTS_DOC_ID_COL_NAME)) {
@@ -2189,42 +2191,36 @@ ha_innobase::check_if_supported_inplace_alter(
21892191
DBUG_RETURN(HA_ALTER_INPLACE_INSTANT);
21902192
}
21912193

2192-
if (!online) {
2193-
/* We already determined that only a non-locking
2194-
operation is possible. */
2195-
} else if ((need_rebuild || (ha_alter_info->handler_flags
2196-
& ALTER_ADD_PK_INDEX))
2197-
&& (innobase_fulltext_exist(altered_table)
2198-
|| innobase_spatial_exist(altered_table)
2199-
|| innobase_indexed_virtual_exist(altered_table))) {
2200-
/* Refuse to rebuild the table online, if
2201-
FULLTEXT OR SPATIAL indexes are to survive the rebuild. */
2202-
online = false;
2194+
if (need_rebuild
2195+
&& (fulltext_indexes
2196+
|| innobase_spatial_exist(altered_table)
2197+
|| innobase_indexed_virtual_exist(altered_table))) {
22032198
/* If the table already contains fulltext indexes,
22042199
refuse to rebuild the table natively altogether. */
2205-
if (m_prebuilt->table->fts) {
2200+
if (fulltext_indexes > 1) {
22062201
cannot_create_many_fulltext_index:
22072202
ha_alter_info->unsupported_reason =
22082203
my_get_err_msg(ER_INNODB_FT_LIMIT);
22092204
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
22102205
}
22112206

2212-
if (ha_alter_info->online
2213-
&& !ha_alter_info->unsupported_reason) {
2214-
2215-
if (innobase_spatial_exist(altered_table)) {
2216-
ha_alter_info->unsupported_reason = my_get_err_msg(
2217-
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS);
2218-
} else if (!innobase_fulltext_exist(altered_table)) {
2219-
/* MDEV-14341 FIXME: Remove this limitation. */
2220-
ha_alter_info->unsupported_reason =
2221-
"online rebuild with indexed virtual columns";
2222-
} else {
2223-
ha_alter_info->unsupported_reason = my_get_err_msg(
2224-
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FTS);
2225-
}
2207+
if (!online || !ha_alter_info->online
2208+
|| ha_alter_info->unsupported_reason != reason_rebuild) {
2209+
/* Either LOCK=NONE was not requested, or we already
2210+
gave specific reason to refuse it. */
2211+
} else if (fulltext_indexes) {
2212+
ha_alter_info->unsupported_reason = my_get_err_msg(
2213+
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_FTS);
2214+
} else if (innobase_spatial_exist(altered_table)) {
2215+
ha_alter_info->unsupported_reason = my_get_err_msg(
2216+
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS);
2217+
} else {
2218+
/* MDEV-14341 FIXME: Remove this limitation. */
2219+
ha_alter_info->unsupported_reason =
2220+
"online rebuild with indexed virtual columns";
22262221
}
22272222

2223+
online = false;
22282224
}
22292225

22302226
if (ha_alter_info->handler_flags

storage/innobase/row/row0mysql.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2015, 2018, MariaDB Corporation.
4+
Copyright (c) 2015, 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
@@ -3425,8 +3425,11 @@ row_drop_table_for_mysql(
34253425
calling btr_search_drop_page_hash_index() while we
34263426
hold the InnoDB dictionary lock, we will drop any
34273427
adaptive hash index entries upfront. */
3428+
bool immune = is_temp_name
3429+
|| strstr(table->name.m_name, "/FTS");
3430+
34283431
while (buf_LRU_drop_page_hash_for_tablespace(table)) {
3429-
if ((!is_temp_name && trx_is_interrupted(trx))
3432+
if ((!immune && trx_is_interrupted(trx))
34303433
|| srv_shutdown_state
34313434
!= SRV_SHUTDOWN_NONE) {
34323435
err = DB_INTERRUPTED;

storage/innobase/row/row0sel.cc

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ row_sel_sec_rec_is_for_clust_rec(
254254
clust_field = static_cast<byte*>(vfield->data);
255255
} else {
256256
clust_pos = dict_col_get_clust_pos(col, clust_index);
257-
ut_ad(!rec_offs_nth_default(clust_offs, clust_pos));
258-
clust_field = rec_get_nth_field(
259-
clust_rec, clust_offs, clust_pos, &clust_len);
257+
clust_field = rec_get_nth_cfield(
258+
clust_rec, clust_index, clust_offs,
259+
clust_pos, &clust_len);
260260
}
261261

262262
sec_field = rec_get_nth_field(sec_rec, sec_offs, i, &sec_len);
@@ -2972,17 +2972,7 @@ row_sel_store_mysql_field_func(
29722972
} else {
29732973
/* The field is stored in the index record, or
29742974
in the metadata for instant ADD COLUMN. */
2975-
2976-
if (rec_offs_nth_default(offsets, field_no)) {
2977-
ut_ad(dict_index_is_clust(index));
2978-
ut_ad(index->is_instant());
2979-
const dict_index_t* clust_index
2980-
= dict_table_get_first_index(prebuilt->table);
2981-
ut_ad(index == clust_index);
2982-
data = clust_index->instant_field_value(field_no,&len);
2983-
} else {
2984-
data = rec_get_nth_field(rec, offsets, field_no, &len);
2985-
}
2975+
data = rec_get_nth_cfield(rec, index, offsets, field_no, &len);
29862976

29872977
if (len == UNIV_SQL_NULL) {
29882978
/* MySQL assumes that the field for an SQL

0 commit comments

Comments
 (0)