Some open-source projects made by Frank DENIS.

MySQL Global User Variables UDF

A MySQL extension to store persistent variables

This shared library adds simple user functions to MySQL in order to keep persistent shared variables in memory. These variables and their values are available to all clients. Any data can be stored into these persistent variables, including BLOBs. Since updates are atomic and way faster than MEMORY tables, this is an easy and efficient way to handle counters and sequences.

Installation

Compilation and installation of the UDF

On most systems, compiling and installing the library should be as simple as
typing (as root):


make install

The shared library is installed as /usr/local/lib/udf_global_user_variables.so

If the base directory of your MySQL installation is not in /usr/local, just
type:


make

and then copy udf_global_user_variables.so to the right location for UDFs on
your system (maybe /usr/lib/).

The name of a variable is limited to 256 bytes. If that limit is too low
for your specific application, just edit the MAX_NAME_LENGTH variable on top
of the .c file and reinstall. Variable names can contain binary characters.

Values are limited to 65536 bytes. If that limit is too low for you, edit the
MAX_VALUE_LENGTH variable and reinstall.

Loading the library

In order to load the shared library, the following SQL statements must be
executed:


DROP FUNCTION IF EXISTS global_set;
CREATE FUNCTION global_set RETURNS INTEGER
  SONAME 'udf_global_user_variables.so';

DROP FUNCTION IF EXISTS global_get;
CREATE FUNCTION global_get RETURNS STRING
  SONAME 'udf_global_user_variables.so';

DROP FUNCTION IF EXISTS global_add;
CREATE FUNCTION global_add RETURNS INTEGER
  SONAME 'udf_global_user_variables.so';

These statements are saved into the table definition. You just need to execute
them once, excepted if you upgrade or reinstall the library.