![]() |
MySQL 8.0.40
Source Code Documentation
|
The ha_example engine is a stubbed storage engine for example purposes only; it does nothing at this point. More...
#include "storage/example/ha_example.h"
#include "my_dbug.h"
#include "mysql/plugin.h"
#include "sql/sql_class.h"
#include "sql/sql_plugin.h"
#include "typelib.h"
Classes | |
struct | example_vars_t |
Functions | |
static handler * | example_create_handler (handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root) |
static bool | example_is_supported_system_table (const char *db, const char *table_name, bool is_sql_layer_system_table) |
Check if the given db.tablename is a system table for this SE. More... | |
static int | example_init_func (void *p) |
static int | example_deinit_func (void *p) |
static | MYSQL_THDVAR_STR (last_create_thdvar, PLUGIN_VAR_MEMALLOC, nullptr, nullptr, nullptr, nullptr) |
static | MYSQL_THDVAR_UINT (create_count_thdvar, 0, nullptr, nullptr, nullptr, 0, 0, 1000, 0) |
static | MYSQL_SYSVAR_ENUM (enum_var, srv_enum_var, PLUGIN_VAR_RQCMDARG, "Sample ENUM system variable.", nullptr, nullptr, 0, &enum_var_typelib) |
static | MYSQL_SYSVAR_ULONG (ulong_var, srv_ulong_var, PLUGIN_VAR_RQCMDARG, "0..1000", nullptr, nullptr, 8, 0, 1000, 0) |
static | MYSQL_SYSVAR_DOUBLE (double_var, srv_double_var, PLUGIN_VAR_RQCMDARG, "0.500000..1000.500000", nullptr, nullptr, 8.5, 0.5, 1000.5, 0) |
static | MYSQL_THDVAR_DOUBLE (double_thdvar, PLUGIN_VAR_RQCMDARG, "0.500000..1000.500000", nullptr, nullptr, 8.5, 0.5, 1000.5, 0) |
static | MYSQL_SYSVAR_INT (signed_int_var, srv_signed_int_var, PLUGIN_VAR_RQCMDARG, "INT_MIN..INT_MAX", nullptr, nullptr, -10, INT_MIN, INT_MAX, 0) |
static | MYSQL_THDVAR_INT (signed_int_thdvar, PLUGIN_VAR_RQCMDARG, "INT_MIN..INT_MAX", nullptr, nullptr, -10, INT_MIN, INT_MAX, 0) |
static | MYSQL_SYSVAR_LONG (signed_long_var, srv_signed_long_var, PLUGIN_VAR_RQCMDARG, "LONG_MIN..LONG_MAX", nullptr, nullptr, -10, LONG_MIN, LONG_MAX, 0) |
static | MYSQL_THDVAR_LONG (signed_long_thdvar, PLUGIN_VAR_RQCMDARG, "LONG_MIN..LONG_MAX", nullptr, nullptr, -10, LONG_MIN, LONG_MAX, 0) |
static | MYSQL_SYSVAR_LONGLONG (signed_longlong_var, srv_signed_longlong_var, PLUGIN_VAR_RQCMDARG, "LLONG_MIN..LLONG_MAX", nullptr, nullptr, -10, LLONG_MIN, LLONG_MAX, 0) |
static | MYSQL_THDVAR_LONGLONG (signed_longlong_thdvar, PLUGIN_VAR_RQCMDARG, "LLONG_MIN..LLONG_MAX", nullptr, nullptr, -10, LLONG_MIN, LLONG_MAX, 0) |
static int | show_func_example (MYSQL_THD, SHOW_VAR *var, char *buf) |
mysql_declare_plugin (example) | |
Variables | |
handlerton * | example_hton |
static st_handler_tablename | ha_example_system_tables [] |
struct st_mysql_storage_engine | example_storage_engine |
static ulong | srv_enum_var = 0 |
static ulong | srv_ulong_var = 0 |
static double | srv_double_var = 0 |
static int | srv_signed_int_var = 0 |
static long | srv_signed_long_var = 0 |
static longlong | srv_signed_longlong_var = 0 |
const char * | enum_var_names [] = {"e1", "e2", NullS} |
TYPELIB | enum_var_typelib |
static SYS_VAR * | example_system_variables [] |
example_vars_t | example_vars = {100, 20.01, "three hundred", true, false, 8250} |
static SHOW_VAR | show_status_example [] |
static SHOW_VAR | show_array_example [] |
static SHOW_VAR | func_status [] |
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 <table name> (...) 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 occurring 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
|
static |
|
static |
|
static |
|
static |
Check if the given db.tablename is a system table for this SE.
db | Database name to check. |
table_name | table name to check. |
is_sql_layer_system_table | if the supplied db.table_name is a SQL layer system table. |
true | Given db.table_name is supported system table. |
false | Given db.table_name is not a supported system table. |
mysql_declare_plugin | ( | example | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
const char* enum_var_names[] = {"e1", "e2", NullS} |
TYPELIB enum_var_typelib |
handlerton* example_hton |
struct st_mysql_storage_engine example_storage_engine |
|
static |
example_vars_t example_vars = {100, 20.01, "three hundred", true, false, 8250} |
|
static |
|
static |
mysql_declare_plugin_end |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |