91 #include "sql_class.h"            
   93 #include "probes_mysql.h" 
   94 #include "sql_plugin.h" 
  103 static const char* example_system_database();
 
  104 static bool example_is_supported_system_table(
const char *db,
 
  106                                       bool is_sql_layer_system_table);
 
  107 #ifdef HAVE_PSI_INTERFACE 
  108 static PSI_mutex_key ex_key_mutex_Example_share_mutex;
 
  110 static PSI_mutex_info all_example_mutexes[]=
 
  112   { &ex_key_mutex_Example_share_mutex, 
"Example_share::mutex", 0}
 
  115 static void init_example_psi_keys()
 
  117   const char* category= 
"example";
 
  120   count= array_elements(all_example_mutexes);
 
  125 Example_share::Example_share()
 
  127   thr_lock_init(&lock);
 
  129                    &mutex, MY_MUTEX_INIT_FAST);
 
  133 static int example_init_func(
void *p)
 
  135   DBUG_ENTER(
"example_init_func");
 
  137 #ifdef HAVE_PSI_INTERFACE 
  138   init_example_psi_keys();
 
  142   example_hton->state=                     SHOW_OPTION_YES;
 
  143   example_hton->create=                    example_create_handler;
 
  144   example_hton->flags=                     HTON_CAN_RECREATE;
 
  164   DBUG_ENTER(
"ha_example::get_share()");
 
  177   DBUG_RETURN(tmp_share);
 
  185   return new (mem_root) 
ha_example(hton, table);
 
  211 static const char *ha_example_exts[] = {
 
  217   return ha_example_exts;
 
  225 const char* ha_example_system_database= NULL;
 
  226 const char* example_system_database()
 
  228   return ha_example_system_database;
 
  241   {(
const char*)NULL, (
const char*)NULL}
 
  256 static bool example_is_supported_system_table(
const char *db,
 
  258                                               bool is_sql_layer_system_table)
 
  263   if (is_sql_layer_system_table)
 
  267   systab= ha_example_system_tables;
 
  268   while (systab && systab->db)
 
  270     if (systab->db == db &&
 
  271         strcmp(systab->tablename, table_name) == 0)
 
  298   DBUG_ENTER(
"ha_example::open");
 
  300   if (!(share = get_share()))
 
  302   thr_lock_data_init(&share->lock,&lock,NULL);
 
  325   DBUG_ENTER(
"ha_example::close");
 
  362   DBUG_ENTER(
"ha_example::write_row");
 
  399   DBUG_ENTER(
"ha_example::update_row");
 
  400   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 
  426   DBUG_ENTER(
"ha_example::delete_row");
 
  427   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 
  439                                key_part_map keypart_map __attribute__((unused)),
 
  440                                enum ha_rkey_function find_flag
 
  441                                __attribute__((unused)))
 
  444   DBUG_ENTER(
"ha_example::index_read");
 
  445   MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
  446   rc= HA_ERR_WRONG_COMMAND;
 
  447   MYSQL_INDEX_READ_ROW_DONE(rc);
 
  460   DBUG_ENTER(
"ha_example::index_next");
 
  461   MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
  462   rc= HA_ERR_WRONG_COMMAND;
 
  463   MYSQL_INDEX_READ_ROW_DONE(rc);
 
  476   DBUG_ENTER(
"ha_example::index_prev");
 
  477   MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
  478   rc= HA_ERR_WRONG_COMMAND;
 
  479   MYSQL_INDEX_READ_ROW_DONE(rc);
 
  497   DBUG_ENTER(
"ha_example::index_first");
 
  498   MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
  499   rc= HA_ERR_WRONG_COMMAND;
 
  500   MYSQL_INDEX_READ_ROW_DONE(rc);
 
  518   DBUG_ENTER(
"ha_example::index_last");
 
  519   MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str);
 
  520   rc= HA_ERR_WRONG_COMMAND;
 
  521   MYSQL_INDEX_READ_ROW_DONE(rc);
 
  541   DBUG_ENTER(
"ha_example::rnd_init");
 
  545 int ha_example::rnd_end()
 
  547   DBUG_ENTER(
"ha_example::rnd_end");
 
  569   DBUG_ENTER(
"ha_example::rnd_next");
 
  570   MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str,
 
  572   rc= HA_ERR_END_OF_FILE;
 
  573   MYSQL_READ_ROW_DONE(rc);
 
  601   DBUG_ENTER(
"ha_example::position");
 
  622   DBUG_ENTER(
"ha_example::rnd_pos");
 
  623   MYSQL_READ_ROW_START(table_share->db.str, table_share->table_name.str,
 
  625   rc= HA_ERR_WRONG_COMMAND;
 
  626   MYSQL_READ_ROW_DONE(rc);
 
  671   DBUG_ENTER(
"ha_example::info");
 
  687   DBUG_ENTER(
"ha_example::extra");
 
  713   DBUG_ENTER(
"ha_example::delete_all_rows");
 
  714   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 
  736   DBUG_ENTER(
"ha_example::truncate");
 
  737   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 
  760   DBUG_ENTER(
"ha_example::external_lock");
 
  804                                        enum thr_lock_type lock_type)
 
  806   if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
 
  834   DBUG_ENTER(
"ha_example::delete_table");
 
  856   DBUG_ENTER(
"ha_example::rename_table ");
 
  857   DBUG_RETURN(HA_ERR_WRONG_COMMAND);
 
  877   DBUG_ENTER(
"ha_example::records_in_range");
 
  904   DBUG_ENTER(
"ha_example::create");
 
  914 { MYSQL_HANDLERTON_INTERFACE_VERSION };
 
  916 static ulong srv_enum_var= 0;
 
  917 static ulong srv_ulong_var= 0;
 
  918 static double srv_double_var= 0;
 
  920 const char *enum_var_names[]=
 
  927   array_elements(enum_var_names) - 1, 
"enum_var_typelib",
 
  931 static MYSQL_SYSVAR_ENUM(
 
  935   "Sample ENUM system variable.", 
 
  941 static MYSQL_SYSVAR_ULONG(
 
  953 static MYSQL_SYSVAR_DOUBLE(
 
  957   "0.500000..1000.500000",
 
  965 static MYSQL_THDVAR_DOUBLE(
 
  968   "0.500000..1000.500000",
 
  977   MYSQL_SYSVAR(enum_var),
 
  978   MYSQL_SYSVAR(ulong_var),
 
  979   MYSQL_SYSVAR(double_var),
 
  980   MYSQL_SYSVAR(double_thdvar),
 
  988   var->type= SHOW_CHAR;
 
  990   my_snprintf(buf, SHOW_VAR_FUNC_BUFF_SIZE,
 
  991               "enum_var is %lu, ulong_var is %lu, " 
  992               "double_var is %f, %.6b", 
 
  993               srv_enum_var, srv_ulong_var, srv_double_var, 
"really");
 
  999   {
"example_func_example",  (
char *)show_func_example, SHOW_FUNC},
 
 1003 mysql_declare_plugin(example)
 
 1005   MYSQL_STORAGE_ENGINE_PLUGIN,
 
 1006   &example_storage_engine,
 
 1008   "Brian Aker, MySQL AB",
 
 1009   "Example storage engine",
 
 1015   example_system_variables,                     
 
 1019 mysql_declare_plugin_end;