mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-22 11:54:54 +00:00
Fix for 930693: ChangeHandler and text columns with just whitespace
This commit is contained in:
@@ -3512,7 +3512,7 @@ sub make_fetch_back_query {
|
||||
my $col = $_;
|
||||
if ( $self->{hex_blob}
|
||||
&& $tbl_struct->{type_for}->{$col} =~ m/blob|text|binary/ ) {
|
||||
$col = "IF(`$col`='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
$col = "IF(BINARY(`$col`)='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
}
|
||||
else {
|
||||
$col = "`$col`";
|
||||
|
@@ -4746,7 +4746,7 @@ sub make_fetch_back_query {
|
||||
my $col = $_;
|
||||
if ( $self->{hex_blob}
|
||||
&& $tbl_struct->{type_for}->{$col} =~ m/blob|text|binary/ ) {
|
||||
$col = "IF(`$col`='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
$col = "IF(BINARY(`$col`)='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
}
|
||||
else {
|
||||
$col = "`$col`";
|
||||
|
@@ -488,7 +488,10 @@ sub make_fetch_back_query {
|
||||
my $col = $_;
|
||||
if ( $self->{hex_blob}
|
||||
&& $tbl_struct->{type_for}->{$col} =~ m/blob|text|binary/ ) {
|
||||
$col = "IF(`$col`='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
# Here we cast to binary, as otherwise, since text columns are
|
||||
# space padded, MySQL would compare ' ' and '' to be the same.
|
||||
# See https://bugs.launchpad.net/percona-toolkit/+bug/930693
|
||||
$col = "IF(BINARY(`$col`)='', '', CONCAT('0x', HEX(`$col`))) AS `$col`";
|
||||
}
|
||||
else {
|
||||
$col = "`$col`";
|
||||
|
@@ -357,7 +357,7 @@ $ch = new ChangeHandler(
|
||||
|
||||
is(
|
||||
$ch->make_fetch_back_query('1=1'),
|
||||
"SELECT `a`, IF(`x`='', '', CONCAT('0x', HEX(`x`))) AS `x`, `b` FROM `test`.`lt` WHERE 1=1 LIMIT 1",
|
||||
"SELECT `a`, IF(BINARY(`x`)='', '', CONCAT('0x', HEX(`x`))) AS `x`, `b` FROM `test`.`lt` WHERE 1=1 LIMIT 1",
|
||||
"Wraps BLOB column in CONCAT('0x', HEX(col)) AS col"
|
||||
);
|
||||
|
||||
@@ -402,7 +402,7 @@ $ch = new ChangeHandler(
|
||||
|
||||
is(
|
||||
$ch->make_fetch_back_query('1=1'),
|
||||
"SELECT IF(`t`='', '', CONCAT('0x', HEX(`t`))) AS `t` FROM `test`.`t` WHERE 1=1 LIMIT 1",
|
||||
"SELECT IF(BINARY(`t`)='', '', CONCAT('0x', HEX(`t`))) AS `t` FROM `test`.`t` WHERE 1=1 LIMIT 1",
|
||||
"Don't prepend 0x to blank blob/text column value (issue 1052)"
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user