Skip to content

Commit

Permalink
Basic Async MySQL Client Support
Browse files Browse the repository at this point in the history
Summary:
WebScaleSQL Feature: Async Client

This diff builds loosely upon the 5.1 client work at Facebook, and
brings async to 5.6.  It is not fully feature complete (no SSL. no
compression, only supports the default native auth) but it is a good
first step, is sufficient for our needs, and we can extend it.

This also adds a #define to indicate the nonblocking client is available.

This changes slightly the ABI and so it also renames 'libmysqlclient' to
'libwebscalesqlclient' -- however, this is compatible with almost every
use case (changes are additive only, but do include changes to some data
structures).

Test Plan:
mtr, testing against internal tools

Also, tested building with:
* clang-3.5 with "-Wno-deprecated-register".
* gcc-4.9

Reviewers: chip, inaam-rana, pivanof, darnaut, jeremycole, weixiang.zhai

Reviewed By: jeremycole, inaam-rana, pivanof, chip, weixiang.zhai

Subscribers: fe, darnaut, methane, steaphan, atcurtis, chip, liang.guo.752, andrew-ford, jeremycole, flamingcow, MarkCallaghan, jtolmer

Differential Revision: https://reviews.facebook.net/D17031
Differential Revision: https://reviews.facebook.net/D33777
Differential Revision: https://reviews.facebook.net/D33801
Differential Revision: https://reviews.facebook.net/D36153
  • Loading branch information
steaphangreene authored and Herman Lee committed Jan 24, 2017
1 parent a195c8e commit 19dc9fa
Show file tree
Hide file tree
Showing 61 changed files with 3,303 additions and 382 deletions.
24 changes: 12 additions & 12 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@ COPY_OPENSSL_DLLS(copy_openssl_client)

ADD_DEFINITIONS(${SSL_DEFINES})
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc)
TARGET_LINK_LIBRARIES(mysql mysqlclient)
TARGET_LINK_LIBRARIES(mysql webscalesqlclient)
IF(UNIX)
TARGET_LINK_LIBRARIES(mysql ${READLINE_LIBRARY} ${CURSES_LIBRARY})
ENDIF(UNIX)

MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest mysqlclient regex)
TARGET_LINK_LIBRARIES(mysqltest webscalesqlclient regex)


MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)
TARGET_LINK_LIBRARIES(mysqlcheck webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
TARGET_LINK_LIBRARIES(mysqldump webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
TARGET_LINK_LIBRARIES(mysqlimport webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
TARGET_LINK_LIBRARIES(mysql_upgrade webscalesqlclient)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)

MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c)
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
TARGET_LINK_LIBRARIES(mysqlshow webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c)
TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient)
TARGET_LINK_LIBRARIES(mysql_plugin webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient semisync_slave_client)
TARGET_LINK_LIBRARIES(mysqlbinlog webscalesqlclient semisync_slave_client)

MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)
TARGET_LINK_LIBRARIES(mysqladmin webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)
TARGET_LINK_LIBRARIES(mysqlslap webscalesqlclient)

MYSQL_ADD_EXECUTABLE(mysql_config_editor mysql_config_editor.cc)
TARGET_LINK_LIBRARIES(mysql_config_editor mysqlclient)
TARGET_LINK_LIBRARIES(mysql_config_editor webscalesqlclient)

# "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/".
IF(WIN32)
Expand Down
14 changes: 14 additions & 0 deletions client/client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ enum options_client
*/
#define PERFORMANCE_SCHEMA_DB_NAME "performance_schema"

#if defined(USE_MYSQL_REAL_CONNECT_WRAPPER)
static MYSQL *
mysql_real_connect_wrapper(MYSQL *mysql, const char *host,
const char *user, const char *passwd,
const char *db, uint port,
const char *unix_socket, ulong client_flag);
#endif

/**
Wrapper for mysql_real_connect() that checks if SSL connection is establised.
Expand All @@ -143,8 +151,13 @@ MYSQL *mysql_connect_ssl_check(MYSQL *mysql_arg, const char *host,
const char *unix_socket, ulong client_flag,
my_bool ssl_required MY_ATTRIBUTE((unused)))
{
#if defined(USE_MYSQL_REAL_CONNECT_WRAPPER)
MYSQL *mysql= mysql_real_connect_wrapper(mysql_arg, host, user, passwd, db,
port, unix_socket, client_flag);
#else
MYSQL *mysql= mysql_real_connect(mysql_arg, host, user, passwd, db, port,
unix_socket, client_flag);
#endif
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if (mysql && /* connection established. */
ssl_required && /* --ssl-mode=REQUIRED. */
Expand All @@ -159,3 +172,4 @@ MYSQL *mysql_connect_ssl_check(MYSQL *mysql_arg, const char *host,
#endif
return mysql;
}

Loading

0 comments on commit 19dc9fa

Please sign in to comment.