Add missing string versions of MySQL commands
The STRPACKETTYPE macro was missing a number of the commands from the enum. Added executed command byte value to readwritesplit info level log output.
This commit is contained in:
parent
598fc485ee
commit
09349aaa22
@ -166,27 +166,6 @@ typedef enum skygw_chk_t
|
||||
((n) == LOG_DEBUG ? "LOG_DEBUG" : \
|
||||
"Unknown log priority"))))))))
|
||||
|
||||
#define STRPACKETTYPE(p) ((p) == MYSQL_COM_INIT_DB ? "COM_INIT_DB" : \
|
||||
((p) == MYSQL_COM_CREATE_DB ? "COM_CREATE_DB" : \
|
||||
((p) == MYSQL_COM_DROP_DB ? "COM_DROP_DB" : \
|
||||
((p) == MYSQL_COM_REFRESH ? "COM_REFRESH" : \
|
||||
((p) == MYSQL_COM_DEBUG ? "COM_DEBUG" : \
|
||||
((p) == MYSQL_COM_PING ? "COM_PING" : \
|
||||
((p) == MYSQL_COM_CHANGE_USER ? "COM_CHANGE_USER" : \
|
||||
((p) == MYSQL_COM_QUERY ? "COM_QUERY" : \
|
||||
((p) == MYSQL_COM_SHUTDOWN ? "COM_SHUTDOWN" : \
|
||||
((p) == MYSQL_COM_PROCESS_INFO ? "COM_PROCESS_INFO" : \
|
||||
((p) == MYSQL_COM_CONNECT ? "COM_CONNECT" : \
|
||||
((p) == MYSQL_COM_PROCESS_KILL ? "COM_PROCESS_KILL" : \
|
||||
((p) == MYSQL_COM_TIME ? "COM_TIME" : \
|
||||
((p) == MYSQL_COM_DELAYED_INSERT ? "COM_DELAYED_INSERT" : \
|
||||
((p) == MYSQL_COM_DAEMON ? "COM_DAEMON" : \
|
||||
((p) == MYSQL_COM_QUIT ? "COM_QUIT" : \
|
||||
((p) == MYSQL_COM_STMT_PREPARE ? "MYSQL_COM_STMT_PREPARE" : \
|
||||
((p) == MYSQL_COM_STMT_EXECUTE ? "MYSQL_COM_STMT_EXECUTE" : \
|
||||
((p) == MYSQL_COM_SET_OPTION ? "MYSQL_COM_SET_OPTION" : \
|
||||
"UNKNOWN MYSQL PACKET TYPE")))))))))))))))))))
|
||||
|
||||
#define STRDCBSTATE(s) ((s) == DCB_STATE_ALLOC ? "DCB_STATE_ALLOC" : \
|
||||
((s) == DCB_STATE_POLLING ? "DCB_STATE_POLLING" : \
|
||||
((s) == DCB_STATE_LISTENING ? "DCB_STATE_LISTENING" : \
|
||||
|
@ -83,4 +83,7 @@ bool is_mysql_statement_end(const char* start, int len);
|
||||
bool is_mysql_sp_end(const char* start, int len);
|
||||
char* modutil_get_canonical(GWBUF* querybuf);
|
||||
|
||||
// TODO: Move modutil out of the core
|
||||
const char* STRPACKETTYPE(int p);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/poll.h>
|
||||
#include <maxscale/modutil.h>
|
||||
#include <maxscale/platform.h>
|
||||
#include <strings.h>
|
||||
|
||||
/** These are used when converting MySQL wildcards to regular expressions */
|
||||
@ -1321,3 +1322,79 @@ char* modutil_MySQL_bypass_whitespace(char* sql, size_t len)
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
const char format_str[] = "COM_UNKNOWN(%02x)";
|
||||
|
||||
// The message always fits inside the buffer
|
||||
thread_local char unknow_type[sizeof(format_str)] = "";
|
||||
|
||||
const char* STRPACKETTYPE(int p)
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
case MYSQL_COM_SLEEP:
|
||||
return "MYSQL_COM_SLEEP";
|
||||
case MYSQL_COM_QUIT:
|
||||
return "MYSQL_COM_QUIT";
|
||||
case MYSQL_COM_INIT_DB:
|
||||
return "MYSQL_COM_INIT_DB";
|
||||
case MYSQL_COM_QUERY:
|
||||
return "MYSQL_COM_QUERY";
|
||||
case MYSQL_COM_FIELD_LIST:
|
||||
return "MYSQL_COM_FIELD_LIST";
|
||||
case MYSQL_COM_CREATE_DB:
|
||||
return "MYSQL_COM_CREATE_DB";
|
||||
case MYSQL_COM_DROP_DB:
|
||||
return "MYSQL_COM_DROP_DB";
|
||||
case MYSQL_COM_REFRESH:
|
||||
return "MYSQL_COM_REFRESH";
|
||||
case MYSQL_COM_SHUTDOWN:
|
||||
return "MYSQL_COM_SHUTDOWN";
|
||||
case MYSQL_COM_STATISTICS:
|
||||
return "MYSQL_COM_STATISTICS";
|
||||
case MYSQL_COM_PROCESS_INFO:
|
||||
return "MYSQL_COM_PROCESS_INFO";
|
||||
case MYSQL_COM_CONNECT:
|
||||
return "MYSQL_COM_CONNECT";
|
||||
case MYSQL_COM_PROCESS_KILL:
|
||||
return "MYSQL_COM_PROCESS_KILL";
|
||||
case MYSQL_COM_DEBUG:
|
||||
return "MYSQL_COM_DEBUG";
|
||||
case MYSQL_COM_PING:
|
||||
return "MYSQL_COM_PING";
|
||||
case MYSQL_COM_TIME:
|
||||
return "MYSQL_COM_TIME";
|
||||
case MYSQL_COM_DELAYED_INSERT:
|
||||
return "MYSQL_COM_DELAYED_INSERT";
|
||||
case MYSQL_COM_CHANGE_USER:
|
||||
return "MYSQL_COM_CHANGE_USER";
|
||||
case MYSQL_COM_BINLOG_DUMP:
|
||||
return "MYSQL_COM_BINLOG_DUMP";
|
||||
case MYSQL_COM_TABLE_DUMP:
|
||||
return "MYSQL_COM_TABLE_DUMP";
|
||||
case MYSQL_COM_CONNECT_OUT:
|
||||
return "MYSQL_COM_CONNECT_OUT";
|
||||
case MYSQL_COM_REGISTER_SLAVE:
|
||||
return "MYSQL_COM_REGISTER_SLAVE";
|
||||
case MYSQL_COM_STMT_PREPARE:
|
||||
return "MYSQL_COM_STMT_PREPARE";
|
||||
case MYSQL_COM_STMT_EXECUTE:
|
||||
return "MYSQL_COM_STMT_EXECUTE";
|
||||
case MYSQL_COM_STMT_SEND_LONG_DATA:
|
||||
return "MYSQL_COM_STMT_SEND_LONG_DATA";
|
||||
case MYSQL_COM_STMT_CLOSE:
|
||||
return "MYSQL_COM_STMT_CLOSE";
|
||||
case MYSQL_COM_STMT_RESET:
|
||||
return "MYSQL_COM_STMT_RESET";
|
||||
case MYSQL_COM_SET_OPTION:
|
||||
return "MYSQL_COM_SET_OPTION";
|
||||
case MYSQL_COM_STMT_FETCH:
|
||||
return "MYSQL_COM_STMT_FETCH";
|
||||
case MYSQL_COM_DAEMON:
|
||||
return "MYSQL_COM_DAEMON";
|
||||
}
|
||||
|
||||
snprintf(unknow_type, sizeof(unknow_type), format_str, p);
|
||||
|
||||
return unknow_type;
|
||||
}
|
||||
|
@ -163,20 +163,22 @@ log_transaction_status(ROUTER_CLIENT_SES *rses, GWBUF *querybuf, qc_query_type_t
|
||||
if (!rses->rses_load_active)
|
||||
{
|
||||
uint8_t *packet = GWBUF_DATA(querybuf);
|
||||
unsigned char ptype = packet[4];
|
||||
size_t len = MXS_MIN(GWBUF_LENGTH(querybuf),
|
||||
MYSQL_GET_PAYLOAD_LEN((unsigned char *)querybuf->start) - 1);
|
||||
char *data = (char *)&packet[5];
|
||||
char *contentstr = strndup(data, MXS_MIN(len, RWSPLIT_TRACE_MSG_LEN));
|
||||
unsigned char command = packet[4];
|
||||
int len = 0;
|
||||
char* sql;
|
||||
modutil_extract_SQL(querybuf, &sql, &len);
|
||||
char *qtypestr = qc_typemask_to_string(qtype);
|
||||
MXS_SESSION *ses = rses->client_dcb->session;
|
||||
MXS_INFO("> Autocommit: %s, trx is %s, cmd: %s, type: %s, stmt: %s%s %s",
|
||||
(session_is_autocommit(ses) ? "[enabled]" : "[disabled]"),
|
||||
(session_trx_is_active(ses) ? "[open]" : "[not open]"),
|
||||
STRPACKETTYPE(ptype), (qtypestr == NULL ? "N/A" : qtypestr),
|
||||
contentstr, (querybuf->hint == NULL ? "" : ", Hint:"),
|
||||
(querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type)));
|
||||
MXS_FREE(contentstr);
|
||||
const char *autocommit = session_is_autocommit(ses) ? "[enabled]" : "[disabled]";
|
||||
const char *transaction = session_trx_is_active(ses) ? "[open]" : "[not open]";
|
||||
const char *querytype = qtypestr == NULL ? "N/A" : qtypestr;
|
||||
const char *hint = querybuf->hint == NULL ? "" : ", Hint:";
|
||||
const char *hint_type = querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type);
|
||||
|
||||
MXS_INFO("> Autocommit: %s, trx is %s, cmd: (0x%02x) %s, type: %s, stmt: %.*s%s %s",
|
||||
autocommit, transaction, command, STRPACKETTYPE(command),
|
||||
querytype, len, sql, hint, hint_type);
|
||||
|
||||
MXS_FREE(qtypestr);
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user