in reply to Re: DBIx::Class and locking tables
in thread DBIx::Class and locking tables

Thank you, problem solved. That was really what I wanted. It's done a bit differently, but now it was easy.

There is one thing. Generated SQL sometimes refers to table by it's name and sometimes by alias 'me'. I had to lock the table as itself and with alias, but then it worked.

My code:

my $res = $schema->storage->dbh_do(sub { my ($storage, $dbh) = @_; $dbh->do(" LOCK TABLES tbl AS tbl WRITE, tbl AS me WRITE "); }); # now use locked tables as usual

Unlocking is done the same way.

ico