/* * __curlog_close -- * WT_CURSOR.close method for the log cursor type. */ static int __curlog_close(WT_CURSOR *cursor) { WT_CONNECTION_IMPL *conn; WT_CURSOR_LOG *cl; WT_DECL_RET; WT_LOG *log; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, close, NULL); cl = (WT_CURSOR_LOG *)cursor; conn = S2C(session); WT_ASSERT(session, FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED)); log = conn->log; WT_TRET(__wt_readunlock(session, log->log_archive_lock)); WT_TRET(__curlog_reset(cursor)); __wt_free(session, cl->cur_lsn); __wt_free(session, cl->next_lsn); __wt_scr_free(session, &cl->logrec); __wt_scr_free(session, &cl->opkey); __wt_scr_free(session, &cl->opvalue); __wt_free(session, cl->packed_key); __wt_free(session, cl->packed_value); WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curfile_close -- * WT_CURSOR->close method for the btree cursor type. */ static int __curfile_close(WT_CURSOR *cursor) { WT_CURSOR_BTREE *cbt; WT_CURSOR_BULK *cbulk; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)cursor; CURSOR_API_CALL(cursor, session, close, cbt->btree); if (F_ISSET(cursor, WT_CURSTD_BULK)) { /* Free the bulk-specific resources. */ cbulk = (WT_CURSOR_BULK *)cbt; WT_TRET(__wt_bulk_wrapup(session, cbulk)); __wt_buf_free(session, &cbulk->last); } WT_TRET(__wt_btcur_close(cbt, 0)); /* The URI is owned by the btree handle. */ cursor->internal_uri = NULL; WT_TRET(__wt_cursor_close(cursor)); /* * Note: release the data handle last so that cursor statistics are * updated correctly. */ if (session->dhandle != NULL) { /* Increment the data-source's in-use counter. */ __wt_cursor_dhandle_decr_use(session); WT_TRET(__wt_session_release_btree(session)); } err: API_END_RET(session, ret); }
/* * __curds_close -- * WT_CURSOR.close method for the data-source cursor type. */ static int __curds_close(WT_CURSOR *cursor) { WT_CURSOR_DATA_SOURCE *cds; WT_DECL_RET; WT_SESSION_IMPL *session; cds = (WT_CURSOR_DATA_SOURCE *)cursor; CURSOR_API_CALL(cursor, session, close, NULL); if (cds->source != NULL) ret = cds->source->close(cds->source); if (cds->collator_owned) { if (cds->collator->terminate != NULL) WT_TRET(cds->collator->terminate( cds->collator, &session->iface)); cds->collator_owned = 0; } cds->collator = NULL; /* * The key/value formats are in allocated memory, which isn't standard * behavior. */ __wt_free(session, cursor->key_format); __wt_free(session, cursor->value_format); WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curlog_close -- * WT_CURSOR.close method for the log cursor type. */ static int __curlog_close(WT_CURSOR *cursor) { WT_CONNECTION_IMPL *conn; WT_CURSOR_LOG *cl; WT_DECL_RET; WT_SESSION_IMPL *session; cl = (WT_CURSOR_LOG *)cursor; CURSOR_API_CALL_PREPARE_ALLOWED(cursor, session, close, NULL); err: conn = S2C(session); if (F_ISSET(cl, WT_CURLOG_ARCHIVE_LOCK)) { (void)__wt_atomic_sub32(&conn->log_cursors, 1); __wt_readunlock(session, &conn->log->log_archive_lock); } __wt_free(session, cl->cur_lsn); __wt_free(session, cl->next_lsn); __wt_scr_free(session, &cl->logrec); __wt_scr_free(session, &cl->opkey); __wt_scr_free(session, &cl->opvalue); __wt_free(session, cl->packed_key); __wt_free(session, cl->packed_value); __wt_cursor_close(cursor); API_END_RET(session, ret); }
/* * __curbackup_close -- * WT_CURSOR->close method for the backup cursor type. */ static int __curbackup_close(WT_CURSOR *cursor) { WT_CURSOR_BACKUP *cb; WT_DECL_RET; WT_SESSION_IMPL *session; cb = (WT_CURSOR_BACKUP *)cursor; CURSOR_API_CALL(cursor, session, close, NULL); /* * When starting a hot backup, we serialize hot backup cursors and set * the connection's hot-backup flag. Once that's done, we set the * cursor's backup-locker flag, implying the cursor owns all necessary * cleanup (including removing temporary files), regardless of error or * success. The cursor's backup-locker flag is never cleared (it's just * discarded when the cursor is closed), because that cursor will never * not be responsible for cleanup. */ if (F_ISSET(cb, WT_CURBACKUP_LOCKER)) WT_TRET(__backup_stop(session, cb)); WT_TRET(__wt_cursor_close(cursor)); session->bkp_cursor = NULL; err: API_END_RET(session, ret); }
/* * __curds_close -- * WT_CURSOR.close method for the data-source cursor type. */ static int __curds_close(WT_CURSOR *cursor) { WT_CURSOR *source; WT_DECL_RET; WT_SESSION_IMPL *session; source = ((WT_CURSOR_DATA_SOURCE *)cursor)->source; CURSOR_API_CALL(cursor, session, close, NULL); if (source != NULL) ret = source->close(source); /* * The key/value formats are in allocated memory, which isn't standard * behavior. */ __wt_free(session, cursor->key_format); __wt_free(session, cursor->value_format); WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curjoin_close -- * WT_CURSOR::close for join cursors. */ static int __curjoin_close(WT_CURSOR *cursor) { WT_CURSOR_JOIN *cjoin; WT_CURSOR_JOIN_ENDPOINT *end; WT_CURSOR_JOIN_ENTRY *entry; WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; cjoin = (WT_CURSOR_JOIN *)cursor; JOINABLE_CURSOR_API_CALL_PREPARE_ALLOWED(cursor, session, close, NULL); err: WT_TRET(__wt_schema_release_table(session, &cjoin->table)); /* This is owned by the table */ cursor->key_format = NULL; if (cjoin->projection != NULL) { __wt_free(session, cjoin->projection); __wt_free(session, cursor->value_format); } for (entry = cjoin->entries, i = 0; i < cjoin->entries_next; entry++, i++) { if (entry->subjoin != NULL) { F_CLR(&entry->subjoin->iface, WT_CURSTD_JOINED); entry->subjoin->parent = NULL; } if (entry->main != NULL) WT_TRET(entry->main->close(entry->main)); if (F_ISSET(entry, WT_CURJOIN_ENTRY_OWN_BLOOM)) WT_TRET(__wt_bloom_close(entry->bloom)); for (end = &entry->ends[0]; end < &entry->ends[entry->ends_next]; end++) { F_CLR(end->cursor, WT_CURSTD_JOINED); if (F_ISSET(end, WT_CURJOIN_END_OWN_CURSOR)) WT_TRET(end->cursor->close(end->cursor)); } __wt_free(session, entry->ends); __wt_free(session, entry->repack_format); } if (cjoin->iter != NULL) WT_TRET(__curjoin_iter_close_all(cjoin->iter)); if (cjoin->main != NULL) WT_TRET(cjoin->main->close(cjoin->main)); __wt_free(session, cjoin->entries); __wt_cursor_close(cursor); API_END_RET(session, ret); }
/* * __curjoin_close -- * WT_CURSOR::close for join cursors. */ static int __curjoin_close(WT_CURSOR *cursor) { WT_CURSOR_JOIN *cjoin; WT_CURSOR_JOIN_ENDPOINT *end; WT_CURSOR_JOIN_ENTRY *entry; WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; cjoin = (WT_CURSOR_JOIN *)cursor; CURSOR_API_CALL(cursor, session, close, NULL); __wt_schema_release_table(session, cjoin->table); /* These are owned by the table */ cursor->internal_uri = NULL; cursor->key_format = NULL; if (cjoin->projection != NULL) { __wt_free(session, cjoin->projection); __wt_free(session, cursor->value_format); } for (entry = cjoin->entries, i = 0; i < cjoin->entries_next; entry++, i++) { if (entry->main != NULL) WT_TRET(entry->main->close(entry->main)); if (F_ISSET(entry, WT_CURJOIN_ENTRY_OWN_BLOOM)) WT_TRET(__wt_bloom_close(entry->bloom)); for (end = &entry->ends[0]; end < &entry->ends[entry->ends_next]; end++) { F_CLR(end->cursor, WT_CURSTD_JOINED); if (F_ISSET(end, WT_CURJOIN_END_OWN_KEY)) __wt_free(session, end->key.data); } __wt_free(session, entry->ends); } if (cjoin->iter != NULL) WT_TRET(__curjoin_entry_iter_close(cjoin->iter)); __wt_free(session, cjoin->entries); WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curmetadata_close -- * WT_CURSOR->close method for the metadata cursor type. */ static int __curmetadata_close(WT_CURSOR *cursor) { WT_CURSOR *file_cursor; WT_CURSOR_METADATA *mdc; WT_DECL_RET; WT_SESSION_IMPL *session; mdc = (WT_CURSOR_METADATA *)cursor; file_cursor = mdc->file_cursor; CURSOR_API_CALL(cursor, session, close, ((WT_CURSOR_BTREE *)file_cursor)->btree); ret = file_cursor->close(file_cursor); WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curlog_close -- * WT_CURSOR.close method for the log cursor type. */ static int __curlog_close(WT_CURSOR *cursor) { WT_CURSOR_LOG *cl; WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, close, NULL); cl = (WT_CURSOR_LOG *)cursor; WT_ERR(__curlog_reset(cursor)); __wt_free(session, cl->cur_lsn); __wt_free(session, cl->next_lsn); __wt_scr_free(&cl->logrec); __wt_scr_free(&cl->opkey); __wt_scr_free(&cl->opvalue); WT_ERR(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curfile_close -- * WT_CURSOR->close method for the btree cursor type. */ static int __curfile_close(WT_CURSOR *cursor) { WT_CURSOR_BTREE *cbt; WT_DECL_RET; WT_SESSION_IMPL *session; cbt = (WT_CURSOR_BTREE *)cursor; CURSOR_API_CALL(cursor, session, close, cbt->btree); WT_TRET(__wt_btcur_close(cbt)); if (session->btree != NULL) WT_TRET(__wt_session_release_btree(session)); /* The URI is owned by the btree handle. */ cursor->uri = NULL; WT_TRET(__wt_cursor_close(cursor)); API_END(session); return (ret); }
/* * __curindex_close -- * WT_CURSOR->close method for index cursors. */ static int __curindex_close(WT_CURSOR *cursor) { WT_CURSOR_INDEX *cindex; WT_CURSOR **cp; WT_DECL_RET; WT_INDEX *idx; WT_SESSION_IMPL *session; u_int i; cindex = (WT_CURSOR_INDEX *)cursor; idx = cindex->index; JOINABLE_CURSOR_API_CALL(cursor, session, close, NULL); if ((cp = cindex->cg_cursors) != NULL) for (i = 0, cp = cindex->cg_cursors; i < WT_COLGROUPS(cindex->table); i++, cp++) if (*cp != NULL) { WT_TRET((*cp)->close(*cp)); *cp = NULL; } __wt_free(session, cindex->cg_needvalue); __wt_free(session, cindex->cg_cursors); if (cindex->key_plan != idx->key_plan) __wt_free(session, cindex->key_plan); if (cursor->value_format != cindex->table->value_format) __wt_free(session, cursor->value_format); if (cindex->value_plan != idx->value_plan) __wt_free(session, cindex->value_plan); if (cindex->child != NULL) WT_TRET(cindex->child->close(cindex->child)); __wt_schema_release_table(session, cindex->table); /* The URI is owned by the index. */ cursor->internal_uri = NULL; WT_TRET(__wt_cursor_close(cursor)); err: API_END_RET(session, ret); }
/* * __curbackup_close -- * WT_CURSOR->close method for the backup cursor type. */ static int __curbackup_close(WT_CURSOR *cursor) { WT_CURSOR_BACKUP *cb; WT_DECL_RET; WT_SESSION_IMPL *session; int tret; cb = (WT_CURSOR_BACKUP *)cursor; CURSOR_API_CALL(cursor, session, close, NULL); WT_TRET(__backup_cleanup_handles(session, cb)); WT_TRET(__wt_cursor_close(cursor)); session->bkp_cursor = NULL; WT_WITH_SCHEMA_LOCK(session, tret = __backup_stop(session)); /* Stop the backup. */ WT_TRET(tret); err: API_END_RET(session, ret); }
/* * __curbulk_close -- * WT_CURSOR->close for the bulk cursor type. */ static int __curbulk_close(WT_CURSOR *cursor) { WT_BTREE *btree; WT_CURSOR_BULK *cbulk; WT_SESSION_IMPL *session; int ret; cbulk = (WT_CURSOR_BULK *)cursor; btree = cbulk->cbt.btree; CURSOR_API_CALL(cursor, session, close, btree); WT_TRET(__wt_bulk_end(cbulk)); if (session->btree != NULL) WT_TRET(__wt_session_release_btree(session)); /* The URI is owned by the btree handle. */ cursor->uri = NULL; WT_TRET(__wt_cursor_close(cursor)); API_END(session); return (ret); }
/* * __curds_close -- * WT_CURSOR.close method for the data-source cursor type. */ static int __curds_close(WT_CURSOR *cursor) { WT_DECL_RET; WT_SESSION_IMPL *session; CURSOR_API_CALL(cursor, session, close, NULL); if (cursor->data_source != NULL) ret = cursor->data_source->close(cursor->data_source); /* * The key/value formats are in allocated memory, which isn't standard * behavior. */ __wt_free(session, cursor->key_format); __wt_free(session, cursor->value_format); WT_TRET(__wt_cursor_close(cursor)); err: API_END(session); return (ret); }
/* * __curconfig_close -- * WT_CURSOR->close method for the config cursor type. */ static int __curconfig_close(WT_CURSOR *cursor) { return (__wt_cursor_close(cursor)); }