Re: [Maria-developers] How to get all fields in a given index?

2014-09-10 Thread Rongrong
Thanks a lot!

Rongrong

Rongrong


On Tue, Sep 9, 2014 at 8:18 AM, Sergey Petrunia ser...@mariadb.com 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



___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] How to get all fields in a given index?

2014-09-09 Thread Sergey Petrunia
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



___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] How to get all fields in a given index?

2014-09-08 Thread Rongrong
Hi,

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?

Thanks!
Rongrong
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp