class PG::Connection

def transaction

+ROLLBACK+ if any exception occurs.
and a +COMMIT+ at the end of the block, or
Executes a +BEGIN+ at the start of the block,

conn.transaction { |conn| ... } -> result of the block
call-seq:
def transaction
	rollback = false
	exec "BEGIN"
	yield(self)
rescue Exception
	rollback = true
	cancel if transaction_status == PG::PQTRANS_ACTIVE
	block
	exec "ROLLBACK"
	raise
ensure
	exec "COMMIT" unless rollback
end