Merge pull request #28743 from taosdata/fix/TD-32860-main
fix: print multi dataDir
This commit is contained in:
commit
82d8f1357c
|
@ -2187,8 +2187,9 @@ int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq
|
|||
|
||||
typedef struct {
|
||||
char name[TSDB_CONFIG_OPTION_LEN + 1];
|
||||
char value[TSDB_CONFIG_VALUE_LEN + 1];
|
||||
char value[TSDB_CONFIG_PATH_LEN + 1];
|
||||
char scope[TSDB_CONFIG_SCOPE_LEN + 1];
|
||||
char info[TSDB_CONFIG_INFO_LEN + 1];
|
||||
} SVariablesInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -42,10 +42,11 @@ extern "C" {
|
|||
#define SHOW_CREATE_VIEW_RESULT_FIELD1_LEN (TSDB_VIEW_FNAME_LEN + 4 + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_CREATE_VIEW_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 3
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 4
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define COMPACT_DB_RESULT_COLS 3
|
||||
#define COMPACT_DB_RESULT_FIELD1_LEN 32
|
||||
|
|
|
@ -195,9 +195,9 @@ static const EOperatorType OPERATOR_ARRAY[] = {
|
|||
OP_TYPE_MULTI,
|
||||
OP_TYPE_DIV,
|
||||
OP_TYPE_REM,
|
||||
|
||||
|
||||
OP_TYPE_MINUS,
|
||||
|
||||
|
||||
OP_TYPE_BIT_AND,
|
||||
OP_TYPE_BIT_OR,
|
||||
|
||||
|
@ -213,7 +213,7 @@ static const EOperatorType OPERATOR_ARRAY[] = {
|
|||
OP_TYPE_NOT_LIKE,
|
||||
OP_TYPE_MATCH,
|
||||
OP_TYPE_NMATCH,
|
||||
|
||||
|
||||
OP_TYPE_IS_NULL,
|
||||
OP_TYPE_IS_NOT_NULL,
|
||||
OP_TYPE_IS_TRUE,
|
||||
|
@ -222,7 +222,7 @@ static const EOperatorType OPERATOR_ARRAY[] = {
|
|||
OP_TYPE_IS_NOT_TRUE,
|
||||
OP_TYPE_IS_NOT_FALSE,
|
||||
OP_TYPE_IS_NOT_UNKNOWN,
|
||||
//OP_TYPE_COMPARE_MAX_VALUE,
|
||||
//OP_TYPE_COMPARE_MAX_VALUE,
|
||||
|
||||
OP_TYPE_JSON_GET_VALUE,
|
||||
OP_TYPE_JSON_CONTAINS,
|
||||
|
@ -631,6 +631,8 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
|
|||
#define TSDB_CONFIG_VALUE_LEN 64
|
||||
#define TSDB_CONFIG_SCOPE_LEN 8
|
||||
#define TSDB_CONFIG_NUMBER 16
|
||||
#define TSDB_CONFIG_PATH_LEN 4096
|
||||
#define TSDB_CONFIG_INFO_LEN 64
|
||||
|
||||
#define QUERY_ID_SIZE 20
|
||||
#define QUERY_OBJ_ID_SIZE 18
|
||||
|
|
|
@ -47,10 +47,11 @@ enum {
|
|||
RES_TYPE__TMQ_BATCH_META,
|
||||
};
|
||||
|
||||
#define SHOW_VARIABLES_RESULT_COLS 3
|
||||
#define SHOW_VARIABLES_RESULT_COLS 4
|
||||
#define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
||||
#define SHOW_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
|
||||
|
||||
#define TD_RES_QUERY(res) (*(int8_t*)(res) == RES_TYPE__QUERY)
|
||||
#define TD_RES_TMQ(res) (*(int8_t*)(res) == RES_TYPE__TMQ)
|
||||
|
|
|
@ -541,6 +541,10 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
|||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD3_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD4_LEN;
|
||||
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
|
||||
|
||||
int32_t numOfCfg = taosArrayGetSize(pVars);
|
||||
code = blockDataEnsureCapacity(pBlock, numOfCfg);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
@ -569,6 +573,13 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
|
|||
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
|
||||
code = colDataSetVal(pColInfo, i, scope, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
|
||||
char info[TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(info, pInfo->info, TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
|
||||
code = colDataSetVal(pColInfo, i, info, false);
|
||||
TSDB_CHECK_CODE(code, line, END);
|
||||
}
|
||||
|
||||
pBlock->info.rows = numOfCfg;
|
||||
|
@ -825,7 +836,7 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tscError("failed to post semaphore");
|
||||
}
|
||||
}
|
||||
return code;
|
||||
return code;
|
||||
}
|
||||
|
||||
__async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
||||
|
@ -845,7 +856,7 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType) {
|
|||
case TDMT_MND_SHOW_VARIABLES:
|
||||
return processShowVariablesRsp;
|
||||
case TDMT_MND_COMPACT_DB:
|
||||
return processCompactDbRsp;
|
||||
return processCompactDbRsp;
|
||||
default:
|
||||
return genericRspCallback;
|
||||
}
|
||||
|
|
|
@ -327,8 +327,9 @@ static const SSysDbTableSchema configSchema[] = {
|
|||
static const SSysDbTableSchema variablesSchema[] = {
|
||||
{.name = "dnode_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "value", .bytes = TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "scope", .bytes = TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "info", .bytes = TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema topicSchema[] = {
|
||||
|
|
|
@ -267,7 +267,14 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
int8_t locked = 0;
|
||||
|
||||
TAOS_CHECK_GOTO(blockDataEnsureCapacity(pBlock, cfgGetSize(pConf)), NULL, _exit);
|
||||
size_t exSize = 0;
|
||||
size_t index = 0;
|
||||
SConfigItem* pDataDirItem = cfgGetItem(pConf, "dataDir");
|
||||
if (pDataDirItem) {
|
||||
exSize = TMAX(taosArrayGetSize(pDataDirItem->array), 1) - 1;
|
||||
}
|
||||
|
||||
TAOS_CHECK_GOTO(blockDataEnsureCapacity(pBlock, cfgGetSize(pConf) + exSize), NULL, _exit);
|
||||
|
||||
TAOS_CHECK_GOTO(cfgCreateIter(pConf, &pIter), NULL, _exit);
|
||||
|
||||
|
@ -275,6 +282,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
locked = 1;
|
||||
|
||||
while ((pItem = cfgNextIter(pIter)) != NULL) {
|
||||
_start:
|
||||
col = startCol;
|
||||
|
||||
// GRANT_CFG_SKIP;
|
||||
|
@ -289,9 +297,18 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, name, false), NULL, _exit);
|
||||
|
||||
char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t valueLen = 0;
|
||||
TAOS_CHECK_GOTO(cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_VALUE_LEN, &valueLen), NULL, _exit);
|
||||
SDiskCfg* pDiskCfg = NULL;
|
||||
if (strcasecmp(pItem->name, "dataDir") == 0 && exSize > 0) {
|
||||
char* buf = &value[VARSTR_HEADER_SIZE];
|
||||
pDiskCfg = taosArrayGet(pItem->array, index);
|
||||
valueLen = tsnprintf(buf, TSDB_CONFIG_PATH_LEN, "%s", pDiskCfg->dir);
|
||||
index++;
|
||||
} else {
|
||||
TAOS_CHECK_GOTO(cfgDumpItemValue(pItem, &value[VARSTR_HEADER_SIZE], TSDB_CONFIG_PATH_LEN, &valueLen), NULL,
|
||||
_exit);
|
||||
}
|
||||
varDataSetLen(value, valueLen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
|
@ -313,8 +330,28 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
|
|||
}
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, scope, false), NULL, _exit);
|
||||
|
||||
char info[TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (strcasecmp(pItem->name, "dataDir") == 0 && pDiskCfg) {
|
||||
char* buf = &info[VARSTR_HEADER_SIZE];
|
||||
valueLen = tsnprintf(buf, TSDB_CONFIG_INFO_LEN, "level %d primary %d disabled %" PRIi8, pDiskCfg->level,
|
||||
pDiskCfg->primary, pDiskCfg->disable);
|
||||
} else {
|
||||
valueLen = 0;
|
||||
}
|
||||
varDataSetLen(info, valueLen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
|
||||
if (pColInfo == NULL) {
|
||||
code = terrno;
|
||||
TAOS_CHECK_GOTO(code, NULL, _exit);
|
||||
}
|
||||
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, info, false), NULL, _exit);
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
if (index > 0 && index <= exSize) {
|
||||
goto _start;
|
||||
}
|
||||
}
|
||||
pBlock->info.rows = numOfRows;
|
||||
_exit:
|
||||
if (locked) cfgUnLock(pConf);
|
||||
|
|
|
@ -5642,6 +5642,12 @@ int32_t tSerializeSShowVariablesRsp(void *buf, int32_t bufLen, SShowVariablesRsp
|
|||
SVariablesInfo *pInfo = taosArrayGet(pRsp->variables, i);
|
||||
TAOS_CHECK_EXIT(tEncodeSVariablesInfo(&encoder, pInfo));
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < varNum; ++i) {
|
||||
SVariablesInfo *pInfo = taosArrayGet(pRsp->variables, i);
|
||||
TAOS_CHECK_RETURN(tEncodeCStr(&encoder, pInfo->info));
|
||||
}
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
_exit:
|
||||
|
@ -5675,6 +5681,13 @@ int32_t tDeserializeSShowVariablesRsp(void *buf, int32_t bufLen, SShowVariablesR
|
|||
TAOS_CHECK_EXIT(terrno);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tDecodeIsEnd(&decoder)) {
|
||||
for (int32_t i = 0; i < varNum; ++i) {
|
||||
SVariablesInfo *pInfo = taosArrayGet(pRsp->variables, i);
|
||||
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pInfo->info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
|
|
@ -1104,6 +1104,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
|||
(void)strcpy(info.name, "statusInterval");
|
||||
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
|
||||
(void)strcpy(info.scope, "server");
|
||||
// fill info.info
|
||||
if (taosArrayPush(rsp.variables, &info) == NULL) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
|
|
|
@ -954,6 +954,12 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD4_LEN;
|
||||
if (taosArrayPush(pBlock->pDataBlock, &infoData) == NULL) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*pOutput = pBlock;
|
||||
|
||||
_exit:
|
||||
|
|
|
@ -3311,11 +3311,11 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType)
|
|||
} else {
|
||||
resultType = gDisplyTypes[type2][type1];
|
||||
}
|
||||
|
||||
|
||||
if (resultType == -1) {
|
||||
return TSDB_CODE_SCALAR_CONVERT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (commonType->type == newType->type) {
|
||||
commonType->bytes = TMAX(commonType->bytes, newType->bytes);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -3328,9 +3328,9 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType)
|
|||
} else {
|
||||
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]);
|
||||
}
|
||||
|
||||
|
||||
commonType->type = resultType;
|
||||
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -13127,7 +13127,7 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p
|
|||
}
|
||||
|
||||
static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) {
|
||||
*numOfCols = 3;
|
||||
*numOfCols = SHOW_LOCAL_VARIABLES_RESULT_COLS; // SHOW_VARIABLES_RESULT_COLS
|
||||
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
|
||||
if (NULL == (*pSchema)) {
|
||||
return terrno;
|
||||
|
@ -13138,13 +13138,17 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS
|
|||
strcpy((*pSchema)[0].name, "name");
|
||||
|
||||
(*pSchema)[1].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[1].bytes = TSDB_CONFIG_VALUE_LEN;
|
||||
(*pSchema)[1].bytes = TSDB_CONFIG_PATH_LEN;
|
||||
strcpy((*pSchema)[1].name, "value");
|
||||
|
||||
(*pSchema)[2].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[2].bytes = TSDB_CONFIG_SCOPE_LEN;
|
||||
strcpy((*pSchema)[2].name, "scope");
|
||||
|
||||
(*pSchema)[3].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[3].bytes = TSDB_CONFIG_INFO_LEN;
|
||||
strcpy((*pSchema)[3].name, "info");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -881,11 +881,26 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
|||
case CFG_DTYPE_CHARSET:
|
||||
case CFG_DTYPE_TIMEZONE:
|
||||
case CFG_DTYPE_NONE:
|
||||
if (strcasecmp(pItem->name, "dataDir") == 0) {
|
||||
size_t sz = taosArrayGetSize(pItem->array);
|
||||
if (sz > 1) {
|
||||
for (size_t j = 0; j < sz; ++j) {
|
||||
SDiskCfg *pCfg = taosArrayGet(pItem->array, j);
|
||||
if (dump) {
|
||||
(void)printf("%s %s %s l:%d p:%d d:%"PRIi8"\n", src, name, pCfg->dir, pCfg->level, pCfg->primary, pCfg->disable);
|
||||
} else {
|
||||
uInfo("%s %s %s l:%d p:%d d:%"PRIi8, src, name, pCfg->dir, pCfg->level, pCfg->primary, pCfg->disable);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dump) {
|
||||
(void)printf("%s %s %s\n", src, name, pItem->str);
|
||||
} else {
|
||||
uInfo("%s %s %s", src, name, pItem->str);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ class TDTestCase:
|
|||
|
||||
tdSql.query("select * from information_schema.ins_columns where db_name ='information_schema'")
|
||||
tdLog.info(len(tdSql.queryResult))
|
||||
tdSql.checkEqual(True, len(tdSql.queryResult) in range(281, 282))
|
||||
tdSql.checkEqual(True, len(tdSql.queryResult) in range(282, 283))
|
||||
|
||||
tdSql.query("select * from information_schema.ins_columns where db_name ='performance_schema'")
|
||||
tdSql.checkEqual(56, len(tdSql.queryResult))
|
||||
|
|
Loading…
Reference in New Issue