140
141
SVN_ERR(svn_sqlite__open(sdb, sdb_abspath, smode,
141
142
my_statements ? my_statements : statements,
142
0, NULL, result_pool, scratch_pool));
143
0, NULL, timeout, result_pool, scratch_pool));
145
146
SVN_ERR(svn_sqlite__exec_statements(*sdb, STMT_PRAGMA_LOCKING_MODE));
147
148
SVN_ERR(svn_sqlite__create_scalar_function(*sdb, "relpath_depth", 1,
149
TRUE /* deterministic */,
148
150
relpath_depth_sqlite, NULL));
150
152
return SVN_NO_ERROR;
154
/* Some helpful transaction helpers.
156
Instead of directly using SQLite transactions, these wrappers
157
relieve the consumer from the need to wrap the wcroot and
158
local_relpath, which are almost always used within the transaction.
160
This also means if we later want to implement some wc_db-specific txn
161
handling, we have a convenient place to do it.
164
/* A callback which supplies WCROOTs and LOCAL_RELPATHs. */
165
typedef svn_error_t *(*db_txn_callback_t)(void *baton,
166
svn_wc__db_wcroot_t *wcroot,
167
const char *local_relpath,
168
apr_pool_t *scratch_pool);
170
/* Baton for use with run_txn() and with_db_txn(). */
173
svn_wc__db_wcroot_t *wcroot;
174
const char *local_relpath;
176
db_txn_callback_t cb_func;
181
/* Unwrap the sqlite transaction into a wc_db txn.
182
Implements svn_sqlite__transaction_callback_t. */
184
run_txn(void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool)
186
struct txn_baton_t *tb = baton;
188
return svn_error_trace(
189
tb->cb_func(tb->cb_baton, tb->wcroot, tb->local_relpath, scratch_pool));
193
/* Run CB_FUNC in a SQLite transaction with CB_BATON, using WCROOT and
194
LOCAL_RELPATH. If callbacks require additional information, they may
195
provide it using CB_BATON. */
197
svn_wc__db_with_txn(svn_wc__db_wcroot_t *wcroot,
198
const char *local_relpath,
199
svn_wc__db_txn_callback_t cb_func,
201
apr_pool_t *scratch_pool)
203
struct txn_baton_t tb;
206
tb.local_relpath = local_relpath;
207
tb.cb_func = cb_func;
208
tb.cb_baton = cb_baton;
210
return svn_error_trace(
211
svn_sqlite__with_lock(wcroot->sdb, run_txn, &tb, scratch_pool));