Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

Rollback not working (2 replies)

$
0
0
I've discovered that my application's transactions aren't working; it doesn't rollback when there's an error. Rollbacks work fine when I run them from the workbench, but not when the application tries to do them.

Below is a list of all the queries my application made in one sample transaction (with added comments). (Note I threw in a junk query in the middle to trigger its automatic rollback.) This should have added a new event (autoincremented record number was 14 in this case), done a couple other queries, and then rolled back and removed it. But afterwards I found that event 14 was still there.

What's wrong?

start transaction;

replace events (startdate,enddate,tempmax,tempmin,humiditymax,humiditymin,wind,sun,rain,weather,notes,recorddate,recordcreator,recordstatus) values('2013-06-07','2013-06-07',
'storm',0,0,0,0,False,False,False,null,null,now(),left(current_user(),locate('@',current_user())-1),'U'); #this query is fine

select last_insert_id() #newly added record is 14 (used below)

insert some bad SQL #deliberately wrong query (to trigger rollback)

update fragments set eventnum=null where eventnum=14; #this query is fine

update treatments set eventnum=null where eventnum=14; #this query is fine

rollback;

Viewing all articles
Browse latest Browse all 1954

Trending Articles



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