Class/Module Index [+]

Quicksearch

Sequel::MySQL::DatabaseMethods

Methods shared by Database instances that connect to MySQL, currently supported by the native and JDBC adapters.

Public Instance Methods

cast_type_literal(type) click to toggle source

MySQL's cast rules are restrictive in that you can't just cast to any possible database type.

# File lib/sequel/adapters/shared/mysql.rb, line 39
def cast_type_literal(type)
  CAST_TYPES[type] || super
end
commit_prepared_transaction(transaction_id) click to toggle source

Commit an existing prepared transaction with the given transaction identifier string.

# File lib/sequel/adapters/shared/mysql.rb, line 45
def commit_prepared_transaction(transaction_id)
  run("XA COMMIT #{literal(transaction_id)}")
end
database_type() click to toggle source

MySQL uses the :mysql database type

# File lib/sequel/adapters/shared/mysql.rb, line 50
def database_type
  :mysql
end
indexes(table, opts={}) click to toggle source

Use SHOW INDEX FROM to get the index information for the table.

By default partial indexes are not included, you can use the option :partial to override this.

# File lib/sequel/adapters/shared/mysql.rb, line 59
def indexes(table, opts={})
  indexes = {}
  remove_indexes = []
  m = output_identifier_meth
  im = input_identifier_meth
  metadata_dataset.with_sql("SHOW INDEX FROM ?", SQL::Identifier.new(im.call(table))).each do |r|
    name = r[:Key_name]
    next if name == PRIMARY
    name = m.call(name)
    remove_indexes << name if r[:Sub_part] && ! opts[:partial]
    i = indexes[name] ||= {:columns=>[], :unique=>r[:Non_unique] != 1}
    i[:columns] << m.call(r[:Column_name])
  end
  indexes.reject{|k,v| remove_indexes.include?(k)}
end
rollback_prepared_transaction(transaction_id) click to toggle source

Rollback an existing prepared transaction with the given transaction identifier string.

# File lib/sequel/adapters/shared/mysql.rb, line 77
def rollback_prepared_transaction(transaction_id)
  run("XA ROLLBACK #{literal(transaction_id)}")
end
server_version() click to toggle source

Get version of MySQL server, used for determined capabilities.

# File lib/sequel/adapters/shared/mysql.rb, line 82
def server_version
  m = /(\d+)\.(\d+)\.(\d+)/.match(get(SQL::Function.new(:version)))
  @server_version ||= (m[1].to_i * 10000) + (m[2].to_i * 100) + m[3].to_i
end
supports_create_table_if_not_exists?() click to toggle source

MySQL supports CREATE TABLE IF NOT EXISTS syntax.

# File lib/sequel/adapters/shared/mysql.rb, line 88
def supports_create_table_if_not_exists?
  true
end
supports_prepared_transactions?() click to toggle source

MySQL supports prepared transactions (two-phase commit) using XA

# File lib/sequel/adapters/shared/mysql.rb, line 93
def supports_prepared_transactions?
  true
end
supports_savepoints?() click to toggle source

MySQL supports savepoints

# File lib/sequel/adapters/shared/mysql.rb, line 98
def supports_savepoints?
  true
end
supports_transaction_isolation_levels?() click to toggle source

MySQL supports transaction isolation levels

# File lib/sequel/adapters/shared/mysql.rb, line 103
def supports_transaction_isolation_levels?
  true
end
tables(opts={}) click to toggle source

Return an array of symbols specifying table names in the current database.

Options:

  • :server - Set the server to use

# File lib/sequel/adapters/shared/mysql.rb, line 111
def tables(opts={})
  full_tables('BASE TABLE', opts)
end
use(db_name) click to toggle source

Changes the database in use by issuing a USE statement. I would be very careful if I used this.

# File lib/sequel/adapters/shared/mysql.rb, line 117
def use(db_name)
  disconnect
  @opts[:database] = db_name if self << "USE #{db_name}"
  @schemas = {}
  self
end
views(opts={}) click to toggle source

Return an array of symbols specifying view names in the current database.

Options:

  • :server - Set the server to use

# File lib/sequel/adapters/shared/mysql.rb, line 128
def views(opts={})
  full_tables('VIEW', opts)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.