Commit 5ed2da95 authored by Marko Mäkelä's avatar Marko Mäkelä

Apply the 5.6.40 security fixes to XtraDB

We did not merge Percona XtraDB 5.6.40-84.0 yet.
The changes in it are mostly cosmetic, except for
2 bug fixes from Oracle MySQL 5.6.40, which could
be security bugs.

This was achieved by taking the applicable parts
of an earlier InnoDB commit to XtraDB:

git diff 15ec8c2f{~,} storage/innobase|
sed -e s+/innobase/+/xtradb/+|patch -p1
parent 7c773abd
/*****************************************************************************
Copyright (c) 2005, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -4782,13 +4782,15 @@ innobase_rename_columns_cache(
}
/** Get the auto-increment value of the table on commit.
@param ha_alter_info Data used during in-place alter
@param ctx In-place ALTER TABLE context
@param altered_table MySQL table that is being altered
@param old_table MySQL table as it is before the ALTER operation
@return the next auto-increment value (0 if not present) */
@param[in] ha_alter_info Data used during in-place alter
@param[in,out] ctx In-place ALTER TABLE context
return autoinc value in ctx->max_autoinc
@param altered_table[in] MySQL table that is being altered
@param old_table[in] MySQL table as it is before the ALTER operation
retval true Failure
@retval false Success*/
static MY_ATTRIBUTE((nonnull, warn_unused_result))
ulonglong
bool
commit_get_autoinc(
/*===============*/
Alter_inplace_info* ha_alter_info,
......@@ -4796,23 +4798,28 @@ commit_get_autoinc(
const TABLE* altered_table,
const TABLE* old_table)
{
ulonglong max_autoinc;
DBUG_ENTER("commit_get_autoinc");
if (!altered_table->found_next_number_field) {
/* There is no AUTO_INCREMENT column in the table
after the ALTER operation. */
max_autoinc = 0;
ctx->max_autoinc = 0;
} else if (ctx->add_autoinc != ULINT_UNDEFINED) {
/* An AUTO_INCREMENT column was added. Get the last
value from the sequence, which may be based on a
supplied AUTO_INCREMENT value. */
max_autoinc = ctx->sequence.last();
ctx->max_autoinc = ctx->sequence.last();
} else if ((ha_alter_info->handler_flags
& Alter_inplace_info::CHANGE_CREATE_OPTION)
&& (ha_alter_info->create_info->used_fields
& HA_CREATE_USED_AUTO)) {
/* Check if the table is discarded */
if(dict_table_is_discarded(ctx->old_table)) {
DBUG_RETURN(true);
}
/* An AUTO_INCREMENT value was supplied, but the table was not
rebuilt. Get the user-supplied value or the last value from the
sequence. */
......@@ -4827,7 +4834,8 @@ commit_get_autoinc(
dict_index_t* index = dict_table_get_index_on_name(
ctx->old_table, autoinc_key->name);
max_autoinc = ha_alter_info->create_info->auto_increment_value;
ctx->max_autoinc =
ha_alter_info->create_info->auto_increment_value;
dict_table_autoinc_lock(ctx->old_table);
......@@ -4836,8 +4844,8 @@ commit_get_autoinc(
if (err != DB_SUCCESS) {
ut_ad(0);
max_autoinc = 0;
} else if (max_autoinc <= max_value_table) {
ctx->max_autoinc = 0;
} else if (ctx->max_autoinc <= max_value_table) {
ulonglong col_max_value;
ulonglong offset;
......@@ -4845,7 +4853,7 @@ commit_get_autoinc(
old_table->found_next_number_field);
offset = ctx->prebuilt->autoinc_offset;
max_autoinc = innobase_next_autoinc(
ctx->max_autoinc = innobase_next_autoinc(
max_value_table, 1, 1, offset,
col_max_value);
}
......@@ -4855,11 +4863,11 @@ commit_get_autoinc(
Read the old counter value from the table. */
ut_ad(old_table->found_next_number_field);
dict_table_autoinc_lock(ctx->old_table);
max_autoinc = ctx->old_table->autoinc;
ctx->max_autoinc = ctx->old_table->autoinc;
dict_table_autoinc_unlock(ctx->old_table);
}
DBUG_RETURN(max_autoinc);
DBUG_RETURN(false);
}
/** Add or drop foreign key constraints to the data dictionary tables,
......@@ -5828,8 +5836,13 @@ ha_innobase::commit_inplace_alter_table(
DBUG_ASSERT(new_clustered == ctx->need_rebuild());
ctx->max_autoinc = commit_get_autoinc(
ha_alter_info, ctx, altered_table, table);
if (commit_get_autoinc(ha_alter_info, ctx, altered_table,
table)) {
fail = true;
my_error(ER_TABLESPACE_DISCARDED, MYF(0),
table->s->table_name.str);
goto rollback_trx;
}
if (ctx->need_rebuild()) {
ctx->tmp_name = dict_mem_create_temporary_tablename(
......@@ -5861,6 +5874,8 @@ ha_innobase::commit_inplace_alter_table(
#endif
}
rollback_trx:
/* Commit or roll back the changes to the data dictionary. */
if (fail) {
......
/*****************************************************************************
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
......@@ -2631,7 +2631,15 @@ row_log_table_apply_ops(
while (!trx_is_interrupted(trx)) {
mrec = next_mrec;
ut_ad(mrec < mrec_end);
ut_ad(mrec <= mrec_end);
if (mrec == mrec_end) {
/* We are at the end of the log.
Mark the replay all_done. */
if (has_index_lock) {
goto all_done;
}
}
if (!has_index_lock) {
/* We are applying operations from a different
......
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