MySQL plugin結構

一、背景


 MySQL插件安裝語法以下:html

13.7.3.3 INSTALL PLUGIN Syntax
INSTALL PLUGIN plugin_name SONAME 'shared_library_name'

http://dev.mysql.com/doc/refman/5.5/en/install-plugin.htmlmysql

問題:如何找到plugin_nameshared_library_name對應關係呢?

一個一個查找文檔嗎?答案不是這樣的,固然能夠經過源碼的方式查找。sql

二、對應關係查找


2.一、半同步主庫設置vim

[root@typhoeus81 ice_test_2 semisync]# pwd
/data1/guosong/opdir/mysql-5.6.16/plugin/semisync/semisync_master_plugin.cc

434 /*
435   Plugin library descriptor
436 */
437 mysql_declare_plugin(semi_sync_master)
438 {
439   MYSQL_REPLICATION_PLUGIN,
440   &semi_sync_master_plugin,
441   "rpl_semi_sync_master",
442   "He Zhenxing",
443   "Semi-synchronous replication master",
444   PLUGIN_LICENSE_GPL,
445   semi_sync_master_plugin_init, /* Plugin Init */
446   semi_sync_master_plugin_deinit, /* Plugin Deinit */
447   0x0100 /* 1.0 */,
448   semi_sync_master_status_vars, /* status variables */
449   semi_sync_master_system_vars, /* system variables */
450   NULL,                         /* config options */
451   0,                            /* flags */
452 }
453 mysql_declare_plugin_end;

 2.二、半同步從庫設置spa

[root@typhoeus81 ice_test_2 semisync]# pwd
/data1/guosong/opdir/mysql-5.6.16/plugin/semisync
[root@typhoeus81 ice_test_2 semisync]# vim semisync_slave_plugin.cc

215 mysql_declare_plugin(semi_sync_slave)
216 {
217   MYSQL_REPLICATION_PLUGIN,
218   &semi_sync_slave_plugin,
219   "rpl_semi_sync_slave",
220   "He Zhenxing",
221   "Semi-synchronous replication slave",
222   PLUGIN_LICENSE_GPL,
223   semi_sync_slave_plugin_init, /* Plugin Init */
224   semi_sync_slave_plugin_deinit, /* Plugin Deinit */
225   0x0100 /* 1.0 */,
226   semi_sync_slave_status_vars,  /* status variables */
227   semi_sync_slave_system_vars,  /* system variables */
228   NULL,                         /* config options */
229   0,                            /* flags */
230 }

 2.三、audit_null插件

[root@typhoeus81 ice_test_2 audit_null]# pwd
/data1/guosong/opdir/mysql-5.6.16/plugin/audit_null
[root@typhoeus81 ice_test_2 audit_null]# vim audit_null.c 

195 mysql_declare_plugin(audit_null)
196 { 
197   MYSQL_AUDIT_PLUGIN,         /* type                            */
198   &audit_null_descriptor,     /* descriptor                      */
199   "NULL_AUDIT",               /* name                            */
200   "Oracle Corp",              /* author                          */
201   "Simple NULL Audit",        /* description                     */
202   PLUGIN_LICENSE_GPL,
203   audit_null_plugin_init,     /* init function (when loaded)     */
204   audit_null_plugin_deinit,   /* deinit function (when unloaded) */
205   0x0003,                     /* version                         */
206   simple_status,              /* status variables                */
207   NULL,                       /* system variables                */
208   NULL,
209   0,
210 }
211 mysql_declare_plugin_end;

 2.四、qa_auth_clientcode

[root@typhoeus81 ice_test_2 auth]# pwd
/data1/guosong/opdir/mysql-5.6.16/plugin/auth
[root@typhoeus81 ice_test_2 auth]# vim qa_auth_client.c 

116 mysql_declare_client_plugin(AUTHENTICATION)
117   "qa_auth_client",
118   "Horst Hunger",
119   "Dialog Client Authentication Plugin",
120   {0,1,0},
121   "GPL",
122   NULL,
123   NULL,
124   NULL,
125   NULL,
126   test_plugin_client
127 mysql_end_client_plugin;

 規律的就是在mysql_declare_plugin中進行定義了,經過查找源碼:htm

很是方便找到對應關係blog

三、MySQL Plugin原理


 

(待續)ip

四、參考文獻


 

http://dev.mysql.com/doc/refman/5.6/en/plugin-data-structures.html

相關文章
相關標籤/搜索