In the command-line client, forbid
[svn.git] / subversion / libsvn_fs_util / sqlite-util.h
blob5500886bb12b7b1be0c4a1a5aa59a1af3a92de6b
1 /* sqlite-util.h
3 * ====================================================================
4 * Copyright (c) 2007 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
19 #ifndef SVN_LIBSVN_FS_UTIL_SQLITE_H
20 #define SVN_LIBSVN_FS_UTIL_SQLITE_H
22 #include "svn_error.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
28 typedef struct svn_fs__sqlite_stmt_t svn_fs__sqlite_stmt_t;
30 /* Steps the given statement; raises an SVN error (and finalizes the
31 statement) if it doesn't return SQLITE_DONE. */
32 svn_error_t *
33 svn_fs__sqlite_step_done(svn_fs__sqlite_stmt_t *stmt);
35 /* Steps the given statement; raises an SVN error (and finalizes the
36 statement) if it doesn't return SQLITE_ROW. */
37 svn_error_t *
38 svn_fs__sqlite_step_row(svn_fs__sqlite_stmt_t *stmt);
40 /* Steps the given statement; raises an SVN error (and finalizes the
41 statement) if it doesn't return SQLITE_DONE or SQLITE_ROW. Sets
42 *GOT_ROW to true iff it got SQLITE_ROW.
44 svn_error_t *
45 svn_fs__sqlite_step(svn_boolean_t *got_row, svn_fs__sqlite_stmt_t *stmt);
47 /* Execute SQL on the sqlite database DB, and raise an SVN error if the
48 result is not okay. */
49 svn_error_t *
50 svn_fs__sqlite_exec(sqlite3 *db, const char *sql);
52 /* Open a connection in *DB to the index database under REPOS_PATH.
53 Validate the merge schema, creating it if it doesn't yet exist.
54 This provides a migration path for pre-1.5 repositories. Perform
55 temporary allocations in POOL. */
56 svn_error_t *
57 svn_fs__sqlite_open(sqlite3 **db, const char *repos_path, apr_pool_t *pool);
59 /* Prepares TEXT as a statement in DB, returning a statement in *STMT. */
60 svn_error_t *
61 svn_fs__sqlite_prepare(svn_fs__sqlite_stmt_t **stmt, sqlite3 *db,
62 const char *text, apr_pool_t *pool);
64 /* Error-handling wrapper around sqlite3_bind_int64. */
65 svn_error_t *
66 svn_fs__sqlite_bind_int64(svn_fs__sqlite_stmt_t *stmt, int slot,
67 sqlite_int64 val);
69 /* Error-handling wrapper around sqlite3_bind_text. VAL cannot contain
70 zero bytes; we always pass SQLITE_TRANSIENT. */
71 svn_error_t *
72 svn_fs__sqlite_bind_text(svn_fs__sqlite_stmt_t *stmt, int slot,
73 const char *val);
75 /* Wrapper around sqlite3_column_text. */
76 const char *
77 svn_fs__sqlite_column_text(svn_fs__sqlite_stmt_t *stmt, int column);
79 /* Wrapper around sqlite3_column_int64. */
80 svn_revnum_t
81 svn_fs__sqlite_column_revnum(svn_fs__sqlite_stmt_t *stmt, int column);
83 /* Wrapper around sqlite3_column_int64. */
84 svn_boolean_t
85 svn_fs__sqlite_column_boolean(svn_fs__sqlite_stmt_t *stmt, int column);
87 /* Wrapper around sqlite3_column_int. */
88 int
89 svn_fs__sqlite_column_int(svn_fs__sqlite_stmt_t *stmt, int column);
91 /* Error-handling wrapper around sqlite3_finalize. */
92 svn_error_t *
93 svn_fs__sqlite_finalize(svn_fs__sqlite_stmt_t *stmt);
95 /* Error-handling wrapper around sqlite3_reset. */
96 svn_error_t *
97 svn_fs__sqlite_reset(svn_fs__sqlite_stmt_t *stmt);
99 /* Close DB, returning any ERR which may've necessitated an early connection
100 closure, or -- if none -- the error from the closure itself. */
101 svn_error_t *
102 svn_fs__sqlite_close(sqlite3 *db, svn_error_t *err);
104 #ifdef __cplusplus
106 #endif /* __cplusplus */
108 #endif /* SVN_LIBSVN_FS_UTIL_SQLITE_H */