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"
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. */
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. */
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.
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. */
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. */
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. */
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. */
66 svn_fs__sqlite_bind_int64(svn_fs__sqlite_stmt_t
*stmt
, int slot
,
69 /* Error-handling wrapper around sqlite3_bind_text. VAL cannot contain
70 zero bytes; we always pass SQLITE_TRANSIENT. */
72 svn_fs__sqlite_bind_text(svn_fs__sqlite_stmt_t
*stmt
, int slot
,
75 /* Wrapper around sqlite3_column_text. */
77 svn_fs__sqlite_column_text(svn_fs__sqlite_stmt_t
*stmt
, int column
);
79 /* Wrapper around sqlite3_column_int64. */
81 svn_fs__sqlite_column_revnum(svn_fs__sqlite_stmt_t
*stmt
, int column
);
83 /* Wrapper around sqlite3_column_int64. */
85 svn_fs__sqlite_column_boolean(svn_fs__sqlite_stmt_t
*stmt
, int column
);
87 /* Wrapper around sqlite3_column_int. */
89 svn_fs__sqlite_column_int(svn_fs__sqlite_stmt_t
*stmt
, int column
);
91 /* Error-handling wrapper around sqlite3_finalize. */
93 svn_fs__sqlite_finalize(svn_fs__sqlite_stmt_t
*stmt
);
95 /* Error-handling wrapper around sqlite3_reset. */
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. */
102 svn_fs__sqlite_close(sqlite3
*db
, svn_error_t
*err
);
106 #endif /* __cplusplus */
108 #endif /* SVN_LIBSVN_FS_UTIL_SQLITE_H */