Chapter 7. Extending MySQL with User-Defined Functions


  • An introduction the MySQL UDF application programming interface (API)

  • The complete steps for designing, implementing, testing, and debugging a UDF

  • An introduction to using the gnu debugger, gdb

Have you ever been assigned a project that required some functionality from MySQL that wasn't included or where writing a stored procedure or function didn't quite implement the functionality you needed? Perhaps you have a custom library or C-program that you want to access from within MySQL, one you could use in the database calls that your application makes and which makes use of any performance advantages your library offers?

MySQL, being the flexible system that it is, offers you a way to extend the server and create your own functions — different than stored procedures or functions — which perform like standard built-in functions that come included with MySQL. MySQL provides an API for writing user-defined functions, otherwise known as UDFs, which are functions written in C or C++ that can do whatever the user needs them to do, limited only by imagination in terms of functionality. Though this book is for PHP programmers, extending MySQL by writing your UDF in either C or C++ using the UDF API is pretty straightforward and the results are extremely useful. Any experienced PHP developer with a mind for programming should be able to easily grasp how to implement a UDF — and in the process gain a deeper understanding ...

Get Expert PHP and MySQL® now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.