Upload
andrew-hutchings
View
2.939
Download
2
Embed Size (px)
DESCRIPTION
MySQL Compatible Open Source Connectors Slides for talk at Percona Live London 2012
Citation preview
MySQL Compatible Open Source Connectors
Andrew (LinuxJedi) HutchingsMaster Software Engineer - HP
Who am I?
● Worked at Sun/Oracle on MySQL 2008-2010● Worked at Rackspace on Drizzle 2010-2011● Worked at SkySQL on MySQL/Drizzle 2011● Co-author MySQL 5.1 Plugin Development● Now work at HP Cloud on an LBaaS
Why this talk?
● I work for HP Cloud● MySQL and its forks are the database for the
cloud● I currently work on a MySQL connector in
my spare time
Licenses
Notes:● I am not a lawyer● These legal views are my own and not
necessarily HP's○ They may not even be correct, my brain has been
fried with legalese
GPL v2
● General Public License● Compatible with most Open Source licenses● Not compatible with commercial licenses● Must include all source (and tracked
changes to library)
FLOSS Exception
Free/Libre Open Source Software Exceptions
● Allows GPL library to be linked to a non-compatible Open Source license without relicensing as GPL
● MySQL's built-in client library is covered by this○ Except maybe a few 5.1 versions
LGPL v2
● Lesser (or Library) General Public License● Allows dynamic linking with other licenses● Doesn't allow static linking
○ becomes a derivative work● Must include library source
BSD Simplified
● AKA BSD New or 3-Clause BSD● Can link to commercial software● Very liberal simple license
MIT
● Even more liberal than BSD● Very simple license
Apache 2.0
● Can link to commercial software● Includes patent usage grants● License text is around 5x longer than BSD's
PHP v3.01
● Not compatible with GPL license● Can link with commercial software
License Compatibility
GPL 2 PHP 3.01 Apache 2.0 LGPL 2.0 BSD/MIT
GPL (dynamically linked) ✔ ✘* ✔ ✔ ✔
GPL (statically linked) ✔ ✘* ✔ ✔ ✔
Commercial (dynamically linked) ✘ ✔ ✔ ✔✝ ✔
Commercial (statically linked) ✘ ✔ ✔ ✘ ✔App
licat
ion
Library
* Workaround possible with FLOSS exception✝ Need to provide lib source to end user
Frameworks
● Only linking to framework○ So connector license not a problem○ Connector is loaded on-demand by the framework○ Should be good as long as you don't distribute the
connector with your application● Examples include
○ ODBC (Open DataBase Connectivity)○ JDBC (Java DataBase Connectivity)○ SQLAlchemy (Python)
● Most are MIT licensed
Licensing Resources
TL;DR Legalhttp://www.tldrlegal.com/
GPL Compatibility Charthttp://www.gnu.org/licenses/license-list.html
Ask Monty Licensing FAQhttps://kb.askmonty.org/en/licensing-faq/
C/C++/C# Connectors
Clibmysqlclient
● Developed by Oracle● Bundled with MySQL● LGPL licensed up until 3.23.58● GPL licensed onwards
○ Also commercial licensed○ Has FLOSS Exception
CConnector/C
● Developed by Sun● An attempt to separate out the connector● GPL licensed
○ Also has commercial license○ Has FLOSS Exception
● No release since 2009-08-10 (6.0.2)
CMariaDB Client Library
● Developed by Monty Program Ab and SkySQL Ab
● A fork of MySQL's 3.23 client library○ Also contains some parts of MySQLnd
● LGPL licensed● Features added to catch up with current API
C/C++Libdrizzle
● Developed by Open Source community○ Companies such as Sun and Rackspace have been
involved● C API (some C++ in 2.0)● BSD licensed● Part of the main Drizzle project● Speaks both client and server MySQL
protocol
CLibdrizzle Redux
● Developed by me● A heavily modified version of Libdrizzle● Still under the Drizzle umbrella
○ But different tree● Still BSD licensed● Server API removed● More simplified client API● New features
○ Binlog retrieval API○ Compression Protocol (coming in 2013)○ Prepared Statements (coming in 2013)○ libmysqlclient compatible API (coming in 2013)
C API ExampleSetup
drizzle = drizzle_create();con = drizzle_con_add_tcp(drizzle, "localhost", 3306, "user", "passwd", "testdb", 0);ret = drizzle_con_connect(con);
conn = mysql_init(NULL);mysql_real_connect(conn, "localhost", "user", "passwd", "testdb", 0, NULL, 0);
MySQL API
Drizzle API
C API ExampleQuery
result = drizzle_query_str(con, "select * from t1", &ret);ret = drizzle_result_buffer(result);num_fields = drizzle_result_column_count(result);while ((row = drizzle_row_next(result)))
...
mysql_query(conn, "SELECT * FROM t1");result = mysql_store_result(conn);num_fields = mysql_num_fields(result);while ((row = mysql_fetch_row(result)))...
MySQL API
Drizzle API
C++Connector/C++
● Developed by Oracle● JDBC 4.0 API compatible
○ Although only about 80% implemented● GPL licensed
○ Commercial also available○ Has FLOSS Exception
CConnector/ODBC
● Developed by Oracle● GPL Licensed
○ With FLOSS Exception○ Commercial available
● Is a plugin for the ODBC framework, so good for commercial
C#Connector/NET
● Developed by Oracle● GPL Licensed
○ With FLOSS Exception○ Commercial available
● Implements ADO.NET interfaces
PHP Connectors
PHP
● Three different connectors○ mysql○ mysqli○ pdo_mysql
● All three use either libmysqlclient or MySQLnd
PHPlibmysqlclient based
● PHP can't link to GPL● PHP 3 dual licensed PHP/GPL● PHP 4 onwards licensed PHP only
○ So couldn't link to libmysqlclient○ But libmysqlclient has FLOSS Exception
● MySQLnd instead!
PHPMySQLnd
● Developed by Oracle● C based MySQL client library for PHP● Licensed under PHP license
Python Connectors
PythonMySQLdb
● Independently developed● GPL licensed● Wraps around libmysqlclient● Supports Python DB-API 2.0
PythonConnector/Python
● Developed by Oracle● GPL licensed
○ With FLOSS exception○ Commercial also available
● Native driver● Supports Python DB-API 2.0
Python FrameworkSQLAlchemy
● MIT licensed● Gets around linking problem● Uses DB-API 2.0 connectors
Java Connectors
JavaConnector/J
● Developed by Oracle● GPL Licensed
○ Also has commercial license○ With FLOSS exception
● JDBC Type 4 driver○ So no linking with app required
JavaDrizzle JDBC
● Developed by Open Source community○ Companies such as Sun and Rackspace have been
involved● BSD Licensed● JDBC Type 4.0 driver
JavaMariaDB Client Library for Java
● Developed by Monty Program Ab and SkySQL Ab
● A fork of Drizzle JDBC● LGPL Licensed● JDBC Type 4.0 driver
Other Interfaces
Node.js
● Many available!○ Around 10 projects
● node-mysql appears to be most prominent○ MIT licensed○ Appears to be a Native driver
NoSQL Interface
● Developed by Oracle● Included in MySQL 5.6● GPL Licensed
○ With a commercial version○ Unsure about FLOSS Exception
● Based on Memcache API● Direct access to InnoDB tables
MySQL Cluster
● NDBAPI & MGMAPI○ NoSQL interface
● Memcache based NoSQL interface● Java APIs
Plugins
Possible to create things like● UDP● HTTP / REST
Read my book to find out more:
Thank you!
My work (we're hiring!):http://hpcloud.com/
Twitter / Freenode IRC nick:LinuxJedi
Email:[email protected] / [email protected]