4 Mar
2014
4 Mar
'14
1:23 p.m.
Hi Sergei, On Tue, Mar 04, 2014 at 01:05:33PM +0100, Sergei Golubchik wrote: > Hi, Sergey! > > On Mar 03, Sergey Vojtovich wrote: > > > > === modified file 'sql/mdl.cc' > > > > --- a/sql/mdl.cc 2014-02-14 12:25:41 +0000 > > > > +++ b/sql/mdl.cc 2014-02-20 07:25:33 +0000 > > > > @@ -760,13 +760,22 @@ void MDL_map::init() > > > > } > > > > > > > > > > > > +my_hash_value_type mdl_hash_function(const CHARSET_INFO *cs, > > > > + const uchar *key, size_t length) > > > > +{ > > > > + return *((my_hash_value_type*) (key - offsetof(MDL_key, m_ptr) + > > > > + offsetof(MDL_key, m_hash_value))) + > > > > + key[0]; > > > > > > I'd prefer to avoid pointer and offset juggling. Because you use a > > > custom hash function anyway, you can directly pass MDL_key as your > > > "key", then here you can use ((MDL_key*)key)->hash_value() > > I'd prefer to avoid it too. But there is hashcmp() function which is called > > when there are many records in a hash bucket. It does my_strnncoll() and > > MDL_key as it is now is not good for strnncoll. > > But hashcmp() uses HASH::get_key() callback to get the key. > You can use it to return MDL_key::m_ptr That's how it is now and that's the reason for this juggling. :) I.e. my_hash_first_from_hash_value(): - calls hashcmp(key) which assumes key is MDL_key::m_ptr - calls my_hash_rec_mask()/hash_function(key) which should assume key is MDL_key Regards, Sergey