[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Regarding Transactions that span Multiple files



Mohammed Muneer wrote:
Create Env   - staff
Create Env   - payroll

Create Txn_staff
Create Txn_payroll

Begin write transaction for Txn_staff

Insert staff data

                 Set Txn_payroll parent to Txn_staff
                 Begin write transaction for Txn_payroll

                 Insert payroll data

                 Commit Txn_payroll

Commit Txn_staff


------------------------------------------------------------------

Can the above Pseudocode work in lmdb ? Or in other words
can a transactions span multiple env's?

No. But a single env can contain multiple DBs, and a txn can span multiple DBs within the same env:

Create Env
Create DB - staff
Create DB - payroll

mdb_txn_begin(env, NULL /*parent*/, &txn_staff) - 1st write txn
insert staff data
   mdb_txn_begin(env, txn_staff /*parent*/, &txn_payroll)
   insert payroll data
   mdb_txn_commit(txn_payroll)
mdb_txn_commit(txn_staff)

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/