Class: Flydata::SourceMysql::PluginSupport::CreateTableQueryHandler

Inherits:
TableDdlQueryHandler show all
Defined in:
lib/flydata/source_mysql/plugin_support/create_table_query_handler.rb

Constant Summary collapse

PATTERN =
/^CREATE TABLE/i

Constants inherited from DdlQueryHandler

DdlQueryHandler::DDL_TABLE_QUERY

Constants included from PluginSupport::SyncRecordEmittable

PluginSupport::SyncRecordEmittable::RESPECT_ORDER, PluginSupport::SyncRecordEmittable::SEQ, PluginSupport::SyncRecordEmittable::SRC_POS, PluginSupport::SyncRecordEmittable::TABLE_NAME, PluginSupport::SyncRecordEmittable::TABLE_REV, PluginSupport::SyncRecordEmittable::TYPE, PluginSupport::SyncRecordEmittable::V

Instance Attribute Summary

Attributes included from PluginSupport::SyncRecordEmittable

#context

Instance Method Summary collapse

Methods inherited from DdlQueryHandler

#acceptable_db?, #emit_record, #table_info

Methods included from PluginSupport::SyncRecordEmittable

#emit_sync_records

Constructor Details

#initialize(context) ⇒ CreateTableQueryHandler

Returns a new instance of CreateTableQueryHandler.


10
11
12
# File 'lib/flydata/source_mysql/plugin_support/create_table_query_handler.rb', line 10

def initialize(context)
  super
end

Instance Method Details

#patternObject


14
15
16
# File 'lib/flydata/source_mysql/plugin_support/create_table_query_handler.rb', line 14

def pattern
  PATTERN
end

#process(record) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flydata/source_mysql/plugin_support/create_table_query_handler.rb', line 18

def process(record)
  if acceptable_db?(record)
    emit_record(:create_table, record) do |opt|
      table_name = table_info(record)[:table_name]
      $log.info "type:create_table table_name:'#{table_name}' query:'#{record["query"]}' binlog_pos:'#{binlog_pos(record)}'"

      opt[:increment_table_rev] = true
      { table_name: table_name, query: record["query"] }
    end
  end
end