module Sequel::MySQL::MysqlMysql2::DatabaseMethods

Constants

MYSQL_DATABASE_DISCONNECT_ERRORS
MYSQL_DISCONNECT_ERROR_CODES

2027 (CR_MALFORMED_PACKET) deliberately not included (protocol error, not connection error)

Public Instance Methods

call_sproc(name, opts=OPTS, &block) click to toggle source

Support stored procedures on MySQL

   # File lib/sequel/adapters/utils/mysql_mysql2.rb
37 def call_sproc(name, opts=OPTS, &block)
38   args = opts[:args] || [] 
39   execute("CALL #{name}#{args.empty? ? '()' : literal(args)}", opts.merge(:sproc=>false), &block)
40 end
execute(sql, opts=OPTS, &block) click to toggle source

Executes the given SQL using an available connection, yielding the connection if the block is given.

   # File lib/sequel/adapters/utils/mysql_mysql2.rb
44 def execute(sql, opts=OPTS, &block)
45   if opts[:sproc]
46     call_sproc(sql, opts, &block)
47   elsif sql.is_a?(Symbol) || sql.is_a?(Sequel::Dataset::ArgumentMapper)
48     execute_prepared_statement(sql, opts, &block)
49   else
50     synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}
51   end
52 end

Private Instance Methods

add_prepared_statements_cache(conn) click to toggle source
   # File lib/sequel/adapters/utils/mysql_mysql2.rb
56 def add_prepared_statements_cache(conn)
57   class << conn
58     attr_accessor :prepared_statements
59   end
60   conn.prepared_statements = {}
61 end
database_specific_error_class(exception, opts) click to toggle source
Calls superclass method
   # File lib/sequel/adapters/utils/mysql_mysql2.rb
63 def database_specific_error_class(exception, opts)
64   case exception.errno
65   when 1048
66     NotNullConstraintViolation
67   when 1062
68     UniqueConstraintViolation
69   when 1451, 1452, 1216, 1217
70     ForeignKeyConstraintViolation
71   when 4025
72     CheckConstraintViolation
73   when 1205
74     DatabaseLockTimeout
75   else
76     super
77   end
78 end