Sha256: 92d4607ed570c4eb15ea741cd08750a2dd72a49c5f8dadbfbc75a3c7585a0fc9

Contents?: true

Size: 1.45 KB

Versions: 29

Compression:

Stored size: 1.45 KB

Contents

require 'flydata/parser/parser_provider'
require 'flydata/source_mysql/plugin_support/ddl_query_handler'

module Flydata
module SourceMysql

module PluginSupport
  class AlterTableQueryHandler < TableDdlQueryHandler
    PATTERN = /^ALTER TABLE/i

    def initialize(context)
      super
    end

    def pattern
      PATTERN
    end

    def process(record)
      emit_record(:alter_table, record) do |opt|
        ret = nil
        begin
          result = Flydata::Parser::ParserProvider.parser(:mysql, :mysql_alter_table).new.parse(record["normalized_query"])
          if result.nil?
            $log.error("Received unsupported alter table query. normalized query:'#{record['normalized_query']}', raw query: '#{record['query']}'")
          else
            ret = result.tree
            breaking_query = ret[:actions].any?{|action| !action.has_key?(:support_level) || action[:support_level] != :nonbreaking}
            opt[:increment_table_rev] = true if breaking_query
          end
        rescue => e
          msg = <<EOS
Received unsupported alter table query. normalized query:'#{record['normalized_query']}', raw query: '#{record['query']}' Caused by error '#{e.to_s}'
  Stacktrace :
#{e.backtrace.join("\n")}
EOS
          $log.error(msg)
        end
        $log.info(ret.to_s + " at \"#{binlog_pos(record)}\"") # log all alter table events even if the table is not subject to sync.  This is for troubleshooting purpose.
        ret
      end
    end
  end
end

end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.10.1 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.9.11 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.10 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.9 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.8 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.7 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.6 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.5 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.4 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.3 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.2 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.1 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.8.0 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.19 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.18 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.17 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.16 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.15 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb
flydata-0.7.14 lib/flydata/source_mysql/plugin_support/alter_table_query_handler.rb