Class: Flydata::SourceMysql::PluginSupport::DdlQueryHandler
Constant Summary
collapse
- DDL_TABLE_QUERY =
/^(?:(?:ALTER|CREATE|DROP|RENAME) +(?:\w+ +)*TABLE +([^ ]+)|TRUNCATE +(?:TABLE +)?([^ ;]+))/i
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
#context
Instance Method Summary
collapse
#pattern
#initialize
#emit_sync_records
Instance Method Details
#acceptable_db?(record) ⇒ Boolean
19
20
21
|
# File 'lib/flydata/source_mysql/plugin_support/ddl_query_handler.rb', line 19
def acceptable_db?(record)
supported_database == table_info(record)[:db_name]
end
|
#emit_record(type, record) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/flydata/source_mysql/plugin_support/ddl_query_handler.rb', line 11
def emit_record(type, record)
record['table_name'] = table_info(record)[:table_name]
super do |opt|
yield opt
end
end
|
#table_info(record) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/flydata/source_mysql/plugin_support/ddl_query_handler.rb', line 23
def table_info(record)
table_info = { db_name: record["db_name"], table_name: nil }
if DDL_TABLE_QUERY =~ record["normalized_query"]
table_name_in_query = ($1 ? $1 : $2).tr("`", "")
if (idx = table_name_in_query.index("."))
table_info[:db_name] = table_name_in_query[0...idx]
table_info[:table_name] = table_name_in_query[idx+1..-1]
else
table_info[:table_name] = table_name_in_query
end
end
table_info
end
|