Introduce internal protocol command enum
The enums exposed by the connector are not intended to be used by the users of the library. The fact that the protocol, and other, modules used it was in violation of how the library is intended to be used. Adding an internal mapping into MaxScale also removes some of the dependencies that the core has on the connector.
This commit is contained in:
@ -137,46 +137,46 @@ static void inspect_query(GWBUF* pPacket, uint32_t* type, qc_query_op_t* op, uin
|
||||
|
||||
switch (*command)
|
||||
{
|
||||
case MYSQL_COM_QUIT: /*< 1 QUIT will close all sessions */
|
||||
case MYSQL_COM_INIT_DB: /*< 2 DDL must go to the master */
|
||||
case MYSQL_COM_REFRESH: /*< 7 - I guess this is session but not sure */
|
||||
case MYSQL_COM_DEBUG: /*< 0d all servers dump debug info to stdout */
|
||||
case MYSQL_COM_PING: /*< 0e all servers are pinged */
|
||||
case MYSQL_COM_CHANGE_USER: /*< 11 all servers change it accordingly */
|
||||
case MYSQL_COM_STMT_CLOSE: /*< free prepared statement */
|
||||
case MYSQL_COM_STMT_SEND_LONG_DATA: /*< send data to column */
|
||||
case MYSQL_COM_STMT_RESET: /*< resets the data of a prepared statement */
|
||||
case MXS_COM_QUIT: /*< 1 QUIT will close all sessions */
|
||||
case MXS_COM_INIT_DB: /*< 2 DDL must go to the master */
|
||||
case MXS_COM_REFRESH: /*< 7 - I guess this is session but not sure */
|
||||
case MXS_COM_DEBUG: /*< 0d all servers dump debug info to stdout */
|
||||
case MXS_COM_PING: /*< 0e all servers are pinged */
|
||||
case MXS_COM_CHANGE_USER: /*< 11 all servers change it accordingly */
|
||||
case MXS_COM_STMT_CLOSE: /*< free prepared statement */
|
||||
case MXS_COM_STMT_SEND_LONG_DATA: /*< send data to column */
|
||||
case MXS_COM_STMT_RESET: /*< resets the data of a prepared statement */
|
||||
*type = QUERY_TYPE_SESSION_WRITE;
|
||||
break;
|
||||
|
||||
case MYSQL_COM_CREATE_DB: /**< 5 DDL must go to the master */
|
||||
case MYSQL_COM_DROP_DB: /**< 6 DDL must go to the master */
|
||||
case MXS_COM_CREATE_DB: /**< 5 DDL must go to the master */
|
||||
case MXS_COM_DROP_DB: /**< 6 DDL must go to the master */
|
||||
*type = QUERY_TYPE_WRITE;
|
||||
break;
|
||||
|
||||
case MYSQL_COM_QUERY:
|
||||
case MXS_COM_QUERY:
|
||||
*type = qc_get_type_mask(pPacket);
|
||||
*op = qc_get_operation(pPacket);
|
||||
break;
|
||||
|
||||
case MYSQL_COM_STMT_PREPARE:
|
||||
case MXS_COM_STMT_PREPARE:
|
||||
*type = qc_get_type_mask(pPacket);
|
||||
*type |= QUERY_TYPE_PREPARE_STMT;
|
||||
break;
|
||||
|
||||
case MYSQL_COM_STMT_EXECUTE:
|
||||
case MXS_COM_STMT_EXECUTE:
|
||||
/** Parsing is not needed for this type of packet */
|
||||
*type = QUERY_TYPE_EXEC_STMT;
|
||||
break;
|
||||
|
||||
case MYSQL_COM_SHUTDOWN: /**< 8 where should shutdown be routed ? */
|
||||
case MYSQL_COM_STATISTICS: /**< 9 ? */
|
||||
case MYSQL_COM_PROCESS_INFO: /**< 0a ? */
|
||||
case MYSQL_COM_CONNECT: /**< 0b ? */
|
||||
case MYSQL_COM_PROCESS_KILL: /**< 0c ? */
|
||||
case MYSQL_COM_TIME: /**< 0f should this be run in gateway ? */
|
||||
case MYSQL_COM_DELAYED_INSERT: /**< 10 ? */
|
||||
case MYSQL_COM_DAEMON: /**< 1d ? */
|
||||
case MXS_COM_SHUTDOWN: /**< 8 where should shutdown be routed ? */
|
||||
case MXS_COM_STATISTICS: /**< 9 ? */
|
||||
case MXS_COM_PROCESS_INFO: /**< 0a ? */
|
||||
case MXS_COM_CONNECT: /**< 0b ? */
|
||||
case MXS_COM_PROCESS_KILL: /**< 0c ? */
|
||||
case MXS_COM_TIME: /**< 0f should this be run in gateway ? */
|
||||
case MXS_COM_DELAYED_INSERT: /**< 10 ? */
|
||||
case MXS_COM_DAEMON: /**< 1d ? */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -221,8 +221,8 @@ SERVER* SchemaRouterSession::resolve_query_target(GWBUF* pPacket,
|
||||
* the current default database or to the first available server. */
|
||||
target = get_shard_target(pPacket, type);
|
||||
|
||||
if ((target == NULL && command != MYSQL_COM_INIT_DB && m_current_db.length() == 0) ||
|
||||
command == MYSQL_COM_FIELD_LIST ||
|
||||
if ((target == NULL && command != MXS_COM_INIT_DB && m_current_db.length() == 0) ||
|
||||
command == MXS_COM_FIELD_LIST ||
|
||||
m_current_db.length() == 0)
|
||||
{
|
||||
/** No current database and no databases in query or the database is
|
||||
@ -352,7 +352,7 @@ int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket)
|
||||
}
|
||||
|
||||
/** The default database changes must be routed to a specific server */
|
||||
if (command == MYSQL_COM_INIT_DB || op == QUERY_OP_CHANGE_DB)
|
||||
if (command == MXS_COM_INIT_DB || op == QUERY_OP_CHANGE_DB)
|
||||
{
|
||||
if (!change_current_db(m_current_db, m_shard, pPacket))
|
||||
{
|
||||
@ -664,7 +664,7 @@ bool extract_database(GWBUF* buf, char* str)
|
||||
plen = gw_mysql_get_byte3(packet) - 1;
|
||||
|
||||
/** Copy database name from MySQL packet to session */
|
||||
if (mxs_mysql_get_command(buf) == MYSQL_COM_QUERY &&
|
||||
if (mxs_mysql_get_command(buf) == MXS_COM_QUERY &&
|
||||
qc_get_operation(buf) == QUERY_OP_CHANGE_DB)
|
||||
{
|
||||
const char *delim = "` \n\t;";
|
||||
@ -1109,7 +1109,7 @@ void create_error_reply(char* fail_str, DCB* dcb)
|
||||
}
|
||||
|
||||
/**
|
||||
* Read new database name from MYSQL_COM_INIT_DB packet or a literal USE ... COM_QUERY
|
||||
* Read new database name from COM_INIT_DB packet or a literal USE ... COM_QUERY
|
||||
* packet, check that it exists in the hashtable and copy its name to MYSQL_session.
|
||||
*
|
||||
* @param dest Destination where the database name will be written
|
||||
@ -1419,7 +1419,7 @@ SERVER* SchemaRouterSession::get_shard_target(GWBUF* buffer, uint32_t qtype)
|
||||
SERVER *rval = NULL;
|
||||
bool has_dbs = false; /**If the query targets any database other than the current one*/
|
||||
|
||||
if (mxs_mysql_get_command(buffer) == MYSQL_COM_QUERY)
|
||||
if (mxs_mysql_get_command(buffer) == MXS_COM_QUERY)
|
||||
{
|
||||
bool uses_current_database = false;
|
||||
int n_tables = 0;
|
||||
|
Reference in New Issue
Block a user