mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-08 09:29:45 +00:00
Merge pull request #253 from percona/PT-193
PT-193 pt-table-checksum reports misleading error if comment has apostroph
This commit is contained in:
@@ -1954,7 +1954,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -2085,6 +2085,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -2092,8 +2094,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -341,7 +341,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -472,6 +472,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -479,8 +481,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -1869,7 +1869,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -2000,6 +2000,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -2007,8 +2009,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -3488,7 +3488,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -3619,6 +3619,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -3626,8 +3628,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -3108,7 +3108,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -3239,6 +3239,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -3246,8 +3248,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -2934,7 +2934,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -3065,6 +3065,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -3072,8 +3074,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -3298,7 +3298,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
|
@@ -8834,7 +8834,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -8965,6 +8965,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -8972,8 +8974,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -4435,7 +4435,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
|
@@ -2853,7 +2853,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -2984,6 +2984,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -2991,8 +2993,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -6784,7 +6784,7 @@ sub parse {
|
||||
my ($name) = $ddl =~ m/CREATE (?:TEMPORARY )?TABLE\s+(`.+?`)/;
|
||||
(undef, $name) = $self->{Quoter}->split_unquote($name) if $name;
|
||||
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
@@ -6915,6 +6915,8 @@ sub check_table {
|
||||
my $db_tbl = $q->quote($db, $tbl);
|
||||
PTDEBUG && _d('Checking', $db_tbl);
|
||||
|
||||
$self->{check_table_error} = undef;
|
||||
|
||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||
. ' LIKE ' . $q->literal_like($tbl);
|
||||
PTDEBUG && _d($sql);
|
||||
@@ -6922,8 +6924,9 @@ sub check_table {
|
||||
eval {
|
||||
$row = $dbh->selectrow_arrayref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
if ( my $e = $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($e);
|
||||
$self->{check_table_error} = $e;
|
||||
return 0;
|
||||
}
|
||||
if ( !$row->[0] || $row->[0] ne $tbl ) {
|
||||
|
@@ -145,7 +145,7 @@ sub parse {
|
||||
|
||||
# Lowercase identifiers to avoid issues with case-sensitivity in Perl.
|
||||
# (Bug #1910276).
|
||||
$ddl =~ s/(`[^`]+`)/\L$1/g;
|
||||
$ddl =~ s/(`[^`\n]+`)/\L$1/gm;
|
||||
|
||||
my $engine = $self->get_engine($ddl);
|
||||
|
||||
|
@@ -806,6 +806,32 @@ is_deeply(
|
||||
'issue with pairing backticks in column comments (issue 330)'
|
||||
);
|
||||
|
||||
|
||||
$tbl = $tp->parse( load_file('t/lib/samples/issue_pt-193_backtick_in_col_comments.sql') );
|
||||
is_deeply(
|
||||
$tbl,
|
||||
{ cols => [qw(id f22abcde f23abc)],
|
||||
col_posn => { id => 0, f22abcde => 1, f23abc => 2 },
|
||||
is_col => { id => 1, f22abcde => 1, f23abc => 1 },
|
||||
is_autoinc => { id => 1, f22abcde => 0, f23abc => 0 },
|
||||
null_cols => [qw(f22abcde)],
|
||||
is_nullable => { f22abcde => 1},
|
||||
clustered_key => undef,
|
||||
keys => {},
|
||||
defs => { id => " `id` int(11) NOT NULL AUTO_INCREMENT",
|
||||
"f22abcde" => " `f22abcde` int(10) unsigned DEFAULT NULL COMMENT 'xxx`XXx'",
|
||||
"f23abc" => " `f23abc` int(10) unsigned NOT NULL DEFAULT '255' COMMENT \"`yyy\""
|
||||
},
|
||||
numeric_cols => [qw(id f22abcde f23abc)],
|
||||
is_numeric => { id => 1, f22abcde => 1, f23abc => 1 },
|
||||
engine => 'InnoDB',
|
||||
type_for => { id => 'int', f22abcde => 'int', f23abc => 'int' },
|
||||
name => 't3',
|
||||
charset => 'latin1',
|
||||
},
|
||||
'issue with pairing backticks in column comments (issue 330)'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Issue 170: mk-parallel-dump dies when table-status Data_length is NULL
|
||||
# #############################################################################
|
||||
|
11
t/lib/samples/issue_pt-193_backtick_in_col_comments.sql
Normal file
11
t/lib/samples/issue_pt-193_backtick_in_col_comments.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
DROP DATABASE IF EXISTS test;
|
||||
CREATE DATABASE test;
|
||||
USE test;
|
||||
|
||||
CREATE TABLE `t3` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`f22aBcDe` int(10) unsigned DEFAULT NULL COMMENT 'xxx`XXx',
|
||||
`f23aBc` int(10) unsigned NOT NULL DEFAULT '255' COMMENT "`yyy",
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
|
||||
|
66
t/pt-table-checksum/pt-193.t
Normal file
66
t/pt-table-checksum/pt-193.t
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
use SqlModes;
|
||||
require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $dbh = $sb->get_dbh_for('master');
|
||||
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 3;
|
||||
}
|
||||
|
||||
$sb->load_file('master', 't/lib/samples/issue_pt-193_backtick_in_col_comments.sql');
|
||||
|
||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
|
||||
# And --max-load "" prevents waiting for status variables.
|
||||
my $master_dsn = $sb->dsn_for('master');
|
||||
my @args = ($master_dsn, "--set-vars", "innodb_lock_wait_timeout=50",
|
||||
"--no-check-binlog-format", "--ignore-databases", "mysql",
|
||||
"--nocheck-replication-filters");
|
||||
my $output;
|
||||
my $exit_status;
|
||||
|
||||
# Test #1
|
||||
$output = output(
|
||||
sub { $exit_status = pt_table_checksum::main(@args) },
|
||||
stderr => 1,
|
||||
);
|
||||
|
||||
is(
|
||||
$exit_status,
|
||||
0,
|
||||
"PT-193 use single backtick in comments",
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/test\.t3/,
|
||||
"PT-193 table t3 was checksumed",
|
||||
);
|
||||
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
Reference in New Issue
Block a user