execute(sql, name = nil)

Executes the SQL statement in the context of this connection and returns the raw result from the connection adapter. Note: depending on your database connector, the result returned by this method may be manually memory managed. Consider using the exec_query wrapper instead.

insert_fixture(fixture, table_name)

Inserts the given fixture into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle). Most of adapters should implement `insert_fixtures` that leverages bulk SQL insert. We keep this method to provide fallback for databases like sqlite that do not support bulk inserts.

insert_fixtures(fixtures, table_name)

Inserts a set of fixtures into the table. Overridden in adapters that require something beyond a simple insert (eg. Oracle).

Source:

# File activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 371definsert_fixtures(fixtures, table_name)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
`insert_fixtures` is deprecated and will be removed in the next version of Rails.
Consider using `insert_fixtures_set` for performance improvement.
MSGreturniffixtures.empty?execute(build_fixture_sql(fixtures, table_name), "Fixtures Insert")
end

It is safe to call this method if a database transaction is already open, i.e. if transaction is called within another transaction block. In case of a nested call, transaction will behave as follows:

The block will be run without doing anything. All database statements that happen within the block are effectively appended to the already open database transaction.

However, if :requires_new is set, the block will be wrapped in a database savepoint acting as a sub-transaction.

Caveats

MySQL doesn't support DDL transactions. If you perform a DDL operation, then any created savepoints will be automatically released. For example, if you've created a savepoint, then you execute a CREATE TABLE statement, then the savepoint that was created will be automatically released.

This means that, on MySQL, you shouldn't execute DDL operations inside a transaction call that you know might create a savepoint. Otherwise, transaction will raise exceptions when it tries to release the already-automatically-released savepoints: