Commit 22a5241f authored by unknown's avatar unknown

Add test case for update/replace bug in bdb.

Remove unused argument to ha_berkeley::remove_key().


mysql-test/r/bdb.result:
  Add test case for update/replace bug in bdb.
BitKeeper/etc/ignore:
  Added .gdbinit .vimrc to the ignore list
mysql-test/t/bdb.test:
  Add test case for update/replace bug in bdb.
sql/ha_berkeley.cc:
  The packed_record argument to ha_berkeley::remove_key() was never
  used; remove it.
sql/ha_berkeley.h:
  The packed_record argument to ha_berkeley::remove_key() was never
  used; remove it.
parent 710fb999
......@@ -289,3 +289,5 @@ tags
tmp/*
myisam/test1.MYD
myisam/test1.MYI
.gdbinit
.vimrc
......@@ -139,6 +139,8 @@ t1 1 level 1 level A 3 NULL NULL
gesuchnr benutzer_id
1 1
2 1
id x
1 2
Table Op Msg_type Msg_text
test.t1 optimize status OK
a
......
......@@ -65,6 +65,13 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
select * from t1;
drop table t1;
# test for bug in replace with secondary key
create table t1 (id int not null primary key, x int not null, key (x)) type=bdb;
insert into t1 (id, x) values (1, 1);
replace into t1 (id, x) values (1, 2);
select * from t1;
drop table t1;
#
# test delete using hidden_primary_key
#
......
......@@ -888,7 +888,7 @@ int ha_berkeley::write_row(byte * record)
if (changed_keys & 1)
{
if ((new_error = remove_key(sub_trans, keynr, record,
(DBT*) 0, &prim_key)))
&prim_key)))
break; /* purecov: inspected */
}
}
......@@ -970,7 +970,7 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
{
// Primary key changed or we are updating a key that can have duplicates.
// Delete the old row and add a new one
if (!(error=remove_key(trans, primary_key, old_row, (DBT *) 0, old_key)))
if (!(error=remove_key(trans, primary_key, old_row, old_key)))
{
if (!(error=pack_row(&row, new_row, 0)))
{
......@@ -1034,7 +1034,7 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys,
if (changed_keys & 1)
{
if (changed_keys != 1 &&
(error = remove_key(trans, keynr, new_row, (DBT*) 0, new_key)))
(error = remove_key(trans, keynr, new_row, new_key)))
break; /* purecov: inspected */
if ((error = key_file[keynr]->put(key_file[keynr], trans,
create_key(&tmp_key, keynr, key_buff2,
......@@ -1105,8 +1105,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
continue;
if (key_cmp(keynr, old_row, new_row) || primary_key_changed)
{
if ((error=remove_key(sub_trans, keynr, old_row, (DBT*) 0,
&old_prim_key)))
if ((error=remove_key(sub_trans, keynr, old_row, &old_prim_key)))
{
if (using_ignore && /* purecov: inspected */
(thd_options & OPTION_INTERNAL_SUBTRANSACTIONS))
......@@ -1172,11 +1171,9 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
Delete one key
This uses key_buff2, when keynr != primary key, so it's important that
a function that calls this doesn't use this buffer for anything else.
packed_record may be NULL if the key is unique
*/
int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record,
DBT *packed_record,
DBT *prim_key)
{
int error;
......@@ -1208,12 +1205,8 @@ int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record,
&tmp_cursor, 0)))
{
if (!(error=tmp_cursor->c_get(tmp_cursor,
(keynr == primary_key ?
prim_key :
create_key(&key, keynr, key_buff2, record)),
(keynr == primary_key ?
packed_record : prim_key),
DB_GET_BOTH | DB_RMW)))
create_key(&key, keynr, key_buff2, record),
prim_key, DB_GET_BOTH | DB_RMW)))
{ // This shouldn't happen
error=tmp_cursor->c_del(tmp_cursor,0);
}
......@@ -1236,7 +1229,7 @@ int ha_berkeley::remove_keys(DB_TXN *trans, const byte *record,
{
if (keys & 1)
{
int new_error=remove_key(trans, keynr, record, new_record, prim_key);
int new_error=remove_key(trans, keynr, record, prim_key);
if (new_error)
{
result=new_error; // Return last error /* purecov: inspected */
......
......@@ -69,8 +69,7 @@ class ha_berkeley: public handler
int key_length = MAX_KEY_LENGTH);
DBT *pack_key(DBT *key, uint keynr, char *buff, const byte *key_ptr,
uint key_length);
int remove_key(DB_TXN *trans, uint keynr, const byte *record,
DBT *packed_record, DBT *prim_key);
int remove_key(DB_TXN *trans, uint keynr, const byte *record, DBT *prim_key);
int remove_keys(DB_TXN *trans,const byte *record, DBT *new_record,
DBT *prim_key, key_map keys);
int restore_keys(DB_TXN *trans, key_map changed_keys, uint primary_key,
......
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