Remove typedefs from schemarouter enums
The enum typedefs weren't really useful in most cases.
This commit is contained in:
@ -24,12 +24,11 @@ bool connect_backend_servers(backend_ref_t* backend_ref,
|
|||||||
int router_nservers,
|
int router_nservers,
|
||||||
MXS_SESSION* session);
|
MXS_SESSION* session);
|
||||||
|
|
||||||
route_target_t get_shard_route_target(uint32_t qtype);
|
|
||||||
bool execute_sescmd_in_backend(backend_ref_t* backend_ref);
|
bool execute_sescmd_in_backend(backend_ref_t* backend_ref);
|
||||||
|
void bref_clear_state(backend_ref_t* bref, enum bref_state state);
|
||||||
|
void bref_set_state(backend_ref_t* bref, enum bref_state state);
|
||||||
|
|
||||||
void bref_clear_state(backend_ref_t* bref, bref_state_t state);
|
enum route_target get_shard_route_target(uint32_t qtype);
|
||||||
void bref_set_state(backend_ref_t* bref, bref_state_t state);
|
|
||||||
|
|
||||||
bool change_current_db(string& dest, Shard& shard, GWBUF* buf);
|
bool change_current_db(string& dest, Shard& shard, GWBUF* buf);
|
||||||
bool extract_database(GWBUF* buf, char* str);
|
bool extract_database(GWBUF* buf, char* str);
|
||||||
bool detect_show_shards(GWBUF* query);
|
bool detect_show_shards(GWBUF* query);
|
||||||
@ -259,7 +258,7 @@ static void inspect_query(GWBUF* pPacket, uint32_t* type, qc_query_op_t* op, uin
|
|||||||
SERVER* SchemaRouterSession::resolve_query_target(GWBUF* pPacket,
|
SERVER* SchemaRouterSession::resolve_query_target(GWBUF* pPacket,
|
||||||
uint32_t type,
|
uint32_t type,
|
||||||
uint8_t command,
|
uint8_t command,
|
||||||
route_target_t& route_target)
|
enum route_target& route_target)
|
||||||
{
|
{
|
||||||
SERVER* target = NULL;
|
SERVER* target = NULL;
|
||||||
|
|
||||||
@ -359,7 +358,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket)
|
|||||||
SERVER* target = NULL;
|
SERVER* target = NULL;
|
||||||
uint32_t type = QUERY_TYPE_UNKNOWN;
|
uint32_t type = QUERY_TYPE_UNKNOWN;
|
||||||
qc_query_op_t op = QUERY_OP_UNDEFINED;
|
qc_query_op_t op = QUERY_OP_UNDEFINED;
|
||||||
route_target_t route_target = TARGET_UNDEFINED;
|
enum route_target route_target = TARGET_UNDEFINED;
|
||||||
|
|
||||||
inspect_query(pPacket, &type, &op, &command);
|
inspect_query(pPacket, &type, &op, &command);
|
||||||
|
|
||||||
@ -1200,7 +1199,7 @@ int SchemaRouterSession::inspect_backend_mapping_states(backend_ref_t *bref,
|
|||||||
writebuf = gwbuf_append(bref->map_queue, writebuf);
|
writebuf = gwbuf_append(bref->map_queue, writebuf);
|
||||||
bref->map_queue = NULL;
|
bref->map_queue = NULL;
|
||||||
}
|
}
|
||||||
showdb_response_t rc = parse_showdb_response(&m_backends[i],
|
enum showdb_response rc = parse_showdb_response(&m_backends[i],
|
||||||
&writebuf);
|
&writebuf);
|
||||||
if (rc == SHOWDB_FULL_RESPONSE)
|
if (rc == SHOWDB_FULL_RESPONSE)
|
||||||
{
|
{
|
||||||
@ -1412,13 +1411,13 @@ char* get_lenenc_str(void* data)
|
|||||||
* @return 1 if a complete response was received, 0 if a partial response was received
|
* @return 1 if a complete response was received, 0 if a partial response was received
|
||||||
* and -1 if a database was found on more than one server.
|
* and -1 if a database was found on more than one server.
|
||||||
*/
|
*/
|
||||||
showdb_response_t SchemaRouterSession::parse_showdb_response(backend_ref_t* bref, GWBUF** buffer)
|
enum showdb_response SchemaRouterSession::parse_showdb_response(backend_ref_t* bref, GWBUF** buffer)
|
||||||
{
|
{
|
||||||
unsigned char* ptr;
|
unsigned char* ptr;
|
||||||
SERVER* target = bref->backend->server;
|
SERVER* target = bref->backend->server;
|
||||||
GWBUF* buf;
|
GWBUF* buf;
|
||||||
bool duplicate_found = false;
|
bool duplicate_found = false;
|
||||||
showdb_response_t rval = SHOWDB_PARTIAL_RESPONSE;
|
enum showdb_response rval = SHOWDB_PARTIAL_RESPONSE;
|
||||||
|
|
||||||
if (buffer == NULL || *buffer == NULL)
|
if (buffer == NULL || *buffer == NULL)
|
||||||
{
|
{
|
||||||
@ -1761,9 +1760,9 @@ return_succp:
|
|||||||
* @return bitfield including the routing target, or the target server name
|
* @return bitfield including the routing target, or the target server name
|
||||||
* if the query would otherwise be routed to slave.
|
* if the query would otherwise be routed to slave.
|
||||||
*/
|
*/
|
||||||
route_target_t get_shard_route_target(uint32_t qtype)
|
enum route_target get_shard_route_target(uint32_t qtype)
|
||||||
{
|
{
|
||||||
route_target_t target = TARGET_UNDEFINED;
|
enum route_target target = TARGET_UNDEFINED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These queries are not affected by hints
|
* These queries are not affected by hints
|
||||||
@ -1844,7 +1843,7 @@ bool SchemaRouterSession::send_database_list()
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bref_clear_state(backend_ref_t* bref, bref_state_t state)
|
void bref_clear_state(backend_ref_t* bref, enum bref_state state)
|
||||||
{
|
{
|
||||||
if (bref == NULL)
|
if (bref == NULL)
|
||||||
{
|
{
|
||||||
@ -1871,7 +1870,7 @@ void bref_clear_state(backend_ref_t* bref, bref_state_t state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bref_set_state(backend_ref_t* bref, bref_state_t state)
|
void bref_set_state(backend_ref_t* bref, enum bref_state state)
|
||||||
{
|
{
|
||||||
if (bref == NULL)
|
if (bref == NULL)
|
||||||
{
|
{
|
||||||
|
@ -32,34 +32,34 @@ using schemarouter::Stats;
|
|||||||
* Bitmask values for the router session's initialization. These values are used
|
* Bitmask values for the router session's initialization. These values are used
|
||||||
* to prevent responses from internal commands being forwarded to the client.
|
* to prevent responses from internal commands being forwarded to the client.
|
||||||
*/
|
*/
|
||||||
typedef enum init_mask
|
enum init_mask
|
||||||
{
|
{
|
||||||
INIT_READY = 0x00,
|
INIT_READY = 0x00,
|
||||||
INIT_MAPPING = 0x01,
|
INIT_MAPPING = 0x01,
|
||||||
INIT_USE_DB = 0x02,
|
INIT_USE_DB = 0x02,
|
||||||
INIT_UNINT = 0x04,
|
INIT_UNINT = 0x04,
|
||||||
INIT_FAILED = 0x08
|
INIT_FAILED = 0x08
|
||||||
} init_mask_t;
|
};
|
||||||
|
|
||||||
typedef enum showdb_response
|
enum showdb_response
|
||||||
{
|
{
|
||||||
SHOWDB_FULL_RESPONSE,
|
SHOWDB_FULL_RESPONSE,
|
||||||
SHOWDB_PARTIAL_RESPONSE,
|
SHOWDB_PARTIAL_RESPONSE,
|
||||||
SHOWDB_DUPLICATE_DATABASES,
|
SHOWDB_DUPLICATE_DATABASES,
|
||||||
SHOWDB_FATAL_ERROR
|
SHOWDB_FATAL_ERROR
|
||||||
} showdb_response_t;
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state of the backend server reference
|
* The state of the backend server reference
|
||||||
*/
|
*/
|
||||||
typedef enum bref_state
|
enum bref_state
|
||||||
{
|
{
|
||||||
BREF_IN_USE = 0x01,
|
BREF_IN_USE = 0x01,
|
||||||
BREF_WAITING_RESULT = 0x02, /**< for session commands only */
|
BREF_WAITING_RESULT = 0x02, /**< for session commands only */
|
||||||
BREF_QUERY_ACTIVE = 0x04, /**< for other queries */
|
BREF_QUERY_ACTIVE = 0x04, /**< for other queries */
|
||||||
BREF_CLOSED = 0x08,
|
BREF_CLOSED = 0x08,
|
||||||
BREF_DB_MAPPED = 0x10
|
BREF_DB_MAPPED = 0x10
|
||||||
} bref_state_t;
|
};
|
||||||
|
|
||||||
#define BREF_IS_NOT_USED(s) ((s)->state & ~BREF_IN_USE)
|
#define BREF_IS_NOT_USED(s) ((s)->state & ~BREF_IN_USE)
|
||||||
#define BREF_IS_IN_USE(s) ((s)->state & BREF_IN_USE)
|
#define BREF_IS_IN_USE(s) ((s)->state & BREF_IN_USE)
|
||||||
@ -76,13 +76,13 @@ typedef enum bref_state
|
|||||||
/**
|
/**
|
||||||
* Route target types
|
* Route target types
|
||||||
*/
|
*/
|
||||||
typedef enum
|
enum route_target
|
||||||
{
|
{
|
||||||
TARGET_UNDEFINED = (1 << 0),
|
TARGET_UNDEFINED,
|
||||||
TARGET_NAMED_SERVER = (1 << 1),
|
TARGET_NAMED_SERVER,
|
||||||
TARGET_ALL = (1 << 2),
|
TARGET_ALL,
|
||||||
TARGET_ANY = (1 << 3)
|
TARGET_ANY
|
||||||
} route_target_t;
|
};
|
||||||
|
|
||||||
/** Helper macros for route target type */
|
/** Helper macros for route target type */
|
||||||
#define TARGET_IS_UNDEFINED(t) (t == TARGET_UNDEFINED)
|
#define TARGET_IS_UNDEFINED(t) (t == TARGET_UNDEFINED)
|
||||||
@ -174,14 +174,14 @@ private:
|
|||||||
int gen_databaselist();
|
int gen_databaselist();
|
||||||
int inspect_backend_mapping_states(backend_ref_t *bref, GWBUF** wbuf);
|
int inspect_backend_mapping_states(backend_ref_t *bref, GWBUF** wbuf);
|
||||||
bool process_show_shards();
|
bool process_show_shards();
|
||||||
showdb_response_t parse_showdb_response(backend_ref_t* bref, GWBUF** buffer);
|
enum showdb_response parse_showdb_response(backend_ref_t* bref, GWBUF** buffer);
|
||||||
void handle_error_reply_client(DCB* backend_dcb, GWBUF* errmsg);
|
void handle_error_reply_client(DCB* backend_dcb, GWBUF* errmsg);
|
||||||
void route_queued_query();
|
void route_queued_query();
|
||||||
void synchronize_shard_map();
|
void synchronize_shard_map();
|
||||||
void handle_mapping_reply(backend_ref_t* bref, GWBUF* pPacket);
|
void handle_mapping_reply(backend_ref_t* bref, GWBUF* pPacket);
|
||||||
void process_response(backend_ref_t* bref, GWBUF** ppPacket);
|
void process_response(backend_ref_t* bref, GWBUF** ppPacket);
|
||||||
SERVER* resolve_query_target(GWBUF* pPacket, uint32_t type, uint8_t command,
|
SERVER* resolve_query_target(GWBUF* pPacket, uint32_t type, uint8_t command,
|
||||||
route_target_t& route_target);
|
enum route_target& route_target);
|
||||||
|
|
||||||
/** Member variables */
|
/** Member variables */
|
||||||
bool m_closed; /**< True if session closed */
|
bool m_closed; /**< True if session closed */
|
||||||
|
Reference in New Issue
Block a user