📄 env_open.so
字号:
m4_comment([$Id: env_open.so,v 1.4 2002/06/24 14:51:07 bostic Exp $])m4_ref_title(m4_tam Applications, Opening the environment,, transapp/app, transapp/data_open)m4_p([dnlCreating transaction-protected applications using the m4_db library isquite easy. Applications first use m4_ref(dbenv_open) to initializethe database environment. Transaction-protected applications normallyrequire all four m4_db subsystems, so the m4_ref(DB_INIT_MPOOL),m4_ref(DB_INIT_LOCK), m4_ref(DB_INIT_LOG), and m4_ref(DB_INIT_TXN) flagsshould be specified.])m4_p([dnlOnce the application has called m4_ref(dbenv_open), it opens itsdatabases within the environment. Once the databases are opened, theapplication makes changes to the databases inside of transactions. Eachset of changes that entails a unit of work should be surrounded by theappropriate m4_ref(txn_begin), m4_ref(txn_commit), and m4_ref(txn_abort)calls. The m4_db access methods will make the appropriate calls intothe Lock, Log and Memory Pool subsystems in order to guaranteetransaction semantics. When the application is ready to exit, alloutstanding transactions should have been committed or aborted.])m4_p([dnlDatabases accessed by a transaction must not be closed during thetransaction. Once all outstanding transactions are finished, all openm4_db files should be closed. When the m4_db database files have beenclosed, the environment should be closed by callingm4_ref(dbenv_close).])m4_p([dnlThe following code fragment creates the database environment directorythen opens the environment, running recovery. Our m4_ref(DbEnv)database environment handle is declared to be free-threaded using them4_ref(DB_THREAD) flag, and so may be used by any number of threads thatwe may subsequently create.])include(ref/transapp/env_open.cs)m4_p([dnlAfter running this initial program, we can use the m4_ref(db_stat)utility to display the contents of the environment directory:])m4_indent([dnlprompt__GT__ db_stat -e -h TXNAPP3.2.1 Environment version.120897 Magic number.0 Panic value.1 References.6 Locks granted without waiting.0 Locks granted after waiting.=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Mpool Region: 4.264KB Size (270336 bytes).-1 Segment ID.1 Locks granted without waiting.0 Locks granted after waiting.=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Log Region: 3.96KB Size (98304 bytes).-1 Segment ID.3 Locks granted without waiting.0 Locks granted after waiting.=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Lock Region: 2.240KB Size (245760 bytes).-1 Segment ID.1 Locks granted without waiting.0 Locks granted after waiting.=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Txn Region: 5.8KB Size (8192 bytes).-1 Segment ID.1 Locks granted without waiting.0 Locks granted after waiting.])m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -