Although MySQL's source code is open in the sense of being publicly available, it's essentially closed to you if you don't understand it. In this book, Sasha Pachev -- a former member of the MySQL Development Team -- provides a comprehensive tour of MySQL 5 that shows you how to figure out the inner workings of this powerful database. You'll go right to heart of the database to learn how data structures and convenience functions operate, how to add new storage engines and configuration options, and much more.
The core of Understanding MySQL Internals begins with an Architecture Overview that provides a brief introduction of how the different components of MySQL work together. You then learn the steps for setting up a working compilable copy of the code that you can change and test at your pleasure. Other sections of the book cover:
Core server classes, structures, and API
The communication protocol between the client and the server
Configuration variables, the controls of the server; includes a tutorial on how to add your own
Thread-based request handling -- understanding threads and how they are used in MySQL
An overview of MySQL storage engines
The storage engine interface for integrating third-party storage engines
The table lock manager
The parser and optimizer for improving MySQL's performance
Integrating a transactional storage engine into MySQL
The internals of replication
Understanding MySQL Internals provides unprecedented opportunities for developers, DBAs, database application programmers, IT departments, software vendors, and computer science students to learn about the inner workings of this enterprise-proven database. With this book, you will soon reach a new level of comprehension regarding database development that will enable you to accomplish your goals. It's your guide to discovering and improving a great database.
Chapter 1 MySQL History and Architecturel
Chapter 2 Nuts and Bolts of Working with the MySQL Source Code
Preparing the System to Build MySQL from BitKeeper Tree
Building MySQL from BitKeeper Tree
Building from Source Distribution
Installing MySQL into a System Directory
Source Code Directory Layout
Preparing the System to Run MySQL in a Debugger
Debugger-Guided Source Tour
Basics of Working with gdb
Finding Things in the Source
Interesting Breakpoints and Variables
Making a Source Modification
Keeping Your BitKeeper Repository Up to Date
Submitting a Patch
Chapter 3 Core Classes, Structures, Variables, and APIs
Utility API Calls
Chapter 4 Client/Server Communication
Relationship Between MySQL Protocol and OS Layer
Chapter 5 Configuration Variables
Configuration Variables Tutorial
Interesting Aspects of Specific Configuration Variables
Chapter 6 Thread-Based Request Handling
Threads Versus Processes
Implementation of Request Handling
Thread Programming Issues
Chapter 7 The Storage Engine Interface
The handler Class
Adding a Custom Storage Engine to MySQL
Chapter 8 Concurrent Access and Locking
Table Lock Manager
Chapter 9 Parser and Optimizer
Chapter 10 Storage Engines
Shared Aspects of Architecture
Chapter 11 Transactions
Overview of Transactional Storage Engine Implementation
Sasha Pachev graduated from the Brigham Young University in 1998 with a degree in Computer Science, worked on the MySQL development team in 2000-2002, and was the original developer of replication in MySQL. In 2003 he wrote his first book MySQL Enterprise Solutions. He currently lives in Provo, Utah with his wife Sarah and his five children working as an independent consultant with the emphasis onMySQL.
In spite of his great interest in computers, Sasha is equallypassionate about distance running. He has won a number of marathons, has a personal best of 2:24:47, and is attempting to qualify for the US Olympic Trials. He feels it is important to help other runners reach their potential, and operates a web site http://FastRunningBlog.Com dedicated to that purpose.
The animal on the cover of Understanding MySQL Internals is a banded broadbill (Eurylaimus javanicus). Broadbills are a family of small- to medium-size passerine (perching) birds marked by their bright colors and a whitish dorsal patch. They have large heads, rounded wings, and short to long tails. Their name originates from their large, flattened, hooked bill (often covered by a short crest), which they use to snap up insects in a kingfisher-like fashion. They also feed on fruit, seeds, and small vertebrates.
Broadbills live in the subcanopies of tropical forests: 11 species can be found in southeast Asia, the Philippines, Borneo, and Sumatra; and 4 others are native to central African rainforests. Because of their dense habitats, they are often incredibly difficult to observe despite their bright coloring. Broadbills build elaborate, pear-shaped nests, which are suspended on tree limbs over quiet forest backwaters and streams. Biologists believe this may be an adaptive behavior to deter mammalian and reptilian predators. Adult broadbills will also sometimes feign injury to draw predators away from their nests.
Broadbills are gregarious creatures and are often found in small feeding flocks. They communicate using a variety of mating and territorial displays. Male green broadbills, for instance, have a spinning display, while other species of broadbills may employ head bobbing, wing flapping, and feather fluffing. Some have display flights in which their primary wing feathers "buzz" during times of courtship or territorial defense. The sound can be heard from as far as 60 meters away. In addition, broadbills have a variety of calls--often described as a cacophony of whistles, rattles, or screams--which they use during courtship rituals, as an alarm signal, and for contact between mates.
The cover image is from Wood's Animate Creation. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed.
The production editors for Understanding MySQL Internals, eMatter Edition were Ellie Cutler and Jeff Liggett. Linda Walsh was the product manager. Kathleen Wilson provided design support. Lenny Muellner, Mike Sierra, Erik Ray, and Benn Salter provided technical support. This eMatter Edition was produced with FrameMaker 5.5.6.