Quantcast
Channel: MySQL Forums - NDB clusters
Viewing all articles
Browse latest Browse all 1560

single update - is it atomic? (1 reply)

$
0
0
Hi!

I am sure someone already asked it, but I could not find definitive clues...

I am runnig an update from php to mysql. I add or substract a given 'price' from a column called 'balance'. Value is int.

add:

UPDATE tableX SET balance = balance + price WHERE ID = Y;

substract:

UPDATE tableX SET balance = balance - price WHERE (balance - price > -1) AND (ID = Y) ;

Now. A lot of PHP threads will be doing this at the same time. Is this like transactionally safe? I mean the server has to check the balance then update it. Can another thread do an update between this two things, or not?

I forgot to mention, this will be running on NDB. The cluster database engine.

Yours Sincererly

Laszlo Balogh

Viewing all articles
Browse latest Browse all 1560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>