summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/config_api.c28
-rw-r--r--src/include/wiredtiger.in11
-rw-r--r--src/support/err.c8
3 files changed, 32 insertions, 15 deletions
diff --git a/src/config/config_api.c b/src/config/config_api.c
index d5c0bedf129..a933e4a3952 100644
--- a/src/config/config_api.c
+++ b/src/config/config_api.c
@@ -109,30 +109,44 @@ err: __wt_free(session, config_parser);
* Validate a configuration string.
*/
int
-wiredtiger_config_validate(
- WT_SESSION *wt_session, const char *name, const char *config)
+wiredtiger_config_validate(WT_SESSION *wt_session,
+ WT_EVENT_HANDLER *handler, const char *name, const char *config)
{
- WT_CONNECTION_IMPL *conn;
+ WT_CONNECTION_IMPL *conn, dummy_conn;
WT_SESSION_IMPL *session;
const WT_CONFIG_ENTRY *ep, **epp;
session = (WT_SESSION_IMPL *)wt_session;
+ /*
+ * If we're not given a session, but we do have an event handler, build
+ * a fake session/connection pair and configure the event handler.
+ */
+ conn = NULL;
+ if (session == NULL && handler != NULL) {
+ WT_CLEAR(dummy_conn);
+ conn = &dummy_conn;
+ session = conn->default_session = &conn->dummy_session;
+ session->iface.connection = &conn->iface;
+ session->name = "wiredtiger_config_validate";
+ __wt_event_handler_set(session, handler);
+ }
+ if (session != NULL)
+ conn = S2C(session);
+
if (name == NULL)
WT_RET_MSG(session, EINVAL, "no name specified");
if (config == NULL)
WT_RET_MSG(session, EINVAL, "no configuration specified");
/*
- * If we don't yet have a connection, look for a matching name in the
+ * If we don't have a real connection, look for a matching name in the
* static list, otherwise look in the configuration list (which has any
* configuration information the application has added).
*/
- if (session == NULL)
+ if (session == NULL || conn == NULL || conn->config_entries == NULL)
ep = __wt_conn_config_match(name);
else {
- conn = S2C(session);
-
ep = NULL;
for (epp = conn->config_entries;
*epp != NULL && (*epp)->method != NULL; ++epp)
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 696e7ad9321..05e92d313f2 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -2510,16 +2510,19 @@ struct __wt_config_item {
* This API is outside the scope of a WiredTiger connection handle, since
* applications may need to validate configuration strings prior to calling
* ::wiredtiger_open.
- * @param session the session handle to be used for error reporting (if NULL,
- * error messages will be written to stderr).
+ * @param session the session handle (may be \c NULL if the database not yet
+ * opened).
+ * @param errhandler An error handler (used if \c session is \c NULL; if both
+ * \c session and \c errhandler are \c NULL, error messages will be written to
+ * stderr).
* @param name the WiredTiger function or method to validate.
* @param config the configuration string being parsed.
* @returns zero for success, non-zero to indicate an error.
*
* @snippet ex_all.c Validate a configuration string
*/
-int wiredtiger_config_validate(
- WT_SESSION *session, const char *name, const char *config);
+int wiredtiger_config_validate(WT_SESSION *session,
+ WT_EVENT_HANDLER *errhandler, const char *name, const char *config);
#endif
/*!
diff --git a/src/support/err.c b/src/support/err.c
index 34e44701ea0..e9b7a53a2ab 100644
--- a/src/support/err.c
+++ b/src/support/err.c
@@ -188,10 +188,10 @@ __wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error,
end = s + sizeof(s);
/*
- * We have several prefixes for the error message:
- * a timestamp and the process and thread ids, the database error
- * prefix, the data-source's name, and the session's name. Write them
- * as a comma-separate list, followed by a colon.
+ * We have several prefixes for the error message: a timestamp and the
+ * process and thread ids, the database error prefix, the data-source's
+ * name, and the session's name. Write them as a comma-separate list,
+ * followed by a colon.
*/
prefix_cnt = 0;
if (__wt_epoch(session, &ts) == 0) {