The Major Directories MySQL

The orderly approach is to look first at the most important directories, then we'll look at the whole list in our second pass. So, first, let's look at what you'll find in just seven of the directories: BUILD, client, Docs, myisam, mysys, sql, and vio.

Major Directories: BUILD

The first major directory we'll look at is BUILD. It actually has very little in it, but it's useful, because one of the first things you might want to do with the source code is: compile and link it. The example command line that we could use is

It invokes a batch file in the BUILD directory. When it's done, you'll have an executable MySQL server and client. Or, um, well, maybe you won't. Sometimes people have trouble with this step because there's something missing in their operating system version, or whatever. Don't worry, it really does work, and there are people around who might help you if you have trouble with this step. Search for "build" in the archives of

We, when we're done building, tend to install it with the following sequence:

This puts the new MySQL installation files on

gdb (GNU debugger)

Once you've got something that runs, you can put a debugger on it. We recommend use of the GNU debugger and many developers use the graphical debugger tool DDD - Data Display Debugger.These are free and common, they're probably on your Linux system already.There are debuggers for Windows and other operating systems, of course — don't feel left out just because we're mentioning a Linux tool name! But it happens that we do a lot of things with Linux ourselves, so we happen to know what to say. To debug the mysqld server, say: From this point on, it may be tempting to follow along through the rest of the "guided tour" by setting breakpoints, displaying the contents of variables, and watching what happens after starting a client from another shell. That would be more fun. But it would require a detour, to discuss how to use the debugger. So we'll plow forward, the dull way, noting what's in the directories and using a text editor to note what's in the individual files.

Running a Test with the Debugger

To run a test named some.test with the debugger in embedded mode you could do this:

  1. Run libmysqld/examples/test_run --gdb some.test. This creates a libmysqld
    /examples/test-gdbinit file which contains the required parameters for
  2. Make a copy of the test-gdbinit file(call it, for example,some-gdbinit).
    The testgdbinit file will be removed after test-run --gdb has finished.
  3. Load libmysqld/examples/mysqltest_embedded into your favorite debugger, for example:
    gdb mysqltest_embedded.
  4. In the debugger,for example in gdb,do: --sou some-gdbinit Now some.test is running,and you can see if it's passing or not.

If you just want to debug some queries with the embedded server(not the test), it's easier to just run libmysqld/examples/mysql. It's the embedded server-based clone of the usual mysql tool, and works fine under gdb or whatever your favorite debugger is.

Major Directories: client

The next major directory is mysql-5.0/client. It has the source code of many of your familiar favorites, like mysql, which everybody has used to connect to the MySQL server at one time or another. There are other utilities too — in fact, you'll find the source of most client-side programs here. There are also programs for checking the password, and for testing that basic functions — such as threading or access via SSL — are possible.

You'll notice, by the way, that we're concentrating on the files that have extension of ".c" or ".cc". By now it's obvious that C is our principal language although there are some utilities written in Perl as well.

Major Directories: Docs

The next major directory is mysql-5.0/Docs. With the BitKeeper downloads, /Docs is nearly empty. Binary and source distributions include some pre-formatted documentation files, such as the MySQL Reference manual in Info format (for Unix) or CHM format (for Windows). The mysqldoc documentation repository is available separately from. If you have Subversion, you can check out a copy of the repository with this command: svn checkout . Some important files in the mysqldoc repository are: Our documents are written in XML using DocBook. The DocBook format is becoming popular among publishers, and of course there's lots of general documentation for it. For our immediate purpose, the most interesting directory might be the internals directory, because it contains the source for the Internals Manual that you're reading now. At this moment, the Internals Manual has more than 100 pages of information, including some details about the formats of MySQL files that you won't find anywhere else, and a complete description of the message formats that the client and server use to communicate. Although it's rough and may contain errors and is obsolete in parts, it is a document that you must read to truly understand the workings of MySQL.

Major Directories: myisam

The next major directory is labelled myisam. We will begin by mentioning that myisam is one of what we call the MySQL storage engine directories.For example the heap directory contains the source files for the heap storage engine and the ndb directory contains the source files for the ndb storage engine. But the files in those directories are mostly analogues of what's in the myisam directory, and the myisam directory is sort of a 'template'.On the myisam directory, you'll find the programs that do file I/O. Notice that the file names begin with the letters mi, by the way. That stands for MyISAM, and most of the important files in this directory start with mi.

File handling programs on mysql-5.0/myisam:
Row handling programs on mysql-5.0/myisam:

Drilling down a bit, you'll also find programs in the myisam directory that handle deleting,updating, and inserting of rows. The only one that's a little hard to find is the program for inserting rows, which we've called mi_write.c instead of mi_insert.c.

Key handling programs on mysql-5.0/myisam:

The final notable group of files in the myisam directory is the group that handles keys in indexes.To sum up: (1) The myisam directory is where you'll find programs for handling files, rows, and keys. You won't find programs for handling columns — we'll get to them a bit later.(2) The myisam directory is just one of the handler directories. The programs in the other storage engine directories fulfill about the same functions.

Major Directories: mysys

The next major directory is labelled mysys, which stands for MySQL System Library. This is the toolbox directory, for example it has low level routines for file access. The .c files in mysys have procedures and functions that are handy for calling by main programs, for example by the programs in the myisam directory. There are 115 .c files in mysys, so we only can note a sampling.Sampling of programs on mysql-5.0/mysys size name comment Example one: with charset.c routines, you can change the character set. Example two: mf_qsort.c contains our quicksort package. Example three: mf_tempfile.c has what's needed for maintaining MySQL's temporary files. You can see from these examples that mysys is a hodgepodge. That's why we went to the trouble of producing extra documentation in this document to help you analyze mysys's contents.

Major Directories: sql

The next major directory is mysql-5.0/sql. If you remember your manual, you know that you must pronounce this: ess queue ell.
The "parser" programs on mysql-5.0/sql:

This is where we keep the parser. In other words, programs like and sql_yacc.yy are responsible for figuring out what's in an SQL command, and deciding what to do about it.The "handler" programs on mysql-5.0/sql:

This is also where we keep the handler programs. Now, you'll recall that the storage engine itself, for example myisam, is a separate directory. But here in the sql directory, we have programs which are responsible for determining which handler to call, formatting appropriate arguments, and checking results. In other words, the programs that begin with the letters ha are the handler interface programs, and there's one for each storage engine.The "statement" routines in mysql-5.0/sql:

Also in the sql directory, you'll find individual programs for handling each of the syntactical components of an SQL statement. These programs tend to have names beginning with sql_. So for the SELECT statement, check out, there are "statement" routines like sql_delete.c, sql_load.c, and sql_help.c, which take care of the DELETE, LOAD DATA, and HELP statements. The file names are hints about the SQL statements involved.

The "statement function" routines in mysql-5.0/sql:

Then there are the routines for components of statements, such as strings, or online analytical processing which at this moment just means ROLLUP, or user-defined functions, or the UNION operator.

Major Directories: vio

The final major directory that we'll highlight is labelled vio, for "virtual I/O". The vio routines are wrappers for the various network I/O calls that happen with different protocols. The idea is that in the main modules one won't have to write separate bits of code for each protocol. Thus vio's purpose is somewhat like the purpose of Microsoft's winsock library.That wraps up our quick look at the seven major directories. Just one summary chart remains to do.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

MySQL Topics