From: Thomas Jones-Low
Date: April 24 2013 12:48pm
Subject: Re: adding an index of my own type/code
List-Archive: http://lists.mysql.com/internals/38754
Message-Id: <5177D481.2060700@akiban.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
I believe, and it has been a while so I can't provide exact pointers,
that the ha_create process (which is where the CREATE INDEX gets
processed), does ask the storage engine for the supported index types.
You should read through the processing in
/sql/handler.cc, handler.h, and table.cc
It has been my experience in writing storage engines that you don't
need to alter the MySQL source to do some interesting things. But you do
need to know all the ins and outs of the processing.
On 4/24/13 5:59 AM, AugustQ wrote:
> Hi,
>
> and thanks for your hints.
>
> Here is what I did: I created a tiny storage engine which inherits its
> functionality from MyIsam. I can load this code and so I created a table
> with this type of storage engine.
>
> Next I wanted to see what my storage engine can do if I add an index to
> this table.
>
> If I create an index without specifying an index-type everything works.
> In the ::create(()-function I see the columns that describe the index.
>
> When I create an index using an index-engine-type by giving the keyword
> engine or type or using in the CREATE-stmt, it works when I use one of
> the keywords given in the description like BTREE or HASH. But when I
> create an index using my own keyword then I got immediately the syntax
> error.
>
> In my example I used the word AQTREE for the description of the
> index-engine. I wanted to see at the storage-engine-level, what
> information was given to my code but this storage engine (my code) was
> never called.
>
> What I expected: MySQL offers the choice of adding another storage
> engine without modifying the source code of MySQL itself. So I assumed
> that this would include the creating and handling of an index.
>
> Is this possible?
>
> Thanks
> AugustQ
>
> Am Dienstag, den 23.04.2013, 09:28 -0700 schrieb Stewart Smith:
>> AugustQ writes:
>>> I'm using the source-code of MySQL-version 5.5.8
>>
>> You really want to use something more recent. 5.5.8 is ancient.
>>
>>> I want to implement my own type of an index and play with it. How can I
>>> do this?
>>
>> You have to do this inside a storage engine, the MySQL server itself
>> doesn't deal with indexing (although the optimizer obviously has some knowledge).
>>
>>> It's easy to add a storage engine. For creating the index on a table I
>>> use a statement like:
>>> create index PRIMA3
>>> on ABDAOK(Id, PZN, ArtikelBez)
>>> type AQTREE;
>>>
>>> I go a syntax-error: ERROR 1064 (42000)
>>>
>>> What do I have to do to implement my own index-code?
>>
>> Pick an engine: MyISAM, Heap, InnoDB (default) or one of the third party
>> ones and go for it. Getting any actual code merged into MySQL if you
>> don't work for Oracle is... well... problematic at best.
>>
>> If you're wanting to experiment with different indexing methods, it is
>> possible that the PostgreSQL code is a better choice - and a higher
>> chance of ever having code integrated.
>>
>> You can, of course, write your own storage engine with whatever indexing
>> methods you like (and just lie to the optimizer about it being like a
>> BTREE :)
>>
>>> Is there a newer version that supports this better?
>>
>> No. Drizle takes away some of the server side issues, but it's still all
>> the responsibility of the storage engine.
>>
>
>
>