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:.
-
#get_result ⇒ Object
Retrieve a #send_query result set.
-
#initialized? ⇒ Boolean
Only support deferring connections once the framework has been initialized.
-
#open_transactions? ⇒ Boolean
Are there any open transactions ?.
-
#send_query(sql, name = nil, skip_logging = false) ⇒ Object
Send a query in an async non-blocking manner.
-
#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.
65 66 67 68 69 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 65 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.
74 75 76 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 74 def deferrable_sql?( sql ) sql =~ DEFERRABLE_SQL end |
#execute(sql, name = nil, skip_logging = false) ⇒ Object
:nodoc:
53 54 55 56 57 58 59 60 61 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 53 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 |
#get_result ⇒ Object
Retrieve a #send_query result set
49 50 51 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 49 def get_result @connection.get_result end |
#initialized? ⇒ Boolean
Only support deferring connections once the framework has been initialized.
80 81 82 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 80 def initialized? Object.const_defined?( 'Rails' ) && ::Rails.initialized? end |
#open_transactions? ⇒ Boolean
Are there any open transactions ?
86 87 88 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 86 def open_transactions? open_transactions != 0 end |
#send_query(sql, name = nil, skip_logging = false) ⇒ Object
Send a query in an async non-blocking manner
37 38 39 40 41 42 43 44 45 |
# File 'lib/active_record/connection_adapters/mysqlplus_adapter.rb', line 37 def send_query( sql, name = nil, skip_logging = false ) if skip_logging @connection.send_query( sql ) else log("(Socket #{socket.to_s}, Thread #{Thread.current.object_id.to_s}) #{sql}",name) do @connection.send_query( sql ) end end 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 |