Class: Flydata::SourceMysql::PluginSupport::DropDatabaseQueryHandler

Inherits:
DatabaseDdlQueryHandler show all
Defined in:
lib/flydata/source_mysql/plugin_support/drop_database_query_handler.rb

Constant Summary collapse

PATTERN =

For MySQL, database and schema are exchangable

/^DROP (DATABASE|SCHEMA)/i

Constants inherited from DdlQueryHandler

Flydata::SourceMysql::PluginSupport::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 DatabaseDdlQueryHandler

#emit_record

Methods inherited from DdlQueryHandler

#acceptable_db?, #emit_record, #table_info

Methods included from PluginSupport::SyncRecordEmittable

#emit_sync_records

Constructor Details

#initialize(context) ⇒ DropDatabaseQueryHandler

Returns a new instance of DropDatabaseQueryHandler.



11
12
13
# File 'lib/flydata/source_mysql/plugin_support/drop_database_query_handler.rb', line 11

def initialize(context)
  super
end

Instance Method Details

#patternObject



15
16
17
# File 'lib/flydata/source_mysql/plugin_support/drop_database_query_handler.rb', line 15

def pattern
  PATTERN
end

#process(record) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/flydata/source_mysql/plugin_support/drop_database_query_handler.rb', line 19

def process(record)
  #Issuing warning message only for the current database.
  if acceptable_db?(record)   #record["db_name"] == @context.database
    $log.error("DROP DATABASE detected. A full re-sync is required to provide sync consistency. - db_name:'#{record["db_name"]}' query:'#{record["query"]}' normalized query:'#{record['normalized_query']}' binlog_pos:'#{binlog_pos(record)}'")
  end
  #NOTE: No emit_record here because this record should not be sent to data servers for now
end