Files
percona-toolkit/t/pt-mysql-summary/pt-2109.t
Sveta Smirnova 1407b5380b PT-2109 - pt-mysql-summary throws an error when using sql_mode="ANSI_QUOTES" (#696)
* PT-2109 - pt-mysql-summary throws an error when using sql_mode="ANSI_QUOTES"

- Fixed issues still visible with SQL mode ANSI_QUOTES
- Added test cases for this mode

* PT-2109 - pt-mysql-summary throws an error when using sql_mode="ANSI_QUOTES"

- Removed keyring plugin check in the beginning of the test, because
  reported error would show up even on servers that do not have keyring
  plugin installed. Same applies to wsrep_on check and Percona Server
  features checks.
- Removed temporary dir setup, because not needed for this test.
2023-11-03 01:46:32 +03:00

61 lines
1.5 KiB
Perl

#!/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 PerconaTest;
use Sandbox;
use DSNParser;
require VersionParser;
use Test::More;
local $ENV{PTDEBUG} = "";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $dbh = $sb->get_dbh_for('master');
my $has_keyring_plugin;
if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 3;
}
my $output;
my $cnf = '/tmp/12345/my.sandbox.cnf';
my ($orig_sql_mode) = $dbh->selectrow_array(q{SELECT @@SQL_MODE});
$dbh->do("SET GLOBAL SQL_MODE='ANSI_QUOTES'");
my $cmd = "$trunk/bin/pt-mysql-summary --sleep 1 -- --defaults-file=$cnf";
$output = `$cmd 2>&1`;
unlike(
$output,
qr/Unknown column 'keyring%' in 'where clause'/s,
"pt-mysql-summary works fine with SQL Mode ANSI_QUOTES"
);
unlike(
$output,
qr/You have an error in your SQL syntax.*wsrep_on/s,
"pt-mysql-summary works fine with PXC and SQL Mode ANSI_QUOTES"
);
# #############################################################################
# Done.
# #############################################################################
$dbh->do("SET GLOBAL SQL_MODE='${orig_sql_mode}'");
$sb->wipe_clean($dbh);
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
exit;