[Nitro] Request for Transaction example

Jonathan Buch john at oxyliquit.de
Tue Jun 5 11:22:01 EDT 2007


> If I take the postgresql log output and remove the extraneous log info,
> and feed it to psql ala psql -U rthompso -f /tmp/test tbl, then selects
> return empty while it is loading, and the rollback leaves the table
> empty -- I.E. it works as expected...

That is slightly discomforting... In fact, until now I always relied on
that working!  O.O;  ... Downright disturbing..
I just did a small test and see that you're right, it in fact does not
work like expected!

irb(main):012:0> begin
irb(main):013:1* store.start
irb(main):014:1> a = User.new; a.name = 'asdf4'; a.save
irb(main):023:0* store.conn.transaction_status
=> 2 # this means inside a transaction, normal status
irb(main):015:1> store.exec "select foo blah"
irb(main):016:1> rescue Object
irb(main):017:1> end
irb(main):019:0* store.conn.transaction_status
=> 3 # This means idle inside a failed transaction
irb(main):021:0* store.rollback
irb(main):023:0* store.conn.transaction_status
=> 0 # this means not in a transaction


conn = store.conn

conn.exec "BEGIN"
conn.exec %{INSERT INTO oguser ("name") VALUES ('asdf4')}
conn.exec "ROLLBACK"

This works!

I'll have to investigate that further....


Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

More information about the Nitro-general mailing list