Class: BDB::Txn

### Home Classes Methods

### In Files

- transaction.rb

### Parent

Object

### Methods

- #abort
- #assoc
- #associate
- #begin
- #close
- #commit
- #dbremove
- #dbrename
- #discard
- #id
- #name
- #name=
- #open_db
- #prepare
- #txn_abort
- #txn_assoc
- #txn_begin
- #txn_close
- #txn_commit
- #txn_discard
- #txn_id
- #txn_prepare

### Class/Module Index

Quicksearch

- BDB
- BDB::Btree
- BDB::Common
- BDB::Cursor
- BDB::Env
- BDB::Hash
- BDB::Lock
- BDB::LockDead
- BDB::LockError
- BDB::LockGranted
- BDB::LockHeld
- BDB::Lockid
- BDB::Lsn
- BDB::Queue
- BDB::Recno
- BDB::Recnum
- BDB::Sequence
- BDB::Txn

No matching classes.

# BDB::Txn

The transaction subsystem makes operations atomic, consistent, isolated, and durable in the face of system and application failures. The subsystem requires that the data be properly logged and locked in order to attain these properties. Berkeley DB contains all the components necessary to transaction-protect the Berkeley DB access methods and other forms of data may be protected if they are logged and locked appropriately.

The transaction subsystem is created, initialized, and opened by calls to BDB::Env#open with the BDB::INIT_TXN flag (or BDB::INIT_TRANSACTION) specified. Note that enabling transactions automatically enables logging, but does not enable locking, as a single thread of control that needed atomicity and recoverability would not require it.

The transaction is created with BDB::Env#begin or with begin

### Public Instance Methods

abort() click to toggle source

Abort the transaction. This is will terminate the transaction.

    # File transaction.rb, line 24
    def  abort()
    end

assoc(db, ...) click to toggle source

Associate a database with the transaction, return a new database handle which is transaction protected.

    # File transaction.rb, line 33
    def  assoc(db, ...)
    end

associate(db, ...) click to toggle source

same than assoc

    # File transaction.rb, line 36
    def  associate(db, ...)
    end

begin(flags = 0, db, ...) click to toggle source

begin a transaction (the transaction manager must be enabled). flags can have the value DBD::TXN_COMMIT, in this case the transaction will be commited at end.

Return a new transaction object, and the associated database handle if specified.

If begin is called as an iterator, commit and abort will terminate the iterator.

env.begin(db) do |txn, b| ... end

is the same than

env.begin do |txn| b = txn.assoc(db) ... end

An optional hash can be given with the possible keys "flags", "set_timeout", "set_txn_timeout", "set_lock_timeout"

    # File transaction.rb, line 67
       def  begin(flags = 0, db, ...)
          yield txn, db, ...
       end
       #same than <em> begin</em>
       def  txn_begin(flags = 0, db, ...)
       end

       #Commit the transaction. This will finish the transaction.
       #The <em>flags</em> can have the value
       #
       #<em>BDB::TXN_SYNC</em> Synchronously flush the log. This means the
       #transaction will exhibit all of the ACID (atomicity, consistency
       #and isolation and durability) properties. This is the default value.
       #
       #<em>BDB::TXN_NOSYNC</em> Do not synchronously flush the log. This
       #means the transaction will exhibit the ACI (atomicity, consistency
       #and isolation) properties, but not D (durability), i.e., database
       #integrity will be maintained but it is possible that this
       #transaction may be undone during recovery instead of being redone.
       #
       #This behavior may be set for an entire Berkeley DB environment as
       #part of the open interface.
       #
       def  commit(flags = 0)
       end
       #same than <em> commit</em>
       def  close(flags = 0)
       end
       #same than <em> commit</em>
       def  txn_commit(flags = 0)
       end
       #same than <em> commit</em>
       def  txn_close(flags = 0)
       end

       #only with BDB::VERSION_MAJOR == 3 && BDB::VERSION_MINOR >= 3
       #
       #Discard a prepared but not resolved transaction handle, must be called
       #only within BDB::Env#recover
       #
       def  discard
       end
       #same than <em> discard</em>
       def  txn_discard
       end

       #only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1
       #
       #remove the database specified by <em>file</em> and <em>database</em>. If no
       #<em>database</em> is <em>nil</em>, the underlying file represented by
       #<em>file</em> is removed, incidentally removing all databases
       #that it contained.
       #
       #The <em>flags</em> value must be set to 0 or <em>BDB::AUTO_COMMIT</em>
       #
       def  dbremove(file, database = nil, flags = 0)
       end

       #only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1
       #
       #rename the database specified by <em>file</em> and <em>database</em> to
       #<em>newname</em>. If <em>database</em> is <em>nil</em>, the underlying file
       #represented by <em>file</em> is renamed, incidentally renaming all databases
       #that it contained.
       #
       #The <em>flags</em> value must be set to 0 or <em>BDB::AUTO_COMMIT</em>
       #
       def  dbrename(file, database, newname, flags = 0)
       end

       #The txn_id function returns the unique transaction id associated
       #with the specified transaction. Locking calls made on behalf of
       #this transaction should use the value returned from txn_id as the
       #locker parameter to the lock_get or lock_vec calls.
       #
       def  id()
       end
       #same than <em> id</em>
       def  txn_id()
       end

       #Only with DB >= 4.1
       #
       #open the database in the current transaction. type must be one of
       #the constant <em>BDB::BTREE</em>, <em>BDB::HASH</em>, <em>BDB::RECNO</em>,
       #<em>BDB::QUEUE</em>. See <em>open</em> for other
       #arguments
       #
       def  open_db(type, name = nil, subname = nil, flags = 0, mode = 0)
       end

       #The txn_prepare function initiates the beginning of a two-phase commit.
       #
       #In a distributed transaction environment, Berkeley DB can be used
       #as a local transaction manager. In this case, the distributed
       #transaction manager must send prepare messages to each local
       #manager. The local manager must then issue a txn_prepare and await its
       #successful return before responding to the distributed transaction
       #manager. Only after the distributed transaction manager receives
       #successful responses from all of its prepare messages should it issue
       #any commit messages.
       #
       def  prepare()
       end
       #same than <em> prepare</em>
       def  txn_prepare()
       end
       #same than <em> prepare</em>
       def  txn_prepare(id)    # version 3.3.11
       end

       #Only with DB >= 4.4
       #
       #Return the string associated with a transaction
       #
       def name
       end

       #Only with DB >= 4.4
       #
       #Set the string associated with a transaction
       #
       def name=(string)
       end

    end

close(flags = 0) click to toggle source

same than commit

    # File transaction.rb, line 93
    def  close(flags = 0)
    end

commit(flags = 0) click to toggle source

Commit the transaction. This will finish the transaction. The flags can have the value

BDB::TXN_SYNC Synchronously flush the log. This means the transaction will exhibit all of the ACID (atomicity, consistency and isolation and durability) properties. This is the default value.

BDB::TXN_NOSYNC Do not synchronously flush the log. This means the transaction will exhibit the ACI (atomicity, consistency and isolation) properties, but not D (durability), i.e., database integrity will be maintained but it is possible that this transaction may be undone during recovery instead of being redone.

This behavior may be set for an entire Berkeley DB environment as part of the open interface.

    # File transaction.rb, line 90
    def  commit(flags = 0)
    end

dbremove(file, database = nil, flags = 0) click to toggle source

only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1

remove the database specified by file and database. If no database is nil, the underlying file represented by file is removed, incidentally removing all databases that it contained.

The flags value must be set to 0 or BDB::AUTO_COMMIT

    # File transaction.rb, line 122
    def  dbremove(file, database = nil, flags = 0)
    end

dbrename(file, database, newname, flags = 0) click to toggle source

only with BDB::VERSION_MAJOR == 4 && BDB::VERSION_MINOR >= 1

rename the database specified by file and database to newname. If database is nil, the underlying file represented by file is renamed, incidentally renaming all databases that it contained.

The flags value must be set to 0 or BDB::AUTO_COMMIT

    # File transaction.rb, line 134
    def  dbrename(file, database, newname, flags = 0)
    end

discard() click to toggle source

only with BDB::VERSION_MAJOR == 3 && BDB::VERSION_MINOR >= 3

Discard a prepared but not resolved transaction handle, must be called only within BDB::Env#recover

    # File transaction.rb, line 107
    def  discard
    end

id() click to toggle source

The txn_id function returns the unique transaction id associated with the specified transaction. Locking calls made on behalf of this transaction should use the value returned from txn_id as the locker parameter to the lock_get or lock_vec calls.

    # File transaction.rb, line 142
    def  id()
    end

name() click to toggle source

Only with DB >= 4.4

Return the string associated with a transaction

    # File transaction.rb, line 182
    def name
    end

name=(string) click to toggle source

Only with DB >= 4.4

Set the string associated with a transaction

    # File transaction.rb, line 189
    def name=(string)
    end

open_db(type, name = nil, subname = nil, flags = 0, mode = 0) click to toggle source

Only with DB >= 4.1

open the database in the current transaction. type must be one of the constant BDB::BTREE, BDB::HASH, BDB::RECNO, BDB::QUEUE. See open for other arguments

    # File transaction.rb, line 155
    def  open_db(type, name = nil, subname = nil, flags = 0, mode = 0)
    end

prepare() click to toggle source

The txn_prepare function initiates the beginning of a two-phase commit.

In a distributed transaction environment, Berkeley DB can be used as a local transaction manager. In this case, the distributed transaction manager must send prepare messages to each local manager. The local manager must then issue a txn_prepare and await its successful return before responding to the distributed transaction manager. Only after the distributed transaction manager receives successful responses from all of its prepare messages should it issue any commit messages.

    # File transaction.rb, line 169
    def  prepare()
    end

txn_abort() click to toggle source

same than abort

    # File transaction.rb, line 27
    def  txn_abort()
    end

txn_assoc(db, ...) click to toggle source

same than assoc

    # File transaction.rb, line 39
    def  txn_assoc(db, ...)
    end

txn_begin(flags = 0, db, ...) click to toggle source

    # File transaction.rb, line 71
    def  txn_begin(flags = 0, db, ...)
    end

txn_close(flags = 0) click to toggle source

same than commit

    # File transaction.rb, line 99
    def  txn_close(flags = 0)
    end

txn_commit(flags = 0) click to toggle source

same than commit

    # File transaction.rb, line 96
    def  txn_commit(flags = 0)
    end

txn_discard() click to toggle source

same than discard

    # File transaction.rb, line 110
    def  txn_discard
    end

txn_id() click to toggle source

same than id

    # File transaction.rb, line 145
    def  txn_id()
    end

txn_prepare() click to toggle source

same than prepare

    # File transaction.rb, line 172
    def  txn_prepare()
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.