Move some mysql/mariadb utilities to maxutils

Can be used in system tests later on.
This commit is contained in:
Esa Korhonen
2018-11-08 19:06:19 +02:00
parent a6fe6a0463
commit 0c7e737eb7
13 changed files with 203 additions and 106 deletions

View File

@ -0,0 +1,3 @@
install_header(mariadb.hh devel)
install_header(ccdefs.hh devel)

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2018 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#pragma once
/**
* @file ccdefs.hh
*
* This file should be included first by all maxsql headers.
*/
#if !defined (__cplusplus)
#error This file is only to be included by C++ code.
#endif
#include <maxbase/ccdefs.hh>
/**
* All classes of MaxSql are defined in the namespace @c maxsql.
*/
namespace maxsql
{
}
/**
* Shorthand for the @c maxsql namespace.
*/
namespace mxq = maxsql;

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2018 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2022-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#pragma once
#include <maxsql/ccdefs.hh>
#include <string>
#include <mysql.h>
namespace maxsql
{
/**
* Execute a query, manually defining retry limits.
*
* @param conn MySQL connection
* @param query Query to execute
* @param query_retries Maximum number of retries
* @param query_retry_timeout Maximum time to spend retrying, in seconds
* @return return value of mysql_query
*/
int mysql_query_ex(MYSQL* conn, const std::string& query, int query_retries, time_t query_retry_timeout);
/**
* Check if the MYSQL error number is a connection error.
*
* @param Error code
* @return True if the MYSQL error number is a connection error
*/
bool mysql_is_net_error(unsigned int errcode);
/**
* Enable/disable the logging of all SQL statements MaxScale sends to
* the servers.
*
* @param enable If true, enable, if false, disable.
*/
void mysql_set_log_statements(bool enable);
/**
* Returns whether SQL statements sent to the servers are logged or not.
*
* @return True, if statements are logged, false otherwise.
*/
bool mysql_get_log_statements();
}