1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2000,2008 Oracle.  All rights reserved.
5 *
6 * $Id: TestGetSetMethods.cpp,v 12.8 2008/01/08 20:58:54 bostic Exp $
7 */
8
9/*
10 * Do some regression tests for simple get/set access methods
11 * on DbEnv, DbTxn, Db.  We don't currently test that they have
12 * the desired effect, only that they operate and return correctly.
13 */
14
15#include <db_cxx.h>
16#include <iostream.h>
17
18int main(int argc, char *argv[])
19{
20	try {
21		DbEnv *dbenv = new DbEnv(0);
22		DbTxn *dbtxn;
23		u_int8_t conflicts[10];
24
25		dbenv->set_error_stream(&cerr);
26		dbenv->set_timeout(0x90000000,
27				   DB_SET_LOCK_TIMEOUT);
28		dbenv->set_lg_bsize(0x1000);
29		dbenv->set_lg_dir(".");
30		dbenv->set_lg_max(0x10000000);
31		dbenv->set_lg_regionmax(0x100000);
32		dbenv->set_lk_conflicts(conflicts, sizeof(conflicts));
33		dbenv->set_lk_detect(DB_LOCK_DEFAULT);
34		dbenv->set_lk_max_lockers(100);
35		dbenv->set_lk_max_locks(10);
36		dbenv->set_lk_max_objects(1000);
37		dbenv->set_mp_mmapsize(0x10000);
38
39		// Need to open the environment so we
40		// can get a transaction.
41		//
42		dbenv->open(".", DB_CREATE | DB_INIT_TXN |
43			    DB_INIT_LOCK | DB_INIT_LOG |
44			    DB_INIT_MPOOL,
45			    0644);
46
47		dbenv->txn_begin(NULL, &dbtxn, DB_TXN_NOWAIT);
48		dbtxn->set_timeout(0xA0000000, DB_SET_TXN_TIMEOUT);
49		dbtxn->abort();
50
51		dbenv->close(0);
52
53		// We get a db, one for each type.
54		// That's because once we call (for instance)
55		// set_bt_minkey, DB 'knows' that this is a
56		// Btree Db, and it cannot be used to try Hash
57		// or Recno functions.
58		//
59		Db *db_bt = new Db(NULL, 0);
60		db_bt->set_bt_minkey(100);
61		db_bt->set_cachesize(0, 0x100000, 0);
62		db_bt->close(0);
63
64		Db *db_h = new Db(NULL, 0);
65		db_h->set_h_ffactor(0x10);
66		db_h->set_h_nelem(100);
67		db_h->set_lorder(0);
68		db_h->set_pagesize(0x10000);
69		db_h->close(0);
70
71		Db *db_re = new Db(NULL, 0);
72		db_re->set_re_delim('@');
73		db_re->set_re_pad(10);
74		db_re->set_re_source("re.in");
75		db_re->close(0);
76
77		Db *db_q = new Db(NULL, 0);
78		db_q->set_q_extentsize(200);
79		db_q->close(0);
80
81	}
82	catch (DbException &dbe) {
83		cerr << "Db Exception: " << dbe.what() << "\n";
84	}
85	return 0;
86}
87