Re: storage engine: how to identify PRIMARY keys?
Christoph Rupp <[email protected]> Wed, 11 May 2016 11:11:24 +0200
| Newsgroups | gmane.comp.db.mysql.devel |
|---|---|
| Message-ID | <CAE6Xdb4GVGa6LVUb+ne=P4+Q2ZZ+7YeanWb4z-m_bXyeTSnhjg@mail.gmail.com> |
table->s->primary_key is always 0. I.e. for the following statement i would have expected it to be 1: create table test1 (value integer, id integer primary key); My current workaround (not yet tested extensively): I search table->key_info for the primary key (table->key_info[i]->name must be "PRIMARY"), then I can retrieve any additional information like table type, name etc through table->key_info[i]->key_part->field. (I need that information to set up my index tables.) 2016-05-10 18:57 GMT+02:00 Vlad Lesin <[email protected]>: > If I understand your question correctly you need something like this: > table->s->primary_key - pk field number, equals to MAX_KEY if there is > no explicit pk. > > On 10/05/16 12:11, Christoph Rupp wrote: >> Hi, >> >> in the ::create() method of my storage engine I want to create indices >> for all columns where (*field)->m_indexed is true. >> >> As far as I understand there are different types of indices: >> - PRIMARY: always unique >> - INDEX: usually not unique (can have duplicate keys) >> >> but I have not been able to figure out whether a FIELD object is a >> primary key or not. >> >> I saw that the Schema description (TABLE->s) has more information >> about the columns, but it seems they're already sorted by priority >> (i.e. primary key is first), whereas the FIELD objects are not sorted. >> >> Thanks >> Christoph >> > > > -- > Best regards, > Vlad -- MySQL Internals Mailing List For list archives: http://lists.mysql.com/internals To unsubscribe: http://lists.mysql.com/internals