Sha256: 95cf3d6eca1699c0c1a989f5d34e495083750b55ca96ca5cf7b5f9a520dca246

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

require 'flydata/parser_provider'
require_relative 'ddl_query_handler'

module Mysql
  class AlterTableQueryHandler < DdlQueryHandler
    PATTERN = /^ALTER TABLE/i

    def initialize(context)
      super
    end

    def pattern
      PATTERN
    end

    def process(record, normalized_query)
      emit_record(:alter_table, record) do |opt|
        ret = nil
        begin
          result = ParserProvider.parser(:mysql, :mysql_alter_table).new.parse(record['query'])
          if result.nil?
            $log.error("Received unsupported alter table query. 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. query:'#{record['query']}'
  Caused by error '#{e.to_s}'
  Stacktrace :
#{e.backtrace.join("\n")}
EOS
          $log.error(msg)
        end
        ret
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
flydata-0.2.13 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.12 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.11 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.10 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.9 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.8 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb