8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 02:03:03 +01:00

Backported fix for CORE-1300 : Lower level index pages is missed from parent page

This commit is contained in:
hvlad 2007-07-12 09:47:04 +00:00
parent f282a5ba9b
commit b0874ce138

View File

@ -895,12 +895,8 @@ void BTR_insert(thread_db* tdbb, WIN * root_window, index_insertion* insertion)
index_desc* idx = insertion->iib_descriptor; index_desc* idx = insertion->iib_descriptor;
WIN window(idx->idx_root); WIN window(idx->idx_root);
btree_page* bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_index); btree_page* bucket = (btree_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_index);
if (bucket->btr_level == 0) {
CCH_RELEASE(tdbb, &window);
CCH_FETCH(tdbb, &window, LCK_write, pag_index);
}
CCH_RELEASE(tdbb, root_window); CCH_RELEASE(tdbb, root_window);
temporary_key key; temporary_key key;
@ -2188,20 +2184,29 @@ static SLONG add_node(thread_db* tdbb,
break; break;
} }
bucket = (btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling, bucket = (btree_page*) CCH_HANDOFF(tdbb, window, bucket->btr_sibling,
LCK_read, pag_index); LCK_write, pag_index);
} }
CCH_MARK(tdbb, window);
bucket->btr_header.pag_flags |= btr_dont_gc;
// Fetch the page at the next level down. If the next level is leaf level, // Fetch the page at the next level down. If the next level is leaf level,
// fetch for write since we know we are going to write to the page (most likely). // fetch for write since we know we are going to write to the page (most likely).
const SLONG index = window->win_page; const SLONG index = window->win_page;
CCH_HANDOFF(tdbb, window, page, CCH_HANDOFF(tdbb, window, page, LCK_write, pag_index);
(SSHORT) ((bucket->btr_level == 1) ? LCK_write : LCK_read), pag_index);
// now recursively try to insert the node at the next level down // now recursively try to insert the node at the next level down
index_insertion propagate; index_insertion propagate;
SLONG split = add_node(tdbb, window, insertion, new_key, SLONG split = add_node(tdbb, window, insertion, new_key,
new_record_number, &page, &propagate.iib_sibling); new_record_number, &page, &propagate.iib_sibling);
if (split == NO_SPLIT) { if (split == NO_SPLIT)
{
window->win_page = index;
bucket = (btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index);
CCH_MARK(tdbb, window);
bucket->btr_header.pag_flags &= ~btr_dont_gc;
CCH_RELEASE(tdbb, window);
return NO_SPLIT; return NO_SPLIT;
} }
@ -2242,6 +2247,12 @@ static SLONG add_node(thread_db* tdbb,
bucket->btr_header.pag_flags &= ~btr_dont_gc; bucket->btr_header.pag_flags &= ~btr_dont_gc;
CCH_RELEASE(tdbb, window); CCH_RELEASE(tdbb, window);
window->win_page = index;
bucket = (btree_page*) CCH_FETCH(tdbb, window, LCK_write, pag_index);
CCH_MARK(tdbb, window);
bucket->btr_header.pag_flags &= ~btr_dont_gc;
CCH_RELEASE(tdbb, window);
if (original_page) { if (original_page) {
*original_page = original_page2; *original_page = original_page2;
} }