libsvn_fs_util

Checkout Tools
  • last updated 3 hours ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates

Changeset 868265 is being indexed.

"mergeinfo" consistency: change "merge info" and "merge-info" to

"mergeinfo" in assorted error messages and comments.

  1. … 6 more files in changeset.
Followup to r28065: since we switched from using the "result" hash to

the "cache" hash, we now have to watch out for explicitly represented

negative cache results.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo): Treat NEGATIVE_CACHE_RESULT the same as

NULL.

Stylistic tweak, no functional change.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(svn_fs_mergeinfo__update_index): Add parens when passing the result

of a boolean comparison as a parameter value.

Make all sqlite-style error handling local to sqlite-util.c. The two

table-specific files now only use Subversion's error system, and only

call the sqlite_column_* APIs (which don't error) directly.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_stmt_error): Remove.

(SQLITE_ERROR_CODE, SQLITE_ERR): Move and rename from

sqlite-util.h.

(step_with_expectation): Use a more specific error message (since

it's a app-level error, not a db-level error).

(svn_fs__sqlite_exec, svn_fs__sqlite_step,

svn_fs__sqlite_bind_int64, svn_fs__sqlite_bind_text,

svn_fs__sqlite_finalize, svn_fs__sqlite_reset, check_format,

svn_fs__sqlite_open, svn_fs__sqlite_close): Adjust.

* subversion/libsvn_fs_util/sqlite-util.h

(SVN_FS__SQLITE_ERROR_CODE, SVN_FS__SQLITE_ERR): Move and rename to

sqlite-util.c.

(svn_fs__sqlite_stmt_error): Remove.

Standardize our use of sqlite3_finalize and sqlite3_reset. Use the

Subversion error system as much as possible; look up the db in the

statement.

* subversion/libsvn_fs_util/sqlite-util.h

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_reset, svn_fs__sqlite_finalize): New helpers.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo, table_has_any_rows_with_rev,

parse_mergeinfo_from_db, get_mergeinfo_for_path,

get_mergeinfo_for_children):

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin, set_origin):

Use new helpers.

Standardize our use of sqlite3_bind_*. Use the Subversion error

system as much as possible instead of passing around sqlite_result

values; hardcode arguments that are always the same; and look up the

db in the statement.

* subversion/libsvn_fs_util/sqlite-util.h

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_bind_int64, svn_fs__sqlite_bind_text): New

helpers.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo, parse_mergeinfo_from_db,

get_mergeinfo_for_path, get_mergeinfo_for_children):

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin, set_origin):

Use new helpers.

Consolidate use of sqlite3_prepare into a helper function which passes

the args that we always use, and uses our normal error system.

* subversion/libsvn_fs_util/sqlite-util.h

(svn_fs__sqlite_prepare): Declare.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_prepare): Implement.

(check_format): Use svn_fs__sqlite_prepare.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo, table_has_any_rows_with_rev,

parse_mergeinfo_from_db, get_mergeinfo_for_path,

get_mergeinfo_for_children):

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin, set_origin):

Use svn_fs__sqlite_prepare.

Standardize our use of sqlite3_step (which now only appears in one

place!). Use the Subversion error system as much as possible instead

of passing around sqlite_result values.

* subversion/libsvn_fs_util/sqlite-util.h

(svn_fs__sqlite_step_row): New helper function that runs

sqlite3_step, expecting SQLITE_ROW to be returned.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_step_done): Reimplement using step_with_expectation.

(step_with_expectation): Guts of svn_fs__sqlite_step_done, now using

svn_fs__sqlite_step.

(svn_fs__sqlite_step_row): New.

(check_format): Use new helpers.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(parse_mergeinfo_from_db): Use new helpers. Also remove a comment

about fallthrough that has been meaningless since r22184.

(get_mergeinfo_for_path, get_mergeinfo_for_children): Use new

helpers.

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin): Use new helpers.

If a call to svn_fs_mergeinfo__update_index is ultimately going to be

a no-op, don't perform any write operations at all.

The upshot of this change is that commits that don't change any

svn:mergeinfo will no longer block (or be blocked by) commands that

read from the merge tracking database.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(table_has_any_rows_with_rev): New helper function.

(clean_tables): New helper function to do the cleanup of failed

transactions, factored out of svn_fs_mergeinfo__update_index.

(svn_fs_mergeinfo__update_index): Factor out clean_tables.

* subversion/libsvn_fs_util/sqlite-util.c

* subversion/libsvn_fs_util/sqlite-util.h

(svn_fs__sqlite_step): New helper for calling sqlite3_step when you

don't know if you expect SQLITE_ROW or SQLITE_DONE.

Followup to r28077, fixing a typo.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_open): Add missing *.

Followup to r28073: set the case-sensitivity pragma at connection

time, not database initialization time.

(Note, by the way, that in addition to making the (path LIKE "foo/%")

queries correct, it also allows the sqlite query optimization to

transform them into (path >= "foo/" AND path < "foo0") and use the

index. Correctness and efficiency: two great tastes that taste great

together!)

[ Note from the future: perhaps I shouldn't brag about correctness in

revisions that don't typecheck... see r28081. ]

* subversion/libsvn_fs_util/sqlite-util.c

(schema_create_sql): Don't make LIKEs case-sensitive here...

(svn_fs__sqlite_open): ... do it here instead.

We make at least one LIKE query against paths, to find paths that are

children of a given path. This really really really needs to be

case-sensitive!

* subversion/libsvn_fs_util/sqlite-util.c

(schema_create_sql): Make all LIKEs case-sensitive when the database

is created.

Initialize all svn_merge_range_t fields in representation of "" mergeinfo.

See http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=133009

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(no_mergeinfo): Initialize the inheritable field of this svn_merge_range_t

representing mergeinfo of "" to TRUE.

Suggested by: glasser

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo) Don't use a "mergeinfo" hash as a

"mergeinfo_for_paths" hash. Just pass NULL for result and use the

"cache" argument to get your answer.

In the spirit of r28059, make sure never to do a SELECT query that

could possibly return info about an uncommitted revision.

index_path_mergeinfo wants to find out about mergeinfo that is *older*

than the revision being committed (new_rev), so it should pass

new_rev-1 to get_mergeinfo_for_path. (This shouldn't be a behavior

change, since any row with revision=new_rev was already deleted in

svn_fs_mergeinfo__update_index.)

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo): Query mergeinfo that is strictly older than

the mergeinfo we're inserting.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

Add a note at the top warning that all queries on the mergeinfo

tables must actively ensure that they don't get rows corresponding

to uncommitted revisions.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(get_mergeinfo_for_path): Redocument, and fix an internal comment.

Review by: kameshj

When a new-enough version of SQLite is detected at 'configure'-time,

employ its thread-safety runtime verification.

* build/ac-macros/sqlite.m4

(SVN_LIB_SQLITE, SVN_SQLITE_CONFIG): Test whether

sqlite3_threadsafe() is available, and if so, set

$threadsafety_runtime_check_avail to "yes". In the former macro,

record that fact by defining the

SVN_HAVE_SQLITE_THREADSAFE_PREDICATE C preprocessor token.

* subversion/libsvn_fs_util/sqlite-util.c

Include svn_types.h

(init_sqlite): Add new function which verifies that SQLite was

compiled in a thread-safe manner when

SVN_HAVE_SQLITE_THREADSAFE_PREDICATE is defined. This could

potentially also/alternately employ apr_dso_load() to check for

SQLite DLLs which have changed since compile-time.

(svn_fs__sqlite_open): Call init_sqlite(), if the library hasn't

already been initialized.

Reviewed by: glasser

philip

  1. … 1 more file in changeset.
In r27922, we started using the sqlite3_prepare_v2 API. However, this

API was only introduced in SQLite 3.3.9, which seems to be a little

too recent for comfort. This revision removes the use of

sqlite3_prepare_v2, replacing it with sqlite3_prepare. This changes

the semantics of the return value of sqlite3_step, so we now make sure

that whenever sqlite3_step has an unexpected return value, we use

sqlite3_finalize to extract a useful return value.

As a side effect, this plugs a few leaks where sqlite3_finalize calls

were missing (for example, the no-rows branch in

parse_mergeinfo_from_db).

* subversion/libsvn_fs_util/sqlite-util.h

(svn_fs__sqlite_stmt_error): Declare new helper function.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_stmt_error): Implement new helper function.

(svn_fs__sqlite_step_done, check_format): Use new helper function

and don't use _v2 API.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo, parse_mergeinfo_from_db,

get_mergeinfo_for_path, get_mergeinfo_for_path,

get_mergeinfo_for_children):

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin, set_origin):

Use new helper function and don't use _v2 API.

Audit the APR pool usage of the recursive function get_mergeinfo_for_path()

(issue #3025).

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

Include apr.h for (at least) apr_ssize_t.

(get_mergeinfo_for_path): Add documentation indicating that a

sub-pool should be used with this function.

(index_path_mergeinfo, get_mergeinfo): Introduce sub-pool for use

with the call to get_mergeinfo_for_path(), dup'ing the returned

mergeinfo hash into POOL.

(mergeinfo_hash_dup): Add new function that returns a deep copy of a

hash of paths -> mergeinfo hashes.

Suggested by: glasser

* subversion/libsvn_fs_util/sqlite-util.h

(svn_fs__sqlite_open): Document POOL usage.

Docstring Fix.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(get_mergeinfo_for_path): Fix the Docstring to document all parameters.

Suggested by: kfogel

Replace all use of apr_pool_clear and apr_pool_destroy in our

codebase with the equivalent svn_pool_* functions (consistency is

helpful).

  1. … 24 more files in changeset.
Make sure to copy a return-value string away from SQLite's memory

space.

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin): Copy returned string into a pool passed as a new

argument.

(set_origin): Take a pool argument and pass it through to

get_origin.

(svn_fs__set_node_origins, svn_fs__get_node_origin): Adjust.

Found by: pburba

Turn an overcomplicated macro into a function.

* subversion/libsvn_fs_util/sqlite-util.h

(SVN_FS__SQLITE_STEP_DONE): Remove macro, replacing with ...

(svn_fs__sqlite_step_done): ... function declaration.

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_step_done): Implement.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo): Adjust.

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(set_origin): Adjust.

  1. … 1 more file in changeset.
Make svn_fs__set_node_origins ignore errors due to a readonly

database.

I am committing a somewhat hacky change to fs-test.c to test this; I

will revert this in two revisions.

* subversion/include/private/svn_fs_node_origins.h

(svn_fs__set_node_origins): Document that in the case of a readonly

database, this function may be a no-op.

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(svn_fs__set_node_origins): If the database operations return a

"readonly" error, ignore it.

* subversion/libsvn_fs_util/sqlite-util.h

(SVN_FS__SQLITE_STEP_DONE): Make sure to finalize the statement

before returning an error; otherwise the call to sqlite3_close will

fail.

* subversion/tests/libsvn_fs/fs-test.c

Add some horribly hacky test code to wipe the node_origins table and

set it readonly a little later. Will be reverted in two revisions.

But both tests do pass.

  1. … 3 more files in changeset.
Standardize error handling in SQLite code, so that the SQLITE_READONLY

error is given a different SVN-level error code from other SQLITE

errors. This will allow caches that are "optional" to ignore errors

due to readonly filesystems while still raising more serious errors.

In order to do this, we add a few new helper macros, and make sure to

always use sqlite3_prepare_v2 instead of sqlite3_prepare; the "v2"

version returns the precise error code from sqlite3_step instead of

just returning SQLITE3_ERROR.

* subversion/include/svn_error_codes.h

(SVN_ERR_FS_SQLITE_READONLY): New error code for an attempt to write

to a read-only SQLite db.

* subversion/libsvn_fs_util/sqlite-util.h

(SVN_FS__SQLITE_ERROR_CODE): New macro to convert a SQLite error

code to a SVN error code; either the new "read-only" one or the

generic SVN_ERR_FS_SQLITE_ERROR.

(SVN_FS__SQLITE_ERR): Update to use SVN_FS__SQLITE_ERROR_CODE.

(SVN_FS__SQLITE_STEP_DONE): New macro, encapsulating a common idiom:

run the given statement for one step, throwing the appropriate

error if the statement isn't done.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(index_path_mergeinfo, parse_mergeinfo_from_db,

get_mergeinfo_for_path, get_mergeinfo_for_children):

* subversion/libsvn_fs_util/node-origins-sqlite-index.c

(get_origin, set_origin):

* subversion/libsvn_fs_util/sqlite-util.c

(svn_fs__sqlite_exec, check_format):

Update to use sqlite3_prepare_v2, SVN_FS__SQLITE_STEP_DONE, and/or

SVN_FS__SQLITE_ERROR_CODE as appropriate.

  1. … 2 more files in changeset.
* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(get_mergeinfo_for_path): Add/expand inline comments.

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(get_mergeinfo_for_path): Fix mis-handling of local variable

"parentpath" (an svn_stringbuf_t), which was not properly setting

"parentpath->len".

* subversion/libsvn_fs_util/mergeinfo-sqlite-index.c

(parse_mergeinfo_from_db): Document pool usage.