From 5c42d84c95d2005dd6e351d351a79dbcca4abbbe Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Thu, 7 Jul 2016 12:57:04 -0300 Subject: [PATCH] BUG-1517155 Added --create-table-engine param to pt-heartbeat --- bin/pt-heartbeat | 18 +++++++++++++++++- t/pt-heartbeat/basics.t | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index b1991b44..42fa9d84 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -5821,7 +5821,16 @@ sub main { my $sql = $o->read_para_after(__FILE__, qr/MAGIC_create_heartbeat/); $sql =~ s/heartbeat/IF NOT EXISTS $db_tbl/; PTDEBUG && _d($sql); - $dbh->do($sql); + if ($o->get('create-table-engine')) { + my $engine = $o->get('create-table-engine'); + $sql =~ s/;$/ ENGINE=$engine;/; + PTDEBUG && _d("Using engine $engine"); + PTDEBUG && _d($sql); + } + eval { $dbh->do($sql); }; + if ( $EVAL_ERROR ) { + die "Error creating heartbeat table:". $EVAL_ERROR; + } # Now we insert first row. # Some caveats: @@ -6664,6 +6673,13 @@ The tool automatically detects if the heartbeat table is legacy. See also L<"MULTI-SLAVE HIERARCHY">. +=item --create-table-engine + +type: string + +Sets the engine to be used for the heartbeat table. +The default storage engine is InnoDB as of MySQL 5.5.5. + =item --daemonize Fork to the background and detach from the shell. POSIX operating systems only. diff --git a/t/pt-heartbeat/basics.t b/t/pt-heartbeat/basics.t index f7afd583..769485e0 100644 --- a/t/pt-heartbeat/basics.t +++ b/t/pt-heartbeat/basics.t @@ -166,6 +166,23 @@ is( '--create-table creates heartbeat table' ) or diag($output, Dumper($row)); +$master_dbh->do('drop table if exists test.heartbeat'); +$sb->wait_for_slaves; + +$output = output( + sub { pt_heartbeat::main('-F', $cnf, + qw(--update --run-time 1s --database test --table heartbeat), + qw(--create-table --create-table-engine MEMORY)) }, + stderr => 1, +); +$master_dbh->do('use test'); +$row = $master_dbh->selectrow_hashref("SHOW TABLE STATUS LIKE 'heartbeat'"); +is( + uc($row->{engine}), + 'MEMORY', + '--create-table-engine creates heartbeat table using a non-default engine' +) or diag($output, Dumper($row)); + # ############################################################################# # Issue 352: Add port to mk-heartbeat --check output # #############################################################################