head 1.2; access; symbols RPM_4_2_1:1.1.1.5 RPM_4_2:1.1.1.5 RPM_4_1_1:1.1.1.5 RPM_4_1:1.1.1.4 RPM_4_0_5:1.1.1.3 RPM_4_0_4:1.1.1.2 RPM_4_0_3:1.1.1.1 RPM:1.1.1; locks; strict; comment @# @; 1.2 date 2008.01.02.09.55.06; author rse; state dead; branches; next 1.1; commitid z4cpSiAhOCXk5PLs; 1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2002.01.08.00.30.12; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2003.01.18.13.49.02; author rse; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2001.05.13.19.58.45; author rse; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2003.01.18.14.05.00; author rse; state Exp; branches; next ; desc @@ 1.2 log @remove the ancient RPM 4.2.1 source tree copy @ text @ Berkeley DB Reference Guide: Opening databases within the environment

Berkeley DB Reference Guide:
Environment

PrevRefNext

Opening databases within the environment

Once the environment has been created, database handles may be created and then opened within the environment. This is done by calling the db_create interface and specifying the appropriate environment as an argument.

File naming, database operations, and error handling will all be done as specified for the environment. For example, if the DB_INIT_LOCK or DB_INIT_CDB flags were specified when the environment was created or joined, database operations will automatically perform all necessary locking operations for the application.

PrevRefNext

Copyright Sleepycat Software @ 1.1 log @Initial revision @ text @d1 1 a1 1 @ 1.1.1.1 log @Import: RPM 4.0.3 @ text @@ 1.1.1.2 log @Import: RPM 4.0.4 @ text @d1 1 a1 1 @ 1.1.1.3 log @Import: RPM 4.0.5 @ text @d1 2 a2 2 a3 1 d13 1 a13 1 PrevRefNext d26 1 a26 36

The following is a simple example of opening two databases within a database environment:

	DB_ENV *dbenv;
	DB *dbp1, *dbp2;
	int ret;

	/* Open an environment with just a memory pool. */
	if ((ret =
	    dbenv->open(dbenv, home, DB_CREATE | DB_INIT_MPOOL, 0)) != 0) {
		dbenv->err(dbenv, ret, "environment open: %s", home);
		return (ret);
	}

/* Open database #1. */ if ((ret = db_create(&dbp1, dbenv, 0)) != 0) { dbenv->err(dbenv, ret, "database create"); return (ret); } if ((ret = dbp1->open(dbp1, NULL, DATABASE1, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { dbenv->err(dbenv, ret, "DB->open: %s", DATABASE1); return (ret); }

/* Open database #2. */ if ((ret = db_create(&dbp2, dbenv, 0)) != 0) { dbenv->err(dbenv, ret, "database create"); return (ret); } if ((ret = dbp2->open(dbp2, NULL, DATABASE2, NULL, DB_HASH, DB_CREATE, 0664)) != 0) { dbenv->err(dbenv, ret, "DB->open: %s", DATABASE2); return (ret); }


PrevRefNext @ 1.1.1.4 log @Import: RPM 4.1 @ text @d1 2 a2 2 d4 1 d14 1 a14 1 PrevRefNext d27 36 a62 1

PrevRefNext @ 1.1.1.5 log @Import: RPM 4.1.1 @ text @d1 2 a2 2 a3 1 d13 1 a13 1 PrevRefNext d26 1 a26 36

The following is a simple example of opening two databases within a database environment:

	DB_ENV *dbenv;
	DB *dbp1, *dbp2;
	int ret;

	/* Open an environment with just a memory pool. */
	if ((ret =
	    dbenv->open(dbenv, home, DB_CREATE | DB_INIT_MPOOL, 0)) != 0) {
		dbenv->err(dbenv, ret, "environment open: %s", home);
		return (ret);
	}

/* Open database #1. */ if ((ret = db_create(&dbp1, dbenv, 0)) != 0) { dbenv->err(dbenv, ret, "database create"); return (ret); } if ((ret = dbp1->open(dbp1, NULL, DATABASE1, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { dbenv->err(dbenv, ret, "DB->open: %s", DATABASE1); return (ret); }

/* Open database #2. */ if ((ret = db_create(&dbp2, dbenv, 0)) != 0) { dbenv->err(dbenv, ret, "database create"); return (ret); } if ((ret = dbp2->open(dbp2, NULL, DATABASE2, NULL, DB_HASH, DB_CREATE, 0664)) != 0) { dbenv->err(dbenv, ret, "DB->open: %s", DATABASE2); return (ret); }


PrevRefNext @