add valid msg

This commit is contained in:
yihaoDeng 2023-12-01 17:19:34 +08:00
parent 50bda0b719
commit c5d9a2b24d
3 changed files with 14 additions and 13 deletions

View File

@ -56,6 +56,7 @@ extern "C" {
extern char* tMsgInfo[];
extern int32_t tMsgDict[];
extern int32_t tMsgRangeDict[];
typedef uint16_t tmsg_t;
@ -63,8 +64,17 @@ typedef uint16_t tmsg_t;
#define TMSG_SEG_SEQ(TYPE) ((TYPE)&0xff)
#define TMSG_INDEX(TYPE) (tMsgDict[TMSG_SEG_CODE(TYPE)] + TMSG_SEG_SEQ(TYPE))
bool tmsgIsValid(tmsg_t type);
char* TMSG_INFO(tmsg_t type);
static inline bool tmsgIsValid(tmsg_t type) {
// static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
int8_t maxSegIdx = TMSG_SEG_CODE(TDMT_MAX_MSG);
int segIdx = TMSG_SEG_CODE(type);
if (segIdx >= 0 && segIdx < maxSegIdx) {
return type < tMsgRangeDict[segIdx];
}
return false;
}
#define TMSG_INFO(type) (tmsgIsValid(type) ? tMsgInfo[TMSG_INDEX(type)] : "unKnown")
static inline bool vnodeIsMsgBlock(tmsg_t type) {
return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) ||

View File

@ -362,6 +362,8 @@ enum { // WARN: new msg should be appended to segment tail
TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL)
TD_CLOSE_MSG_TYPE(TDMT_END_TMQ_MSG)
TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark
#if defined(TD_MSG_NUMBER_)
TDMT_MAX
#endif

View File

@ -37,17 +37,6 @@
#include "tlog.h"
inline bool tmsgIsValid(tmsg_t type) {
static int8_t sz = sizeof(tMsgRangeDict) / sizeof(tMsgRangeDict[0]);
int segIdx = TMSG_SEG_CODE(type);
if (segIdx >= 0 && segIdx < sz) {
return type < tMsgRangeDict[segIdx];
}
return false;
}
inline char *TMSG_INFO(tmsg_t type) { return (tmsgIsValid(type) ? tMsgInfo[TMSG_INDEX(type)] : "unKnown"); };
#define DECODESQL() \
do { \