ITS#7594 Fix MDB cursor tracking with subDBs.

The tracking code should not change the current cursor.
It did when that was a C_SUB cursor, which should not be
checked against the tracked cursors but their xcursors.

However, do not bother to skip the tracking code for the
current cursor when it would not change that cursor anyway.
vmware
Hallvard Furuseth 12 years ago
parent 2bacf6e59e
commit 79844bd446
  1. 13
      libraries/liblmdb/mdb.c

@ -1621,8 +1621,8 @@ finish:
MDB_dbi dbi = mc->mc_dbi-1; MDB_dbi dbi = mc->mc_dbi-1;
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (m2 == mc) continue;
m3 = &m2->mc_xcursor->mx_cursor; m3 = &m2->mc_xcursor->mx_cursor;
if (m3 == mc) continue;
if (m3->mc_snum < mc->mc_snum) continue; if (m3->mc_snum < mc->mc_snum) continue;
if (m3->mc_pg[mc->mc_top] == mc->mc_pg[mc->mc_top]) { if (m3->mc_pg[mc->mc_top] == mc->mc_pg[mc->mc_top]) {
m3->mc_pg[mc->mc_top] = mp; m3->mc_pg[mc->mc_top] = mp;
@ -6236,11 +6236,11 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst)
dbi--; dbi--;
for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (m2 == csrc) continue;
if (csrc->mc_flags & C_SUB) if (csrc->mc_flags & C_SUB)
m3 = &m2->mc_xcursor->mx_cursor; m3 = &m2->mc_xcursor->mx_cursor;
else else
m3 = m2; m3 = m2;
if (m3 == csrc) continue;
if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] == if (m3->mc_pg[csrc->mc_top] == mp && m3->mc_ki[csrc->mc_top] ==
csrc->mc_ki[csrc->mc_top]) { csrc->mc_ki[csrc->mc_top]) {
m3->mc_pg[csrc->mc_top] = cdst->mc_pg[cdst->mc_top]; m3->mc_pg[csrc->mc_top] = cdst->mc_pg[cdst->mc_top];
@ -6496,10 +6496,10 @@ mdb_rebalance(MDB_cursor *mc)
mc->mc_db->md_depth = 0; mc->mc_db->md_depth = 0;
mc->mc_db->md_leaf_pages = 0; mc->mc_db->md_leaf_pages = 0;
mdb_midl_append(&mc->mc_txn->mt_free_pgs, mp->mp_pgno); mdb_midl_append(&mc->mc_txn->mt_free_pgs, mp->mp_pgno);
/* Adjust cursors pointing to mp */
mc->mc_snum = 0; mc->mc_snum = 0;
mc->mc_top = 0; mc->mc_top = 0;
{ {
/* Adjust other cursors pointing to mp */
MDB_cursor *m2, *m3; MDB_cursor *m2, *m3;
MDB_dbi dbi = mc->mc_dbi; MDB_dbi dbi = mc->mc_dbi;
@ -6507,7 +6507,6 @@ mdb_rebalance(MDB_cursor *mc)
dbi--; dbi--;
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (m2 == mc) continue;
if (mc->mc_flags & C_SUB) if (mc->mc_flags & C_SUB)
m3 = &m2->mc_xcursor->mx_cursor; m3 = &m2->mc_xcursor->mx_cursor;
else else
@ -6537,12 +6536,11 @@ mdb_rebalance(MDB_cursor *mc)
dbi--; dbi--;
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (m2 == mc) continue;
if (mc->mc_flags & C_SUB) if (mc->mc_flags & C_SUB)
m3 = &m2->mc_xcursor->mx_cursor; m3 = &m2->mc_xcursor->mx_cursor;
else else
m3 = m2; m3 = m2;
if (m3->mc_snum < mc->mc_snum) continue; if (m3 == mc || m3->mc_snum < mc->mc_snum) continue;
if (m3->mc_pg[0] == mp) { if (m3->mc_pg[0] == mp) {
m3->mc_pg[0] = mc->mc_pg[0]; m3->mc_pg[0] = mc->mc_pg[0];
m3->mc_snum = 1; m3->mc_snum = 1;
@ -7069,11 +7067,12 @@ done:
dbi--; dbi--;
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (m2 == mc) continue;
if (mc->mc_flags & C_SUB) if (mc->mc_flags & C_SUB)
m3 = &m2->mc_xcursor->mx_cursor; m3 = &m2->mc_xcursor->mx_cursor;
else else
m3 = m2; m3 = m2;
if (m3 == mc)
continue;
if (!(m3->mc_flags & C_INITIALIZED)) if (!(m3->mc_flags & C_INITIALIZED))
continue; continue;
if (m3->mc_flags & C_SPLITTING) if (m3->mc_flags & C_SPLITTING)

Loading…
Cancel
Save