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.
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.
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. |
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.
Awesome! (Score:1, Insightful)
Cram business logic that should properly exist at the application level into a crappy SQL platform!
Re: (Score:3, Interesting)
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.
Re:Awesome! (Score:5, Insightful)
you can use a trigger and a stored proc for this.... but if you forget to document it in the written design doc, I will give you a terrible beating
and by the way it is a business logic question, as an exercise I will let you find why
Re: (Score:1)
Didn't say it had to be a plugin - just arguing against this sort of thing being in application code.
Re: (Score:2)
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. W
A rule like that can only come from a business requirement in the first place -- or did the developer or DBA arbitrarily make that decision?
Re:Awesome! (Score:5, Insightful)
Cram business logic that should properly exist at the application level into a crappy SQL platform!
After you work in BI for a while you'll come to realize that where business logic is kept isn't nearly as important as that it's only kept in one place.
Re:Awesome! (Score:4, Informative)
After you work in BI for a while you'll come to realize that where business logic is kept isn't nearly as important as that it's only kept in one place.
God yes. I used to hate the idea of stored procedures and the like because that meant losing control (as an application programmer). But over time, I've come to realize that what it really means is that I don't have to worry about all the other application programmers implementing the same goddamn thing in a dozen different places.
Re: (Score:2)
Re: (Score:2)
You could think of it like MSSQL or Oracle... both of them add their own "enhancements" to the standard SQL.
This sounds like it's just moving that "power" into the hands of the DB Admins. Sure, it could spawn some ugly stuff... but it could give you something the big players didn't think of.
Mozilla Firefox addons? (Score:1)
This might be a hit, like addons in Mozilla Firefox.
Potential Security Nightmare (Score:2, Interesting)
Re: (Score:1)
It's true, but that is the problem of third-party software. The same issues hold for Firefox addons, and for the ability to run programs written by anyone in your PC, as opposed to, say, the iPad. It's up to the end-user to decide what to install and what not to install.
Re: (Score:1)
Re: (Score:1)
Re: (Score:1)
Re: (Score:1)
Re: (Score:2)
Normalisation... (Score:2)
Re: (Score:2)
As with all things database, it's only as normalized as the meat between the chair and the keyboard wants it to be.
authentication plugins? (Score:2)
Re: (Score:3, Informative)
Ported Plugins? (Score:2)
It would be useful if there were a way to use all kinds of existing Apache plugins to deliver their functions to MySQL. Auth plugins are an obvious win; other functions not so obvious could still make code reuse deliver real productivity and wider functionality.
Indeed, an interesting MySQL plugin would be an Apache httpd that could run regular Apache plugins. Or MySQL packaged as an Apache plugin, for inline SQL embedded in Apache server side scripting.
In a similar vein, JBoss running as a plugin exposing
Plug-ins to MySQL - bad idea (Score:2)
Database engines have to be highly reliable, and MySQL has some good ones. They're very difficult to write and get correct. There's considerable theory and formalism involved. Real Q/A is needed. This is not a place for "crowdsourcing".
MySQL goes Home Cinema surround (Score:1)
Table Index Plugin? (Score:3, Interesting)
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?
Re: (Score:2, Insightful)
Using Existing Plugins (Score:2)
How about a plugin that replaces any replaceable default MySQL feature with the execution of a stored procedure that's stored in that MySQL server instance?
Re: (Score:1)
Re: (Score:2)
For example, could I write a plugin that intercepts the call to the implementation of "=" (eg. in "SELECT cola FROM tableb WHERE colb = colc"), that executes a Stored Function or UDF returning a boolean?
Re: (Score:1)
Re: (Score:2)
So I take it that there's no option to replace the entire lexical parser code, or perhaps some larger functional block that includes the lexical parser, with a "plugin" (install-time selection, not compile-time) that just rewrites the "=" operator, replacing the default code that executes "=" the conventional way.
Re: (Score:1)
Re: (Score:2)
Thanks for this info.
I've tried a few times to start up a project that inserts a MySQL engine between Linux filesystem calls and the storage subsystem, so the filesystem has a SQL API, but the teams quickly fell apart.
Maybe with that UMI book and your plugin book I might find a better approach that would produce a result this time.
Re: (Score:1, Interesting)
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 tha
Storing BLOBs as Files? (Score:2)
MS SQLServer has a feature which structures a column as a BLOB type, that can be specified to store each record's field in a separate file managed by SQLServer. Those files in that column can have a separate fulltext index supporting matching and proximity operators. Is there a plugin for MySQL that delivers those kinds of features?
Re: (Score:2, Insightful)
.XLSX Parser Plugin? (Score:2)
Is there a MySQL plugin that allows bulk insertion or other simple processing of MS Excel .XLS and .XLSX format files?
Extend the SQL language? (Score:2)
---
SQL Programming [feeddistiller.com] Feed @ Feed Distiller [feeddistiller.com]
Re: (Score:1)