mysql 自定义插件调试

# 创建表的stack

frame #0: 0x000000011d11f58a ha_spartan.so`Spartan_data::create_table(this=0x00007f9fc1311c40, path="./test/testarc.sde") + 74 at spartan_data.cc:32
frame #1: 0x000000011d11dded ha_spartan.so`ha_spartan::create(this=0x00007f9fc1314b70, name="./test/testarc", table_arg=0x000070000fd97778, create_info=0x000070000fd9b2f8) + 269 at ha_spartan.cc:923
frame #2: 0x000000010fe6e416 mysqld`handler::ha_create(this=0x00007f9fc1314b70, name="./test/testarc", form=0x000070000fd97778, info=0x000070000fd9b2f8) + 118 at handler.cc:4526
frame #3: 0x000000010fe6ed6f mysqld`ha_create_table(thd=0x00007f9fc0060a00, path="./test/testarc", db="test", table_name="testarc", create_info=0x000070000fd9b2f8, update_create_info=false, is_temp_table=false) + 831 at handler.cc:4770
frame #4: 0x000000011025a877 mysqld`rea_create_table(thd=0x00007f9fc0060a00, path="./test/testarc", db="test", table_name="testarc", create_info=0x000070000fd9b2f8, create_fields=0x000070000fd9b2b0, keys=0, key_info=0x00007f9fbf09d520, file=0x00007f9fbf09d2d0, no_ha_table=false) + 551 at unireg.cc:546
frame #5: 0x00000001101cd650 mysqld`create_table_impl(thd=0x00007f9fc0060a00, db="test", table_name="testarc", error_table_name="testarc", path="./test/testarc", create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268, internal_tmp_table=false, select_field_count=0, no_ha_table=false, is_trans=0x000070000fd9a25e, key_info=0x000070000fd99f88, key_count=0x000070000fd99f84) + 5232 at sql_table.cc:5009
frame #6: 0x00000001101cc13a mysqld`mysql_create_table_no_lock(thd=0x00007f9fc0060a00, db="test", table_name="testarc", create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268, select_field_count=0, is_trans=0x000070000fd9a25e) + 506 at sql_table.cc:5125
frame #7: 0x00000001101cdb60 mysqld`mysql_create_table(thd=0x00007f9fc0060a00, create_table=0x00007f9fbf09c748, create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268) + 272 at sql_table.cc:5174
frame #8: 0x000000011011bc59 mysqld`mysql_execute_command(thd=0x00007f9fc0060a00) + 9673 at sql_parse.cc:3136
frame #9: 0x0000000110117ba0 mysqld`mysql_parse(thd=0x00007f9fc0060a00, rawbuf="CREATE TABLE testarc (a int, b varchar(20), c int) ENGINE=SPARTAN", length=65, parser_state=0x000070000fd9d380) + 1376 at sql_parse.cc:6422
frame #10: 0x00000001101144cf mysqld`dispatch_command(command=COM_QUERY, thd=0x00007f9fc0060a00, packet="CREATE TABLE testarc (a int, b varchar(20), c int) ENGINE=SPARTAN", packet_length=65) + 4367 at sql_parse.cc:1399
frame #11: 0x00000001101170bb mysqld`do_command(thd=0x00007f9fc0060a00) + 875 at sql_parse.cc:1064
frame #12: 0x000000011009a562 mysqld`do_handle_one_connection(thd_arg=0x00007f9fc0060a00) + 498 at sql_connect.cc:982
frame #13: 0x000000011009a30d mysqld`::handle_one_connection(arg=0x00007f9fc0060a00) + 45 at sql_connect.cc:899
frame #14: 0x0000000110773bdd mysqld`::pfs_spawn_thread(arg=0x00007f9fc17736e0) + 333 at pfs.cc:1861
frame #15: 0x00007fff9458993b libsystem_pthread.dylib`_pthread_body + 180
frame #16: 0x00007fff94589887 libsystem_pthread.dylib`_pthread_start + 286
frame #17: 0x00007fff9458908d libsystem_pthread.dylib`thread_start + 13

#  创建表

(lldb) bt

(lldb) bt
* thread #22: tid = 0xcfa54, 0x000000011d11ef2b ha_spartan.so`spartan_create_handler(hton=0x00007f9fc1416490, table=0x0000000000000000, mem_root=0x00007f9fc0063af0) + 27 at ha_spartan.cc:102, stop reason = step in
* frame #0: 0x000000011d11ef2b ha_spartan.so`spartan_create_handler(hton=0x00007f9fc1416490, table=0x0000000000000000, mem_root=0x00007f9fc0063af0) + 27 at ha_spartan.cc:102
frame #1: 0x000000010fe6296b mysqld`get_new_handler(share=0x0000000000000000, alloc=0x00007f9fc0063af0, db_type=0x00007f9fc1416490) + 203 at handler.cc:442
frame #2: 0x00000001101cc47f mysqld`create_table_impl(thd=0x00007f9fc0060a00, db="test", table_name="testarc1", error_table_name="testarc1", path="./test/testarc1", create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268, internal_tmp_table=false, select_field_count=0, no_ha_table=false, is_trans=0x000070000fd9a25e, key_info=0x000070000fd99f88, key_count=0x000070000fd99f84) + 671 at sql_table.cc:4640
frame #3: 0x00000001101cc13a mysqld`mysql_create_table_no_lock(thd=0x00007f9fc0060a00, db="test", table_name="testarc1", create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268, select_field_count=0, is_trans=0x000070000fd9a25e) + 506 at sql_table.cc:5125
frame #4: 0x00000001101cdb60 mysqld`mysql_create_table(thd=0x00007f9fc0060a00, create_table=0x00007f9fbf09c758, create_info=0x000070000fd9b2f8, alter_info=0x000070000fd9b268) + 272 at sql_table.cc:5174
frame #5: 0x000000011011bc59 mysqld`mysql_execute_command(thd=0x00007f9fc0060a00) + 9673 at sql_parse.cc:3136
frame #6: 0x0000000110117ba0 mysqld`mysql_parse(thd=0x00007f9fc0060a00, rawbuf="CREATE TABLE testarc1 (a int, b varchar(20), c int) ENGINE=SPARTAN", length=66, parser_state=0x000070000fd9d380) + 1376 at sql_parse.cc:6422
frame #7: 0x00000001101144cf mysqld`dispatch_command(command=COM_QUERY, thd=0x00007f9fc0060a00, packet="CREATE TABLE testarc1 (a int, b varchar(20), c int) ENGINE=SPARTAN", packet_length=66) + 4367 at sql_parse.cc:1399
frame #8: 0x00000001101170bb mysqld`do_command(thd=0x00007f9fc0060a00) + 875 at sql_parse.cc:1064
frame #9: 0x000000011009a562 mysqld`do_handle_one_connection(thd_arg=0x00007f9fc0060a00) + 498 at sql_connect.cc:982
frame #10: 0x000000011009a30d mysqld`::handle_one_connection(arg=0x00007f9fc0060a00) + 45 at sql_connect.cc:899
frame #11: 0x0000000110773bdd mysqld`::pfs_spawn_thread(arg=0x00007f9fc17736e0) + 333 at pfs.cc:1861
frame #12: 0x00007fff9458993b libsystem_pthread.dylib`_pthread_body + 180
frame #13: 0x00007fff94589887 libsystem_pthread.dylib`_pthread_start + 286
frame #14: 0x00007fff9458908d libsystem_pthread.dylib`thread_start + 13

获取handler

static int spartan_init_func(void *p)
{
DBUG_ENTER("spartan_init_func"); #ifdef HAVE_PSI_INTERFACE
init_spartan_psi_keys();
#endif spartan_hton= (handlerton *)p;
spartan_hton->state= SHOW_OPTION_YES;
spartan_hton->create= spartan_create_handler;
spartan_hton->flags= HTON_CAN_RECREATE;
spartan_hton->system_database= spartan_system_database;
spartan_hton->is_supported_system_table= spartan_is_supported_system_table; DBUG_RETURN(0);
} mysql_declare_plugin(spartan)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&spartan_storage_engine,
"SPARTAN",
"jishu",
"demo storage engine",
PLUGIN_LICENSE_GPL,
spartan_init_func, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0001 /* 0.1 */,
func_status, /* status variables */
spartan_system_variables, /* system variables */
NULL, /* config options */
0, /* flags */
}
mysql_declare_plugin_end;
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
handlerton *db_type)
{
handler *file;
DBUG_ENTER("get_new_handler");
DBUG_PRINT("enter", ("alloc: 0x%lx", (long) alloc)); if (db_type && db_type->state == SHOW_OPTION_YES && db_type->create)
{
if ((file= db_type->create(db_type, share, alloc)))
file->init();
DBUG_RETURN(file);
}
/*
Try the default table type
Here the call to current_thd() is ok as we call this function a lot of
times but we enter this branch very seldom.
*/
DBUG_RETURN(get_new_handler(share, alloc, ha_default_handlerton(current_thd)));
}

  mysql 自定义插件调试

# db 类型

create_table_option:
ENGINE_SYM opt_equal storage_engines
{
Lex->create_info.db_type= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
} storage_engines:
ident_or_text
{
THD *thd= YYTHD;
plugin_ref plugin=
ha_resolve_by_name(thd, &$,
thd->lex->create_info.options & HA_LEX_CREATE_TMP_TABLE); if (plugin)
$$= plugin_data(plugin, handlerton*);
else
{
if (thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION)
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(), $.str);
MYSQL_YYABORT;
}
$$= ;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_UNKNOWN_STORAGE_ENGINE,
ER(ER_UNKNOWN_STORAGE_ENGINE),
$.str);
}
}
;

# 新增的断点

: name = 'ha_spartan::create', locations =  (pending)

: name = 'create', locations =  (pending)

: file = 'ha_spartan.cc', line = , exact_match = , locations = , resolved = , hit count =
3.1: where = ha_spartan.so`ha_spartan::create(char const*, TABLE*, st_ha_create_information*) + at ha_spartan.cc:, address = 0x000000011d11dd4f, resolved, hit count = : file = 'ha_spartan.cc', line = , exact_match = , locations = , resolved = , hit count =
4.1: where = ha_spartan.so`ha_spartan::create(char const*, TABLE*, st_ha_create_information*) + at ha_spartan.cc:, address = 0x000000011d11dd4f, resolved, hit count = : file = 'ha_spartan.cc', line = , exact_match = , locations = , resolved = , hit count =
5.1: where = ha_spartan.so`ha_spartan::create(char const*, TABLE*, st_ha_create_information*) + at ha_spartan.cc:, address = 0x000000011d11dd4f, resolved, hit count = : file = 'ha_spartan.cc', line = , exact_match = , locations = , resolved = , hit count =
6.1: where = ha_spartan.so`ha_spartan::create(char const*, TABLE*, st_ha_create_information*) + at ha_spartan.cc:, address = 0x000000011d11dd4f, resolved, hit count = : name = 'ha_spartan::get_share', locations = , resolved = , hit count =
7.1: where = ha_spartan.so`ha_spartan::get_share() + at ha_spartan.cc:, address = 0x000000011d11c7a7, resolved, hit count = : name = 'create_table_impl', locations = , resolved = , hit count =
8.1: where = mysqld`create_table_impl(THD*, char const*, char const*, char const*, char const*, st_ha_create_information*, Alter_info*, bool, unsigned int, bool, bool*, st_key**, unsigned int*) + at sql_table.cc:, address = 0x00000001101cc2c2, resolved, hit count = : name = 'ha_create_table', locations = , resolved = , hit count =
9.1: where = mysqld`ha_create_table(THD*, char const*, char const*, char const*, st_ha_create_information*, bool, bool) + at handler.cc:, address = 0x000000010fe6ea8e, resolved, hit count = : name = 'open_table_from_share', locations = , resolved = , hit count =
10.1: where = mysqld`open_table_from_share(THD*, TABLE_SHARE*, char const*, unsigned int, unsigned int, unsigned int, TABLE*, bool) + at table.cc:, address = 0x000000011023d652, resolved, hit count = : name = 'get_new_handler', locations = , resolved = , hit count =
11.1: where = mysqld`get_new_handler(TABLE_SHARE*, st_mem_root*, handlerton*) + at handler.cc:, address = 0x000000010fe628cc, resolved, hit count =
11.2: where = libc++abi.dylib`std::get_new_handler(), address = 0x00007fff92f25de3, resolved, hit count = : name = 'spartan_create_handler', locations = , resolved = , hit count =
12.1: where = ha_spartan.so`spartan_create_handler(handlerton*, TABLE_SHARE*, st_mem_root*) + at ha_spartan.cc:, address = 0x000000011d11ef2b, resolved, hit count = : name = 'ha_resolve_by_name', locations = , resolved = , hit count =
13.1: where = mysqld`ha_resolve_by_name(THD*, st_mysql_lex_string const*, bool) + at handler.cc:, address = 0x000000010fe62387, resolved, hit count =
上一篇:java笔记知识点总结


下一篇:Python下载图片小程序