mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Allow to disable ICU (#711)
* Allow to disable ICU [#CLICKHOUSE-2]. * Addition to prev. revision [#CLICKHOUSE-2]. * Addition to prev. revision [#CLICKHOUSE-2]. * Addition to prev. revision [#CLICKHOUSE-2].
This commit is contained in:
parent
3ad87ec820
commit
35abae95c8
@ -1,10 +1,21 @@
|
||||
set (ICU_PATHS "/usr/local/opt/icu4c/lib")
|
||||
set (ICU_INCLUDE_PATHS "/usr/local/opt/icu4c/include")
|
||||
find_library (ICUI18N icui18n PATHS ${ICU_PATHS})
|
||||
find_library (ICUUC icuuc PATHS ${ICU_PATHS})
|
||||
find_library (ICUDATA icudata PATHS ${ICU_PATHS})
|
||||
set (ICU_LIBS ${ICUI18N} ${ICUUC} ${ICUDATA})
|
||||
option (ENABLE_ICU "Enable ICU" ON)
|
||||
|
||||
find_path (ICU_INCLUDE_DIR NAMES unicode/unistr.h PATHS ${ICU_INCLUDE_PATHS})
|
||||
message (STATUS "Using icu: ${ICU_INCLUDE_DIR} : ${ICU_LIBS}")
|
||||
include_directories (${ICU_INCLUDE_DIR})
|
||||
if (ENABLE_ICU)
|
||||
set (ICU_PATHS "/usr/local/opt/icu4c/lib")
|
||||
set (ICU_INCLUDE_PATHS "/usr/local/opt/icu4c/include")
|
||||
find_library (ICUI18N icui18n PATHS ${ICU_PATHS})
|
||||
find_library (ICUUC icuuc PATHS ${ICU_PATHS})
|
||||
find_library (ICUDATA icudata PATHS ${ICU_PATHS})
|
||||
set (ICU_LIBS ${ICUI18N} ${ICUUC} ${ICUDATA})
|
||||
|
||||
find_path (ICU_INCLUDE_DIR NAMES unicode/unistr.h PATHS ${ICU_INCLUDE_PATHS})
|
||||
include_directories (${ICU_INCLUDE_DIR})
|
||||
|
||||
set(USE_ICU 1)
|
||||
endif ()
|
||||
|
||||
if (USE_ICU)
|
||||
message (STATUS "Using icu=${USE_ICU}: ${ICU_INCLUDE_DIR} : ${ICU_LIBS}")
|
||||
else ()
|
||||
message (STATUS "Build without ICU (support for collations and charset conversion functions will be disabled)")
|
||||
endif ()
|
||||
|
@ -1,18 +1,36 @@
|
||||
#include <Common/Collator.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __APPLE__
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <Common/config.h>
|
||||
#if USE_ICU
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef __APPLE__
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
#include <unicode/ucol.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#else
|
||||
#pragma GCC diagnostic ignored "-Wunused-private-field"
|
||||
#endif
|
||||
#include <unicode/ucol.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <Common/Exception.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Poco/String.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int UNSUPPORTED_COLLATION_LOCALE;
|
||||
extern const int COLLATION_COMPARISON_FAILED;
|
||||
extern const int SUPPORT_IS_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Collator::Collator(const std::string & locale_) : locale(Poco::toLower(locale_))
|
||||
{
|
||||
#if USE_ICU
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
collator = ucol_open(locale.c_str(), &status);
|
||||
@ -21,15 +39,22 @@ Collator::Collator(const std::string & locale_) : locale(Poco::toLower(locale_))
|
||||
ucol_close(collator);
|
||||
throw DB::Exception("Unsupported collation locale: " + locale, DB::ErrorCodes::UNSUPPORTED_COLLATION_LOCALE);
|
||||
}
|
||||
#else
|
||||
throw DB::Exception("Collations support is disabled, because ClickHouse was built without ICU library", DB::ErrorCodes::SUPPORT_IS_DISABLED);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Collator::~Collator()
|
||||
{
|
||||
#if USE_ICU
|
||||
ucol_close(collator);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Collator::compare(const char * str1, size_t length1, const char * str2, size_t length2) const
|
||||
{
|
||||
#if USE_ICU
|
||||
UCharIterator iter1, iter2;
|
||||
uiter_setUTF8(&iter1, str1, length1);
|
||||
uiter_setUTF8(&iter2, str2, length2);
|
||||
@ -47,6 +72,9 @@ int Collator::compare(const char * str1, size_t length1, const char * str2, size
|
||||
* UCOL_LESS = -1
|
||||
*/
|
||||
return compare_result;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string & Collator::getLocale() const
|
||||
|
@ -5,16 +5,6 @@
|
||||
|
||||
struct UCollator;
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int UNSUPPORTED_COLLATION_LOCALE;
|
||||
extern const int COLLATION_COMPARISON_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Collator : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// .h autogenerated by cmake !
|
||||
|
||||
#cmakedefine01 USE_ICU
|
||||
#cmakedefine01 USE_MYSQL
|
||||
#cmakedefine01 USE_RE2_ST
|
||||
#cmakedefine01 USE_VECTORCLASS
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include <Common/config.h>
|
||||
#if USE_ICU
|
||||
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Functions/ObjectPool.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
@ -216,3 +219,14 @@ void registerFunctionsCharset(FunctionFactory & factory)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class FunctionFactory;
|
||||
void registerFunctionsCharset(FunctionFactory & factory) {}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
option (ENABLE_MYSQL "Enable MySQL" ON)
|
||||
|
||||
if (ENABLE_MYSQL)
|
||||
|
||||
set (MYSQL_LIB_PATHS
|
||||
"/usr/local/opt/mysql/lib"
|
||||
"/usr/local/lib/mysql/"
|
||||
@ -12,15 +11,13 @@ if (ENABLE_MYSQL)
|
||||
"/usr/lib/mysql"
|
||||
"/usr/lib64/mysql"
|
||||
"/lib/mysql"
|
||||
"/lib64/mysql"
|
||||
)
|
||||
"/lib64/mysql")
|
||||
|
||||
set (MYSQL_INCLUDE_PATHS
|
||||
"/usr/local/opt/mysql/include"
|
||||
"/usr/mysql/include/mysql"
|
||||
"/usr/local/include/mysql"
|
||||
"/usr/include/mysql"
|
||||
)
|
||||
"/usr/include/mysql")
|
||||
|
||||
find_path (MYSQL_INCLUDE_DIR NAMES mysql/mysql.h PATHS ${MYSQL_INCLUDE_PATHS})
|
||||
|
||||
@ -38,7 +35,13 @@ if (ENABLE_MYSQL)
|
||||
if (MYSQL_FOUND)
|
||||
set(USE_MYSQL 1)
|
||||
set(MYSQLXX_LIBRARY mysqlxx)
|
||||
else ()
|
||||
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
message (STATUS "Using mysqlclient=${MYSQL_FOUND}: ${MYSQL_INCLUDE_DIR} : ${MYSQLCLIENT_LIB}; static=${STATIC_MYSQLCLIENT_LIB}")
|
||||
if (USE_MYSQL)
|
||||
message (STATUS "Using mysqlclient=${MYSQL_FOUND}: ${MYSQL_INCLUDE_DIR} : ${MYSQLCLIENT_LIB}; static=${STATIC_MYSQLCLIENT_LIB}")
|
||||
else ()
|
||||
message (STATUS "Build without mysqlclient (support for MYSQL dictionary source will be disabled)")
|
||||
endif ()
|
||||
|
Loading…
Reference in New Issue
Block a user