hackinghat / cl-mysql

Common Lisp MySQL library
http://hackinghat.com/index.php/cl-mysql
53 stars 17 forks source link

TRANSACTION seem not to work. #9

Open snmsts opened 8 years ago

snmsts commented 8 years ago

HI, I tried the following code. And what I expected with this code was while the sleeping period, the other update should be prohibited exclusively.

(let ((cl-mysql-system:*last-database*
       (cl-mysql:connect :database "xxx" :user "root")))
  (cl-mysql:query "START TRANSACTION")
  (cl-mysql:query "SELECT x FROM c where id=1 FOR UPDATE")
  (sleep 30)
  (cl-mysql:query "UPDATE c SET x = 100 where id=1")
  (cl-mysql:query "COMMIT"))

But, It doesn't work like expected. The update executed immediately.

What's wrong with this?

rudolph-miller commented 8 years ago

Really??

I executed the code above, and I executed UPDATE c SET x = 10 WHERE id = 1 via other MySQL console while sleeping 30 secs, then I got the behavior expected (The next UPDATE query was waiting for the first transaction to finish.).