O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MySQL 5.1 Plugin Development

Book Description

Overview of MySQL 5.1 Plugin Development

  • 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

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

Table of Contents

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