PT-1570 pt-archiver fails to detect columns with the word GENERATED as part of the comment

This commit is contained in:
Carlos Salguero
2018-06-14 14:15:20 -03:00
parent accdd7712b
commit 602c1f0ea2
5 changed files with 92 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
Changelog for Percona Toolkit Changelog for Percona Toolkit
* Fixed bug PT-1570 : pt-archiver fails to detect columns with the word GENERATED as part of the comment
* Fixed bug PT-1563 : Fixed pt-show-grants for MySQL 5.6 * Fixed bug PT-1563 : Fixed pt-show-grants for MySQL 5.6
* Improvement PT-1562 : pt-mysql-summary: Fix mysqld command for Travis * Improvement PT-1562 : pt-mysql-summary: Fix mysqld command for Travis
* Improvement PT-242 : (pt-stalk) Include SHOW SLAVE STATUS on 5.7 (Thanks Marcelo Altmann) * Improvement PT-242 : (pt-stalk) Include SHOW SLAVE STATUS on 5.7 (Thanks Marcelo Altmann)

View File

@@ -6240,6 +6240,11 @@ sub main {
. "$src->{db_tbl} does not have a PRIMARY KEY"; . "$src->{db_tbl} does not have a PRIMARY KEY";
} }
warn "====================================================================================================";
warn Data::Dumper::Dumper($src);
warn "====================================================================================================";
warn Data::Dumper::Dumper($dst);
warn "====================================================================================================";
if ( $dst && $o->get('check-columns') ) { if ( $dst && $o->get('check-columns') ) {
my @not_in_src = grep { my @not_in_src = grep {
!$src->{info}->{is_col}->{$_} !$src->{info}->{is_col}->{$_}

View File

@@ -220,7 +220,7 @@ sub remove_quoted_text {
my ($string) = @_; my ($string) = @_;
$string =~ s/[^\\]`[^`]*[^\\]`//g; $string =~ s/[^\\]`[^`]*[^\\]`//g;
$string =~ s/[^\\]"[^"]*[^\\]"//g; $string =~ s/[^\\]"[^"]*[^\\]"//g;
$string =~ s/[^\\]"[^"]*[^\\]"//g; $string =~ s/[^\\]'[^']*[^\\]'//g;
return $string; return $string;
} }

View File

@@ -1188,6 +1188,85 @@ SKIP: {
) or die Data::Dumper::Dumper($tbl); ) or die Data::Dumper::Dumper($tbl);
} }
# Test that the GENERATED word in a column comment doesn't make that column
# to be detected as a MySQL 5.7+ generated column.
$tbl = $tp->parse( load_file('t/lib/samples/generated_cols_comments.sql') );
is_deeply(
$tbl,
{
charset => 'latin1',
clustered_key => 'PRIMARY',
col_posn => {
id => 0,
source => 1,
tso_id => 2
},
cols => [
'id',
'source',
'tso_id'
],
defs => {
id => ' `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT \'The unique id of the audit record.\'',
source => ' `source` enum(\'val1\',\'val2\') NOT NULL COMMENT \'Transaction originator\'',
tso_id => ' `tso_id` int(11) unsigned NOT NULL DEFAULT \'0\' COMMENT \'An internally generated transaction.\''
},
engine => 'InnoDB',
is_autoinc => {
id => 1,
source => 0,
tso_id => 0
},
is_col => {
id => 1,
source => 1,
tso_id => 1
},
is_generated => {},
is_nullable => {},
is_numeric => {
id => 1,
tso_id => 1
},
keys => {
PRIMARY => {
col_prefixes => [
undef
],
colnames => '`id`',
cols => [
'id'
],
ddl => 'PRIMARY KEY (`id`),',
is_col => {
id => 1
},
is_nullable => 0,
is_unique => 1,
name => 'PRIMARY',
type => 'BTREE'
}
},
name => 't1',
non_generated_cols => [
'id',
'source',
'tso_id'
],
null_cols => [],
numeric_cols => [
'id',
'tso_id'
],
type_for => {
id => 'int',
source => 'enum',
tso_id => 'int'
}
},
'Column having the word "generated" as part of the comment is OK',
) or diag Data::Dumper::Dumper($tbl);
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################

View File

@@ -0,0 +1,6 @@
CREATE TABLE `t1` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'The unique id of the audit record.',
`source` enum('val1','val2') NOT NULL COMMENT 'Transaction originator',
`tso_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'An internally generated transaction.',
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='some comment here generated'