From c6b95222c3c614342575f752a6787b83fe6ffaa4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 26 Sep 2014 20:03:38 +0200 Subject: use MD5 service in innodb/xtradb --- include/mysql/service_md5.h | 2 +- libservices/my_md5_service.c | 2 +- storage/innobase/CMakeLists.txt | 25 ------------ storage/innobase/handler/ha_innodb.cc | 13 +++--- storage/innobase/wsrep/md5.cc | 75 ----------------------------------- storage/innobase/wsrep/wsrep_md5.h | 26 ------------ storage/xtradb/CMakeLists.txt | 25 ------------ storage/xtradb/handler/ha_innodb.cc | 13 +++--- storage/xtradb/wsrep/md5.cc | 75 ----------------------------------- storage/xtradb/wsrep/wsrep_md5.h | 26 ------------ 10 files changed, 16 insertions(+), 266 deletions(-) delete mode 100644 storage/innobase/wsrep/md5.cc delete mode 100644 storage/innobase/wsrep/wsrep_md5.h delete mode 100644 storage/xtradb/wsrep/md5.cc delete mode 100644 storage/xtradb/wsrep/wsrep_md5.h diff --git a/include/mysql/service_md5.h b/include/mysql/service_md5.h index faf967a5739..5e589e57415 100644 --- a/include/mysql/service_md5.h +++ b/include/mysql/service_md5.h @@ -1,5 +1,5 @@ #ifndef MYSQL_SERVICE_MD5_INCLUDED -/* Copyright (c) 2013, Monty Program Ab +/* Copyright (c) 2014, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/libservices/my_md5_service.c b/libservices/my_md5_service.c index f9db24d0179..f993751a9a5 100644 --- a/libservices/my_md5_service.c +++ b/libservices/my_md5_service.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 Monty Program Ab +/* Copyright (c) 2014 Monty Program Ab Use is subject to license terms. This program is free software; you can redistribute it and/or modify diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 79fe57dffc5..e783f3e6459 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -251,27 +251,6 @@ ENDIF() INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include ${CMAKE_SOURCE_DIR}/storage/innobase/handler) -IF(WITH_WSREP) - # ssl include directory - INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/storage/innobase/wsrep) - - IF(SSL_DEFINES) - ADD_DEFINITIONS(${SSL_DEFINES}) - ENDIF() - - LINK_LIBRARIES(${SSL_LIBRARIES}) - - # We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere. - # In order to get correct symbol visibility, these files - # must be compiled with "-fvisibility=hidden" - IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN) - SET_SOURCE_FILES_PROPERTIES( - {CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc - PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") - ENDIF() -ENDIF() - # Sun Studio bug with -xO2 IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2" @@ -420,10 +399,6 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) -IF(WITH_WSREP) - SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) -ENDIF() - IF(WITH_INNODB) # Legacy option SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2b0223a6c50..ef5387edca1 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -122,7 +122,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0priv.h" #include "../storage/innobase/include/ut0byte.h" #include -#include +#include extern my_bool wsrep_certify_nonPK; class binlog_trx_data; @@ -8142,7 +8142,8 @@ wsrep_calc_row_hash( ulint col_type; uint i; - void *ctx = wsrep_md5_init(); + void *ctx = alloca(my_md5_context_size()); + my_md5_init(ctx); n_fields = table->s->fields; @@ -8191,14 +8192,14 @@ wsrep_calc_row_hash( */ if (field->is_null_in_record(row)) { - wsrep_md5_update(ctx, (char*)&null_byte, 1); + my_md5_input(ctx, &null_byte, 1); } else { - wsrep_md5_update(ctx, (char*)&true_byte, 1); - wsrep_md5_update(ctx, (char*)ptr, len); + my_md5_input(ctx, &true_byte, 1); + my_md5_input(ctx, ptr, len); } } - wsrep_compute_md5_hash((char*)digest, ctx); + my_md5_result(ctx, digest); return(0); } diff --git a/storage/innobase/wsrep/md5.cc b/storage/innobase/wsrep/md5.cc deleted file mode 100644 index d3d83c65301..00000000000 --- a/storage/innobase/wsrep/md5.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (c) 2014 SkySQL AB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "my_config.h" - -#if defined(HAVE_YASSL) -#include "md5.hpp" -#elif defined(HAVE_OPENSSL) -#include -#endif /* HAVE_YASSL */ - -#ifdef WITH_WSREP - -/* Initialize md5 object. */ -void *wsrep_md5_init() -{ -#if defined(HAVE_YASSL) - TaoCrypt::MD5 *hasher= new TaoCrypt::MD5; - return (void*)hasher; -#elif defined(HAVE_OPENSSL) - MD5_CTX *ctx = new MD5_CTX(); - MD5_Init (ctx); - return (void *)ctx; -#endif /* HAVE_YASSL */ -} - -/** - Supply message to be hashed. - - @param ctx [IN] Pointer to MD5 context - @param buf [IN] Message to be computed. - @param len [IN] Length of the message. -*/ -void wsrep_md5_update(void *ctx, char* buf, int len) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len); -#elif defined(HAVE_OPENSSL) - MD5_Update((MD5_CTX*)(ctx), buf, len); -#endif /* HAVE_YASSL */ -} - -/** - Place computed MD5 digest into the given buffer. - - @param digest [OUT] Computed MD5 digest - @param ctx [IN] Pointer to MD5 context -*/ -void wsrep_compute_md5_hash(char *digest, void *ctx) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest); - delete (TaoCrypt::MD5*)ctx; -#elif defined(HAVE_OPENSSL) - MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx); - delete (MD5_CTX*)ctx; -#endif /* HAVE_YASSL */ -} - -#endif /* WITH_WSREP */ - diff --git a/storage/innobase/wsrep/wsrep_md5.h b/storage/innobase/wsrep/wsrep_md5.h deleted file mode 100644 index 1339f7f4b86..00000000000 --- a/storage/innobase/wsrep/wsrep_md5.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WSREP_MD5_INCLUDED -#define WSREP_MD5_INCLUDED - -/* Copyright (c) 2014 SkySQL AB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - -#ifdef WITH_WSREP -void *wsrep_md5_init(); -void wsrep_md5_update(void *ctx, char* buf, int len); -void wsrep_compute_md5_hash(char *digest, void *ctx); -#endif /* WITH_WSREP */ - -#endif /* WSREP_MD5_INCLUDED */ diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index c29888b8b15..e34add61886 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -268,27 +268,6 @@ ENDIF() INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/xtradb/include ${CMAKE_SOURCE_DIR}/storage/xtradb/handler) -IF(WITH_WSREP) - # ssl include directory - INCLUDE_DIRECTORIES(${SSL_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/storage/xtradb/wsrep) - - IF(SSL_DEFINES) - ADD_DEFINITIONS(${SSL_DEFINES}) - ENDIF() - - LINK_LIBRARIES(${SSL_LIBRARIES}) - - # We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere. - # In order to get correct symbol visibility, these files - # must be compiled with "-fvisibility=hidden" - IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN) - SET_SOURCE_FILES_PROPERTIES( - {CMAKE_CURRENT_SOURCE_DIR}/wsrep/md5.cc - PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") - ENDIF() -ENDIF() - # Sun Studio bug with -xO2 IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro" AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2" @@ -430,10 +409,6 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) -IF(WITH_WSREP) - SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) -ENDIF() - IF(NOT XTRADB_OK) MESSAGE(FATAL_ERROR "Percona XtraDB is not supported on this platform") ENDIF() diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 6773dc7c346..76de9efe080 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -125,7 +125,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0priv.h" #include "../storage/innobase/include/ut0byte.h" #include -#include +#include extern my_bool wsrep_certify_nonPK; class binlog_trx_data; @@ -8605,7 +8605,8 @@ wsrep_calc_row_hash( ulint col_type; uint i; - void *ctx = wsrep_md5_init(); + void *ctx = alloca(my_md5_context_size()); + my_md5_init(ctx); n_fields = table->s->fields; @@ -8654,14 +8655,14 @@ wsrep_calc_row_hash( */ if (field->is_null_in_record(row)) { - wsrep_md5_update(ctx, (char*)&null_byte, 1); + my_md5_input(ctx, &null_byte, 1); } else { - wsrep_md5_update(ctx, (char*)&true_byte, 1); - wsrep_md5_update(ctx, (char*)ptr, len); + my_md5_input(ctx, &true_byte, 1); + my_md5_input(ctx, ptr, len); } } - wsrep_compute_md5_hash((char*)digest, ctx); + my_md5_result(ctx, digest); return(0); } diff --git a/storage/xtradb/wsrep/md5.cc b/storage/xtradb/wsrep/md5.cc deleted file mode 100644 index d3d83c65301..00000000000 --- a/storage/xtradb/wsrep/md5.cc +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (c) 2014 SkySQL AB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "my_config.h" - -#if defined(HAVE_YASSL) -#include "md5.hpp" -#elif defined(HAVE_OPENSSL) -#include -#endif /* HAVE_YASSL */ - -#ifdef WITH_WSREP - -/* Initialize md5 object. */ -void *wsrep_md5_init() -{ -#if defined(HAVE_YASSL) - TaoCrypt::MD5 *hasher= new TaoCrypt::MD5; - return (void*)hasher; -#elif defined(HAVE_OPENSSL) - MD5_CTX *ctx = new MD5_CTX(); - MD5_Init (ctx); - return (void *)ctx; -#endif /* HAVE_YASSL */ -} - -/** - Supply message to be hashed. - - @param ctx [IN] Pointer to MD5 context - @param buf [IN] Message to be computed. - @param len [IN] Length of the message. -*/ -void wsrep_md5_update(void *ctx, char* buf, int len) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5 *)ctx)->Update((TaoCrypt::byte *) buf, len); -#elif defined(HAVE_OPENSSL) - MD5_Update((MD5_CTX*)(ctx), buf, len); -#endif /* HAVE_YASSL */ -} - -/** - Place computed MD5 digest into the given buffer. - - @param digest [OUT] Computed MD5 digest - @param ctx [IN] Pointer to MD5 context -*/ -void wsrep_compute_md5_hash(char *digest, void *ctx) -{ -#if defined(HAVE_YASSL) - ((TaoCrypt::MD5*)ctx)->Final((TaoCrypt::byte *) digest); - delete (TaoCrypt::MD5*)ctx; -#elif defined(HAVE_OPENSSL) - MD5_Final ((unsigned char*)digest, (MD5_CTX*)ctx); - delete (MD5_CTX*)ctx; -#endif /* HAVE_YASSL */ -} - -#endif /* WITH_WSREP */ - diff --git a/storage/xtradb/wsrep/wsrep_md5.h b/storage/xtradb/wsrep/wsrep_md5.h deleted file mode 100644 index 1339f7f4b86..00000000000 --- a/storage/xtradb/wsrep/wsrep_md5.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WSREP_MD5_INCLUDED -#define WSREP_MD5_INCLUDED - -/* Copyright (c) 2014 SkySQL AB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ - -#ifdef WITH_WSREP -void *wsrep_md5_init(); -void wsrep_md5_update(void *ctx, char* buf, int len); -void wsrep_compute_md5_hash(char *digest, void *ctx); -#endif /* WITH_WSREP */ - -#endif /* WSREP_MD5_INCLUDED */ -- cgit v1.2.1