drizzle
Profile
Search
 
Hosted by The Rackspace Cloud
Tutorial : Writing A Storage Engine for Drizzle

Contents

Writing A Storage Engine for Drizzle

This turorial is a edited version of Stewart Smith's blog post

First Step is to create a skeleton StorageEngine plugin.
You can refer Stewart Smith's merge request for embedded_innodb StorageEngine plugin.
This tutorial explains step by step instructions to create same Storage Engine Plugin.

Create A Plugin directory

 mkdir plugin/embedded_innodb

Create the plugin.ini file

The file need to be inside the above created directory and this file describes the plugin.

[plugin]
title=InnoDB Storage Engine using the Embedded InnoDB library
description=Work in progress engine using libinnodb instead of including it in tree.
sources=embedded_innodb_engine.cc
headers=embedded_innodb_engine.h

This contains Title, Description and information for build : source files and headers

Add Pluggin dependencies (plugin.ac)

This particular plugin is dependent on Embedded InnoDB library (libinnodb). another example is : BlitzDB storage requiring Tokyo Cabinet libraries

pandora-build has a macro for finding libinnodb on the system and We want to run this configure check. so we create a plugin.ac file in the plugin directory

For embedded_innodb, the plugin.ac file just contains this one line:

PANDORA_HAVE_LIBINNODB

Now we need tell the build (by adding lines to plugin.ini) to
1. build this plugin only if libinnodb is found
2. link this plugin to libinnodb
Add following lines to plugin.in

build_conditional="x${ac_cv_libinnodb}" = "xyes"
ldflags=${LTLIBINNODB}

Add skeleton source code for your StorageEngine

Please refer Stewart Smith's merge request for mbedded_innodb StorageEngine plugin because it is not feasible to copy the source code completely here.

WARNING: There can be few changes over time

Build

Let build system picks up new plugin

./config/autorun.sh

Afterwards ./configure will give option to enable/disable this plugin

Add Test

When your plugin is built, the test suite automatically picks up any tests you have in the plugin/plugin_name/tests directory
(tests go in a t/ directory, expected results in a r/ directory) Need to instruct the drizzle server to load the plugin by the file test-master.opt
For this particular plugin's plugin_load testing, we have a plugin/embedded_innodb/tests/t/plugin_load-master.opt file with the following content:

--plugin_add=embedded_innodb

You can have pretty much anything in the plugin_load.test file… if you’re fancy, you’ll have a SELECT query on data_dictionary.plugins to check that the plugin really is there. Be sure to also add a r/plugin_load.result file (My preferred method is to just create an empty result file, run the test suite and examine the rejected output before renaming the .reject file to .result)

Once you’ve added your test, you can run it either by just typing “make test” (which will run the whole test suite), or you can go into the main tests/ directory and run ./test-run.pl --suite=plugin_name (which will just run the tests for your plugin).


Last updated : 01:27, 5 March 2010 (UTC)

Further Suggeted Reading

MySQL Storage Engine development

Stewart's original blog posts: