diff --git a/Makefile b/Makefile index e7dae0586..b34fefc0a 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ DEBUG=${ALL_DEBUG} #export OPTZ #export EXTRALINK export MAKE -export CURVER?=2.5.0 +export CURVER?=2.4.7 ifneq (,$(wildcard /etc/os-release)) DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) else diff --git a/deps/Makefile b/deps/Makefile index 60c67a934..55a45ba99 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -75,7 +75,7 @@ endif ifeq ($(UNAME_S),Darwin) sed -i '' 's/CC=/CC?=/' libinjection/libinjection/src/Makefile else - sed -i 's/CC=/CC?=/' libinjection/libinjection/src/Makefile + sed -i -e 's/CC=/CC?=/' libinjection/libinjection/src/Makefile endif cd libinjection/libinjection && CC=${CC} CXX=${CXX} ${MAKE} @@ -178,7 +178,7 @@ else echo ">>> Clickhouse CXX11" cd clickhouse-cpp && ln -fs clickhouse-cpp-1.0.0 clickhouse-cpp cd clickhouse-cpp && tar -zxf v1.0.0.tar.gz && sync - cd clickhouse-cpp && sed -i 's/SET (CMAKE_CXX_STANDARD_REQUIRED ON)//' clickhouse-cpp/cmake/cpp17.cmake + cd clickhouse-cpp && sed -i -e 's/SET (CMAKE_CXX_STANDARD_REQUIRED ON)//' clickhouse-cpp/cmake/cpp17.cmake endif cd clickhouse-cpp/clickhouse-cpp && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo . cd clickhouse-cpp/clickhouse-cpp && CC=${CC} CXX=${CXX} ${MAKE} diff --git a/include/proxysql_utils.h b/include/proxysql_utils.h index 8a79127d0..2d75c4693 100644 --- a/include/proxysql_utils.h +++ b/include/proxysql_utils.h @@ -8,6 +8,12 @@ #include #include +#ifndef ETIME +// ETIME is not defined on FreeBSD +// ETIME is used internaly to report API timer expired +// replace with ETIMEDOUT as closest alternative +#define ETIME ETIMEDOUT +#endif #ifdef CXX17 template struct conjunction : std::true_type { }; diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 98565dd00..7af628237 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -3627,57 +3627,29 @@ SQLite3_result * ProxySQL_Admin::generate_show_table_status(const char *tablenam return result; } -/** - * @brief Helper function to format the received hours into a string - * in the format ('HH'|'0H'|'-0H'|'-HH'). Depending on the supplied - * number digit count and sign. - * @param num A number to be converted to described format. - * @return std::string holding the converted number. - */ -const std::string format_timezone_hours(const int num) { - std::string result {}; - - const std::string base_num = std::to_string(num); - - if (num < 10 && num >= 0) { - result = "0" + base_num; - } else if (num > -10 && num < 0) { - result = base_num.substr(0, 1) + "0" + base_num.substr(1); - } else if (num <= -10) { - result = base_num; - } - - return result; -} - /** * @brief Helper function that converts the current timezone * expressed in seconds into a string of the format: - * - 'hours' + ':00:00'. + * - '[-]HH:MM:00'. * Following the same pattern as the possible values returned by the SQL query * 'SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP())' in a MySQL server. * @return A string holding the specified representation of the * supplied timezone. */ std::string timediff_timezone_offset() { - // explecitly call 'tzset' to make sure '::timezone' is set - tzset(); - - // get the global variable - long int timezone = ::timezone; - - // first negate the received number - timezone = -timezone; - - // transform into hours - int timezone_offset_hours = timezone / 3600; - - // create an string with the resulting 'hours' + ':00:00' - std::string time_zone_offset { - format_timezone_hours(timezone_offset_hours) + ":00:00" - }; - - return time_zone_offset; + std::string time_zone_offset {}; + char result[8]; + time_t rawtime; + struct tm *info; + int offset; + + time(&rawtime); + info = localtime(&rawtime); + strftime(result, 8, "%z", info); + offset = (result[0] == '+') ? 1 : 0; + time_zone_offset = ((std::string)(result)).substr(offset, 3-offset) + ":" + ((std::string)(result)).substr(3, 2) + ":00"; + + return time_zone_offset; } void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) {