Commit caa9023c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19331 Merge new release of InnoDB 5.6.44 to 10.1

parents bb17094b 1cd31bc1
......@@ -918,3 +918,45 @@ ERROR HY000: CHECK OPTION failed 'test.v'
SET GLOBAL innodb_stats_persistent= @save_isp;
DROP view v;
DROP TABLE t;
#
# Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT
#
CREATE TABLE t (a VARCHAR(10) NOT NULL,b INT,PRIMARY KEY (b)) ENGINE=INNODB
PARTITION BY RANGE (b)
(PARTITION pa VALUES LESS THAN (2),
PARTITION pb VALUES LESS THAN (20),
PARTITION pc VALUES LESS THAN (30),
PARTITION pd VALUES LESS THAN (40));
INSERT INTO t
VALUES('A',0),('B',1),('C',2),('D',3),('E',4),('F',5),('G',25),('H',35);
CREATE TABLE t_copy LIKE t;
INSERT INTO t_copy SELECT * FROM t;
ALTER TABLE t ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD UNIQUE KEY (r,b);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE t_copy ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD UNIQUE KEY (r,b), ALGORITHM=COPY;
affected rows: 8
info: Records: 8 Duplicates: 0 Warnings: 0
SELECT * FROM t;
a b r
A 0 1
B 1 2
C 2 3
D 3 4
E 4 5
F 5 6
G 25 7
H 35 8
SELECT * FROM t_copy;
a b r
A 0 1
B 1 2
C 2 3
D 3 4
E 4 5
F 5 6
G 25 7
H 35 8
DROP TABLE t,t_copy;
......@@ -1213,3 +1213,30 @@ test.t1 check status OK
DROP TABLE t1;
SET GLOBAL innodb_file_format=@save_format;
SET GLOBAL innodb_large_prefix=@save_prefix;
#
# Bug#19811005 ALTER TABLE ADD INDEX DOES NOT UPDATE INDEX_LENGTH
# IN I_S TABLES
#
CREATE TABLE t1(a INT, b INT) ENGINE=INNODB, STATS_PERSISTENT=1;
SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
cast(INDEX_LENGTH/@@innodb_page_size as int) I
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
D I
1 0
ALTER TABLE t1 ADD INDEX (a);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
cast(INDEX_LENGTH/@@innodb_page_size as int) I
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
D I
1 1
ALTER TABLE t1 ADD INDEX (b);
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
cast(INDEX_LENGTH/@@innodb_page_size as int) I
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
D I
1 2
DROP TABLE t1;
......@@ -593,3 +593,23 @@ CHECK TABLE t1;
DROP TABLE t1;
SET GLOBAL innodb_file_format=@save_format;
SET GLOBAL innodb_large_prefix=@save_prefix;
--echo #
--echo # Bug#19811005 ALTER TABLE ADD INDEX DOES NOT UPDATE INDEX_LENGTH
--echo # IN I_S TABLES
--echo #
let $i_s_query=SELECT cast(DATA_LENGTH/@@innodb_page_size as int) D,
cast(INDEX_LENGTH/@@innodb_page_size as int) I
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test';
CREATE TABLE t1(a INT, b INT) ENGINE=INNODB, STATS_PERSISTENT=1;
eval $i_s_query;
--enable_info
ALTER TABLE t1 ADD INDEX (a);
--disable_info
eval $i_s_query;
--enable_info
ALTER TABLE t1 ADD INDEX (b);
--disable_info
eval $i_s_query;
DROP TABLE t1;
......@@ -1214,7 +1214,7 @@
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.43
-GLOBAL_VALUE 5.6.44
+GLOBAL_VALUE 5.6.43-84.3
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
......
......@@ -684,7 +684,7 @@
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.43
-GLOBAL_VALUE 5.6.44
+GLOBAL_VALUE 5.6.43-84.3
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
......
......@@ -2401,7 +2401,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
GLOBAL_VALUE 5.6.43
GLOBAL_VALUE 5.6.44
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
......
......@@ -1028,3 +1028,27 @@ SET GLOBAL innodb_stats_persistent= @save_isp;
DROP view v;
DROP TABLE t;
--echo #
--echo # Bug#28573894 ALTER PARTITIONED TABLE ADD AUTO_INCREMENT DIFF RESULT
--echo #
CREATE TABLE t (a VARCHAR(10) NOT NULL,b INT,PRIMARY KEY (b)) ENGINE=INNODB
PARTITION BY RANGE (b)
(PARTITION pa VALUES LESS THAN (2),
PARTITION pb VALUES LESS THAN (20),
PARTITION pc VALUES LESS THAN (30),
PARTITION pd VALUES LESS THAN (40));
INSERT INTO t
VALUES('A',0),('B',1),('C',2),('D',3),('E',4),('F',5),('G',25),('H',35);
CREATE TABLE t_copy LIKE t;
INSERT INTO t_copy SELECT * FROM t;
--enable_info
ALTER TABLE t ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD UNIQUE KEY (r,b);
ALTER TABLE t_copy ADD COLUMN r INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD UNIQUE KEY (r,b), ALGORITHM=COPY;
--disable_info
SELECT * FROM t;
SELECT * FROM t_copy;
DROP TABLE t,t_copy;
/*
Copyright (c) 2005, 2017, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB
Copyright (c) 2005, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -8329,7 +8329,12 @@ bool ha_partition::inplace_alter_table(TABLE *altered_table,
for (index= 0; index < m_tot_parts && !error; index++)
{
ha_alter_info->handler_ctx= part_inplace_ctx->handler_ctx_array[index];
if ((ha_alter_info->handler_ctx=
part_inplace_ctx->handler_ctx_array[index]) != NULL
&& index != 0)
ha_alter_info->handler_ctx->set_shared_data
(*part_inplace_ctx->handler_ctx_array[index - 1]);
if (m_file[index]->ha_inplace_alter_table(altered_table,
ha_alter_info))
error= true;
......
#ifndef HANDLER_INCLUDED
#define HANDLER_INCLUDED
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2018, MariaDB
Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
......@@ -1833,6 +1833,7 @@ class inplace_alter_handler_ctx : public Sql_alloc
inplace_alter_handler_ctx() {}
virtual ~inplace_alter_handler_ctx() {}
virtual void set_shared_data(const inplace_alter_handler_ctx& ctx) {}
};
......
/*****************************************************************************
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -2499,7 +2499,6 @@ dict_stats_report_error(
return (err);
}
/** Save the table's statistics into the persistent statistics storage.
@param[in] table_orig table whose stats to save
@param[in] only_for_index if this is non-NULL, then stats for indexes
......@@ -3208,6 +3207,8 @@ dict_stats_update_for_index(
if (dict_stats_persistent_storage_check(false)) {
dict_table_stats_lock(index->table, RW_X_LATCH);
dict_stats_analyze_index(index);
index->table->stat_sum_of_other_index_sizes
+= index->stat_index_size;
dict_table_stats_unlock(index->table, RW_X_LATCH);
dict_stats_save(index->table, &index->id);
DBUG_VOID_RETURN;
......
/*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2005, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -2178,6 +2178,23 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
@return whether the table will be rebuilt */
bool need_rebuild () const { return(old_table != new_table); }
/** Share context between partitions.
@param[in] ctx context from another partition of the table */
void set_shared_data(const inplace_alter_handler_ctx& ctx)
{
if (add_autoinc != ULINT_UNDEFINED) {
const ha_innobase_inplace_ctx& ha_ctx =
static_cast<const ha_innobase_inplace_ctx&>
(ctx);
/* When adding an AUTO_INCREMENT column to a
partitioned InnoDB table, we must share the
sequence for all partitions. */
ut_ad(ha_ctx.add_autoinc == add_autoinc);
ut_ad(ha_ctx.sequence.last());
sequence = ha_ctx.sequence;
}
}
private:
// Disable copying
ha_innobase_inplace_ctx(const ha_innobase_inplace_ctx&);
......@@ -2721,7 +2738,7 @@ prepare_inplace_alter_table_dict(
(ha_alter_info->handler_ctx);
DBUG_ASSERT((ctx->add_autoinc != ULINT_UNDEFINED)
== (ctx->sequence.m_max_value > 0));
== (ctx->sequence.max_value() > 0));
DBUG_ASSERT(!ctx->num_to_drop_index == !ctx->drop_index);
DBUG_ASSERT(!ctx->num_to_drop_fk == !ctx->drop_fk);
DBUG_ASSERT(!add_fts_doc_id || add_fts_doc_id_idx);
......
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -96,9 +97,13 @@ struct ib_sequence_t {
return(m_next_value);
}
/** Maximum calumn value if adding an AUTOINC column else 0. Once
we reach the end of the sequence it will be set to ~0. */
const ulonglong m_max_value;
/** @return maximum column value
@retval 0 if not adding AUTO_INCREMENT column */
ulonglong max_value() const { return m_max_value; }
private:
/** Maximum value if adding an AUTO_INCREMENT column, else 0 */
ulonglong m_max_value;
/** Value of auto_increment_increment */
ulong m_increment;
......
......@@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6
#define INNODB_VERSION_BUGFIX 43
#define INNODB_VERSION_BUGFIX 44
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
......
/*****************************************************************************
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -3207,6 +3207,8 @@ dict_stats_update_for_index(
if (dict_stats_persistent_storage_check(false)) {
dict_table_stats_lock(index->table, RW_X_LATCH);
dict_stats_analyze_index(index);
index->table->stat_sum_of_other_index_sizes
+= index->stat_index_size;
dict_table_stats_unlock(index->table, RW_X_LATCH);
dict_stats_save(index->table, &index->id);
DBUG_VOID_RETURN;
......@@ -4006,7 +4008,6 @@ dict_stats_save_defrag_stats(
{
dberr_t ret;
if (index->is_readable()) {
} else {
return (dict_stats_report_error(index->table, true));
......
/*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2005, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -2181,6 +2181,23 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
@return whether the table will be rebuilt */
bool need_rebuild () const { return(old_table != new_table); }
/** Share context between partitions.
@param[in] ctx context from another partition of the table */
void set_shared_data(const inplace_alter_handler_ctx& ctx)
{
if (add_autoinc != ULINT_UNDEFINED) {
const ha_innobase_inplace_ctx& ha_ctx =
static_cast<const ha_innobase_inplace_ctx&>
(ctx);
/* When adding an AUTO_INCREMENT column to a
partitioned InnoDB table, we must share the
sequence for all partitions. */
ut_ad(ha_ctx.add_autoinc == add_autoinc);
ut_ad(ha_ctx.sequence.last());
sequence = ha_ctx.sequence;
}
}
private:
// Disable copying
ha_innobase_inplace_ctx(const ha_innobase_inplace_ctx&);
......@@ -2727,7 +2744,7 @@ prepare_inplace_alter_table_dict(
(ha_alter_info->handler_ctx);
DBUG_ASSERT((ctx->add_autoinc != ULINT_UNDEFINED)
== (ctx->sequence.m_max_value > 0));
== (ctx->sequence.max_value() > 0));
DBUG_ASSERT(!ctx->num_to_drop_index == !ctx->drop_index);
DBUG_ASSERT(!ctx->num_to_drop_fk == !ctx->drop_fk);
DBUG_ASSERT(!add_fts_doc_id || add_fts_doc_id_idx);
......
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -96,9 +97,13 @@ struct ib_sequence_t {
return(m_next_value);
}
/** Maximum calumn value if adding an AUTOINC column else 0. Once
we reach the end of the sequence it will be set to ~0. */
const ulonglong m_max_value;
/** @return maximum column value
@retval 0 if not adding AUTO_INCREMENT column */
ulonglong max_value() const { return m_max_value; }
private:
/** Maximum value if adding an AUTO_INCREMENT column, else 0 */
ulonglong m_max_value;
/** Value of auto_increment_increment */
ulong m_increment;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment