1. MySQL Compatible Open
Source Connectors
Andrew (LinuxJedi) Hutchings
Master Software Engineer - HP
2. 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
3. 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
4. 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
5. 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)
6. 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
7. 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
8. BSD Simplified
● AKA BSD New or 3-Clause BSD
● Can link to commercial software
● Very liberal simple license
10. Apache 2.0
● Can link to commercial software
● Includes patent usage grants
● License text is around 5x longer than BSD's
11. PHP v3.01
● Not compatible with GPL license
● Can link with commercial software
12. License Compatibility
Library
GPL 2 PHP 3.01 Apache 2.0 LGPL 2.0 BSD/MIT
GPL (dynamically linked) ✔ ✘* ✔ ✔ ✔
Application
GPL (statically linked) ✔ ✘* ✔ ✔ ✔
Commercial (dynamically linked) ✘ ✔ ✔ ✔✝ ✔
Commercial (statically linked) ✘ ✔ ✔ ✘ ✔
* Workaround possible with FLOSS exception
✝ Need to provide lib source to end user
13. 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
16. C
libmysqlclient
● Developed by Oracle
● Bundled with MySQL
● LGPL licensed up until 3.23.58
● GPL licensed onwards
○ Also commercial licensed
○ Has FLOSS Exception
17. C
Connector/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)
18. C
MariaDB 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
19. 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
20. C
Libdrizzle 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)
21. C API Example
Setup
MySQL API
conn = mysql_init(NULL);
mysql_real_connect(conn, "localhost", "user", "passwd",
"testdb", 0, NULL, 0);
Drizzle API
drizzle = drizzle_create();
con = drizzle_con_add_tcp(drizzle, "localhost", 3306, "user",
"passwd", "testdb", 0);
ret = drizzle_con_connect(con);
22. C API Example
Query
MySQL API
mysql_query(conn, "SELECT * FROM t1");
result = mysql_store_result(conn);
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
...
Drizzle API
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)))
...
23. C++
Connector/C++
● Developed by Oracle
● JDBC 4.0 API compatible
○ Although only about 80% implemented
● GPL licensed
○ Commercial also available
○ Has FLOSS Exception
24. C
Connector/ODBC
● Developed by Oracle
● GPL Licensed
○ With FLOSS Exception
○ Commercial available
● Is a plugin for the ODBC framework, so good
for commercial
25. C#
Connector/NET
● Developed by Oracle
● GPL Licensed
○ With FLOSS Exception
○ Commercial available
● Implements ADO.NET interfaces
27. PHP
● Three different connectors
○ mysql
○ mysqli
○ pdo_mysql
● All three use either libmysqlclient or
MySQLnd
28. PHP
libmysqlclient 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!
35. Java
Connector/J
● Developed by Oracle
● GPL Licensed
○ Also has commercial license
○ With FLOSS exception
● JDBC Type 4 driver
○ So no linking with app required
36. Java
Drizzle JDBC
● Developed by Open Source community
○ Companies such as Sun and Rackspace have been
involved
● BSD Licensed
● JDBC Type 4.0 driver
37. Java
MariaDB Client Library for Java
● Developed by Monty Program Ab and
SkySQL Ab
● A fork of Drizzle JDBC
● LGPL Licensed
● JDBC Type 4.0 driver
39. Node.js
● Many available!
○ Around 10 projects
● node-mysql appears to be most prominent
○ MIT licensed
○ Appears to be a Native driver
40. 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
41. MySQL Cluster
● NDBAPI & MGMAPI
○ NoSQL interface
● Memcache based NoSQL interface
● Java APIs