签到成功

知道了

CNDBA社区CNDBA社区

MySQL 源码目录结构

2022-02-20 21:03 1812 0 原创 MySQL
作者: dave

1 MySQL 源码下载地址

MySQL 的源码可以在官网直接下载:

https://dev.mysql.com/downloads/mysql/http://www.cndba.cn/dave/article/107751

下载页面上在“Select Operating System”选择“SourceCode”,在“Select OS Version”选项中使用“All”,然后选择Generic Linux 即可。

2 源码目录结构

解压之后的文件目录如下:http://www.cndba.cn/dave/article/107751

http://www.cndba.cn/dave/article/107751
http://www.cndba.cn/dave/article/107751
http://www.cndba.cn/dave/article/107751

[root@dave mysql]# cd mysql-8.0.28/
[root@dave mysql-8.0.28]# ll
total 628
drwxr-xr-x  3 7161 31415     26 Dec 18 00:32 boost
drwxr-xr-x 10 7161 31415   4096 Dec 18 00:30 client
drwxr-xr-x  4 7161 31415   4096 Dec 18 00:30 cmake
-rw-r--r--  1 7161 31415  81576 Dec 18 00:07 CMakeLists.txt
drwxr-xr-x 15 7161 31415    267 Dec 18 00:30 components
-rw-r--r--  1 7161 31415  10654 Dec 18 00:07 config.h.cmake
-rw-r--r--  1 7161 31415  24206 Dec 18 00:07 configure.cmake
drwxr-xr-x  2 7161 31415     82 Dec 18 00:30 Docs
-rw-r--r--  1 7161 31415   5135 Dec 18 00:07 Doxyfile-ignored
-rw-r--r--  1 7161 31415 119336 Dec 18 00:07 Doxyfile.in
drwxr-xr-x  3 7161 31415    124 Dec 18 00:30 doxygen_resources
drwxr-xr-x 15 7161 31415    230 Dec 18 00:30 extra
drwxr-xr-x  4 7161 31415   8192 Dec 18 00:30 include
-rw-r--r--  1 7161 31415    333 Dec 18 00:07 INSTALL
drwxr-xr-x  5 7161 31415    112 Dec 18 00:30 libbinlogevents
drwxr-xr-x  3 7161 31415     39 Dec 18 00:30 libbinlogstandalone
drwxr-xr-x  4 7161 31415     54 Dec 18 00:30 libchangestreams
drwxr-xr-x  7 7161 31415   4096 Dec 18 00:30 libmysql
drwxr-xr-x  2 7161 31415   4096 Dec 18 00:30 libservices
-rw-r--r--  1 7161 31415 276595 Dec 18 00:07 LICENSE
drwxr-xr-x  2 7161 31415   4096 Dec 18 00:32 man
drwxr-xr-x 10 7161 31415   4096 Dec 18 00:31 mysql-test
-rw-r--r--  1 7161 31415     88 Dec 18 00:07 MYSQL_VERSION
drwxr-xr-x  2 7161 31415   4096 Dec 18 00:31 mysys
drwxr-xr-x 10 7161 31415    131 Dec 18 00:31 packaging
drwxr-xr-x 24 7161 31415   4096 Dec 18 00:31 plugin
-rw-r--r--  1 7161 31415    666 Dec 18 00:07 README
drwxr-xr-x  6 7161 31415    155 Dec 18 00:31 router
-rw-r--r--  1 7161 31415   4677 Dec 18 00:07 run_doxygen.cmake
drwxr-xr-x  4 7161 31415   4096 Dec 18 00:31 scripts
drwxr-xr-x  3 7161 31415    155 Dec 18 00:31 share
drwxr-xr-x 23 7161 31415  24576 Dec 18 00:31 sql
drwxr-xr-x  3 7161 31415    331 Dec 18 00:31 sql-common
drwxr-xr-x 14 7161 31415    204 Dec 18 00:32 storage
drwxr-xr-x  3 7161 31415   4096 Dec 18 00:31 strings
drwxr-xr-x  2 7161 31415    202 Dec 18 00:31 support-files
drwxr-xr-x  2 7161 31415    101 Dec 18 00:31 testclients
drwxr-xr-x  5 7161 31415     70 Dec 18 00:31 unittest
drwxr-xr-x  2 7161 31415    271 Dec 18 00:31 utilities
drwxr-xr-x  2 7161 31415    296 Dec 18 00:31 vio
[root@dave mysql-8.0.28]#

主要的目录功能说明如下:

boost: 这个版本是自带Boost的库相关文件的,放在此处,如果是其它的版本就没有这个文件夹
client: 客户端相关的软件和工具代码
cmake: CMAKE相关的脚本命令文件
components: 组件工具
Docs: 文档文件夹
doxyen_resources: doxyen工具相关资源
extra: 引入的一些其它包,如网络消息谁的SSL包以及一些小工具。
include: 源码用的相关的头文件放置的文件夹,但不包括存储引擎的头文件。
libbinlogevents: 解析Binlog的lib服务,5.7后提供。
libbinlogstandalone: 脱机配置CMAKE
libmysql: 可嵌入式的客户端API
libservices: 动态服务插件管理
man: 帮助文档
mysql-test: 服务端mysqlid的测试工具。
mysys: MySql自己实现的数据结构和一些基本算法。如数组和链表等。
packaging: 打包相关
plugin: 插件管理文件夹,包括一些动态加入的插件。
router: 集群路由
scripts: 系统工具运行的脚本。
share: 共享信息,err和字符集
sql: 服务端的主要代码,包括main函数。
sql-common: 服务端和客户端通用的一些代码。
storage: 存储引擎相关文件。
strings: 字符串库
support-files: .conf的示例文件和相关工具。
testclients: 客户框架测试。
unittest: 单元测试,这个搞程序的都知道。
utilities: 公用的一些文件,有ZLIB等
vio: 虚拟网络IO处理系统,不同平台或不同协议的网络通信API的二次封装。http://www.cndba.cn/dave/article/107751

http://www.cndba.cn/dave/article/107751

3 sql 目录结构

在mysql源码的目录中,最主要的就是SQL 这个目录,该目录存放的是mysql的主要代码,大部分的系统流程都发生在这里。比如sql_insert.cc, sql_update.cc, sql_select.cc,等等,分别实现了对应的SQL命令。

该目录中文件众多,官方文档有文章专门介绍了每个文件的功能,如下:

The sql Directory
https://dev.mysql.com/doc/internals/en/sql-directory.htmlhttp://www.cndba.cn/dave/article/107751

http://www.cndba.cn/dave/article/107751
http://www.cndba.cn/dave/article/107751

These are the .c and .cc files in the sql directory:
derror.cc --- read language-dependent message file
des_key_file.cc --- load DES keys from plaintext file
discover.cc --- Functions for discovery of .frm file from handler
field.cc --- "implement classes defined in field.h" (long); defines all storage methods MySQL uses to store field information into records that are then passed to handlers
field_conv.cc --- functions to copy data between fields
filesort.cc --- sort a result set, using memory or temporary files
frm_crypt.cc --- contains only one short function: get_crypt_for_frm
gen_lex_hash.cc --- Knuth's algorithm from Vol 3 Sorting and Searching, Chapter 6.3; used to search for SQL keywords in a query
gstream.cc --- GTextReadStream, used to read GIS objects
handler.cc --- handler-calling functions
hash_filo.cc --- static-sized hash tables, used to store info like hostname -> ip tables in a FIFO manner
ha_berkeley.cc --- Handler: BDB
ha_blackhole.cc --- Handler: Black Hole
ha_federated.cc --- Handler: Federated
ha_heap.cc --- Handler: Heap
……

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2262
    原创
  • 3
    翻译
  • 579
    转载
  • 192
    评论
  • 访问:8091000次
  • 积分:4350
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ