Skip to content

Commit

Permalink
MDEV-14799 After UPDATE of indexed columns, old values will not be pu…
Browse files Browse the repository at this point in the history
…rged from secondary indexes

This is a regression caused by MDEV-14051 'Undo log record is too big.'

Purge in the secondary index is wrongly skipped in
row_purge_upd_exist_or_extern() because node->row only does not contain all
indexed columns.

trx_undo_rec_get_partial_row(): Add the parameter for node->update
so that the updated columns will be copied from the initial part
of the undo log record.
  • Loading branch information
dr-m committed Jan 2, 2018
1 parent 1300627 commit d384ead
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions storage/innobase/include/trx0rec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/row/row0purge.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2015, 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
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -730,7 +731,7 @@ row_purge_parse_undo_rec(

if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
ptr = trx_undo_rec_get_partial_row(
ptr, clust_index, &node->row,
ptr, clust_index, node->update, &node->row,
type == TRX_UNDO_UPD_DEL_REC,
node->heap);
}
Expand Down
14 changes: 13 additions & 1 deletion storage/innobase/trx/trx0rec.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -1072,6 +1072,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used
Expand All @@ -1081,6 +1082,8 @@ trx_undo_rec_get_partial_row(
{
const byte* end_ptr;
ulint row_len;
const upd_field_t* uf = update->fields;
const upd_field_t* const ue = update->fields + update->n_fields;

ut_ad(index);
ut_ad(ptr);
Expand All @@ -1094,6 +1097,15 @@ trx_undo_rec_get_partial_row(

dict_table_copy_types(*row, index->table);


for (; uf != ue; uf++) {
ulint c = dict_index_get_nth_col(index, uf->field_no)->ind;
ut_ad(uf->orig_len == UNIV_SQL_NULL
|| uf->orig_len < UNIV_EXTERN_STORAGE_FIELD);
ut_ad(!dfield_is_ext(&uf->new_val));
*dtuple_get_nth_field(*row, c) = uf->new_val;
}

end_ptr = ptr + mach_read_from_2(ptr);
ptr += 2;

Expand Down
2 changes: 2 additions & 0 deletions storage/xtradb/include/trx0rec.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used
Expand Down
3 changes: 2 additions & 1 deletion storage/xtradb/row/row0purge.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2015, 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
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -730,7 +731,7 @@ row_purge_parse_undo_rec(

if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
ptr = trx_undo_rec_get_partial_row(
ptr, clust_index, &node->row,
ptr, clust_index, node->update, &node->row,
type == TRX_UNDO_UPD_DEL_REC,
node->heap);
}
Expand Down
14 changes: 13 additions & 1 deletion storage/xtradb/trx/trx0rec.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, 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
Expand Down Expand Up @@ -1085,6 +1085,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the
record! */
dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used
Expand All @@ -1094,6 +1095,8 @@ trx_undo_rec_get_partial_row(
{
const byte* end_ptr;
ulint row_len;
const upd_field_t* uf = update->fields;
const upd_field_t* const ue = update->fields + update->n_fields;

ut_ad(index);
ut_ad(ptr);
Expand All @@ -1107,6 +1110,15 @@ trx_undo_rec_get_partial_row(

dict_table_copy_types(*row, index->table);


for (; uf != ue; uf++) {
ulint c = dict_index_get_nth_col(index, uf->field_no)->ind;
ut_ad(uf->orig_len == UNIV_SQL_NULL
|| uf->orig_len < UNIV_EXTERN_STORAGE_FIELD);
ut_ad(!dfield_is_ext(&uf->new_val));
*dtuple_get_nth_field(*row, c) = uf->new_val;
}

end_ptr = ptr + mach_read_from_2(ptr);
ptr += 2;

Expand Down

0 comments on commit d384ead

Please sign in to comment.