最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MySQL源代码阅读笔记:代码流程

来源:动视网 责编:小采 时间:2020-11-09 11:36:01
文档

MySQL源代码阅读笔记:代码流程

MySQL源代码阅读笔记:代码流程:代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc。 我们直接从mysqld_main()开始阅 代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc
推荐度:
导读MySQL源代码阅读笔记:代码流程:代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc。 我们直接从mysqld_main()开始阅 代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc


代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc。 我们直接从mysqld_main()开始阅

代码分析基于最新的5.5.21

Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc。

我们直接从mysqld_main()开始阅读。

先理解一些比较重要的宏定义:

(1)宏HAVE_NPTL:

这个宏如果打开了会去读一个系统变量LD_ASSUME_KERNEL,并把他赋给一个全局变量ld_assume_kernel_is_set,这个系统变量设置了系统线程的实现模型。linux内核在2.6版本后,缺省的线程模型是NPTL。

详细情况请阅读我博客里的这篇文章。

对于以HAVE_前缀的的宏,另有如下文章阐述:

这里介绍了CMake的相关知识,,通过CMake在影子编译目录的include目录里面生成了my_config.h文件。

my_config.h文件通过my_global.h文件包含到具体的需要使用HAVE_前缀的宏的源文件中。

(2)EMBEDDED_LIBRARY

该宏用于控制 嵌入式库和客户端/服务器版本不同的那部分代码。

Mysql 可以编译为一个libmysqld库(嵌入式服务器),使用嵌入式MySQL服务器库,能够在客户端应用程序中使用具备全部特性的MySQL服务器。

主要优点在于,增加了速度,并使得嵌入式应用程序的管理更简单。嵌入式服务器库是以MySQL的客户端/服务器版本为基础的,采用C/C++语言编写。 其结果是嵌入式服务器也是用C/C++语言编写的。 在其他语言中,嵌入式服务器不可用。

这个宏可以通过CMake配置,

-DWITH_EMBEDDED_SERVER=1 打开这个宏

在plug.cmake函数里有它的定义:

PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY")

整个代码的流程如下:我们讲分更细的文章详细介绍每部分:

Mysql服务器监听:

Mysql 源代码的目录结构 :(以下来自官方文档)

/BUILD The compilation configuration and make files for all platforms supported.
Use this folder for compilation and linking.
/client The MySQL command-line client tool.
/dbug Utilities for use in debugging (see Chapter 5 for more details).
/Docs Documentation for the current release. Linux users should usegenerate-text-files.pl in the support subfolder to generate the documentation. Windows users are provided with a manual.chm file.
/include The base system include files and headers.
/libmysql The C client API used for creating embedded systems. (See Chapter 6 formore details.)
/libmysqld The core server API files. Also used in creating embedded systems.(See Chapter 6 for more details.)
/mysql-test The MySQL system test suite. (See Chapter 4 for more details.)
/mysys The majority of the core operating system API wrappers and helper functions.
/regex A regular expression library. Used in the query optimizer and execution to resolve expressions.
/scripts A set of shell script-based utilities.
/sql The main system code. You should start your exploration from this folder.
/sql-bench A set of benchmarking utilities.
/SSL A set of Secure Socket Layer utilities and definitions.
/storage The MySQL pluggable storage engine source code is located inside this folder. Also included is the storage engine example code. (See Chapter 7 for more details.)
/strings The core string handling wrappers. Use these for all of your string handling needs.
/support-files A set of preconfigured configuration files for compiling with different options.
/tests A set of test programs and test files.
/vio The network and socket layer code.
/zlib Data compression tools.

文档

MySQL源代码阅读笔记:代码流程

MySQL源代码阅读笔记:代码流程:代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc。 我们直接从mysqld_main()开始阅 代码分析基于最新的5.5.21 Mysql服务器的main()在/sql/main.cc,实际的入口点在/sql/mysqld.cc
推荐度:
标签: 流程 阅读 过程
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top