MySQL 5.1 Plugin Development

MySQL 5.1 Plugin Development
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • A practical guide with working examples explained line by line
  • Add new functions to MySQL with User Defined Functions
  • Export information via SQL using the INFORMATION_SCHEMA plugins
  • Search within PDFs, MP3s, and images; offset user typing errors with fulltext parser plugins
  • Access your custom data formats with a storage engine plugin

Book Details

Language : English
Paperback : 288 pages [ 235mm x 191mm ]
Release Date : August 2010
ISBN : 1849510601
ISBN 13 : 9781849510608
Author(s) : Andrew Hutchings, Sergei Golubchik
Topics and Technologies : All Books, Big Data and Business Intelligence, Architecture & Analysis, MySQL, Open Source

Table of Contents

Chapter 1: Compiling and Using MySQL Plugins
Chapter 2: User Defined Functions
Chapter 3: Daemon Plugins
Chapter 4: Information Schema Plugins
Chapter 5: Advanced Information Schema Plugins
Chapter 6: Full-text Parser Plugins
Chapter 7: Practical Full-text Parsers
Chapter 8: Storage Engine Plugins
Chapter 9: HTML Storage Engine—Reads and Writes
Chapter 10: TOCAB Storage Engine—Implementing Indexes
Appendix: Beyond MySQL 5.1
  • Chapter 1: Compiling and Using MySQL Plugins
    • UDF libraries
      • Linux
      • Mac OS X
      • Windows
      • Installing a UDF
    • Plugin libraries
      • Linux
      • Mac OS X
      • Windows
      • Installing a plugin
    • Automatic builds, packaging
      • UDFs and standalone plugins
      • Plugins that are built from the MySQL source tree
        • CMakeLists.txt
    • Summary
  • Chapter 2: User Defined Functions
    • Writing UDFs
      • Why write UDFs
      • Installing and using UDFs
      • Defining UDFs
      • Execution sequence of a UDF
      • UDF error handling
      • UDF security
      • Gotchas with UDFs
    • A constant integer output UDF
    • An integer echoing UDF
    • A simple static text output UDF
    • A summing aggregate UDF
    • Further reading
    • Summary
  • Chapter 3: Daemon Plugins
    • A look inside a Daemon plugin
      • Why write a Daemon plugin
      • Installing and using Daemon plugins
      • The role of a version
      • Defining Daemon plugins
        • Status variables
        • System variables
    • A Hello World! Daemon plugin
    • A system and status variables demo plugin
    • A simple monitoring plugin
    • System Status Variables plugin
    • Summary
  • Chapter 4: Information Schema Plugins
    • Why write Information Schema plugins
      • Installing and using Information Schema plugins
    • The creation of Information Schema plugins
      • Defining Information Schema plugins
    • A Static Table example
    • A System Information plugin
    • Summary
  • Chapter 5: Advanced Information Schema Plugins
    • Accessing MySQL internals
    • Condition pushdown
      • Using condition pushdown
      • A condition pushdown example
    • A User Variables Information Schema plugin
    • A Binary Logs Information Schema plugin
    • Summary
  • Chapter 6: Full-text Parser Plugins
    • The full-text parser plugin architecture
      • Three roles of a full-text parser plugin
      • Installing and using a full-text parser plugin
      • Structure of a full-text parser plugin
    • A PHP full-text parser
    • Summary
  • Chapter 7: Practical Full-text Parsers
    • Boolean parsers
    • A Boolean full-text parser
    • An Image Metadata processor
      • How to access Exif data
      • Writing the plugin
      • Test run
    • A Soundex full-text parser
      • The Soundex algorithm
      • The plugin
      • Trying it out
    • Summary
  • Chapter 9: HTML Storage Engine—Reads and Writes
    • An idea of the HTML engine
    • Flashback
    • Creating, opening, and closing the table
    • Reading data
    • Updating the table
    • Optimizing and analyzing
    • What's left
      • ha_html.h
    • Compiling and linking
    • Putting it all together
    • Summary
  • Chapter 10: TOCAB Storage Engine—Implementing Indexes
    • B-tree library
    • Storage engine API for indexes
    • Describing the engine
    • Creating, opening, and closing the table
    • Searching in the index
    • Rows and keys
    • Table scan and random access
    • Inserting rows
    • What's left
    • Compiling and linking
    • Putting it all together
    • Possible extensions
    • Summary
  • Appendix: Beyond MySQL 5.1
    • Server services
      • my_snprintf
      • thd_alloc
    • Audit plugins
    • Authentication plugins
      • How it works
      • Authentication plugins—server side
      • Authentication plugins—client side
    • SQL extension by Storage Engine plugins
      • Putting it to use
      • Test drive
    • Summary

Andrew Hutchings

Andrew Hutchings has been working in the IT industry almost all his life. He started his development career programming embedded microcontrollers in assembly language for environmental monitoring systems. He then went on to systems administrator for a hosting company, in which he got his first taste for modifying the MySQL source code.

Andrew created his own business in development and DBA work, which led him to be employed by Dennis Publishing, a major UK magazine publisher. In this role as Technical Architect he designed and implemented hosting setups, acting as senior developer and DBA. This was to be his first taste of MySQL clusters and led to his development of ndb_watch, a cluster monitoring daemon.

After gaining Zend Certified Engineer and Certified MySQL Database Administrator qualifications he gained a position at Sun Microsystems as a MySQL Support Engineer. This involves working daily with the MySQL source code and customer API code to help diagnose and fix issues. He is now a specialist in MySQL Cluster and C APIs.

In his spare time Andrew is a community contributor to MySQL with feature patches and bug fixes in both 5.1 and 6.0. He has also contributed to the Drizzle project, a fork of MySQL aimed at having a clean micro-kernel core, committing a significant amount of code to the project.

Sergei Golubchik

Sergei Golubchik started on modifying MySQL source code in 1998, and has continued doing it as a MySQL AB employee since 2000. Working professionally with the MySQL sources he had a chance to get to know and extend almost every part of the server code – from the SQL core to the utility functions. He was one of the primary architects of the Plugin API. After working for ten years in the ever-growing MySQL AB, and later in Sun Microsystems as a Principal Software Developer, he resigned to join a small startup company that works on MariaDB – an extended version of the MySQL server, where he continues to do what he likes the most – hack on MySQL, architecting and developing the MySQL/MariaDB Plugin API, making it even more powerful, safer, and easier to use.
He works and lives in Germany, near Cologne, with his lovely wife and two kids.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

MySQL 5.1 Plugin Development +    Unity 4.x Cookbook =
50% Off
the second eBook
Price for both: €30.90

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Build and install a plugin, and learn how to package it for distributing separately from MySQL
  • Add new functions to MySQL using the UDF interface
  • Declare new MySQL status and configuration variables from a plugin, and use Daemon plugins for a simple push style server monitoring
  • Add a new table to the INFORMATION_SCHEMA that shows anything you like with an INFORMATION_SCHEMA plugin
  • Use fulltext parser plugins to tolerate user errors, and search for text in binary data formats, for example, JPEG, or text that is stored outside the database
  • Store and retrieve rows and convert your custom data format to what MySQL understands using the storage engine plugin
  • Create a parser that indexes comments from JPEG files using the libexif library
  • Understand how the indexing API works, and how to work around the incompatibilities between your indexing engine and MySQL expectations
  • Learn about new features of the Plugin API, available beyond MySQL 5.1

In Detail

MySQL has introduced a Plugin API with its latest version – a robust, powerful, and easy way of extending the server functionality with loadable modules on the fly. But until now anyone wishing to develop a plugin would almost certainly need to dig into the MySQL source code and search the Web for missing bits of the information.

This is the first book on the MySQL Plugin API. Written together with one of the Plugin API primary architects, it contains all the details you need to build a plugin. It shows what a plugin should contain and how to compile, install, and package it. Every chapter illustrates the material with thoroughly explained source code examples.

Starting from the basic features, common to all plugin types, and the structure of the plugin framework, this book will guide you through the different plugin types, from simple examples to advanced ones. Server monitoring, full-text search in JPEG comments, typo-tolerant searches, getting the list of all user variables, system usage statistics, or a complete storage engine with indexes – these and other plugins are developed in different chapters of this book, demonstrating the power and versatility of the MySQL Plugin API and explaining the intricate details of MySQL Plugin programming.

A hands-on guide for MySQL application developers to creating feature-rich plug-ins


This book is written in a hands-on style that actively involves you while you read through its chapters. In every chapter you, along with the author, will be implementing one or more fully working example plugins. The process is accompanied with a detailed step-by-step explanation of the code, at the same time providing you with resources to create your own plugins.

Who this book is for

If you are a MySQL application developer or a programmer who wants to interface with MySQL server, this book is for you. Basic knowledge of C/C++, SQL, and MySQL in particular is assumed in the book, but no deep familiarity with any of the topics is required.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software