始创于2000年 股票代码:831685
咨询热线:0371-60135900 注册有礼 登录
  • 挂牌上市企业
  • 60秒人工响应
  • 99.99%连通率
  • 7*24h人工
  • 故障100倍补偿
您的位置: 网站首页 > 帮助中心>文章内容

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

发布时间:  2012/9/3 17:16:02

代码分析基于最新的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。-
 


http://www.linuxidc.com/Linux/2012-03/56277.htm    详细情况请阅读我博客里的这篇文章。

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

http://www.linuxidc.com/Linux/2012-03/56278.htm  这里介绍了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.


 


本文出自:亿恩科技【www.enkj.com】

服务器租用/服务器托管中国五强!虚拟主机域名注册顶级提供商!15年品质保障!--亿恩科技[ENKJ.COM]

  • 您可能在找
  • 亿恩北京公司:
  • 经营性ICP/ISP证:京B2-20150015
  • 亿恩郑州公司:
  • 经营性ICP/ISP/IDC证:豫B1.B2-20060070
  • 亿恩南昌公司:
  • 经营性ICP/ISP证:赣B2-20080012
  • 服务器/云主机 24小时售后服务电话:0371-60135900
  • 虚拟主机/智能建站 24小时售后服务电话:0371-60135900
  • 专注服务器托管17年
    扫扫关注-微信公众号
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 亿恩科技 版权所有  地址:郑州市高新区翠竹街1号总部企业基地亿恩大厦  法律顾问:河南亚太人律师事务所郝建锋、杜慧月律师   京公网安备41019702002023号
      0
     
     
     
     

    0371-60135900
    7*24小时客服服务热线