Bdb: txn.abort/txn.commit immediately exits the txn_begin block

Executing txn.abort/txn.commit within a txn_begin block immediately
exits the block.

Is this the expected behaviour? If so, then it means not all the code
in the ensure block is executed, as guaranteed.

ruby 1.8, bdb 0.4.8, libdb4.1

···

require 'bdb41’
db = BDB::Env.new(“testdb”, BDB::CREATE|BDB::INIT_TRANSACTION|BDB::THREAD)
table = db.open_db(BDB::BTREE, “test”, nil, BDB::CREATE)
db.txn_begin(table) {|txn, t|
begin
t[234]='sdfds’
rescue Exception => e
p e
ensure
puts "Aborting trans…"
txn.abort # txn.commit also produces the same result
puts "Trans aborted."
end
}
puts “Test DONE”

produces:

$ ruby1.8 storage_test.rb
Aborting trans…
Test DONE

YS.

Is this the expected behaviour?

Yes, it's implemented internally with catch/throw

Guy Decoux