Sha256: 59d57c45885255d339cb526eb34d16158795fd1ff25bd3083b880661926656c3

Contents?: true

Size: 1.17 KB

Versions: 22

Compression:

Stored size: 1.17 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(normalized_query)
          if result.nil?
            $log.error("Received unsupported alter table query. normalized query:'#{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:'#{normalized_query}', raw 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

22 entries across 22 versions & 1 rubygems

Version Path
flydata-0.3.5 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.3.4 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.3.3 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.3.2 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.3.1 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.3.0 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.30 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.29 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.28 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.27 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.26 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.25 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.24 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.23 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.22 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.21 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.20 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.19 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.18 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb
flydata-0.2.17 lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb