susumu.yata
null+****@clear*****
Sun May 5 13:09:24 JST 2013
susumu.yata 2013-05-05 13:09:24 +0900 (Sun, 05 May 2013) New Revision: 46d6b4a3fe544b00a35ebcee6cac2c92b2f74b78 https://github.com/groonga/grnxx/commit/46d6b4a3fe544b00a35ebcee6cac2c92b2f74b78 Message: Fix a bug that the storage tree structure is broken by unlink_node(). Modified files: lib/grnxx/storage/storage_impl.cpp Modified: lib/grnxx/storage/storage_impl.cpp (+15 -7) =================================================================== --- lib/grnxx/storage/storage_impl.cpp 2013-05-05 12:04:28 +0900 (cb28428) +++ lib/grnxx/storage/storage_impl.cpp 2013-05-05 13:09:24 +0900 (7cb783f) @@ -267,13 +267,6 @@ bool StorageImpl::unlink_node(uint32_t node_id) { if (!from_node_header) { return false; } - NodeHeader *latest_node_header = nullptr; - if (header_->latest_unlinked_node_id != STORAGE_INVALID_NODE_ID) { - latest_node_header = get_node_header(header_->latest_unlinked_node_id); - if (!latest_node_header) { - return false; - } - } if (node_id == from_node_header->child_node_id) { from_node_header->child_node_id = node_header->sibling_node_id; } else if (node_id == from_node_header->sibling_node_id) { @@ -287,6 +280,21 @@ bool StorageImpl::unlink_node(uint32_t node_id) { << from_node_header->sibling_node_id; return false; } + if (node_header->sibling_node_id != STORAGE_INVALID_NODE_ID) { + NodeHeader * const sibling_node_header = + get_node_header(node_header->sibling_node_id); + if (!sibling_node_header) { + return false; + } + sibling_node_header->from_node_id = node_header->from_node_id; + } + NodeHeader *latest_node_header = nullptr; + if (header_->latest_unlinked_node_id != STORAGE_INVALID_NODE_ID) { + latest_node_header = get_node_header(header_->latest_unlinked_node_id); + if (!latest_node_header) { + return false; + } + } node_header->status = STORAGE_NODE_UNLINKED; if (latest_node_header) { node_header->next_unlinked_node_id = -------------- next part -------------- HTML����������������������������... Download