Michael J. Ross writes "If you were to ask some database developers to cite their favorite strategies for expanding the functionality of the relational database management systems with which they work, you would probably hear a variety of answers. One individual might recommend the use of an alternate database engine optimized for the given application. Another might explain the many advantages of using stored procedures to replace SQL queries embedded in the source code of any programs that connect to databases. But one answer you likely would not receive involves changing the internals of the database engine itself. With the latest major release of MySQL, developers using that particular RDBMS are now able to extend the capabilities of the built-in database engines, by creating plug-ins. This is the topic of a book by Sergei Golubchik and Andrew Hutchings: MySQL 5.1 Plugin Development." Read on for the rest of Michael's review.This title was released by Packt Publishing on 26 August 2010, under the ISBN 978-1849510608. On the publisher's page for the book, visitors will find a detailed description, the table of contents, a sample chapter (the fourth one in the book, "Information Schema Plugins," as a PDF file), and links to purchase the print and/or electronic versions of the book. There is also a link for downloading all of the sample code used in the book, except for the commands found in the first chapter. The sample code is sufficient to demonstrate the complexity of the subject area, and thus it is good that both authors possess a lot of experience in all of the primary technologies discussed in the book — particularly MySQL. In fact, Sergei Golubchik was one of the principal architects of the MySQL Plug-in application programming interface (API). Incidentally, in the "About the Authors" section, we read that he "has continued as a MySQL AB employee since 2000," which makes it sound as though he is still employed there (now Oracle); but then we are told that he resigned to join a startup firm, which is a bit confusing.
The book spans 288 pages, most of which are organized into ten chapters, followed by an appendix and an index. The first chapter explains the details of how to compile, link, and install MySQL User Defined Functions (UDFs), as well as proper MySQL plug-ins. For those people working on Windows platforms, numerous screenshots are provided, showing how to work with Microsoft Visual Studio (which is freely available). Readers learn how to use MySQL command-line utilities for building and packaging plug-ins, and the options needed to do so. The subsequent chapter focuses on UDFs — both normal and aggregate ones — which are technically not part of the MySQL Plugin API, although they may be in the future. However, they can be thought of as precursors to true plug-ins, because they are written in C/C++, loaded dynamically at runtime, and extend the capabilities of the MySQL server — in this case, by being callable from within SQL statements. The authors explicate how to install and utilize UDFs, and provide several examples.
The book's remaining chapters explore different types of plug-ins, starting with the most basic kind of all, Daemon plug-ins, which can run code utilizing a dedicated thread in the mysqld server process. Readers are shown how Daemon plug-ins are structured — including their declarations, types, status variables, and configuration system variables. To demonstrate these components, the authors dissect four separate sample plug-ins, line by line, with a great deal of helpful commentary. The next two chapters, 4 and 5, delve into schema-related plug-ins, starting with those that create tables, and ending with more advanced topics, such as how to access and output information about a server's internal data structures. These two chapters present almost half a dozen examples, as equally detailed as those of the earlier material.
During the past several years, all relational database systems are seeing increased use of full-text parsing, for various purposes. Chapters 6 and 7 show the reader how to create plug-ins that supplement the full-text search capabilities already baked into MySQL. The first sample plug-in presented by the authors could be used by PHP programmers for parsing their scripts, while another sample could be used by developers who need to match user input (which may include typos), using a Soundex algorithm. The final three chapters cover many aspects of storage engines, ranging from a basic read-only engine to a more complex one that supports indexes. The book concludes with an appendix that surveys the primary enhancements to the Plug-in API that database developers may see in versions of MySQL after 5.1.
On the publisher's site, there are no reported errata, but here are some that I found in just the first couple pages, to get the list started: "class [a] to" (page 1), "on [a] MySQL fork" (page 2), and "ask [the] questions" (page 2). Also, countless phrases and sentences in the book are oddly constructed, with multi-word adjectives missing hyphens, commas used where semicolons are called for, and sometimes both mistakes committed in the same sentence, such as the very first sentence of the preface. In fact, the lead author admits that he prefers reading fiction to a dictionary. Regardless, the information and instruction provided by the authors are generally clear to the reader, and ably illustrated with the sample code.
The book and thus the reader benefit greatly from the extensive MySQL experience and knowledge of the authors, reflected in the depth of coverage of the various topics. MySQL 5.1 Plugin Development brings together valuable information that is otherwise tedious to find — scattered throughout the API source code, official documentation, and online forum threads. For any programmer interested in unleashing the full potential of their MySQL servers through the creation and use of plug-ins, this book is an essential resource.
Michael J. Ross is a freelance website developer and writer.
You can purchase MySQL 5.1 Plugin Development from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.