Home > Articles > Data > MySQL

  • Print
  • + Share This
From the author of

Requirements for Transaction Support

Transaction support in DBI requires transaction capabilities in the underlying database. For MySQL, transactions appeared in version 3.23.17. However, the 3.23.xx series wasn't declared stable until version 3.23.28, so it's best to use a release at least that recent.

You also need to use table types that support transactions, and not all types do (for example, ISAM and MyISAM tables do not). The CREATE TABLE statements set up the doc_order and doc_item table as BDB tables, one of the applicable types. BDB (Berkeley DB) tables are based on work contributed by Sleepycat Software. Depending on your version of MySQL, other transaction-capable table types may be available to you as well, such as InnoDB tables, contributed by InnoBase, and Gemini tables, contributed by NuSphere. (The Gemini work is in beta at the moment, but should be ready by the time you read this.) Consult the MySQL manual to see what table types are available for performing transactions in current releases.

Finally, you need a version of DBD::mysql (the MySQL-specific DBI driver) at least as recent as 1.2216 if you want to use the DBI transaction abstraction. Earlier versions of the driver cannot handle transactions using the standard DBI mechanism (setting the AutoCommit attribute has no effect). In this case, to control transactional behavior, you have to issue SET AUTOCOMMIT, BEGIN, COMMIT, and ROLLBACK statements directly.

  • + Share This
  • 🔖 Save To Your Account