PT-2375 - fixed pt-table-sync for tables with generated columns

Previously, pt-table-sync generated DML statements that included
the generated columns of a table, which is however rejected by
the database and not necessary for the required sync statements.
This commit is contained in:
Henning Poettker
2024-11-14 23:51:40 +01:00
parent b6dff19d97
commit 5f14441d19
5 changed files with 181 additions and 1 deletions

View File

@@ -462,7 +462,8 @@ sub get_changes {
# Sub: sort_cols
# Sort a row's columns based on their real order in the table.
# Sort a row's columns based on their real order in the table, and remove
# generated columns.
# This requires that the optional tbl_struct arg was passed to <new()>.
# If not, the rows are sorted alphabetically.
#
@@ -476,6 +477,7 @@ sub sort_cols {
my @cols;
if ( $self->{tbl_struct} ) {
my $pos = $self->{tbl_struct}->{col_posn};
my $is_generated = $self->{tbl_struct}->{is_generated};
my @not_in_tbl;
@cols = sort {
$pos->{$a} <=> $pos->{$b}
@@ -489,6 +491,9 @@ sub sort_cols {
1;
}
}
grep {
!$is_generated->{$_}
}
sort keys %$row;
push @cols, @not_in_tbl if @not_in_tbl;
}