Skip to content

Commit 7f26499

Browse files
committed
Merge branch '10.2' into 10.3
2 parents 1423cf5 + b549af6 commit 7f26499

File tree

9 files changed

+119
-50
lines changed

9 files changed

+119
-50
lines changed

mysql-test/main/processlist_notembedded.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2828
Warnings:
2929
Note 1003 select sleep(100000)
3030
KILL QUERY $con_id;
31+
disconnect con1;
3132
#
3233
# End of 10.2 tests
3334
#

mysql-test/main/processlist_notembedded.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
source include/have_debug.inc;
21
source include/have_debug_sync.inc;
32
source include/not_embedded.inc;
43
source include/count_sessions.inc;
@@ -37,8 +36,6 @@ connection default;
3736

3837
SET DEBUG_SYNC = 'RESET';
3938

40-
source include/wait_until_count_sessions.inc;
41-
4239
--echo #
4340
--echo # End of 5.5 tests
4441
--echo #
@@ -52,8 +49,12 @@ source include/wait_until_count_sessions.inc;
5249
--send select sleep(100000)
5350

5451
--connection default
52+
let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist where state='User sleep';
53+
source include/wait_condition.inc;
5554
evalp SHOW EXPLAIN FOR $con_id;
5655
evalp KILL QUERY $con_id;
56+
disconnect con1;
57+
source include/wait_until_count_sessions.inc;
5758

5859
--echo #
5960
--echo # End of 10.2 tests

mysql-test/suite/gcol/inc/gcol_partition.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,15 @@ CREATE TABLE t1 (
169169
INSERT INTO t1 () VALUES (),();
170170
UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
171171
DROP TABLE t1;
172+
173+
--echo #
174+
--echo # MDEV-26220 Server crashes with indexed by prefix virtual column
175+
--echo #
176+
177+
CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b CHAR(20), c CHAR(20) AS (b),
178+
KEY (c(10),a)) PARTITION BY HASH(pk);
179+
INSERT INTO t1 (pk,a,b) VALUES (1,10,'foo'),(2,11,'baz');
180+
SELECT a FROM t1;
181+
182+
# Cleanup
183+
DROP TABLE t1;

mysql-test/suite/gcol/r/gcol_partition_innodb.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ INSERT INTO t1 () VALUES (),();
104104
UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
105105
DROP TABLE t1;
106106
#
107+
# MDEV-26220 Server crashes with indexed by prefix virtual column
108+
#
109+
CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b CHAR(20), c CHAR(20) AS (b),
110+
KEY (c(10),a)) PARTITION BY HASH(pk);
111+
INSERT INTO t1 (pk,a,b) VALUES (1,10,'foo'),(2,11,'baz');
112+
SELECT a FROM t1;
113+
a
114+
11
115+
10
116+
DROP TABLE t1;
117+
#
107118
# MDEV-16980 Wrongly set tablename len while opening the
108119
# table for purge thread
109120
#

mysql-test/suite/gcol/r/gcol_partition_myisam.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ KEY (b,d)
101101
INSERT INTO t1 () VALUES (),();
102102
UPDATE t1 SET a = 0 WHERE b IS NULL ORDER BY pk;
103103
DROP TABLE t1;
104+
#
105+
# MDEV-26220 Server crashes with indexed by prefix virtual column
106+
#
107+
CREATE TABLE t1 (pk INT PRIMARY KEY, a INT, b CHAR(20), c CHAR(20) AS (b),
108+
KEY (c(10),a)) PARTITION BY HASH(pk);
109+
INSERT INTO t1 (pk,a,b) VALUES (1,10,'foo'),(2,11,'baz');
110+
SELECT a FROM t1;
111+
a
112+
11
113+
10
114+
DROP TABLE t1;
104115
DROP VIEW IF EXISTS v1,v2;
105116
DROP TABLE IF EXISTS t1,t2,t3;
106117
DROP PROCEDURE IF EXISTS p1;

mysql-test/suite/gcol/r/innodb_virtual_index.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,17 @@ Table Op Msg_type Msg_text
296296
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
297297
test.t1 optimize status OK
298298
DROP TABLE t1;
299+
#
300+
# MDEV-20154 Assertion `len <= col->len || ((col->mtype) == 5
301+
# || (col->mtype) == 14)' failed in row_merge_buf_add
302+
#
303+
CREATE TABLE t1 (
304+
a VARCHAR(2500),
305+
b VARCHAR(2499) AS (a) VIRTUAL
306+
) ENGINE=InnoDB;
307+
INSERT INTO t1 (a) VALUES ('foo');
308+
ALTER TABLE t1 MODIFY a VARCHAR(2600), ALGORITHM=INPLACE;
309+
ALTER TABLE t1 ADD KEY (b), ALGORITHM=INPLACE;
310+
# Cleanup
311+
DROP TABLE t1;
312+
# End of 10.2 tests

mysql-test/suite/gcol/t/innodb_virtual_index.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,23 @@ CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(3),
314314
INSERT INTO t1 (id,a) VALUES (1,'foo');
315315
OPTIMIZE TABLE t1;
316316
DROP TABLE t1;
317+
318+
--echo #
319+
--echo # MDEV-20154 Assertion `len <= col->len || ((col->mtype) == 5
320+
--echo # || (col->mtype) == 14)' failed in row_merge_buf_add
321+
--echo #
322+
323+
CREATE TABLE t1 (
324+
a VARCHAR(2500),
325+
b VARCHAR(2499) AS (a) VIRTUAL
326+
) ENGINE=InnoDB;
327+
INSERT INTO t1 (a) VALUES ('foo');
328+
329+
ALTER TABLE t1 MODIFY a VARCHAR(2600), ALGORITHM=INPLACE;
330+
ALTER TABLE t1 ADD KEY (b), ALGORITHM=INPLACE;
331+
332+
--echo # Cleanup
333+
DROP TABLE t1;
334+
335+
--echo # End of 10.2 tests
336+

sql/table.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,21 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
34363436

34373437
/* Update to use trigger fields */
34383438
switch_defaults_to_nullable_trigger_fields(outparam);
3439+
3440+
for (uint k= 0; k < share->keys; k++)
3441+
{
3442+
KEY &key_info= outparam->key_info[k];
3443+
uint parts = (share->use_ext_keys ? key_info.ext_key_parts :
3444+
key_info.user_defined_key_parts);
3445+
for (uint p= 0; p < parts; p++)
3446+
{
3447+
KEY_PART_INFO &kp= key_info.key_part[p];
3448+
if (kp.field != outparam->field[kp.fieldnr - 1])
3449+
{
3450+
kp.field->vcol_info = outparam->field[kp.fieldnr - 1]->vcol_info;
3451+
}
3452+
}
3453+
}
34393454
}
34403455

34413456
#ifdef WITH_PARTITION_STORAGE_ENGINE

storage/innobase/handler/handler0alter.cc

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6245,6 +6245,10 @@ alter_fill_stored_column(
62456245
}
62466246
}
62476247

6248+
static bool alter_templ_needs_rebuild(const TABLE* altered_table,
6249+
const Alter_inplace_info* ha_alter_info,
6250+
const dict_table_t* table);
6251+
62486252

62496253
/** Allows InnoDB to update internal structures with concurrent
62506254
writes blocked (provided that check_if_supported_inplace_alter()
@@ -6394,11 +6398,7 @@ ha_innobase::prepare_inplace_alter_table(
63946398
ha_alter_info->key_count)) {
63956399
err_exit_no_heap:
63966400
DBUG_ASSERT(m_prebuilt->trx->dict_operation_lock_mode == 0);
6397-
if (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) {
6398-
6399-
online_retry_drop_indexes(
6400-
m_prebuilt->table, m_user_thd);
6401-
}
6401+
online_retry_drop_indexes(m_prebuilt->table, m_user_thd);
64026402
DBUG_RETURN(true);
64036403
}
64046404

@@ -6849,9 +6849,9 @@ ha_innobase::prepare_inplace_alter_table(
68496849
== ALTER_OPTIONS
68506850
&& !alter_options_need_rebuild(ha_alter_info, table))) {
68516851

6852+
ha_innobase_inplace_ctx *ctx = NULL;
68526853
if (heap) {
6853-
ha_alter_info->handler_ctx
6854-
= new ha_innobase_inplace_ctx(
6854+
ctx = new ha_innobase_inplace_ctx(
68556855
m_prebuilt,
68566856
drop_index, n_drop_index,
68576857
rename_index, n_rename_index,
@@ -6864,15 +6864,11 @@ ha_innobase::prepare_inplace_alter_table(
68646864
|| !thd_is_strict_mode(m_user_thd)),
68656865
alt_opt.page_compressed,
68666866
alt_opt.page_compression_level);
6867+
ha_alter_info->handler_ctx = ctx;
68676868
}
68686869

68696870
DBUG_ASSERT(m_prebuilt->trx->dict_operation_lock_mode == 0);
6870-
if (ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE)) {
6871-
6872-
online_retry_drop_indexes(
6873-
m_prebuilt->table, m_user_thd);
6874-
6875-
}
6871+
online_retry_drop_indexes(m_prebuilt->table, m_user_thd);
68766872

68776873
if ((ha_alter_info->handler_flags
68786874
& ALTER_DROP_VIRTUAL_COLUMN)
@@ -6887,6 +6883,24 @@ ha_innobase::prepare_inplace_alter_table(
68876883
DBUG_RETURN(true);
68886884
}
68896885

6886+
if (!(ha_alter_info->handler_flags & INNOBASE_ALTER_DATA)
6887+
&& alter_templ_needs_rebuild(altered_table, ha_alter_info,
6888+
ctx->new_table)
6889+
&& ctx->new_table->n_v_cols > 0) {
6890+
/* Changing maria record structure may end up here only
6891+
if virtual columns were altered. In this case, however,
6892+
vc_templ should be rebuilt. Since we don't actually
6893+
change any stored data, we can just dispose vc_templ;
6894+
it will be recreated on next ha_innobase::open(). */
6895+
6896+
DBUG_ASSERT(ctx->new_table == ctx->old_table);
6897+
6898+
dict_free_vc_templ(ctx->new_table->vc_templ);
6899+
UT_DELETE(ctx->new_table->vc_templ);
6900+
6901+
ctx->new_table->vc_templ = NULL;
6902+
}
6903+
68906904
DBUG_RETURN(false);
68916905
}
68926906

@@ -7000,35 +7014,6 @@ ha_innobase::prepare_inplace_alter_table(
70007014
add_fts_doc_id_idx));
70017015
}
70027016

7003-
/** Check that the column is part of a virtual index(index contains
7004-
virtual column) in the table
7005-
@param[in] table Table containing column
7006-
@param[in] col column to be checked
7007-
@return true if this column is indexed with other virtual columns */
7008-
static
7009-
bool
7010-
dict_col_in_v_indexes(
7011-
dict_table_t* table,
7012-
dict_col_t* col)
7013-
{
7014-
for (dict_index_t* index = dict_table_get_next_index(
7015-
dict_table_get_first_index(table)); index != NULL;
7016-
index = dict_table_get_next_index(index)) {
7017-
if (!dict_index_has_virtual(index)) {
7018-
continue;
7019-
}
7020-
for (ulint k = 0; k < index->n_fields; k++) {
7021-
dict_field_t* field
7022-
= dict_index_get_nth_field(index, k);
7023-
if (field->col->ind == col->ind) {
7024-
return(true);
7025-
}
7026-
}
7027-
}
7028-
7029-
return(false);
7030-
}
7031-
70327017
/* Check whether a columnn length change alter operation requires
70337018
to rebuild the template.
70347019
@param[in] altered_table TABLE object for new version of table.
@@ -7040,9 +7025,9 @@ to rebuild the template.
70407025
static
70417026
bool
70427027
alter_templ_needs_rebuild(
7043-
TABLE* altered_table,
7044-
Alter_inplace_info* ha_alter_info,
7045-
dict_table_t* table)
7028+
const TABLE* altered_table,
7029+
const Alter_inplace_info* ha_alter_info,
7030+
const dict_table_t* table)
70467031
{
70477032
ulint i = 0;
70487033
List_iterator_fast<Create_field> cf_it(
@@ -7054,8 +7039,7 @@ alter_templ_needs_rebuild(
70547039
for (ulint j=0; j < table->n_cols; j++) {
70557040
dict_col_t* cols
70567041
= dict_table_get_nth_col(table, j);
7057-
if (cf->length > cols->len
7058-
&& dict_col_in_v_indexes(table, cols)) {
7042+
if (cf->length > cols->len) {
70597043
return(true);
70607044
}
70617045
}

0 commit comments

Comments
 (0)