### Home Classes Methods

### In Files

- lib/sequel/adapters/shared/mysql.rb

### Methods

- #alter_table_sql
- #auto_increment_sql
- #begin_new_transaction
- #begin_transaction
- #cast_type_literal
- #column_definition_order
- #column_definition_sql
- #commit_prepared_transaction
- #commit_transaction
- #create_table_sql
- #database_type
- #full_tables
- #identifier_input_method_default
- #identifier_output_method_default
- #index_definition_sql
- #indexes
- #primary_key_from_schema
- #rollback_prepared_transaction
- #rollback_transaction
- #schema_autoincrementing_primary_key?
- #schema_parse_table
- #server_version
- #supports_create_table_if_not_exists?
- #supports_prepared_transactions?
- #supports_savepoints?
- #supports_savepoints_in_prepared_transactions?
- #supports_transaction_isolation_levels?
- #tables
- #type_literal_generic_datetime
- #type_literal_generic_file
- #type_literal_generic_time
- #type_literal_generic_trueclass
- #use
- #views

### Files

- CHANGELOG
- MIT-LICENSE
- README.rdoc
- active_record.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- cheat_sheet.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- mass_assignment.rdoc
- migration.rdoc
- model_hooks.rdoc
- opening_databases.rdoc
- prepared_statements.rdoc
- querying.rdoc
- reflection.rdoc
- 1.0.txt
- 1.1.txt
- 1.3.txt
- 1.4.0.txt
- 1.5.0.txt
- 2.0.0.txt
- 2.1.0.txt
- 2.10.0.txt
- 2.11.0.txt
- 2.12.0.txt
- 2.2.0.txt
- 2.3.0.txt
- 2.4.0.txt
- 2.5.0.txt
- 2.6.0.txt
- 2.7.0.txt
- 2.8.0.txt
- 2.9.0.txt
- 3.0.0.txt
- 3.1.0.txt
- 3.10.0.txt
- 3.11.0.txt
- 3.12.0.txt
- 3.13.0.txt
- 3.14.0.txt
- 3.15.0.txt
- 3.16.0.txt
- 3.17.0.txt
- 3.18.0.txt
- 3.19.0.txt
- 3.2.0.txt
- 3.20.0.txt
- 3.21.0.txt
- 3.22.0.txt
- 3.23.0.txt
- 3.24.0.txt
- 3.25.0.txt
- 3.26.0.txt
- 3.27.0.txt
- 3.28.0.txt
- 3.29.0.txt
- 3.3.0.txt
- 3.30.0.txt
- 3.31.0.txt
- 3.32.0.txt
- 3.33.0.txt
- 3.4.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- schema_modification.rdoc
- sharding.rdoc
- sql.rdoc
- testing.rdoc
- transactions.rdoc
- validations.rdoc
- virtual_rows.rdoc

### Class Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::ASTTransformer
- Sequel::Access
- Sequel::Access::DatabaseMethods
- Sequel::Access::DatasetMethods
- Sequel::Adapter
- Sequel::AdapterNotFound
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::ArbitraryServers
- Sequel::BasicObject
- Sequel::ColumnsIntrospection
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::DB2
- Sequel::DB2::DB2Error
- Sequel::DB2::Database
- Sequel::DB2::DatabaseMethods
- Sequel::DB2::Dataset
- Sequel::DB2::DatasetMethods
- Sequel::DBI
- Sequel::DBI::Database
- Sequel::DBI::Dataset
- Sequel::DataObjects
- Sequel::DataObjects::Database
- Sequel::DataObjects::Dataset
- Sequel::DataObjects::MySQL
- Sequel::DataObjects::MySQL::DatabaseMethods
- Sequel::DataObjects::MySQL::Dataset
- Sequel::DataObjects::Postgres
- Sequel::DataObjects::Postgres::AdapterMethods
- Sequel::DataObjects::Postgres::DatabaseMethods
- Sequel::DataObjects::Postgres::Dataset
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::DataObjects::SQLite::Dataset
- Sequel::Database
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::Dataset
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::BindArgumentMethods
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::QueryBlockCopy
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::TYPE_TRANSLATOR
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::EmulateOffsetWithRowNumber
- Sequel::Error
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::DatabaseMethods
- Sequel::Firebird::Dataset
- Sequel::Firebird::DatasetMethods
- Sequel::HookFailed
- Sequel::HookFailed
- Sequel::IBMDB
- Sequel::IBMDB::Connection
- Sequel::IBMDB::Connection::Error
- Sequel::IBMDB::Database
- Sequel::IBMDB::Dataset
- Sequel::IBMDB::Dataset::CallableStatementMethods
- Sequel::IBMDB::Dataset::PreparedStatementMethods
- Sequel::IBMDB::Statement
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::DatabaseMethods
- Sequel::Informix::Dataset
- Sequel::Informix::DatasetMethods
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::DB2
- Sequel::JDBC::DB2::DatabaseMethods
- Sequel::JDBC::DB2::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Derby
- Sequel::JDBC::Derby::DatabaseMethods
- Sequel::JDBC::Derby::Dataset
- Sequel::JDBC::Firebird
- Sequel::JDBC::Firebird::DatabaseMethods
- Sequel::JDBC::Firebird::Dataset
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::HSQLDB
- Sequel::JDBC::HSQLDB::DatabaseMethods
- Sequel::JDBC::HSQLDB::Dataset
- Sequel::JDBC::Informix
- Sequel::JDBC::Informix::DatabaseMethods
- Sequel::JDBC::Informix::Dataset
- Sequel::JDBC::JTDS
- Sequel::JDBC::JTDS::DatabaseMethods
- Sequel::JDBC::JTDS::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::MySQL::Dataset
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::AdapterMethods
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::SQLServer
- Sequel::JDBC::SQLServer::DatabaseMethods
- Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods
- Sequel::JDBC::SQLServer::Dataset
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::SQLite::Dataset
- Sequel::JDBC::Transactions
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Mock
- Sequel::Mock::Connection
- Sequel::Mock::Database
- Sequel::Mock::Dataset
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::EagerGraphLoader
- Sequel::Model::Associations::InstanceMethods
- Sequel::Model::Associations::ManyToManyAssociationReflection
- Sequel::Model::Associations::ManyToOneAssociationReflection
- Sequel::Model::Associations::OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Sequel::Model::ClassMethods
- Sequel::Model::DatasetMethods
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::DatasetMethods
- Sequel::MySQL::DatasetMethods::CallableStatementMethods
- Sequel::MySQL::DatasetMethods::PreparedStatementMethods
- Sequel::MySQL::DatasetMethods::StoredProcedureMethods
- Sequel::MySQL::PreparedStatements
- Sequel::MySQL::PreparedStatements::DatabaseMethods
- Sequel::Mysql2
- Sequel::Mysql2::Database
- Sequel::Mysql2::Dataset
- Sequel::NamedTimezones
- Sequel::NoExistingObject
- Sequel::NoExistingObject
- Sequel::NotImplemented
- Sequel::ODBC
- Sequel::ODBC::DB2
- Sequel::ODBC::DB2::DatabaseMethods
- Sequel::ODBC::DB2::Dataset
- Sequel::ODBC::Database
- Sequel::ODBC::Dataset
- Sequel::ODBC::MSSQL
- Sequel::ODBC::MSSQL::DatabaseMethods
- Sequel::ODBC::MSSQL::Dataset
- Sequel::OpenBase
- Sequel::OpenBase::Database
- Sequel::OpenBase::Dataset
- Sequel::Oracle
- Sequel::Oracle::Database
- Sequel::Oracle::DatabaseMethods
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::ClassMethods
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AssociationAutoreloading
- Sequel::Plugins::AssociationAutoreloading::ClassMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationPks::InstanceMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::BooleanReaders
- Sequel::Plugins::BooleanReaders::ClassMethods
- Sequel::Plugins::Caching
- Sequel::Plugins::Caching::ClassMethods
- Sequel::Plugins::Caching::InstanceMethods
- Sequel::Plugins::ClassTableInheritance
- Sequel::Plugins::ClassTableInheritance::ClassMethods
- Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Sequel::Plugins::Composition
- Sequel::Plugins::Composition::ClassMethods
- Sequel::Plugins::Composition::InstanceMethods
- Sequel::Plugins::DatasetAssociations
- Sequel::Plugins::DatasetAssociations::ClassMethods
- Sequel::Plugins::DatasetAssociations::DatasetMethods
- Sequel::Plugins::DefaultsSetter
- Sequel::Plugins::DefaultsSetter::ClassMethods
- Sequel::Plugins::DefaultsSetter::InstanceMethods
- Sequel::Plugins::ForceEncoding
- Sequel::Plugins::ForceEncoding::ClassMethods
- Sequel::Plugins::ForceEncoding::InstanceMethods
- Sequel::Plugins::HookClassMethods
- Sequel::Plugins::HookClassMethods::ClassMethods
- Sequel::Plugins::HookClassMethods::InstanceMethods
- Sequel::Plugins::IdentityMap
- Sequel::Plugins::IdentityMap::ClassMethods
- Sequel::Plugins::IdentityMap::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::JsonSerializer
- Sequel::Plugins::JsonSerializer::ClassMethods
- Sequel::Plugins::JsonSerializer::DatasetMethods
- Sequel::Plugins::JsonSerializer::InstanceMethods
- Sequel::Plugins::JsonSerializer::Literal
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::List
- Sequel::Plugins::List::ClassMethods
- Sequel::Plugins::List::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::DatasetMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::PreparedStatements
- Sequel::Plugins::PreparedStatements::ClassMethods
- Sequel::Plugins::PreparedStatements::InstanceMethods
- Sequel::Plugins::PreparedStatementsAssociations
- Sequel::Plugins::PreparedStatementsAssociations::ClassMethods
- Sequel::Plugins::PreparedStatementsAssociations::InstanceMethods
- Sequel::Plugins::PreparedStatementsSafe
- Sequel::Plugins::PreparedStatementsSafe::ClassMethods
- Sequel::Plugins::PreparedStatementsSafe::InstanceMethods
- Sequel::Plugins::PreparedStatementsWithPk
- Sequel::Plugins::PreparedStatementsWithPk::ClassMethods
- Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::SerializationModificationDetection
- Sequel::Plugins::SerializationModificationDetection::InstanceMethods
- Sequel::Plugins::Sharding
- Sequel::Plugins::Sharding::ClassMethods
- Sequel::Plugins::Sharding::DatasetMethods
- Sequel::Plugins::Sharding::InstanceMethods
- Sequel::Plugins::SingleTableInheritance
- Sequel::Plugins::SingleTableInheritance::ClassMethods
- Sequel::Plugins::SingleTableInheritance::InstanceMethods
- Sequel::Plugins::SkipCreateRefresh
- Sequel::Plugins::SkipCreateRefresh::InstanceMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::InstanceMethods
- Sequel::Plugins::Subclasses
- Sequel::Plugins::Subclasses::ClassMethods
- Sequel::Plugins::TacticalEagerLoading
- Sequel::Plugins::TacticalEagerLoading::DatasetMethods
- Sequel::Plugins::TacticalEagerLoading::InstanceMethods
- Sequel::Plugins::Timestamps
- Sequel::Plugins::Timestamps::ClassMethods
- Sequel::Plugins::Timestamps::InstanceMethods
- Sequel::Plugins::Touch
- Sequel::Plugins::Touch::ClassMethods
- Sequel::Plugins::Touch::InstanceMethods
- Sequel::Plugins::Tree
- Sequel::Plugins::Tree::ClassMethods
- Sequel::Plugins::Tree::InstanceMethods
- Sequel::Plugins::Tree::SingleRoot
- Sequel::Plugins::Tree::SingleRoot::ClassMethods
- Sequel::Plugins::Tree::SingleRoot::InstanceMethods
- Sequel::Plugins::Tree::TreeMultipleRootError
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- Sequel::Plugins::UpdatePrimaryKey::ClassMethods
- Sequel::Plugins::UpdatePrimaryKey::InstanceMethods
- Sequel::Plugins::ValidationClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Sequel::Plugins::ValidationClassMethods::InstanceMethods
- Sequel::Plugins::ValidationHelpers
- Sequel::Plugins::ValidationHelpers::InstanceMethods
- Sequel::Plugins::XmlSerializer
- Sequel::Plugins::XmlSerializer::ClassMethods
- Sequel::Plugins::XmlSerializer::DatasetMethods
- Sequel::Plugins::XmlSerializer::InstanceMethods
- Sequel::PoolTimeout
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::AdapterMethods
- Sequel::Postgres::DatabaseMethods
- Sequel::Postgres::DatasetMethods
- Sequel::Postgres::DatasetMethods::PreparedStatementMethods
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Qualifier
- Sequel::Rollback
- Sequel::Rollback
- Sequel::SQL
- Sequel::SQL::AliasMethods
- Sequel::SQL::AliasedExpression
- Sequel::SQL::BitwiseMethods
- Sequel::SQL::Blob
- Sequel::SQL::BooleanConstant
- Sequel::SQL::BooleanExpression
- Sequel::SQL::BooleanMethods
- Sequel::SQL::CaseExpression
- Sequel::SQL::Cast
- Sequel::SQL::CastMethods
- Sequel::SQL::ColumnAll
- Sequel::SQL::ComplexExpression
- Sequel::SQL::ComplexExpressionMethods
- Sequel::SQL::Constant
- Sequel::SQL::Constants
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericComplexExpression
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- Sequel::SQL::IdentifierMethods
- Sequel::SQL::InequalityMethods
- Sequel::SQL::JoinClause
- Sequel::SQL::JoinOnClause
- Sequel::SQL::JoinUsingClause
- Sequel::SQL::NegativeBooleanConstant
- Sequel::SQL::NoBooleanInputMethods
- Sequel::SQL::NumericExpression
- Sequel::SQL::NumericMethods
- Sequel::SQL::OrderMethods
- Sequel::SQL::OrderedExpression
- Sequel::SQL::PlaceholderLiteralString
- Sequel::SQL::QualifiedIdentifier
- Sequel::SQL::QualifyingMethods
- Sequel::SQL::StringConcatenationMethods
- Sequel::SQL::StringExpression
- Sequel::SQL::StringMethods
- Sequel::SQL::Subscript
- Sequel::SQL::SubscriptMethods
- Sequel::SQL::ValueList
- Sequel::SQL::ValueList
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQLTime
- Sequel::SQLite
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::Generator
- Sequel::ServerBlock
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::Swift
- Sequel::Swift::Database
- Sequel::Swift::Dataset
- Sequel::Swift::MySQL
- Sequel::Swift::MySQL::DatabaseMethods
- Sequel::Swift::MySQL::Dataset
- Sequel::Swift::Postgres
- Sequel::Swift::Postgres::AdapterMethods
- Sequel::Swift::Postgres::DatabaseMethods
- Sequel::Swift::Postgres::Dataset
- Sequel::Swift::SQLite
- Sequel::Swift::SQLite::DatabaseMethods
- Sequel::Swift::SQLite::Dataset
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::ThreadedServerBlock
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::TinyTDS
- Sequel::TinyTDS::Database
- Sequel::TinyTDS::Dataset
- Sequel::TinyTDS::Dataset::ArgumentMapper
- Sequel::TinyTDS::Dataset::PreparedStatementMethods
- Sequel::ToDot
- Sequel::UnbindDuplicate
- Sequel::Unbinder
- Sequel::UndefinedAssociation
- Sequel::UnthreadedServerBlock
- Sequel::ValidationFailed
- Dataset
- Dataset::ArgumentMapper
- Dataset::BindArgumentMethods
- Dataset::PreparedStatementMethods
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Proc
- Symbol
- TrueClass

No matching classes.

# Sequel::MySQL::DatabaseMethods

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

### Constants

AUTO_INCREMENT
CAST_TYPES
COLUMN_DEFINITION_ORDER
PRIMARY

### 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
    39:       def cast_type_literal(type)
    40:         CAST_TYPES[type] || super
    41:       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
    45:       def commit_prepared_transaction(transaction_id)
    46:         run("XA COMMIT #{literal(transaction_id)}")
    47:       end

database_type() click to toggle source

MySQL uses the :mysql database type

        # File lib/sequel/adapters/shared/mysql.rb, line 50
    50:       def database_type
    51:         :mysql
    52:       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
    59:       def indexes(table, opts={})
    60:         indexes = {}
    61:         remove_indexes = []
    62:         m = output_identifier_meth
    63:         im = input_identifier_meth
    64:         metadata_dataset.with_sql("SHOW INDEX FROM ?", SQL::Identifier.new(im.call(table))).each do |r|
    65:           name = r[:Key_name]
    66:           next if name == PRIMARY
    67:           name = m.call(name)
    68:           remove_indexes << name if r[:Sub_part] && ! opts[:partial]
    69:           i = indexes[name] ||= {:columns=>[], :unique=>r[:Non_unique] != 1}
    70:           i[:columns] << m.call(r[:Column_name])
    71:         end
    72:         indexes.reject{|k,v| remove_indexes.include?(k)}
    73:       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
    77:       def rollback_prepared_transaction(transaction_id)
    78:         run("XA ROLLBACK #{literal(transaction_id)}")
    79:       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
    82:       def server_version
    83:         m = /(\d+)\.(\d+)\.(\d+)/.match(get(SQL::Function.new(:version)))
    84:         @server_version ||= (m[1].to_i * 10000) + (m[2].to_i * 100) + m[3].to_i
    85:       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
    88:       def supports_create_table_if_not_exists?
    89:         true
    90:       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
    93:       def supports_prepared_transactions?
    94:         server_version >= 50000
    95:       end

supports_savepoints?() click to toggle source

MySQL supports savepoints

         # File lib/sequel/adapters/shared/mysql.rb, line 98
     98:       def supports_savepoints?
     99:         server_version >= 50000
    100:       end

supports_savepoints_in_prepared_transactions?() click to toggle source

MySQL doesn’t appear to support savepoints inside prepared transactions in >=5.5.12, see bugs.mysql.com/bug.php?id=64374

         # File lib/sequel/adapters/shared/mysql.rb, line 104
    104:       def supports_savepoints_in_prepared_transactions?
    105:         super && server_version <= 50512
    106:       end

supports_transaction_isolation_levels?() click to toggle source

MySQL supports transaction isolation levels

         # File lib/sequel/adapters/shared/mysql.rb, line 109
    109:       def supports_transaction_isolation_levels?
    110:         true
    111:       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 117
    117:       def tables(opts={})
    118:         full_tables('BASE TABLE', opts)
    119:       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 123
    123:       def use(db_name)
    124:         disconnect
    125:         @opts[:database] = db_name if self << "USE #{db_name}"
    126:         @schemas = {}
    127:         self
    128:       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 134
    134:       def views(opts={})
    135:         full_tables('VIEW', opts)
    136:       end

### Private Instance Methods

alter_table_sql(table, op) click to toggle source

Use MySQL specific syntax for rename column, set column type, and drop index cases.

         # File lib/sequel/adapters/shared/mysql.rb, line 142
    142:       def alter_table_sql(table, op)
    143:         case op[:op]
    144:         when :add_column
    145:           if related = op.delete(:table)
    146:             sql = super(table, op)
    147:             op[:table] = related
    148:             op[:key] ||= primary_key_from_schema(related)
    149:             [sql, "ALTER TABLE #{quote_schema_table(table)} ADD FOREIGN KEY (#{quote_identifier(op[:name])})#{column_references_sql(op)}"]
    150:           else
    151:             super(table, op)
    152:           end
    153:         when :rename_column, :set_column_type, :set_column_null, :set_column_default
    154:           o = op[:op]
    155:           opts = schema(table).find{|x| x.first == op[:name]}
    156:           opts = opts ? opts.last.dup : {}
    157:           opts[:name] = o == :rename_column ? op[:new_name] : op[:name]
    158:           opts[:type] = o == :set_column_type ? op[:type] : opts[:db_type]
    159:           opts[:null] = o == :set_column_null ? op[:null] : opts[:allow_null]
    160:           opts[:default] = o == :set_column_default ? op[:default] : opts[:ruby_default]
    161:           opts.delete(:default) if opts[:default] == nil
    162:           "ALTER TABLE #{quote_schema_table(table)} CHANGE COLUMN #{quote_identifier(op[:name])} #{column_definition_sql(op.merge(opts))}"
    163:         when :drop_index
    164:           "#{drop_index_sql(table, op)} ON #{quote_schema_table(table)}"
    165:         when :drop_constraint
    166:           type = case op[:type]
    167:           when :primary_key
    168:             return "ALTER TABLE #{quote_schema_table(table)} DROP PRIMARY KEY"
    169:           when :foreign_key
    170:             'FOREIGN KEY'
    171:           when :unique
    172:             'INDEX'
    173:           else
    174:             raise(Error, "must specify constraint type via :type=>(:foreign_key|:primary_key|:unique) when dropping constraints on MySQL")
    175:           end
    176:           "ALTER TABLE #{quote_schema_table(table)} DROP #{type} #{quote_identifier(op[:name])}"
    177:         when :add_constraint
    178:           if op[:type] == :foreign_key
    179:             op[:key] ||= primary_key_from_schema(op[:table])
    180:           end
    181:           super(table, op)
    182:         else
    183:           super(table, op)
    184:         end
    185:       end

auto_increment_sql() click to toggle source

Use MySQL specific AUTO_INCREMENT text.

         # File lib/sequel/adapters/shared/mysql.rb, line 188
    188:       def auto_increment_sql
    189:         AUTO_INCREMENT
    190:       end

begin_new_transaction(conn, opts) click to toggle source

MySQL needs to set transaction isolation before begining a transaction

         # File lib/sequel/adapters/shared/mysql.rb, line 193
    193:       def begin_new_transaction(conn, opts)
    194:         set_transaction_isolation(conn, opts)
    195:         log_connection_execute(conn, begin_transaction_sql)
    196:       end

begin_transaction(conn, opts={}) click to toggle source

Use XA START to start a new prepared transaction if the :prepare option is given.

         # File lib/sequel/adapters/shared/mysql.rb, line 200
    200:       def begin_transaction(conn, opts={})
    201:         if (s = opts[:prepare]) && (th = @transactions[conn])[:savepoint_level] == 0
    202:           log_connection_execute(conn, "XA START #{literal(s)}")
    203:           th[:savepoint_level] += 1
    204:         else
    205:           super
    206:         end
    207:       end

column_definition_order() click to toggle source

The order of the column definition, as an array of symbols.

         # File lib/sequel/adapters/shared/mysql.rb, line 210
    210:       def column_definition_order
    211:         COLUMN_DEFINITION_ORDER
    212:       end

column_definition_sql(column) click to toggle source

MySQL doesn’t allow default values on text columns, so ignore if it the generic text type is used

         # File lib/sequel/adapters/shared/mysql.rb, line 216
    216:       def column_definition_sql(column)
    217:         column.delete(:default) if column[:type] == File || (column[:type] == String && column[:text] == true)
    218:         super
    219:       end

commit_transaction(conn, opts={}) click to toggle source

Prepare the XA transaction for a two-phase commit if the :prepare option is given.

         # File lib/sequel/adapters/shared/mysql.rb, line 223
    223:       def commit_transaction(conn, opts={})
    224:         if (s = opts[:prepare]) && @transactions[conn][:savepoint_level] <= 1
    225:           log_connection_execute(conn, "XA END #{literal(s)}")
    226:           log_connection_execute(conn, "XA PREPARE #{literal(s)}")
    227:         else
    228:           super
    229:         end
    230:       end

create_table_sql(name, generator, options = {}) click to toggle source

Use MySQL specific syntax for engine type and character encoding

         # File lib/sequel/adapters/shared/mysql.rb, line 233
    233:       def create_table_sql(name, generator, options = {})
    234:         engine = options.fetch(:engine, Sequel::MySQL.default_engine)
    235:         charset = options.fetch(:charset, Sequel::MySQL.default_charset)
    236:         collate = options.fetch(:collate, Sequel::MySQL.default_collate)
    237:         generator.constraints.sort_by{|c| (c[:type] == :primary_key) ? 1 : 1}
    238:
    239:         key_proc = lambda do |t|
    240:           if t == name
    241:             if pk = generator.primary_key_name
    242:               [pk]
    243:             elsif !(pkc = generator.constraints.select{|con| con[:type] == :primary_key}).empty?
    244:               pkc.first[:columns]
    245:             end
    246:           else
    247:             primary_key_from_schema(t)
    248:           end
    249:         end
    250:
    251:         generator.constraints.each do |c|
    252:           if c[:type] == :foreign_key
    253:             c[:key] ||= key_proc.call(c[:table])
    254:           end
    255:         end
    256:
    257:         generator.columns.each do |c|
    258:           if t = c.delete(:table)
    259:             same_table = t == name
    260:             k = c[:key]
    261:
    262:             key ||= key_proc.call(t)
    263:
    264:             if same_table && !k.nil?
    265:               generator.constraints.unshift(:type=>:unique, :columns=>Array(k))
    266:             end
    267:
    268:             generator.foreign_key([c[:name]], t, c.merge(:name=>nil, :type=>:foreign_key, :key=>key))
    269:           end
    270:         end
    271:
    272:         "#{super}#{" ENGINE=#{engine}" if engine}#{" DEFAULT CHARSET=#{charset}" if charset}#{" DEFAULT COLLATE=#{collate}" if collate}"
    273:       end

full_tables(type, opts) click to toggle source

Backbone of the tables and views support using SHOW FULL TABLES.

         # File lib/sequel/adapters/shared/mysql.rb, line 276
    276:       def full_tables(type, opts)
    277:         m = output_identifier_meth
    278:         metadata_dataset.with_sql('SHOW FULL TABLES').server(opts[:server]).map{|r| m.call(r.values.first) if r.delete(:Table_type) == type}.compact
    279:       end

identifier_input_method_default() click to toggle source

MySQL folds unquoted identifiers to lowercase, so it shouldn’t need to upcase identifiers on input.

         # File lib/sequel/adapters/shared/mysql.rb, line 282
    282:       def identifier_input_method_default
    283:         nil
    284:       end

identifier_output_method_default() click to toggle source

MySQL folds unquoted identifiers to lowercase, so it shouldn’t need to upcase identifiers on output.

         # File lib/sequel/adapters/shared/mysql.rb, line 287
    287:       def identifier_output_method_default
    288:         nil
    289:       end

index_definition_sql(table_name, index) click to toggle source

Handle MySQL specific index SQL syntax

         # File lib/sequel/adapters/shared/mysql.rb, line 292
    292:       def index_definition_sql(table_name, index)
    293:         index_name = quote_identifier(index[:name] || default_index_name(table_name, index[:columns]))
    294:         index_type = case index[:type]
    295:         when :full_text
    296:           "FULLTEXT "
    297:         when :spatial
    298:           "SPATIAL "
    299:         else
    300:           using = " USING #{index[:type]}" unless index[:type] == nil
    301:           "UNIQUE " if index[:unique]
    302:         end
    303:         "CREATE #{index_type}INDEX #{index_name}#{using} ON #{quote_schema_table(table_name)} #{literal(index[:columns])}"
    304:       end

primary_key_from_schema(table) click to toggle source

Parse the schema for the given table to get an array of primary key columns

         # File lib/sequel/adapters/shared/mysql.rb, line 307
    307:       def primary_key_from_schema(table)
    308:         schema(table).select{|a| a[1][:primary_key]}.map{|a| a[0]}
    309:       end

rollback_transaction(conn, opts={}) click to toggle source

Rollback the currently open XA transaction

         # File lib/sequel/adapters/shared/mysql.rb, line 312
    312:       def rollback_transaction(conn, opts={})
    313:         if (s = opts[:prepare]) && @transactions[conn][:savepoint_level] <= 1
    314:           log_connection_execute(conn, "XA END #{literal(s)}")
    315:           log_connection_execute(conn, "XA PREPARE #{literal(s)}")
    316:           log_connection_execute(conn, "XA ROLLBACK #{literal(s)}")
    317:         else
    318:           super
    319:         end
    320:       end

schema_autoincrementing_primary_key?(schema) click to toggle source

MySQL treats integer primary keys as autoincrementing.

         # File lib/sequel/adapters/shared/mysql.rb, line 323
    323:       def schema_autoincrementing_primary_key?(schema)
    324:         super and schema[:db_type] =~ /int/o
    325:       end

schema_parse_table(table_name, opts) click to toggle source

Use the MySQL specific DESCRIBE syntax to get a table description.

         # File lib/sequel/adapters/shared/mysql.rb, line 328
    328:       def schema_parse_table(table_name, opts)
    329:         m = output_identifier_meth(opts[:dataset])
    330:         im = input_identifier_meth(opts[:dataset])
    331:         metadata_dataset.with_sql("DESCRIBE ?", SQL::Identifier.new(im.call(table_name))).map do |row|
    332:           row[:auto_increment] = true if row.delete(:Extra).to_s =~ /auto_increment/o
    333:           row[:allow_null] = row.delete(:Null) == 'YES'
    334:           row[:default] = row.delete(:Default)
    335:           row[:primary_key] = row.delete(:Key) == 'PRI'
    336:           row[:default] = nil if blank_object?(row[:default])
    337:           row[:db_type] = row.delete(:Type)
    338:           row[:type] = schema_column_type(row[:db_type])
    339:           [m.call(row.delete(:Field)), row]
    340:         end
    341:       end

type_literal_generic_datetime(column) click to toggle source

MySQL has both datetime and timestamp classes, most people are going to want datetime

         # File lib/sequel/adapters/shared/mysql.rb, line 361
    361:       def type_literal_generic_datetime(column)
    362:         if column[:default] == Sequel::CURRENT_TIMESTAMP
    363:           :timestamp
    364:         else
    365:           :datetime
    366:         end
    367:       end

type_literal_generic_file(column) click to toggle source

Respect the :size option if given to produce tinyblob, mediumblob, and longblob if :tiny, :medium, or :long is given.

         # File lib/sequel/adapters/shared/mysql.rb, line 346
    346:       def type_literal_generic_file(column)
    347:         case column[:size]
    348:         when :tiny    # < 2^8 bytes
    349:           :tinyblob
    350:         when :medium  # < 2^24 bytes
    351:           :mediumblob
    352:         when :long    # < 2^32 bytes
    353:           :longblob
    354:         else          # 2^16 bytes
    355:           :blob
    356:         end
    357:       end

type_literal_generic_time(column) click to toggle source

MySQL has both datetime and timestamp classes, most people are going to want datetime

         # File lib/sequel/adapters/shared/mysql.rb, line 371
    371:       def type_literal_generic_time(column)
    372:         column[:only_time] ? :time : type_literal_generic_datetime(column)
    373:       end

type_literal_generic_trueclass(column) click to toggle source

MySQL doesn’t have a true boolean class, so it uses tinyint(1)

         # File lib/sequel/adapters/shared/mysql.rb, line 376
    376:       def type_literal_generic_trueclass(column)
    377:         :'tinyint(1)'
    378:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.