SlideShare a Scribd company logo
1 of 22
Roland Bouman
http://rpbouman.blogspot.com/
1
MySQL 5.1 Plugins
Roland Bouman
http://rpbouman.blogspot.com/
2
Hi! Welcome to the MySQL UC,
Thanks for coming!!!
● Roland Bouman
● Ex MySQL AB/Sun
● BI guy, App.
Developer
● Leiden, Netherlands
● Sergei Golubchik
● Sun (MySQL)
● Architect, Senior
Software Developer
● Hamburg, Germany
Roland Bouman
http://rpbouman.blogspot.com/
3
...and you ?!
● Operating System?
● Ever compiled MySQL from Source?
● C/C++ language skills?
● Other language skills? Java? PHP?
● Virtualbox?
Roland Bouman
http://rpbouman.blogspot.com/
4
Program● Introduction
● Generic Code tasks
● Daemon Plug-in
– Hands-on (Daemon)
● Audit Plugin (Sergei)
● FULLTEXT parser Plug-in (Sergei)
● Information Schema Plug-in (Roland)
– Hands-on
● Future (Sergei)
● Storage Engine Plug-in (Roland)
Roland Bouman
http://rpbouman.blogspot.com/
5
MySQL 5.1 Plugin API – Overview
● New in MySQL 5.1
– Successor to User-defined Functions (UDFs)
● Plugin is a dynamically loadable binary library
– '.so' (linux)
– '.dylib' (Mac OS/X)
– '.dll' (Windows)
● Dynamically add or remove functionality
– No need to recompile
– No need to restart
Roland Bouman
http://rpbouman.blogspot.com/
6
Why to Extend ?
• You know why
• Adding functionality to the server that we have
no time to add
• Adding functions that we prefer not to have in
the server to avoid code bloat
• Adding features that you need!
Roland Bouman
http://rpbouman.blogspot.com/
7
How to Extend: Traditional
options
• Compiled-in function
• allows to use statically-compiled mysqld binary
• requires constant maintainance
• UDF
• user-defined function, loaded dynamically
• easier to maintain, but still not bullet-proof
• Procedure
• A filter that it is put after the select, but before the
data are sent (like in “ls -l|wc”)
• Only statically compiled, poorly documented
Roland Bouman
http://rpbouman.blogspot.com/
8
Plugin API
• New in MySQL 5.1
• Generic ― allows to load any functionality in the
running mysqld
• Built-in versioning
• Easy to maintain and distribute
• User friendly ― no cryptic arguments to install
• INSTALL PLUGIN foo SONAME 'bar.so'
• CREATE AGGREGATE FUNCTION median
RETURNS REAL SONAME 'aggr.so';
Roland Bouman
http://rpbouman.blogspot.com/
9
Compiling and Linking
• Built separately ? Loaded dynamically ?
• Yes! No!
• Plugin can be built separately
• Plugin can be built from the MySQL source tree
• No patching of MySQL code, simply unpack the
plugin tarball – it will be picked up automatically
• Plugin can be loaded dynamically
• Plugin can be linked in statically
• Without modifying plugin source code
Roland Bouman
http://rpbouman.blogspot.com/
10
Plugin Can
• provide the code for mysqld to execute
• add new status variables
• SHOW STATUS
• add new command-line options
• --plugin-option=value
• add new server variables
• SHOW VARIABLES, SET @@var
• add new SQL keywords (todo)
• CREATE TABLE ... METHOD='deflate'
Roland Bouman
http://rpbouman.blogspot.com/
11
MySQL 6.0 Plugin Types
● Storage Engines
● Full text parsers
● Information Schema tables
● Daemon
● Audit Plugins (New in 6.0)
Roland Bouman
http://rpbouman.blogspot.com/
12
MySQL 5.1 Plugins – Deployment
● Place plugin library in the plugin directory:
mysql> SHOW VARIABLES LIKE 'plugin_dir';
+----------------------------------------------------------+
| Variable_name | Value |
+---------------+------------------------------------------+
| plugin_dir | /usr/local/mysql/lib/plugin |
+---------------+------------------------------------------+
1 row in set (0.00 sec)
● Use DDL to install:
INSTALL PLUGIN <plugin_name> SONAME '<plugin_library>'
● ...and to uninstall:
UNINSTALL PLUGIN <plugin_name>
● NOTE: limited support for MS Windows
Roland Bouman
http://rpbouman.blogspot.com/
13
MySQL 5.1 Plugins – Managing
● Show all plugins with the SHOW syntax
mysql> SHOW PLUGINS LIKE 'PBXT';
● ...or query the information schema:
mysql> SELECT PLUGIN_NAME
-> , PLUGIN_VERSION
-> , PLUGIN_STATUS
-> , PLUGIN_TYPE
-> , PLUGIN_TYPE_VERSION
-> , PLUGIN_LIBRARY
-> , PLUGIN_LIBRARY_VERSION
-> , PLUGIN_AUTHOR
-> , PLUGIN_DESCRIPTION
-> , PLUGIN_LICENSE
-> FROM information_schema.PLUGINS
Roland Bouman
http://rpbouman.blogspot.com/
14
Storage Engine Plugins
Roland Bouman
http://rpbouman.blogspot.com/
15
Storage Engine Plugins
● Implements a row store
● MySQL Server delegates to engine
– Storage
– Retrieval
– Index lookup
– Statistics
● Usage:
CREATE TABLE <table_name> (
...columns...
)
ENGINE <plugin_name>
Roland Bouman
http://rpbouman.blogspot.com/
16
Storage Engine Plugin Examples
● PBXT (http://www.primebase.org/download/index.php)
● InnoDB (http://www.innodb.com/innodb_plugin/)
● XTRADB (https://launchpad.net/percona-xtradb)
● Federated X (?)
● S3 (http://fallenpegasus.com/code/mysql-awss3/)
● HTTP (http://tangent.org/528/myhttp_engine.html)
Roland Bouman
http://rpbouman.blogspot.com/
17
FULLTEXT parser Plugins
● For FULLTEXT indexes
● Filter text for built-in parser (Extraction)
– Example: parse PDF and pass on the text
● Instead of built-in parser (Splitting)
– Parse words out of text
● Postprocessing
● Usage:
CREATE TABLE t(
doc CHAR(255),
FULLTEXT INDEX (doc) WITH PARSER <parser-name>
);
Roland Bouman
http://rpbouman.blogspot.com/
18
FULLTEXT parser Plugins
Fulltext Parser Plugin
Lorem ipsum
dolor sit amet,
consectetuer
adipiscing elit.
Nunc quis felis
sed pede tristi-
que dignissim.
Fusce luctus,
nibh quis pel-
FOO
Extracting Splitting Postprocessing
Object Text Words Index
Roland Bouman
http://rpbouman.blogspot.com/
19
Information Schema Plugins
● Implements an information_schema table
– Can provide an arbitrary set of data
– Can report internal server data
● Usage: new information_schema table
becomes available after installation
Roland Bouman
http://rpbouman.blogspot.com/
20
Information Schema Plugin
Examples
● SIGAR plugin
– https://code.launchpad.net/~m.ch/mysql-server/sigar-plugin
● Vmstat
– http://krow.net/talks/PluggageInformationSchemaVancouver2007.pdf
– http://download.tangent.org/vmstat_information_schema-0.1.tar.gz
● Query Cache
– http://rpbouman.blogspot.com/2008/07/inspect-query-cahce-using-mysql.html
Roland Bouman
http://rpbouman.blogspot.com/
21
Daemon Plugins
● Generic plugin
– no particular type specific interface
– basically, this is a hack
● Yes, more so than the other plugin types
● Examples:
– Heartbeat plugin
– UDP client protocol implementation
Roland Bouman
http://rpbouman.blogspot.com/
22
Learn more
● http://dev.mysql.com/doc/refman/5.1/en/plugin-api.html
● http://rpbouman.blogspot.com/2008/02/mysql-information-schema-plugins-best.html
● http://rpbouman.blogspot.com/2008/02/reporting-mysql-internals-with.html
● http://forge.mysql.com/wiki/MySQL_Internals_Custom_Engine
● http://tangent.org/543/Skeleton_Engine_for_MySQL.html

More Related Content

What's hot

What's hot (20)

More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomMore on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
 
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
 
MariaDB Server on macOS - FOSDEM 2022 MariaDB Devroom
MariaDB Server on macOS -  FOSDEM 2022 MariaDB DevroomMariaDB Server on macOS -  FOSDEM 2022 MariaDB Devroom
MariaDB Server on macOS - FOSDEM 2022 MariaDB Devroom
 
PHP 5.6 New and Deprecated Features
PHP 5.6  New and Deprecated FeaturesPHP 5.6  New and Deprecated Features
PHP 5.6 New and Deprecated Features
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
 
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginxLSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
 
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAsFOSDEM 2015: gdb tips and tricks for MySQL DBAs
FOSDEM 2015: gdb tips and tricks for MySQL DBAs
 
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
 
More on gdb for my sql db as (fosdem 2016)
More on gdb for my sql db as (fosdem 2016)More on gdb for my sql db as (fosdem 2016)
More on gdb for my sql db as (fosdem 2016)
 
10 Most Important Features of New PHP 5.6
10 Most Important Features of New PHP 5.610 Most Important Features of New PHP 5.6
10 Most Important Features of New PHP 5.6
 
Ruby meetup ROM
Ruby meetup ROMRuby meetup ROM
Ruby meetup ROM
 
GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101GopherCon IL 2020 - Web Application Profiling 101
GopherCon IL 2020 - Web Application Profiling 101
 
Shaping Optimizer's Search Space
Shaping Optimizer's Search SpaceShaping Optimizer's Search Space
Shaping Optimizer's Search Space
 
An evening with Postgresql
An evening with PostgresqlAn evening with Postgresql
An evening with Postgresql
 
Go replicator
Go replicatorGo replicator
Go replicator
 
Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
 
Riding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamRiding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication Stream
 
Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)Sql php-vibrant course-mumbai(1)
Sql php-vibrant course-mumbai(1)
 
Automating with ansible (Part A)
Automating with ansible (Part A)Automating with ansible (Part A)
Automating with ansible (Part A)
 

Similar to 1. MySql plugins

01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1
Ivan Ma
 

Similar to 1. MySql plugins (20)

PostgreSQL for Oracle Developers and DBA's
PostgreSQL for Oracle Developers and DBA'sPostgreSQL for Oracle Developers and DBA's
PostgreSQL for Oracle Developers and DBA's
 
Beyond Puppet
Beyond PuppetBeyond Puppet
Beyond Puppet
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
SCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scalingSCM Puppet: from an intro to the scaling
SCM Puppet: from an intro to the scaling
 
Modern web technologies
Modern web technologiesModern web technologies
Modern web technologies
 
The Foreman Project
The Foreman ProjectThe Foreman Project
The Foreman Project
 
Git pusshuten
Git pusshutenGit pusshuten
Git pusshuten
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven Infrastructure
 
WordPress Security
WordPress SecurityWordPress Security
WordPress Security
 
OpenCms Days 2015 Workflow using Docker and Jenkins
OpenCms Days 2015 Workflow using Docker and JenkinsOpenCms Days 2015 Workflow using Docker and Jenkins
OpenCms Days 2015 Workflow using Docker and Jenkins
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
 
Joomlatools Platform v2.0
Joomlatools Platform v2.0Joomlatools Platform v2.0
Joomlatools Platform v2.0
 
Warsaw MuleSoft Meetup - Runtime Fabric
Warsaw MuleSoft Meetup - Runtime FabricWarsaw MuleSoft Meetup - Runtime Fabric
Warsaw MuleSoft Meetup - Runtime Fabric
 
Welcome to MySQL
Welcome to MySQLWelcome to MySQL
Welcome to MySQL
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Joomlatools Platform v1.0
Joomlatools Platform v1.0Joomlatools Platform v1.0
Joomlatools Platform v1.0
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
 

More from Roland Bouman (7)

Beyond OData: Introducing the XML/A model for ui5
Beyond OData: Introducing the XML/A model for ui5Beyond OData: Introducing the XML/A model for ui5
Beyond OData: Introducing the XML/A model for ui5
 
Moving and Transforming Data with Pentaho Data Integration 5.0 CE (aka Kettle)
Moving and Transforming Data with Pentaho Data Integration 5.0 CE (aka Kettle)Moving and Transforming Data with Pentaho Data Integration 5.0 CE (aka Kettle)
Moving and Transforming Data with Pentaho Data Integration 5.0 CE (aka Kettle)
 
Xml4js pentaho
Xml4js pentahoXml4js pentaho
Xml4js pentaho
 
Writing MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScriptWriting MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScript
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

1. MySql plugins

  • 2. Roland Bouman http://rpbouman.blogspot.com/ 2 Hi! Welcome to the MySQL UC, Thanks for coming!!! ● Roland Bouman ● Ex MySQL AB/Sun ● BI guy, App. Developer ● Leiden, Netherlands ● Sergei Golubchik ● Sun (MySQL) ● Architect, Senior Software Developer ● Hamburg, Germany
  • 3. Roland Bouman http://rpbouman.blogspot.com/ 3 ...and you ?! ● Operating System? ● Ever compiled MySQL from Source? ● C/C++ language skills? ● Other language skills? Java? PHP? ● Virtualbox?
  • 4. Roland Bouman http://rpbouman.blogspot.com/ 4 Program● Introduction ● Generic Code tasks ● Daemon Plug-in – Hands-on (Daemon) ● Audit Plugin (Sergei) ● FULLTEXT parser Plug-in (Sergei) ● Information Schema Plug-in (Roland) – Hands-on ● Future (Sergei) ● Storage Engine Plug-in (Roland)
  • 5. Roland Bouman http://rpbouman.blogspot.com/ 5 MySQL 5.1 Plugin API – Overview ● New in MySQL 5.1 – Successor to User-defined Functions (UDFs) ● Plugin is a dynamically loadable binary library – '.so' (linux) – '.dylib' (Mac OS/X) – '.dll' (Windows) ● Dynamically add or remove functionality – No need to recompile – No need to restart
  • 6. Roland Bouman http://rpbouman.blogspot.com/ 6 Why to Extend ? • You know why • Adding functionality to the server that we have no time to add • Adding functions that we prefer not to have in the server to avoid code bloat • Adding features that you need!
  • 7. Roland Bouman http://rpbouman.blogspot.com/ 7 How to Extend: Traditional options • Compiled-in function • allows to use statically-compiled mysqld binary • requires constant maintainance • UDF • user-defined function, loaded dynamically • easier to maintain, but still not bullet-proof • Procedure • A filter that it is put after the select, but before the data are sent (like in “ls -l|wc”) • Only statically compiled, poorly documented
  • 8. Roland Bouman http://rpbouman.blogspot.com/ 8 Plugin API • New in MySQL 5.1 • Generic ― allows to load any functionality in the running mysqld • Built-in versioning • Easy to maintain and distribute • User friendly ― no cryptic arguments to install • INSTALL PLUGIN foo SONAME 'bar.so' • CREATE AGGREGATE FUNCTION median RETURNS REAL SONAME 'aggr.so';
  • 9. Roland Bouman http://rpbouman.blogspot.com/ 9 Compiling and Linking • Built separately ? Loaded dynamically ? • Yes! No! • Plugin can be built separately • Plugin can be built from the MySQL source tree • No patching of MySQL code, simply unpack the plugin tarball – it will be picked up automatically • Plugin can be loaded dynamically • Plugin can be linked in statically • Without modifying plugin source code
  • 10. Roland Bouman http://rpbouman.blogspot.com/ 10 Plugin Can • provide the code for mysqld to execute • add new status variables • SHOW STATUS • add new command-line options • --plugin-option=value • add new server variables • SHOW VARIABLES, SET @@var • add new SQL keywords (todo) • CREATE TABLE ... METHOD='deflate'
  • 11. Roland Bouman http://rpbouman.blogspot.com/ 11 MySQL 6.0 Plugin Types ● Storage Engines ● Full text parsers ● Information Schema tables ● Daemon ● Audit Plugins (New in 6.0)
  • 12. Roland Bouman http://rpbouman.blogspot.com/ 12 MySQL 5.1 Plugins – Deployment ● Place plugin library in the plugin directory: mysql> SHOW VARIABLES LIKE 'plugin_dir'; +----------------------------------------------------------+ | Variable_name | Value | +---------------+------------------------------------------+ | plugin_dir | /usr/local/mysql/lib/plugin | +---------------+------------------------------------------+ 1 row in set (0.00 sec) ● Use DDL to install: INSTALL PLUGIN <plugin_name> SONAME '<plugin_library>' ● ...and to uninstall: UNINSTALL PLUGIN <plugin_name> ● NOTE: limited support for MS Windows
  • 13. Roland Bouman http://rpbouman.blogspot.com/ 13 MySQL 5.1 Plugins – Managing ● Show all plugins with the SHOW syntax mysql> SHOW PLUGINS LIKE 'PBXT'; ● ...or query the information schema: mysql> SELECT PLUGIN_NAME -> , PLUGIN_VERSION -> , PLUGIN_STATUS -> , PLUGIN_TYPE -> , PLUGIN_TYPE_VERSION -> , PLUGIN_LIBRARY -> , PLUGIN_LIBRARY_VERSION -> , PLUGIN_AUTHOR -> , PLUGIN_DESCRIPTION -> , PLUGIN_LICENSE -> FROM information_schema.PLUGINS
  • 15. Roland Bouman http://rpbouman.blogspot.com/ 15 Storage Engine Plugins ● Implements a row store ● MySQL Server delegates to engine – Storage – Retrieval – Index lookup – Statistics ● Usage: CREATE TABLE <table_name> ( ...columns... ) ENGINE <plugin_name>
  • 16. Roland Bouman http://rpbouman.blogspot.com/ 16 Storage Engine Plugin Examples ● PBXT (http://www.primebase.org/download/index.php) ● InnoDB (http://www.innodb.com/innodb_plugin/) ● XTRADB (https://launchpad.net/percona-xtradb) ● Federated X (?) ● S3 (http://fallenpegasus.com/code/mysql-awss3/) ● HTTP (http://tangent.org/528/myhttp_engine.html)
  • 17. Roland Bouman http://rpbouman.blogspot.com/ 17 FULLTEXT parser Plugins ● For FULLTEXT indexes ● Filter text for built-in parser (Extraction) – Example: parse PDF and pass on the text ● Instead of built-in parser (Splitting) – Parse words out of text ● Postprocessing ● Usage: CREATE TABLE t( doc CHAR(255), FULLTEXT INDEX (doc) WITH PARSER <parser-name> );
  • 18. Roland Bouman http://rpbouman.blogspot.com/ 18 FULLTEXT parser Plugins Fulltext Parser Plugin Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc quis felis sed pede tristi- que dignissim. Fusce luctus, nibh quis pel- FOO Extracting Splitting Postprocessing Object Text Words Index
  • 19. Roland Bouman http://rpbouman.blogspot.com/ 19 Information Schema Plugins ● Implements an information_schema table – Can provide an arbitrary set of data – Can report internal server data ● Usage: new information_schema table becomes available after installation
  • 20. Roland Bouman http://rpbouman.blogspot.com/ 20 Information Schema Plugin Examples ● SIGAR plugin – https://code.launchpad.net/~m.ch/mysql-server/sigar-plugin ● Vmstat – http://krow.net/talks/PluggageInformationSchemaVancouver2007.pdf – http://download.tangent.org/vmstat_information_schema-0.1.tar.gz ● Query Cache – http://rpbouman.blogspot.com/2008/07/inspect-query-cahce-using-mysql.html
  • 21. Roland Bouman http://rpbouman.blogspot.com/ 21 Daemon Plugins ● Generic plugin – no particular type specific interface – basically, this is a hack ● Yes, more so than the other plugin types ● Examples: – Heartbeat plugin – UDP client protocol implementation
  • 22. Roland Bouman http://rpbouman.blogspot.com/ 22 Learn more ● http://dev.mysql.com/doc/refman/5.1/en/plugin-api.html ● http://rpbouman.blogspot.com/2008/02/mysql-information-schema-plugins-best.html ● http://rpbouman.blogspot.com/2008/02/reporting-mysql-internals-with.html ● http://forge.mysql.com/wiki/MySQL_Internals_Custom_Engine ● http://tangent.org/543/Skeleton_Engine_for_MySQL.html