Sha256: d1024e573f00745c3b94bc30a6a158ba6795bb305ddcbb7396b368c2f89d958e

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

require 'flydata/parser_provider'
require 'flydata/fluent-plugins/mysql/ddl_query_handler'

module Mysql
  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 = 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) # log all alter table events even if the table is not subject to sync.  This is for troubleshooting purpose.
        ret
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
flydata-0.6.3 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.6.2 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.6.1 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.6.0 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.21 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.20 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.17 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.16 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.15 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.14 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.13 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.5.12 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb