1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1996,2008 Oracle.  All rights reserved.
5 *
6 * $Id: txn_method.c,v 12.11 2008/01/08 20:59:00 bostic Exp $
7 */
8
9#include "db_config.h"
10
11#include "db_int.h"
12#include "dbinc/txn.h"
13
14/*
15 * __txn_env_create --
16 *	Transaction specific initialization of the DB_ENV structure.
17 *
18 * PUBLIC: int __txn_env_create __P((DB_ENV *));
19 */
20int
21__txn_env_create(dbenv)
22	DB_ENV *dbenv;
23{
24	/*
25	 * !!!
26	 * Our caller has not yet had the opportunity to reset the panic
27	 * state or turn off mutex locking, and so we can neither check
28	 * the panic state or acquire a mutex in the DB_ENV create path.
29	 */
30	dbenv->tx_max = DEF_MAX_TXNS;
31
32	return (0);
33}
34
35/*
36 * __txn_env_destroy --
37 *	Transaction specific destruction of the DB_ENV structure.
38 *
39 * PUBLIC: void __txn_env_destroy __P((DB_ENV *));
40 */
41void
42__txn_env_destroy(dbenv)
43	DB_ENV *dbenv;
44{
45	COMPQUIET(dbenv, NULL);
46}
47
48/*
49 * PUBLIC: int __txn_get_tx_max __P((DB_ENV *, u_int32_t *));
50 */
51int
52__txn_get_tx_max(dbenv, tx_maxp)
53	DB_ENV *dbenv;
54	u_int32_t *tx_maxp;
55{
56	ENV *env;
57
58	env = dbenv->env;
59
60	ENV_NOT_CONFIGURED(env,
61	    env->tx_handle, "DB_ENV->get_tx_max", DB_INIT_TXN);
62
63	if (TXN_ON(env)) {
64		/* Cannot be set after open, no lock required to read. */
65		*tx_maxp = ((DB_TXNREGION *)
66		    env->tx_handle->reginfo.primary)->maxtxns;
67	} else
68		*tx_maxp = dbenv->tx_max;
69	return (0);
70}
71
72/*
73 * __txn_set_tx_max --
74 *	DB_ENV->set_tx_max.
75 *
76 * PUBLIC: int __txn_set_tx_max __P((DB_ENV *, u_int32_t));
77 */
78int
79__txn_set_tx_max(dbenv, tx_max)
80	DB_ENV *dbenv;
81	u_int32_t tx_max;
82{
83	ENV *env;
84
85	env = dbenv->env;
86
87	ENV_ILLEGAL_AFTER_OPEN(env, "DB_ENV->set_tx_max");
88
89	dbenv->tx_max = tx_max;
90	return (0);
91}
92
93/*
94 * PUBLIC: int __txn_get_tx_timestamp __P((DB_ENV *, time_t *));
95 */
96int
97__txn_get_tx_timestamp(dbenv, timestamp)
98	DB_ENV *dbenv;
99	time_t *timestamp;
100{
101	*timestamp = dbenv->tx_timestamp;
102	return (0);
103}
104
105/*
106 * __txn_set_tx_timestamp --
107 *	Set the transaction recovery timestamp.
108 *
109 * PUBLIC: int __txn_set_tx_timestamp __P((DB_ENV *, time_t *));
110 */
111int
112__txn_set_tx_timestamp(dbenv, timestamp)
113	DB_ENV *dbenv;
114	time_t *timestamp;
115{
116	ENV *env;
117
118	env = dbenv->env;
119
120	ENV_ILLEGAL_AFTER_OPEN(env, "DB_ENV->set_tx_timestamp");
121
122	dbenv->tx_timestamp = *timestamp;
123	return (0);
124}
125