1/* txn-table.h : internal interface to ops on `transactions' table
2 *
3 * ====================================================================
4 *    Licensed to the Apache Software Foundation (ASF) under one
5 *    or more contributor license agreements.  See the NOTICE file
6 *    distributed with this work for additional information
7 *    regarding copyright ownership.  The ASF licenses this file
8 *    to you under the Apache License, Version 2.0 (the
9 *    "License"); you may not use this file except in compliance
10 *    with the License.  You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 *    Unless required by applicable law or agreed to in writing,
15 *    software distributed under the License is distributed on an
16 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 *    KIND, either express or implied.  See the License for the
18 *    specific language governing permissions and limitations
19 *    under the License.
20 * ====================================================================
21 */
22
23#ifndef SVN_LIBSVN_FS_TXN_TABLE_H
24#define SVN_LIBSVN_FS_TXN_TABLE_H
25
26#include "svn_fs.h"
27#include "svn_error.h"
28#include "../trail.h"
29#include "../fs.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif /* __cplusplus */
34
35
36/* Open a `transactions' table in ENV.  If CREATE is non-zero, create
37   one if it doesn't exist.  Set *TRANSACTIONS_P to the new table.
38   Return a Berkeley DB error code.  */
39int svn_fs_bdb__open_transactions_table(DB **transactions_p,
40                                        DB_ENV *env,
41                                        svn_boolean_t create);
42
43
44/* Create a new transaction in FS as part of TRAIL, with an initial
45   root and base root ID of ROOT_ID.  Set *TXN_NAME_P to the name of the
46   new transaction, allocated in POOL.  */
47svn_error_t *svn_fs_bdb__create_txn(const char **txn_name_p,
48                                    svn_fs_t *fs,
49                                    const svn_fs_id_t *root_id,
50                                    trail_t *trail,
51                                    apr_pool_t *pool);
52
53
54/* Remove the transaction whose name is TXN_NAME from the `transactions'
55   table of FS, as part of TRAIL.
56
57   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
58   transaction that has already been committed.  */
59svn_error_t *svn_fs_bdb__delete_txn(svn_fs_t *fs,
60                                    const char *txn_name,
61                                    trail_t *trail,
62                                    apr_pool_t *pool);
63
64
65/* Retrieve the transaction *TXN_P for the Subversion transaction
66   named TXN_NAME from the `transactions' table of FS, as part of
67   TRAIL.  Perform all allocations in POOL.
68
69   If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
70   the error returned.  */
71svn_error_t *svn_fs_bdb__get_txn(transaction_t **txn_p,
72                                 svn_fs_t *fs,
73                                 const char *txn_name,
74                                 trail_t *trail,
75                                 apr_pool_t *pool);
76
77
78/* Store the Subversion transaction TXN in FS with an ID of TXN_NAME as
79   part of TRAIL. */
80svn_error_t *svn_fs_bdb__put_txn(svn_fs_t *fs,
81                                 const transaction_t *txn,
82                                 const char *txn_name,
83                                 trail_t *trail,
84                                 apr_pool_t *pool);
85
86
87/* Set *NAMES_P to an array of const char * IDs (unfinished
88   transactions in FS) as part of TRAIL.  Allocate the array and the
89   names in POOL, and use POOL for any temporary allocations.  */
90svn_error_t *svn_fs_bdb__get_txn_list(apr_array_header_t **names_p,
91                                      svn_fs_t *fs,
92                                      trail_t *trail,
93                                      apr_pool_t *pool);
94
95
96#ifdef __cplusplus
97}
98#endif /* __cplusplus */
99
100#endif /* SVN_LIBSVN_FS_TXN_TABLE_H */
101