Skip to content

Commit

Permalink
Bug#24399819 SQL/RPL_WRITE_SET_HANDLER.CC INCLUDES PRIVATE LZ4 HEADER
Browse files Browse the repository at this point in the history
FILE

Problem: The fix for bug #23607230 used xxhash symbols from liblz4,
but even though the xxhash symbols are exported by liblz4, the header
file is not part of the API, so compilation fails when building with
WITH_LZ4=system.

Fix: Build xxhash separately from liblz4 so that it's available both
when using system and bundled lz4 libraries.
  • Loading branch information
nryeng committed Aug 5, 2016
1 parent 357b5bf commit e7a7489
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
27 changes: 27 additions & 0 deletions extra/lz4/my_xxhash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef MY_XXHASH_H_INCLUDED
#define MY_XXHASH_H_INCLUDED

/*
Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
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,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/

// Define a namespace prefix to all xxhash functions. This is done to
// avoid conflict with xxhash symbols in liblz4.
#define XXH_NAMESPACE MY_

#include "xxhash.h"

#endif // MY_XXHASH_H_INCLUDED
6 changes: 6 additions & 0 deletions libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ SET(SQL_EMBEDDED_SOURCES
libmysqld.c
${GEN_SOURCES}
${GEN_YACC_SOURCES}
../extra/lz4/xxhash.c
../client/get_password.c
../libmysql/errmsg.c
../libmysql/libmysql.c
Expand Down Expand Up @@ -118,6 +119,11 @@ ADD_COMPILE_FLAGS(
COMPILE_FLAGS -I${BOOST_PATCHES_DIR} -I${BOOST_INCLUDE_DIR}
)

ADD_COMPILE_FLAGS(
../extra/lz4/xxhash.c
COMPILE_FLAGS -DXXH_NAMESPACE=MY_
)

# Fixes "C1128: number of sections exceeded object file format limit" in MSVC /MD
# The flag /bigobj is not added if the build is not /MD
IF(WIN32 AND CMAKE_SIZEOF_VOID_P MATCHES 8)
Expand Down
6 changes: 6 additions & 0 deletions sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ SET(SQL_SOURCE
${GEN_DIGEST_SOURCES}
${CONF_SOURCES}
${SQL_SHARED_SOURCES}
../extra/lz4/xxhash.c
../libmysql/errmsg.c
../sql-common/client.c
../sql-common/client_plugin.c
Expand Down Expand Up @@ -314,6 +315,11 @@ ADD_COMPILE_FLAGS(
COMPILE_FLAGS -I${BOOST_PATCHES_DIR} -I${BOOST_INCLUDE_DIR}
)

ADD_COMPILE_FLAGS(
../extra/lz4/xxhash.c
COMPILE_FLAGS -DXXH_NAMESPACE=MY_
)

# Fixes "C1128: number of sections exceeded object file format limit" in MSVC /MD
# The flag /bigobj is not added if the build is not WINDOWS_RUNTIME_MD (/MD)
IF(WINDOWS_RUNTIME_MD AND CMAKE_SIZEOF_VOID_P MATCHES 8)
Expand Down
4 changes: 2 additions & 2 deletions sql/rpl_write_set_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "table.h" // TABLE

#include "my_murmur3.h" // murmur3_32
#include "xxhash.h" // xxHash
#include "../extra/lz4/my_xxhash.h" // xxHash

#include <map>
#include <string>
Expand Down Expand Up @@ -61,7 +61,7 @@ template <class type> uint64 calc_hash(ulong algorithm, type T)
if(algorithm == HASH_ALGORITHM_MURMUR32)
return (murmur3_32((const uchar*)T, strlen(T), 0));
else
return (XXH64((const uchar*)T, strlen(T), 0));
return (MY_XXH64((const uchar*)T, strlen(T), 0));
}

/**
Expand Down

0 comments on commit e7a7489

Please sign in to comment.