Class: ActiveRecord::ConnectionAdapters::MysqlplusAdapter
- Inherits:
-
MysqlAdapter
- Object
- MysqlAdapter
- ActiveRecord::ConnectionAdapters::MysqlplusAdapter
- Defined in:
- lib/active_record/connection_adapters/mysqlplus_adapter.rb
Constant Summary collapse
- DEFERRABLE_SQL =
/^(INSERT|UPDATE|ALTER|DROP|SELECT|DELETE|RENAME|REPLACE|TRUNCATE)/i.freeze
Instance Method Summary collapse
-
#deferrable?(sql) ⇒ Boolean
Determine if a given SQL snippet is deferrable to another Thread.
-
#deferrable_sql?(sql) ⇒ Boolean
Determine if the raw SQL can be deferred.This excludes changing users, retrieving column information, per connection configuration etc.
-
#execute(sql, name = nil, skip_logging = false) ⇒ Object
:nodoc:.
-
#initialized? ⇒ Boolean
Only support deferring connections once the framework has been initialized.
-
#open_transactions? ⇒ Boolean
Are there any open transactions ?.
-
#socket ⇒ Object
Accessor for the raw connection socket for integration with EventMachine etc.
Instance Method Details
#deferrable?(sql) ⇒ Boolean
Determine if a given SQL snippet is deferrable to another Thread.
47 48 49 50 51 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 47 def deferrable?( sql ) !open_transactions? && initialized? && deferrable_sql?( sql ) end |
#deferrable_sql?(sql) ⇒ Boolean
Determine if the raw SQL can be deferred.This excludes changing users, retrieving column information, per connection configuration etc.
56 57 58 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 56 def deferrable_sql?( sql ) sql =~ DEFERRABLE_SQL end |
#execute(sql, name = nil, skip_logging = false) ⇒ Object
:nodoc:
35 36 37 38 39 40 41 42 43 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 35 def execute(sql, name = nil, skip_logging = false) #:nodoc: if skip_logging @connection.c_async_query( sql ) else log("(Socket #{socket.to_s}, Thread #{Thread.current.object_id.to_s}) #{sql}",name) do @connection.c_async_query( sql ) end end end |
#initialized? ⇒ Boolean
Only support deferring connections once the framework has been initialized.
62 63 64 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 62 def initialized? Object.const_defined?( 'Rails' ) && ::Rails.initialized? end |
#open_transactions? ⇒ Boolean
Are there any open transactions ?
68 69 70 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 68 def open_transactions? open_transactions != 0 end |
#socket ⇒ Object
Accessor for the raw connection socket for integration with EventMachine etc.
31 32 33 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 31 def socket @connection.socket end |