Format rest of the sources

This commit is contained in:
Markus Mäkelä
2019-05-09 11:31:40 +03:00
parent fbd61967a7
commit de95fcc9d6
29 changed files with 384 additions and 388 deletions

View File

@ -50,12 +50,12 @@ bool maxavro_datablock_finalize(MAXAVRO_DATABLOCK* block);
/** Adding values to a datablock. The caller must ensure that the inserted /** 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 * values conform to the file schema and that the required amount of fields
* is added before finalizing the block. */ * is added before finalizing the block. */
bool maxavro_datablock_add_integer(MAXAVRO_DATABLOCK *file, uint64_t 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_string(MAXAVRO_DATABLOCK* file, const char* str);
bool maxavro_datablock_add_float(MAXAVRO_DATABLOCK *file, float val); bool maxavro_datablock_add_float(MAXAVRO_DATABLOCK* file, float val);
bool maxavro_datablock_add_double(MAXAVRO_DATABLOCK *file, double val); bool maxavro_datablock_add_double(MAXAVRO_DATABLOCK* file, double val);
bool maxavro_read_datablock_start(MAXAVRO_FILE *file); bool maxavro_read_datablock_start(MAXAVRO_FILE* file);
bool maxavro_verify_block(MAXAVRO_FILE *file); bool maxavro_verify_block(MAXAVRO_FILE* file);
const char* type_to_string(enum maxavro_value_type type); const char* type_to_string(enum maxavro_value_type type);
enum maxavro_value_type string_to_type(const char *str); enum maxavro_value_type string_to_type(const char* str);

View File

@ -26,7 +26,9 @@
* @param field_num Field index in the schema * @param field_num Field index in the schema
* @return JSON object or NULL if an error occurred * @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; json_t* value = NULL;
switch (type) switch (type)
@ -107,7 +109,7 @@ static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *fie
case MAXAVRO_TYPE_UNION: case MAXAVRO_TYPE_UNION:
{ {
json_t *arr = (json_t*)field->extra; json_t* arr = (json_t*)field->extra;
uint64_t val = 0; uint64_t val = 0;
if (maxavro_read_integer(file, &val) && val < json_array_size(arr)) 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++) 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) if (value)
{ {
json_object_set_new(object, file->schema->fields[i].name, value); json_object_set_new(object, file->schema->fields[i].name, value);

View File

@ -44,15 +44,15 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
MXS_FILTER_VERSION, MXS_FILTER_VERSION,
DESC, DESC,
"V1.0.0", "V1.0.0",
RCAP_TYPE_STMT_INPUT, // See getCapabilities() below RCAP_TYPE_STMT_INPUT, // See getCapabilities() below
&ExampleFilter::s_object, // This is defined in the MaxScale filter template &ExampleFilter::s_object, // This is defined in the MaxScale filter template
NULL, /* Process init. */ NULL, /* Process init. */
NULL, /* Process finish. */ NULL, /* Process finish. */
NULL, /* Thread init. */ NULL, /* Thread init. */
NULL, /* Thread finish. */ NULL, /* Thread finish. */
{ {
{"an_example_parameter", MXS_MODULE_PARAM_STRING, "a-default-value"}, {"an_example_parameter",MXS_MODULE_PARAM_STRING, "a-default-value"},
{CN_COUNT_GLOBALS, MXS_MODULE_PARAM_BOOL, "true"}, {CN_COUNT_GLOBALS, MXS_MODULE_PARAM_BOOL, "true" },
{MXS_END_MODULE_PARAMS} {MXS_END_MODULE_PARAMS}
} }
}; };

View File

@ -87,8 +87,8 @@ private:
ExampleFilter(const MXS_CONFIG_PARAMETER* pParams); ExampleFilter(const MXS_CONFIG_PARAMETER* pParams);
// The fields are specific to ExampleFilter. // The fields are specific to ExampleFilter.
std::atomic<int> m_total_queries {0}; /**< How many queries has this filter seen */ std::atomic<int> m_total_queries {0}; /**< How many queries has this filter seen */
std::atomic<int> m_total_replies {0}; /**< How many replies has this filter seen */ std::atomic<int> 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 */
}; };

View File

@ -70,9 +70,9 @@ private:
// Used in the create function // Used in the create function
ExampleFilterSession(MXS_SESSION* pSession, ExampleFilter& filter); 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 */ uint64_t m_session_id {0}; /**< Session id */
int m_queries {0}; /**< How many queries has this session seen */ int m_queries {0}; /**< How many queries has this session seen */
int m_replies {0}; /**< How many replies has this session seen */ int m_replies {0}; /**< How many replies has this session seen */
}; };

View File

@ -58,7 +58,8 @@ public:
{ {
TimePoint time_point; TimePoint time_point;
int count; int count;
Timestamp(TimePoint p, int c) : time_point(p) Timestamp(TimePoint p, int c)
: time_point(p)
, count(c) , count(c)
{ {
} }

View File

@ -38,5 +38,4 @@ std::string to_binary_size(int64_t size);
* @return The result string * @return The result string
*/ */
std::string string_printf(const char* format, ...) mxb_attribute((format (printf, 1, 2))); std::string string_printf(const char* format, ...) mxb_attribute((format (printf, 1, 2)));
} }

View File

@ -117,5 +117,4 @@ inline bool operator!=(const Host& l, const Host& r)
* @return True on success * @return True on success
*/ */
bool reverse_dns(const std::string& ip, std::string* output); bool reverse_dns(const std::string& ip, std::string* output);
} }

View File

@ -57,28 +57,28 @@ public:
enum enum
{ {
DEFAULT_CONNECT_TIMEOUT = 10, // @see https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.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 DEFAULT_TIMEOUT = 10 // @see https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
}; };
struct Config struct Config
{ {
int connect_timeout_s = DEFAULT_CONNECT_TIMEOUT; int connect_timeout_s = DEFAULT_CONNECT_TIMEOUT;
int timeout_s = DEFAULT_TIMEOUT; int timeout_s = DEFAULT_TIMEOUT;
}; };
struct Result struct Result
{ {
enum enum
{ {
ERROR = -1, // Some non-specific error occurred. ERROR = -1, // Some non-specific error occurred.
COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved. COULDNT_RESOLVE_HOST = -2, // The specified host cold not be resolved.
OPERATION_TIMEDOUT = -3 // The operation timed out. OPERATION_TIMEDOUT = -3 // The operation timed out.
}; };
int code = 0; // HTTP response code int code = 0;// HTTP response code
std::string body; // Response body std::string body; // Response body
std::map<std::string, std::string> headers; // Headers attached to the response std::map<std::string, std::string> headers; // Headers attached to the response
}; };
/** /**
@ -156,9 +156,9 @@ class Async
public: public:
enum status_t enum status_t
{ {
READY, // The result is ready. READY, // The result is ready.
ERROR, // The operation has failed. ERROR, // The operation has failed.
PENDING // The operation is pending. PENDING // The operation is pending.
}; };
class Imp class Imp
@ -197,7 +197,7 @@ public:
* *
* @return *this. * @return *this.
*/ */
Async& operator = (const Async& rhs) Async& operator=(const Async& rhs)
{ {
std::shared_ptr<Imp> sImp(rhs.m_sImp); std::shared_ptr<Imp> sImp(rhs.m_sImp);
m_sImp.swap(sImp); m_sImp.swap(sImp);
@ -307,7 +307,5 @@ Async get_async(const std::vector<std::string>& urls,
Async get_async(const std::vector<std::string>& urls, Async get_async(const std::vector<std::string>& urls,
const std::string& user, const std::string& password, const std::string& user, const std::string& password,
const Config& config = Config()); const Config& config = Config());
} }
} }

View File

@ -51,17 +51,17 @@ public:
return prev; return prev;
} }
bool operator == (const intrusive_slist_iterator& rhs) const bool operator==(const intrusive_slist_iterator& rhs) const
{ {
return m_pT == rhs.m_pT; 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); return !(m_pT == rhs.m_pT);
} }
T& operator * () const T& operator*() const
{ {
mxb_assert(m_pT); mxb_assert(m_pT);
return *m_pT; return *m_pT;
@ -70,5 +70,4 @@ public:
private: private:
T* m_pT; T* m_pT;
}; };
} }

View File

@ -17,32 +17,32 @@
namespace maxbase namespace maxbase
{ {
class PamResult class PamResult
{
public:
enum class Result
{ {
public: SUCCESS,
enum class Result WRONG_USER_PW, /**< Username or password was wrong */
{ ACCOUNT_INVALID, /**< pam_acct_mgmt returned error */
SUCCESS, MISC_ERROR /**< Miscellaneous error */
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;
}; };
/** Result type {Result::MISC_ERROR};
* Check if the user & password can log into the given PAM service. This function will block until the std::string error;
* operation completes. };
*
* @param user Username /**
* @param password Password * Check if the user & password can log into the given PAM service. This function will block until the
* @param service Which PAM service is the user logging to * operation completes.
* @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. * @param user Username
* @return A result struct with the result and an error message. * @param password Password
*/ * @param service Which PAM service is the user logging to
PamResult pam_authenticate(const std::string& user, const std::string& password, * @param expected_msg The first expected message from the PAM authentication system.
const std::string& service, const std::string& expected_msg = "Password: "); * 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: ");
} }

View File

@ -285,7 +285,7 @@ public:
* and in the latter `EINTR. * and in the latter `EINTR.
*/ */
bool timedwait(time_t seconds, bool timedwait(time_t seconds,
long nseconds, long nseconds,
signal_approach_t signal_approach = IGNORE_SIGNALS) const signal_approach_t signal_approach = IGNORE_SIGNALS) const
{ {
timespec ts; timespec ts;
@ -316,7 +316,7 @@ public:
*/ */
size_t timedwait_n(size_t n_wait, size_t timedwait_n(size_t n_wait,
time_t seconds, time_t seconds,
long nseconds, long nseconds,
signal_approach_t signal_approach = IGNORE_SIGNALS) const signal_approach_t signal_approach = IGNORE_SIGNALS) const
{ {
timespec ts; timespec ts;

View File

@ -42,15 +42,15 @@ struct WORKER_STATISTICS
N_QUEUE_TIMES = 30 N_QUEUE_TIMES = 30
}; };
int64_t n_read = 0; /*< Number of read events */ int64_t n_read = 0; /*< Number of read events */
int64_t n_write = 0; /*< Number of write events */ int64_t n_write = 0; /*< Number of write events */
int64_t n_error = 0; /*< Number of error events */ int64_t n_error = 0; /*< Number of error events */
int64_t n_hup = 0; /*< Number of hangup events */ int64_t n_hup = 0; /*< Number of hangup events */
int64_t n_accept = 0; /*< Number of accept events */ int64_t n_accept = 0; /*< Number of accept events */
int64_t n_polls = 0; /*< Number of poll cycles */ int64_t n_polls = 0; /*< Number of poll cycles */
int64_t n_pollev = 0; /*< Number of polls returning events */ int64_t n_pollev = 0; /*< Number of polls returning events */
int64_t evq_avg = 0; /*< Average event queue length */ int64_t evq_avg = 0; /*< Average event queue length */
int64_t evq_max = 0; /*< Maximum event queue length */ int64_t evq_max = 0; /*< Maximum event queue length */
int64_t maxqtime = 0; int64_t maxqtime = 0;
int64_t maxexectime = 0; int64_t maxexectime = 0;
std::array<int64_t, MAXNFDS> n_fds {}; /*< Number of wakeups with particular n_fds value */ std::array<int64_t, MAXNFDS> n_fds {}; /*< Number of wakeups with particular n_fds value */
@ -249,12 +249,12 @@ class Worker : public MXB_WORKER
Worker& operator=(const Worker&) = delete; Worker& operator=(const Worker&) = delete;
public: public:
using STATISTICS = WORKER_STATISTICS; using STATISTICS = WORKER_STATISTICS;
using Task = WorkerTask; using Task = WorkerTask;
using DisposableTask = WorkerDisposableTask; using DisposableTask = WorkerDisposableTask;
using Load = WorkerLoad; using Load = WorkerLoad;
using Timer = WorkerTimer; using Timer = WorkerTimer;
using RandomEngine = maxbase::XorShiftRandom; using RandomEngine = maxbase::XorShiftRandom;
/** /**
* A delegating timer that delegates the timer tick handling * A delegating timer that delegates the timer tick handling

View File

@ -55,7 +55,8 @@ namespace
struct TimePointLessEqual struct TimePointLessEqual
{ {
TimePoint lhs; TimePoint lhs;
TimePointLessEqual(TimePoint tp) : lhs(tp) TimePointLessEqual(TimePoint tp)
: lhs(tp)
{ {
} }
bool operator()(const EventCount::Timestamp& rhs) const bool operator()(const EventCount::Timestamp& rhs) const
@ -134,7 +135,8 @@ namespace
struct MatchEventId struct MatchEventId
{ {
std::string event_id; 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 bool operator()(const EventCount& stats) const

View File

@ -95,5 +95,4 @@ std::string string_printf(const char* format, ...)
} }
return rval; return rval;
} }
} }

View File

@ -271,5 +271,4 @@ bool reverse_dns(const std::string& ip, std::string* output)
} }
return success; return success;
} }
} }

View File

@ -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, CURL* get_easy_curl(const std::string& url,
const std::string& user, const std::string& password, const std::string& user, const std::string& password,
const Config& config, const Config& config,
Result *pRes, Result* pRes,
char* pErrbuf) char* pErrbuf)
{ {
CURL* pCurl = curl_easy_init(); CURL* pCurl = curl_easy_init();
@ -126,8 +126,10 @@ CURL* get_easy_curl(const std::string& url,
if (pCurl) if (pCurl)
{ {
checked_curl_setopt(pCurl, CURLOPT_NOSIGNAL, 1); 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_CONNECTTIMEOUT, config.connect_timeout_s); // For connection
checked_curl_setopt(pCurl, CURLOPT_TIMEOUT, config.timeout_s); // For data transfer phase // 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_ERRORBUFFER, pErrbuf);
checked_curl_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_callback); checked_curl_setopt(pCurl, CURLOPT_WRITEFUNCTION, write_callback);
checked_curl_setopt(pCurl, CURLOPT_WRITEDATA, &pRes->body); checked_curl_setopt(pCurl, CURLOPT_WRITEDATA, &pRes->body);
@ -169,7 +171,7 @@ struct Context
} }
mxb::http::Result* pResult; mxb::http::Result* pResult;
Errbuf * pErrbuf; Errbuf* pErrbuf;
}; };
class ReadyImp : public Async::Imp class ReadyImp : public Async::Imp
@ -228,7 +230,7 @@ public:
for (auto& item : m_curls) for (auto& item : m_curls)
{ {
CURL* pCurl = item.first; 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); mxb_assert(rv == CURLM_OK);
curl_easy_cleanup(pCurl); curl_easy_cleanup(pCurl);
} }
@ -440,7 +442,6 @@ private:
int m_still_running; int m_still_running;
long m_wait_no_more_than; 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: 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); curl_easy_getinfo(pCurl, CURLINFO_RESPONSE_CODE, &code);
res.code = code; res.code = code;
} }
@ -614,7 +615,5 @@ const char* to_string(Async::status_t status)
mxb_assert(!true); mxb_assert(!true);
return "Unknown"; return "Unknown";
} }
} }
} }

View File

@ -32,7 +32,7 @@ class ConversationData
public: public:
string m_client; string m_client;
string m_password; string m_password;
int m_counter {0}; int m_counter {0};
string m_expected_msg; string m_expected_msg;
ConversationData(const string& client, const string& password, const string& 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; return rval;
} }
} }
namespace maxbase namespace maxbase
@ -123,25 +122,25 @@ PamResult pam_authenticate(const string& user, const string& password, const str
pam_status = pam_authenticate(pam_handle, 0); pam_status = pam_authenticate(pam_handle, 0);
switch (pam_status) switch (pam_status)
{ {
case PAM_SUCCESS: case PAM_SUCCESS:
authenticated = true; authenticated = true;
MXB_DEBUG("pam_authenticate returned success."); MXB_DEBUG("pam_authenticate returned success.");
break; break;
case PAM_USER_UNKNOWN: case PAM_USER_UNKNOWN:
case PAM_AUTH_ERR: case PAM_AUTH_ERR:
// Normal failure, username or password was wrong. // Normal failure, username or password was wrong.
result.type = PamResult::Result::WRONG_USER_PW; result.type = PamResult::Result::WRONG_USER_PW;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status)); pam_strerror(pam_handle, pam_status));
break; break;
default: default:
// More exotic error // More exotic error
result.type = PamResult::Result::MISC_ERROR; result.type = PamResult::Result::MISC_ERROR;
result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(), result.error = mxb::string_printf(PAM_AUTH_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status)); pam_strerror(pam_handle, pam_status));
break; break;
} }
} }
else else
@ -156,20 +155,19 @@ PamResult pam_authenticate(const string& user, const string& password, const str
pam_status = pam_acct_mgmt(pam_handle, 0); pam_status = pam_acct_mgmt(pam_handle, 0);
switch (pam_status) switch (pam_status)
{ {
case PAM_SUCCESS: case PAM_SUCCESS:
result.type = PamResult::Result::SUCCESS; result.type = PamResult::Result::SUCCESS;
break; break;
default: default:
// Credentials have already been checked to be ok, so this is a somewhat unexpected error. // Credentials have already been checked to be ok, so this is a somewhat unexpected error.
result.type = PamResult::Result::ACCOUNT_INVALID; result.type = PamResult::Result::ACCOUNT_INVALID;
result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(), result.error = mxb::string_printf(PAM_ACC_ERR_MSG, user.c_str(), service.c_str(),
pam_strerror(pam_handle, pam_status)); pam_strerror(pam_handle, pam_status));
break; break;
} }
} }
pam_end(pam_handle, pam_status); pam_end(pam_handle, pam_status);
return result; return result;
} }
} }

View File

@ -19,7 +19,7 @@ namespace maxbase
// static // static
void Semaphore::get_current_timespec(time_t seconds, void Semaphore::get_current_timespec(time_t seconds,
long nseconds, long nseconds,
timespec* pTs) timespec* pTs)
{ {
mxb_assert(nseconds <= 999999999); mxb_assert(nseconds <= 999999999);

View File

@ -19,7 +19,6 @@ namespace
{ {
thread_local char errbuf[512]; // Enough for all errors thread_local char errbuf[512]; // Enough for all errors
} }
const char* mxb_strerror(int error) const char* mxb_strerror(int error)
@ -73,5 +72,4 @@ char* trim(char* str)
{ {
return ltrim(rtrim(str)); return ltrim(rtrim(str));
} }
} }

View File

@ -103,8 +103,8 @@ int test_multi_http()
{ {
cout << __func__ << endl; cout << __func__ << endl;
vector<string> urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" }; vector<string> urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"};
vector<bool> expected_successes = { true, true, false }; vector<bool> expected_successes = {true, true, false};
vector<mxb::http::Result> results = mxb::http::get(urls); vector<mxb::http::Result> results = mxb::http::get(urls);
int rv = check_results(urls, expected_successes, results); int rv = check_results(urls, expected_successes, results);
@ -118,8 +118,8 @@ int test_async_http()
int rv = EXIT_FAILURE; int rv = EXIT_FAILURE;
vector<string> urls = { "http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz" }; vector<string> urls = {"http://www.example.com/", "http://www.example.com/", "http://non-existent.xyz"};
vector<bool> expected_successes = { true, true, false }; vector<bool> expected_successes = {true, true, false};
mxb::http::Async http = mxb::http::get_async(urls); mxb::http::Async http = mxb::http::get_async(urls);
while (http.perform(0) == mxb::http::Async::PENDING) while (http.perform(0) == mxb::http::Async::PENDING)
@ -148,7 +148,6 @@ int test_async_http()
return rv == EXIT_FAILURE ? 1 : 0; return rv == EXIT_FAILURE ? 1 : 0;
} }
} }
uint64_t time_since_epoch_ms() uint64_t time_since_epoch_ms()

View File

@ -116,7 +116,6 @@ int test_rtrim()
cout << "rtrim()" << endl; cout << "rtrim()" << endl;
return test(rtrim_testcases, n_rtrim_testcases, mxb::rtrim); return test(rtrim_testcases, n_rtrim_testcases, mxb::rtrim);
} }
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])

View File

@ -111,7 +111,7 @@ uint64_t WorkerLoad::get_time_ms()
int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t); int rv = clock_gettime(CLOCK_MONOTONIC_COARSE, &t);
if (rv != 0) 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); rv = clock_gettime(CLOCK_MONOTONIC, &t);
mxb_assert(rv == 0); mxb_assert(rv == 0);
} }

View File

@ -117,7 +117,7 @@ bool QueryResult::next_row()
if (m_rowdata) if (m_rowdata)
{ {
m_current_row_ind++; m_current_row_ind++;
m_error = ConversionError(); // Reset error m_error = ConversionError(); // Reset error
return true; return true;
} }
else else
@ -333,5 +333,4 @@ bool QueryResult::ConversionError::error() const
{ {
return !m_target_type.empty(); return !m_target_type.empty();
} }
} }

View File

@ -2361,7 +2361,7 @@ static void add_field_info(parsing_info_t* info,
} }
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* database,
const char* table, const char* table,
const char* column, 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, static QC_FUNCTION_INFO* add_function_info(parsing_info_t* info,
st_select_lex* select, st_select_lex* select,
const char* name, const char* name,
Item** items, Item** items,
int n_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, static void add_field_info(parsing_info_t* pi,
st_select_lex* select, st_select_lex* select,
Item_field* item, Item_field* item,
List<Item>* excludep) List<Item>* excludep)
{ {
@ -2727,7 +2727,7 @@ static void add_field_info(parsing_info_t* pi,
} }
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, Item* item,
List<Item>* excludep) List<Item>* 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, static void update_field_infos(parsing_info_t* pi,
st_select_lex* select, st_select_lex* select,
collect_source_t source, collect_source_t source,
Item* item, Item* item,
List<Item>* excludep) List<Item>* 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. char func_name[strlen(f) + 3 + 1]; // strlen(substring) - strlen(substr) from below.
strcpy(func_name, f); 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. // Non native functions are surrounded by back-ticks, let's remove them.
remove_surrounding_back_ticks(func_name); remove_surrounding_back_ticks(func_name);
@ -3603,57 +3603,57 @@ int32_t qc_mysql_set_options(uint32_t options)
extern "C" 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_setup, qc_mysql_process_end,
qc_mysql_process_init, qc_mysql_thread_init,
qc_mysql_process_end, qc_mysql_thread_end,
qc_mysql_thread_init, qc_mysql_parse,
qc_mysql_thread_end, qc_mysql_get_type_mask,
qc_mysql_parse, qc_mysql_get_operation,
qc_mysql_get_type_mask, qc_mysql_get_created_table_name,
qc_mysql_get_operation, qc_mysql_is_drop_table_query,
qc_mysql_get_created_table_name, qc_mysql_get_table_names,
qc_mysql_is_drop_table_query, NULL,
qc_mysql_get_table_names, qc_mysql_query_has_clause,
NULL, qc_mysql_get_database_names,
qc_mysql_query_has_clause, qc_mysql_get_prepare_name,
qc_mysql_get_database_names, qc_mysql_get_field_info,
qc_mysql_get_prepare_name, qc_mysql_get_function_info,
qc_mysql_get_field_info, qc_mysql_get_preparable_stmt,
qc_mysql_get_function_info, qc_mysql_set_server_version,
qc_mysql_get_preparable_stmt, qc_mysql_get_server_version,
qc_mysql_set_server_version, qc_mysql_get_sql_mode,
qc_mysql_get_server_version, qc_mysql_set_sql_mode,
qc_mysql_get_sql_mode, nullptr, // qc_info_dup not supported.
qc_mysql_set_sql_mode, nullptr, // qc_info_close not supported.
nullptr, // qc_info_dup not supported. qc_mysql_get_options,
nullptr, // qc_info_close not supported. qc_mysql_set_options,
qc_mysql_get_options, nullptr, // qc_get_result_from_info not supported
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_END_MODULE_PARAMS}
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}
}
};
return &info; return &info;
} }
} }

View File

@ -192,45 +192,45 @@ static const char* get_token_symbol(int token);
extern "C" extern "C"
{ {
extern void exposed_sqlite3ExprDelete(sqlite3* db, Expr* pExpr); extern void exposed_sqlite3ExprDelete(sqlite3* db, Expr* pExpr);
extern void exposed_sqlite3ExprListDelete(sqlite3* db, ExprList* pList); extern void exposed_sqlite3ExprListDelete(sqlite3* db, ExprList* pList);
extern void exposed_sqlite3IdListDelete(sqlite3* db, IdList* pList); extern void exposed_sqlite3IdListDelete(sqlite3* db, IdList* pList);
extern void exposed_sqlite3SrcListDelete(sqlite3* db, SrcList* pList); extern void exposed_sqlite3SrcListDelete(sqlite3* db, SrcList* pList);
extern void exposed_sqlite3SelectDelete(sqlite3* db, Select* p); extern void exposed_sqlite3SelectDelete(sqlite3* db, Select* p);
extern void exposed_sqlite3BeginTrigger(Parse* pParse, extern void exposed_sqlite3BeginTrigger(Parse* pParse,
Token* pName1, Token* pName1,
Token* pName2, Token* pName2,
int tr_tm, int tr_tm,
int op, int op,
IdList* pColumns, IdList* pColumns,
SrcList* pTableName, SrcList* pTableName,
Expr* pWhen, Expr* pWhen,
int isTemp, int isTemp,
int noErr); int noErr);
extern void exposed_sqlite3FinishTrigger(Parse* pParse, extern void exposed_sqlite3FinishTrigger(Parse* pParse,
TriggerStep* pStepList, TriggerStep* pStepList,
Token* pAll); Token* pAll);
extern int exposed_sqlite3Dequote(char* z); extern int exposed_sqlite3Dequote(char* z);
extern int exposed_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*); extern int exposed_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*);
extern void exposed_sqlite3Insert(Parse* pParse, extern void exposed_sqlite3Insert(Parse* pParse,
SrcList* pTabList, SrcList* pTabList,
Select* pSelect, Select* pSelect,
IdList* pColumns, IdList* pColumns,
int onError); int onError);
extern int exposed_sqlite3Select(Parse* pParse, Select* p, SelectDest* pDest); extern int exposed_sqlite3Select(Parse* pParse, Select* p, SelectDest* pDest);
extern void exposed_sqlite3StartTable(Parse* pParse,/* Parser context */ extern void exposed_sqlite3StartTable(Parse* pParse, /* Parser context */
Token* pName1,/* First part of the name of the table or view */ Token* pName1, /* First part of the name of the table or view */
Token* pName2,/* Second 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 isTemp, /* True if this is a TEMP table */
int isView, /* True if this is a VIEW */ int isView, /* True if this is a VIEW */
int isVirtual,/* True if this is a VIRTUAL table */ int isVirtual, /* True if this is a VIRTUAL table */
int noErr); /* Do nothing if table already exists */ int noErr); /* Do nothing if table already exists */
extern void exposed_sqlite3Update(Parse* pParse, extern void exposed_sqlite3Update(Parse* pParse,
SrcList* pTabList, SrcList* pTabList,
ExprList* pChanges, ExprList* pChanges,
Expr* pWhere, Expr* pWhere,
int onError); int onError);
} }
/** /**
@ -843,7 +843,7 @@ public:
update_field_infos_from_expr(pAliases, context, pExpr, pExclude); update_field_infos_from_expr(pAliases, context, pExpr, pExclude);
break; 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) if (this_thread.options & QC_OPTION_STRING_AS_FIELD)
{ {
const char* zColumn = pExpr->u.zToken; const char* zColumn = pExpr->u.zToken;
@ -1268,7 +1268,10 @@ public:
if (pSrc->a[i].pSelect) 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 #ifdef QC_COLLECT_NAMES_FROM_USING
@ -1460,8 +1463,8 @@ public:
} }
static void update_function_fields(const QcAliases* pAliases, static void update_function_fields(const QcAliases* pAliases,
const ExprList* pEList, const ExprList* pEList,
const ExprList* pExclude, const ExprList* pExclude,
vector<QC_FIELD_INFO>& fields) vector<QC_FIELD_INFO>& fields)
{ {
for (int i = 0; i < pEList->nExpr; ++i) 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 */ 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 */ Token* pName1, /* The name of the trigger */
int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */ Token* pName2, /* The name of the trigger */
int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */ int tr_tm, /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */
IdList* pColumns, /* column list if this is an UPDATE OF trigger */ int op, /* One of TK_INSERT, TK_UPDATE, TK_DELETE */
SrcList* pTableName, /* The name of the table/view the trigger applies to */ IdList* pColumns, /* column list if this is an UPDATE OF trigger */
Expr* pWhen, /* WHEN clause */ SrcList* pTableName, /* The name of the table/view the trigger applies to
int isTemp, /* True if the TEMPORARY keyword is present */ * */
int noErr) /* Suppress errors if the trigger already exists */ 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); mxb_assert(this_thread.initialized);
@ -1670,7 +1675,7 @@ public:
ExprList* pList, /* A list of columns to be indexed */ ExprList* pList, /* A list of columns to be indexed */
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
Token* pStart, /* The CREATE token that begins this statement */ 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 sortOrder, /* Sort order of primary key when pList==NULL */
int ifNotExist) /* Omit error if index already exists */ 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* pName1, /* The token that holds the name of the view */
Token* pName2, /* 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 */ 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 isTemp, /* TRUE for a TEMPORARY view */
int noErr) /* Suppress error messages if VIEW already exists */ int noErr) /* Suppress error messages if VIEW already exists */
{ {
@ -1868,8 +1873,8 @@ public:
void mxs_sqlite3Insert(Parse* pParse, void mxs_sqlite3Insert(Parse* pParse,
SrcList* pTabList, SrcList* pTabList,
Select* pSelect, Select* pSelect,
IdList* pColumns, IdList* pColumns,
int onError, int onError,
ExprList* pSet) ExprList* pSet)
{ {
@ -2109,7 +2114,7 @@ public:
void maxscaleAlterTable(Parse* pParse, /* Parser context. */ void maxscaleAlterTable(Parse* pParse, /* Parser context. */
mxs_alter_t command, mxs_alter_t command,
SrcList* pSrc, /* The table to rename. */ 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); mxb_assert(this_thread.initialized);
@ -3431,78 +3436,78 @@ public:
extern "C" extern "C"
{ {
extern void mxs_sqlite3AlterFinishAddColumn(Parse*, Token*); extern void mxs_sqlite3AlterFinishAddColumn(Parse*, Token*);
extern void mxs_sqlite3AlterBeginAddColumn(Parse*, SrcList*); extern void mxs_sqlite3AlterBeginAddColumn(Parse*, SrcList*);
extern void mxs_sqlite3Analyze(Parse*, SrcList*); extern void mxs_sqlite3Analyze(Parse*, SrcList*);
extern void mxs_sqlite3BeginTransaction(Parse*, int token, int type); extern void mxs_sqlite3BeginTransaction(Parse*, int token, int type);
extern void mxs_sqlite3CommitTransaction(Parse*); extern void mxs_sqlite3CommitTransaction(Parse*);
extern void mxs_sqlite3CreateIndex(Parse*, extern void mxs_sqlite3CreateIndex(Parse*,
Token*, Token*,
Token*, Token*,
SrcList*, SrcList*,
ExprList*, ExprList*,
int, int,
Token*, Token*,
Expr*, Expr*,
int, int,
int); int);
extern void mxs_sqlite3BeginTrigger(Parse*, extern void mxs_sqlite3BeginTrigger(Parse*,
Token*, Token*,
Token*, Token*,
int, int,
int, int,
IdList*, IdList*,
SrcList*, SrcList*,
Expr*, Expr*,
int, int,
int); int);
extern void mxs_sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); extern void mxs_sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);
extern void mxs_sqlite3CreateView(Parse*, Token*, Token*, Token*, ExprList*, Select*, int, int); 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_sqlite3DeleteFrom(Parse* pParse, SrcList* pTabList, Expr* pWhere, SrcList* pUsing);
extern void mxs_sqlite3DropIndex(Parse*, SrcList*, SrcList*, int); extern void mxs_sqlite3DropIndex(Parse*, SrcList*, SrcList*, int);
extern void mxs_sqlite3DropTable(Parse*, SrcList*, int, int, int); extern void mxs_sqlite3DropTable(Parse*, SrcList*, int, int, int);
extern void mxs_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*, SrcList*); extern void mxs_sqlite3EndTable(Parse*, Token*, Token*, u8, Select*, SrcList*);
extern void mxs_sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, ExprList*); extern void mxs_sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, ExprList*);
extern void mxs_sqlite3RollbackTransaction(Parse*); extern void mxs_sqlite3RollbackTransaction(Parse*);
extern void mxs_sqlite3Savepoint(Parse* pParse, int op, Token* pName); extern void mxs_sqlite3Savepoint(Parse* pParse, int op, Token* pName);
extern int mxs_sqlite3Select(Parse*, Select*, SelectDest*); extern int mxs_sqlite3Select(Parse*, Select*, SelectDest*);
extern void mxs_sqlite3StartTable(Parse*, Token*, Token*, int, int, int, int); extern void mxs_sqlite3StartTable(Parse*, Token*, Token*, int, int, int, int);
extern void mxs_sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, 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 maxscaleAlterTable(Parse*, mxs_alter_t command, SrcList*, Token*);
extern void maxscaleCall(Parse*, SrcList* pName, ExprList* pExprList); extern void maxscaleCall(Parse*, SrcList* pName, ExprList* pExprList);
extern void maxscaleCheckTable(Parse*, SrcList* pTables); extern void maxscaleCheckTable(Parse*, SrcList* pTables);
extern void maxscaleCreateSequence(Parse*, Token* pDatabase, Token* pTable); extern void maxscaleCreateSequence(Parse*, Token* pDatabase, Token* pTable);
extern void maxscaleDeclare(Parse* pParse); extern void maxscaleDeclare(Parse* pParse);
extern void maxscaleDeallocate(Parse*, Token* pName); extern void maxscaleDeallocate(Parse*, Token* pName);
extern void maxscaleDo(Parse*, ExprList* pEList); extern void maxscaleDo(Parse*, ExprList* pEList);
extern void maxscaleDrop(Parse*, int what, Token* pDatabase, Token* pName); extern void maxscaleDrop(Parse*, int what, Token* pDatabase, Token* pName);
extern void maxscaleExecute(Parse*, Token* pName, int type_mask); extern void maxscaleExecute(Parse*, Token* pName, int type_mask);
extern void maxscaleExecuteImmediate(Parse*, Token* pName, ExprSpan* pExprSpan, int type_mask); extern void maxscaleExecuteImmediate(Parse*, Token* pName, ExprSpan* pExprSpan, int type_mask);
extern void maxscaleExplain(Parse*, Token* pNext); extern void maxscaleExplain(Parse*, Token* pNext);
extern void maxscaleFlush(Parse*, Token* pWhat); extern void maxscaleFlush(Parse*, Token* pWhat);
extern void maxscaleHandler(Parse*, mxs_handler_t, SrcList* pFullName, Token* pName); extern void maxscaleHandler(Parse*, mxs_handler_t, SrcList* pFullName, Token* pName);
extern void maxscaleLoadData(Parse*, SrcList* pFullName, int local); extern void maxscaleLoadData(Parse*, SrcList* pFullName, int local);
extern void maxscaleLock(Parse*, mxs_lock_t, SrcList*); extern void maxscaleLock(Parse*, mxs_lock_t, SrcList*);
extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt); extern void maxscalePrepare(Parse*, Token* pName, Expr* pStmt);
extern void maxscalePrivileges(Parse*, int kind); extern void maxscalePrivileges(Parse*, int kind);
extern void maxscaleRenameTable(Parse*, SrcList* pTables); extern void maxscaleRenameTable(Parse*, SrcList* pTables);
extern void maxscaleReset(Parse*, int what); extern void maxscaleReset(Parse*, int what);
extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*); extern void maxscaleSet(Parse*, int scope, mxs_set_t kind, ExprList*);
extern void maxscaleShow(Parse*, MxsShow* pShow); extern void maxscaleShow(Parse*, MxsShow* pShow);
extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName); extern void maxscaleTruncate(Parse*, Token* pDatabase, Token* pName);
extern void maxscaleUse(Parse*, Token*); extern void maxscaleUse(Parse*, Token*);
extern void maxscale_update_function_info(const char* name, const Expr* pExpr); 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. // '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_set_type_mask(unsigned int type_mask);
extern int maxscaleComment(); extern int maxscaleComment();
extern int maxscaleKeyword(int token); extern int maxscaleKeyword(int token);
extern void maxscaleSetStatusCap(int cap); extern void maxscaleSetStatusCap(int cap);
extern int maxscaleTranslateKeyword(int token); 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 */ IdList* pColumns, /* column list if this is an UPDATE OF trigger */
SrcList* pTableName, /* The name of the table/view the trigger applies to */ SrcList* pTableName, /* The name of the table/view the trigger applies to */
Expr* pWhen, /* WHEN clause */ Expr* pWhen, /* WHEN clause */
int isTemp, /* True if the TEMPORARY keyword is present */ int isTemp, /* True if the TEMPORARY keyword is present */
int noErr) /* Suppress errors if the trigger already exists */ int noErr) /* Suppress errors if the trigger already exists */
{ {
QC_TRACE(); 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 */ ExprList* pList, /* A list of columns to be indexed */
int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
Token* pStart, /* The CREATE token that begins this statement */ 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 sortOrder, /* Sort order of primary key when pList==NULL */
int ifNotExist) /* Omit error if index already exists */ 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* pName1, /* The token that holds the name of the view */
Token* pName2, /* 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 */ 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 isTemp, /* TRUE for a TEMPORARY view */
int noErr) /* Suppress error messages if VIEW already exists */ 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, void mxs_sqlite3Insert(Parse* pParse,
SrcList* pTabList, SrcList* pTabList,
Select* pSelect, Select* pSelect,
IdList* pColumns, IdList* pColumns,
int onError, int onError,
ExprList* pSet) ExprList* pSet)
{ {
@ -4293,7 +4298,7 @@ void maxscaleCollectInfoFromSelect(Parse* pParse, Select* pSelect, int sub_selec
void maxscaleAlterTable(Parse* pParse, /* Parser context. */ void maxscaleAlterTable(Parse* pParse, /* Parser context. */
mxs_alter_t command, mxs_alter_t command,
SrcList* pSrc, /* The table to rename. */ SrcList* pSrc, /* The table to rename. */
Token* pName) /* The new table name (RENAME). */ Token* pName) /* The new table name (RENAME). */
{ {
QC_TRACE(); QC_TRACE();
@ -5323,57 +5328,57 @@ QC_STMT_RESULT qc_sqlite_get_result_from_info(const QC_STMT_INFO* pInfo)
extern "C" 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_setup, qc_sqlite_process_end,
qc_sqlite_process_init, qc_sqlite_thread_init,
qc_sqlite_process_end, qc_sqlite_thread_end,
qc_sqlite_thread_init, qc_sqlite_parse,
qc_sqlite_thread_end, qc_sqlite_get_type_mask,
qc_sqlite_parse, qc_sqlite_get_operation,
qc_sqlite_get_type_mask, qc_sqlite_get_created_table_name,
qc_sqlite_get_operation, qc_sqlite_is_drop_table_query,
qc_sqlite_get_created_table_name, qc_sqlite_get_table_names,
qc_sqlite_is_drop_table_query, NULL,
qc_sqlite_get_table_names, qc_sqlite_query_has_clause,
NULL, qc_sqlite_get_database_names,
qc_sqlite_query_has_clause, qc_sqlite_get_prepare_name,
qc_sqlite_get_database_names, qc_sqlite_get_field_info,
qc_sqlite_get_prepare_name, qc_sqlite_get_function_info,
qc_sqlite_get_field_info, qc_sqlite_get_preparable_stmt,
qc_sqlite_get_function_info, qc_sqlite_set_server_version,
qc_sqlite_get_preparable_stmt, qc_sqlite_get_server_version,
qc_sqlite_set_server_version, qc_sqlite_get_sql_mode,
qc_sqlite_get_server_version, qc_sqlite_set_sql_mode,
qc_sqlite_get_sql_mode, qc_sqlite_info_dup,
qc_sqlite_set_sql_mode, qc_sqlite_info_close,
qc_sqlite_info_dup, qc_sqlite_get_options,
qc_sqlite_info_close, qc_sqlite_set_options,
qc_sqlite_get_options, qc_sqlite_get_result_from_info,
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_END_MODULE_PARAMS}
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}
}
};
return &info; return &info;
} }
} }

View File

@ -154,7 +154,7 @@ QUERY_CLASSIFIER* load_classifier(const char* name)
{ {
bool loaded = false; bool loaded = false;
size_t len = strlen(name); size_t len = strlen(name);
char libdir[len + 3 + 1]; // Extra for ../ char libdir[len + 3 + 1]; // Extra for ../
sprintf(libdir, "../%s", name); sprintf(libdir, "../%s", name);
@ -204,8 +204,8 @@ void put_classifier(QUERY_CLASSIFIER* pClassifier)
} }
bool get_classifiers(qc_sql_mode_t sql_mode, bool get_classifiers(qc_sql_mode_t sql_mode,
const char* zName1, const char* zName1,
const char* zArgs1, const char* zArgs1,
QUERY_CLASSIFIER** ppClassifier1, QUERY_CLASSIFIER** ppClassifier1,
const char* zName2, const char* zName2,
const char* zArgs2, const char* zArgs2,
@ -594,7 +594,7 @@ bool compare_get_table_names(QUERY_CLASSIFIER* pClassifier1,
GWBUF* pCopy1, GWBUF* pCopy1,
QUERY_CLASSIFIER* pClassifier2, QUERY_CLASSIFIER* pClassifier2,
GWBUF* pCopy2, GWBUF* pCopy2,
bool full) bool full)
{ {
bool success = false; bool success = false;
const char* HEADING; const char* HEADING;

View File

@ -225,7 +225,7 @@ namespace maxscale
{ {
TestReader::TestReader(istream& in, TestReader::TestReader(istream& in,
size_t line) size_t line)
: m_in(in) : m_in(in)
, m_line(line) , m_line(line)
, m_delimiter(";") , m_delimiter(";")

View File

@ -70,10 +70,9 @@ int test()
string valid_json("SELECT Json_Array(56, 3.1416, 'My name is \"Foo\"', NULL)"); 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)"); string invalid_json("SELECT Json_Foo(56, 3.1416, 'My name is \"Foo\"', NULL)");
auto encode_version = [](const SERVER::Version& sv) -> uint64_t auto encode_version = [](const SERVER::Version& sv) -> uint64_t {
{ return sv.major * 10000 + sv.minor * 100 + sv.patch;
return sv.major * 10000 + sv.minor * 100 + sv.patch; };
};
SERVER::Version sv; SERVER::Version sv;
// pre-Json // pre-Json