Databases Reference
In-Depth Information
ptm = localtime (&t);
/* Format the date and time, down to a single second. */
strftime (time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S", ptm);
/* Print the formatted time, in seconds, followed by a decimal point
* and the microseconds. */
sprintf(usec_time_string, "%s.%06ld\n", time_string, tv.tv_usec);
*length = 26;
return(usec_time_string);
}
For one example of a user-defined function at work solving a thorny problem, see the
case studies in the previous chapter. We've also written UDFs that ship with the Per-
cona Toolkit for checksumming data efficiently so you can test your replication integ-
rity at lower cost, and one for preprocessing text before indexing it with Sphinx for
searching. UDFs can be very powerful.
Plugins
In addition to UDFs, MySQL supports a variety of other plugins. They can add their
own command-line options and status variables, provide INFORMATION_SCHEMA tables,
run as daemons, and much more. In MySQL 5.1 and newer, the server has many
more plugin APIs than it did previously, and the server can now be extended in many
ways without altering its source code. Here is a short list:
Procedure plugins
Procedure plugins can post-process a result set. This is an ancient type of plugin,
similar to UDFs, that most people aren't even aware of and never consider using.
The built-in PROCEDURE ANALYSE is an example.
Daemon plugins
Daemon plugins run as a process within MySQL and can perform tasks such as
listening on network ports or executing periodic jobs. An example is the Handler-
Socket plugin included with Percona Server. It opens network ports and accepts a
simple protocol that lets you access InnoDB tables through the Handler interface
without using SQL, which makes it a high-performance NoSQL interface into the
server.
INFORMATION_SCHEMA plugins
These plugins can provide arbitrary INFORMATION_SCHEMA tables.
Full-text parser plugins
These plugins provide a way to intercept the processes of reading and breaking a
document into words for indexing, so you can do things such as indexing PDF
documents given their filenames. You can also make it a part of the matching
process during query execution.
Audit plugins
Audit plugins receive events at defined points in query execution, so they can be
used (for example) as a way to log what happens in the server.
 
Search WWH ::




Custom Search