Beispiel #1
0
/*
 * __wt_metadata_cursor --
 *	Opens a cursor on the metadata.
 */
int
__wt_metadata_cursor(
    WT_SESSION_IMPL *session, const char *config, WT_CURSOR **cursorp)
{
	WT_DATA_HANDLE *saved_dhandle;
	WT_DECL_RET;
	const char *cfg[] =
	    { WT_CONFIG_BASE(session, session_open_cursor), config, NULL };

	saved_dhandle = session->dhandle;
	WT_ERR(__wt_metadata_open(session));

	WT_SET_BTREE_IN_SESSION(session, session->metafile);

	/* 
	 * We use the metadata a lot, so we have a handle cached; lock it and
	 * increment the in-use counter.
	 */
	WT_ERR(__wt_session_lock_btree(session, 0));
	__wt_session_dhandle_incr_use(session);

	ret = __wt_curfile_create(session, NULL, cfg, 0, 0, cursorp);

	/* Restore the caller's btree. */
err:	session->dhandle = saved_dhandle;
	return (ret);
}
Beispiel #2
0
/*
 * __wt_metadata_cursor --
 *	Opens a cursor on the metadata.
 */
int
__wt_metadata_cursor(
    WT_SESSION_IMPL *session, const char *config, WT_CURSOR **cursorp)
{
	WT_DATA_HANDLE *saved_dhandle;
	WT_DECL_RET;
	const char *cfg[] =
	    { WT_CONFIG_BASE(session, session_open_cursor), config, NULL };

	saved_dhandle = session->dhandle;
	WT_ERR(__wt_metadata_open(session));

	WT_SET_BTREE_IN_SESSION(session, session->metafile);
	WT_ERR(__wt_session_lock_btree(session, 0));
	ret = __wt_curfile_create(session, NULL, cfg, 0, 0, cursorp);

	/* Restore the caller's btree. */
err:	session->dhandle = saved_dhandle;
	return (ret);
}