SlideShare a Scribd company logo
1 of 47
Download to read offline
libAttachSQL 
The Next-Generation C Connector for MySQL 
by Andrew Hutchings (LinuxJedi), HP Advanced Technology Group
About LinuxJedi 
• Worked for Sun/Oracle, MySQL Support Engineer 
• Worked at Rackspace, Drizzle Software Engineer 
• Worked at SkySQL, Senior Sustaining Engineer 
• Managed two teams, several projects at HP Cloud 
• Co-Author of MySQL 5.1 Plugins Development
About HP's Advanced Techonology Group 
• An Open Source think-tank 
• Fosters collaboration throughout HP 
and Open Source communities
Other MySQL C Connectors 
• libmysqlclient (GPLv2/proprietary) 
• libdrizzle (3-clause BSD) 
• Maria DB Client (LGPLv2.1 (sort-of))
None of these have an official fully non-blocking API!
Introducing libAttachSQL
libAttachSQL 1.0 Features 
• Non-blocking API 
• Apache 2.0 license 
• Very lightweight (1.0.0 shared binary is 501KiB) 
• Can use OpenSSL and zlib for encryption and compression 
• Server side and (sort-of) local prepared statements 
• Good documentation from the start (http://docs.libattatchsql.org/)
Compatible With 
• Ubuntu 12.04 and up 
• RedHat/CentOS 6.x and up 
• Windows (via. MinGW cross-compile) 
• GCC and CLang
Why not libdrizzle? 
• libdrizzle 5.1 has a blocking API 
• Internal state loop is ugly to deal with 
• Networking code was hard to work with
Good things about libdrizzle 
• Lightweight 
• Nice, simple API 
• Well tested (Jenkins CI) 
• Easy to contribute to 
• Liberal license
Why libAttachSQL? 
• Modern techniques 
• All of the good points of libdrizzle, none of the legacy 
• Designed from the ground-up for use with MySQL
Event loops are web scale!
Non-blocking Internals 
• Using libuv - a library born out of Node.js 
• Uses epoll/poll/kqueue in *nix 
• Uses I/O Completion Ports in Windows
Very Open Development 
• GitHub (with issues & pull requests) 
• GitHub Pages + Pelican 
• Travis CI 
• Waffle.io 
• Read The Docs 
• Coverity Scan 
• IRC
Travis Tests 
• GCC 32bit & 64bit 
• CLang 3.0 32bit & 64bit 
• CLang 3.4 64bit 
• No OpenSSL & zlib 
• Valgrind 
• Cppcheck 
• CLang Scan-Build 
• Documentation (Sphinx nit-pick mode)
Software Using libAttachSQL 
• Sysbench 
• AttachBench
Basic Query Example
con= attachsql_connect_create("localhost", 3306, "test", "test", "testdb", NULL); 
attachsql_query(con, strlen(query), query, 0, NULL, &error);
Things to Note 
• We haven't actually even connected yet! 
• No query/result object
while ((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) 
{ 
ret= attachsql_connect_poll(con, &error); 
if (ret != ATTACHSQL_RETURN_ROW_READY) 
{ 
continue; 
}
row= attachsql_query_row_get(con, &error); 
columns= attachsql_query_column_count(con); 
... 
attachsql_query_row_next(con); 
}
Escaped Queries
const char *query= "SELECT * FROM t1 WHERE name = ? AND age > ?"; 
attachsql_query_parameter_st param[2]; 
const char *name= "fred"; 
uint32_t age= 30; 
param[0].type= ATTACHSQL_ESCAPE_TYPE_CHAR; 
param[0].data= (char*)name; 
param[0].length= strlen(name); 
param[1].type= ATTACHSQL_ESCAPE_TYPE_INT; 
param[1].data= &age; 
param[1].is_unsigned= true; 
attachsql_query(con, strlen(query), query, 2, param, &error);
Prepared Statements
const char *query= "SELECT * FROM t1 WHERE name = ? AND age > ?"; 
attachsql_statement_prepare(con, strlen(query), query, &error); 
while((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) 
{ 
ret= attachsql_connect_poll(con, &error); 
}
const char *name= "fred"; 
uint32_t age= 30; 
attachsql_statement_set_string(con, 0, strlen(name), name, NULL); 
attachsql_statement_set_int(con, 1, age, NULL); 
attachsql_statement_execute(con, &error); 
ret= ATTACHSQL_RETURN_NONE; 
while ((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) 
{
ret= attachsql_connect_poll(con, &error); 
if (ret != ATTACHSQL_RETURN_ROW_READY) 
{ 
continue; 
} 
attachsql_statement_row_get(con, &error); 
printf("ID: %d, ", attachsql_statement_get_int(con, 0, &error)); 
size_t len; 
char *name_data= attachsql_statement_get_char(con, 1, &len, &error); 
printf("Name: %.*s, ", (int)len, name_data); 
printf("Age: %dn", attachsql_statement_get_int(con, 2, &error)); 
attachsql_statement_row_next(con); 
}
Connection Groups 
• Group many connections into a single event loop 
• Many queries can run simultaneously on a single thread 
• Uses a callback API when there events to process 
• Can't be used for Prepared Statements (yet)
Connection Groups Example
group= attachsql_group_create(NULL); 
con[0]= attachsql_connect_create("localhost", 3306, "test", "test", "testdb", NULL); 
attachsql_group_add_connection(group, con[0], &error); 
attachsql_connect_set_callback(con[0], callbk, &con_no[0]);
attachsql_query(con[0], strlen(query1), query1, 0, NULL, &error);
while(done_count < 3) 
{ 
attachsql_group_run(group); 
} 
attachsql_group_destroy(group);
void callbk(attachsql_connect_t *current_con, attachsql_events_t events, 
void *context, attachsql_error_t *error) 
{ 
... 
switch(events) 
{
case ATTACHSQL_EVENT_CONNECTED: 
printf("Connected event on con %dn", *con_no); 
break;
case ATTACHSQL_EVENT_ERROR: 
printf("Error exists on con %d: %dn", *con_no, attachsql_error_code(error)); 
attachsql_error_free(error); 
break;
case ATTACHSQL_EVENT_EOF: 
printf("Connection %d finishedn", *con_no); 
done_count++; 
attachsql_query_close(current_con); 
break;
case ATTACHSQL_EVENT_ROW_READY: 
row= attachsql_query_row_get(current_con, &error); 
... 
attachsql_query_row_next(current_con); 
break;
Error Handling
attachsql_error_t *error= NULL; 
ret= attachsql_connect_poll(con, &error); 
if (error != NULL) 
{ 
printf("Error occurred: %s", attachsql_error_message(error)); 
attachsql_error_free(error); 
}
Project Status 
• 4 months in development (coding started 4th July) 
• 3 alpha releases, 2 beta releases, 1 RC release 
• First GA (1.0.0) is out now! 
• Packages for Ubuntu and RHEL/CentOS
Future 
• Python wrapper 
• Other language wrappers 
• Server API? 
• Tools built around libAttachSQL
Questions?
Thank you 
libAttachSQL - http://libattachsql.org/ 
Freenode IRC - #libAttachSQL 
GitHub - http://github.com/libattachsql/libattachsql 
Email andrew@linuxjedi.co.uk 
Twitter @LinuxJedi or @libAttachSQL

More Related Content

What's hot

Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend appsOtto Chrons
 
とりあえず使うScalaz
とりあえず使うScalazとりあえず使うScalaz
とりあえず使うScalazShuya Tsukamoto
 
Task queuing with redis and rq
Task queuing with redis and rqTask queuing with redis and rq
Task queuing with redis and rqndeininger
 
Node collaboration - sharing information between your systems
Node collaboration - sharing information between your systemsNode collaboration - sharing information between your systems
Node collaboration - sharing information between your systemsm_richardson
 
Scaling an ELK stack at bol.com
Scaling an ELK stack at bol.comScaling an ELK stack at bol.com
Scaling an ELK stack at bol.comRenzo Tomà
 
Elastic{ON} 2016 Review - 김종민 님
Elastic{ON} 2016 Review - 김종민 님Elastic{ON} 2016 Review - 김종민 님
Elastic{ON} 2016 Review - 김종민 님NAVER D2
 
CICD using jenkins and Nomad
CICD using jenkins and NomadCICD using jenkins and Nomad
CICD using jenkins and NomadBram Vogelaar
 
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupStartit
 
Machine Learning in a Twitter ETL using ELK
Machine Learning in a Twitter ETL using ELK Machine Learning in a Twitter ETL using ELK
Machine Learning in a Twitter ETL using ELK hypto
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rqAshish Acharya
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...All Things Open
 
Elastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & KibanaElastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & KibanaSpringPeople
 
Logstash-Elasticsearch-Kibana
Logstash-Elasticsearch-KibanaLogstash-Elasticsearch-Kibana
Logstash-Elasticsearch-Kibanadknx01
 
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Codemotion
 
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...ForgeRock
 

What's hot (20)

Scala.js for large and complex frontend apps
Scala.js for large and complex frontend appsScala.js for large and complex frontend apps
Scala.js for large and complex frontend apps
 
とりあえず使うScalaz
とりあえず使うScalazとりあえず使うScalaz
とりあえず使うScalaz
 
Task queuing with redis and rq
Task queuing with redis and rqTask queuing with redis and rq
Task queuing with redis and rq
 
Cummingsdceluna2012
Cummingsdceluna2012Cummingsdceluna2012
Cummingsdceluna2012
 
Node collaboration - sharing information between your systems
Node collaboration - sharing information between your systemsNode collaboration - sharing information between your systems
Node collaboration - sharing information between your systems
 
Scaling an ELK stack at bol.com
Scaling an ELK stack at bol.comScaling an ELK stack at bol.com
Scaling an ELK stack at bol.com
 
Elastic{ON} 2016 Review - 김종민 님
Elastic{ON} 2016 Review - 김종민 님Elastic{ON} 2016 Review - 김종민 님
Elastic{ON} 2016 Review - 김종민 님
 
CICD using jenkins and Nomad
CICD using jenkins and NomadCICD using jenkins and Nomad
CICD using jenkins and Nomad
 
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech MeetupLogstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
Logstash + Elasticsearch + Kibana Presentation on Startit Tech Meetup
 
Machine Learning in a Twitter ETL using ELK
Machine Learning in a Twitter ETL using ELK Machine Learning in a Twitter ETL using ELK
Machine Learning in a Twitter ETL using ELK
 
Elk scilifelab
Elk scilifelabElk scilifelab
Elk scilifelab
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
Asynchronous job queues with python-rq
Asynchronous job queues with python-rqAsynchronous job queues with python-rq
Asynchronous job queues with python-rq
 
Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...Leveraging Open Source for Database Development: Database Version Control wit...
Leveraging Open Source for Database Development: Database Version Control wit...
 
Elastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & KibanaElastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & Kibana
 
Logstash-Elasticsearch-Kibana
Logstash-Elasticsearch-KibanaLogstash-Elasticsearch-Kibana
Logstash-Elasticsearch-Kibana
 
Elk
Elk Elk
Elk
 
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
 
In
InIn
In
 
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
Customer Intelligence: Using the ELK Stack to Analyze ForgeRock OpenAM Audit ...
 

Similar to libAttachSQL, The Next-Generation C Connector For MySQL

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRichard Lee
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
Exploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeExploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeFrancis Alexander
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"IT Event
 
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsCassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsDataStax Academy
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearchErhwen Kuo
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroMohammad Shaker
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele RialdiCodeFest
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
 Openstack - An introduction/Installation - Presented at Dr Dobb's conference... Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...Rahul Krishna Upadhyaya
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkAarti Parikh
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchVic Hargrave
 

Similar to libAttachSQL, The Next-Generation C Connector For MySQL (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
Exploiting NoSQL Like Never Before
Exploiting NoSQL Like Never BeforeExploiting NoSQL Like Never Before
Exploiting NoSQL Like Never Before
 
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
Leonid Vasilyev  "Building, deploying and running production code at Dropbox"Leonid Vasilyev  "Building, deploying and running production code at Dropbox"
Leonid Vasilyev "Building, deploying and running production code at Dropbox"
 
Intro to CakePHP
Intro to CakePHPIntro to CakePHP
Intro to CakePHP
 
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data PlatformsCassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
Cassandra Summit 2014: Apache Spark - The SDK for All Big Data Platforms
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Raffaele Rialdi
Raffaele RialdiRaffaele Rialdi
Raffaele Rialdi
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
 Openstack - An introduction/Installation - Presented at Dr Dobb's conference... Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
Openstack - An introduction/Installation - Presented at Dr Dobb's conference...
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with Elasticsearch
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 

Recently uploaded

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 

Recently uploaded (20)

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

libAttachSQL, The Next-Generation C Connector For MySQL

  • 1. libAttachSQL The Next-Generation C Connector for MySQL by Andrew Hutchings (LinuxJedi), HP Advanced Technology Group
  • 2. About LinuxJedi • Worked for Sun/Oracle, MySQL Support Engineer • Worked at Rackspace, Drizzle Software Engineer • Worked at SkySQL, Senior Sustaining Engineer • Managed two teams, several projects at HP Cloud • Co-Author of MySQL 5.1 Plugins Development
  • 3. About HP's Advanced Techonology Group • An Open Source think-tank • Fosters collaboration throughout HP and Open Source communities
  • 4.
  • 5. Other MySQL C Connectors • libmysqlclient (GPLv2/proprietary) • libdrizzle (3-clause BSD) • Maria DB Client (LGPLv2.1 (sort-of))
  • 6. None of these have an official fully non-blocking API!
  • 8. libAttachSQL 1.0 Features • Non-blocking API • Apache 2.0 license • Very lightweight (1.0.0 shared binary is 501KiB) • Can use OpenSSL and zlib for encryption and compression • Server side and (sort-of) local prepared statements • Good documentation from the start (http://docs.libattatchsql.org/)
  • 9. Compatible With • Ubuntu 12.04 and up • RedHat/CentOS 6.x and up • Windows (via. MinGW cross-compile) • GCC and CLang
  • 10. Why not libdrizzle? • libdrizzle 5.1 has a blocking API • Internal state loop is ugly to deal with • Networking code was hard to work with
  • 11. Good things about libdrizzle • Lightweight • Nice, simple API • Well tested (Jenkins CI) • Easy to contribute to • Liberal license
  • 12. Why libAttachSQL? • Modern techniques • All of the good points of libdrizzle, none of the legacy • Designed from the ground-up for use with MySQL
  • 13. Event loops are web scale!
  • 14. Non-blocking Internals • Using libuv - a library born out of Node.js • Uses epoll/poll/kqueue in *nix • Uses I/O Completion Ports in Windows
  • 15.
  • 16. Very Open Development • GitHub (with issues & pull requests) • GitHub Pages + Pelican • Travis CI • Waffle.io • Read The Docs • Coverity Scan • IRC
  • 17.
  • 18. Travis Tests • GCC 32bit & 64bit • CLang 3.0 32bit & 64bit • CLang 3.4 64bit • No OpenSSL & zlib • Valgrind • Cppcheck • CLang Scan-Build • Documentation (Sphinx nit-pick mode)
  • 19. Software Using libAttachSQL • Sysbench • AttachBench
  • 20.
  • 22. con= attachsql_connect_create("localhost", 3306, "test", "test", "testdb", NULL); attachsql_query(con, strlen(query), query, 0, NULL, &error);
  • 23. Things to Note • We haven't actually even connected yet! • No query/result object
  • 24. while ((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) { ret= attachsql_connect_poll(con, &error); if (ret != ATTACHSQL_RETURN_ROW_READY) { continue; }
  • 25. row= attachsql_query_row_get(con, &error); columns= attachsql_query_column_count(con); ... attachsql_query_row_next(con); }
  • 27. const char *query= "SELECT * FROM t1 WHERE name = ? AND age > ?"; attachsql_query_parameter_st param[2]; const char *name= "fred"; uint32_t age= 30; param[0].type= ATTACHSQL_ESCAPE_TYPE_CHAR; param[0].data= (char*)name; param[0].length= strlen(name); param[1].type= ATTACHSQL_ESCAPE_TYPE_INT; param[1].data= &age; param[1].is_unsigned= true; attachsql_query(con, strlen(query), query, 2, param, &error);
  • 29. const char *query= "SELECT * FROM t1 WHERE name = ? AND age > ?"; attachsql_statement_prepare(con, strlen(query), query, &error); while((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) { ret= attachsql_connect_poll(con, &error); }
  • 30. const char *name= "fred"; uint32_t age= 30; attachsql_statement_set_string(con, 0, strlen(name), name, NULL); attachsql_statement_set_int(con, 1, age, NULL); attachsql_statement_execute(con, &error); ret= ATTACHSQL_RETURN_NONE; while ((ret != ATTACHSQL_RETURN_EOF) && (error == NULL)) {
  • 31. ret= attachsql_connect_poll(con, &error); if (ret != ATTACHSQL_RETURN_ROW_READY) { continue; } attachsql_statement_row_get(con, &error); printf("ID: %d, ", attachsql_statement_get_int(con, 0, &error)); size_t len; char *name_data= attachsql_statement_get_char(con, 1, &len, &error); printf("Name: %.*s, ", (int)len, name_data); printf("Age: %dn", attachsql_statement_get_int(con, 2, &error)); attachsql_statement_row_next(con); }
  • 32. Connection Groups • Group many connections into a single event loop • Many queries can run simultaneously on a single thread • Uses a callback API when there events to process • Can't be used for Prepared Statements (yet)
  • 34. group= attachsql_group_create(NULL); con[0]= attachsql_connect_create("localhost", 3306, "test", "test", "testdb", NULL); attachsql_group_add_connection(group, con[0], &error); attachsql_connect_set_callback(con[0], callbk, &con_no[0]);
  • 36. while(done_count < 3) { attachsql_group_run(group); } attachsql_group_destroy(group);
  • 37. void callbk(attachsql_connect_t *current_con, attachsql_events_t events, void *context, attachsql_error_t *error) { ... switch(events) {
  • 38. case ATTACHSQL_EVENT_CONNECTED: printf("Connected event on con %dn", *con_no); break;
  • 39. case ATTACHSQL_EVENT_ERROR: printf("Error exists on con %d: %dn", *con_no, attachsql_error_code(error)); attachsql_error_free(error); break;
  • 40. case ATTACHSQL_EVENT_EOF: printf("Connection %d finishedn", *con_no); done_count++; attachsql_query_close(current_con); break;
  • 41. case ATTACHSQL_EVENT_ROW_READY: row= attachsql_query_row_get(current_con, &error); ... attachsql_query_row_next(current_con); break;
  • 43. attachsql_error_t *error= NULL; ret= attachsql_connect_poll(con, &error); if (error != NULL) { printf("Error occurred: %s", attachsql_error_message(error)); attachsql_error_free(error); }
  • 44. Project Status • 4 months in development (coding started 4th July) • 3 alpha releases, 2 beta releases, 1 RC release • First GA (1.0.0) is out now! • Packages for Ubuntu and RHEL/CentOS
  • 45. Future • Python wrapper • Other language wrappers • Server API? • Tools built around libAttachSQL
  • 47. Thank you libAttachSQL - http://libattachsql.org/ Freenode IRC - #libAttachSQL GitHub - http://github.com/libattachsql/libattachsql Email andrew@linuxjedi.co.uk Twitter @LinuxJedi or @libAttachSQL