Become a fan of Slashdot on Facebook


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×
Book Reviews

MySQL 5.1 Plugin Development 44

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.
MySQL 5.1 Plugin Development
author Sergei Golubchik and Andrew Hutchings
pages 288 pages
publisher Packt Publishing
rating 9/10
reviewer Michael J. Ross
ISBN 978-1849510608
summary A practical and example-rich introduction to developing MySQL plug-ins.
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 Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.


This discussion has been archived. No new comments can be posted.

MySQL 5.1 Plugin Development

Comments Filter:
  • Re:Awesome! (Score:3, Interesting)

    by omnichad ( 1198475 ) on Monday November 01, 2010 @02:39PM (#34092638) Homepage

    That's only partly true. For example - say you have "products" and "categories." When you delete a category, all products should either revert to a default category, no category, or move to an archive. That's a database question, not business logic. Why shouldn't the database handle the delete so that it handles the little details across multiple implementations.

  • by csciborg ( 1902542 ) on Monday November 01, 2010 @02:49PM (#34092754)
    I think the ability to modify the functionality of the RDBMS could be very useful in some instances, however if the plugin is poorly crafted or maliciously crafted it could open up interesting new attack surfaces. Any thoughts from the security minded out there?
  • Table Index Plugin? (Score:3, Interesting)

    by Doc Ruby ( 173196 ) on Monday November 01, 2010 @04:38PM (#34094330) Homepage Journal

    If all I wanted to change in MySQL was the function that searched a table index for matching records, how would I go about writing a plugin for just that operation? How about a plugin that only creates/updates an index table (perhaps in a nonstandard format, to be read by my index search plugin)?

    Is it feasible to replace just those two feature groups with a plugin, rather than the entire database engine?

  • by Anonymous Coward on Monday November 01, 2010 @09:56PM (#34097326)

    Postgresql and Oracle let you overload equality on user-defined types in a manner that does precisely what you want. Postgresql's support for this is particularly robust, letting you overload any operator or define new ones, and overloaded equality and comparison operations play nice with indexes, in a way that the portable solution to this problem (selecting from a view) does not.

    Not trying to be a platform weenie here, just pointing out a solution you might be able to use if you're really looking for that sort of thing.

Coding is easy; All you do is sit staring at a terminal until the drops of blood form on your forehead.