MXS-1840 Compile all routers as C++
Minimal changes, only what is needed in order to make it compile.
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
#ifndef _MAXAVRO_H
|
#pragma once
|
||||||
#define _MAXAVRO_H
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||||
*
|
*
|
||||||
@ -20,6 +19,8 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <maxscale/buffer.h>
|
#include <maxscale/buffer.h>
|
||||||
|
|
||||||
|
MXS_BEGIN_DECLS
|
||||||
|
|
||||||
/** File magic and sync marker sizes block sizes */
|
/** File magic and sync marker sizes block sizes */
|
||||||
#define AVRO_MAGIC_SIZE 4
|
#define AVRO_MAGIC_SIZE 4
|
||||||
#define SYNC_MARKER_SIZE 16
|
#define SYNC_MARKER_SIZE 16
|
||||||
@ -154,4 +155,4 @@ GWBUF* maxavro_file_binary_header(MAXAVRO_FILE *file);
|
|||||||
enum maxavro_error maxavro_get_error(MAXAVRO_FILE *file);
|
enum maxavro_error maxavro_get_error(MAXAVRO_FILE *file);
|
||||||
const char* maxavro_get_error_string(MAXAVRO_FILE *file);
|
const char* maxavro_get_error_string(MAXAVRO_FILE *file);
|
||||||
|
|
||||||
#endif
|
MXS_END_DECLS
|
||||||
|
|||||||
@ -5,6 +5,7 @@ if(BUILD_BINLOG)
|
|||||||
add_subdirectory(binlogrouter)
|
add_subdirectory(binlogrouter)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(cat)
|
||||||
add_subdirectory(cli)
|
add_subdirectory(cli)
|
||||||
add_subdirectory(debugcli)
|
add_subdirectory(debugcli)
|
||||||
add_subdirectory(hintrouter)
|
add_subdirectory(hintrouter)
|
||||||
@ -12,6 +13,5 @@ add_subdirectory(maxinfo)
|
|||||||
add_subdirectory(readconnroute)
|
add_subdirectory(readconnroute)
|
||||||
add_subdirectory(readwritesplit)
|
add_subdirectory(readwritesplit)
|
||||||
add_subdirectory(schemarouter)
|
add_subdirectory(schemarouter)
|
||||||
add_subdirectory(cat)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
if(AVRO_FOUND AND JANSSON_FOUND)
|
if(AVRO_FOUND AND JANSSON_FOUND)
|
||||||
include_directories(${AVRO_INCLUDE_DIR})
|
include_directories(${AVRO_INCLUDE_DIR})
|
||||||
include_directories(${JANSSON_INCLUDE_DIR})
|
include_directories(${JANSSON_INCLUDE_DIR})
|
||||||
add_library(avrorouter SHARED avro.c ../binlogrouter/binlog_common.c avro_client.c avro_schema.c avro_rbr.c avro_file.c avro_index.c)
|
add_library(avrorouter SHARED avro.cc ../binlogrouter/binlog_common.cc avro_client.cc avro_schema.cc avro_rbr.cc avro_file.cc avro_index.cc)
|
||||||
set_target_properties(avrorouter PROPERTIES VERSION "1.0.0")
|
set_target_properties(avrorouter PROPERTIES VERSION "1.0.0")
|
||||||
set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
set_target_properties(avrorouter PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
||||||
target_link_libraries(avrorouter maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro lzma)
|
target_link_libraries(avrorouter maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro lzma)
|
||||||
|
|||||||
@ -195,7 +195,7 @@ static bool avro_handle_purge(const MODULECMD_ARG *args, json_t** output)
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
instances = NULL;
|
instances = NULL;
|
||||||
@ -479,7 +479,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
AVRO_INSTANCE *inst;
|
AVRO_INSTANCE *inst;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((inst = MXS_CALLOC(1, sizeof(AVRO_INSTANCE))) == NULL)
|
if ((inst = static_cast<AVRO_INSTANCE*>(MXS_CALLOC(1, sizeof(AVRO_INSTANCE)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
inst->fileroot = MXS_STRDUP_A(config_get_string(params, "filestem"));
|
inst->fileroot = MXS_STRDUP_A(config_get_string(params, "filestem"));
|
||||||
inst->row_target = config_get_integer(params, "group_rows");
|
inst->row_target = config_get_integer(params, "group_rows");
|
||||||
inst->trx_target = config_get_integer(params, "group_trx");
|
inst->trx_target = config_get_integer(params, "group_trx");
|
||||||
inst->codec = config_get_enum(params, "codec", codec_values);
|
inst->codec = static_cast<mxs_avro_codec_type>(config_get_enum(params, "codec", codec_values));
|
||||||
int first_file = config_get_integer(params, "start_index");
|
int first_file = config_get_integer(params, "start_index");
|
||||||
inst->block_size = config_get_size(params, "block_size");
|
inst->block_size = config_get_size(params, "block_size");
|
||||||
|
|
||||||
@ -798,7 +798,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
|
|
||||||
CHK_CLIENT_RSES(client);
|
CHK_CLIENT_RSES(client);
|
||||||
|
|
||||||
return (void *) client;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,7 +156,7 @@ avro_client_do_registration(AVRO_INSTANCE *router, AVRO_CLIENT *client, GWBUF *d
|
|||||||
*sep_ptr = '\0';
|
*sep_ptr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(uuid) < uuid_len)
|
if (strlen(uuid) < static_cast<size_t>(uuid_len))
|
||||||
{
|
{
|
||||||
data_len -= (uuid_len - strlen(uuid));
|
data_len -= (uuid_len - strlen(uuid));
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ void avro_close_binlog(int fd)
|
|||||||
AVRO_TABLE* avro_table_alloc(const char* filepath, const char* json_schema, const char *codec,
|
AVRO_TABLE* avro_table_alloc(const char* filepath, const char* json_schema, const char *codec,
|
||||||
size_t block_size)
|
size_t block_size)
|
||||||
{
|
{
|
||||||
AVRO_TABLE *table = MXS_CALLOC(1, sizeof(AVRO_TABLE));
|
AVRO_TABLE *table = static_cast<AVRO_TABLE*>(MXS_CALLOC(1, sizeof(AVRO_TABLE)));
|
||||||
if (table)
|
if (table)
|
||||||
{
|
{
|
||||||
if (avro_schema_from_json_length(json_schema, strlen(json_schema),
|
if (avro_schema_from_json_length(json_schema, strlen(json_schema),
|
||||||
@ -340,7 +340,7 @@ static avro_binlog_end_t rotate_to_next_file_if_exists(AVRO_INSTANCE* router, ui
|
|||||||
char next_binlog[BINLOG_FNAMELEN + 1];
|
char next_binlog[BINLOG_FNAMELEN + 1];
|
||||||
if (snprintf(next_binlog, sizeof(next_binlog),
|
if (snprintf(next_binlog, sizeof(next_binlog),
|
||||||
BINLOG_NAMEFMT, router->fileroot,
|
BINLOG_NAMEFMT, router->fileroot,
|
||||||
blr_file_get_next_binlogname(router->binlog_name)) >= sizeof(next_binlog))
|
blr_file_get_next_binlogname(router->binlog_name)) >= (int)sizeof(next_binlog))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Next binlog name did not fit into the allocated buffer "
|
MXS_ERROR("Next binlog name did not fit into the allocated buffer "
|
||||||
"but was truncated, aborting: %s", next_binlog);
|
"but was truncated, aborting: %s", next_binlog);
|
||||||
@ -416,7 +416,7 @@ static GWBUF* read_event_data(AVRO_INSTANCE *router, REP_HEADER* hdr, uint64_t p
|
|||||||
/** NULL-terminate for QUERY_EVENT processing */
|
/** NULL-terminate for QUERY_EVENT processing */
|
||||||
data[hdr->event_size - BINLOG_EVENT_HDR_LEN] = '\0';
|
data[hdr->event_size - BINLOG_EVENT_HDR_LEN] = '\0';
|
||||||
|
|
||||||
if (n != hdr->event_size - BINLOG_EVENT_HDR_LEN)
|
if (n != static_cast<int>(hdr->event_size - BINLOG_EVENT_HDR_LEN))
|
||||||
{
|
{
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
{
|
{
|
||||||
@ -824,7 +824,8 @@ void avro_load_metadata_from_schemas(AVRO_INSTANCE *router)
|
|||||||
if (versionend == suffix)
|
if (versionend == suffix)
|
||||||
{
|
{
|
||||||
snprintf(table_ident, sizeof(table_ident), "%s.%s", db, table);
|
snprintf(table_ident, sizeof(table_ident), "%s.%s", db, table);
|
||||||
TABLE_CREATE *old = hashtable_fetch(router->created_tables, table_ident);
|
TABLE_CREATE *old =
|
||||||
|
static_cast<TABLE_CREATE*>(hashtable_fetch(router->created_tables, table_ident));
|
||||||
|
|
||||||
if (old == NULL || version > old->version)
|
if (old == NULL || version > old->version)
|
||||||
{
|
{
|
||||||
@ -860,7 +861,7 @@ void avro_flush_all_tables(AVRO_INSTANCE *router, enum avrorouter_file_op flush)
|
|||||||
char *key;
|
char *key;
|
||||||
while ((key = (char*)hashtable_next(iter)))
|
while ((key = (char*)hashtable_next(iter)))
|
||||||
{
|
{
|
||||||
AVRO_TABLE *table = hashtable_fetch(router->open_tables, key);
|
AVRO_TABLE *table = static_cast<AVRO_TABLE*>(hashtable_fetch(router->open_tables, key));
|
||||||
|
|
||||||
if (table)
|
if (table)
|
||||||
{
|
{
|
||||||
@ -974,18 +975,18 @@ bool save_and_replace_table_create(AVRO_INSTANCE *router, TABLE_CREATE *created)
|
|||||||
snprintf(table_ident, sizeof(table_ident), "%s.%s", created->database, created->table);
|
snprintf(table_ident, sizeof(table_ident), "%s.%s", created->database, created->table);
|
||||||
|
|
||||||
spinlock_acquire(&router->lock); // Is this necessary?
|
spinlock_acquire(&router->lock); // Is this necessary?
|
||||||
TABLE_CREATE *old = hashtable_fetch(router->created_tables, table_ident);
|
TABLE_CREATE *old = static_cast<TABLE_CREATE*>(hashtable_fetch(router->created_tables, table_ident));
|
||||||
|
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
HASHITERATOR *iter = hashtable_iterator(router->table_maps);
|
HASHITERATOR *iter = hashtable_iterator(router->table_maps);
|
||||||
|
|
||||||
char *key;
|
char *key;
|
||||||
while ((key = hashtable_next(iter)))
|
while ((key = static_cast<char*>(hashtable_next(iter))))
|
||||||
{
|
{
|
||||||
if (strcmp(key, table_ident) == 0)
|
if (strcmp(key, table_ident) == 0)
|
||||||
{
|
{
|
||||||
TABLE_MAP* map = hashtable_fetch(router->table_maps, key);
|
TABLE_MAP* map = static_cast<TABLE_MAP*>(hashtable_fetch(router->table_maps, key));
|
||||||
router->active_maps[map->id % MAX_MAPPED_TABLES] = NULL;
|
router->active_maps[map->id % MAX_MAPPED_TABLES] = NULL;
|
||||||
hashtable_delete(router->table_maps, key);
|
hashtable_delete(router->table_maps, key);
|
||||||
}
|
}
|
||||||
@ -1066,7 +1067,7 @@ void handle_query_event(AVRO_INSTANCE *router, REP_HEADER *hdr, int *pending_tra
|
|||||||
db[dblen] = 0;
|
db[dblen] = 0;
|
||||||
|
|
||||||
size_t sqlsz = len, tmpsz = len;
|
size_t sqlsz = len, tmpsz = len;
|
||||||
char *tmp = MXS_MALLOC(len + 1);
|
char *tmp = static_cast<char*>(MXS_MALLOC(len + 1));
|
||||||
MXS_ABORT_IF_NULL(tmp);
|
MXS_ABORT_IF_NULL(tmp);
|
||||||
remove_mysql_comments((const char**)&sql, &sqlsz, &tmp, &tmpsz);
|
remove_mysql_comments((const char**)&sql, &sqlsz, &tmp, &tmpsz);
|
||||||
sql = tmp;
|
sql = tmp;
|
||||||
@ -1126,7 +1127,7 @@ void handle_query_event(AVRO_INSTANCE *router, REP_HEADER *hdr, int *pending_tra
|
|||||||
}
|
}
|
||||||
else if (is_alter_table_statement(router, sql, len))
|
else if (is_alter_table_statement(router, sql, len))
|
||||||
{
|
{
|
||||||
TABLE_CREATE *created = hashtable_fetch(router->created_tables, ident);
|
TABLE_CREATE *created = static_cast<TABLE_CREATE*>(hashtable_fetch(router->created_tables, ident));
|
||||||
|
|
||||||
if (created)
|
if (created)
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ void avro_index_file(AVRO_INSTANCE *router, const char* filename)
|
|||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
char *name = strrchr(filename, '/');
|
const char *name = strrchr(filename, '/');
|
||||||
ss_dassert(name);
|
ss_dassert(name);
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
@ -194,7 +194,7 @@ void avro_update_index(AVRO_INSTANCE* router)
|
|||||||
|
|
||||||
if (glob(path, 0, NULL, &files) != GLOB_NOMATCH)
|
if (glob(path, 0, NULL, &files) != GLOB_NOMATCH)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < files.gl_pathc; i++)
|
for (size_t i = 0; i < files.gl_pathc; i++)
|
||||||
{
|
{
|
||||||
avro_index_file(router, files.gl_pathv[i]);
|
avro_index_file(router, files.gl_pathv[i]);
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ static const char *insert_sql = "INSERT OR IGNORE INTO "MEMORY_TABLE_NAME
|
|||||||
* @param router Avro router instance
|
* @param router Avro router instance
|
||||||
* @param table Table to add
|
* @param table Table to add
|
||||||
*/
|
*/
|
||||||
void add_used_table(AVRO_INSTANCE* router, char* table)
|
void add_used_table(AVRO_INSTANCE* router, const char* table)
|
||||||
{
|
{
|
||||||
char sql[AVRO_SQL_BUFFER_SIZE], *errmsg;
|
char sql[AVRO_SQL_BUFFER_SIZE], *errmsg;
|
||||||
snprintf(sql, sizeof(sql), insert_sql, router->gtid.domain, router->gtid.server_id,
|
snprintf(sql, sizeof(sql), insert_sql, router->gtid.domain, router->gtid.server_id,
|
||||||
@ -100,12 +100,12 @@ bool handle_table_map_event(AVRO_INSTANCE *router, REP_HEADER *hdr, uint8_t *ptr
|
|||||||
int ev_len = router->event_type_hdr_lens[hdr->event_type];
|
int ev_len = router->event_type_hdr_lens[hdr->event_type];
|
||||||
|
|
||||||
read_table_info(ptr, ev_len, &id, table_ident, sizeof(table_ident));
|
read_table_info(ptr, ev_len, &id, table_ident, sizeof(table_ident));
|
||||||
TABLE_CREATE* create = hashtable_fetch(router->created_tables, table_ident);
|
TABLE_CREATE* create = static_cast<TABLE_CREATE*>(hashtable_fetch(router->created_tables, table_ident));
|
||||||
|
|
||||||
if (create)
|
if (create)
|
||||||
{
|
{
|
||||||
ss_dassert(create->columns > 0);
|
ss_dassert(create->columns > 0);
|
||||||
TABLE_MAP *old = hashtable_fetch(router->table_maps, table_ident);
|
TABLE_MAP *old = static_cast<TABLE_MAP*>(hashtable_fetch(router->table_maps, table_ident));
|
||||||
TABLE_MAP *map = table_map_alloc(ptr, ev_len, create);
|
TABLE_MAP *map = table_map_alloc(ptr, ev_len, create);
|
||||||
MXS_ABORT_IF_NULL(map); // Fatal error at this point
|
MXS_ABORT_IF_NULL(map); // Fatal error at this point
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ bool handle_row_event(AVRO_INSTANCE *router, REP_HEADER *hdr, uint8_t *ptr)
|
|||||||
{
|
{
|
||||||
char table_ident[MYSQL_TABLE_MAXLEN + MYSQL_DATABASE_MAXLEN + 2];
|
char table_ident[MYSQL_TABLE_MAXLEN + MYSQL_DATABASE_MAXLEN + 2];
|
||||||
snprintf(table_ident, sizeof(table_ident), "%s.%s", map->database, map->table);
|
snprintf(table_ident, sizeof(table_ident), "%s.%s", map->database, map->table);
|
||||||
AVRO_TABLE* table = hashtable_fetch(router->open_tables, table_ident);
|
AVRO_TABLE* table = static_cast<AVRO_TABLE*>(hashtable_fetch(router->open_tables, table_ident));
|
||||||
TABLE_CREATE* create = map->table_create;
|
TABLE_CREATE* create = map->table_create;
|
||||||
ss_dassert(hashtable_fetch(router->created_tables, table_ident) == create);
|
ss_dassert(hashtable_fetch(router->created_tables, table_ident) == create);
|
||||||
|
|
||||||
@ -642,9 +642,9 @@ int count_columns(const char* ptr)
|
|||||||
static int process_column_definition(const char *nameptr, char*** dest, char*** dest_types, int** dest_lens)
|
static int process_column_definition(const char *nameptr, char*** dest, char*** dest_types, int** dest_lens)
|
||||||
{
|
{
|
||||||
int n = count_columns(nameptr);
|
int n = count_columns(nameptr);
|
||||||
*dest = MXS_MALLOC(sizeof(char*) * n);
|
*dest = static_cast<char**>(MXS_MALLOC(sizeof(char*) * n));
|
||||||
*dest_types = MXS_MALLOC(sizeof(char*) * n);
|
*dest_types = static_cast<char**>(MXS_MALLOC(sizeof(char*) * n));
|
||||||
*dest_lens = MXS_MALLOC(sizeof(int) * n);
|
*dest_lens = static_cast<int*>(MXS_MALLOC(sizeof(int) * n));
|
||||||
|
|
||||||
char **names = *dest;
|
char **names = *dest;
|
||||||
char **types = *dest_types;
|
char **types = *dest_types;
|
||||||
@ -727,7 +727,7 @@ int resolve_table_version(const char* db, const char* table)
|
|||||||
*
|
*
|
||||||
* @return New CREATE_TABLE object or NULL if an error occurred
|
* @return New CREATE_TABLE object or NULL if an error occurred
|
||||||
*/
|
*/
|
||||||
TABLE_CREATE* table_create_alloc(const char* ident, const char* sql, int len)
|
TABLE_CREATE* table_create_alloc(char* ident, const char* sql, int len)
|
||||||
{
|
{
|
||||||
/** Extract the table definition so we can get the column names from it */
|
/** Extract the table definition so we can get the column names from it */
|
||||||
int stmt_len = 0;
|
int stmt_len = 0;
|
||||||
@ -753,7 +753,7 @@ TABLE_CREATE* table_create_alloc(const char* ident, const char* sql, int len)
|
|||||||
TABLE_CREATE *rval = NULL;
|
TABLE_CREATE *rval = NULL;
|
||||||
if (n_columns > 0)
|
if (n_columns > 0)
|
||||||
{
|
{
|
||||||
if ((rval = MXS_MALLOC(sizeof(TABLE_CREATE))))
|
if ((rval = static_cast<TABLE_CREATE*>(MXS_MALLOC(sizeof(TABLE_CREATE)))))
|
||||||
{
|
{
|
||||||
rval->version = resolve_table_version(database, table);
|
rval->version = resolve_table_version(database, table);
|
||||||
rval->was_used = false;
|
rval->was_used = false;
|
||||||
@ -990,15 +990,15 @@ TABLE_CREATE* table_create_copy(AVRO_INSTANCE *router, const char* sql, size_t l
|
|||||||
|
|
||||||
strcat(table_ident, source);
|
strcat(table_ident, source);
|
||||||
|
|
||||||
TABLE_CREATE *old = hashtable_fetch(router->created_tables, table_ident);
|
TABLE_CREATE *old = static_cast<TABLE_CREATE*>(hashtable_fetch(router->created_tables, table_ident));
|
||||||
|
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
int n = old->columns;
|
int n = old->columns;
|
||||||
char** names = MXS_MALLOC(sizeof(char*) * n);
|
char** names = static_cast<char**>(MXS_MALLOC(sizeof(char*) * n));
|
||||||
char** types = MXS_MALLOC(sizeof(char*) * n);
|
char** types = static_cast<char**>(MXS_MALLOC(sizeof(char*) * n));
|
||||||
int* lengths = MXS_MALLOC(sizeof(int) * n);
|
int* lengths = static_cast<int*>(MXS_MALLOC(sizeof(int) * n));
|
||||||
rval = MXS_MALLOC(sizeof(TABLE_CREATE));
|
rval = static_cast<TABLE_CREATE*>(MXS_MALLOC(sizeof(TABLE_CREATE)));
|
||||||
|
|
||||||
MXS_ABORT_IF_FALSE(names && types && lengths && rval);
|
MXS_ABORT_IF_FALSE(names && types && lengths && rval);
|
||||||
|
|
||||||
@ -1402,7 +1402,7 @@ int get_column_index(TABLE_CREATE *create, const char *tok, int len)
|
|||||||
|
|
||||||
fix_reserved_word(safe_tok);
|
fix_reserved_word(safe_tok);
|
||||||
|
|
||||||
for (int x = 0; x < create->columns; x++)
|
for (size_t x = 0; x < create->columns; x++)
|
||||||
{
|
{
|
||||||
if (strcasecmp(create->column_names[x], safe_tok) == 0)
|
if (strcasecmp(create->column_names[x], safe_tok) == 0)
|
||||||
{
|
{
|
||||||
@ -1496,9 +1496,15 @@ bool table_create_alter(TABLE_CREATE *create, const char *sql, const char *end)
|
|||||||
|
|
||||||
if (is_new)
|
if (is_new)
|
||||||
{
|
{
|
||||||
create->column_names = MXS_REALLOC(create->column_names, sizeof(char*) * (create->columns + 1));
|
create->column_names =
|
||||||
create->column_types = MXS_REALLOC(create->column_types, sizeof(char*) * (create->columns + 1));
|
static_cast<char**>(MXS_REALLOC(create->column_names,
|
||||||
create->column_lengths = MXS_REALLOC(create->column_lengths, sizeof(int) * (create->columns + 1));
|
sizeof(char*) * (create->columns + 1)));
|
||||||
|
create->column_types =
|
||||||
|
static_cast<char**>(MXS_REALLOC(create->column_types,
|
||||||
|
sizeof(char*) * (create->columns + 1)));
|
||||||
|
create->column_lengths =
|
||||||
|
static_cast<int*>(MXS_REALLOC(create->column_lengths,
|
||||||
|
sizeof(int) * (create->columns + 1)));
|
||||||
|
|
||||||
char field_type[200] = ""; // Enough to hold all types
|
char field_type[200] = ""; // Enough to hold all types
|
||||||
int field_length = extract_type_length(tok + len, field_type);
|
int field_length = extract_type_length(tok + len, field_type);
|
||||||
@ -1526,9 +1532,15 @@ bool table_create_alter(TABLE_CREATE *create, const char *sql, const char *end)
|
|||||||
create->column_lengths[i] = create->column_lengths[i + 1];
|
create->column_lengths[i] = create->column_lengths[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
create->column_names = MXS_REALLOC(create->column_names, sizeof(char*) * (create->columns - 1));
|
create->column_names =
|
||||||
create->column_types = MXS_REALLOC(create->column_types, sizeof(char*) * (create->columns - 1));
|
static_cast<char**>(MXS_REALLOC(create->column_names,
|
||||||
create->column_lengths = MXS_REALLOC(create->column_lengths, sizeof(int) * (create->columns - 1));
|
sizeof(char*) * (create->columns - 1)));
|
||||||
|
create->column_types =
|
||||||
|
static_cast<char**>(MXS_REALLOC(create->column_types,
|
||||||
|
sizeof(char*) * (create->columns - 1)));
|
||||||
|
create->column_lengths =
|
||||||
|
static_cast<int*>(MXS_REALLOC(create->column_lengths,
|
||||||
|
sizeof(int) * (create->columns - 1)));
|
||||||
create->columns--;
|
create->columns--;
|
||||||
updates++;
|
updates++;
|
||||||
}
|
}
|
||||||
@ -1657,7 +1669,7 @@ TABLE_MAP *table_map_alloc(uint8_t *ptr, uint8_t hdr_len, TABLE_CREATE* create)
|
|||||||
uint8_t* metadata = (uint8_t*)mxs_lestr_consume(&ptr, &metadata_size);
|
uint8_t* metadata = (uint8_t*)mxs_lestr_consume(&ptr, &metadata_size);
|
||||||
uint8_t *nullmap = ptr;
|
uint8_t *nullmap = ptr;
|
||||||
size_t nullmap_size = (column_count + 7) / 8;
|
size_t nullmap_size = (column_count + 7) / 8;
|
||||||
TABLE_MAP *map = MXS_MALLOC(sizeof(TABLE_MAP));
|
TABLE_MAP *map = static_cast<TABLE_MAP*>(MXS_MALLOC(sizeof(TABLE_MAP)));
|
||||||
|
|
||||||
if (map)
|
if (map)
|
||||||
{
|
{
|
||||||
@ -1665,11 +1677,11 @@ TABLE_MAP *table_map_alloc(uint8_t *ptr, uint8_t hdr_len, TABLE_CREATE* create)
|
|||||||
map->version = create->version;
|
map->version = create->version;
|
||||||
map->flags = flags;
|
map->flags = flags;
|
||||||
map->columns = column_count;
|
map->columns = column_count;
|
||||||
map->column_types = MXS_MALLOC(column_count);
|
map->column_types = static_cast<uint8_t*>(MXS_MALLOC(column_count));
|
||||||
/** Allocate at least one byte for the metadata */
|
/** Allocate at least one byte for the metadata */
|
||||||
map->column_metadata = MXS_CALLOC(1, metadata_size + 1);
|
map->column_metadata = static_cast<uint8_t*>(MXS_CALLOC(1, metadata_size + 1));
|
||||||
map->column_metadata_size = metadata_size;
|
map->column_metadata_size = metadata_size;
|
||||||
map->null_bitmap = MXS_MALLOC(nullmap_size);
|
map->null_bitmap = static_cast<uint8_t*>(MXS_MALLOC(nullmap_size));
|
||||||
map->database = MXS_STRDUP(schema_name);
|
map->database = MXS_STRDUP(schema_name);
|
||||||
map->table = MXS_STRDUP(table_name);
|
map->table = MXS_STRDUP(table_name);
|
||||||
map->table_create = create;
|
map->table_create = create;
|
||||||
@ -73,8 +73,8 @@ MXS_BEGIN_DECLS
|
|||||||
#define AVRO_MAX_FILENAME_LEN 255
|
#define AVRO_MAX_FILENAME_LEN 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *avro_client_states[] = { "Unregistered", "Registered", "Processing", "Errored" };
|
static const char *avro_client_states[] = { "Unregistered", "Registered", "Processing", "Errored" };
|
||||||
static char *avro_client_client_mode[] = { "Catch-up", "Busy", "Wait_for_data" };
|
static const char *avro_client_client_mode[] = { "Catch-up", "Busy", "Wait_for_data" };
|
||||||
|
|
||||||
static const char *avro_domain = "domain";
|
static const char *avro_domain = "domain";
|
||||||
static const char *avro_server_id = "server_id";
|
static const char *avro_server_id = "server_id";
|
||||||
@ -82,7 +82,7 @@ static const char *avro_sequence = "sequence";
|
|||||||
static const char *avro_event_number = "event_number";
|
static const char *avro_event_number = "event_number";
|
||||||
static const char *avro_event_type = "event_type";
|
static const char *avro_event_type = "event_type";
|
||||||
static const char *avro_timestamp = "timestamp";
|
static const char *avro_timestamp = "timestamp";
|
||||||
static char *avro_client_ouput[] = { "Undefined", "JSON", "Avro" };
|
static const char *avro_client_ouput[] = { "Undefined", "JSON", "Avro" };
|
||||||
|
|
||||||
static inline bool is_reserved_word(const char* word)
|
static inline bool is_reserved_word(const char* word)
|
||||||
{
|
{
|
||||||
@ -310,7 +310,7 @@ extern void read_table_info(uint8_t *ptr, uint8_t post_header_len, uint64_t *tab
|
|||||||
char* dest, size_t len);
|
char* dest, size_t len);
|
||||||
extern TABLE_MAP *table_map_alloc(uint8_t *ptr, uint8_t hdr_len, TABLE_CREATE* create);
|
extern TABLE_MAP *table_map_alloc(uint8_t *ptr, uint8_t hdr_len, TABLE_CREATE* create);
|
||||||
extern void table_map_free(TABLE_MAP *map);
|
extern void table_map_free(TABLE_MAP *map);
|
||||||
extern TABLE_CREATE* table_create_alloc(const char* ident, const char* sql, int len);
|
extern TABLE_CREATE* table_create_alloc(char* ident, const char* sql, int len);
|
||||||
extern TABLE_CREATE* table_create_copy(AVRO_INSTANCE *router, const char* sql, size_t len, const char* db);
|
extern TABLE_CREATE* table_create_copy(AVRO_INSTANCE *router, const char* sql, size_t len, const char* db);
|
||||||
extern void table_create_free(TABLE_CREATE* value);
|
extern void table_create_free(TABLE_CREATE* value);
|
||||||
extern bool table_create_save(TABLE_CREATE *create, const char *filename);
|
extern bool table_create_save(TABLE_CREATE *create, const char *filename);
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
add_executable(test_alter_parsing test_alter_parsing.c)
|
add_executable(test_alter_parsing test_alter_parsing.cc)
|
||||||
target_link_libraries(test_alter_parsing maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro sqlite3 lzma)
|
target_link_libraries(test_alter_parsing maxscale-common ${JANSSON_LIBRARIES} ${AVRO_LIBRARIES} maxavro sqlite3 lzma)
|
||||||
add_test(test_alter_parsing test_alter_parsing)
|
add_test(test_alter_parsing test_alter_parsing)
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "../avro_schema.c"
|
#include "../avro_schema.cc"
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
@ -1,10 +1,10 @@
|
|||||||
add_library(binlogrouter SHARED blr.c blr_master.c blr_cache.c blr_slave.c blr_file.c)
|
add_library(binlogrouter SHARED blr.cc blr_master.cc blr_cache.cc blr_slave.cc blr_file.cc)
|
||||||
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "2.0.0")
|
set_target_properties(binlogrouter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "2.0.0")
|
||||||
set_target_properties(binlogrouter PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
set_target_properties(binlogrouter PROPERTIES LINK_FLAGS -Wl,-z,defs)
|
||||||
target_link_libraries(binlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
target_link_libraries(binlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
||||||
install_module(binlogrouter core)
|
install_module(binlogrouter core)
|
||||||
|
|
||||||
add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master.c blr_slave.c blr.c)
|
add_executable(maxbinlogcheck maxbinlogcheck.cc blr_file.cc blr_cache.cc blr_master.cc blr_slave.cc blr.cc)
|
||||||
target_link_libraries(maxbinlogcheck maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
target_link_libraries(maxbinlogcheck maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
||||||
|
|
||||||
install_executable(maxbinlogcheck core)
|
install_executable(maxbinlogcheck core)
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
int blr_file_get_next_binlogname(const char *binlog_name)
|
int blr_file_get_next_binlogname(const char *binlog_name)
|
||||||
{
|
{
|
||||||
char *sptr;
|
const char *sptr;
|
||||||
int filenum;
|
int filenum;
|
||||||
|
|
||||||
if ((sptr = strrchr(binlog_name, '.')) == NULL)
|
if ((sptr = strrchr(binlog_name, '.')) == NULL)
|
||||||
@ -72,7 +72,7 @@ bool binlog_next_file_exists(const char* binlogdir, const char* binlog)
|
|||||||
|
|
||||||
if (filenum)
|
if (filenum)
|
||||||
{
|
{
|
||||||
char *sptr = strrchr(binlog, '.');
|
const char *sptr = strrchr(binlog, '.');
|
||||||
|
|
||||||
if (sptr)
|
if (sptr)
|
||||||
{
|
{
|
||||||
@ -135,7 +135,7 @@ static const MXS_ENUM_VALUE binlog_storage_values[] =
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise binlog router module.");
|
MXS_NOTICE("Initialise binlog router module.");
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
@ -810,7 +810,8 @@ createInstance(SERVICE *service, char **options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate SSL struct for backend connection */
|
/* Allocate SSL struct for backend connection */
|
||||||
if ((ssl_cfg = MXS_CALLOC(1, sizeof(SSL_LISTENER))) == NULL)
|
if ((ssl_cfg =
|
||||||
|
static_cast<SSL_LISTENER*>(MXS_CALLOC(1, sizeof(SSL_LISTENER)))) == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Error allocating memory for SSL struct in createInstance",
|
MXS_ERROR("%s: Error allocating memory for SSL struct in createInstance",
|
||||||
inst->service->name);
|
inst->service->name);
|
||||||
@ -1236,7 +1237,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
|
|
||||||
CHK_CLIENT_RSES(slave);
|
CHK_CLIENT_RSES(slave);
|
||||||
|
|
||||||
return (void *)slave;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(slave);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1417,7 +1418,7 @@ routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queu
|
|||||||
return blr_slave_request(router, slave, queue);
|
return blr_slave_request(router, slave, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *event_names[] =
|
static const char *event_names[] =
|
||||||
{
|
{
|
||||||
"Invalid", "Start Event V3", "Query Event", "Stop Event", "Rotate Event",
|
"Invalid", "Start Event V3", "Query Event", "Stop Event", "Rotate Event",
|
||||||
"Integer Session Variable", "Load Event", "Slave Event", "Create File Event",
|
"Integer Session Variable", "Load Event", "Slave Event", "Create File Event",
|
||||||
@ -1433,7 +1434,7 @@ static char *event_names[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* New MariaDB event numbers starts from 0xa0 */
|
/* New MariaDB event numbers starts from 0xa0 */
|
||||||
static char *event_names_mariadb10[] =
|
static const char *event_names_mariadb10[] =
|
||||||
{
|
{
|
||||||
"Annotate Rows Event",
|
"Annotate Rows Event",
|
||||||
/* New MariaDB 10.x event numbers */
|
/* New MariaDB 10.x event numbers */
|
||||||
@ -1641,7 +1642,7 @@ diagnostics(MXS_ROUTER *router, DCB *dcb)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *ptr = NULL;
|
const char *ptr = NULL;
|
||||||
if (router_inst->lastEventReceived <= MAX_EVENT_TYPE)
|
if (router_inst->lastEventReceived <= MAX_EVENT_TYPE)
|
||||||
{
|
{
|
||||||
ptr = event_names[router_inst->lastEventReceived];
|
ptr = event_names[router_inst->lastEventReceived];
|
||||||
@ -2061,7 +2062,7 @@ static json_t* diagnostics_json(const MXS_ROUTER *router)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *ptr = NULL;
|
const char *ptr = NULL;
|
||||||
if (router_inst->lastEventReceived <= MAX_EVENT_TYPE)
|
if (router_inst->lastEventReceived <= MAX_EVENT_TYPE)
|
||||||
{
|
{
|
||||||
ptr = event_names[router_inst->lastEventReceived];
|
ptr = event_names[router_inst->lastEventReceived];
|
||||||
@ -2623,7 +2624,7 @@ blr_send_custom_error(DCB *dcb,
|
|||||||
int packet_number,
|
int packet_number,
|
||||||
int affected_rows,
|
int affected_rows,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
char *statemsg,
|
const char *statemsg,
|
||||||
unsigned int errcode)
|
unsigned int errcode)
|
||||||
{
|
{
|
||||||
uint8_t *outbuf = NULL;
|
uint8_t *outbuf = NULL;
|
||||||
@ -2967,10 +2968,10 @@ static int blr_check_binlog(ROUTER_INSTANCE *router)
|
|||||||
* @param router The router instance
|
* @param router The router instance
|
||||||
* @return The event description or NULL
|
* @return The event description or NULL
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
blr_last_event_description(ROUTER_INSTANCE *router)
|
blr_last_event_description(ROUTER_INSTANCE *router)
|
||||||
{
|
{
|
||||||
char *event_desc = NULL;
|
const char *event_desc = NULL;
|
||||||
|
|
||||||
if (!router->mariadb10_compat)
|
if (!router->mariadb10_compat)
|
||||||
{
|
{
|
||||||
@ -3006,10 +3007,10 @@ blr_last_event_description(ROUTER_INSTANCE *router)
|
|||||||
* @param event The current event
|
* @param event The current event
|
||||||
* @return The event description or NULL
|
* @return The event description or NULL
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
blr_get_event_description(ROUTER_INSTANCE *router, uint8_t event)
|
blr_get_event_description(ROUTER_INSTANCE *router, uint8_t event)
|
||||||
{
|
{
|
||||||
char *event_desc = NULL;
|
const char *event_desc = NULL;
|
||||||
|
|
||||||
if (!router->mariadb10_compat)
|
if (!router->mariadb10_compat)
|
||||||
{
|
{
|
||||||
@ -473,6 +473,23 @@ typedef enum blr_thread_role
|
|||||||
r == BLR_THREAD_ROLE_MASTER_NOTRX ? "master (no trx)" : \
|
r == BLR_THREAD_ROLE_MASTER_NOTRX ? "master (no trx)" : \
|
||||||
r == BLR_THREAD_ROLE_MASTER_TRX ? "master (trx)" : "slave"
|
r == BLR_THREAD_ROLE_MASTER_TRX ? "master (trx)" : "slave"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binlog encryption context of slave binlog file
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct slave_encryption_ctx
|
||||||
|
{
|
||||||
|
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
||||||
|
uint32_t binlog_key_version; /**< Encryption key version */
|
||||||
|
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
||||||
|
* These bytes + the binlog event current pos
|
||||||
|
* form the encrryption IV for the event */
|
||||||
|
char *log_file; /**< The log file the client has requested */
|
||||||
|
uint32_t first_enc_event_pos; /**< The position of first encrypted event
|
||||||
|
* It's the first event afte Start_encryption_event
|
||||||
|
* which is after FDE */
|
||||||
|
} SLAVE_ENCRYPTION_CTX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client session structure used within this router. This represents
|
* The client session structure used within this router. This represents
|
||||||
* the slaves that are replicating binlogs from MaxScale.
|
* the slaves that are replicating binlogs from MaxScale.
|
||||||
@ -525,7 +542,7 @@ typedef struct router_slave
|
|||||||
/*< Which binlog file */
|
/*< Which binlog file */
|
||||||
uint32_t lsi_binlog_pos;
|
uint32_t lsi_binlog_pos;
|
||||||
/*< What position */
|
/*< What position */
|
||||||
void *encryption_ctx;
|
SLAVE_ENCRYPTION_CTX *encryption_ctx;
|
||||||
/*< Encryption context */
|
/*< Encryption context */
|
||||||
bool gtid_strict_mode;
|
bool gtid_strict_mode;
|
||||||
/*< MariaDB 10 Slave sets gtid_strict_mode */
|
/*< MariaDB 10 Slave sets gtid_strict_mode */
|
||||||
@ -631,6 +648,20 @@ typedef struct pending_transaction
|
|||||||
*/
|
*/
|
||||||
} PENDING_TRANSACTION;
|
} PENDING_TRANSACTION;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binlog encryption context of binlog file
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct binlog_encryption_ctx
|
||||||
|
{
|
||||||
|
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
||||||
|
uint32_t binlog_key_version; /**< Encryption key version */
|
||||||
|
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
||||||
|
* These bytes + the binlog event current pos
|
||||||
|
* form the encrryption IV for the event */
|
||||||
|
char *binlog_file; /**< Current binlog file being encrypted */
|
||||||
|
} BINLOG_ENCRYPTION_CTX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The per instance data for the router.
|
* The per instance data for the router.
|
||||||
*/
|
*/
|
||||||
@ -718,7 +749,7 @@ typedef struct router_instance
|
|||||||
bool request_semi_sync; /*< Request Semi-Sync replication to master */
|
bool request_semi_sync; /*< Request Semi-Sync replication to master */
|
||||||
int master_semi_sync; /*< Semi-Sync replication status of master server */
|
int master_semi_sync; /*< Semi-Sync replication status of master server */
|
||||||
BINLOG_ENCRYPTION_SETUP encryption; /*< Binlog encryption setup */
|
BINLOG_ENCRYPTION_SETUP encryption; /*< Binlog encryption setup */
|
||||||
void *encryption_ctx; /*< Encryption context */
|
BINLOG_ENCRYPTION_CTX *encryption_ctx; /*< Encryption context */
|
||||||
char last_mariadb_gtid[GTID_MAX_LEN + 1];
|
char last_mariadb_gtid[GTID_MAX_LEN + 1];
|
||||||
/*< Last seen MariaDB 10 GTID */
|
/*< Last seen MariaDB 10 GTID */
|
||||||
bool mariadb10_gtid; /*< Save received MariaDB GTIDs into repo.
|
bool mariadb10_gtid; /*< Save received MariaDB GTIDs into repo.
|
||||||
@ -735,37 +766,6 @@ typedef struct router_instance
|
|||||||
struct router_instance *next;
|
struct router_instance *next;
|
||||||
} ROUTER_INSTANCE;
|
} ROUTER_INSTANCE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Binlog encryption context of slave binlog file
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct slave_encryption_ctx
|
|
||||||
{
|
|
||||||
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
|
||||||
uint32_t binlog_key_version; /**< Encryption key version */
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
|
||||||
* These bytes + the binlog event current pos
|
|
||||||
* form the encrryption IV for the event */
|
|
||||||
char *log_file; /**< The log file the client has requested */
|
|
||||||
uint32_t first_enc_event_pos; /**< The position of first encrypted event
|
|
||||||
* It's the first event afte Start_encryption_event
|
|
||||||
* which is after FDE */
|
|
||||||
} SLAVE_ENCRYPTION_CTX;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Binlog encryption context of binlog file
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct binlog_encryption_ctx
|
|
||||||
{
|
|
||||||
uint8_t binlog_crypto_scheme; /**< Encryption scheme */
|
|
||||||
uint32_t binlog_key_version; /**< Encryption key version */
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE]; /**< nonce (random bytes) of current binlog.
|
|
||||||
* These bytes + the binlog event current pos
|
|
||||||
* form the encrryption IV for the event */
|
|
||||||
char *binlog_file; /**< Current binlog file being encrypted */
|
|
||||||
} BINLOG_ENCRYPTION_CTX;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds information about:
|
* Holds information about:
|
||||||
* truncating a corrupted file
|
* truncating a corrupted file
|
||||||
@ -848,7 +848,7 @@ typedef struct binlog_pos_fix
|
|||||||
|
|
||||||
#define BLRM_MAXSTATE 0x0023
|
#define BLRM_MAXSTATE 0x0023
|
||||||
|
|
||||||
static char *blrm_states[] =
|
static const char *blrm_states[] =
|
||||||
{
|
{
|
||||||
"Unconfigured",
|
"Unconfigured",
|
||||||
"Unconnected",
|
"Unconnected",
|
||||||
@ -896,7 +896,7 @@ static char *blrm_states[] =
|
|||||||
|
|
||||||
#define BLRS_MAXSTATE 0x0004
|
#define BLRS_MAXSTATE 0x0004
|
||||||
|
|
||||||
static char *blrs_states[] =
|
static const char *blrs_states[] =
|
||||||
{
|
{
|
||||||
"Created",
|
"Created",
|
||||||
"Unregistered",
|
"Unregistered",
|
||||||
@ -987,7 +987,7 @@ extern int blr_send_custom_error(DCB *,
|
|||||||
int,
|
int,
|
||||||
int,
|
int,
|
||||||
const char *,
|
const char *,
|
||||||
char *,
|
const char *,
|
||||||
unsigned int);
|
unsigned int);
|
||||||
extern int blr_file_next_exists(ROUTER_INSTANCE *,
|
extern int blr_file_next_exists(ROUTER_INSTANCE *,
|
||||||
ROUTER_SLAVE *,
|
ROUTER_SLAVE *,
|
||||||
@ -996,10 +996,10 @@ uint32_t extract_field(uint8_t *src, int bits);
|
|||||||
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
||||||
int blr_read_events_all_events(ROUTER_INSTANCE *, BINLOG_FILE_FIX *, int);
|
int blr_read_events_all_events(ROUTER_INSTANCE *, BINLOG_FILE_FIX *, int);
|
||||||
int blr_save_dbusers(const ROUTER_INSTANCE *router);
|
int blr_save_dbusers(const ROUTER_INSTANCE *router);
|
||||||
char *blr_get_event_description(ROUTER_INSTANCE *router, uint8_t event);
|
const char *blr_get_event_description(ROUTER_INSTANCE *router, uint8_t event);
|
||||||
void blr_file_append(ROUTER_INSTANCE *router, char *file);
|
void blr_file_append(ROUTER_INSTANCE *router, char *file);
|
||||||
void blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf);
|
void blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf);
|
||||||
char * blr_last_event_description(ROUTER_INSTANCE *router);
|
const char *blr_last_event_description(ROUTER_INSTANCE *router);
|
||||||
void blr_free_ssl_data(ROUTER_INSTANCE *inst);
|
void blr_free_ssl_data(ROUTER_INSTANCE *inst);
|
||||||
|
|
||||||
extern bool blr_send_event(blr_thread_role_t role,
|
extern bool blr_send_event(blr_thread_role_t role,
|
||||||
|
|||||||
@ -130,7 +130,7 @@ static const char blr_encryption_algorithm_list_names[] = "aes_cbc";
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int blr_file_create(ROUTER_INSTANCE *router, char *file);
|
static int blr_file_create(ROUTER_INSTANCE *router, char *file);
|
||||||
static void blr_log_header(int priority, char *msg, uint8_t *ptr);
|
static void blr_log_header(int priority, const char *msg, uint8_t *ptr);
|
||||||
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
void blr_cache_read_master_data(ROUTER_INSTANCE *router);
|
||||||
int blr_file_get_next_binlogname(ROUTER_INSTANCE *router);
|
int blr_file_get_next_binlogname(ROUTER_INSTANCE *router);
|
||||||
int blr_file_new_binlog(ROUTER_INSTANCE *router, char *file);
|
int blr_file_new_binlog(ROUTER_INSTANCE *router, char *file);
|
||||||
@ -737,7 +737,7 @@ blr_write_binlog_record(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check write operation result*/
|
/* Check write operation result*/
|
||||||
if (n != size)
|
if (n != static_cast<int>(size))
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
|
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
|
||||||
"Truncating to previous record.",
|
"Truncating to previous record.",
|
||||||
@ -1275,7 +1275,7 @@ blr_read_binlog(ROUTER_INSTANCE *router,
|
|||||||
&data[BINLOG_EVENT_HDR_LEN],
|
&data[BINLOG_EVENT_HDR_LEN],
|
||||||
hdr->event_size - BINLOG_EVENT_HDR_LEN,
|
hdr->event_size - BINLOG_EVENT_HDR_LEN,
|
||||||
pos + BINLOG_EVENT_HDR_LEN))
|
pos + BINLOG_EVENT_HDR_LEN))
|
||||||
!= hdr->event_size - BINLOG_EVENT_HDR_LEN) // Read the balance
|
!= static_cast<ssize_t>(hdr->event_size - BINLOG_EVENT_HDR_LEN)) // Read the balance
|
||||||
{
|
{
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
@ -1447,7 +1447,7 @@ blr_close_binlog(ROUTER_INSTANCE *router, BLFILE *file)
|
|||||||
* @param ptr The event header raw data
|
* @param ptr The event header raw data
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
blr_log_header(int priority, char *msg, uint8_t *ptr)
|
blr_log_header(int priority, const char *msg, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
char buf[400], *bufp;
|
char buf[400], *bufp;
|
||||||
int i;
|
int i;
|
||||||
@ -1551,7 +1551,7 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
|
|||||||
* @return A pointer to a GWBUF structure
|
* @return A pointer to a GWBUF structure
|
||||||
*/
|
*/
|
||||||
GWBUF *
|
GWBUF *
|
||||||
blr_cache_read_response(ROUTER_INSTANCE *router, char *response)
|
blr_cache_read_response(ROUTER_INSTANCE *router, const char *response)
|
||||||
{
|
{
|
||||||
static const char CACHE[] = "/cache";
|
static const char CACHE[] = "/cache";
|
||||||
size_t len = strlen(router->binlogdir) +
|
size_t len = strlen(router->binlogdir) +
|
||||||
@ -2127,10 +2127,11 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
|||||||
memcpy(data, hdbuf, BINLOG_EVENT_HDR_LEN);// Copy the header in
|
memcpy(data, hdbuf, BINLOG_EVENT_HDR_LEN);// Copy the header in
|
||||||
|
|
||||||
/* Read event data */
|
/* Read event data */
|
||||||
if ((n = pread(router->binlog_fd,
|
n = pread(router->binlog_fd,
|
||||||
&data[BINLOG_EVENT_HDR_LEN],
|
&data[BINLOG_EVENT_HDR_LEN],
|
||||||
hdr.event_size - BINLOG_EVENT_HDR_LEN,
|
hdr.event_size - BINLOG_EVENT_HDR_LEN,
|
||||||
pos + BINLOG_EVENT_HDR_LEN)) != hdr.event_size - BINLOG_EVENT_HDR_LEN)
|
pos + BINLOG_EVENT_HDR_LEN);
|
||||||
|
if (n != static_cast<ssize_t>(hdr.event_size - BINLOG_EVENT_HDR_LEN))
|
||||||
{
|
{
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
{
|
{
|
||||||
@ -2359,7 +2360,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
|||||||
|
|
||||||
if ((debug & BLR_REPORT_REP_HEADER))
|
if ((debug & BLR_REPORT_REP_HEADER))
|
||||||
{
|
{
|
||||||
char *event_desc = blr_get_event_description(router, hdr.event_type);
|
const char *event_desc = blr_get_event_description(router, hdr.event_type);
|
||||||
MXS_DEBUG("%8s==== Event Header ====\n%39sEvent Pos %lu\n%39sEvent time %lu\n%39s"
|
MXS_DEBUG("%8s==== Event Header ====\n%39sEvent Pos %lu\n%39sEvent time %lu\n%39s"
|
||||||
"Event size %lu\n%39sEvent Type %u (%s)\n%39s"
|
"Event size %lu\n%39sEvent Type %u (%s)\n%39s"
|
||||||
"Server Id %lu\n%39sNextPos %lu\n%39sFlags %u",
|
"Server Id %lu\n%39sNextPos %lu\n%39sFlags %u",
|
||||||
@ -2392,7 +2393,9 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char nonce_hex[AES_BLOCK_SIZE * 2 + 1] = "";
|
char nonce_hex[AES_BLOCK_SIZE * 2 + 1] = "";
|
||||||
START_ENCRYPTION_EVENT ste_event = {};
|
START_ENCRYPTION_EVENT ste_event = {};
|
||||||
BINLOG_ENCRYPTION_CTX *new_encryption_ctx = MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX));
|
void *mem = MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX));
|
||||||
|
BINLOG_ENCRYPTION_CTX *new_encryption_ctx =
|
||||||
|
static_cast<BINLOG_ENCRYPTION_CTX*>(mem);
|
||||||
|
|
||||||
if (new_encryption_ctx == NULL)
|
if (new_encryption_ctx == NULL)
|
||||||
{
|
{
|
||||||
@ -2516,7 +2519,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
|||||||
action->pos > 4 &&
|
action->pos > 4 &&
|
||||||
(pos == action->pos || replace_trx_events))
|
(pos == action->pos || replace_trx_events))
|
||||||
{
|
{
|
||||||
char *event_desc = blr_get_event_description(router, hdr.event_type);
|
const char *event_desc = blr_get_event_description(router, hdr.event_type);
|
||||||
|
|
||||||
if (action->replace_trx && !replace_trx_events)
|
if (action->replace_trx && !replace_trx_events)
|
||||||
{
|
{
|
||||||
@ -2742,7 +2745,7 @@ blr_read_events_all_events(ROUTER_INSTANCE *router,
|
|||||||
BINLOG_EVENT_HDR_LEN -
|
BINLOG_EVENT_HDR_LEN -
|
||||||
(4 + 4 + 1 + 2 + 2 + var_block_len + 1 + db_name_len);
|
(4 + 4 + 1 + 2 + 2 + var_block_len + 1 + db_name_len);
|
||||||
|
|
||||||
statement_sql = MXS_CALLOC(1, statement_len + 1);
|
statement_sql = static_cast<char*>(MXS_CALLOC(1, statement_len + 1));
|
||||||
if (statement_sql)
|
if (statement_sql)
|
||||||
{
|
{
|
||||||
memcpy(statement_sql,
|
memcpy(statement_sql,
|
||||||
@ -3114,7 +3117,7 @@ blr_file_new_binlog(ROUTER_INSTANCE *router, char *file)
|
|||||||
int
|
int
|
||||||
blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
|
blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
|
||||||
{
|
{
|
||||||
char *section = "binlog_configuration";
|
const char *section = "binlog_configuration";
|
||||||
FILE *config_file;
|
FILE *config_file;
|
||||||
int rc;
|
int rc;
|
||||||
static const char MASTER_INI[] = "master.ini";
|
static const char MASTER_INI[] = "master.ini";
|
||||||
@ -3233,7 +3236,7 @@ blr_print_binlog_details(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char buf_t[40];
|
char buf_t[40];
|
||||||
struct tm tm_t;
|
struct tm tm_t;
|
||||||
char *event_desc;
|
const char *event_desc;
|
||||||
|
|
||||||
/* First Event */
|
/* First Event */
|
||||||
localtime_r(&first_event.event_time, &tm_t);
|
localtime_r(&first_event.event_time, &tm_t);
|
||||||
@ -3291,7 +3294,7 @@ blr_create_ignorable_event(uint32_t event_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space for event: size might contain the 4 crc32
|
// Allocate space for event: size might contain the 4 crc32
|
||||||
new_event = MXS_CALLOC(1, event_size);
|
new_event = static_cast<uint8_t*>(MXS_CALLOC(1, event_size));
|
||||||
if (new_event == NULL)
|
if (new_event == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3343,7 +3346,7 @@ blr_write_special_event(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
uint8_t *new_event;
|
uint8_t *new_event;
|
||||||
char *new_event_desc;
|
const char *new_event_desc;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -3417,7 +3420,7 @@ blr_write_special_event(ROUTER_INSTANCE *router,
|
|||||||
if ((n = pwrite(router->binlog_fd,
|
if ((n = pwrite(router->binlog_fd,
|
||||||
new_event,
|
new_event,
|
||||||
event_size,
|
event_size,
|
||||||
router->last_written)) != event_size)
|
router->last_written)) != static_cast<ssize_t>(event_size))
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Failed to write %s special binlog record at %lu of %s, %s. "
|
MXS_ERROR("%s: Failed to write %s special binlog record at %lu of %s, %s. "
|
||||||
"Truncating to previous record.",
|
"Truncating to previous record.",
|
||||||
@ -3476,7 +3479,8 @@ blr_create_start_encryption_event(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
uint8_t *new_event;
|
uint8_t *new_event;
|
||||||
uint8_t event_size = sizeof(START_ENCRYPTION_EVENT);
|
uint8_t event_size = sizeof(START_ENCRYPTION_EVENT);
|
||||||
BINLOG_ENCRYPTION_CTX *new_encryption_ctx = MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX));
|
BINLOG_ENCRYPTION_CTX *new_encryption_ctx =
|
||||||
|
static_cast<BINLOG_ENCRYPTION_CTX*>(MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX)));
|
||||||
|
|
||||||
if (new_encryption_ctx == NULL)
|
if (new_encryption_ctx == NULL)
|
||||||
{
|
{
|
||||||
@ -3489,7 +3493,7 @@ blr_create_start_encryption_event(ROUTER_INSTANCE *router,
|
|||||||
event_size += BINLOG_EVENT_CRC_SIZE;
|
event_size += BINLOG_EVENT_CRC_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_event = MXS_CALLOC(1, event_size);
|
new_event = static_cast<uint8_t*>(MXS_CALLOC(1, event_size));
|
||||||
if (new_event == NULL)
|
if (new_event == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3891,7 +3895,7 @@ static int blr_aes_create_tail_for_cbc(uint8_t *output,
|
|||||||
*
|
*
|
||||||
* Note: this also works for decryption
|
* Note: this also works for decryption
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < in_size; i++)
|
for (uint32_t i = 0; i < in_size; i++)
|
||||||
{
|
{
|
||||||
output[i] = input[i] ^ mask[i];
|
output[i] = input[i] ^ mask[i];
|
||||||
}
|
}
|
||||||
@ -4253,7 +4257,7 @@ bool blr_fetch_mariadb_gtid(ROUTER_SLAVE *slave,
|
|||||||
unsigned int
|
unsigned int
|
||||||
blr_file_get_next_seqno(const char *filename)
|
blr_file_get_next_seqno(const char *filename)
|
||||||
{
|
{
|
||||||
char *sptr;
|
const char *sptr;
|
||||||
int filenum;
|
int filenum;
|
||||||
|
|
||||||
if ((sptr = strrchr(filename, '.')) == NULL)
|
if ((sptr = strrchr(filename, '.')) == NULL)
|
||||||
@ -4486,7 +4490,7 @@ bool blr_compare_binlogs(const ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
// domain_id, server_id and strcmp()
|
// domain_id, server_id and strcmp()
|
||||||
return ((router->mariadb10_gtid_domain == info->domain_id) &&
|
return ((router->mariadb10_gtid_domain == info->domain_id) &&
|
||||||
(router->orig_masterid == info->server_id) &&
|
(router->orig_masterid == static_cast<int>(info->server_id)) &&
|
||||||
strcmp(r_file, s_file) == 0);
|
strcmp(r_file, s_file) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,12 +58,13 @@ static GWBUF *blr_make_binlog_dump(ROUTER_INSTANCE *router);
|
|||||||
void encode_value(unsigned char *data, unsigned int value, int len);
|
void encode_value(unsigned char *data, unsigned int value, int len);
|
||||||
void blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt);
|
void blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt);
|
||||||
static int blr_rotate_event(ROUTER_INSTANCE *router, uint8_t *pkt, REP_HEADER *hdr);
|
static int blr_rotate_event(ROUTER_INSTANCE *router, uint8_t *pkt, REP_HEADER *hdr);
|
||||||
static void *CreateMySQLAuthData(char *username, char *password, char *database);
|
static void *CreateMySQLAuthData(const char *username,
|
||||||
|
const char *password,
|
||||||
|
const char *database);
|
||||||
void blr_extract_header(uint8_t *pkt, REP_HEADER *hdr);
|
void blr_extract_header(uint8_t *pkt, REP_HEADER *hdr);
|
||||||
static void blr_log_packet(int priority, char *msg, uint8_t *ptr, int len);
|
static void blr_log_packet(int priority, const char *msg, uint8_t *ptr, int len);
|
||||||
void blr_master_close(ROUTER_INSTANCE *);
|
void blr_master_close(ROUTER_INSTANCE *);
|
||||||
char *blr_extract_column(GWBUF *buf, int col);
|
char *blr_extract_column(GWBUF *buf, int col);
|
||||||
void poll_fake_write_event(DCB *dcb);
|
|
||||||
static bool blr_check_last_master_event(void *inst);
|
static bool blr_check_last_master_event(void *inst);
|
||||||
extern int blr_check_heartbeat(ROUTER_INSTANCE *router);
|
extern int blr_check_heartbeat(ROUTER_INSTANCE *router);
|
||||||
static void blr_log_identity(ROUTER_INSTANCE *router);
|
static void blr_log_identity(ROUTER_INSTANCE *router);
|
||||||
@ -354,7 +355,7 @@ static void worker_cb_close_master(int worker_id, void* data)
|
|||||||
// This is itended to be called only in the main worker.
|
// This is itended to be called only in the main worker.
|
||||||
ss_dassert(worker_id == 0);
|
ss_dassert(worker_id == 0);
|
||||||
|
|
||||||
blr_master_close(data);
|
blr_master_close(static_cast<ROUTER_INSTANCE*>(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -629,7 +630,7 @@ blr_master_response(ROUTER_INSTANCE *router, GWBUF *buf)
|
|||||||
{
|
{
|
||||||
MXS_FREE(router->m_errmsg);
|
MXS_FREE(router->m_errmsg);
|
||||||
}
|
}
|
||||||
router->m_errmsg = msg_err ? msg_err : "(memory failure)";
|
router->m_errmsg = msg_err ? msg_err : MXS_STRDUP("(memory failure)");
|
||||||
|
|
||||||
router->active_logs = 0;
|
router->active_logs = 0;
|
||||||
if (router->reconnect_pending)
|
if (router->reconnect_pending)
|
||||||
@ -927,7 +928,7 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
|
|||||||
|
|
||||||
if (len < BINLOG_EVENT_HDR_LEN && router->master_event_state != BLR_EVENT_ONGOING)
|
if (len < BINLOG_EVENT_HDR_LEN && router->master_event_state != BLR_EVENT_ONGOING)
|
||||||
{
|
{
|
||||||
char *event_msg = "unknown";
|
const char *event_msg = "unknown";
|
||||||
|
|
||||||
/* Packet is too small to be a binlog event */
|
/* Packet is too small to be a binlog event */
|
||||||
if (ptr[4] == 0xfe) /* EOF Packet */
|
if (ptr[4] == 0xfe) /* EOF Packet */
|
||||||
@ -1242,7 +1243,8 @@ blr_handle_binlog_record(ROUTER_INSTANCE *router, GWBUF *pkt)
|
|||||||
|
|
||||||
statement_len = len - (MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \
|
statement_len = len - (MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \
|
||||||
+ var_block_len + 1 + db_name_len);
|
+ var_block_len + 1 + db_name_len);
|
||||||
statement_sql = MXS_CALLOC(1, statement_len + 1);
|
statement_sql =
|
||||||
|
static_cast<char*>(MXS_CALLOC(1, statement_len + 1));
|
||||||
MXS_ABORT_IF_NULL(statement_sql);
|
MXS_ABORT_IF_NULL(statement_sql);
|
||||||
memcpy(statement_sql,
|
memcpy(statement_sql,
|
||||||
(char *)ptr + MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \
|
(char *)ptr + MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \
|
||||||
@ -1694,7 +1696,7 @@ blr_rotate_event(ROUTER_INSTANCE *router, uint8_t *ptr, REP_HEADER *hdr)
|
|||||||
* This doesn't really belong here and should be moved at some stage.
|
* This doesn't really belong here and should be moved at some stage.
|
||||||
*/
|
*/
|
||||||
static void *
|
static void *
|
||||||
CreateMySQLAuthData(char *username, char *password, char *database)
|
CreateMySQLAuthData(const char *username, const char *password, const char *database)
|
||||||
{
|
{
|
||||||
MYSQL_session *auth_info;
|
MYSQL_session *auth_info;
|
||||||
|
|
||||||
@ -1718,7 +1720,8 @@ CreateMySQLAuthData(char *username, char *password, char *database)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((auth_info = MXS_CALLOC(1, sizeof(MYSQL_session))) == NULL)
|
if ((auth_info =
|
||||||
|
static_cast<MYSQL_session*>(MXS_CALLOC(1, sizeof(MYSQL_session)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1747,7 +1750,7 @@ typedef enum
|
|||||||
* @param len Length of message packet
|
* @param len Length of message packet
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
blr_log_packet(int priority, char *msg, uint8_t *ptr, int len)
|
blr_log_packet(int priority, const char *msg, uint8_t *ptr, int len)
|
||||||
{
|
{
|
||||||
char buf[400] = "";
|
char buf[400] = "";
|
||||||
char *bufp;
|
char *bufp;
|
||||||
@ -1851,7 +1854,7 @@ blr_extract_column(GWBUF *buf, int col)
|
|||||||
ptr += collen;
|
ptr += collen;
|
||||||
}
|
}
|
||||||
collen = *ptr++;
|
collen = *ptr++;
|
||||||
if ((rval = MXS_MALLOC(collen + 1)) == NULL)
|
if ((rval = static_cast<char*>(MXS_MALLOC(collen + 1))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1976,7 +1979,7 @@ int
|
|||||||
blr_check_heartbeat(ROUTER_INSTANCE *router)
|
blr_check_heartbeat(ROUTER_INSTANCE *router)
|
||||||
{
|
{
|
||||||
time_t t_now = time(0);
|
time_t t_now = time(0);
|
||||||
char *event_desc = NULL;
|
const char *event_desc = NULL;
|
||||||
|
|
||||||
if (router->master_state != BLRM_BINLOGDUMP)
|
if (router->master_state != BLRM_BINLOGDUMP)
|
||||||
{
|
{
|
||||||
@ -1988,7 +1991,8 @@ blr_check_heartbeat(ROUTER_INSTANCE *router)
|
|||||||
if (router->master_state == BLRM_BINLOGDUMP &&
|
if (router->master_state == BLRM_BINLOGDUMP &&
|
||||||
router->lastEventReceived > 0)
|
router->lastEventReceived > 0)
|
||||||
{
|
{
|
||||||
if ((t_now - router->stats.lastReply) > (router->heartbeat + BLR_NET_LATENCY_WAIT_TIME))
|
if (static_cast<unsigned long>(t_now - router->stats.lastReply) >
|
||||||
|
(router->heartbeat + BLR_NET_LATENCY_WAIT_TIME))
|
||||||
{
|
{
|
||||||
MXS_ERROR("No event received from master [%s]:%d in heartbeat period (%lu seconds), "
|
MXS_ERROR("No event received from master [%s]:%d in heartbeat period (%lu seconds), "
|
||||||
"last event (%s %d) received %lu seconds ago. Assuming connection is dead "
|
"last event (%s %d) received %lu seconds ago. Assuming connection is dead "
|
||||||
@ -2097,7 +2101,7 @@ blr_write_data_into_binlog(ROUTER_INSTANCE *router, uint32_t data_len, uint8_t *
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if ((n = pwrite(router->binlog_fd, buf, data_len,
|
if ((n = pwrite(router->binlog_fd, buf, data_len,
|
||||||
router->last_written)) != data_len)
|
router->last_written)) != static_cast<int64_t>(data_len))
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
|
MXS_ERROR("%s: Failed to write binlog record at %lu of %s, %s. "
|
||||||
"Truncating to previous record.",
|
"Truncating to previous record.",
|
||||||
@ -69,27 +69,27 @@
|
|||||||
|
|
||||||
#include "blr.h"
|
#include "blr.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <maxscale/maxscale.h>
|
|
||||||
#include <maxscale/service.h>
|
|
||||||
#include <maxscale/server.h>
|
|
||||||
#include <maxscale/router.h>
|
|
||||||
#include <maxscale/atomic.h>
|
|
||||||
#include <maxscale/spinlock.h>
|
|
||||||
#include <maxscale/dcb.h>
|
|
||||||
#include <maxscale/spinlock.h>
|
|
||||||
#include <maxscale/housekeeper.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <maxscale/log_manager.h>
|
|
||||||
#include <maxscale/version.h>
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <maxscale/alloc.h>
|
#include <maxscale/alloc.h>
|
||||||
#include <inttypes.h>
|
#include <maxscale/atomic.h>
|
||||||
#include <maxscale/utils.h>
|
|
||||||
#include <maxscale/clock.h>
|
#include <maxscale/clock.h>
|
||||||
|
#include <maxscale/dcb.h>
|
||||||
|
#include <maxscale/housekeeper.h>
|
||||||
|
#include <maxscale/log_manager.h>
|
||||||
|
#include <maxscale/maxscale.h>
|
||||||
|
#include <maxscale/poll.h>
|
||||||
|
#include <maxscale/router.h>
|
||||||
|
#include <maxscale/server.h>
|
||||||
|
#include <maxscale/service.h>
|
||||||
|
#include <maxscale/spinlock.h>
|
||||||
|
#include <maxscale/utils.h>
|
||||||
|
#include <maxscale/version.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This struct is used by sqlite3_exec callback routine
|
* This struct is used by sqlite3_exec callback routine
|
||||||
@ -118,7 +118,6 @@ typedef enum
|
|||||||
SLAVE_EOF_ERROR
|
SLAVE_EOF_ERROR
|
||||||
} slave_eof_action_t;
|
} slave_eof_action_t;
|
||||||
|
|
||||||
extern void poll_fake_write_event(DCB *dcb);
|
|
||||||
static char* get_next_token(char *str, const char* delim, char **saveptr);
|
static char* get_next_token(char *str, const char* delim, char **saveptr);
|
||||||
extern int load_mysql_users(SERV_LISTENER *listener);
|
extern int load_mysql_users(SERV_LISTENER *listener);
|
||||||
extern void blr_master_close(ROUTER_INSTANCE* router);
|
extern void blr_master_close(ROUTER_INSTANCE* router);
|
||||||
@ -137,7 +136,7 @@ static int blr_slave_replay(ROUTER_INSTANCE *router,
|
|||||||
GWBUF *master);
|
GWBUF *master);
|
||||||
static void blr_slave_send_error(ROUTER_INSTANCE *router,
|
static void blr_slave_send_error(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *msg);
|
const char *msg);
|
||||||
static int blr_slave_send_timestamp(ROUTER_INSTANCE *router,
|
static int blr_slave_send_timestamp(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave);
|
ROUTER_SLAVE *slave);
|
||||||
static int blr_slave_register(ROUTER_INSTANCE *router,
|
static int blr_slave_register(ROUTER_INSTANCE *router,
|
||||||
@ -199,9 +198,9 @@ static int blr_stop_slave(ROUTER_INSTANCE* router,
|
|||||||
static int blr_start_slave(ROUTER_INSTANCE* router,
|
static int blr_start_slave(ROUTER_INSTANCE* router,
|
||||||
ROUTER_SLAVE* slave);
|
ROUTER_SLAVE* slave);
|
||||||
static void blr_slave_send_error_packet(ROUTER_SLAVE *slave,
|
static void blr_slave_send_error_packet(ROUTER_SLAVE *slave,
|
||||||
char *msg,
|
const char *msg,
|
||||||
unsigned int err_num,
|
unsigned int err_num,
|
||||||
char *status);
|
const char *status);
|
||||||
static int blr_handle_change_master(ROUTER_INSTANCE* router,
|
static int blr_handle_change_master(ROUTER_INSTANCE* router,
|
||||||
char *command,
|
char *command,
|
||||||
char *error);
|
char *error);
|
||||||
@ -237,17 +236,17 @@ static int blr_handle_change_master_token(char *input,
|
|||||||
static void blr_master_free_parsed_options(CHANGE_MASTER_OPTIONS *options);
|
static void blr_master_free_parsed_options(CHANGE_MASTER_OPTIONS *options);
|
||||||
static int blr_slave_send_var_value(ROUTER_INSTANCE *router,
|
static int blr_slave_send_var_value(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type);
|
int column_type);
|
||||||
static int blr_slave_send_variable(ROUTER_INSTANCE *router,
|
static int blr_slave_send_variable(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type);
|
int column_type);
|
||||||
static int blr_slave_send_columndef_with_info_schema(ROUTER_INSTANCE *router,
|
static int blr_slave_send_columndef_with_info_schema(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *name,
|
const char *name,
|
||||||
int type,
|
int type,
|
||||||
int len,
|
int len,
|
||||||
uint8_t seqno);
|
uint8_t seqno);
|
||||||
@ -262,20 +261,20 @@ static int blr_slave_handle_variables(ROUTER_INSTANCE *router,
|
|||||||
char *stmt);
|
char *stmt);
|
||||||
static int blr_slave_send_warning_message(ROUTER_INSTANCE* router,
|
static int blr_slave_send_warning_message(ROUTER_INSTANCE* router,
|
||||||
ROUTER_SLAVE* slave,
|
ROUTER_SLAVE* slave,
|
||||||
char *message);
|
const char *message);
|
||||||
static int blr_slave_show_warnings(ROUTER_INSTANCE* router,
|
static int blr_slave_show_warnings(ROUTER_INSTANCE* router,
|
||||||
ROUTER_SLAVE* slave);
|
ROUTER_SLAVE* slave);
|
||||||
static int blr_slave_send_status_variable(ROUTER_INSTANCE *router,
|
static int blr_slave_send_status_variable(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type);
|
int column_type);
|
||||||
static int blr_slave_handle_status_variables(ROUTER_INSTANCE *router,
|
static int blr_slave_handle_status_variables(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *stmt);
|
char *stmt);
|
||||||
static int blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
|
static int blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *name,
|
const char *name,
|
||||||
int type,
|
int type,
|
||||||
int len,
|
int len,
|
||||||
uint8_t seqno);
|
uint8_t seqno);
|
||||||
@ -610,11 +609,10 @@ static int
|
|||||||
blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
blr_slave_query(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *queue)
|
||||||
{
|
{
|
||||||
char *qtext, *query_text;
|
char *qtext, *query_text;
|
||||||
char *sep = " ,=";
|
const char *sep = " ,=";
|
||||||
char *word, *brkb;
|
char *word, *brkb;
|
||||||
int query_len;
|
int query_len;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
extern char *strcasestr();
|
|
||||||
bool unexpected = true;
|
bool unexpected = true;
|
||||||
|
|
||||||
qtext = (char*)GWBUF_DATA(queue);
|
qtext = (char*)GWBUF_DATA(queue);
|
||||||
@ -816,7 +814,7 @@ blr_slave_replay(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, GWBUF *master)
|
|||||||
* @param msg The error message to send
|
* @param msg The error message to send
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
blr_slave_send_error(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, char *msg)
|
blr_slave_send_error(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, const char *msg)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -2480,8 +2478,9 @@ blr_slave_catchup(ROUTER_INSTANCE *router, ROUTER_SLAVE *slave, bool large)
|
|||||||
{
|
{
|
||||||
/* read it, set slave & file context */
|
/* read it, set slave & file context */
|
||||||
uint8_t *record_ptr = GWBUF_DATA(record);
|
uint8_t *record_ptr = GWBUF_DATA(record);
|
||||||
|
void *mem = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
||||||
SLAVE_ENCRYPTION_CTX *encryption_ctx;
|
SLAVE_ENCRYPTION_CTX *encryption_ctx;
|
||||||
encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
encryption_ctx = static_cast<SLAVE_ENCRYPTION_CTX*>(mem);
|
||||||
|
|
||||||
MXS_ABORT_IF_NULL(encryption_ctx);
|
MXS_ABORT_IF_NULL(encryption_ctx);
|
||||||
record_ptr += BINLOG_EVENT_HDR_LEN;
|
record_ptr += BINLOG_EVENT_HDR_LEN;
|
||||||
@ -3209,7 +3208,7 @@ blr_slave_fake_rotate(ROUTER_INSTANCE *router,
|
|||||||
BLFILE** filep,
|
BLFILE** filep,
|
||||||
const char *new_file)
|
const char *new_file)
|
||||||
{
|
{
|
||||||
char *sptr;
|
const char *sptr;
|
||||||
int filenum;
|
int filenum;
|
||||||
GWBUF *r_event;
|
GWBUF *r_event;
|
||||||
MARIADB_GTID_INFO *f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ?
|
MARIADB_GTID_INFO *f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ?
|
||||||
@ -4139,15 +4138,15 @@ blr_start_slave(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
blr_slave_send_error_packet(ROUTER_SLAVE *slave,
|
blr_slave_send_error_packet(ROUTER_SLAVE *slave,
|
||||||
char *msg,
|
const char *msg,
|
||||||
unsigned int err_num,
|
unsigned int err_num,
|
||||||
char *status)
|
const char *status)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int len;
|
int len;
|
||||||
unsigned int mysql_errno = 0;
|
unsigned int mysql_errno = 0;
|
||||||
char *mysql_state;
|
const char *mysql_state;
|
||||||
|
|
||||||
if ((pkt = gwbuf_alloc(strlen(msg) + 13)) == NULL)
|
if ((pkt = gwbuf_alloc(strlen(msg) + 13)) == NULL)
|
||||||
{
|
{
|
||||||
@ -5060,7 +5059,7 @@ blr_parse_change_master_command(char *input,
|
|||||||
char *error_string,
|
char *error_string,
|
||||||
CHANGE_MASTER_OPTIONS *config)
|
CHANGE_MASTER_OPTIONS *config)
|
||||||
{
|
{
|
||||||
char *sep = ",";
|
const char *sep = ",";
|
||||||
char *word, *brkb;
|
char *word, *brkb;
|
||||||
|
|
||||||
if ((word = get_next_token(input, sep, &brkb)) == NULL)
|
if ((word = get_next_token(input, sep, &brkb)) == NULL)
|
||||||
@ -5111,7 +5110,7 @@ blr_handle_change_master_token(char *input,
|
|||||||
CHANGE_MASTER_OPTIONS *config)
|
CHANGE_MASTER_OPTIONS *config)
|
||||||
{
|
{
|
||||||
/* space+TAB+= */
|
/* space+TAB+= */
|
||||||
char *sep = " \t=";
|
const char *sep = " \t=";
|
||||||
char *word, *brkb;
|
char *word, *brkb;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
char **option_field = NULL;
|
char **option_field = NULL;
|
||||||
@ -5172,7 +5171,7 @@ blr_get_parsed_command_value(char *input)
|
|||||||
strcpy(value, input);
|
strcpy(value, input);
|
||||||
|
|
||||||
/* space+TAB+= */
|
/* space+TAB+= */
|
||||||
char *sep = " \t=";
|
const char *sep = " \t=";
|
||||||
char *word;
|
char *word;
|
||||||
|
|
||||||
if ((word = get_next_token(NULL, sep, &input)) != NULL)
|
if ((word = get_next_token(NULL, sep, &input)) != NULL)
|
||||||
@ -5330,8 +5329,8 @@ blr_master_free_parsed_options(CHANGE_MASTER_OPTIONS *options)
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_var_value(ROUTER_INSTANCE *router,
|
blr_slave_send_var_value(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type)
|
int column_type)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
@ -5384,8 +5383,8 @@ blr_slave_send_var_value(ROUTER_INSTANCE *router,
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_variable(ROUTER_INSTANCE *router,
|
blr_slave_send_variable(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type)
|
int column_type)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
@ -5475,7 +5474,7 @@ blr_slave_send_variable(ROUTER_INSTANCE *router,
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_columndef_with_info_schema(ROUTER_INSTANCE *router,
|
blr_slave_send_columndef_with_info_schema(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *name,
|
const char *name,
|
||||||
int type,
|
int type,
|
||||||
int len,
|
int len,
|
||||||
uint8_t seqno)
|
uint8_t seqno)
|
||||||
@ -5616,7 +5615,7 @@ blr_slave_handle_variables(ROUTER_INSTANCE *router,
|
|||||||
char *brkb;
|
char *brkb;
|
||||||
char *word;
|
char *word;
|
||||||
/* SPACE,TAB,= */
|
/* SPACE,TAB,= */
|
||||||
char *sep = " ,=";
|
const char *sep = " ,=";
|
||||||
|
|
||||||
if ((word = strtok_r(stmt, sep, &brkb)) == NULL)
|
if ((word = strtok_r(stmt, sep, &brkb)) == NULL)
|
||||||
{
|
{
|
||||||
@ -5696,7 +5695,7 @@ blr_slave_handle_variables(ROUTER_INSTANCE *router,
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_warning_message(ROUTER_INSTANCE* router,
|
blr_slave_send_warning_message(ROUTER_INSTANCE* router,
|
||||||
ROUTER_SLAVE* slave,
|
ROUTER_SLAVE* slave,
|
||||||
char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
@ -5764,7 +5763,7 @@ blr_slave_show_warnings(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave)
|
|||||||
/* check whether a warning message is available */
|
/* check whether a warning message is available */
|
||||||
if (slave->warning_msg)
|
if (slave->warning_msg)
|
||||||
{
|
{
|
||||||
char *level = "Warning";
|
const char *level = "Warning";
|
||||||
char *msg_ptr;
|
char *msg_ptr;
|
||||||
char err_code[16 + 1] = "";
|
char err_code[16 + 1] = "";
|
||||||
msg_ptr = strchr(slave->warning_msg, ':');
|
msg_ptr = strchr(slave->warning_msg, ':');
|
||||||
@ -5855,7 +5854,7 @@ blr_slave_handle_status_variables(ROUTER_INSTANCE *router,
|
|||||||
char *brkb = NULL;
|
char *brkb = NULL;
|
||||||
char *word = NULL;
|
char *word = NULL;
|
||||||
/* SPACE,TAB,= */
|
/* SPACE,TAB,= */
|
||||||
char *sep = " ,=";
|
const char *sep = " ,=";
|
||||||
|
|
||||||
if ((word = strtok_r(stmt, sep, &brkb)) == NULL)
|
if ((word = strtok_r(stmt, sep, &brkb)) == NULL)
|
||||||
{
|
{
|
||||||
@ -5913,8 +5912,8 @@ blr_slave_handle_status_variables(ROUTER_INSTANCE *router,
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_status_variable(ROUTER_INSTANCE *router,
|
blr_slave_send_status_variable(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *variable,
|
const char *variable,
|
||||||
char *value,
|
const char *value,
|
||||||
int column_type)
|
int column_type)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
@ -6009,7 +6008,7 @@ blr_slave_send_status_variable(ROUTER_INSTANCE *router,
|
|||||||
static int
|
static int
|
||||||
blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
|
blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
|
||||||
ROUTER_SLAVE *slave,
|
ROUTER_SLAVE *slave,
|
||||||
char *name,
|
const char *name,
|
||||||
int type,
|
int type,
|
||||||
int len,
|
int len,
|
||||||
uint8_t seqno)
|
uint8_t seqno)
|
||||||
@ -6022,7 +6021,7 @@ blr_slave_send_columndef_with_status_schema(ROUTER_INSTANCE *router,
|
|||||||
int column_name_len = strlen(name);
|
int column_name_len = strlen(name);
|
||||||
int orig_column_name_len = strlen("VARIABLE_NAME");
|
int orig_column_name_len = strlen("VARIABLE_NAME");
|
||||||
int packet_data_len = 0;
|
int packet_data_len = 0;
|
||||||
char *ptr_name_start = name;
|
const char *ptr_name_start = name;
|
||||||
|
|
||||||
if (strcasecmp(ptr_name_start, "value") == 0)
|
if (strcasecmp(ptr_name_start, "value") == 0)
|
||||||
{
|
{
|
||||||
@ -6308,7 +6307,8 @@ blr_set_master_ssl(ROUTER_INSTANCE *router,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Allocate SSL struct for backend connection */
|
/* Allocate SSL struct for backend connection */
|
||||||
if ((server_ssl = MXS_CALLOC(1, sizeof(SSL_LISTENER))) == NULL)
|
server_ssl = static_cast<SSL_LISTENER*>(MXS_CALLOC(1, sizeof(SSL_LISTENER)));
|
||||||
|
if (server_ssl == NULL)
|
||||||
{
|
{
|
||||||
router->ssl_enabled = false;
|
router->ssl_enabled = false;
|
||||||
|
|
||||||
@ -6481,8 +6481,9 @@ blr_slave_read_ste(ROUTER_INSTANCE *router,
|
|||||||
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT)
|
if (hdr.event_type == MARIADB10_START_ENCRYPTION_EVENT)
|
||||||
{
|
{
|
||||||
uint8_t *record_ptr = GWBUF_DATA(record);
|
uint8_t *record_ptr = GWBUF_DATA(record);
|
||||||
SLAVE_ENCRYPTION_CTX *new_encryption_ctx;
|
void *mem = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
||||||
new_encryption_ctx = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX));
|
SLAVE_ENCRYPTION_CTX *new_encryption_ctx =
|
||||||
|
static_cast<SLAVE_ENCRYPTION_CTX*>(mem);
|
||||||
|
|
||||||
if (!new_encryption_ctx)
|
if (!new_encryption_ctx)
|
||||||
{
|
{
|
||||||
@ -6545,7 +6546,7 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
char *brkb;
|
char *brkb;
|
||||||
char *sep = " \t,=";
|
const char *sep = " \t,=";
|
||||||
|
|
||||||
if ((word = strtok_r(select_stmt, sep, &brkb)) == NULL)
|
if ((word = strtok_r(select_stmt, sep, &brkb)) == NULL)
|
||||||
{
|
{
|
||||||
@ -7456,7 +7457,7 @@ static bool blr_handle_show_stmt(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
char *brkb;
|
char *brkb;
|
||||||
char *sep = " \t,=";
|
const char *sep = " \t,=";
|
||||||
if ((word = strtok_r(show_stmt, sep, &brkb)) == NULL)
|
if ((word = strtok_r(show_stmt, sep, &brkb)) == NULL)
|
||||||
{
|
{
|
||||||
MXS_ERROR("%s: Incomplete show query.", router->service->name);
|
MXS_ERROR("%s: Incomplete show query.", router->service->name);
|
||||||
@ -7475,7 +7476,8 @@ static bool blr_handle_show_stmt(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *errmsg = "SHOW [FULL] BINARY LOGS needs the"
|
const char *errmsg =
|
||||||
|
"SHOW [FULL] BINARY LOGS needs the"
|
||||||
" 'mariadb10_slave_gtid' option to be set.";
|
" 'mariadb10_slave_gtid' option to be set.";
|
||||||
MXS_ERROR("%s: %s",
|
MXS_ERROR("%s: %s",
|
||||||
errmsg,
|
errmsg,
|
||||||
@ -7678,7 +7680,7 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
char *brkb;
|
char *brkb;
|
||||||
char *sep = " \t,=";
|
const char *sep = " \t,=";
|
||||||
|
|
||||||
if ((word = strtok_r(set_stmt, sep, &brkb)) == NULL)
|
if ((word = strtok_r(set_stmt, sep, &brkb)) == NULL)
|
||||||
{
|
{
|
||||||
@ -7976,7 +7978,7 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
char *brkb;
|
char *brkb;
|
||||||
char *sep = " \t,=";
|
const char *sep = " \t,=";
|
||||||
|
|
||||||
if (admin_opts == NULL || !admin_opts[0])
|
if (admin_opts == NULL || !admin_opts[0])
|
||||||
{
|
{
|
||||||
@ -8004,7 +8006,8 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *errmsg = "PURGE BINARY LOGS needs the "
|
const char *errmsg =
|
||||||
|
"PURGE BINARY LOGS needs the "
|
||||||
"'mariadb10_slave_gtid' option to be set.";
|
"'mariadb10_slave_gtid' option to be set.";
|
||||||
MXS_ERROR("%s: %s",
|
MXS_ERROR("%s: %s",
|
||||||
errmsg,
|
errmsg,
|
||||||
@ -9194,7 +9197,8 @@ static void blr_log_config_changes(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare GTID msg */
|
/* Prepare GTID msg */
|
||||||
char *gtid_msg = change_master->use_mariadb10_gtid ?
|
const char *gtid_msg =
|
||||||
|
change_master->use_mariadb10_gtid ?
|
||||||
", MASTER_USE_GTID=Slave_pos" :
|
", MASTER_USE_GTID=Slave_pos" :
|
||||||
"";
|
"";
|
||||||
|
|
||||||
@ -9244,10 +9248,10 @@ static bool blr_check_connecting_slave(const ROUTER_INSTANCE *router,
|
|||||||
enum blr_slave_check check)
|
enum blr_slave_check check)
|
||||||
{
|
{
|
||||||
int rv = true;
|
int rv = true;
|
||||||
char *err_msg = NULL;
|
const char *err_msg = NULL;
|
||||||
char *err_status = "HY000";
|
const char *err_status = "HY000";
|
||||||
int err_code = BINLOG_FATAL_ERROR_READING;
|
int err_code = BINLOG_FATAL_ERROR_READING;
|
||||||
char *msg_detail = "";
|
const char *msg_detail = "";
|
||||||
|
|
||||||
switch (check)
|
switch (check)
|
||||||
{
|
{
|
||||||
@ -9657,7 +9661,8 @@ static bool blr_apply_changes(ROUTER_INSTANCE *router,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (master_log_pos != NULL && pos != router->current_pos)
|
if (master_log_pos != NULL &&
|
||||||
|
pos != static_cast<long long>(router->current_pos))
|
||||||
{
|
{
|
||||||
snprintf(error,
|
snprintf(error,
|
||||||
BINLOG_ERROR_MSG_LEN, "Can not set MASTER_LOG_POS to %s: "
|
BINLOG_ERROR_MSG_LEN, "Can not set MASTER_LOG_POS to %s: "
|
||||||
@ -72,7 +72,7 @@ static struct option long_options[] =
|
|||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
char *binlog_check_version = "2.2.1";
|
const char *binlog_check_version = "2.2.1";
|
||||||
|
|
||||||
int
|
int
|
||||||
maxscale_uptime()
|
maxscale_uptime()
|
||||||
@ -1,5 +1,5 @@
|
|||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
add_executable(testbinlogrouter testbinlog.c ../blr.c ../blr_slave.c ../blr_master.c ../blr_file.c ../blr_cache.c)
|
add_executable(testbinlogrouter testbinlog.cc ../blr.cc ../blr_slave.cc ../blr_master.cc ../blr_file.cc ../blr_cache.cc)
|
||||||
target_link_libraries(testbinlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
target_link_libraries(testbinlogrouter maxscale-common ${PCRE_LINK_FLAGS} uuid)
|
||||||
add_test(NAME TestBinlogRouter COMMAND ./testbinlogrouter WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME TestBinlogRouter COMMAND ./testbinlogrouter WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -132,7 +132,8 @@ int main(int argc, char **argv)
|
|||||||
serviceAddBackend(service, server);
|
serviceAddBackend(service, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((inst = MXS_CALLOC(1, sizeof(ROUTER_INSTANCE))) == NULL)
|
inst = static_cast<ROUTER_INSTANCE*>(MXS_CALLOC(1, sizeof(ROUTER_INSTANCE)));
|
||||||
|
if (inst == NULL)
|
||||||
{
|
{
|
||||||
mxs_log_flush_sync();
|
mxs_log_flush_sync();
|
||||||
mxs_log_finish();
|
mxs_log_finish();
|
||||||
@ -62,8 +62,6 @@ uint64_t Cat::getCapabilities()
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The module entry point routine. It is this routine that
|
* The module entry point routine. It is this routine that
|
||||||
* must populate the structure that is referred to as the
|
* must populate the structure that is referred to as the
|
||||||
@ -72,7 +70,7 @@ MXS_BEGIN_DECLS
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
{
|
{
|
||||||
@ -94,5 +92,3 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_END_DECLS
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
add_library(cli SHARED cli.c ../debugcli/debugcmd.c)
|
add_library(cli SHARED cli.cc ../debugcli/debugcmd.cc)
|
||||||
target_link_libraries(cli maxscale-common)
|
target_link_libraries(cli maxscale-common)
|
||||||
set_target_properties(cli PROPERTIES VERSION "1.0.0")
|
set_target_properties(cli PROPERTIES VERSION "1.0.0")
|
||||||
install_module(cli core)
|
install_module(cli core)
|
||||||
|
|||||||
@ -65,7 +65,7 @@ static CLI_INSTANCE *instances;
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise CLI router module");
|
MXS_NOTICE("Initialise CLI router module");
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
@ -122,7 +122,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
CLI_INSTANCE *inst;
|
CLI_INSTANCE *inst;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((inst = MXS_MALLOC(sizeof(CLI_INSTANCE))) == NULL)
|
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
|
|
||||||
session->state = SESSION_STATE_READY;
|
session->state = SESSION_STATE_READY;
|
||||||
|
|
||||||
return (void *)client;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1,4 +1,4 @@
|
|||||||
add_library(debugcli SHARED debugcli.c debugcmd.c)
|
add_library(debugcli SHARED debugcli.cc debugcmd.cc)
|
||||||
target_link_libraries(debugcli maxscale-common)
|
target_link_libraries(debugcli maxscale-common)
|
||||||
set_target_properties(debugcli PROPERTIES VERSION "1.1.1")
|
set_target_properties(debugcli PROPERTIES VERSION "1.1.1")
|
||||||
install_module(debugcli core)
|
install_module(debugcli core)
|
||||||
|
|||||||
@ -64,7 +64,7 @@ static CLI_INSTANCE *instances;
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise debug CLI router module.");
|
MXS_NOTICE("Initialise debug CLI router module.");
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
@ -121,7 +121,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
CLI_INSTANCE *inst;
|
CLI_INSTANCE *inst;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((inst = MXS_MALLOC(sizeof(CLI_INSTANCE))) == NULL)
|
if ((inst = static_cast<CLI_INSTANCE*>(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
dcb_printf(session->client_dcb, "Welcome to the MariaDB Corporation MaxScale Debug Interface.\n");
|
dcb_printf(session->client_dcb, "Welcome to the MariaDB Corporation MaxScale Debug Interface.\n");
|
||||||
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
|
dcb_printf(session->client_dcb, "Type help for a list of available commands.\n\n");
|
||||||
|
|
||||||
return (void *)client;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,14 +84,44 @@
|
|||||||
*
|
*
|
||||||
* These are the options that may be passed to a command
|
* These are the options that may be passed to a command
|
||||||
*/
|
*/
|
||||||
|
typedef void (*FN )(DCB*);
|
||||||
|
typedef void (*FN1 )(DCB*, unsigned long);
|
||||||
|
typedef void (*FN2 )(DCB*, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN3 )(DCB*, unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN4 )(DCB*, unsigned long, unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN5 )(DCB*, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN6 )(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long);
|
||||||
|
typedef void (*FN7 )(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long);
|
||||||
|
typedef void (*FN8 )(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN9 )(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN10)(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
|
||||||
|
typedef void (*FN11)(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long);
|
||||||
|
typedef void (*FN12)(DCB*,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
|
||||||
|
unsigned long, unsigned long);
|
||||||
|
|
||||||
struct subcommand
|
struct subcommand
|
||||||
{
|
{
|
||||||
char *arg1;
|
const char *arg1;
|
||||||
int argc_min;
|
int argc_min;
|
||||||
int argc_max;
|
int argc_max;
|
||||||
void (*fn)();
|
void (*fn)(DCB*);
|
||||||
char *help;
|
const char *help;
|
||||||
char *devhelp;
|
const char *devhelp;
|
||||||
int arg_types[MAXARGS];
|
int arg_types[MAXARGS];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,26 +142,26 @@ struct subcommand showoptions[] =
|
|||||||
{
|
{
|
||||||
#if defined(BUFFER_TRACE)
|
#if defined(BUFFER_TRACE)
|
||||||
{
|
{
|
||||||
"buffers", 0, dprintAllBuffers,
|
"buffers", 0, (FN)dprintAllBuffers,
|
||||||
"Show all buffers with backtrace",
|
"Show all buffers with backtrace",
|
||||||
"Show all buffers with backtrace",
|
"Show all buffers with backtrace",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
"dcbs", 0, 0, dprintAllDCBs,
|
"dcbs", 0, 0, (FN)dprintAllDCBs,
|
||||||
"Show all DCBs",
|
"Show all DCBs",
|
||||||
"Usage: show dcbs",
|
"Usage: show dcbs",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dbusers", 1, 1, service_print_users,
|
"dbusers", 1, 1, (FN)service_print_users,
|
||||||
"[deprecated] Show user statistics",
|
"[deprecated] Show user statistics",
|
||||||
"See `show authenticators`",
|
"See `show authenticators`",
|
||||||
{ARG_TYPE_SERVICE}
|
{ARG_TYPE_SERVICE}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"authenticators", 1, 1, service_print_users,
|
"authenticators", 1, 1, (FN)service_print_users,
|
||||||
"Show authenticator diagnostics for a service",
|
"Show authenticator diagnostics for a service",
|
||||||
"Usage: show authenticators SERVICE\n"
|
"Usage: show authenticators SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -142,19 +172,19 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_SERVICE}
|
{ARG_TYPE_SERVICE}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"epoll", 0, 0, dprintPollStats,
|
"epoll", 0, 0, (FN)dprintPollStats,
|
||||||
"Show the polling system statistics",
|
"Show the polling system statistics",
|
||||||
"Usage: show epoll",
|
"Usage: show epoll",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eventstats", 0, 0, dShowEventStats,
|
"eventstats", 0, 0, (FN)dShowEventStats,
|
||||||
"Show event queue statistics",
|
"Show event queue statistics",
|
||||||
"Usage: show eventstats",
|
"Usage: show eventstats",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filter", 1, 1, dprintFilter,
|
"filter", 1, 1, (FN)dprintFilter,
|
||||||
"Show filter details",
|
"Show filter details",
|
||||||
"Usage: show filter FILTER\n"
|
"Usage: show filter FILTER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -165,25 +195,25 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_FILTER}
|
{ARG_TYPE_FILTER}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filters", 0, 0, dprintAllFilters,
|
"filters", 0, 0, (FN)dprintAllFilters,
|
||||||
"Show all filters",
|
"Show all filters",
|
||||||
"Usage: show filters",
|
"Usage: show filters",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"log_throttling", 0, 0, show_log_throttling,
|
"log_throttling", 0, 0, (FN)show_log_throttling,
|
||||||
"Show the current log throttling setting (count, window (ms), suppression (ms))",
|
"Show the current log throttling setting (count, window (ms), suppression (ms))",
|
||||||
"Usage: show log_throttling",
|
"Usage: show log_throttling",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"modules", 0, 0, dprintAllModules,
|
"modules", 0, 0, (FN)dprintAllModules,
|
||||||
"Show all currently loaded modules",
|
"Show all currently loaded modules",
|
||||||
"Usage: show modules",
|
"Usage: show modules",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitor", 1, 1, monitorShow,
|
"monitor", 1, 1, (FN)monitorShow,
|
||||||
"Show monitor details",
|
"Show monitor details",
|
||||||
"Usage: show monitor MONITOR\n"
|
"Usage: show monitor MONITOR\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -194,13 +224,13 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_MONITOR}
|
{ARG_TYPE_MONITOR}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitors", 0, 0, monitorShowAll,
|
"monitors", 0, 0, (FN)monitorShowAll,
|
||||||
"Show all monitors",
|
"Show all monitors",
|
||||||
"Usage: show monitors",
|
"Usage: show monitors",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"persistent", 1, 1, dprintPersistentDCBs,
|
"persistent", 1, 1, (FN)dprintPersistentDCBs,
|
||||||
"Show the persistent connection pool of a server",
|
"Show the persistent connection pool of a server",
|
||||||
"Usage: show persistent SERVER\n"
|
"Usage: show persistent SERVER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -211,7 +241,7 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_SERVER}
|
{ARG_TYPE_SERVER}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"server", 1, 1, dprintServer,
|
"server", 1, 1, (FN)dprintServer,
|
||||||
"Show server details",
|
"Show server details",
|
||||||
"Usage: show server SERVER\n"
|
"Usage: show server SERVER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -222,25 +252,25 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_SERVER}
|
{ARG_TYPE_SERVER}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"servers", 0, 0, dprintAllServers,
|
"servers", 0, 0, (FN)dprintAllServers,
|
||||||
"Show all servers",
|
"Show all servers",
|
||||||
"Usage: show servers",
|
"Usage: show servers",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"serversjson", 0, 0, dprintAllServersJson,
|
"serversjson", 0, 0, (FN)dprintAllServersJson,
|
||||||
"Show all servers in JSON",
|
"Show all servers in JSON",
|
||||||
"Usage: show serversjson",
|
"Usage: show serversjson",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"services", 0, 0, dprintAllServices,
|
"services", 0, 0, (FN)dprintAllServices,
|
||||||
"Show all configured services in MaxScale",
|
"Show all configured services in MaxScale",
|
||||||
"Usage: show services",
|
"Usage: show services",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"service", 1, 1, dprintService,
|
"service", 1, 1, (FN)dprintService,
|
||||||
"Show a single service in MaxScale",
|
"Show a single service in MaxScale",
|
||||||
"Usage: show service SERVICE\n"
|
"Usage: show service SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -251,7 +281,7 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_SERVICE}
|
{ARG_TYPE_SERVICE}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"session", 1, 1, dprintSession,
|
"session", 1, 1, (FN)dprintSession,
|
||||||
"Show session details",
|
"Show session details",
|
||||||
"Usage: show session SESSION\n"
|
"Usage: show session SESSION\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -262,31 +292,31 @@ struct subcommand showoptions[] =
|
|||||||
{ARG_TYPE_SESSION}
|
{ARG_TYPE_SESSION}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sessions", 0, 0, dprintAllSessions,
|
"sessions", 0, 0, (FN)dprintAllSessions,
|
||||||
"Show all active sessions in MaxScale",
|
"Show all active sessions in MaxScale",
|
||||||
"Usage: show sessions",
|
"Usage: show sessions",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tasks", 0, 0, hkshow_tasks,
|
"tasks", 0, 0, (FN)hkshow_tasks,
|
||||||
"Show all active housekeeper tasks in MaxScale",
|
"Show all active housekeeper tasks in MaxScale",
|
||||||
"Usage: show tasks",
|
"Usage: show tasks",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"threads", 0, 0, dShowThreads,
|
"threads", 0, 0, (FN)dShowThreads,
|
||||||
"Show the status of the worker threads in MaxScale",
|
"Show the status of the worker threads in MaxScale",
|
||||||
"Usage: show threads",
|
"Usage: show threads",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"users", 0, 0, telnetdShowUsers,
|
"users", 0, 0, (FN)telnetdShowUsers,
|
||||||
"Show enabled Linux accounts",
|
"Show enabled Linux accounts",
|
||||||
"Usage: show users",
|
"Usage: show users",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"version", 0, 0, showVersion,
|
"version", 0, 0, (FN)showVersion,
|
||||||
"Show the MaxScale version number",
|
"Show the MaxScale version number",
|
||||||
"Usage: show version",
|
"Usage: show version",
|
||||||
{0}
|
{0}
|
||||||
@ -336,67 +366,67 @@ void dListCommands(DCB *dcb, const char *domain, const char *ident)
|
|||||||
struct subcommand listoptions[] =
|
struct subcommand listoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"clients", 0, 0, dListClients,
|
"clients", 0, 0, (FN)dListClients,
|
||||||
"List all the client connections to MaxScale",
|
"List all the client connections to MaxScale",
|
||||||
"Usage: list clients",
|
"Usage: list clients",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dcbs", 0, 0, dListDCBs,
|
"dcbs", 0, 0, (FN)dListDCBs,
|
||||||
"List all active connections within MaxScale",
|
"List all active connections within MaxScale",
|
||||||
"Usage: list dcbs",
|
"Usage: list dcbs",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filters", 0, 0, dListFilters,
|
"filters", 0, 0, (FN)dListFilters,
|
||||||
"List all filters",
|
"List all filters",
|
||||||
"Usage: list filters",
|
"Usage: list filters",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"listeners", 0, 0, dListListeners,
|
"listeners", 0, 0, (FN)dListListeners,
|
||||||
"List all listeners",
|
"List all listeners",
|
||||||
"Usage: list listeners",
|
"Usage: list listeners",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"modules", 0, 0, dprintAllModules,
|
"modules", 0, 0, (FN)dprintAllModules,
|
||||||
"List all currently loaded modules",
|
"List all currently loaded modules",
|
||||||
"Usage: list modules",
|
"Usage: list modules",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitors", 0, 0, monitorList,
|
"monitors", 0, 0, (FN)monitorList,
|
||||||
"List all monitors",
|
"List all monitors",
|
||||||
"Usage: list monitors",
|
"Usage: list monitors",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"services", 0, 0, dListServices,
|
"services", 0, 0, (FN)dListServices,
|
||||||
"List all services",
|
"List all services",
|
||||||
"Usage: list services",
|
"Usage: list services",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"servers", 0, 0, dListServers,
|
"servers", 0, 0, (FN)dListServers,
|
||||||
"List all servers",
|
"List all servers",
|
||||||
"Usage: list servers",
|
"Usage: list servers",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"sessions", 0, 0, dListSessions,
|
"sessions", 0, 0, (FN)dListSessions,
|
||||||
"List all the active sessions within MaxScale",
|
"List all the active sessions within MaxScale",
|
||||||
"Usage: list sessions",
|
"Usage: list sessions",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"threads", 0, 0, dShowThreads,
|
"threads", 0, 0, (FN)dShowThreads,
|
||||||
"List the status of the polling threads in MaxScale",
|
"List the status of the polling threads in MaxScale",
|
||||||
"Usage: list threads",
|
"Usage: list threads",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"commands", 0, 2, dListCommands,
|
"commands", 0, 2, (FN)dListCommands,
|
||||||
"List registered commands",
|
"List registered commands",
|
||||||
"Usage: list commands [MODULE] [COMMAND]\n"
|
"Usage: list commands [MODULE] [COMMAND]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -439,7 +469,7 @@ struct subcommand shutdownoptions[] =
|
|||||||
{
|
{
|
||||||
"maxscale",
|
"maxscale",
|
||||||
0, 0,
|
0, 0,
|
||||||
shutdown_server,
|
(FN)shutdown_server,
|
||||||
"Initiate a controlled shutdown of MaxScale",
|
"Initiate a controlled shutdown of MaxScale",
|
||||||
"Usage: shutdown maxscale",
|
"Usage: shutdown maxscale",
|
||||||
{0}
|
{0}
|
||||||
@ -447,7 +477,7 @@ struct subcommand shutdownoptions[] =
|
|||||||
{
|
{
|
||||||
"monitor",
|
"monitor",
|
||||||
1, 1,
|
1, 1,
|
||||||
shutdown_monitor,
|
(FN)shutdown_monitor,
|
||||||
"Stop a monitor",
|
"Stop a monitor",
|
||||||
"Usage: shutdown monitor MONITOR\n"
|
"Usage: shutdown monitor MONITOR\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -460,7 +490,7 @@ struct subcommand shutdownoptions[] =
|
|||||||
{
|
{
|
||||||
"service",
|
"service",
|
||||||
1, 1,
|
1, 1,
|
||||||
shutdown_service,
|
(FN)shutdown_service,
|
||||||
"Stop a service",
|
"Stop a service",
|
||||||
"Usage: shutdown service SERVICE\n"
|
"Usage: shutdown service SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -473,7 +503,7 @@ struct subcommand shutdownoptions[] =
|
|||||||
{
|
{
|
||||||
"listener",
|
"listener",
|
||||||
2, 2,
|
2, 2,
|
||||||
shutdown_listener,
|
(FN)shutdown_listener,
|
||||||
"Stop a listener",
|
"Stop a listener",
|
||||||
"Usage: shutdown listener SERVICE LISTENER\n"
|
"Usage: shutdown listener SERVICE LISTENER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -507,7 +537,7 @@ struct subcommand syncoptions[] =
|
|||||||
{
|
{
|
||||||
"logs",
|
"logs",
|
||||||
0, 0,
|
0, 0,
|
||||||
sync_logs,
|
(FN)sync_logs,
|
||||||
"Flush log files to disk",
|
"Flush log files to disk",
|
||||||
"Usage: flush logs",
|
"Usage: flush logs",
|
||||||
{0}
|
{0}
|
||||||
@ -539,7 +569,7 @@ restart_listener(DCB *dcb, SERVICE *service, const char *name)
|
|||||||
struct subcommand restartoptions[] =
|
struct subcommand restartoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"monitor", 1, 1, restart_monitor,
|
"monitor", 1, 1, (FN)restart_monitor,
|
||||||
"Restart a monitor",
|
"Restart a monitor",
|
||||||
"Usage: restart monitor NAME\n"
|
"Usage: restart monitor NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -550,7 +580,7 @@ struct subcommand restartoptions[] =
|
|||||||
{ARG_TYPE_MONITOR}
|
{ARG_TYPE_MONITOR}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"service", 1, 1, restart_service,
|
"service", 1, 1, (FN)restart_service,
|
||||||
"Restart a service",
|
"Restart a service",
|
||||||
"Usage: restart service NAME\n"
|
"Usage: restart service NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -561,7 +591,7 @@ struct subcommand restartoptions[] =
|
|||||||
{ARG_TYPE_SERVICE}
|
{ARG_TYPE_SERVICE}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"listener", 2, 2, restart_listener,
|
"listener", 2, 2, (FN)restart_listener,
|
||||||
"Restart a listener",
|
"Restart a listener",
|
||||||
"Usage: restart listener NAME\n"
|
"Usage: restart listener NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -584,7 +614,7 @@ static void set_log_throttling(DCB *dcb, int count, int window_ms, int suppress_
|
|||||||
struct subcommand setoptions[] =
|
struct subcommand setoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"server", 2, 2, set_server,
|
"server", 2, 2, (FN)set_server,
|
||||||
"Set the status of a server",
|
"Set the status of a server",
|
||||||
"Usage: set server NAME STATUS\n"
|
"Usage: set server NAME STATUS\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -596,19 +626,19 @@ struct subcommand setoptions[] =
|
|||||||
{ARG_TYPE_SERVER, ARG_TYPE_OBJECT_NAME}
|
{ARG_TYPE_SERVER, ARG_TYPE_OBJECT_NAME}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pollsleep", 1, 1, set_pollsleep,
|
"pollsleep", 1, 1, (FN)set_pollsleep,
|
||||||
"Set poll sleep period",
|
"Set poll sleep period",
|
||||||
"Deprecated in 2.3",
|
"Deprecated in 2.3",
|
||||||
{ARG_TYPE_NUMERIC}
|
{ARG_TYPE_NUMERIC}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nbpolls", 1, 1, set_nbpoll,
|
"nbpolls", 1, 1, (FN)set_nbpoll,
|
||||||
"Set non-blocking polls",
|
"Set non-blocking polls",
|
||||||
"Deprecated in 2.3",
|
"Deprecated in 2.3",
|
||||||
{ARG_TYPE_NUMERIC}
|
{ARG_TYPE_NUMERIC}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"log_throttling", 3, 3, set_log_throttling,
|
"log_throttling", 3, 3, (FN)set_log_throttling,
|
||||||
"Set the log throttling configuration",
|
"Set the log throttling configuration",
|
||||||
"Usage: set log_throttling COUNT WINDOW SUPPRESS\n"
|
"Usage: set log_throttling COUNT WINDOW SUPPRESS\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -630,7 +660,7 @@ static void clear_server(DCB *dcb, SERVER *server, char *bit);
|
|||||||
struct subcommand clearoptions[] =
|
struct subcommand clearoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"server", 2, 2, clear_server,
|
"server", 2, 2, (FN)clear_server,
|
||||||
"Clear server status",
|
"Clear server status",
|
||||||
"Usage: clear server NAME STATUS\n"
|
"Usage: clear server NAME STATUS\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -653,13 +683,13 @@ static void reload_config(DCB *dcb);
|
|||||||
struct subcommand reloadoptions[] =
|
struct subcommand reloadoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"config", 0, 0, reload_config,
|
"config", 0, 0, (FN)reload_config,
|
||||||
"[Deprecated] Reload the configuration",
|
"[Deprecated] Reload the configuration",
|
||||||
"Usage: reload config",
|
"Usage: reload config",
|
||||||
{0}
|
{0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"dbusers", 1, 1, reload_dbusers,
|
"dbusers", 1, 1, (FN)reload_dbusers,
|
||||||
"Reload the database users for a service",
|
"Reload the database users for a service",
|
||||||
"Usage: reload dbusers SERVICE\n"
|
"Usage: reload dbusers SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -694,7 +724,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"log-priority",
|
"log-priority",
|
||||||
1, 1,
|
1, 1,
|
||||||
enable_log_priority,
|
(FN)enable_log_priority,
|
||||||
"Enable a logging priority",
|
"Enable a logging priority",
|
||||||
"Usage: enable log-priority PRIORITY\n"
|
"Usage: enable log-priority PRIORITY\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -707,7 +737,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"sessionlog-priority",
|
"sessionlog-priority",
|
||||||
2, 2,
|
2, 2,
|
||||||
enable_sess_log_priority,
|
(FN)enable_sess_log_priority,
|
||||||
"[Deprecated] Enable a logging priority for a session",
|
"[Deprecated] Enable a logging priority for a session",
|
||||||
"This command is deprecated",
|
"This command is deprecated",
|
||||||
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME}
|
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME}
|
||||||
@ -715,7 +745,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"root",
|
"root",
|
||||||
1, 1,
|
1, 1,
|
||||||
enable_service_root,
|
(FN)enable_service_root,
|
||||||
"Enable root user access to a service",
|
"Enable root user access to a service",
|
||||||
"Usage: enable root SERVICE\n"
|
"Usage: enable root SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -728,7 +758,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"syslog",
|
"syslog",
|
||||||
0, 0,
|
0, 0,
|
||||||
enable_syslog,
|
(FN)enable_syslog,
|
||||||
"Enable syslog logging",
|
"Enable syslog logging",
|
||||||
"Usage: enable syslog",
|
"Usage: enable syslog",
|
||||||
{0}
|
{0}
|
||||||
@ -736,7 +766,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"maxlog",
|
"maxlog",
|
||||||
0, 0,
|
0, 0,
|
||||||
enable_maxlog,
|
(FN)enable_maxlog,
|
||||||
"Enable MaxScale logging",
|
"Enable MaxScale logging",
|
||||||
"Usage: enable maxlog",
|
"Usage: enable maxlog",
|
||||||
{0}
|
{0}
|
||||||
@ -744,7 +774,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"account",
|
"account",
|
||||||
1, 1,
|
1, 1,
|
||||||
enable_admin_account,
|
(FN)enable_admin_account,
|
||||||
"Activate a Linux user account for administrative MaxAdmin use",
|
"Activate a Linux user account for administrative MaxAdmin use",
|
||||||
"Usage: enable account USER\n"
|
"Usage: enable account USER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -757,7 +787,7 @@ struct subcommand enableoptions[] =
|
|||||||
{
|
{
|
||||||
"readonly-account",
|
"readonly-account",
|
||||||
1, 1,
|
1, 1,
|
||||||
enable_account,
|
(FN)enable_account,
|
||||||
"Activate a Linux user account for read-only MaxAdmin use",
|
"Activate a Linux user account for read-only MaxAdmin use",
|
||||||
"Usage: enable account USER\n"
|
"Usage: enable account USER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -782,7 +812,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"log-priority",
|
"log-priority",
|
||||||
1, 1,
|
1, 1,
|
||||||
disable_log_priority,
|
(FN)disable_log_priority,
|
||||||
"Disable a logging priority",
|
"Disable a logging priority",
|
||||||
"Usage: disable log-priority PRIORITY\n"
|
"Usage: disable log-priority PRIORITY\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -795,7 +825,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"sessionlog-priority",
|
"sessionlog-priority",
|
||||||
2, 2,
|
2, 2,
|
||||||
disable_sess_log_priority,
|
(FN)disable_sess_log_priority,
|
||||||
"[Deprecated] Disable a logging priority for a particular session",
|
"[Deprecated] Disable a logging priority for a particular session",
|
||||||
"This command is deprecated",
|
"This command is deprecated",
|
||||||
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME}
|
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_OBJECT_NAME}
|
||||||
@ -803,7 +833,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"root",
|
"root",
|
||||||
1, 1,
|
1, 1,
|
||||||
disable_service_root,
|
(FN)disable_service_root,
|
||||||
"Disable root access",
|
"Disable root access",
|
||||||
"Usage: disable root SERVICE\n"
|
"Usage: disable root SERVICE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -816,7 +846,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"syslog",
|
"syslog",
|
||||||
0, 0,
|
0, 0,
|
||||||
disable_syslog,
|
(FN)disable_syslog,
|
||||||
"Disable syslog logging",
|
"Disable syslog logging",
|
||||||
"Usage: disable syslog",
|
"Usage: disable syslog",
|
||||||
{0}
|
{0}
|
||||||
@ -824,7 +854,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"maxlog",
|
"maxlog",
|
||||||
0, 0,
|
0, 0,
|
||||||
disable_maxlog,
|
(FN)disable_maxlog,
|
||||||
"Disable MaxScale logging",
|
"Disable MaxScale logging",
|
||||||
"Usage: disable maxlog",
|
"Usage: disable maxlog",
|
||||||
{0}
|
{0}
|
||||||
@ -832,7 +862,7 @@ struct subcommand disableoptions[] =
|
|||||||
{
|
{
|
||||||
"account",
|
"account",
|
||||||
1, 1,
|
1, 1,
|
||||||
disable_account,
|
(FN)disable_account,
|
||||||
"Disable Linux user",
|
"Disable Linux user",
|
||||||
"Usage: disable account USER\n"
|
"Usage: disable account USER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -884,7 +914,7 @@ void ping_workers(DCB* dcb)
|
|||||||
struct subcommand pingoptions[] =
|
struct subcommand pingoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"workers", 0, 0, ping_workers,
|
"workers", 0, 0, (FN)ping_workers,
|
||||||
"Ping Workers",
|
"Ping Workers",
|
||||||
"Ping Workers",
|
"Ping Workers",
|
||||||
{ARG_TYPE_NONE}
|
{ARG_TYPE_NONE}
|
||||||
@ -898,7 +928,7 @@ struct subcommand pingoptions[] =
|
|||||||
struct subcommand addoptions[] =
|
struct subcommand addoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"user", 2, 2, inet_add_admin_user,
|
"user", 2, 2, (FN)inet_add_admin_user,
|
||||||
"Add an administrative account for using maxadmin over the network",
|
"Add an administrative account for using maxadmin over the network",
|
||||||
"Usage: add user USER PASSWORD\n"
|
"Usage: add user USER PASSWORD\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -910,7 +940,7 @@ struct subcommand addoptions[] =
|
|||||||
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_STRING}
|
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_STRING}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"readonly-user", 2, 2, inet_add_user,
|
"readonly-user", 2, 2, (FN)inet_add_user,
|
||||||
"Add a read-only account for using maxadmin over the network",
|
"Add a read-only account for using maxadmin over the network",
|
||||||
"Usage: add user USER PASSWORD\n"
|
"Usage: add user USER PASSWORD\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -922,7 +952,7 @@ struct subcommand addoptions[] =
|
|||||||
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_STRING}
|
{ARG_TYPE_OBJECT_NAME, ARG_TYPE_STRING}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"server", 2, 12, cmd_AddServer,
|
"server", 2, 12, (FN)cmd_AddServer,
|
||||||
"Add a new server to a service",
|
"Add a new server to a service",
|
||||||
"Usage: add server SERVER TARGET...\n"
|
"Usage: add server SERVER TARGET...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -973,7 +1003,7 @@ struct subcommand removeoptions[] =
|
|||||||
{
|
{
|
||||||
"user",
|
"user",
|
||||||
1, 1,
|
1, 1,
|
||||||
telnetdRemoveUser,
|
(FN)telnetdRemoveUser,
|
||||||
"Remove account for using maxadmin over the network",
|
"Remove account for using maxadmin over the network",
|
||||||
"Usage: remove user USER\n"
|
"Usage: remove user USER\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -984,7 +1014,7 @@ struct subcommand removeoptions[] =
|
|||||||
{ARG_TYPE_STRING}
|
{ARG_TYPE_STRING}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"server", 2, 12, cmd_RemoveServer,
|
"server", 2, 12, (FN)cmd_RemoveServer,
|
||||||
"Remove a server from a service or a monitor",
|
"Remove a server from a service or a monitor",
|
||||||
"Usage: remove server SERVER TARGET...\n"
|
"Usage: remove server SERVER TARGET...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1080,7 +1110,7 @@ struct subcommand flushoptions[] =
|
|||||||
{
|
{
|
||||||
"log",
|
"log",
|
||||||
1, 1,
|
1, 1,
|
||||||
flushlog,
|
(FN)flushlog,
|
||||||
"Flush the content of a log file and reopen it",
|
"Flush the content of a log file and reopen it",
|
||||||
"Usage: flush log",
|
"Usage: flush log",
|
||||||
{ARG_TYPE_STRING}
|
{ARG_TYPE_STRING}
|
||||||
@ -1088,7 +1118,7 @@ struct subcommand flushoptions[] =
|
|||||||
{
|
{
|
||||||
"logs",
|
"logs",
|
||||||
0, 0,
|
0, 0,
|
||||||
flushlogs,
|
(FN)flushlogs,
|
||||||
"Flush the content of a log file and reopen it",
|
"Flush the content of a log file and reopen it",
|
||||||
"Usage: flush logs",
|
"Usage: flush logs",
|
||||||
{0}
|
{0}
|
||||||
@ -1172,7 +1202,7 @@ static void createMonitor(DCB *dcb, const char *name, const char *module)
|
|||||||
struct subcommand createoptions[] =
|
struct subcommand createoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"server", 2, 6, createServer,
|
"server", 2, 6, (FN)createServer,
|
||||||
"Create a new server",
|
"Create a new server",
|
||||||
"Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n"
|
"Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1193,7 +1223,7 @@ struct subcommand createoptions[] =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"listener", 2, 12, createListener,
|
"listener", 2, 12, (FN)createListener,
|
||||||
"Create a new listener for a service",
|
"Create a new listener for a service",
|
||||||
"Usage: create listener SERVICE NAME [HOST] [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n"
|
"Usage: create listener SERVICE NAME [HOST] [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n"
|
||||||
" [SSL_KEY] [SSL_CERT] [SSL_CA] [SSL_VERSION] [SSL_VERIFY_DEPTH]\n"
|
" [SSL_KEY] [SSL_CERT] [SSL_CA] [SSL_VERSION] [SSL_VERIFY_DEPTH]\n"
|
||||||
@ -1225,7 +1255,7 @@ struct subcommand createoptions[] =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitor", 2, 2, createMonitor,
|
"monitor", 2, 2, (FN)createMonitor,
|
||||||
"Create a new monitor",
|
"Create a new monitor",
|
||||||
"Usage: create monitor NAME MODULE\n"
|
"Usage: create monitor NAME MODULE\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1292,7 +1322,7 @@ static void destroyMonitor(DCB *dcb, MXS_MONITOR *monitor)
|
|||||||
struct subcommand destroyoptions[] =
|
struct subcommand destroyoptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"server", 1, 1, destroyServer,
|
"server", 1, 1, (FN)destroyServer,
|
||||||
"Destroy a server",
|
"Destroy a server",
|
||||||
"Usage: destroy server NAME\n"
|
"Usage: destroy server NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1303,7 +1333,7 @@ struct subcommand destroyoptions[] =
|
|||||||
{ARG_TYPE_SERVER}
|
{ARG_TYPE_SERVER}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"listener", 2, 2, destroyListener,
|
"listener", 2, 2, (FN)destroyListener,
|
||||||
"Destroy a listener",
|
"Destroy a listener",
|
||||||
"Usage: destroy listener SERVICE NAME\n"
|
"Usage: destroy listener SERVICE NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1316,7 +1346,7 @@ struct subcommand destroyoptions[] =
|
|||||||
{ARG_TYPE_SERVICE, ARG_TYPE_OBJECT_NAME}
|
{ARG_TYPE_SERVICE, ARG_TYPE_OBJECT_NAME}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitor", 1, 1, destroyMonitor,
|
"monitor", 1, 1, (FN)destroyMonitor,
|
||||||
"Destroy a monitor",
|
"Destroy a monitor",
|
||||||
"Usage: destroy monitor NAME\n"
|
"Usage: destroy monitor NAME\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1510,7 +1540,7 @@ static void alterMaxScale(DCB *dcb, char *v1, char *v2, char *v3,
|
|||||||
struct subcommand alteroptions[] =
|
struct subcommand alteroptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"server", 2, 12, alterServer,
|
"server", 2, 12, (FN)alterServer,
|
||||||
"Alter server parameters",
|
"Alter server parameters",
|
||||||
"Usage: alter server NAME KEY=VALUE ...\n"
|
"Usage: alter server NAME KEY=VALUE ...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1544,7 +1574,7 @@ struct subcommand alteroptions[] =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"monitor", 2, 12, alterMonitor,
|
"monitor", 2, 12, (FN)alterMonitor,
|
||||||
"Alter monitor parameters",
|
"Alter monitor parameters",
|
||||||
"Usage: alter monitor NAME KEY=VALUE ...\n"
|
"Usage: alter monitor NAME KEY=VALUE ...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1574,7 +1604,7 @@ struct subcommand alteroptions[] =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"service", 2, 12, alterService,
|
"service", 2, 12, (FN)alterService,
|
||||||
"Alter service parameters",
|
"Alter service parameters",
|
||||||
"Usage: alter service NAME KEY=VALUE ...\n"
|
"Usage: alter service NAME KEY=VALUE ...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1605,7 +1635,7 @@ struct subcommand alteroptions[] =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"maxscale", 1, 11, alterMaxScale,
|
"maxscale", 1, 11, (FN)alterMaxScale,
|
||||||
"Alter maxscale parameters",
|
"Alter maxscale parameters",
|
||||||
"Usage: alter maxscale KEY=VALUE ...\n"
|
"Usage: alter maxscale KEY=VALUE ...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1694,7 +1724,7 @@ static void callModuleCommand(DCB *dcb, char *domain, char *id, char *v3,
|
|||||||
struct subcommand calloptions[] =
|
struct subcommand calloptions[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"command", 2, 12, callModuleCommand,
|
"command", 2, 12, (FN)callModuleCommand,
|
||||||
"Call module command",
|
"Call module command",
|
||||||
"Usage: call command MODULE COMMAND ARGS...\n"
|
"Usage: call command MODULE COMMAND ARGS...\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -1722,7 +1752,7 @@ struct subcommand calloptions[] =
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *cmd;
|
const char *cmd;
|
||||||
struct subcommand *options;
|
struct subcommand *options;
|
||||||
} cmds[] =
|
} cmds[] =
|
||||||
{
|
{
|
||||||
@ -1825,7 +1855,7 @@ static void free_arg(int arg_type, void *value)
|
|||||||
switch (arg_type)
|
switch (arg_type)
|
||||||
{
|
{
|
||||||
case ARG_TYPE_SESSION:
|
case ARG_TYPE_SESSION:
|
||||||
session_put_ref(value);
|
session_put_ref(static_cast<MXS_SESSION*>(value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2067,55 +2097,55 @@ execute_cmd(CLI_SESSION *cli)
|
|||||||
cmds[i].options[j].fn(dcb);
|
cmds[i].options[j].fn(dcb);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0]);
|
((FN1)cmds[i].options[j].fn)(dcb, arg_list[0]);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1]);
|
((FN2)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2]);
|
((FN3)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2]);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN4)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3]);
|
arg_list[3]);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN5)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4]);
|
arg_list[3], arg_list[4]);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN6)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5]);
|
arg_list[3], arg_list[4], arg_list[5]);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN7)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6]);
|
arg_list[6]);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN8)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6], arg_list[7]);
|
arg_list[6], arg_list[7]);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN9)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6], arg_list[7], arg_list[8]);
|
arg_list[6], arg_list[7], arg_list[8]);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN10)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6], arg_list[7], arg_list[8],
|
arg_list[6], arg_list[7], arg_list[8],
|
||||||
arg_list[9]);
|
arg_list[9]);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN11)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6], arg_list[7], arg_list[8],
|
arg_list[6], arg_list[7], arg_list[8],
|
||||||
arg_list[9], arg_list[10]);
|
arg_list[9], arg_list[10]);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
cmds[i].options[j].fn(dcb, arg_list[0], arg_list[1], arg_list[2],
|
((FN12)cmds[i].options[j].fn)(dcb, arg_list[0], arg_list[1], arg_list[2],
|
||||||
arg_list[3], arg_list[4], arg_list[5],
|
arg_list[3], arg_list[4], arg_list[5],
|
||||||
arg_list[6], arg_list[7], arg_list[8],
|
arg_list[6], arg_list[7], arg_list[8],
|
||||||
arg_list[9], arg_list[10], arg_list[11]);
|
arg_list[9], arg_list[10], arg_list[11]);
|
||||||
@ -2453,12 +2483,14 @@ static int string_to_priority(const char* name)
|
|||||||
const size_t N_LOG_PRIORITY_ENTRIES = sizeof(LOG_PRIORITY_ENTRIES) / sizeof(LOG_PRIORITY_ENTRIES[0]);
|
const size_t N_LOG_PRIORITY_ENTRIES = sizeof(LOG_PRIORITY_ENTRIES) / sizeof(LOG_PRIORITY_ENTRIES[0]);
|
||||||
|
|
||||||
struct log_priority_entry key = { name, -1 };
|
struct log_priority_entry key = { name, -1 };
|
||||||
struct log_priority_entry* result = bsearch(&key,
|
void* value = bsearch(&key,
|
||||||
LOG_PRIORITY_ENTRIES,
|
LOG_PRIORITY_ENTRIES,
|
||||||
N_LOG_PRIORITY_ENTRIES,
|
N_LOG_PRIORITY_ENTRIES,
|
||||||
sizeof(struct log_priority_entry),
|
sizeof(struct log_priority_entry),
|
||||||
compare_log_priority_entries);
|
compare_log_priority_entries);
|
||||||
|
|
||||||
|
struct log_priority_entry* result = static_cast<struct log_priority_entry*>(value);
|
||||||
|
|
||||||
return result ? result->priority : -1;
|
return result ? result->priority : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2561,7 +2593,9 @@ set_log_throttling(DCB *dcb, int count, int window_ms, int suppress_ms)
|
|||||||
{
|
{
|
||||||
if ((count >= 0) || (window_ms >= 0) || (suppress_ms >= 0))
|
if ((count >= 0) || (window_ms >= 0) || (suppress_ms >= 0))
|
||||||
{
|
{
|
||||||
MXS_LOG_THROTTLING t = { count, window_ms, suppress_ms };
|
MXS_LOG_THROTTLING t = { static_cast<size_t>(count),
|
||||||
|
static_cast<size_t>(window_ms),
|
||||||
|
static_cast<size_t>(suppress_ms) };
|
||||||
|
|
||||||
mxs_log_set_throttling(&t);
|
mxs_log_set_throttling(&t);
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
add_library(maxinfo SHARED maxinfo.c maxinfo_parse.c maxinfo_error.c maxinfo_exec.c)
|
add_library(maxinfo SHARED maxinfo.cc maxinfo_parse.cc maxinfo_error.cc maxinfo_exec.cc)
|
||||||
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "1.0.0")
|
set_target_properties(maxinfo PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR} VERSION "1.0.0")
|
||||||
target_link_libraries(maxinfo maxscale-common)
|
target_link_libraries(maxinfo maxscale-common)
|
||||||
install_module(maxinfo core)
|
install_module(maxinfo core)
|
||||||
|
|||||||
@ -92,7 +92,7 @@ static INFO_INSTANCE *instances;
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise MaxInfo router module.");
|
MXS_NOTICE("Initialise MaxInfo router module.");
|
||||||
spinlock_init(&instlock);
|
spinlock_init(&instlock);
|
||||||
@ -149,7 +149,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
INFO_INSTANCE *inst;
|
INFO_INSTANCE *inst;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((inst = MXS_MALLOC(sizeof(INFO_INSTANCE))) == NULL)
|
if ((inst = static_cast<INFO_INSTANCE*>(MXS_MALLOC(sizeof(INFO_INSTANCE)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
|
|
||||||
session->state = SESSION_STATE_READY;
|
session->state = SESSION_STATE_READY;
|
||||||
|
|
||||||
return (void *)client;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -329,7 +329,7 @@ execute(MXS_ROUTER *rinstance, MXS_ROUTER_SESSION *router_session, GWBUF *queue)
|
|||||||
}
|
}
|
||||||
data = (uint8_t *)GWBUF_DATA(queue);
|
data = (uint8_t *)GWBUF_DATA(queue);
|
||||||
length = data[0] + (data[1] << 8) + (data[2] << 16);
|
length = data[0] + (data[1] << 8) + (data[2] << 16);
|
||||||
if (length + 4 > GWBUF_LENGTH(queue))
|
if (length + 4 > static_cast<int>(GWBUF_LENGTH(queue)))
|
||||||
{
|
{
|
||||||
// Incomplete packet, must be buffered
|
// Incomplete packet, must be buffered
|
||||||
session->queue = queue;
|
session->queue = queue;
|
||||||
@ -684,7 +684,7 @@ typedef RESULTSET *(*RESULTSETFUNC)();
|
|||||||
*/
|
*/
|
||||||
static struct uri_table
|
static struct uri_table
|
||||||
{
|
{
|
||||||
char *uri;
|
const char *uri;
|
||||||
RESULTSETFUNC func;
|
RESULTSETFUNC func;
|
||||||
} supported_uri[] =
|
} supported_uri[] =
|
||||||
{
|
{
|
||||||
@ -135,9 +135,8 @@ typedef enum
|
|||||||
extern MAXINFO_TREE *maxinfo_parse(char *, PARSE_ERROR *);
|
extern MAXINFO_TREE *maxinfo_parse(char *, PARSE_ERROR *);
|
||||||
extern void maxinfo_free_tree(MAXINFO_TREE *);
|
extern void maxinfo_free_tree(MAXINFO_TREE *);
|
||||||
extern void maxinfo_execute(DCB *, MAXINFO_TREE *);
|
extern void maxinfo_execute(DCB *, MAXINFO_TREE *);
|
||||||
extern void maxinfo_send_error(DCB *, int, char *);
|
extern void maxinfo_send_error(DCB *, int, const char *);
|
||||||
extern void maxinfo_send_parse_error(DCB *, char *, PARSE_ERROR);
|
extern void maxinfo_send_parse_error(DCB *, char *, PARSE_ERROR);
|
||||||
extern void maxinfo_send_error(DCB *, int, char *);
|
|
||||||
extern RESULTSET *maxinfo_variables();
|
extern RESULTSET *maxinfo_variables();
|
||||||
extern RESULTSET *maxinfo_status();
|
extern RESULTSET *maxinfo_status();
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@
|
|||||||
void
|
void
|
||||||
maxinfo_send_parse_error(DCB *dcb, char *sql, PARSE_ERROR err)
|
maxinfo_send_parse_error(DCB *dcb, char *sql, PARSE_ERROR err)
|
||||||
{
|
{
|
||||||
char *desc = "";
|
const char *desc = "";
|
||||||
char *msg;
|
char *msg;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ maxinfo_send_parse_error(DCB *dcb, char *sql, PARSE_ERROR err)
|
|||||||
* @param msg The slave server instance
|
* @param msg The slave server instance
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
maxinfo_send_error(DCB *dcb, int errcode, char *msg)
|
maxinfo_send_error(DCB *dcb, int errcode, const char *msg)
|
||||||
{
|
{
|
||||||
GWBUF *pkt;
|
GWBUF *pkt;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -55,7 +55,7 @@ static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
|
|||||||
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);
|
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);
|
||||||
static void exec_show_status(DCB *dcb, MAXINFO_TREE *filter);
|
static void exec_show_status(DCB *dcb, MAXINFO_TREE *filter);
|
||||||
static int maxinfo_pattern_match(char *pattern, char *str);
|
static int maxinfo_pattern_match(const char *pattern, const char *str);
|
||||||
static void exec_flush(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_flush(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
static void exec_set(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_set(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
static void exec_clear(DCB *dcb, MAXINFO_TREE *tree);
|
static void exec_clear(DCB *dcb, MAXINFO_TREE *tree);
|
||||||
@ -272,7 +272,7 @@ exec_show_eventTimes(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} show_commands[] =
|
} show_commands[] =
|
||||||
{
|
{
|
||||||
@ -334,7 +334,7 @@ void exec_flush_logs(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} flush_commands[] =
|
} flush_commands[] =
|
||||||
{
|
{
|
||||||
@ -421,7 +421,7 @@ void exec_set_server(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} set_commands[] =
|
} set_commands[] =
|
||||||
{
|
{
|
||||||
@ -502,7 +502,7 @@ void exec_clear_server(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} clear_commands[] =
|
} clear_commands[] =
|
||||||
{
|
{
|
||||||
@ -621,7 +621,7 @@ void exec_shutdown_service(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} shutdown_commands[] =
|
} shutdown_commands[] =
|
||||||
{
|
{
|
||||||
@ -731,7 +731,7 @@ void exec_restart_service(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
void (*func)(DCB *, MAXINFO_TREE *);
|
void (*func)(DCB *, MAXINFO_TREE *);
|
||||||
} restart_commands[] =
|
} restart_commands[] =
|
||||||
{
|
{
|
||||||
@ -777,10 +777,10 @@ exec_restart(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
static char *
|
static char *
|
||||||
getVersion()
|
getVersion()
|
||||||
{
|
{
|
||||||
return MAXSCALE_VERSION;
|
return const_cast<char*>(MAXSCALE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *versionComment = "MariaDB MaxScale";
|
static const char *versionComment = "MariaDB MaxScale";
|
||||||
/**
|
/**
|
||||||
* Return the current MaxScale version
|
* Return the current MaxScale version
|
||||||
*
|
*
|
||||||
@ -789,7 +789,7 @@ static char *versionComment = "MariaDB MaxScale";
|
|||||||
static char *
|
static char *
|
||||||
getVersionComment()
|
getVersionComment()
|
||||||
{
|
{
|
||||||
return versionComment;
|
return const_cast<char*>(versionComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -813,7 +813,7 @@ typedef void *(*STATSFUNC)();
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
int type;
|
int type;
|
||||||
STATSFUNC func;
|
STATSFUNC func;
|
||||||
} variables[] =
|
} variables[] =
|
||||||
@ -833,7 +833,7 @@ static struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
char *like;
|
const char *like;
|
||||||
} VARCONTEXT;
|
} VARCONTEXT;
|
||||||
/**
|
/**
|
||||||
* Callback function to populate rows of the show variable
|
* Callback function to populate rows of the show variable
|
||||||
@ -894,7 +894,7 @@ exec_show_variables(DCB *dcb, MAXINFO_TREE *filter)
|
|||||||
RESULTSET *result;
|
RESULTSET *result;
|
||||||
VARCONTEXT *context;
|
VARCONTEXT *context;
|
||||||
|
|
||||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -931,7 +931,7 @@ maxinfo_variables()
|
|||||||
{
|
{
|
||||||
RESULTSET *result;
|
RESULTSET *result;
|
||||||
VARCONTEXT *context;
|
VARCONTEXT *context;
|
||||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1079,7 +1079,7 @@ maxinfo_max_event_exec_time()
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *name;
|
const char *name;
|
||||||
int type;
|
int type;
|
||||||
STATSFUNC func;
|
STATSFUNC func;
|
||||||
} status[] =
|
} status[] =
|
||||||
@ -1166,7 +1166,7 @@ exec_show_status(DCB *dcb, MAXINFO_TREE *filter)
|
|||||||
RESULTSET *result;
|
RESULTSET *result;
|
||||||
VARCONTEXT *context;
|
VARCONTEXT *context;
|
||||||
|
|
||||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1203,7 +1203,7 @@ maxinfo_status()
|
|||||||
{
|
{
|
||||||
RESULTSET *result;
|
RESULTSET *result;
|
||||||
VARCONTEXT *context;
|
VARCONTEXT *context;
|
||||||
if ((context = MXS_MALLOC(sizeof(VARCONTEXT))) == NULL)
|
if ((context = static_cast<VARCONTEXT*>(MXS_MALLOC(sizeof(VARCONTEXT)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1242,10 +1242,10 @@ exec_select(DCB *dcb, MAXINFO_TREE *tree)
|
|||||||
* @return Zero on match
|
* @return Zero on match
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
maxinfo_pattern_match(char *pattern, char *str)
|
maxinfo_pattern_match(const char *pattern, const char *str)
|
||||||
{
|
{
|
||||||
int anchor = 0, len, trailing;
|
int anchor = 0, len, trailing;
|
||||||
char *fixed;
|
const char *fixed;
|
||||||
|
|
||||||
if (*pattern != '%')
|
if (*pattern != '%')
|
||||||
{
|
{
|
||||||
@ -1275,7 +1275,7 @@ maxinfo_pattern_match(char *pattern, char *str)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *portion = MXS_MALLOC(len + 1);
|
char *portion = static_cast<char*>(MXS_MALLOC(len + 1));
|
||||||
MXS_ABORT_IF_NULL(portion);
|
MXS_ABORT_IF_NULL(portion);
|
||||||
int rval;
|
int rval;
|
||||||
strncpy(portion, fixed, len - trailing);
|
strncpy(portion, fixed, len - trailing);
|
||||||
@ -305,7 +305,7 @@ maxinfo_free_tree(MAXINFO_TREE *tree)
|
|||||||
*/
|
*/
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char *text;
|
const char *text;
|
||||||
int token;
|
int token;
|
||||||
} keywords[] =
|
} keywords[] =
|
||||||
{
|
{
|
||||||
@ -1,4 +1,4 @@
|
|||||||
add_library(readconnroute SHARED readconnroute.c)
|
add_library(readconnroute SHARED readconnroute.cc)
|
||||||
target_link_libraries(readconnroute maxscale-common)
|
target_link_libraries(readconnroute maxscale-common)
|
||||||
set_target_properties(readconnroute PROPERTIES VERSION "1.1.0")
|
set_target_properties(readconnroute PROPERTIES VERSION "1.1.0")
|
||||||
install_module(readconnroute core)
|
install_module(readconnroute core)
|
||||||
|
|||||||
@ -112,7 +112,7 @@ static SERVER_REF *get_root_master(SERVER_REF *servers);
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
MXS_NOTICE("Initialise readconnroute router module.");
|
MXS_NOTICE("Initialise readconnroute router module.");
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ createInstance(SERVICE *service, char **options)
|
|||||||
SERVER_REF *sref;
|
SERVER_REF *sref;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
if ((inst = MXS_CALLOC(1, sizeof(ROUTER_INSTANCE))) == NULL)
|
if ((inst = static_cast<ROUTER_INSTANCE*>(MXS_CALLOC(1, sizeof(ROUTER_INSTANCE)))) == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
|
|||||||
MXS_INFO("New session for server %s. Connections : %d",
|
MXS_INFO("New session for server %s. Connections : %d",
|
||||||
candidate->server->name, candidate->connections);
|
candidate->server->name, candidate->connections);
|
||||||
|
|
||||||
return (void *) client_rses;
|
return reinterpret_cast<MXS_ROUTER_SESSION*>(client_rses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -613,6 +613,7 @@ routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queu
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool valid;
|
bool valid;
|
||||||
|
char* trc = NULL;
|
||||||
|
|
||||||
if (rses_is_closed || backend_dcb == NULL ||
|
if (rses_is_closed || backend_dcb == NULL ||
|
||||||
(valid = !connection_is_valid(inst, router_cli_ses)))
|
(valid = !connection_is_valid(inst, router_cli_ses)))
|
||||||
@ -623,8 +624,6 @@ routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, GWBUF *queu
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* trc = NULL;
|
|
||||||
|
|
||||||
switch (mysql_command)
|
switch (mysql_command)
|
||||||
{
|
{
|
||||||
case MXS_COM_CHANGE_USER:
|
case MXS_COM_CHANGE_USER:
|
||||||
@ -419,14 +419,12 @@ uint64_t RWSplit::getCapabilities()
|
|||||||
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING;
|
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The module entry point routine. It is this routine that must return
|
* The module entry point routine. It is this routine that must return
|
||||||
* the structure that is referred to as the "module object". This is a
|
* the structure that is referred to as the "module object". This is a
|
||||||
* structure with the set of external entry points for this module.
|
* structure with the set of external entry points for this module.
|
||||||
*/
|
*/
|
||||||
MXS_MODULE *MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE *MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
{
|
{
|
||||||
@ -485,5 +483,3 @@ MXS_MODULE *MXS_CREATE_MODULE()
|
|||||||
MXS_NOTICE("Initializing statement-based read/write split router module.");
|
MXS_NOTICE("Initializing statement-based read/write split router module.");
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_END_DECLS
|
|
||||||
|
|||||||
@ -369,8 +369,6 @@ uint64_t SchemaRouter::getCapabilities()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_BEGIN_DECLS
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The module entry point routine. It is this routine that
|
* The module entry point routine. It is this routine that
|
||||||
* must populate the structure that is referred to as the
|
* must populate the structure that is referred to as the
|
||||||
@ -379,7 +377,7 @@ MXS_BEGIN_DECLS
|
|||||||
*
|
*
|
||||||
* @return The module object
|
* @return The module object
|
||||||
*/
|
*/
|
||||||
MXS_MODULE* MXS_CREATE_MODULE()
|
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
|
||||||
{
|
{
|
||||||
static MXS_MODULE info =
|
static MXS_MODULE info =
|
||||||
{
|
{
|
||||||
@ -409,5 +407,3 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
|||||||
|
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
MXS_END_DECLS
|
|
||||||
|
|||||||
Reference in New Issue
Block a user