The ha_example engine is a stubbed storage engine for example purposes only; it does nothing at this point.
More...
|
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) |
|
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.
- Note
- When you create an EXAMPLE table, the MySQL Server creates a table .frm (format) file in the database directory, using the table name as the file name as is customary with MySQL. No other files are created. To get an idea of what occurs, here is an example select that would do a scan of an entire table:
ENUM HA_EXTRA_RESET Reset database to after
open
int rnd_init(bool scan) override
Unlike index_init(), rnd_init() can be called two consecutive times without rnd_end() in between (it ...
Definition: ha_example.cc:438
int external_lock(THD *thd, int lock_type) override
required
Definition: ha_example.cc:613
THR_LOCK_DATA ** store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) override
required
Definition: ha_example.cc:655
int extra(enum ha_extra_function operation) override
extra() is called whenever the server wishes to send a hint to the storage engine.
Definition: ha_example.cc:566
int rnd_next(uchar *buf) override
required
Definition: ha_example.cc:463
int info(uint) override
required
Definition: ha_example.cc:552
stdx::expected< int, std::error_code > open(const char *fname, int flags, mode_t mode) noexcept
Definition: file_handle.cc:79
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