Commit 125c41bd authored by unknown's avatar unknown

fixes for new key_map code

parent 249798d8
...@@ -884,12 +884,12 @@ int ha_berkeley::write_row(byte * record) ...@@ -884,12 +884,12 @@ int ha_berkeley::write_row(byte * record)
DBUG_PRINT("trans",("aborting subtransaction")); /* purecov: deadcode */ DBUG_PRINT("trans",("aborting subtransaction")); /* purecov: deadcode */
new_error=txn_abort(sub_trans); /* purecov: deadcode */ new_error=txn_abort(sub_trans); /* purecov: deadcode */
} }
else if (changed_keys) else if (!changed_keys.is_clear_all())
{ {
new_error = 0; new_error = 0;
for (uint keynr=0; changed_keys; keynr++, changed_keys >>= 1) for (uint keynr=0; keynr < changed_keys.length(); keynr++)
{ {
if (changed_keys & 1) if (changed_keys.is_set(keynr))
{ {
if ((new_error = remove_key(sub_trans, keynr, record, if ((new_error = remove_key(sub_trans, keynr, record,
&prim_key))) &prim_key)))
...@@ -1033,18 +1033,22 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys, ...@@ -1033,18 +1033,22 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys,
rolled back. The last key set in changed_keys is the one that rolled back. The last key set in changed_keys is the one that
triggered the duplicate key error (it wasn't inserted), so for triggered the duplicate key error (it wasn't inserted), so for
that one just put back the old value. */ that one just put back the old value. */
for (keynr=0; changed_keys; keynr++, changed_keys >>= 1) if (!changed_keys.is_clear_all())
{ {
if (changed_keys & 1) key_map map1(1);
for (keynr=0; keynr < changed_keys.length(); keynr++)
{ {
if (changed_keys != 1 && if (changed_keys.is_set(keynr))
(error = remove_key(trans, keynr, new_row, new_key))) {
break; /* purecov: inspected */ if (changed_keys.is_subset(map1) &&
if ((error = key_file[keynr]->put(key_file[keynr], trans, (error = remove_key(trans, keynr, new_row, new_key)))
create_key(&tmp_key, keynr, key_buff2, break; /* purecov: inspected */
old_row), if ((error = key_file[keynr]->put(key_file[keynr], trans,
old_key, key_type[keynr]))) create_key(&tmp_key, keynr, key_buff2,
break; /* purecov: inspected */ old_row),
old_key, key_type[keynr])))
break; /* purecov: inspected */
}
} }
} }
...@@ -1146,7 +1150,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) ...@@ -1146,7 +1150,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
DBUG_PRINT("trans",("aborting subtransaction")); /* purecov: deadcode */ DBUG_PRINT("trans",("aborting subtransaction")); /* purecov: deadcode */
new_error=txn_abort(sub_trans); /* purecov: deadcode */ new_error=txn_abort(sub_trans); /* purecov: deadcode */
} }
else if (changed_keys) else if (!changed_keys.is_clear_all())
new_error=restore_keys(transaction, changed_keys, primary_key, new_error=restore_keys(transaction, changed_keys, primary_key,
old_row, &old_prim_key, new_row, &prim_key, old_row, &old_prim_key, new_row, &prim_key,
thd_options); thd_options);
...@@ -1231,9 +1235,9 @@ int ha_berkeley::remove_keys(DB_TXN *trans, const byte *record, ...@@ -1231,9 +1235,9 @@ int ha_berkeley::remove_keys(DB_TXN *trans, const byte *record,
DBT *new_record, DBT *prim_key, key_map keys) DBT *new_record, DBT *prim_key, key_map keys)
{ {
int result = 0; int result = 0;
for (uint keynr=0; keys; keynr++, keys>>=1) for (uint keynr=0; keynr < keys.length(); keynr++)
{ {
if (keys & 1) if (keys.is_set(keynr))
{ {
int new_error=remove_key(trans, keynr, record, prim_key); int new_error=remove_key(trans, keynr, record, prim_key);
if (new_error) if (new_error)
......
...@@ -107,7 +107,7 @@ class ha_berkeley: public handler ...@@ -107,7 +107,7 @@ class ha_berkeley: public handler
uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; } uint extra_rec_buf_length() { return BDB_HIDDEN_PRIMARY_KEY_LENGTH; }
ha_rows estimate_number_of_rows(); ha_rows estimate_number_of_rows();
bool fast_key_read() { return 1;} bool fast_key_read() { return 1;}
const key_map keys_to_use_for_scanning() { return key_map(~0); } const key_map& keys_to_use_for_scanning() { return key_map_full; }
bool has_transactions() { return 1;} bool has_transactions() { return 1;}
int open(const char *name, int mode, uint test_if_locked); int open(const char *name, int mode, uint test_if_locked);
......
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
template <> class Bitmap<64> template <> class Bitmap<64>
{ {
longlong map; ulonglong map;
public: public:
Bitmap(uint prefix_to_set=0) { set_prefix(prefix_to_set); } Bitmap(uint prefix_to_set=0) { set_prefix(prefix_to_set); }
Bitmap<64>& init() { return *this; } Bitmap<64>& init() { return *this; }
......
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