Remove duplicate utils from 'test_query_rules_fast_routing_algorithm-t'

pull/4881/head
Javier Jaramago Fernández 1 year ago
parent 69c2839f0d
commit 73288cb76f

@ -21,6 +21,9 @@
template <typename T>
using rc_t = std::pair<int,T>;
#define _S(s) ( std::string {s} )
#define _TO_S(s) ( std::to_string(s) )
// Improve dependency failure compilation error
#ifndef DISABLE_WARNING_COUNT_LOGGING
@ -63,6 +66,12 @@ my_bool mysql_stmt_close_override(MYSQL_STMT* stmt, const char* file, int line);
#endif
/**
* @brief Simple macro to use with 'mysql_query' versions.
* @details E.g: `mysql_query_ext_val(admin, SELECT_RUNTIME_VAR"'mysql-eventslog_filename'", "")`.
*/
#define SELECT_RUNTIME_VAR "SELECT variable_value FROM runtime_global_variables WHERE variable_name="
/**
* @brief Computes the binomial coefficient C(n, k)
*/
@ -221,6 +230,19 @@ enum SQ3_RES_T {
*/
sq3_res_t sqlite3_execute_stmt(sqlite3* db, const std::string& query);
/**
* @brief Utility one-liner macro to check for query failure on a 'ext_val_t<T>'.
* @param val The 'ext_val_t<T>' to be checked.
* @return In case of failure, 'EXIT_FAILURE' after logging the error, continues otherwise.
*/
#define CHECK_EXT_VAL(val)\
do {\
if (val.err) {\
diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, val.str.c_str());\
return EXIT_FAILURE;\
}\
} while(0)
/**
* @brief Holds the result of an `mysql_query_ext_val` operation.
*/

@ -36,29 +36,6 @@ using std::vector;
// Used for 'extract_module_host_port'
#include "modules_server_test.h"
////////////////////////////////////////////////////////////////////////////////
// Borrowed from test_match_eof_conn_cap.cpp - TODO: MERGE
////////////////////////////////////////////////////////////////////////////////
#include <dirent.h>
#define _S(s) ( std::string {s} )
#define _TO_S(s) ( std::to_string(s) )
#define SELECT_RUNTIME_VAR "SELECT variable_value FROM runtime_global_variables WHERE variable_name="
#define CHECK_EXT_VAL(val)\
do {\
if (val.err) {\
diag("%s:%d: Query failed err=\"%s\"", __func__, __LINE__, val.str.c_str());\
return EXIT_FAILURE;\
}\
} while(0)
const uint32_t USLEEP_SQLITE_LOCKED = 100;
////////////////////////////////////////////////////////////////////////////////
int get_query_int_res(MYSQL* admin, const string& q, int& val) {
MYSQL_QUERY_T(admin, q.c_str());
MYSQL_RES* myres = mysql_store_result(admin);

Loading…
Cancel
Save