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

MDEV-14799 After UPDATE of indexed columns, old values will not be purged 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.
parent 1300627a
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row( ...@@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the used, as we do NOT copy the data in the
record! */ record! */
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */ dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used expect blob prefixes in undo. Used
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -730,7 +731,7 @@ row_purge_parse_undo_rec( ...@@ -730,7 +731,7 @@ row_purge_parse_undo_rec(
if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
ptr = trx_undo_rec_get_partial_row( 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, type == TRX_UNDO_UPD_DEL_REC,
node->heap); node->heap);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1072,6 +1072,7 @@ trx_undo_rec_get_partial_row( ...@@ -1072,6 +1072,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the used, as we do NOT copy the data in the
record! */ record! */
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */ dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used expect blob prefixes in undo. Used
...@@ -1081,6 +1082,8 @@ trx_undo_rec_get_partial_row( ...@@ -1081,6 +1082,8 @@ trx_undo_rec_get_partial_row(
{ {
const byte* end_ptr; const byte* end_ptr;
ulint row_len; 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(index);
ut_ad(ptr); ut_ad(ptr);
...@@ -1094,6 +1097,15 @@ trx_undo_rec_get_partial_row( ...@@ -1094,6 +1097,15 @@ trx_undo_rec_get_partial_row(
dict_table_copy_types(*row, index->table); 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); end_ptr = ptr + mach_read_from_2(ptr);
ptr += 2; ptr += 2;
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row( ...@@ -193,6 +194,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the used, as we do NOT copy the data in the
record! */ record! */
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */ dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used expect blob prefixes in undo. Used
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2015, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -730,7 +731,7 @@ row_purge_parse_undo_rec( ...@@ -730,7 +731,7 @@ row_purge_parse_undo_rec(
if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) { if (!(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
ptr = trx_undo_rec_get_partial_row( 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, type == TRX_UNDO_UPD_DEL_REC,
node->heap); node->heap);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1085,6 +1085,7 @@ trx_undo_rec_get_partial_row( ...@@ -1085,6 +1085,7 @@ trx_undo_rec_get_partial_row(
used, as we do NOT copy the data in the used, as we do NOT copy the data in the
record! */ record! */
dict_index_t* index, /*!< in: clustered index */ dict_index_t* index, /*!< in: clustered index */
const upd_t* update, /*!< in: updated columns */
dtuple_t** row, /*!< out, own: partial row */ dtuple_t** row, /*!< out, own: partial row */
ibool ignore_prefix, /*!< in: flag to indicate if we ibool ignore_prefix, /*!< in: flag to indicate if we
expect blob prefixes in undo. Used expect blob prefixes in undo. Used
...@@ -1094,6 +1095,8 @@ trx_undo_rec_get_partial_row( ...@@ -1094,6 +1095,8 @@ trx_undo_rec_get_partial_row(
{ {
const byte* end_ptr; const byte* end_ptr;
ulint row_len; 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(index);
ut_ad(ptr); ut_ad(ptr);
...@@ -1107,6 +1110,15 @@ trx_undo_rec_get_partial_row( ...@@ -1107,6 +1110,15 @@ trx_undo_rec_get_partial_row(
dict_table_copy_types(*row, index->table); 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); end_ptr = ptr + mach_read_from_2(ptr);
ptr += 2; ptr += 2;
......
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