summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_posix/Make.base1
-rw-r--r--dist/api_data.py1
-rw-r--r--dist/filelist1
-rw-r--r--docs/src/command-line.dox15
-rw-r--r--src/btree/bt_handle.c10
-rw-r--r--src/btree/bt_upgrade.c22
-rw-r--r--src/config/config_def.c8
-rw-r--r--src/include/btree.h3
-rw-r--r--src/include/extern.h3
-rw-r--r--src/include/wiredtiger.in15
-rw-r--r--src/session/session_api.c20
-rw-r--r--src/session/session_btree.c8
-rw-r--r--src/utilities/util.h1
-rw-r--r--src/utilities/util_main.c7
-rw-r--r--src/utilities/util_upgrade.c61
15 files changed, 167 insertions, 9 deletions
diff --git a/build_posix/Make.base b/build_posix/Make.base
index 0c8b38c140f..95d6b971e8d 100644
--- a/build_posix/Make.base
+++ b/build_posix/Make.base
@@ -23,6 +23,7 @@ wt_SOURCES =\
src/utilities/util_read.c \
src/utilities/util_salvage.c \
src/utilities/util_stat.c \
+ src/utilities/util_upgrade.c \
src/utilities/util_verbose.c \
src/utilities/util_verify.c \
src/utilities/util_write.c
diff --git a/dist/api_data.py b/dist/api_data.py
index 3f4dc20e29e..68ff78b25c1 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -236,6 +236,7 @@ methods = {
]),
'session.sync' : Method([]),
'session.truncate' : Method([]),
+'session.upgrade' : Method([]),
'session.verify' : Method([]),
'session.dumpfile' : Method([]),
diff --git a/dist/filelist b/dist/filelist
index e3b84a773f8..af03f2e5cc8 100644
--- a/dist/filelist
+++ b/dist/filelist
@@ -33,6 +33,7 @@ src/btree/bt_root.c
src/btree/bt_slvg.c
src/btree/bt_stat.c
src/btree/bt_sync.c
+src/btree/bt_upgrade.c
src/btree/bt_vrfy.c
src/btree/bt_vrfy_dsk.c
src/btree/bt_walk.c
diff --git a/docs/src/command-line.dox b/docs/src/command-line.dox
index d38e5b13ee7..5c541b02e92 100644
--- a/docs/src/command-line.dox
+++ b/docs/src/command-line.dox
@@ -275,6 +275,21 @@ argument \c prefix will be printed.
<hr>
+@section utility_upgrade wt upgrade
+Upgrade a table or file.
+
+The \c upgrade command upgrades the specified table or file, exiting
+success if the object up-to-date, and failure if the object cannot be
+upgraded.
+
+@subsection utility_upgrade_synopsis Synopsis
+<code>wt [-Vv] [-C config] [-h directory] upgrade uri</code>
+
+@subsection utility_upgrade_options Options
+The \c upgrade command has no command-specific options.
+
+
+<hr>
@section utility_verify wt verify
Check the structural integrity of a table or file.
diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c
index 5b74508c719..c2ee94322bb 100644
--- a/src/btree/bt_handle.c
+++ b/src/btree/bt_handle.c
@@ -115,8 +115,9 @@ conf: WT_ERR(__btree_conf(session, name, filename, config, flags));
btree->config, cfg, F_ISSET(btree, WT_BTREE_SALVAGE) ? 1 : 0));
WT_ERR(__wt_bm_block_header(session, &btree->block_header));
- /* Initialize the tree if not salvage or verify. */
- if (!F_ISSET(btree, WT_BTREE_SALVAGE | WT_BTREE_VERIFY))
+ /* Initialize the tree if not a special command. */
+ if (!F_ISSET(btree,
+ WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY))
WT_ERR(__btree_tree_init(session));
F_SET(btree, WT_BTREE_OPEN);
@@ -168,8 +169,9 @@ __wt_btree_reopen(WT_SESSION_IMPL *session, uint32_t flags)
btree->flags = flags; /* XXX */
- /* Initialize the tree if not salvage or verify. */
- if (!F_ISSET(btree, WT_BTREE_SALVAGE | WT_BTREE_VERIFY))
+ /* Initialize the tree if not a special command. */
+ if (!F_ISSET(btree,
+ WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY))
WT_RET(__btree_tree_init(session));
F_SET(btree, WT_BTREE_OPEN); /* XXX */
diff --git a/src/btree/bt_upgrade.c b/src/btree/bt_upgrade.c
new file mode 100644
index 00000000000..bb846cb0d8c
--- /dev/null
+++ b/src/btree/bt_upgrade.c
@@ -0,0 +1,22 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2008-2011 WiredTiger, Inc.
+ * All rights reserved.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_upgrade --
+ * Upgrade a file.
+ */
+int
+__wt_upgrade(WT_SESSION_IMPL *session, const char *cfg[])
+{
+ WT_UNUSED(session); /* XXX: unused for now */
+ WT_UNUSED(cfg); /* XXX: unused for now */
+
+ /* There's nothing to upgrade, yet. */
+ return (0);
+}
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 8444f004bb4..ebd2b730545 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -239,6 +239,14 @@ __wt_confchk_session_truncate =
"";
const char *
+__wt_confdfl_session_upgrade =
+ "";
+
+const char *
+__wt_confchk_session_upgrade =
+ "";
+
+const char *
__wt_confdfl_session_verify =
"";
diff --git a/src/include/btree.h b/src/include/btree.h
index f54862d789b..9af2e572cd7 100644
--- a/src/include/btree.h
+++ b/src/include/btree.h
@@ -74,7 +74,8 @@ struct __wt_btree {
#define WT_BTREE_NO_LOCK 0x04 /* Do not lock the handle */
#define WT_BTREE_OPEN 0x08 /* Handle is open */
#define WT_BTREE_SALVAGE 0x10 /* Handle is for salvage */
-#define WT_BTREE_VERIFY 0x20 /* Handle is for verify */
+#define WT_BTREE_UPGRADE 0x20 /* Handle is for upgrade */
+#define WT_BTREE_VERIFY 0x40 /* Handle is for verify */
uint32_t flags;
};
diff --git a/src/include/extern.h b/src/include/extern.h
index 1328a88ffb7..58a6352b155 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -241,6 +241,7 @@ extern int __wt_btree_set_root(WT_SESSION_IMPL *session,
extern int __wt_salvage(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_btree_stat_init(WT_SESSION_IMPL *session);
extern int __wt_btree_sync(WT_SESSION_IMPL *session, const char *cfg[]);
+extern int __wt_upgrade(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_dumpfile(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_verify_dsk(WT_SESSION_IMPL *session,
@@ -423,6 +424,8 @@ extern const char *__wt_confdfl_session_sync;
extern const char *__wt_confchk_session_sync;
extern const char *__wt_confdfl_session_truncate;
extern const char *__wt_confchk_session_truncate;
+extern const char *__wt_confdfl_session_upgrade;
+extern const char *__wt_confchk_session_upgrade;
extern const char *__wt_confdfl_session_verify;
extern const char *__wt_confchk_session_verify;
extern const char *__wt_confdfl_table_meta;
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index a44ffa9f1cd..7a2091077d5 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -712,6 +712,21 @@ struct wt_session {
const char *name,
WT_CURSOR *start, WT_CURSOR *end, const char *config);
+ /*! Upgrade a table.
+ *
+ * Upgrade upgrades a file, or the files of which a table is comprised.
+ *
+ * @dontinclude ex_all.c
+ * @skipline ->upgrade
+ *
+ * @param session the session handle
+ * @param name the URI of the file or table to upgrade
+ * @configempty{session.upgrade, see dist/api_data.py}
+ * @errors
+ */
+ int __F(upgrade)(WT_SESSION *session,
+ const char *name, const char *config);
+
/*! Verify a table.
*
* Verify reports if a file, or the files of which a table is
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 56a39b08056..493cdb6a1ec 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -261,6 +261,25 @@ __session_truncate(WT_SESSION *wt_session,
}
/*
+ * __session_upgrade --
+ * WT_SESSION->upgrade method.
+ */
+static int
+__session_upgrade(WT_SESSION *wt_session, const char *uri, const char *config)
+{
+ WT_SESSION_IMPL *session;
+ int ret;
+
+ session = (WT_SESSION_IMPL *)wt_session;
+
+ SESSION_API_CALL(session, upgrade, config, cfg);
+ ret = __wt_schema_worker(session, uri, cfg,
+ __wt_upgrade, WT_BTREE_EXCLUSIVE | WT_BTREE_UPGRADE);
+err: API_END(session);
+ return (ret);
+}
+
+/*
* __session_verify --
* WT_SESSION->verify method.
*/
@@ -370,6 +389,7 @@ __wt_open_session(WT_CONNECTION_IMPL *conn, int internal,
__session_salvage,
__session_sync,
__session_truncate,
+ __session_upgrade,
__session_verify,
__session_begin_transaction,
__session_commit_transaction,
diff --git a/src/session/session_btree.c b/src/session/session_btree.c
index 9d8262a2517..cd60fcf8695 100644
--- a/src/session/session_btree.c
+++ b/src/session/session_btree.c
@@ -75,8 +75,8 @@ __wt_session_lock_btree(
* We do need to pick up the flags anyway, for example to set
* WT_BTREE_BULK so the handle is closed correctly.
*/
- if (cfg != NULL && LF_ISSET(
- WT_BTREE_BULK | WT_BTREE_SALVAGE | WT_BTREE_VERIFY))
+ if (cfg != NULL && LF_ISSET(WT_BTREE_BULK |
+ WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY))
return (__wt_btree_reopen(session, flags));
else
F_SET(btree, flags);
@@ -104,8 +104,8 @@ __wt_session_release_btree(WT_SESSION_IMPL *session)
* If we had exclusive access, reopen the tree without special flags so
* that other threads can use it.
*/
- if (F_ISSET(btree,
- WT_BTREE_BULK | WT_BTREE_SALVAGE | WT_BTREE_VERIFY)) {
+ if (F_ISSET(btree, WT_BTREE_BULK |
+ WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY)) {
WT_ASSERT(session, F_ISSET(btree, WT_BTREE_EXCLUSIVE));
ret = __wt_btree_reopen(session, 0);
} else if (F_ISSET(btree, WT_BTREE_EXCLUSIVE))
diff --git a/src/utilities/util.h b/src/utilities/util.h
index 3b216eaa799..06a78509290 100644
--- a/src/utilities/util.h
+++ b/src/utilities/util.h
@@ -57,5 +57,6 @@ int util_read_line(ULINE *, int, int *);
int util_salvage(WT_SESSION *, int, char *[]);
int util_stat(WT_SESSION *, int, char *[]);
int util_str2recno(const char *p, uint64_t *recnop);
+int util_upgrade(WT_SESSION *, int, char *[]);
int util_verify(WT_SESSION *, int, char *[]);
int util_write(WT_SESSION *, int, char *[]);
diff --git a/src/utilities/util_main.c b/src/utilities/util_main.c
index 63f4a2a9e20..18a801c11db 100644
--- a/src/utilities/util_main.c
+++ b/src/utilities/util_main.c
@@ -157,6 +157,12 @@ main(int argc, char *argv[])
else
ret = usage();
break;
+ case 'u':
+ if (strcmp(command, "upgrade") == 0)
+ ret = util_upgrade(session, argc, argv);
+ else
+ ret = usage();
+ break;
case 'w':
if (strcmp(command, "write") == 0)
ret = util_write(session, argc, argv);
@@ -199,6 +205,7 @@ usage(void)
"\tread\t read values from an object\n"
"\tsalvage\t salvage a file\n"
"\tstat\t display statistics for an object\n"
+ "\tupgrade\t upgrade an object\n"
"\tverify\t verify an object\n"
"\twrite\t write values to an object\n");
diff --git a/src/utilities/util_upgrade.c b/src/utilities/util_upgrade.c
new file mode 100644
index 00000000000..6d3941741bc
--- /dev/null
+++ b/src/utilities/util_upgrade.c
@@ -0,0 +1,61 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2008-2011 WiredTiger, Inc.
+ * All rights reserved.
+ */
+
+#include "util.h"
+
+static int usage(void);
+
+int
+util_upgrade(WT_SESSION *session, int argc, char *argv[])
+{
+ int ch, ret;
+ char *name;
+
+ name = NULL;
+ while ((ch = util_getopt(argc, argv, "")) != EOF)
+ switch (ch) {
+ case '?':
+ default:
+ return (usage());
+ }
+ argc -= util_optind;
+ argv += util_optind;
+
+ /* The remaining argument is the table name. */
+ if (argc != 1)
+ return (usage());
+ if ((name = util_name(
+ *argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL)
+ return (1);
+
+ if ((ret = session->upgrade(session, name, NULL)) != 0) {
+ fprintf(stderr, "%s: upgrade(%s): %s\n",
+ progname, name, wiredtiger_strerror(ret));
+ goto err;
+ }
+ if (verbose)
+ printf("\n");
+
+ if (0) {
+err: ret = 1;
+ }
+
+ if (name != NULL)
+ free(name);
+
+ return (ret);
+}
+
+static int
+usage(void)
+{
+ (void)fprintf(stderr,
+ "usage: %s %s "
+ "upgrade file\n",
+ progname, usage_prefix);
+ return (1);
+}