MySQL Source Code Reading Notes: code process

Source: Internet
Author: User

Code analysis is based on the latest 5.5.21

The main () of the Mysql server is in/SQL/main. cc. The actual entry point is in/SQL/mysqld. cc.

We can start reading from mysqld_main () directly.

First, understand some important macro definitions:

(1) macro HAVE_NPTL:

If this macro is enabled, it reads a system variable LD_ASSUME_KERNEL and assigns it to a global variable ld_assume_kernel_is_set. This system variable sets the implementation model of the system thread. After Linux kernel version 2.6, the default thread model is NPTL.

For details, please read this article in my blog.

Macros prefixed with HAVE _ are described in the following article:

This section describes the knowledge of CMake and uses CMake to generate the my_config.h file in the include directory of the Shadow compilation directory.

The my_config.h file uses the my_global.h file to contain specific macro source files that require the HAVE _ prefix.

(2) EMBEDDED_LIBRARY

This macro is used to control the code of the embedded Library and the client/server version.

Mysql can be compiled into a libmysqld Library (Embedded Server). With the embedded MySQL Server library, MySQL servers with all features can be used in client applications.

The main advantage is that it increases the speed and simplifies the management of embedded applications. The Embedded Server library is based on the MySQL client/server version and is written in C/C ++. The result is that the Embedded Server is also written in C/C ++. In other languages, the Embedded Server is unavailable.

This macro can be configured through CMake,

-DWITH_EMBEDDED_SERVER = 1 open this macro

The plug. cmake function has its definition:

PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER; EMBEDDED_LIBRARY ")

The entire code process is as follows: we will introduce each part in detail in a more detailed article:

Mysql Server listener:

Directory structure of Mysql source code: (The following is from the official documentation)

/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 shocould 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 shoshould start your authentication from this folder.
/SQL-define 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 stored ded 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.