43
MySQL Compatible Open Source Connectors Andrew (LinuxJedi) Hutchings Master Software Engineer - HP

MySQL Compatible Open Source Connectors

Embed Size (px)

DESCRIPTION

MySQL Compatible Open Source Connectors Slides for talk at Percona Live London 2012

Citation preview

Page 1: MySQL Compatible Open Source Connectors

MySQL Compatible Open Source Connectors

Andrew (LinuxJedi) HutchingsMaster Software Engineer - HP

Page 2: MySQL Compatible Open Source Connectors

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

Page 3: MySQL Compatible Open Source Connectors

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

Page 4: MySQL Compatible Open Source Connectors

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

Page 5: MySQL Compatible Open Source Connectors

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)

Page 6: MySQL Compatible Open Source Connectors

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

Page 7: MySQL Compatible Open Source Connectors

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

Page 8: MySQL Compatible Open Source Connectors

BSD Simplified

● AKA BSD New or 3-Clause BSD● Can link to commercial software● Very liberal simple license

Page 9: MySQL Compatible Open Source Connectors

MIT

● Even more liberal than BSD● Very simple license

Page 10: MySQL Compatible Open Source Connectors

Apache 2.0

● Can link to commercial software● Includes patent usage grants● License text is around 5x longer than BSD's

Page 11: MySQL Compatible Open Source Connectors

PHP v3.01

● Not compatible with GPL license● Can link with commercial software

Page 12: MySQL Compatible Open Source Connectors

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

Page 13: MySQL Compatible Open Source Connectors

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

Page 14: MySQL Compatible Open Source Connectors

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/

Page 15: MySQL Compatible Open Source Connectors

C/C++/C# Connectors

Page 16: MySQL Compatible Open Source Connectors

Clibmysqlclient

● Developed by Oracle● Bundled with MySQL● LGPL licensed up until 3.23.58● GPL licensed onwards

○ Also commercial licensed○ Has FLOSS Exception

Page 17: MySQL Compatible Open Source Connectors

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)

Page 18: MySQL Compatible Open Source Connectors

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

Page 19: MySQL Compatible Open Source Connectors

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

Page 20: MySQL Compatible Open Source Connectors

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)

Page 21: MySQL Compatible Open Source Connectors

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

Page 22: MySQL Compatible Open Source Connectors

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

Page 23: MySQL Compatible Open Source Connectors

C++Connector/C++

● Developed by Oracle● JDBC 4.0 API compatible

○ Although only about 80% implemented● GPL licensed

○ Commercial also available○ Has FLOSS Exception

Page 24: MySQL Compatible Open Source Connectors

CConnector/ODBC

● Developed by Oracle● GPL Licensed

○ With FLOSS Exception○ Commercial available

● Is a plugin for the ODBC framework, so good for commercial

Page 25: MySQL Compatible Open Source Connectors

C#Connector/NET

● Developed by Oracle● GPL Licensed

○ With FLOSS Exception○ Commercial available

● Implements ADO.NET interfaces

Page 26: MySQL Compatible Open Source Connectors

PHP Connectors

Page 27: MySQL Compatible Open Source Connectors

PHP

● Three different connectors○ mysql○ mysqli○ pdo_mysql

● All three use either libmysqlclient or MySQLnd

Page 28: MySQL Compatible Open Source Connectors

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!

Page 29: MySQL Compatible Open Source Connectors

PHPMySQLnd

● Developed by Oracle● C based MySQL client library for PHP● Licensed under PHP license

Page 30: MySQL Compatible Open Source Connectors

Python Connectors

Page 31: MySQL Compatible Open Source Connectors

PythonMySQLdb

● Independently developed● GPL licensed● Wraps around libmysqlclient● Supports Python DB-API 2.0

Page 32: MySQL Compatible Open Source Connectors

PythonConnector/Python

● Developed by Oracle● GPL licensed

○ With FLOSS exception○ Commercial also available

● Native driver● Supports Python DB-API 2.0

Page 33: MySQL Compatible Open Source Connectors

Python FrameworkSQLAlchemy

● MIT licensed● Gets around linking problem● Uses DB-API 2.0 connectors

Page 34: MySQL Compatible Open Source Connectors

Java Connectors

Page 35: MySQL Compatible Open Source 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

Page 36: MySQL Compatible Open Source Connectors

JavaDrizzle JDBC

● Developed by Open Source community○ Companies such as Sun and Rackspace have been

involved● BSD Licensed● JDBC Type 4.0 driver

Page 37: MySQL Compatible Open Source Connectors

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

Page 38: MySQL Compatible Open Source Connectors

Other Interfaces

Page 39: MySQL Compatible Open Source Connectors

Node.js

● Many available!○ Around 10 projects

● node-mysql appears to be most prominent○ MIT licensed○ Appears to be a Native driver

Page 40: MySQL Compatible Open Source Connectors

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

Page 41: MySQL Compatible Open Source Connectors

MySQL Cluster

● NDBAPI & MGMAPI○ NoSQL interface

● Memcache based NoSQL interface● Java APIs

Page 42: MySQL Compatible Open Source Connectors

Plugins

Possible to create things like● UDP● HTTP / REST

Read my book to find out more: