Commit f6476e01 authored by Rich Prohaska's avatar Rich Prohaska

fix the ncursors > 0 assert in the nonleaf expand code caused when the cursor...

fix the ncursors > 0 assert in the nonleaf expand code caused when the cursor path traverses the child at the split point.  addresses #119

git-svn-id: file:///svn/tokudb@928 c7de825b-a66e-492c-adef-691d508d4ae1
parent accc92e4
...@@ -682,6 +682,7 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum, ...@@ -682,6 +682,7 @@ static int handle_split_of_child (BRT t, BRTNODE node, int childnum,
} }
node->u.n.children[childnum] = childa->thisnodename; node->u.n.children[childnum] = childa->thisnodename;
node->u.n.children[childnum+1] = childb->thisnodename; node->u.n.children[childnum+1] = childb->thisnodename;
node->u.n.n_cursors[childnum+1] = 0;
fixup_child_fingerprint(node, childnum, childa); fixup_child_fingerprint(node, childnum, childa);
fixup_child_fingerprint(node, childnum+1, childb); fixup_child_fingerprint(node, childnum+1, childb);
toku_hashtable_create(&node->u.n.htables[childnum]); toku_hashtable_create(&node->u.n.htables[childnum]);
...@@ -2280,13 +2281,23 @@ void toku_brt_cursor_nonleaf_expand(BRT_CURSOR cursor, BRT t __attribute__((unus ...@@ -2280,13 +2281,23 @@ void toku_brt_cursor_nonleaf_expand(BRT_CURSOR cursor, BRT t __attribute__((unus
// if (i >= 0 && cursor->path[i] == node) { // if (i >= 0 && cursor->path[i] == node) {
// } // }
if (0) toku_brt_cursor_print(cursor); if (0) toku_brt_cursor_print(cursor);
/* see if the cursor path references the node */
for (i = 0; i < cursor->path_len; i++) for (i = 0; i < cursor->path_len; i++)
if (cursor->path[i] == node) if (cursor->path[i] == node)
break; break;
if (i < cursor->path_len) { if (i < cursor->path_len) {
if (cursor->pathcnum[i] < childnum) if (cursor->pathcnum[i] < childnum) /* cursor is left of the split so nothing to do */
return; return;
if (cursor->pathcnum[i] > childnum) { if (cursor->pathcnum[i] > childnum) { /* cursor is right of the split so just increment the cursor childnum */
cursor->pathcnum[i] += 1;
return;
}
if (i == cursor->path_len-1 && (cursor->op == DB_PREV || cursor->op == DB_LAST)) { /* explain this, batman */
goto setnewchild;
}
if (i+1 < cursor->path_len) { /* the cursor path traversed the old child so update it if it traverses the right child */
assert(cursor->path[i+1] == left || cursor->path[i+1] == right);
if (cursor->path[i+1] == right) {
setnewchild: setnewchild:
oldchildnum = cursor->pathcnum[i]; oldchildnum = cursor->pathcnum[i];
newchildnum = oldchildnum + 1; newchildnum = oldchildnum + 1;
...@@ -2295,14 +2306,6 @@ void toku_brt_cursor_nonleaf_expand(BRT_CURSOR cursor, BRT t __attribute__((unus ...@@ -2295,14 +2306,6 @@ void toku_brt_cursor_nonleaf_expand(BRT_CURSOR cursor, BRT t __attribute__((unus
cursor->pathcnum[i] = newchildnum; cursor->pathcnum[i] = newchildnum;
return; return;
} }
if (i == cursor->path_len-1 && (cursor->op == DB_PREV || cursor->op == DB_LAST)) {
goto setnewchild;
}
if (i+1 < cursor->path_len) {
assert(cursor->path[i+1] == left || cursor->path[i+1] == right);
if (cursor->path[i+1] == right) {
goto setnewchild;
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment