From aa42210f728e07fa2708a29e656d5b2e9e2882c4 Mon Sep 17 00:00:00 2001 From: Baron Schwartz Date: Wed, 6 Jun 2012 23:36:07 -0400 Subject: [PATCH] Fix a number of SQL queries to work with ANSI_QUOTES --- lib/RowChecksum.pm | 2 +- lib/TableChecksum.pm | 2 +- t/lib/OSCCaptureSync.t.THIS | 132 ------------------------------------ 3 files changed, 2 insertions(+), 134 deletions(-) delete mode 100644 t/lib/OSCCaptureSync.t.THIS diff --git a/lib/RowChecksum.pm b/lib/RowChecksum.pm index 10f5239b..14a2ba4d 100644 --- a/lib/RowChecksum.pm +++ b/lib/RowChecksum.pm @@ -364,7 +364,7 @@ sub _optimize_xor { do { # Try different positions till sliced result equals non-sliced. PTDEBUG && _d('Trying slice', $opt_slice); - $dbh->do('SET @crc := "", @cnt := 0'); + $dbh->do(q{SET @crc := '', @cnt := 0}); my $slices = $self->_make_xor_slices( row_checksum => "\@crc := $func('a')", crc_width => $crc_width, diff --git a/lib/TableChecksum.pm b/lib/TableChecksum.pm index 2fe9840b..f8a35ae9 100644 --- a/lib/TableChecksum.pm +++ b/lib/TableChecksum.pm @@ -204,7 +204,7 @@ sub optimize_xor { do { # Try different positions till sliced result equals non-sliced. PTDEBUG && _d('Trying slice', $opt_slice); - $dbh->do('SET @crc := "", @cnt := 0'); + $dbh->do(q{SET @crc := '', @cnt := 0}); my $slices = $self->make_xor_slices( query => "\@crc := $func('a')", crc_wid => $crc_wid, diff --git a/t/lib/OSCCaptureSync.t.THIS b/t/lib/OSCCaptureSync.t.THIS deleted file mode 100644 index ca1206a9..00000000 --- a/t/lib/OSCCaptureSync.t.THIS +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/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 DSNParser; -use Sandbox; -use PerconaTest; -use Quoter; -use OSCCaptureSync; - -use Data::Dumper; -$Data::Dumper::Indent = 1; -$Data::Dumper::Sortkeys = 1; -$Data::Dumper::Quotekeys = 0; - -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 MySQL'; - -} -else { - plan tests => 11; -} - -my $q = new Quoter(); -my $osc = new OSCCaptureSync(Quoter => $q); -my $msg = sub { print "$_[0]\n"; }; -my $output; - -sub test_table { - my (%args) = @_; - my ($tbl, $col, $expect) = @args{qw(tbl col expect)}; - - $sb->load_file("master", "t/lib/samples/osc/$tbl"); - PerconaTest::wait_for_table($dbh, "osc.t", "id=5"); - $dbh->do("USE osc"); - - ok( - no_diff( - sub { - $osc->capture( - dbh => $dbh, - db => 'osc', - tbl => 't', - tmp_tbl => '__new_t', - columns => ['id', $col], - chunk_column => 'id', - msg => $msg, - ) - }, - "t/lib/samples/osc/$expect", - stderr => 1, - ), - "$tbl: SQL statments to create triggers" - ); - - $dbh->do("insert into t values (6, 'f')"); - $dbh->do("update t set `$col`='z' where id=1"); - $dbh->do("delete from t where id=3"); - - my $rows = $dbh->selectall_arrayref("select id, `$col` from __new_t order by id"); - is_deeply( - $rows, - [ - [1, 'z'], # update t set c="z" where id=1 - [6, 'f'], # insert into t values (6, "f") - ], - "$tbl: Triggers work" - ) or print Dumper($rows); - - output(sub { - $osc->cleanup( - dbh => $dbh, - db => 'osc', - msg => $msg, - ); - }); - - $rows = $dbh->selectall_arrayref("show triggers from `osc` like 't'"); - is_deeply( - $rows, - [], - "$tbl: Cleanup removes the triggers" - ); -} - -test_table( - tbl => "tbl001.sql", - col => "c", - expect => "capsync001.txt", -); - -test_table( - tbl => "tbl002.sql", - col => "default", - expect => "capsync002.txt", -); - -test_table( - tbl => "tbl003.sql", - col => "space col", - expect => "capsync003.txt", -); - -# ############################################################################# -# Done. -# ############################################################################# -{ - local *STDERR; - open STDERR, '>', \$output; - $osc->_d('Complete test coverage'); -} -like( - $output, - qr/Complete test coverage/, - '_d() works' -); -$sb->wipe_clean($dbh); -ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); -exit;