At 20:02 +0900 3/27/03, Brian Candler wrote: >The following patch adds transaction support to dbd_mysql, e.g. > > require 'dbi' > db = DBI.connect('dbi:mysql:test','foo') > db['AutoCommit'] = false > db.execute('create table foo(bar varchar(200)) type=innodb') rescue nil > > db.transaction do > p db.select_one('select count(*) from foo') > db.execute('insert into foo values (?)','hello') > p db.select_one('select count(*) from foo') > raise "hell" # does an automatic rollback > end > >It was rather too simple to implement, so I'm not sure if I'm missing >something fundamental here. I'd appreciate feedback from any other mysql >users. Transaction support was added a few weeks ago. It's not available in a release yet, but you can get it by getting the CVS distribution. You might want to have a look and see how it compares to your own changes. Comments welcome. BTW, a better list for this kind of thing is: At 10:26 +0100 3/11/03, Michael Neumann wrote: >Ruby-dbi-devel mailing list >Ruby-dbi-devel / lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/ruby-dbi-devel > >I didn't implement the read accessor, e.g. "puts db['AutoCommit']", because >I can't find a way to ask mysql to show the current AutoCommit state, and I >don't believe that keeping a parallel instance variable is a good idea. > >I had a quick look at how the pg driver implements transactions. It uses an >instance variable "@in_transaction", but this does not appear to be >necessary in mysql, as you don't need to issue an explicit 'BEGIN'. > >I did notice one odd thing in the pg driver: > > if attr =~ /^pg_/ or attr != /_/ > ^^^^^^^^^^^ > >I think that should be "attr !~ /_/" otherwise I can't see how it does >anything useful. Might be a good idea to ask this on the Ruby DBI list. > >Regards, > >Brian. > >Attachment converted: onyx3:ruby-dbi-all-mysql.patch (TEXT/R*ch) (00035E00)