mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-27 07:54:58 +00:00
Merged fix-1038276-changehandler-hex-looking-vals
This commit is contained in:
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 33;
|
||||
use Test::More;
|
||||
|
||||
use ChangeHandler;
|
||||
use Quoter;
|
||||
@@ -468,10 +468,52 @@ is_deeply(
|
||||
"process_rows() appends trace msg to SQL statements"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# ChangeHandler doesn't quote varchar columns with hex-looking values
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1038276
|
||||
# #############################################################################
|
||||
SKIP: {
|
||||
skip 'Cannot connect to sandbox master', 1 unless $master_dbh;
|
||||
$sb->load_file('master', "t/lib/samples/bug_1038276.sql");
|
||||
|
||||
@rows = ();
|
||||
$tbl_struct = {
|
||||
cols => [qw(id b)],
|
||||
col_posn => {id=>0, b=>1},
|
||||
type_for => {id=>'int', b=>'varchar'},
|
||||
};
|
||||
$ch = new ChangeHandler(
|
||||
Quoter => $q,
|
||||
left_db => 'bug_1038276',
|
||||
left_tbl => 'lt',
|
||||
right_db => 'bug_1038276',
|
||||
right_tbl => 'rt',
|
||||
actions => [ sub { push @rows, $_[0]; } ],
|
||||
replace => 0,
|
||||
queue => 0,
|
||||
tbl_struct => $tbl_struct,
|
||||
);
|
||||
$ch->fetch_back($master_dbh);
|
||||
|
||||
$ch->change('UPDATE', {id=>1}, [qw(id)] );
|
||||
$ch->change('INSERT', {id=>1}, [qw(id)] );
|
||||
|
||||
is_deeply(
|
||||
\@rows,
|
||||
[
|
||||
"UPDATE `bug_1038276`.`rt` SET `b`='0x89504E470D0A1A0A0000000D4948445200000079000000750802000000E55AD965000000097048597300000EC300000EC301C76FA8640000200049444154789C4CBB7794246779FFBBF78F7B7EBE466177677772CE3D9D667AA67BA62776CE39545557CE3974EE9EB049AB9556392210414258083' WHERE `id`='1' LIMIT 1",
|
||||
"INSERT INTO `bug_1038276`.`rt`(`id`, `b`) VALUES ('1', '0x89504E470D0A1A0A0000000D4948445200000079000000750802000000E55AD965000000097048597300000EC300000EC301C76FA8640000200049444154789C4CBB7794246779FFBBF78F7B7EBE466177677772CE3D9D667AA67BA62776CE39545557CE3974EE9EB049AB9556392210414258083')",
|
||||
],
|
||||
"UPDATE and INSERT quote data regardless of how it looks if tbl_struct->quote_val is true"
|
||||
);
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($slave1_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
||||
done_testing;
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 55;
|
||||
use Test::More;
|
||||
|
||||
use Quoter;
|
||||
use PerconaTest;
|
||||
@@ -59,6 +59,8 @@ is( $q->quote_val('\\\''), "'\\\\\\\''", 'embedded backslash');
|
||||
is( $q->quote_val('123-abc'), "'123-abc'", 'looks numeric but is string');
|
||||
is( $q->quote_val('123abc'), "'123abc'", 'looks numeric but is string');
|
||||
is( $q->quote_val('0x89504E470'), '0x89504E470', 'hex string');
|
||||
is( $q->quote_val('0x89504E470', is_char => 0), '0x89504E470', 'hex string, with is_char => 0');
|
||||
is( $q->quote_val('0x89504E470', is_char => 1), "'0x89504E470'", 'hex string, with is_char => 1');
|
||||
is( $q->quote_val('0x89504I470'), "'0x89504I470'", 'looks like hex string');
|
||||
is( $q->quote_val('eastside0x3'), "'eastside0x3'", 'looks like hex str (issue 1110');
|
||||
|
||||
@@ -219,4 +221,5 @@ SKIP: {
|
||||
# Done.
|
||||
# ###########################################################################
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
||||
done_testing;
|
||||
|
12
t/lib/samples/bug_1038276.sql
Normal file
12
t/lib/samples/bug_1038276.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
DROP DATABASE IF EXISTS bug_1038276;
|
||||
CREATE DATABASE bug_1038276;
|
||||
USE bug_1038276;
|
||||
CREATE TABLE lt (
|
||||
id int not null auto_increment primary key,
|
||||
b varchar(300)
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE rt (
|
||||
id int not null auto_increment primary key,
|
||||
b varchar(300)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO lt VALUES (null, "0x89504E470D0A1A0A0000000D4948445200000079000000750802000000E55AD965000000097048597300000EC300000EC301C76FA8640000200049444154789C4CBB7794246779FFBBF78F7B7EBE466177677772CE3D9D667AA67BA62776CE39545557CE3974EE9EB049AB9556392210414258083");
|
Reference in New Issue
Block a user