MySQL plugin结构

1、背景


 MySQL插件安装语法如下:

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.html

问题:如何找到plugin_nameshared_library_name对应关系呢?

一个一个查找文档吗?答案不是这样的,当然可以通过源码的方式查找。

2、对应关系查找


2.1、半同步主库设置

[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.2、半同步从库设置

[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.3、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.4、qa_auth_client

[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中进行定义了,通过查找源码:

非常方便找到对应关系

3、MySQL Plugin原理


 

(待续)

4、参考文献


 

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

posted @ 2014-05-19 21:01  小郭学路  阅读(790)  评论(0编辑  收藏  举报