Module: Sequel::MySQL::MysqlMysql2::DatabaseMethods
- Included in:
- Database, Sequel::Mysql2::Database
- Defined in:
- lib/sequel/adapters/utils/mysql_mysql2.rb
Constant Summary collapse
- MYSQL_DATABASE_DISCONNECT_ERRORS =
Error messages for mysql and mysql2 that indicate the current connection should be disconnected
/\A#{Regexp.union(disconnect_errors)}/o
Instance Method Summary collapse
-
#call_sproc(name, opts = OPTS, &block) ⇒ Object
Support stored procedures on MySQL.
-
#execute(sql, opts = OPTS, &block) ⇒ Object
Executes the given SQL using an available connection, yielding the connection if the block is given.
Instance Method Details
#call_sproc(name, opts = OPTS, &block) ⇒ Object
Support stored procedures on MySQL
23 24 25 26 |
# File 'lib/sequel/adapters/utils/mysql_mysql2.rb', line 23 def call_sproc(name, opts=OPTS, &block) args = opts[:args] || [] execute("CALL #{name}#{args.empty? ? '()' : literal(args)}", opts.merge(:sproc=>false), &block) end |
#execute(sql, opts = OPTS, &block) ⇒ Object
Executes the given SQL using an available connection, yielding the connection if the block is given.
30 31 32 33 34 35 36 37 38 |
# File 'lib/sequel/adapters/utils/mysql_mysql2.rb', line 30 def execute(sql, opts=OPTS, &block) if opts[:sproc] call_sproc(sql, opts, &block) elsif sql.is_a?(Symbol) execute_prepared_statement(sql, opts, &block) else synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)} end end |