External Language                                   Stored Procedures         Presented by,MySQL AB® & O’Reilly Media, Inc...
Example: Non Trivial SortingRequirements:  Sort by first vowel (pig-latin) Options:1) Ignore it: Sort on the client.2) Rew...
Demo of Java Stored Procedures
Perl Stored ProceduresPerl stored routines are declared in standard Perl modules.CREATE PROCEDURE test.PerlPrimes1(top_lim...
Demo of Perl Stored Procedures
Server ImpactMinimal parser changesExtends existing stored procedure implementationVery minor change to system tablesRecur...
The Internals: How it works“External Language” implementations are a type of MySQL plug-inSummary of plug-in interfacefoo_...
The Internals: How it works (part 2)
Extensibility: The Sky is the LimitNot just for Perl and Java...Can be used as a replacement to the MySQL UDF API for user...
Tour of XML-RPC Plug-in Source
Security and LimitationsBasic user Create/Execute control by GRANT/REVOKE statementsSpecific language plugins are responsi...
The futureCode available todayhttps://code.launchpad.net/~starbuggers/mysql/mysql-5.1-wl820Planned:* Feature preview binar...
http://forge.mysql.com/wiki/ProjectPage_External_Language_Stored_Procedures                                    Questions? ...
A tour of External Language Stored Procedures for MySQL
A tour of External Language Stored Procedures for MySQL
Upcoming SlideShare
Loading in...5
×

A tour of External Language Stored Procedures for MySQL

662

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
662
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "A tour of External Language Stored Procedures for MySQL"

  1. 1. External Language Stored Procedures Presented by,MySQL AB® & O’Reilly Media, Inc. Eric Herman eric@mysql.com Antony T Curtis antony.curtis@ieee.org
  2. 2. Example: Non Trivial SortingRequirements: Sort by first vowel (pig-latin) Options:1) Ignore it: Sort on the client.2) Rewrite in existing UDF/SPframework.3) Somehow use existingbusiness logic in the server.Ideal Select:SELECT name, email FROM accountsWHERE ?ORDER BY pig_latin(name)LIMIT ?,?
  3. 3. Demo of Java Stored Procedures
  4. 4. Perl Stored ProceduresPerl stored routines are declared in standard Perl modules.CREATE PROCEDURE test.PerlPrimes1(top_limit INT)LANGUAGE Perl NO SQL DYNAMIC RESULT SETS 1EXTERNAL NAME MyUDFExample::testprimes;CALL test.PerlPrimes1(50);What works:IN/OUT parameters.Dynamic SQL with DBD::mysqlResult sets from hashes and arrays.
  5. 5. Demo of Perl Stored Procedures
  6. 6. Server ImpactMinimal parser changesExtends existing stored procedure implementationVery minor change to system tablesRecursion handlingRefactor Protocol handling for inline embedded SQLClient library: extended to support inline dynamic SQL
  7. 7. The Internals: How it works“External Language” implementations are a type of MySQL plug-inSummary of plug-in interfacefoo_udf_plugin_init - initialize the pluginfoo_udf_find - get a handle to routinefoo_udf_execute - call your routinefoo_udf_release - cleanup routine handlefoo_udf_plugin_deinit - tear down pluginCallback interface for storing/retrieving values from the server
  8. 8. The Internals: How it works (part 2)
  9. 9. Extensibility: The Sky is the LimitNot just for Perl and Java...Can be used as a replacement to the MySQL UDF API for user-definedextensions.Example: XML-RPCmysql> create function xml_get_state(id int) returns text -> no sql language xmlrpc external name -> xmlrpc://betty.userland.com/RPC2;examples.getStateName;Query OK, 0 rows affected (0.00 sec)mysql> select xml_get_state(40);+-------------------+| xml_get_state(40) |+-------------------+| South Carolina |+-------------------+1 row in set (0.42 sec)
  10. 10. Tour of XML-RPC Plug-in Source
  11. 11. Security and LimitationsBasic user Create/Execute control by GRANT/REVOKE statementsSpecific language plugins are responsible for their own sandboxesNo support for aggregate functions yetNot yet delivered an ‘adaptor’ for legacy UDF supportPlugins run in-process with MySQL daemon
  12. 12. The futureCode available todayhttps://code.launchpad.net/~starbuggers/mysql/mysql-5.1-wl820Planned:* Feature preview binaries to download* Type 2 Connector/J Driver* Legacy UDF adaptor* Fenced plugin adaptor* Additional languages: LUA, Ruby, Python...Pipe-dreams?
  13. 13. http://forge.mysql.com/wiki/ProjectPage_External_Language_Stored_Procedures Questions? Presented by,MySQL AB® & O’Reilly Media, Inc. Eric Herman eric@mysql.com Antony T Curtis antony.curtis@ieee.org
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×