eZ Community » Forums » Developer » MySQL Use
expandshrink

MySQL Use

MySQL Use

Wednesday 28 July 2010 4:48:47 pm - 7 replies

Hello everyone,

I would like to know if eZPublish is using commit/rollback features (installation with mysql ormysqli).

It looks like many parts of code could use these features, but I don't find any autocommit in eZ code...

Thanks for a quick info about that. blunk.gif Emoticon

Wednesday 28 July 2010 6:05:55 pm

Yes, commit / rollback are used. We don't rollback that much, but transactions are started for most atomic operations. Most...

Wednesday 28 July 2010 9:23:27 pm

Autocommit is eanbled by default on mysql. For the oracle driver, we enable it when connecting

@bd: did you mean for most non-atomic operations? blunk.gif Emoticon

Wednesday 28 July 2010 11:21:36 pm

Thanks for the quick answer. happy.gif Emoticon

Like you wrote Gaetano, autocommit is set to On by default. For this reason I was thinking to find somewhere a "SET AUTOCOMMIT = 0" in eZ code...

Maybe Bertrand could you tell me shortly how it's working. I'm maybe just blind.

Thursday 29 July 2010 10:29:14 am

How it's working ? Well, quite manually: transactions are explicitely started when needed ($db->begin()), and ended after the transaction unsafe queries have been executed, using $db->commit(). If an error occurs on any of those queries, the transaction is automatically rollbacked.

And what I mean with non-atomic operations is... well, what it means: operations which aren't meant to be part of a transaction because they're not critically dependent on each other ?

Thursday 29 July 2010 3:24:28 pm

Thanks Bertrand,

I've seen these code lines (and use them blunk.gif Emoticon ), but I'm searching how it's working exactly with the db handler.

I've checked in lib/ezdb/classes/ezmysqlidb.php, found the query( "COMMIT" ).... but nothing to allow this COMMIT with transactions (using the set autocommit=0; stuff ).

That's the thing disturbing me.

Sorry to bug you about, and apologize for my english.
Just want to learn. blunk.gif Emoticon

Cheers
Laurent

Friday 30 July 2010 9:20:01 am

No problem whatsoever with your english, Laurent. Most of us here don't speak english as their native language anyway happy.gif Emoticon

Regarding the set autocommit part, it is a bit unrelated: we indeed don't disable autocommit, because, well, there is no need to. When a query isn't considered transaction unsafe (e.g. it can be executed independantly from the previous one), we just execute the query. Now if a set of queries are interdependant on each other, we do explicitely start a transaction ($db->begin()), and as the manual says (http://dev.mysql.com/doc/refman/5.0/en/commit.html), starting a transaction will disable autocommit.

We then just execute the "transaction unsafe" queries, and commit them using $db->commit(). If an error occurs in the transaction, the query is automatically rollbacked by the DB layer. Does it make sense ?

Friday 30 July 2010 10:57:11 am

Thanks a lot Bertrand !!!

It's now really clear. I was missing the point "With START TRANSACTION, autocommit remains disabled"

Sure it makes sense. Well done guys. blunk.gif Emoticon

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from