upgrade to WiredTiger version 1.3.0

Since 1.3.0 folded the session sync function into the session checkpoint
function, the wterl:sync/(2,3) functions are now renamed
wterl:checkpoint/(1,2). See
http://source.wiredtiger.com/1.3.0/upgrading.html for details.
This commit is contained in:
Steve Vinoski 2012-09-17 10:58:48 -04:00
parent 6c808da7af
commit b2807e2c14
5 changed files with 57 additions and 46 deletions

View file

@ -2,7 +2,7 @@
set -e
WT_VSN=1.2.2
WT_VSN=1.3.0
[ `basename $PWD` != "c_src" ] && cd c_src

Binary file not shown.

Binary file not shown.

View file

@ -74,6 +74,7 @@ static ERL_NIF_TERM wterl_cursor_search_near(ErlNifEnv* env, int argc, const ERL
static ERL_NIF_TERM wterl_cursor_search_worker(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[], int near);
static ERL_NIF_TERM wterl_cursor_update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_cursor_value_ret(ErlNifEnv* env, WT_CURSOR *cursor, int rc);
static ERL_NIF_TERM wterl_session_checkpoint(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_close(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_create(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_delete(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
@ -83,7 +84,6 @@ static ERL_NIF_TERM wterl_session_open(ErlNifEnv* env, int argc, const ERL_NIF_T
static ERL_NIF_TERM wterl_session_put(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_rename(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_salvage(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_sync(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_truncate(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_upgrade(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
static ERL_NIF_TERM wterl_session_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
@ -106,6 +106,7 @@ static ErlNifFunc nif_funcs[] =
{"cursor_search", 2, wterl_cursor_search},
{"cursor_search_near", 2, wterl_cursor_search_near},
{"cursor_update", 3, wterl_cursor_update},
{"session_checkpoint", 2, wterl_session_checkpoint},
{"session_close", 1, wterl_session_close},
{"session_create", 3, wterl_session_create},
{"session_delete", 3, wterl_session_delete},
@ -115,7 +116,6 @@ static ErlNifFunc nif_funcs[] =
{"session_put", 4, wterl_session_put},
{"session_rename", 4, wterl_session_rename},
{"session_salvage", 3, wterl_session_salvage},
{"session_sync", 3, wterl_session_sync},
{"session_truncate", 3, wterl_session_truncate},
{"session_upgrade", 3, wterl_session_upgrade},
{"session_verify", 3, wterl_session_verify},
@ -169,10 +169,9 @@ static ERL_NIF_TERM wterl_conn_close(ErlNifEnv* env, int argc, const ERL_NIF_TER
#define WTERL_OP_CREATE 1
#define WTERL_OP_DROP 2
#define WTERL_OP_SALVAGE 3
#define WTERL_OP_SYNC 4
#define WTERL_OP_TRUNCATE 5
#define WTERL_OP_UPGRADE 6
#define WTERL_OP_VERIFY 7
#define WTERL_OP_TRUNCATE 4
#define WTERL_OP_UPGRADE 5
#define WTERL_OP_VERIFY 6
static inline ERL_NIF_TERM wterl_session_worker(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[], int op)
{
@ -180,39 +179,36 @@ static inline ERL_NIF_TERM wterl_session_worker(ErlNifEnv* env, int argc, const
if (enif_get_resource(env, argv[0], wterl_session_RESOURCE, (void**)&session_handle))
{
WT_SESSION* session = session_handle->session;
ErlNifBinary config;
int rc;
Uri uri;
ErlNifBinary config;
if (enif_get_string(env, argv[1], uri, sizeof uri, ERL_NIF_LATIN1) &&
enif_inspect_binary(env, argv[2], &config))
{
int rc;
switch (op)
switch (op)
{
case WTERL_OP_CREATE:
rc = session->create(session, uri, (const char*)config.data);
break;
case WTERL_OP_DROP:
rc = session->drop(session, uri, (const char*)config.data);
break;
case WTERL_OP_SALVAGE:
rc = session->salvage(session, uri, (const char*)config.data);
break;
case WTERL_OP_SYNC:
rc = session->sync(session, uri, (const char*)config.data);
break;
case WTERL_OP_TRUNCATE:
// Ignore the cursor start/stop form of truncation for now,
// support only the full file truncation.
rc = session->truncate(session, uri, NULL, NULL, (const char*)config.data);
break;
case WTERL_OP_UPGRADE:
rc = session->upgrade(session, uri, (const char*)config.data);
break;
case WTERL_OP_VERIFY:
default:
rc = session->verify(session, uri, (const char*)config.data);
break;
}
case WTERL_OP_CREATE:
rc = session->create(session, uri, (const char*)config.data);
break;
case WTERL_OP_DROP:
rc = session->drop(session, uri, (const char*)config.data);
break;
case WTERL_OP_SALVAGE:
rc = session->salvage(session, uri, (const char*)config.data);
break;
case WTERL_OP_TRUNCATE:
// Ignore the cursor start/stop form of truncation for now,
// support only the full file truncation.
rc = session->truncate(session, uri, NULL, NULL, (const char*)config.data);
break;
case WTERL_OP_UPGRADE:
rc = session->upgrade(session, uri, (const char*)config.data);
break;
case WTERL_OP_VERIFY:
default:
rc = session->verify(session, uri, (const char*)config.data);
break;
}
return rc == 0 ? ATOM_OK : wterl_strerror(env, rc);
}
}
@ -291,9 +287,18 @@ static ERL_NIF_TERM wterl_session_salvage(ErlNifEnv* env, int argc, const ERL_NI
return wterl_session_worker(env, argc, argv, WTERL_OP_SALVAGE);
}
static ERL_NIF_TERM wterl_session_sync(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
static ERL_NIF_TERM wterl_session_checkpoint(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
return wterl_session_worker(env, argc, argv, WTERL_OP_SYNC);
WterlSessionHandle* session_handle;
ErlNifBinary config;
if (enif_get_resource(env, argv[0], wterl_session_RESOURCE, (void**)&session_handle) &&
enif_inspect_binary(env, argv[1], &config))
{
WT_SESSION* session = session_handle->session;
int rc = session->checkpoint(session, (const char*)config.data);
return rc == 0 ? ATOM_OK : wterl_strerror(env, rc);
}
return enif_make_badarg(env);
}
static ERL_NIF_TERM wterl_session_truncate(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])

View file

@ -36,6 +36,8 @@
cursor_search/2,
cursor_search_near/2,
cursor_update/3,
session_checkpoint/1,
session_checkpoint/2,
session_close/1,
session_create/2,
session_create/3,
@ -49,8 +51,6 @@
session_rename/4,
session_salvage/2,
session_salvage/3,
session_sync/2,
session_sync/3,
session_truncate/2,
session_truncate/3,
session_upgrade/2,
@ -156,11 +156,11 @@ session_salvage(Ref, Name) ->
session_salvage(_Ref, _Name, _Config) ->
?nif_stub.
-spec session_sync(session(), string()) -> ok | {error, term()}.
-spec session_sync(session(), string(), config()) -> ok | {error, term()}.
session_sync(Ref, Name) ->
session_sync(Ref, Name, ?EMPTY_CONFIG).
session_sync(_Ref, _Name, _Config) ->
-spec session_checkpoint(session()) -> ok | {error, term()}.
-spec session_checkpoint(session(), config()) -> ok | {error, term()}.
session_checkpoint(_Ref) ->
session_checkpoint(_Ref, ?EMPTY_CONFIG).
session_checkpoint(_Ref, _Config) ->
?nif_stub.
-spec session_truncate(session(), string()) -> ok | {error, term()}.
@ -266,6 +266,7 @@ fold(Cursor, Fun, Acc, {ok, Key, Value}) ->
config_types() ->
[{cache_size, string},
{create, bool},
{drop, list},
{error_prefix, string},
{eviction_target, integer},
{eviction_trigger, integer},
@ -276,7 +277,9 @@ config_types() ->
{home_environment_priv, bool},
{logging, bool},
{multiprocess, bool},
{name, string},
{session_max, integer},
{target, list},
{transactional, bool},
{verbose, string}].
@ -287,6 +290,8 @@ config_encode(integer, Value) ->
_:_ ->
invalid
end;
config_encode(list, Value) ->
list_to_binary(["(", string:join(Value, ","), ")"]);
config_encode(string, Value) ->
list_to_binary(Value);
config_encode(bool, true) ->
@ -404,9 +409,10 @@ various_session_test_() ->
?assertMatch({ok, <<"apple">>},
session_get(SRef, "table:test", <<"a">>))
end},
{"session sync",
{"session checkpoint",
fun() ->
?assertMatch(ok, session_sync(SRef, "table:test")),
Cfg = wterl:config_to_bin([{target, ["\"table:test\""]}]),
?assertMatch(ok, session_checkpoint(SRef, Cfg)),
?assertMatch({ok, <<"apple">>},
session_get(SRef, "table:test", <<"a">>))
end},