MySQL 5.6.14 Source Code Document
|
The ha_example engine is a stubbed storage engine for example purposes only; it does nothing at this point. Its purpose is to provide a source code illustration of how to begin writing new storage engines; see also /storage/example/ha_example.h. More...
#include "sql_priv.h"
#include "sql_class.h"
#include "ha_example.h"
#include "probes_mysql.h"
#include "sql_plugin.h"
Go to the source code of this file.
Functions | |
mysql_declare_plugin (example) |
Variables | |
handlerton * | example_hton |
const char * | ha_example_system_database = NULL |
struct st_mysql_storage_engine | example_storage_engine |
const char * | enum_var_names [] |
TYPELIB | enum_var_typelib |
mysql_declare_plugin_end |
The ha_example engine is a stubbed storage engine for example purposes only; it does nothing at this point. Its purpose is to provide a source code illustration of how to begin writing new storage engines; see also /storage/example/ha_example.h.
ha_example will let you create/open/delete tables, but nothing further (for example, indexes are not supported nor can data be stored in the table). Use this example as a template for implementing the same functionality in your own storage engine. You can enable the example storage engine in your build by doing the following during your build process:
./configure –with-example-storage-engine
Once this is done, MySQL will let you create tables with:
CREATE TABLE
...) ENGINE=EXAMPLE;
The example storage engine is set up to use table locks. It implements an example "SHARE" that is inserted into a hash by table name. You can use this to store information of state that any example handler object will be able to see when it is using that table.
Please read the object definition in ha_example.h before reading the rest of this file.
Here you see that the example storage engine has 9 rows called before rnd_next signals that it has reached the end of its data. Also note that the table in question was already opened; had it not been open, a call to ha_example::open() would also have been necessary. Calls to ha_example::extra() are hints as to what will be occuring to the request.
A Longer Example can be found called the "Skeleton Engine" which can be found on TangentOrg. It has both an engine and a full build environment for building a pluggable storage engine.
Happy coding!
-Brian
Definition in file ha_example.cc.
const char* enum_var_names[] |
Definition at line 920 of file ha_example.cc.
TYPELIB enum_var_typelib |
Definition at line 925 of file ha_example.cc.
struct st_mysql_storage_engine example_storage_engine |
Definition at line 913 of file ha_example.cc.