diff --git a/avro/maxavro_internal.hh b/avro/maxavro_internal.hh index 6f0ee091c..ca0b03843 100644 --- a/avro/maxavro_internal.hh +++ b/avro/maxavro_internal.hh @@ -50,12 +50,12 @@ bool maxavro_datablock_finalize(MAXAVRO_DATABLOCK* block); /** Adding values to a datablock. The caller must ensure that the inserted * values conform to the file schema and that the required amount of fields * is added before finalizing the block. */ -bool maxavro_datablock_add_integer(MAXAVRO_DATABLOCK *file, uint64_t val); -bool maxavro_datablock_add_string(MAXAVRO_DATABLOCK *file, const char* str); -bool maxavro_datablock_add_float(MAXAVRO_DATABLOCK *file, float val); -bool maxavro_datablock_add_double(MAXAVRO_DATABLOCK *file, double val); +bool maxavro_datablock_add_integer(MAXAVRO_DATABLOCK* file, uint64_t val); +bool maxavro_datablock_add_string(MAXAVRO_DATABLOCK* file, const char* str); +bool maxavro_datablock_add_float(MAXAVRO_DATABLOCK* file, float val); +bool maxavro_datablock_add_double(MAXAVRO_DATABLOCK* file, double val); -bool maxavro_read_datablock_start(MAXAVRO_FILE *file); -bool maxavro_verify_block(MAXAVRO_FILE *file); -const char* type_to_string(enum maxavro_value_type type); -enum maxavro_value_type string_to_type(const char *str); +bool maxavro_read_datablock_start(MAXAVRO_FILE* file); +bool maxavro_verify_block(MAXAVRO_FILE* file); +const char* type_to_string(enum maxavro_value_type type); +enum maxavro_value_type string_to_type(const char* str); diff --git a/avro/maxavro_record.cc b/avro/maxavro_record.cc index 88a356f51..4948a6125 100644 --- a/avro/maxavro_record.cc +++ b/avro/maxavro_record.cc @@ -26,7 +26,9 @@ * @param field_num Field index in the schema * @return JSON object or NULL if an error occurred */ -static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *field, enum maxavro_value_type type) +static json_t* read_and_pack_value(MAXAVRO_FILE* file, + MAXAVRO_SCHEMA_FIELD* field, + enum maxavro_value_type type) { json_t* value = NULL; switch (type) @@ -107,7 +109,7 @@ static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *fie case MAXAVRO_TYPE_UNION: { - json_t *arr = (json_t*)field->extra; + json_t* arr = (json_t*)field->extra; uint64_t val = 0; if (maxavro_read_integer(file, &val) && val < json_array_size(arr)) @@ -187,7 +189,9 @@ json_t* maxavro_record_read_json(MAXAVRO_FILE* file) { for (size_t i = 0; i < file->schema->num_fields; i++) { - json_t* value = read_and_pack_value(file, &file->schema->fields[i], file->schema->fields[i].type); + json_t* value = read_and_pack_value(file, + &file->schema->fields[i], + file->schema->fields[i].type); if (value) { json_object_set_new(object, file->schema->fields[i].name, value); diff --git a/examples/examplefilter.cc b/examples/examplefilter.cc index 824bc1849..4ff25208c 100644 --- a/examples/examplefilter.cc +++ b/examples/examplefilter.cc @@ -44,15 +44,15 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() MXS_FILTER_VERSION, DESC, "V1.0.0", - RCAP_TYPE_STMT_INPUT, // See getCapabilities() below - &ExampleFilter::s_object, // This is defined in the MaxScale filter template - NULL, /* Process init. */ - NULL, /* Process finish. */ - NULL, /* Thread init. */ - NULL, /* Thread finish. */ + RCAP_TYPE_STMT_INPUT, // See getCapabilities() below + &ExampleFilter::s_object, // This is defined in the MaxScale filter template + NULL, /* Process init. */ + NULL, /* Process finish. */ + NULL, /* Thread init. */ + NULL, /* Thread finish. */ { - {"an_example_parameter", MXS_MODULE_PARAM_STRING, "a-default-value"}, - {CN_COUNT_GLOBALS, MXS_MODULE_PARAM_BOOL, "true"}, + {"an_example_parameter",MXS_MODULE_PARAM_STRING, "a-default-value"}, + {CN_COUNT_GLOBALS, MXS_MODULE_PARAM_BOOL, "true" }, {MXS_END_MODULE_PARAMS} } }; diff --git a/examples/examplefilter.hh b/examples/examplefilter.hh index 8faf2651a..21df24ee4 100644 --- a/examples/examplefilter.hh +++ b/examples/examplefilter.hh @@ -87,8 +87,8 @@ private: ExampleFilter(const MXS_CONFIG_PARAMETER* pParams); // The fields are specific to ExampleFilter. - std::atomic m_total_queries {0}; /**< How many queries has this filter seen */ - std::atomic m_total_replies {0}; /**< How many replies has this filter seen */ + std::atomic m_total_queries {0}; /**< How many queries has this filter seen */ + std::atomic m_total_replies {0}; /**< How many replies has this filter seen */ - bool m_collect_global_counts {false}; /**< Should sessions manipulate the total counts */ + bool m_collect_global_counts {false}; /**< Should sessions manipulate the total counts */ }; diff --git a/examples/examplefiltersession.hh b/examples/examplefiltersession.hh index ced7116fd..9c9c7321a 100644 --- a/examples/examplefiltersession.hh +++ b/examples/examplefiltersession.hh @@ -70,9 +70,9 @@ private: // Used in the create function ExampleFilterSession(MXS_SESSION* pSession, ExampleFilter& filter); - ExampleFilter& m_filter; /**< Shared filter data */ + ExampleFilter& m_filter; /**< Shared filter data */ - uint64_t m_session_id {0}; /**< Session id */ - int m_queries {0}; /**< How many queries has this session seen */ - int m_replies {0}; /**< How many replies has this session seen */ + uint64_t m_session_id {0}; /**< Session id */ + int m_queries {0}; /**< How many queries has this session seen */ + int m_replies {0}; /**< How many replies has this session seen */ }; diff --git a/maxutils/maxbase/include/maxbase/eventcount.hh b/maxutils/maxbase/include/maxbase/eventcount.hh index 74997fca9..163ea3ede 100644 --- a/maxutils/maxbase/include/maxbase/eventcount.hh +++ b/maxutils/maxbase/include/maxbase/eventcount.hh @@ -58,7 +58,8 @@ public: { TimePoint time_point; int count; - Timestamp(TimePoint p, int c) : time_point(p) + Timestamp(TimePoint p, int c) + : time_point(p) , count(c) { } diff --git a/maxutils/maxbase/include/maxbase/format.hh b/maxutils/maxbase/include/maxbase/format.hh index fed935b0a..f64443cd7 100644 --- a/maxutils/maxbase/include/maxbase/format.hh +++ b/maxutils/maxbase/include/maxbase/format.hh @@ -38,5 +38,4 @@ std::string to_binary_size(int64_t size); * @return The result string */ std::string string_printf(const char* format, ...) mxb_attribute((format (printf, 1, 2))); - } diff --git a/maxutils/maxbase/include/maxbase/host.hh b/maxutils/maxbase/include/maxbase/host.hh index 9c5d1406d..ebba9bda1 100644 --- a/maxutils/maxbase/include/maxbase/host.hh +++ b/maxutils/maxbase/include/maxbase/host.hh @@ -117,5 +117,4 @@ inline bool operator!=(const Host& l, const Host& r) * @return True on success */ bool reverse_dns(const std::string& ip, std::string* output); - } diff --git a/maxutils/maxbase/include/maxbase/http.hh b/maxutils/maxbase/include/maxbase/http.hh index dba9797f3..611338dea 100644 --- a/maxutils/maxbase/include/maxbase/http.hh +++ b/maxutils/maxbase/include/maxbase/http.hh @@ -57,28 +57,28 @@ public: enum { - DEFAULT_CONNECT_TIMEOUT = 10, // @see https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html - DEFAULT_TIMEOUT = 10 // @see https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html + DEFAULT_CONNECT_TIMEOUT = 10, // @see https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html + DEFAULT_TIMEOUT = 10 // @see https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html }; struct Config { int connect_timeout_s = DEFAULT_CONNECT_TIMEOUT; - int timeout_s = DEFAULT_TIMEOUT; + int timeout_s = DEFAULT_TIMEOUT; }; struct Result { enum { - ERROR = -1, // Some non-specific error occurred. - COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved. - OPERATION_TIMEDOUT = -3 // The operation timed out. + ERROR = -1, // Some non-specific error occurred. + COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved. + OPERATION_TIMEDOUT = -3 // The operation timed out. }; - int code = 0; // HTTP response code - std::string body; // Response body - std::map headers; // Headers attached to the response + int code = 0;// HTTP response code + std::string body; // Response body + std::map headers; // Headers attached to the response }; /** @@ -156,9 +156,9 @@ class Async public: enum status_t { - READY, // The result is ready. - ERROR, // The operation has failed. - PENDING // The operation is pending. + READY, // The result is ready. + ERROR, // The operation has failed. + PENDING // The operation is pending. }; class Imp @@ -197,7 +197,7 @@ public: * * @return *this. */ - Async& operator = (const Async& rhs) + Async& operator=(const Async& rhs) { std::shared_ptr sImp(rhs.m_sImp); m_sImp.swap(sImp); @@ -307,7 +307,5 @@ Async get_async(const std::vector& urls, Async get_async(const std::vector& urls, const std::string& user, const std::string& password, const Config& config = Config()); - } - } diff --git a/maxutils/maxbase/include/maxbase/iterator.hh b/maxutils/maxbase/include/maxbase/iterator.hh index 6c7bdc468..e0bbc1887 100644 --- a/maxutils/maxbase/include/maxbase/iterator.hh +++ b/maxutils/maxbase/include/maxbase/iterator.hh @@ -51,17 +51,17 @@ public: return prev; } - bool operator == (const intrusive_slist_iterator& rhs) const + bool operator==(const intrusive_slist_iterator& rhs) const { return m_pT == rhs.m_pT; } - bool operator != (const intrusive_slist_iterator& rhs) const + bool operator!=(const intrusive_slist_iterator& rhs) const { return !(m_pT == rhs.m_pT); } - T& operator * () const + T& operator*() const { mxb_assert(m_pT); return *m_pT; @@ -70,5 +70,4 @@ public: private: T* m_pT; }; - } diff --git a/maxutils/maxbase/include/maxbase/pam_utils.hh b/maxutils/maxbase/include/maxbase/pam_utils.hh index 9b007a3fb..f6400f4ee 100644 --- a/maxutils/maxbase/include/maxbase/pam_utils.hh +++ b/maxutils/maxbase/include/maxbase/pam_utils.hh @@ -17,32 +17,32 @@ namespace maxbase { - class PamResult +class PamResult +{ +public: + enum class Result { - public: - enum class Result - { - SUCCESS, - WRONG_USER_PW, /**< Username or password was wrong */ - ACCOUNT_INVALID, /**< pam_acct_mgmt returned error */ - MISC_ERROR /**< Miscellaneous error */ - }; - - Result type {Result::MISC_ERROR}; - std::string error; + SUCCESS, + WRONG_USER_PW, /**< Username or password was wrong */ + ACCOUNT_INVALID, /**< pam_acct_mgmt returned error */ + MISC_ERROR /**< Miscellaneous error */ }; - /** - * Check if the user & password can log into the given PAM service. This function will block until the - * operation completes. - * - * @param user Username - * @param password Password - * @param service Which PAM service is the user logging to - * @param expected_msg The first expected message from the PAM authentication system. - * Typically "Password: ", which is also the default value. If set to empty, the message is not checked. - * @return A result struct with the result and an error message. - */ - PamResult pam_authenticate(const std::string& user, const std::string& password, - const std::string& service, const std::string& expected_msg = "Password: "); + Result type {Result::MISC_ERROR}; + std::string error; +}; + +/** + * Check if the user & password can log into the given PAM service. This function will block until the + * operation completes. + * + * @param user Username + * @param password Password + * @param service Which PAM service is the user logging to + * @param expected_msg The first expected message from the PAM authentication system. + * Typically "Password: ", which is also the default value. If set to empty, the message is not checked. + * @return A result struct with the result and an error message. + */ +PamResult pam_authenticate(const std::string& user, const std::string& password, + const std::string& service, const std::string& expected_msg = "Password: "); } diff --git a/maxutils/maxbase/include/maxbase/semaphore.hh b/maxutils/maxbase/include/maxbase/semaphore.hh index 3b3bfcc6c..01cfb9176 100644 --- a/maxutils/maxbase/include/maxbase/semaphore.hh +++ b/maxutils/maxbase/include/maxbase/semaphore.hh @@ -285,7 +285,7 @@ public: * and in the latter `EINTR. */ bool timedwait(time_t seconds, - long nseconds, + long nseconds, signal_approach_t signal_approach = IGNORE_SIGNALS) const { timespec ts; @@ -316,7 +316,7 @@ public: */ size_t timedwait_n(size_t n_wait, time_t seconds, - long nseconds, + long nseconds, signal_approach_t signal_approach = IGNORE_SIGNALS) const { timespec ts; diff --git a/maxutils/maxbase/include/maxbase/worker.hh b/maxutils/maxbase/include/maxbase/worker.hh index 6ea3142de..871f51581 100644 --- a/maxutils/maxbase/include/maxbase/worker.hh +++ b/maxutils/maxbase/include/maxbase/worker.hh @@ -42,15 +42,15 @@ struct WORKER_STATISTICS N_QUEUE_TIMES = 30 }; - int64_t n_read = 0; /*< Number of read events */ - int64_t n_write = 0; /*< Number of write events */ - int64_t n_error = 0; /*< Number of error events */ - int64_t n_hup = 0; /*< Number of hangup events */ - int64_t n_accept = 0; /*< Number of accept events */ - int64_t n_polls = 0; /*< Number of poll cycles */ - int64_t n_pollev = 0; /*< Number of polls returning events */ - int64_t evq_avg = 0; /*< Average event queue length */ - int64_t evq_max = 0; /*< Maximum event queue length */ + int64_t n_read = 0; /*< Number of read events */ + int64_t n_write = 0; /*< Number of write events */ + int64_t n_error = 0; /*< Number of error events */ + int64_t n_hup = 0; /*< Number of hangup events */ + int64_t n_accept = 0; /*< Number of accept events */ + int64_t n_polls = 0; /*< Number of poll cycles */ + int64_t n_pollev = 0; /*< Number of polls returning events */ + int64_t evq_avg = 0; /*< Average event queue length */ + int64_t evq_max = 0; /*< Maximum event queue length */ int64_t maxqtime = 0; int64_t maxexectime = 0; std::array n_fds {}; /*< Number of wakeups with particular n_fds value */ @@ -249,12 +249,12 @@ class Worker : public MXB_WORKER Worker& operator=(const Worker&) = delete; public: - using STATISTICS = WORKER_STATISTICS; - using Task = WorkerTask; + using STATISTICS = WORKER_STATISTICS; + using Task = WorkerTask; using DisposableTask = WorkerDisposableTask; - using Load = WorkerLoad; - using Timer = WorkerTimer; - using RandomEngine = maxbase::XorShiftRandom; + using Load = WorkerLoad; + using Timer = WorkerTimer; + using RandomEngine = maxbase::XorShiftRandom; /** * A delegating timer that delegates the timer tick handling diff --git a/maxutils/maxbase/src/eventcount.cc b/maxutils/maxbase/src/eventcount.cc index 73a05f0c2..9925bd679 100644 --- a/maxutils/maxbase/src/eventcount.cc +++ b/maxutils/maxbase/src/eventcount.cc @@ -55,7 +55,8 @@ namespace struct TimePointLessEqual { TimePoint lhs; - TimePointLessEqual(TimePoint tp) : lhs(tp) + TimePointLessEqual(TimePoint tp) + : lhs(tp) { } bool operator()(const EventCount::Timestamp& rhs) const @@ -134,7 +135,8 @@ namespace struct MatchEventId { std::string event_id; - MatchEventId(const std::string& id) : event_id(id) + MatchEventId(const std::string& id) + : event_id(id) { } bool operator()(const EventCount& stats) const diff --git a/maxutils/maxbase/src/format.cc b/maxutils/maxbase/src/format.cc index 4313aeddf..54be0ee8c 100644 --- a/maxutils/maxbase/src/format.cc +++ b/maxutils/maxbase/src/format.cc @@ -95,5 +95,4 @@ std::string string_printf(const char* format, ...) } return rval; } - } diff --git a/maxutils/maxbase/src/host.cc b/maxutils/maxbase/src/host.cc index 143947bcd..f3cefbe99 100644 --- a/maxutils/maxbase/src/host.cc +++ b/maxutils/maxbase/src/host.cc @@ -271,5 +271,4 @@ bool reverse_dns(const std::string& ip, std::string* output) } return success; } - } diff --git a/maxutils/maxbase/src/http.cc b/maxutils/maxbase/src/http.cc index 26ddbc7bf..ce0d01467 100644 --- a/maxutils/maxbase/src/http.cc +++ b/maxutils/maxbase/src/http.cc @@ -117,7 +117,7 @@ size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata) CURL* get_easy_curl(const std::string& url, const std::string& user, const std::string& password, const Config& config, - Result *pRes, + Result* pRes, char* pErrbuf) { CURL* pCurl = curl_easy_init(); @@ -126,8 +126,10 @@ CURL* get_easy_curl(const std::string& url, if (pCurl) { checked_curl_setopt(pCurl, CURLOPT_NOSIGNAL, 1); - checked_curl_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, config.connect_timeout_s);// For connection phase - checked_curl_setopt(pCurl, CURLOPT_TIMEOUT, config.timeout_s); // For data transfer phase + checked_curl_setopt(pCurl, CURLOPT_CONNECTTIMEOUT, config.connect_timeout_s); // For connection + // phase + checked_curl_setopt(pCurl, CURLOPT_TIMEOUT, config.timeout_s); // For data transfer + // phase checked_curl_setopt(pCurl, CURLOPT_ERRORBUFFER, pErrbuf); checked_curl_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_callback); checked_curl_setopt(pCurl, CURLOPT_WRITEDATA, &pRes->body); @@ -169,7 +171,7 @@ struct Context } mxb::http::Result* pResult; - Errbuf * pErrbuf; + Errbuf* pErrbuf; }; class ReadyImp : public Async::Imp @@ -228,7 +230,7 @@ public: for (auto& item : m_curls) { CURL* pCurl = item.first; - MXB_AT_DEBUG(CURLMcode rv =) curl_multi_remove_handle(m_pCurlm, pCurl); + MXB_AT_DEBUG(CURLMcode rv = ) curl_multi_remove_handle(m_pCurlm, pCurl); mxb_assert(rv == CURLM_OK); curl_easy_cleanup(pCurl); } @@ -440,7 +442,6 @@ private: int m_still_running; long m_wait_no_more_than; }; - } @@ -546,7 +547,7 @@ Result get(const std::string& url, const std::string& user, const std::string& p { case CURLE_OK: { - long code = 0; // needs to be a long + long code = 0; // needs to be a long curl_easy_getinfo(pCurl, CURLINFO_RESPONSE_CODE, &code); res.code = code; } @@ -614,7 +615,5 @@ const char* to_string(Async::status_t status) mxb_assert(!true); return "Unknown"; } - } - } diff --git a/maxutils/maxbase/src/pam_utils.cc b/maxutils/maxbase/src/pam_utils.cc index 48f3d0681..2a93abea4 100644 --- a/maxutils/maxbase/src/pam_utils.cc +++ b/maxutils/maxbase/src/pam_utils.cc @@ -32,7 +32,7 @@ class ConversationData public: string m_client; string m_password; - int m_counter {0}; + int m_counter {0}; string m_expected_msg; ConversationData(const string& client, const string& password, const string& expected_msg) @@ -97,7 +97,6 @@ int conversation_func(int num_msg, } return rval; } - } namespace maxbase @@ -123,25 +122,25 @@ PamResult pam_authenticate(const string& user, const string& password, const str pam_status = pam_authenticate(pam_handle, 0); switch (pam_status) { - case PAM_SUCCESS: - authenticated = true; - MXB_DEBUG("pam_authenticate returned success."); - break; + case PAM_SUCCESS: + authenticated = true; + MXB_DEBUG("pam_authenticate returned success."); + break; - case PAM_USER_UNKNOWN: - case PAM_AUTH_ERR: - // Normal failure, username or password was wrong. - result.type = PamResult::Result::WRONG_USER_PW; - result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), - pam_strerror(pam_handle, pam_status)); - break; + case PAM_USER_UNKNOWN: + case PAM_AUTH_ERR: + // Normal failure, username or password was wrong. + result.type = PamResult::Result::WRONG_USER_PW; + result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), + pam_strerror(pam_handle, pam_status)); + break; - default: - // More exotic error - result.type = PamResult::Result::MISC_ERROR; - result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), - pam_strerror(pam_handle, pam_status)); - break; + default: + // More exotic error + result.type = PamResult::Result::MISC_ERROR; + result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), + pam_strerror(pam_handle, pam_status)); + break; } } else @@ -156,20 +155,19 @@ PamResult pam_authenticate(const string& user, const string& password, const str pam_status = pam_acct_mgmt(pam_handle, 0); switch (pam_status) { - case PAM_SUCCESS: - result.type = PamResult::Result::SUCCESS; - break; + case PAM_SUCCESS: + result.type = PamResult::Result::SUCCESS; + break; - default: - // Credentials have already been checked to be ok, so this is a somewhat unexpected error. - result.type = PamResult::Result::ACCOUNT_INVALID; - result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(), - pam_strerror(pam_handle, pam_status)); - break; + default: + // Credentials have already been checked to be ok, so this is a somewhat unexpected error. + result.type = PamResult::Result::ACCOUNT_INVALID; + result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(), + pam_strerror(pam_handle, pam_status)); + break; } } pam_end(pam_handle, pam_status); return result; } - } diff --git a/maxutils/maxbase/src/semaphore.cc b/maxutils/maxbase/src/semaphore.cc index 95c15b74e..5d254caf1 100644 --- a/maxutils/maxbase/src/semaphore.cc +++ b/maxutils/maxbase/src/semaphore.cc @@ -19,7 +19,7 @@ namespace maxbase // static void Semaphore::get_current_timespec(time_t seconds, - long nseconds, + long nseconds, timespec* pTs) { mxb_assert(nseconds <= 999999999); diff --git a/maxutils/maxbase/src/string.cc b/maxutils/maxbase/src/string.cc index f1dbc3cfb..a36bcd038 100644 --- a/maxutils/maxbase/src/string.cc +++ b/maxutils/maxbase/src/string.cc @@ -19,7 +19,6 @@ namespace { thread_local char errbuf[512]; // Enough for all errors - } const char* mxb_strerror(int error) @@ -73,5 +72,4 @@ char* trim(char* str) { return ltrim(rtrim(str)); } - } diff --git a/maxutils/maxbase/src/test/test_http.cc b/maxutils/maxbase/src/test/test_http.cc index 0e16f9196..9070845d2 100644 --- a/maxutils/maxbase/src/test/test_http.cc +++ b/maxutils/maxbase/src/test/test_http.cc @@ -103,8 +103,8 @@ int test_multi_http() { cout << __func__ << endl; - vector urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" }; - vector expected_successes = { true, true, false }; + vector urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"}; + vector expected_successes = {true, true, false}; vector results = mxb::http::get(urls); int rv = check_results(urls, expected_successes, results); @@ -118,8 +118,8 @@ int test_async_http() int rv = EXIT_FAILURE; - vector urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" }; - vector expected_successes = { true, true, false }; + vector urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"}; + vector expected_successes = {true, true, false}; mxb::http::Async http = mxb::http::get_async(urls); while (http.perform(0) == mxb::http::Async::PENDING) @@ -148,7 +148,6 @@ int test_async_http() return rv == EXIT_FAILURE ? 1 : 0; } - } uint64_t time_since_epoch_ms() diff --git a/maxutils/maxbase/src/test/test_string.cc b/maxutils/maxbase/src/test/test_string.cc index a753106cf..098b0e429 100644 --- a/maxutils/maxbase/src/test/test_string.cc +++ b/maxutils/maxbase/src/test/test_string.cc @@ -116,7 +116,6 @@ int test_rtrim() cout << "rtrim()" << endl; return test(rtrim_testcases, n_rtrim_testcases, mxb::rtrim); } - } int main(int argc, char* argv[]) diff --git a/maxutils/maxbase/src/worker.cc b/maxutils/maxbase/src/worker.cc index b1546fd12..71b0b4eb4 100644 --- a/maxutils/maxbase/src/worker.cc +++ b/maxutils/maxbase/src/worker.cc @@ -111,7 +111,7 @@ uint64_t WorkerLoad::get_time_ms() int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t); if (rv != 0) { - mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported. + mxb_assert(errno == EINVAL); // CLOCK_MONOTONIC_COARSE not supported. rv = clock_gettime(CLOCK_MONOTONIC, &t); mxb_assert(rv == 0); } diff --git a/maxutils/maxsql/src/mariadb.cc b/maxutils/maxsql/src/mariadb.cc index 8e0c6237f..e3bd86e56 100644 --- a/maxutils/maxsql/src/mariadb.cc +++ b/maxutils/maxsql/src/mariadb.cc @@ -117,7 +117,7 @@ bool QueryResult::next_row() if (m_rowdata) { m_current_row_ind++; - m_error = ConversionError(); // Reset error + m_error = ConversionError(); // Reset error return true; } else @@ -333,5 +333,4 @@ bool QueryResult::ConversionError::error() const { return !m_target_type.empty(); } - } diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index 330c9ac31..3c7a7374b 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -2361,7 +2361,7 @@ static void add_field_info(parsing_info_t* info, } static void add_field_info(parsing_info_t* info, - st_select_lex* select, + st_select_lex* select, const char* database, const char* table, const char* column, @@ -2575,7 +2575,7 @@ static QC_FUNCTION_INFO* get_function_info(parsing_info_t* info, const char* nam } static QC_FUNCTION_INFO* add_function_info(parsing_info_t* info, - st_select_lex* select, + st_select_lex* select, const char* name, Item** items, int n_items) @@ -2630,7 +2630,7 @@ static QC_FUNCTION_INFO* add_function_info(parsing_info_t* info, } static void add_field_info(parsing_info_t* pi, - st_select_lex* select, + st_select_lex* select, Item_field* item, List* excludep) { @@ -2727,7 +2727,7 @@ static void add_field_info(parsing_info_t* pi, } static void add_field_info(parsing_info_t* pi, - st_select_lex* select, + st_select_lex* select, Item* item, List* excludep) { @@ -2822,7 +2822,7 @@ static bool should_function_be_ignored(parsing_info_t* pi, const char* func_name } static void update_field_infos(parsing_info_t* pi, - st_select_lex* select, + st_select_lex* select, collect_source_t source, Item* item, List* excludep) @@ -2914,7 +2914,7 @@ static void update_field_infos(parsing_info_t* pi, char func_name[strlen(f) + 3 + 1]; // strlen(substring) - strlen(substr) from below. strcpy(func_name, f); - mxb::trim(func_name); // Sometimes the embedded parser leaves leading and trailing whitespace. + mxb::trim(func_name); // Sometimes the embedded parser leaves leading and trailing whitespace. // Non native functions are surrounded by back-ticks, let's remove them. remove_surrounding_back_ticks(func_name); @@ -3603,57 +3603,57 @@ int32_t qc_mysql_set_options(uint32_t options) extern "C" { - MXS_MODULE* MXS_CREATE_MODULE() +MXS_MODULE* MXS_CREATE_MODULE() +{ + static QUERY_CLASSIFIER qc = { - static QUERY_CLASSIFIER qc = - { - qc_mysql_setup, - qc_mysql_process_init, - qc_mysql_process_end, - qc_mysql_thread_init, - qc_mysql_thread_end, - qc_mysql_parse, - qc_mysql_get_type_mask, - qc_mysql_get_operation, - qc_mysql_get_created_table_name, - qc_mysql_is_drop_table_query, - qc_mysql_get_table_names, - NULL, - qc_mysql_query_has_clause, - qc_mysql_get_database_names, - qc_mysql_get_prepare_name, - qc_mysql_get_field_info, - qc_mysql_get_function_info, - qc_mysql_get_preparable_stmt, - qc_mysql_set_server_version, - qc_mysql_get_server_version, - qc_mysql_get_sql_mode, - qc_mysql_set_sql_mode, - nullptr, // qc_info_dup not supported. - nullptr, // qc_info_close not supported. - qc_mysql_get_options, - qc_mysql_set_options, - nullptr, // qc_get_result_from_info not supported - }; + qc_mysql_setup, + qc_mysql_process_init, + qc_mysql_process_end, + qc_mysql_thread_init, + qc_mysql_thread_end, + qc_mysql_parse, + qc_mysql_get_type_mask, + qc_mysql_get_operation, + qc_mysql_get_created_table_name, + qc_mysql_is_drop_table_query, + qc_mysql_get_table_names, + NULL, + qc_mysql_query_has_clause, + qc_mysql_get_database_names, + qc_mysql_get_prepare_name, + qc_mysql_get_field_info, + qc_mysql_get_function_info, + qc_mysql_get_preparable_stmt, + qc_mysql_set_server_version, + qc_mysql_get_server_version, + qc_mysql_get_sql_mode, + qc_mysql_set_sql_mode, + nullptr, // qc_info_dup not supported. + nullptr, // qc_info_close not supported. + qc_mysql_get_options, + qc_mysql_set_options, + nullptr, // qc_get_result_from_info not supported + }; - static MXS_MODULE info = + static MXS_MODULE info = + { + MXS_MODULE_API_QUERY_CLASSIFIER, + MXS_MODULE_GA, + MXS_QUERY_CLASSIFIER_VERSION, + "Query classifier based upon MySQL Embedded", + "V1.0.0", + MXS_NO_MODULE_CAPABILITIES, + &qc, + qc_mysql_process_init, + qc_mysql_process_end, + qc_mysql_thread_init, + qc_mysql_thread_end, { - MXS_MODULE_API_QUERY_CLASSIFIER, - MXS_MODULE_GA, - MXS_QUERY_CLASSIFIER_VERSION, - "Query classifier based upon MySQL Embedded", - "V1.0.0", - MXS_NO_MODULE_CAPABILITIES, - &qc, - qc_mysql_process_init, - qc_mysql_process_end, - qc_mysql_thread_init, - qc_mysql_thread_end, - { - {MXS_END_MODULE_PARAMS} - } - }; + {MXS_END_MODULE_PARAMS} + } + }; - return &info; - } + return &info; +} } diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index 8e9f2924d..d3b14b93f 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -192,45 +192,45 @@ static const char* get_token_symbol(int token); extern "C" { - extern void exposed_sqlite3ExprDelete(sqlite3* db, Expr* pExpr); - extern void exposed_sqlite3ExprListDelete(sqlite3* db, ExprList* pList); - extern void exposed_sqlite3IdListDelete(sqlite3* db, IdList* pList); - extern void exposed_sqlite3SrcListDelete(sqlite3* db, SrcList* pList); - extern void exposed_sqlite3SelectDelete(sqlite3* db, Select* p); +extern void exposed_sqlite3ExprDelete(sqlite3* db, Expr* pExpr); +extern void exposed_sqlite3ExprListDelete(sqlite3* db, ExprList* pList); +extern void exposed_sqlite3IdListDelete(sqlite3* db, IdList* pList); +extern void exposed_sqlite3SrcListDelete(sqlite3* db, SrcList* pList); +extern void exposed_sqlite3SelectDelete(sqlite3* db, Select* p); - extern void exposed_sqlite3BeginTrigger(Parse* pParse, - Token* pName1, - Token* pName2, - int tr_tm, - int op, - IdList* pColumns, - SrcList* pTableName, - Expr* pWhen, - int isTemp, - int noErr); - extern void exposed_sqlite3FinishTrigger(Parse* pParse, - TriggerStep* pStepList, - Token* pAll); - extern int exposed_sqlite3Dequote(char* z); - extern int exposed_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*); - extern void exposed_sqlite3Insert(Parse* pParse, - SrcList* pTabList, - Select* pSelect, - IdList* pColumns, - int onError); - extern int exposed_sqlite3Select(Parse* pParse, Select* p, SelectDest* pDest); - extern void exposed_sqlite3StartTable(Parse* pParse,/* Parser context */ - Token* pName1,/* First part of the name of the table or view */ - Token* pName2,/* Second part of the name of the table or view */ - int isTemp, /* True if this is a TEMP table */ - int isView, /* True if this is a VIEW */ - int isVirtual,/* True if this is a VIRTUAL table */ - int noErr); /* Do nothing if table already exists */ - extern void exposed_sqlite3Update(Parse* pParse, - SrcList* pTabList, - ExprList* pChanges, - Expr* pWhere, - int onError); +extern void exposed_sqlite3BeginTrigger(Parse* pParse, + Token* pName1, + Token* pName2, + int tr_tm, + int op, + IdList* pColumns, + SrcList* pTableName, + Expr* pWhen, + int isTemp, + int noErr); +extern void exposed_sqlite3FinishTrigger(Parse* pParse, + TriggerStep* pStepList, + Token* pAll); +extern int exposed_sqlite3Dequote(char* z); +extern int exposed_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*); +extern void exposed_sqlite3Insert(Parse* pParse, + SrcList* pTabList, + Select* pSelect, + IdList* pColumns, + int onError); +extern int exposed_sqlite3Select(Parse* pParse, Select* p, SelectDest* pDest); +extern void exposed_sqlite3StartTable(Parse* pParse, /* Parser context */ + Token* pName1, /* First part of the name of the table or view */ + Token* pName2, /* Second part of the name of the table or view */ + int isTemp, /* True if this is a TEMP table */ + int isView, /* True if this is a VIEW */ + int isVirtual, /* True if this is a VIRTUAL table */ + int noErr); /* Do nothing if table already exists */ +extern void exposed_sqlite3Update(Parse* pParse, + SrcList* pTabList, + ExprList* pChanges, + Expr* pWhere, + int onError); } /** @@ -843,7 +843,7 @@ public: update_field_infos_from_expr(pAliases, context, pExpr, pExclude); break; - case TK_STRING: // select "a" ..., for @@sql_mode containing 'ANSI_QUOTES' + case TK_STRING: // select "a" ..., for @@sql_mode containing 'ANSI_QUOTES' if (this_thread.options & QC_OPTION_STRING_AS_FIELD) { const char* zColumn = pExpr->u.zToken; @@ -1268,7 +1268,10 @@ public: if (pSrc->a[i].pSelect) { - update_field_infos_from_select(aliases, context | QC_FIELD_SUBQUERY, pSrc->a[i].pSelect, pExclude); + update_field_infos_from_select(aliases, + context | QC_FIELD_SUBQUERY, + pSrc->a[i].pSelect, + pExclude); } #ifdef QC_COLLECT_NAMES_FROM_USING @@ -1460,8 +1463,8 @@ public: } static void update_function_fields(const QcAliases* pAliases, - const ExprList* pEList, - const ExprList* pExclude, + const ExprList* pEList, + const ExprList* pExclude, vector& fields) { for (int i = 0; i < pEList->nExpr; ++i) @@ -1613,16 +1616,18 @@ public: } } - void mxs_sqlite3BeginTrigger(Parse* pParse, /* The parse context of the CREATE TRIGGER statement */ - Token* pName1, /* The name of the trigger */ - Token* pName2, /* The name of the trigger */ - int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ - int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ - IdList* pColumns, /* column list if this is an UPDATE OF trigger */ - SrcList* pTableName, /* The name of the table/view the trigger applies to */ - Expr* pWhen, /* WHEN clause */ - int isTemp, /* True if the TEMPORARY keyword is present */ - int noErr) /* Suppress errors if the trigger already exists */ + void mxs_sqlite3BeginTrigger(Parse* pParse, /* The parse context of the CREATE TRIGGER statement + * */ + Token* pName1, /* The name of the trigger */ + Token* pName2, /* The name of the trigger */ + int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ + int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ + IdList* pColumns, /* column list if this is an UPDATE OF trigger */ + SrcList* pTableName, /* The name of the table/view the trigger applies to + * */ + Expr* pWhen, /* WHEN clause */ + int isTemp, /* True if the TEMPORARY keyword is present */ + int noErr) /* Suppress errors if the trigger already exists */ { mxb_assert(this_thread.initialized); @@ -1670,7 +1675,7 @@ public: ExprList* pList, /* A list of columns to be indexed */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ Token* pStart, /* The CREATE token that begins this statement */ - Expr* pPIWhere, /* WHERE clause for partial indices */ + Expr* pPIWhere, /* WHERE clause for partial indices */ int sortOrder, /* Sort order of primary key when pList==NULL */ int ifNotExist) /* Omit error if index already exists */ { @@ -1699,7 +1704,7 @@ public: Token* pName1, /* The token that holds the name of the view */ Token* pName2, /* The token that holds the name of the view */ ExprList* pCNames, /* Optional list of view column names */ - Select* pSelect, /* A SELECT statement that will become the new view */ + Select* pSelect, /* A SELECT statement that will become the new view */ int isTemp, /* TRUE for a TEMPORARY view */ int noErr) /* Suppress error messages if VIEW already exists */ { @@ -1868,8 +1873,8 @@ public: void mxs_sqlite3Insert(Parse* pParse, SrcList* pTabList, - Select* pSelect, - IdList* pColumns, + Select* pSelect, + IdList* pColumns, int onError, ExprList* pSet) { @@ -2109,7 +2114,7 @@ public: void maxscaleAlterTable(Parse* pParse, /* Parser context. */ mxs_alter_t command, SrcList* pSrc, /* The table to rename. */ - Token* pName) /* The new table name (RENAME). */ + Token* pName) /* The new table name (RENAME). */ { mxb_assert(this_thread.initialized); @@ -3431,78 +3436,78 @@ public: extern "C" { - extern void mxs_sqlite3AlterFinishAddColumn(Parse*, Token*); - extern void mxs_sqlite3AlterBeginAddColumn(Parse*, SrcList*); - extern void mxs_sqlite3Analyze(Parse*, SrcList*); - extern void mxs_sqlite3BeginTransaction(Parse*, int token, int type); - extern void mxs_sqlite3CommitTransaction(Parse*); - extern void mxs_sqlite3CreateIndex(Parse*, - Token*, - Token*, - SrcList*, - ExprList*, - int, - Token*, - Expr*, - int, - int); - extern void mxs_sqlite3BeginTrigger(Parse*, - Token*, - Token*, - int, - int, - IdList*, - SrcList*, - Expr*, - int, - int); - extern void mxs_sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); - extern void mxs_sqlite3CreateView(Parse*, Token*, Token*, Token*, ExprList*, Select*, int, int); - extern void mxs_sqlite3DeleteFrom(Parse* pParse, SrcList* pTabList, Expr* pWhere, SrcList* pUsing); - extern void mxs_sqlite3DropIndex(Parse*, SrcList*, SrcList*, int); - extern void mxs_sqlite3DropTable(Parse*, SrcList*, int, int, int); - extern void mxs_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*, SrcList*); - extern void mxs_sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, ExprList*); - extern void mxs_sqlite3RollbackTransaction(Parse*); - extern void mxs_sqlite3Savepoint(Parse* pParse, int op, Token* pName); - extern int mxs_sqlite3Select(Parse*, Select*, SelectDest*); - extern void mxs_sqlite3StartTable(Parse*, Token*, Token*, int, int, int, int); - extern void mxs_sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); +extern void mxs_sqlite3AlterFinishAddColumn(Parse*, Token*); +extern void mxs_sqlite3AlterBeginAddColumn(Parse*, SrcList*); +extern void mxs_sqlite3Analyze(Parse*, SrcList*); +extern void mxs_sqlite3BeginTransaction(Parse*, int token, int type); +extern void mxs_sqlite3CommitTransaction(Parse*); +extern void mxs_sqlite3CreateIndex(Parse*, + Token*, + Token*, + SrcList*, + ExprList*, + int, + Token*, + Expr*, + int, + int); +extern void mxs_sqlite3BeginTrigger(Parse*, + Token*, + Token*, + int, + int, + IdList*, + SrcList*, + Expr*, + int, + int); +extern void mxs_sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); +extern void mxs_sqlite3CreateView(Parse*, Token*, Token*, Token*, ExprList*, Select*, int, int); +extern void mxs_sqlite3DeleteFrom(Parse* pParse, SrcList* pTabList, Expr* pWhere, SrcList* pUsing); +extern void mxs_sqlite3DropIndex(Parse*, SrcList*, SrcList*, int); +extern void mxs_sqlite3DropTable(Parse*, SrcList*, int, int, int); +extern void mxs_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*, SrcList*); +extern void mxs_sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, ExprList*); +extern void mxs_sqlite3RollbackTransaction(Parse*); +extern void mxs_sqlite3Savepoint(Parse* pParse, int op, Token* pName); +extern int mxs_sqlite3Select(Parse*, Select*, SelectDest*); +extern void mxs_sqlite3StartTable(Parse*, Token*, Token*, int, int, int, int); +extern void mxs_sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); - extern void maxscaleCollectInfoFromSelect(Parse*, Select*, int); +extern void maxscaleCollectInfoFromSelect(Parse*, Select*, int); - extern void maxscaleAlterTable(Parse*, mxs_alter_t command, SrcList*, Token*); - extern void maxscaleCall(Parse*, SrcList* pName, ExprList* pExprList); - extern void maxscaleCheckTable(Parse*, SrcList* pTables); - extern void maxscaleCreateSequence(Parse*, Token* pDatabase, Token* pTable); - extern void maxscaleDeclare(Parse* pParse); - extern void maxscaleDeallocate(Parse*, Token* pName); - extern void maxscaleDo(Parse*, ExprList* pEList); - extern void maxscaleDrop(Parse*, int what, Token* pDatabase, Token* pName); - extern void maxscaleExecute(Parse*, Token* pName, int type_mask); - extern void maxscaleExecuteImmediate(Parse*, Token* pName, ExprSpan* pExprSpan, int type_mask); - extern void maxscaleExplain(Parse*, Token* pNext); - extern void maxscaleFlush(Parse*, Token* pWhat); - extern void maxscaleHandler(Parse*, mxs_handler_t, SrcList* pFullName, Token* pName); - extern void maxscaleLoadData(Parse*, SrcList* pFullName, int local); - extern void maxscaleLock(Parse*, mxs_lock_t, SrcList*); - extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt); - extern void maxscalePrivileges(Parse*, int kind); - extern void maxscaleRenameTable(Parse*, SrcList* pTables); - extern void maxscaleReset(Parse*, int what); - extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*); - extern void maxscaleShow(Parse*, MxsShow* pShow); - extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName); - extern void maxscaleUse(Parse*, Token*); +extern void maxscaleAlterTable(Parse*, mxs_alter_t command, SrcList*, Token*); +extern void maxscaleCall(Parse*, SrcList* pName, ExprList* pExprList); +extern void maxscaleCheckTable(Parse*, SrcList* pTables); +extern void maxscaleCreateSequence(Parse*, Token* pDatabase, Token* pTable); +extern void maxscaleDeclare(Parse* pParse); +extern void maxscaleDeallocate(Parse*, Token* pName); +extern void maxscaleDo(Parse*, ExprList* pEList); +extern void maxscaleDrop(Parse*, int what, Token* pDatabase, Token* pName); +extern void maxscaleExecute(Parse*, Token* pName, int type_mask); +extern void maxscaleExecuteImmediate(Parse*, Token* pName, ExprSpan* pExprSpan, int type_mask); +extern void maxscaleExplain(Parse*, Token* pNext); +extern void maxscaleFlush(Parse*, Token* pWhat); +extern void maxscaleHandler(Parse*, mxs_handler_t, SrcList* pFullName, Token* pName); +extern void maxscaleLoadData(Parse*, SrcList* pFullName, int local); +extern void maxscaleLock(Parse*, mxs_lock_t, SrcList*); +extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt); +extern void maxscalePrivileges(Parse*, int kind); +extern void maxscaleRenameTable(Parse*, SrcList* pTables); +extern void maxscaleReset(Parse*, int what); +extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*); +extern void maxscaleShow(Parse*, MxsShow* pShow); +extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName); +extern void maxscaleUse(Parse*, Token*); - extern void maxscale_update_function_info(const char* name, const Expr* pExpr); - // 'unsigned int' and not 'uint32_t' because 'uint32_t' is unknown in sqlite3 context. - extern void maxscale_set_type_mask(unsigned int type_mask); +extern void maxscale_update_function_info(const char* name, const Expr* pExpr); +// 'unsigned int' and not 'uint32_t' because 'uint32_t' is unknown in sqlite3 context. +extern void maxscale_set_type_mask(unsigned int type_mask); - extern int maxscaleComment(); - extern int maxscaleKeyword(int token); - extern void maxscaleSetStatusCap(int cap); - extern int maxscaleTranslateKeyword(int token); +extern int maxscaleComment(); +extern int maxscaleKeyword(int token); +extern void maxscaleSetStatusCap(int cap); +extern int maxscaleTranslateKeyword(int token); } /** @@ -4021,8 +4026,8 @@ void mxs_sqlite3BeginTrigger(Parse* pParse, /* The parse context of the IdList* pColumns, /* column list if this is an UPDATE OF trigger */ SrcList* pTableName, /* The name of the table/view the trigger applies to */ Expr* pWhen, /* WHEN clause */ - int isTemp, /* True if the TEMPORARY keyword is present */ - int noErr) /* Suppress errors if the trigger already exists */ + int isTemp, /* True if the TEMPORARY keyword is present */ + int noErr) /* Suppress errors if the trigger already exists */ { QC_TRACE(); @@ -4058,7 +4063,7 @@ void mxs_sqlite3CreateIndex(Parse* pParse, /* All information about this pa ExprList* pList, /* A list of columns to be indexed */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ Token* pStart, /* The CREATE token that begins this statement */ - Expr* pPIWhere, /* WHERE clause for partial indices */ + Expr* pPIWhere, /* WHERE clause for partial indices */ int sortOrder, /* Sort order of primary key when pList==NULL */ int ifNotExist) /* Omit error if index already exists */ { @@ -4084,7 +4089,7 @@ void mxs_sqlite3CreateView(Parse* pParse, /* The parsing context */ Token* pName1, /* The token that holds the name of the view */ Token* pName2, /* The token that holds the name of the view */ ExprList* pCNames, /* Optional list of view column names */ - Select* pSelect, /* A SELECT statement that will become the new view */ + Select* pSelect, /* A SELECT statement that will become the new view */ int isTemp, /* TRUE for a TEMPORARY view */ int noErr) /* Suppress error messages if VIEW already exists */ { @@ -4165,8 +4170,8 @@ void mxs_sqlite3FinishTrigger(Parse* pParse, /* Parser context */ void mxs_sqlite3Insert(Parse* pParse, SrcList* pTabList, - Select* pSelect, - IdList* pColumns, + Select* pSelect, + IdList* pColumns, int onError, ExprList* pSet) { @@ -4293,7 +4298,7 @@ void maxscaleCollectInfoFromSelect(Parse* pParse, Select* pSelect, int sub_selec void maxscaleAlterTable(Parse* pParse, /* Parser context. */ mxs_alter_t command, SrcList* pSrc, /* The table to rename. */ - Token* pName) /* The new table name (RENAME). */ + Token* pName) /* The new table name (RENAME). */ { QC_TRACE(); @@ -5323,57 +5328,57 @@ QC_STMT_RESULT qc_sqlite_get_result_from_info(const QC_STMT_INFO* pInfo) extern "C" { - MXS_MODULE* MXS_CREATE_MODULE() +MXS_MODULE* MXS_CREATE_MODULE() +{ + static QUERY_CLASSIFIER qc = { - static QUERY_CLASSIFIER qc = - { - qc_sqlite_setup, - qc_sqlite_process_init, - qc_sqlite_process_end, - qc_sqlite_thread_init, - qc_sqlite_thread_end, - qc_sqlite_parse, - qc_sqlite_get_type_mask, - qc_sqlite_get_operation, - qc_sqlite_get_created_table_name, - qc_sqlite_is_drop_table_query, - qc_sqlite_get_table_names, - NULL, - qc_sqlite_query_has_clause, - qc_sqlite_get_database_names, - qc_sqlite_get_prepare_name, - qc_sqlite_get_field_info, - qc_sqlite_get_function_info, - qc_sqlite_get_preparable_stmt, - qc_sqlite_set_server_version, - qc_sqlite_get_server_version, - qc_sqlite_get_sql_mode, - qc_sqlite_set_sql_mode, - qc_sqlite_info_dup, - qc_sqlite_info_close, - qc_sqlite_get_options, - qc_sqlite_set_options, - qc_sqlite_get_result_from_info, - }; + qc_sqlite_setup, + qc_sqlite_process_init, + qc_sqlite_process_end, + qc_sqlite_thread_init, + qc_sqlite_thread_end, + qc_sqlite_parse, + qc_sqlite_get_type_mask, + qc_sqlite_get_operation, + qc_sqlite_get_created_table_name, + qc_sqlite_is_drop_table_query, + qc_sqlite_get_table_names, + NULL, + qc_sqlite_query_has_clause, + qc_sqlite_get_database_names, + qc_sqlite_get_prepare_name, + qc_sqlite_get_field_info, + qc_sqlite_get_function_info, + qc_sqlite_get_preparable_stmt, + qc_sqlite_set_server_version, + qc_sqlite_get_server_version, + qc_sqlite_get_sql_mode, + qc_sqlite_set_sql_mode, + qc_sqlite_info_dup, + qc_sqlite_info_close, + qc_sqlite_get_options, + qc_sqlite_set_options, + qc_sqlite_get_result_from_info, + }; - static MXS_MODULE info = + static MXS_MODULE info = + { + MXS_MODULE_API_QUERY_CLASSIFIER, + MXS_MODULE_GA, + MXS_QUERY_CLASSIFIER_VERSION, + "Query classifier using sqlite.", + "V1.0.0", + MXS_NO_MODULE_CAPABILITIES, + &qc, + qc_sqlite_process_init, + qc_sqlite_process_end, + qc_sqlite_thread_init, + qc_sqlite_thread_end, { - MXS_MODULE_API_QUERY_CLASSIFIER, - MXS_MODULE_GA, - MXS_QUERY_CLASSIFIER_VERSION, - "Query classifier using sqlite.", - "V1.0.0", - MXS_NO_MODULE_CAPABILITIES, - &qc, - qc_sqlite_process_init, - qc_sqlite_process_end, - qc_sqlite_thread_init, - qc_sqlite_thread_end, - { - {MXS_END_MODULE_PARAMS} - } - }; + {MXS_END_MODULE_PARAMS} + } + }; - return &info; - } + return &info; +} } diff --git a/query_classifier/test/compare.cc b/query_classifier/test/compare.cc index 627b03478..5bea5f224 100644 --- a/query_classifier/test/compare.cc +++ b/query_classifier/test/compare.cc @@ -154,7 +154,7 @@ QUERY_CLASSIFIER* load_classifier(const char* name) { bool loaded = false; size_t len = strlen(name); - char libdir[len + 3 + 1]; // Extra for ../ + char libdir[len + 3 + 1]; // Extra for ../ sprintf(libdir, "../%s", name); @@ -204,8 +204,8 @@ void put_classifier(QUERY_CLASSIFIER* pClassifier) } bool get_classifiers(qc_sql_mode_t sql_mode, - const char* zName1, - const char* zArgs1, + const char* zName1, + const char* zArgs1, QUERY_CLASSIFIER** ppClassifier1, const char* zName2, const char* zArgs2, @@ -594,7 +594,7 @@ bool compare_get_table_names(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1, QUERY_CLASSIFIER* pClassifier2, GWBUF* pCopy2, - bool full) + bool full) { bool success = false; const char* HEADING; diff --git a/query_classifier/test/testreader.cc b/query_classifier/test/testreader.cc index faef9521f..59d0a1aa6 100644 --- a/query_classifier/test/testreader.cc +++ b/query_classifier/test/testreader.cc @@ -225,7 +225,7 @@ namespace maxscale { TestReader::TestReader(istream& in, - size_t line) + size_t line) : m_in(in) , m_line(line) , m_delimiter(";") diff --git a/query_classifier/test/version_sensitivity.cc b/query_classifier/test/version_sensitivity.cc index e1b366fe7..cddf03ee5 100644 --- a/query_classifier/test/version_sensitivity.cc +++ b/query_classifier/test/version_sensitivity.cc @@ -70,10 +70,9 @@ int test() string valid_json("SELECT Json_Array(56, 3.1416, 'My name is \"Foo\"', NULL)"); string invalid_json("SELECT Json_Foo(56, 3.1416, 'My name is \"Foo\"', NULL)"); - auto encode_version = [](const SERVER::Version& sv) -> uint64_t - { - return sv.major * 10000 + sv.minor * 100 + sv.patch; - }; + auto encode_version = [](const SERVER::Version& sv) -> uint64_t { + return sv.major * 10000 + sv.minor * 100 + sv.patch; + }; SERVER::Version sv; // pre-Json