Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the MySQL source code directories

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces what the MySQL source code directory has, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

1. Source code directory introduction:

1 、 BUILD

The BUILD directory is a directory for compilation and installation scripts, most of which start with compile-, and the SETUP.sh scripts set optimization options for C and C++ compilers.

2 、 client

The client directory includes common commands and client tool code, these source code files include password confirmation function get_password.c, SSL connection feasibility check, MySQL client mysql.cc, mysqladmin tool and mysqladmin for server operation mysqladmin.c, display database and its tables and columns mysqlshow.c, and so on.

3 、 storage

MySQL's various storage engine codes are in this directory, including CVS storage engine (cvs directory), InnoDB storage engine, Federate, and so on. Storage engine is the core of database system, which encapsulates the operation of database files and is the most important factor in whether the database system is powerful or not. Mysql implements an abstract interface layer called handler (sql/handler.h), which defines interface functions, such as ha_open, ha_index_end, ha_create and so on. The storage engine needs to implement these interfaces in order to be used by the system. The definition of this interface is super complex, with more than 900 lines:-(, but we just need to know what it does for a while, there is no need to delve into every line of code. For the specific characteristics of each engine, I recommend that you take a look at mysql's online documentation: http://dev.mysql.com/doc/refman/5.1/en/storage-engines.html

You should see the following directory:

* innobase, innodb directory, the most popular storage engine at present

* myisam, the earliest Mysql storage engine, until the advent of innodb, the most widely used engine

* heap, memory-based storage engine

* federated, a relatively new storage engine

* example and csv, which can be used as reference implementations when writing the storage engine, are easier to understand.

4 、 mysys

Mysys stands for MySQL system library and is the library function file of MySQL. A library function is a collection of precompiled functions that are written according to the principle of reusability. They usually consist of a set of interrelated functions used to accomplish a common task, and the library is essentially an executable binary form that can be loaded into memory by the operating system. There are 125. c files in the mysys directory, and the library functions are growing with the evolution of the version and the addition of new features.

These include mf_qsort.c for quick sorting, mf_tempfile.c for temporary file management, charset-def.c that defines the type of character set used in client-side compilation, and charset.c for character set-related operations (character set loading, initialization, etc.).

Mysys is a hodgepodge of various functional library files Including file opening, data reading and writing, memory allocation, OS/2 system special optimization, thread control, rights control, RaidTable, dynamic string processing, queue algorithm, network transfer protocol, initialization function, error handling, balanced binary tree algorithm, symbolic connection processing, unique temporary file name generation, hash function, sorting algorithm, compression transfer protocol and so on.

5 、 sql

The sql directory contains the MySQL main function mysqld.cc (yes, this is where the database master program mysqld is located, where most of the system flow takes place. ) in addition to the file, it also includes the parsing / implementation of all kinds of SQL statements, threads, query parsing and query optimizer, storage engine interface (you can also see sql_insert.cc, sql_update.cc, sql_select.cc, and so on), respectively implementing the corresponding SQL commands. We will also often mention the files in this directory later. In the directory of each storage engine under storage, there is the implementation code of all kinds of storage engine, while in the sql/ directory is the processing interface handler. There are many virtual functions in the handler class, which need to be implemented by its subclasses.

Today, in MySQL 5.1, the combined files hadler.cc and handler.h handle all different kinds of storage requests. The execution code for various SQL statements can also be found in the sql directory, and such files are often named with sql. MySQL treats operations such as UNION and ROLLUP as internal functions.

There are probably the following and some parts:

SQL parser code: sql_lex.cc, sql_yacc.yy, sql_yacc.cc, sql_parse.cc, etc., to achieve the parsing operation of SQL statements.

The "handler" code: handle.cc, handler.h, defines the interface of the storage engine.

The "item" code: item_func.cc, item_create.cc, defines the parts after SQL parsing.

The SQL statement executes the code: sql_update.cc, sql_insert.cc sql_select.cc, sql_show.cc, sql_load.cc, and executes the statement corresponding to SQL. When you want to see "SELECT." When implementing, go directly to sql_select.cc to see OK.

Auxiliary code: net_serv.cc to realize network operation

There's a lot of other code.

6 、 vio

VIO means Virtual IO O, which is mainly used to deal with various network protocols. Virtual I PUBO enables the network protocols of various modules to seamlessly call the IZP O function. The method here will be called by the MySQL network subsystem.

7 、 regex

Regex provides support for MySQL to execute the regular matching function REGEXP.

8 、 dbug

MySQL compiled with the with-debug parameter displays dbug output, and all .c and .cc files in the code can call this library.

2. Installation directory introduction:

On Windows, the default installation directory is C:\ mysql, which has the following subdirectories:

Directory

Contents of Directory

Bin

Client programs and the mysqld server

Data

Log files, databases

Docs

Documentation

Examples

Example programs and scripts

Include

Include (header) files

Lib

Libraries

Scripts

Utility scripts

Share

Error message files

Installations created from Linux RPM distributions result in files under the following system directories:

Directory

Contents of Directory

/ usr/bin

Client programs and scripts

/ usr/sbin

The mysqld server

/ var/lib/mysql

Log files, databases

/ usr/share/doc/packages

Documentation

Include/usr/include/mysql

Include (header) files

Lib/usr/lib/mysql

Libraries

/ usr/share/mysql

Error message and character set files

Sql-bench/usr/share/sql-bench

Benchmarks

On Unix, a tar file binary distribution is installed by unpacking it at the installation location you choose (typically/usr/local/mysql) and creates the following directories in that location:

Directory

Contents of Directory

Bin

Client programs and the mysqld server

Data

Log files, databases

Docs

Documentation, ChangeLog

Include

Include (header) files

Lib

Libraries

Scripts

Mysql_install_db

Share/mysql

Error message files

Sql-bench

Benchmarks

A source distribution is installed after you configure and compile it. By default, the installation step installs files under / usr/local, in the following subdirectories:

Directory

Contents of Directory

Bin

Client programs and scripts

Include/mysql

Include (header) files

Info

Documentation in Info format

Lib/mysql

Libraries

Libexec

The mysqld server

Share/mysql

Error message files

Sql-bench

Benchmarks and crash-me test

Var

Databases and log files

Thank you for reading this article carefully. I hope the article "what is the MySQL source code directory shared by the editor is helpful to everyone?" at the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report