/* * __wt_metadata_update -- * Update a row in the metadata. */ int __wt_metadata_update( WT_SESSION_IMPL *session, const char *key, const char *value) { WT_CURSOR *cursor; WT_DECL_RET; if (__metadata_turtle(key)) return (__wt_meta_turtle_update(session, key, value)); if (WT_META_TRACKING(session)) WT_RET(__wt_meta_track_update(session, key)); WT_RET(__wt_metadata_cursor(session, "overwrite", &cursor)); cursor->set_key(cursor, key); cursor->set_value(cursor, value); WT_ERR(cursor->insert(cursor)); err: WT_TRET(cursor->close(cursor)); return (ret); }
/* * __wt_meta_turtle_init -- * Check the turtle file and create if necessary. */ int __wt_meta_turtle_init(WT_SESSION_IMPL *session, int *existp) { WT_DECL_RET; WT_ITEM *buf; int exist; const char *metaconf; const char *cfg[] = API_CONF_DEFAULTS(file, meta, NULL); buf = NULL; metaconf = NULL; *existp = 0; /* Discard any turtle setup file left-over from previous runs. */ WT_RET(__wt_exist(session, WT_METADATA_TURTLE_SET, &exist)); if (exist) WT_RET(__wt_remove(session, WT_METADATA_TURTLE_SET)); /* If there's already a turtle file, we're done. */ WT_RET(__wt_exist(session, WT_METADATA_TURTLE, &exist)); if (exist) { *existp = 1; return (0); } /* Create a turtle file with default values. */ WT_ERR(__wt_scr_alloc(session, 0, &buf)); WT_ERR(__wt_buf_fmt(session, buf, "key_format=S,value_format=S,version=(major=%d,minor=%d)", WT_BTREE_MAJOR_VERSION, WT_BTREE_MINOR_VERSION)); cfg[1] = buf->data; WT_ERR(__wt_config_collapse(session, cfg, &metaconf)); WT_ERR(__wt_meta_turtle_update(session, WT_METADATA_URI, metaconf)); err: __wt_free(session, metaconf); __wt_scr_free(&buf); return (ret); }