Class: PerconaMigrator::Runner
- Inherits:
-
Object
- Object
- PerconaMigrator::Runner
- Defined in:
- lib/percona_migrator/runner.rb
Overview
It executes pt-online-schema-change commands in a new process and gets its output and status
Instance Method Summary collapse
-
#affected_rows ⇒ Integer
Returns the number of rows affected by the last UPDATE, DELETE or INSERT statements.
-
#execute(command_line) ⇒ Boolean
TODO: rename it so we don’t confuse it with AR’s #execute Runs and logs the given command.
-
#initialize(logger, cli_generator, mysql_adapter, config = PerconaMigrator.configuration) ⇒ Runner
constructor
Constructor.
-
#query(sql) ⇒ Object
Executes the passed sql statement using pt-online-schema-change for ALTER TABLE statements, or the specified mysql adapter otherwise.
Constructor Details
#initialize(logger, cli_generator, mysql_adapter, config = PerconaMigrator.configuration) ⇒ Runner
Constructor
15 16 17 18 19 20 |
# File 'lib/percona_migrator/runner.rb', line 15 def initialize(logger, cli_generator, mysql_adapter, config = PerconaMigrator.configuration) @logger = logger @cli_generator = cli_generator @mysql_adapter = mysql_adapter @error_log_path = config.error_log_path end |
Instance Method Details
#affected_rows ⇒ Integer
Returns the number of rows affected by the last UPDATE, DELETE or INSERT statements
39 40 41 |
# File 'lib/percona_migrator/runner.rb', line 39 def affected_rows mysql_adapter.raw_connection.affected_rows end |
#execute(command_line) ⇒ Boolean
TODO: rename it so we don’t confuse it with AR’s #execute Runs and logs the given command
48 49 50 |
# File 'lib/percona_migrator/runner.rb', line 48 def execute(command_line) Command.new(command_line, error_log_path, logger).run end |
#query(sql) ⇒ Object
Executes the passed sql statement using pt-online-schema-change for ALTER TABLE statements, or the specified mysql adapter otherwise.
26 27 28 29 30 31 32 33 |
# File 'lib/percona_migrator/runner.rb', line 26 def query(sql) if alter_statement?(sql) command_line = cli_generator.parse_statement(sql) execute(command_line) else mysql_adapter.execute(sql) end end |