Skip to Content
MySQL Reference Manual
book

MySQL Reference Manual

by Michael Widenius, David Axmark, Kaj Arno
June 2002
Intermediate to advanced
816 pages
20h 46m
English
O'Reilly Media, Inc.
Content preview from MySQL Reference Manual

Adding New Procedures to MySQL

In MySQL, you can define a procedure in C++ that can access and modify the data in a query before it is sent to the client. The modification can be done on a row-by-row or GROUP BY level.

We have created an example procedure in MySQL Version 3.23 to show you what can be done.

Additionally, we recommend that you take a look at mylua. With this you can use the LUA language to load a procedure at runtime into mysqld.

Procedure Analyse

analyse([max elements,[max memory]])

This procedure is defined in the sql/sql_analyse.cc. This examines the result from your query and returns an analysis of the results:

  • max elements (default 256) is the maximum number of distinct values analyse will notice per column. This is used by analyse to check if the optimal column type should be of type ENUM.

  • max memory (default 8192) is the maximum memory analyse should allocate per column while trying to find all distinct values.

    SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])

Writing a Procedure

For the moment, the only documentation for this is the source.

You can find all information about procedures by examining the following files:

  • sql/sql_analyse.cc

  • sql/procedure.h

  • sql/procedure.cc

  • sql/sql_select.cc

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MySQL Troubleshooting

MySQL Troubleshooting

Sveta Smirnova
MySQL Cookbook

MySQL Cookbook

Paul DuBois
The MySQL Workshop

The MySQL Workshop

Thomas Pettit, Scott Cosentino, Dr. Vlad Sebastian Ionescu

Publisher Resources

ISBN: 0596002653Purchase bookErrata Page