From 780b92ada9afcf1d58085a83a0b9e6bc982203d1 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 17 Feb 2015 17:25:57 +0000 Subject: Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz. --- docs/programmer_reference/transapp_data_open.html | 81 +++++++++++++---------- 1 file changed, 47 insertions(+), 34 deletions(-) (limited to 'docs/programmer_reference/transapp_data_open.html') diff --git a/docs/programmer_reference/transapp_data_open.html b/docs/programmer_reference/transapp_data_open.html index 7315fe12..ca9ca0b4 100644 --- a/docs/programmer_reference/transapp_data_open.html +++ b/docs/programmer_reference/transapp_data_open.html @@ -14,7 +14,7 @@ -

Next, we open three databases ("color" and "fruit" and "cats"), in the -database environment. Again, our DB database handles are -declared to be free-threaded using the DB_THREAD flag, and so -may be used by any number of threads we subsequently create.

+

+ Next, we open three databases ("color" and "fruit" and + "cats"), in the database environment. Again, our DB database + handles are declared to be free-threaded using the DB_THREAD + flag, and so may be used by any number of threads we + subsequently create. +

int
 main(int argc, char *argv[])
@@ -119,8 +120,10 @@ db_open(DB_ENV *dbenv, DB **dbp, char *name, int dups)
     *dbp = db;
     return (0);
 }
-

After opening the database, we can use the db_stat utility to -display information about a database we have created:

+

+ After opening the database, we can use the db_stat utility to + display information about a database we have created: +

prompt> db_stat -h TXNAPP -d color
 53162   Btree magic number.
 8       Btree version number.
@@ -139,30 +142,40 @@ Flags:
 0       Number of tree overflow pages.
 0       Number of bytes free in tree overflow pages (0% ff).
 0       Number of pages on the free list.
-

The database open must be enclosed within a transaction in order to be -recoverable. The transaction will ensure that created files are -re-created in recovered environments (or do not appear at all). -Additional database operations or operations on other databases can be -included in the same transaction, of course. In the simple case, where -the open is the only operation in the transaction, an application can -set the DB_AUTO_COMMIT flag instead of creating and managing -its own transaction handle. The DB_AUTO_COMMIT flag will -internally wrap the operation in a transaction, simplifying application -code.

-

The previous example is the simplest case of transaction protection for -database open. Obviously, additional database operations can be done -in the scope of the same transaction. For example, an application -maintaining a list of the databases in a database environment in a -well-known file might include an update of the list in the same -transaction in which the database is created. Or, an application might -create both a primary and secondary database in a single transaction.

-

DB handles that will later be used for transactionally protected -database operations must be opened within a transaction. Specifying a -transaction handle to database operations using DB handles not -opened within a transaction will return an error. Similarly, not -specifying a transaction handle to database operations that will modify -the database, using handles that were opened within a transaction, will -also return an error.

+

+ The database open must be enclosed within a transaction in + order to be recoverable. The transaction will ensure that + created files are re-created in recovered environments (or do + not appear at all). Additional database operations or + operations on other databases can be included in the same + transaction, of course. In the simple case, where the open is + the only operation in the transaction, an application can set + the DB_AUTO_COMMIT flag instead of creating and managing its + own transaction handle. The DB_AUTO_COMMIT flag will + internally wrap the operation in a transaction, simplifying + application code. +

+

+ The previous example is the simplest case of transaction + protection for database open. Obviously, additional database + operations can be done in the scope of the same transaction. + For example, an application maintaining a list of the + databases in a database environment in a well-known file might + include an update of the list in the same transaction in which + the database is created. Or, an application might create both + a primary and secondary database in a single + transaction. +

+

+ DB handles that will later be used for transactionally + protected database operations must be opened within a + transaction. Specifying a transaction handle to database + operations using DB handles not opened within a transaction + will return an error. Similarly, not specifying a transaction + handle to database operations that will modify the database, + using handles that were opened within a transaction, will also + return an error. +