← Back to team overview

maria-developers team mailing list archive

Re: How to get all fields in a given index?

 

Thanks a lot!

Rongrong

Rongrong


On Tue, Sep 9, 2014 at 8:18 AM, Sergey Petrunia <sergey@xxxxxxxxxxx> wrote:

> On Mon, Sep 08, 2014 at 08:54:00PM +0100, Rongrong wrote:
> > I'm trying to implement some feature that requires to get the list of
> > fields for a given index. I'm trying to follow the optimizer code to find
> > some clue but am not successful so far. Can anyone give me some pointers?
> >
>
> A TABLE object has a member called key_info. It is an array of structures
> describing each index.
>
> For an index $I, table->key_info[$I].usable_key_parts gives the number of
> key
> parts that the optimizer considers (it varies depending on
> extended_keys=on|off
> setting),
>
> Then, table->key_info[$I].key_part is an array of structures describing key
> parts.
> The most interesting are table->key_info[$I].key_part[$PART].field (the
> field
> itself) and table->key_info[$I].key_part[$PART].fieldnr (field number).
>
>
> Alternatively, there is table->field[$FIELD_NO].part_of_key - this is a
> bitmap
> which tells which indexes this field is a part of.
>
> BR
>  Sergei
> --
> Sergei Petrunia, Software Developer
> MariaDB | Skype: sergefp | Blog: http://s.petrunia.net/blog
>
>
>

References