List:Commits« Previous MessageNext Message »
From:Sergei Golubchik Date:November 12 2008 10:18am
Subject:Re: bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742
View as plain text  
Hi, Georgi!

On Nov 12, Georgi Kodinov wrote:
> Serg,
>
> On 12.11.2008, at 02:01, Sergei Golubchik wrote:
>
>> Yes, that much I know. I asked what code was enabling keyread for
>> partial keys.  As you can see, in open_binary_frm() partial keys are
>> *not* added to keys_for_keyread bitmap. So, how comes that a keyread
>> is enabled for a key not present in keys_for_keyread ?
>
> It's not exactly like this in open_binary_frm.  The way it works is
> that a key is added to the keys_for_keyread bitmap whenever there's a
> single non-partial keypart into it.  So keys like (e.g.) KEY (a, b(3))
> will still get added.

okay

> But this bug is about storage engines like innodb that have the
> primary key clustered to the secondary keys, e.g.  CREATE TABLE (a
> char(10), b int, PRIMARY KEY (a(3)), KEY (b)) Engine=Innodb.  In this
> case open_binary_frm appends the primary key parts (partial in this
> case) to a secondary key that open_binary_frm thinks is covering.

Yes, but it should be ok, isn't it ? It's the same as adding KEY(a,b(3))
from your first example - it's covering on 'a', but not on 'b'.
Similarly, in your second example, the key(b) is still covering for b,
and keyread can be used for SELECT b FROM, but not for SELECT a FROM.

Don't you think that the bug is here:

  /*
    If this field is part of the primary key and all keys contains
    the primary key, then we can use any key to find this column
  */
  if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
  {
    field->part_of_key= share->keys_in_use;
    if (field->part_of_sortkey.is_set(key))
      field->part_of_sortkey= share->keys_in_use;
  }

looks like it shouldn't set field->part_of_key to all keys if the
primary key is built on the part of the field.

> I had a discussion with Igor last night on this bug and he managed to
> convince me that this is actually not a bug.
> It's not a bug because it's the storage engine's job to reply
> negatively for a key that it thinks is not covering (there's a check
> in open_binary_frm on the storage engine returning HA_KEYREAD_ONLY for
> the index just before it gets added to the keys_for_keyread).

No, I don't think so. Engine uses that for engine-specific checks,
but the server should take care of generic and obvious checks like no
keyread for partial indexes.

Regards / Mit vielen Grüßen,
Sergei

-- 
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@stripped>
 / /|_/ / // /\ \/ /_/ / /__  Principal Software Engineer/Server Architect
/_/  /_/\_, /___/\___\_\___/  Sun Microsystems GmbH, HRB München 161028
       <___/                  Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Häring
Thread
bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742Georgi Kodinov11 Nov
  • Re: bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742Sergei Golubchik11 Nov
Re: bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742Sergei Golubchik12 Nov
Re: bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742Sergei Golubchik12 Nov
Re: bzr commit into mysql-5.1 branch (kgeorge:2703) Bug#37742Sergei Golubchik25 Nov