~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/include/private/svn_sqlite.h

  • Committer: Package Import Robot
  • Author(s): James McCoy, Peter Samuelson, James McCoy
  • Date: 2014-01-12 19:48:33 UTC
  • mfrom: (0.2.10)
  • Revision ID: package-import@ubuntu.com-20140112194833-w3axfwksn296jn5x
Tags: 1.8.5-1
[ Peter Samuelson ]
* New upstream release.  (Closes: #725787) Rediff patches:
  - Remove apr-abi1 (applied upstream), rename apr-abi2 to apr-abi
  - Remove loosen-sqlite-version-check (shouldn't be needed)
  - Remove java-osgi-metadata (applied upstream)
  - svnmucc prompts for a changelog if none is provided. (Closes: #507430)
  - Remove fix-bdb-version-detection, upstream uses "apu-config --dbm-libs"
  - Remove ruby-test-wc (applied upstream)
  - Fix “svn diff -r N file” when file has svn:mime-type set.
    (Closes: #734163)
  - Support specifying an encoding for mod_dav_svn's environment in which
    hooks are run.  (Closes: #601544)
  - Fix ordering of “svnadmin dump” paths with certain APR versions.
    (Closes: #687291)
  - Provide a better error message when authentication fails with an
    svn+ssh:// URL.  (Closes: #273874)
  - Updated Polish translations.  (Closes: #690815)

[ James McCoy ]
* Remove all traces of libneon, replaced by libserf.
* patches/sqlite_3.8.x_workaround: Upstream fix for wc-queries-test test
  failurse.
* Run configure with --with-apache-libexecdir, which allows removing part of
  patches/rpath.
* Re-enable auth-test as upstream has fixed the problem of picking up
  libraries from the environment rather than the build tree.
  (Closes: #654172)
* Point LD_LIBRARY_PATH at the built auth libraries when running the svn
  command during the build.  (Closes: #678224)
* Add a NEWS entry describing how to configure mod_dav_svn to understand
  UTF-8.  (Closes: #566148)
* Remove ancient transitional package, libsvn-ruby.
* Enable compatibility with Sqlite3 versions back to Wheezy.
* Enable hardening flags.  (Closes: #734918)
* patches/build-fixes: Enable verbose build logs.
* Build against the default ruby version.  (Closes: #722393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#endif /* __cplusplus */
38
38
 
39
39
 
 
40
/* Because the SQLite code can be inlined into libsvn_subre/sqlite.c,
 
41
   we define accessors to its compile-time and run-time version
 
42
   numbers here. */
 
43
 
 
44
/* Return the value that SQLITE_VERSION had at compile time. */
 
45
const char *svn_sqlite__compiled_version(void);
 
46
 
 
47
/* Return the value of sqlite3_libversion() at run time. */
 
48
const char *svn_sqlite__runtime_version(void);
 
49
 
 
50
 
40
51
typedef struct svn_sqlite__db_t svn_sqlite__db_t;
41
52
typedef struct svn_sqlite__stmt_t svn_sqlite__stmt_t;
42
53
typedef struct svn_sqlite__context_t svn_sqlite__context_t;
85
96
svn_error_t *
86
97
svn_sqlite__update(int *affected_rows, svn_sqlite__stmt_t *stmt);
87
98
 
88
 
/* Return in *VERSION the version of the schema for the database as PATH.
89
 
   Use SCRATCH_POOL for temporary allocations. */
90
 
svn_error_t *
91
 
svn_sqlite__get_schema_version(int *version,
92
 
                               const char *path,
93
 
                               apr_pool_t *scratch_pool);
94
 
 
95
99
/* Return in *VERSION the version of the schema in DB. Use SCRATCH_POOL
96
100
   for temporary allocations.  */
97
101
svn_error_t *
99
103
                                svn_sqlite__db_t *db,
100
104
                                apr_pool_t *scratch_pool);
101
105
 
102
 
/* Set DB's schema version to VERSION. Use SCRATCH_POOL for all temporary
103
 
   allocations.  */
104
 
svn_error_t *
105
 
svn_sqlite__set_schema_version(svn_sqlite__db_t *db,
106
 
                               int version,
107
 
                               apr_pool_t *scratch_pool);
108
106
 
109
107
 
110
108
/* Open a connection in *DB to the database at PATH. Validate the schema,
164
162
   Spec  Argument type             Item type
165
163
   ----  -----------------         ---------
166
164
   n     <none, absent>            Column assignment skip
167
 
   i     apr_int64_t               Number
 
165
   d     int                       Number
 
166
   L     apr_int64_t               Number
 
167
   i     apr_int64_t               Number (deprecated format spec)
168
168
   s     const char *              String
169
169
   b     const void *              Blob data
170
170
         apr_size_t                Blob length
171
171
   r     svn_revnum_t              Revision number
172
 
   t     const svn_token_t *       Token mapping table
173
 
         int value                 Token value
 
172
   t     const svn_token_map_t *   Token mapping table
 
173
         int                       Token value
174
174
 
175
175
  Each character in FMT maps to one SQL parameter, and one or two function
176
176
  parameters, in the order they appear.
221
221
                            const apr_hash_t *props,
222
222
                            apr_pool_t *scratch_pool);
223
223
 
 
224
/* Bind a set of inherited properties to the given slot. If INHERITED_PROPS
 
225
   is NULL, then no binding will occur. INHERITED_PROPS will be stored as a
 
226
   serialized skel. */
 
227
svn_error_t *
 
228
svn_sqlite__bind_iprops(svn_sqlite__stmt_t *stmt,
 
229
                        int slot,
 
230
                        const apr_array_header_t *inherited_props,
 
231
                        apr_pool_t *scratch_pool);
 
232
 
224
233
/* Bind a checksum's value to the given slot. If CHECKSUM is NULL, then no
225
234
   binding will occur. */
226
235
svn_error_t *
237
246
*/
238
247
 
239
248
/* Wrapper around sqlite3_column_blob and sqlite3_column_bytes. The return
240
 
   value will be NULL if the column is null. If RESULT_POOL is not NULL,
241
 
   allocate the return value (if any) in it. Otherwise, the value will
242
 
   become invalid on the next invocation of svn_sqlite__column_* */
 
249
   value will be NULL if the column is null.
 
250
 
 
251
   If RESULT_POOL is not NULL, allocate the return value (if any) in it.
 
252
   If RESULT_POOL is NULL, the return value will be valid until an
 
253
   invocation of svn_sqlite__column_* performs a data type conversion (as
 
254
   described in the SQLite documentation) or the statement is stepped or
 
255
   reset or finalized. */
243
256
const void *
244
257
svn_sqlite__column_blob(svn_sqlite__stmt_t *stmt, int column,
245
258
                        apr_size_t *len, apr_pool_t *result_pool);
246
259
 
247
260
/* Wrapper around sqlite3_column_text. If the column is null, then the
248
 
   return value will be NULL. If RESULT_POOL is not NULL, allocate the
249
 
   return value (if any) in it. Otherwise, the value will become invalid
250
 
   on the next invocation of svn_sqlite__column_* */
 
261
   return value will be NULL.
 
262
 
 
263
   If RESULT_POOL is not NULL, allocate the return value (if any) in it.
 
264
   If RESULT_POOL is NULL, the return value will be valid until an
 
265
   invocation of svn_sqlite__column_* performs a data type conversion (as
 
266
   described in the SQLite documentation) or the statement is stepped or
 
267
   reset or finalized. */
251
268
const char *
252
269
svn_sqlite__column_text(svn_sqlite__stmt_t *stmt, int column,
253
270
                        apr_pool_t *result_pool);
279
296
                         int column,
280
297
                         const svn_token_map_t *map);
281
298
 
 
299
/* Fetch the word at COLUMN, look it up in the MAP, and return its value.
 
300
   Returns NULL_VAL if the column is null. MALFUNCTION is thrown if the
 
301
   column contains an unknown word.  */
 
302
int
 
303
svn_sqlite__column_token_null(svn_sqlite__stmt_t *stmt,
 
304
                              int column,
 
305
                              const svn_token_map_t *map,
 
306
                              int null_val);
 
307
 
282
308
/* Return the column as a hash of const char * => const svn_string_t *.
283
 
   If the column is null, then NULL will be stored into *PROPS. The
 
309
   If the column is null, then set *PROPS to NULL. The
284
310
   results will be allocated in RESULT_POOL, and any temporary allocations
285
311
   will be made in SCRATCH_POOL. */
286
312
svn_error_t *
290
316
                              apr_pool_t *result_pool,
291
317
                              apr_pool_t *scratch_pool);
292
318
 
 
319
/* Return the column as an array of depth-first ordered array of
 
320
   svn_prop_inherited_item_t * structures.  If the column is null, then
 
321
   set *IPROPS to NULL. The results will be allocated in RESULT_POOL,
 
322
   and any temporary allocations will be made in SCRATCH_POOL. */
 
323
svn_error_t *
 
324
svn_sqlite__column_iprops(apr_array_header_t **iprops,
 
325
                          svn_sqlite__stmt_t *stmt,
 
326
                          int column,
 
327
                          apr_pool_t *result_pool,
 
328
                          apr_pool_t *scratch_pool);
 
329
 
293
330
/* Return the column as a checksum. If the column is null, then NULL will
294
331
   be stored into *CHECKSUM. The result will be allocated in RESULT_POOL. */
295
332
svn_error_t *
343
380
svn_error_t *
344
381
svn_sqlite__finalize(svn_sqlite__stmt_t *stmt);
345
382
 
346
 
/* Error-handling wrapper around sqlite3_reset. */
 
383
/* Reset STMT by calling sqlite3_reset(), and also clear any bindings to it.
 
384
 
 
385
   Note: svn_sqlite__get_statement() calls this function automatically if
 
386
   the requested statement has been used and has not yet been reset. */
347
387
svn_error_t *
348
388
svn_sqlite__reset(svn_sqlite__stmt_t *stmt);
349
389
 
350
390
 
 
391
/* Begin a transaction in DB. */
 
392
svn_error_t *
 
393
svn_sqlite__begin_transaction(svn_sqlite__db_t *db);
 
394
 
 
395
/* Like svn_sqlite__begin_transaction(), but takes out a 'RESERVED' lock
 
396
   immediately, instead of using the default deferred locking scheme. */
 
397
svn_error_t *
 
398
svn_sqlite__begin_immediate_transaction(svn_sqlite__db_t *db);
 
399
 
 
400
/* Begin a savepoint in DB. */
 
401
svn_error_t *
 
402
svn_sqlite__begin_savepoint(svn_sqlite__db_t *db);
 
403
 
 
404
/* Commit the current transaction in DB if ERR is SVN_NO_ERROR, otherwise
 
405
 * roll back the transaction.  Return a composition of ERR and any error
 
406
 * that may occur during the commit or roll-back. */
 
407
svn_error_t *
 
408
svn_sqlite__finish_transaction(svn_sqlite__db_t *db,
 
409
                               svn_error_t *err);
 
410
 
 
411
/* Release the current savepoint in DB if EXPR is SVN_NO_ERROR, otherwise
 
412
 * roll back to the savepoint and then release it.  Return a composition of
 
413
 * ERR and any error that may occur during the release or roll-back. */
 
414
svn_error_t *
 
415
svn_sqlite__finish_savepoint(svn_sqlite__db_t *db,
 
416
                             svn_error_t *err);
 
417
 
 
418
/* Evaluate the expression EXPR within a transaction.
 
419
 *
 
420
 * Begin a transaction in DB; evaluate the expression EXPR, which would
 
421
 * typically be a function call that does some work in DB; finally commit
 
422
 * the transaction if EXPR evaluated to SVN_NO_ERROR, otherwise roll back
 
423
 * the transaction.
 
424
 */
 
425
#define SVN_SQLITE__WITH_TXN(expr, db)                                        \
 
426
  do {                                                                        \
 
427
    svn_sqlite__db_t *svn_sqlite__db = (db);                                  \
 
428
    svn_error_t *svn_sqlite__err;                                             \
 
429
                                                                              \
 
430
    SVN_ERR(svn_sqlite__begin_transaction(svn_sqlite__db));                   \
 
431
    svn_sqlite__err = (expr);                                                 \
 
432
    SVN_ERR(svn_sqlite__finish_transaction(svn_sqlite__db, svn_sqlite__err)); \
 
433
  } while (0)
 
434
 
351
435
/* Callback function to for use with svn_sqlite__with_transaction(). */
352
436
typedef svn_error_t *(*svn_sqlite__transaction_callback_t)(
353
437
  void *baton, svn_sqlite__db_t *db, apr_pool_t *scratch_pool);
362
446
                             svn_sqlite__transaction_callback_t cb_func,
363
447
                             void *cb_baton, apr_pool_t *scratch_pool);
364
448
 
 
449
/* Like SVN_SQLITE__WITH_TXN(), but takes out a 'RESERVED' lock
 
450
   immediately, instead of using the default deferred locking scheme. */
 
451
#define SVN_SQLITE__WITH_IMMEDIATE_TXN(expr, db)                              \
 
452
  do {                                                                        \
 
453
    svn_sqlite__db_t *svn_sqlite__db = (db);                                  \
 
454
    svn_error_t *svn_sqlite__err;                                             \
 
455
                                                                              \
 
456
    SVN_ERR(svn_sqlite__begin_immediate_transaction(svn_sqlite__db));         \
 
457
    svn_sqlite__err = (expr);                                                 \
 
458
    SVN_ERR(svn_sqlite__finish_transaction(svn_sqlite__db, svn_sqlite__err)); \
 
459
  } while (0)
 
460
 
365
461
/* Like svn_sqlite__with_transaction(), but takes out a 'RESERVED' lock
366
462
   immediately, instead of using the default deferred locking scheme. */
367
463
svn_error_t *
370
466
                                       void *cb_baton,
371
467
                                       apr_pool_t *scratch_pool);
372
468
 
 
469
/* Evaluate the expression EXPR within a 'savepoint'.  Savepoints can be
 
470
 * nested.
 
471
 *
 
472
 * Begin a savepoint in DB; evaluate the expression EXPR, which would
 
473
 * typically be a function call that does some work in DB; finally release
 
474
 * the savepoint if EXPR evaluated to SVN_NO_ERROR, otherwise roll back
 
475
 * to the savepoint and then release it.
 
476
 */
 
477
#define SVN_SQLITE__WITH_LOCK(expr, db)                                       \
 
478
  do {                                                                        \
 
479
    svn_sqlite__db_t *svn_sqlite__db = (db);                                  \
 
480
    svn_error_t *svn_sqlite__err;                                             \
 
481
                                                                              \
 
482
    SVN_ERR(svn_sqlite__begin_savepoint(svn_sqlite__db));                     \
 
483
    svn_sqlite__err = (expr);                                                 \
 
484
    SVN_ERR(svn_sqlite__finish_savepoint(svn_sqlite__db, svn_sqlite__err));   \
 
485
  } while (0)
373
486
 
374
487
/* Helper function to handle several SQLite operations inside a shared lock.
375
488
   This callback is similar to svn_sqlite__with_transaction(), but can be
376
 
   nested (even with a transaction) and changes in the callback are always
377
 
   committed when this function returns.
 
489
   nested (even with a transaction).
378
490
 
379
 
   For SQLite 3.6.8 and later using this function as a wrapper around a group
380
 
   of operations can give a *huge* performance boost as the shared-read lock
381
 
   will be shared over multiple statements, instead of being reobtained
382
 
   everytime, which requires disk and/or network io.
 
491
   Using this function as a wrapper around a group of operations can give a
 
492
   *huge* performance boost as the shared-read lock will be shared over
 
493
   multiple statements, instead of being reobtained every time, which may
 
494
   require disk and/or network io, depending on SQLite's locking strategy.
383
495
 
384
496
   SCRATCH_POOL will be passed to the callback (NULL is valid).
385
497