您的位置:首页 > 数据库 > MySQL

Mysql 体系结构系列之十一

2013-10-18 17:31 573 查看
前言:参考Mysql体系结构系列之十:细看核心模块
http://blog.csdn.net/nature_ann/article/details/12441665

1. 细看核心模块 Detailed Look at the Core Modules

1.1 Table Maintenance Module 表维护模块

<<---- Table Maintenance Module-- sql_table.cc-- mysql_admin_table( )-- ----->>

The
Table Maintenance Module is responsible for table maintenance operations such ascheck,
repair, back up,
restore, optimize (defragment), andanalyze (update key distribution statistics).

表维护模块负责表维护操作,诸如检查、修理、备份、恢复、优化(碎片整理)及分析(更新键分布统计)。
 
The code is found in sql/sql_table.cc. The core function is
mysql_admin_table( ), with the following convenience wrappers:
>>mysql_check_table( )
>>mysql_repair_table( )
>>mysql_backup_table( )
>>mysql_restore_table( )
>>mysql_optimize_table( )
>>mysql_analyze_table( )
mysql_admin_table( ) will further dispatch the request to the appropriate storage
engine method. The bulk of the work happens on the storage engine level.
代码位于sql/sql_table.cc中,核心函数为mysql_admin_table(),具有下列一些使用方便的封装器:mysql_check_table(),mysql_repair_table( ),
mysql_backup_table( ),mysql_restore_table( ),mysql_optimize_table( ),mysql_analyze_table( ).
Mysql_admin_table()将会进一步将请求派发给适当的存储引擎方法。大部分工作都在存储引擎层次上完成。
 
The module was introduced in version 3.23 to provide an SQL interface for table
maintenance. Prior to that table maintenance had to beperformed offline. In version
4.1, significant changes were made to the Network Protocol Module to support prepared statements.
在3.2版本中引进了该模块,提供用于表维护的SQL接口。在此之前,表维护必须离线进行。4.1版本中对网络协议模块进行了大量修改,以支持预处理语句。
 
This affected all the modules thattalk back to the client, including the Table Maintenance Module. Otherwise, not much has changed since its introduction,and it
is reasonable to expect that not much will in the future.
这对所有对客户端进行回应的模块都有所影响,表维护模块也不例外。另外,由于该模块在引进后没有多大改动,我们又理由预测,以后也不会有多大改变。

1.2 Status Reporting Module 状态报告模块

<<---Status Reporting Module-- answering queries-query show-sql/sql_show.cc ----->>

The
Status Reporting Moduleis responsible for answering queries about
server configuration settings,
performance tracking variables, table structure information,replication progress,
condition of the table cache, and other things.
状态报告模块负责回答关于服务器配置设置性能追踪变量、表结构信息、复制进度、表高速缓存状况等查询。
 
It handles
queries that begin with SHOW. Most of the code is found in sql/sql_show.cc. Some functions of interest, all in sql/sql_show.cc unless indicated otherwise, are:
>>mysqld_list_processes( )
>>mysqld_show( )
>>mysqld_show_create( )
>>mysqld_show_fields( )
>>mysqld_show_open_tables( )
>>mysqld_show_warnings( )
>>show_master_info( ) in sql/slave.cc
>>show_binlog_info( ) in sql/sql_repl.cc
该模块处理以show开始的查询。大部分代码位于sql/sql_show.cc中。除非另有说明,否则有关函数都在sql/sql_show.cc中,包括: mysqld_list_processes( ),
mysqld_show( ),mysqld_show_create( ),mysqld_show_fields( ),mysqld_show_open_tables( ),mysqld_show_warnings( ),位于sql/slave.cc中的show_master_info( ),位于sql/sql_repl.cc中的show_binlog_info( )
 
The module has been constantly evolving. The addition of new functionality has created the need for additional status reporting. It is reasonable to expect that this pattern will continue in
the future.
该模块不断演变。新功能的增加产生了对附加状态报告的需求。我们有理由相信这一模式将在以后继续。

1.3 Absracted Strorage Engine Interface (Table Handler)抽象存储引擎接口(表处理器)

<<--- abstract class named handler -- handlerton
-- standardized interface--sql/handler.h ---
sql/handler.cc -- storage engines --->>

This module is actually an
abstract class named handler and a structure called a
handlerton. The handlerton structure was added in version 5.1 for plug-in integration.
这个模块实际上是一个名为handler的抽象类和一个名为handlerton的结构。
在5.1版本中添加了handlerton结构实现插件集成。
 
It provides a
standardized interface to perform
low-level storageand retrieval operations.
它提供了执行低层次存储与检索操作的标准化接口。
 
The table hander is defined in
sql/handler.h and partially implemented in
sql/handler.cc.
表处理器在sql/handler.h中进行定义,部分在sql/handler.cc中实现。
 
The derived
specific storage engine classes will have to implement all the pure virtual
methods of this class.

派生得出的各种特定存储引擎类将必须实现该类的所有纯虚拟方法。
 
This module was introduced in version 3.23 to facilitate the integration ofBerkeley
DB tables. This move had far-reaching consequences: now a variety oflow-level storage engines could be put underneath
MySQL with a fair amount of ease.
在3.23版本中引进了这一模块,这有利于集成berkeley DB表。这一改动意义深远,现在可以轻而易举地把各种各样的低层次存储引擎放进mysql。
 
The code was further refined during the integration ofInnoDB. The future of the module will largely depend on what new storage engineswill
be integrated into MySQL, and on the way the existing ones will change.
在集成innodb的时候对代码进行了进一步的提炼。模块的未来将大大取决于要在mysql中集成哪些新引擎,以及现有引擎要发生哪些变化。
 
For example, sometimes a
new feature in some underlying
storage engine may require an addition to the abstracted interface to make it available to the higher-level modules.
例如,有时一些下层存储引擎的新功能可能要求将其增加到抽象接口中,以便上层模块能够使用这些新功能。

1.4 Storage Engine Implementations(MyISAM,InnoDB,MEMORY,Berkeley DB)存储引擎的实现

<<---storage engines--storage engine interface—MyISAM、ISAM、MEMORY
----->>

Each of the storage engines provides astandard interface for its operations by
extending the handler class mentioned earlier.
每一个存储引擎都通过扩展前面提过的handler类提供了一个操作标准接口。
 
The methods of the derived class define thestandard interface operations in terms of the low-level calls of thespecific storage
engine.
派生类的方法定义了特定存储引擎低层次调用方面的标准接口操作。
 
Meanwhile, for a quick introduction, you may want to take a look at afew files and
directories of interest:
>>sql/ha_myisam.h and sql/ha_myisam.cc
>>sql/ha_innodb.h and sql/ha_innodb.cc
>>sql/ha_heap.h and sql/ha_heap.cc
>>sql/ha_ndbcluster.h and sql/ha_ndbcluster.cc
>>myisam/
>>innobase/
>>heap/
>>ndb/
同时,为了快速入门,你可能需要浏览有关的文件和目录:
sql/ha_myisam.h he 和 sql/ha_myisam.cc,
sql/ha_innodb.h 和 sql/ha_innodb.cc,
sql/ha_heap.h 和 sql/ha_heap.cc,
sql/ha_ndbcluster.h 和 sql/ha_ndbcluster.cc,
myisam/,innobase/,heap/,ndb/
 
When the
storage engine interface was first abstracted (version 3.23), there were only three fully functional storage engines:MyISAM,
ISAM (older version of MyISAM), andMEMORY. (Note that the MEMORY storage engine used to be called HEAP,and some of the file and directory
names in the source tree still reflect the earlier name.)

在最早抽象出存储引擎接口这个概念时(3.23版本中),只有三种功能全面的存储引擎:MyISAM、ISAM(MyISAM的早期版本)和MEMORY(注意:MEMORY存储引擎以前被称为HEAP,源码树中的一些文件和目录名称依然反映出这个早期名称)。
 
However, the list grew rapidly with the addition ofBerkeleyDB,
MERGE,InnoDB, and more recently, NDB for the MySQL Cluster. Most storage engines are still in fairly active development, and we may see some new ones added in the future.
不过,随着BerkeleyDB、MERGE、InnoDB以及最近出现的用于MySQLCluster的NDB的增加,存储引擎的名单很快变长了。大多数存储引擎仍然处于相当积极的开发阶段,将来我们可能会看到增加的一些新的存储引擎。
待续。。。
 
 
 
 
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql-体系结构