diff options
author | ingo@mysql.com <> | 2004-06-22 17:27:57 +0200 |
---|---|---|
committer | ingo@mysql.com <> | 2004-06-22 17:27:57 +0200 |
commit | e1cd282ea2d43b68468f22319affd152447919bb (patch) | |
tree | 1b7296aae4148b71f0a0197d64a51b5728af6d7e /sql/ha_berkeley.cc | |
parent | fe3f6f4c362599cefa84fe681d6e45b003e7e5c9 (diff) | |
download | mariadb-git-e1cd282ea2d43b68468f22319affd152447919bb.tar.gz |
bug#2688 - Wrong index_merge query results for BDB table with variable length primary key.
dded code to clear the tail of the reference buffer if the actual key length
is less than the maximum key length.
Diffstat (limited to 'sql/ha_berkeley.cc')
-rw-r--r-- | sql/ha_berkeley.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 3522aadf349..18af688d07c 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1611,13 +1611,44 @@ int ha_berkeley::rnd_pos(byte * buf, byte *pos) (char*) buf, primary_key, ¤t_row, (DBT*) 0, 0)); } +/* + Set a reference to the current record in (ref,ref_length). + + SYNOPSIS + ha_berkeley::position() + record The current record buffer + + DESCRIPTION + The BDB handler stores the primary key in (ref,ref_length). + There is either an explicit primary key, or an implicit (hidden) + primary key. + During open(), 'ref_length' is calculated as the maximum primary + key length. When an actual key is shorter than that, the rest of + the buffer must be cleared out. The row cannot be identified, if + garbage follows behind the end of the key. There is no length + field for the current key, so that the whole ref_length is used + for comparison. + + RETURN + nothing +*/ + void ha_berkeley::position(const byte *record) { DBT key; + DBUG_ENTER("ha_berkeley::position"); if (hidden_primary_key) + { + DBUG_ASSERT(ref_length == BDB_HIDDEN_PRIMARY_KEY_LENGTH); memcpy_fixed(ref, (char*) current_ident, BDB_HIDDEN_PRIMARY_KEY_LENGTH); + } else + { create_key(&key, primary_key, (char*) ref, record); + if (key.size < ref_length) + bzero(ref + key.size, ref_length - key.size); + } + DBUG_VOID_RETURN; } |