add show local variables scope
This commit is contained in:
parent
7935d824b6
commit
cdb3453812
|
@ -36,9 +36,10 @@ extern "C" {
|
||||||
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
|
#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||||
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN * 3)
|
#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN * 3)
|
||||||
|
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 2
|
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 3
|
||||||
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
|
#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_VALUE_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
#define SHOW_ALIVE_RESULT_COLS 1
|
#define SHOW_ALIVE_RESULT_COLS 1
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,12 @@ typedef enum {
|
||||||
CFG_DTYPE_TIMEZONE
|
CFG_DTYPE_TIMEZONE
|
||||||
} ECfgDataType;
|
} ECfgDataType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CFG_SCOPE_SERVER,
|
||||||
|
CFG_SCOPE_CLIENT,
|
||||||
|
CFG_SCOPE_BOTH
|
||||||
|
} ECfgScopeType;
|
||||||
|
|
||||||
typedef struct SConfigItem {
|
typedef struct SConfigItem {
|
||||||
ECfgSrcType stype;
|
ECfgSrcType stype;
|
||||||
ECfgDataType dtype;
|
ECfgDataType dtype;
|
||||||
|
@ -106,6 +112,7 @@ const char *cfgStypeStr(ECfgSrcType type);
|
||||||
const char *cfgDtypeStr(ECfgDataType type);
|
const char *cfgDtypeStr(ECfgDataType type);
|
||||||
|
|
||||||
void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||||
|
void cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
||||||
|
|
||||||
|
|
|
@ -768,15 +768,19 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
|
||||||
pBlock->pDataBlock = taosArrayInit(SHOW_LOCAL_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData));
|
pBlock->pDataBlock = taosArrayInit(SHOW_LOCAL_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData));
|
||||||
|
|
||||||
SColumnInfoData infoData = {0};
|
SColumnInfoData infoData = {0};
|
||||||
|
|
||||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN;
|
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN;
|
||||||
|
|
||||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN;
|
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN;
|
||||||
taosArrayPush(pBlock->pDataBlock, &infoData);
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
|
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
|
||||||
|
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN;
|
||||||
|
taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||||
|
|
||||||
*pOutput = pBlock;
|
*pOutput = pBlock;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -789,6 +793,7 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
|
||||||
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) {
|
||||||
SConfigItem* pItem = taosArrayGet(tsCfg->array, i);
|
SConfigItem* pItem = taosArrayGet(tsCfg->array, i);
|
||||||
GRANT_CFG_SKIP;
|
GRANT_CFG_SKIP;
|
||||||
|
|
||||||
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);
|
||||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
|
@ -801,6 +806,13 @@ int32_t setLocalVariablesResultIntoDataBlock(SSDataBlock* pBlock) {
|
||||||
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
colDataSetVal(pColInfo, i, value, false);
|
colDataSetVal(pColInfo, i, value, false);
|
||||||
|
|
||||||
|
char scope[TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
|
valueLen = 0;
|
||||||
|
cfgDumpItemScope(pItem, &scope[VARSTR_HEADER_SIZE], TSDB_CONFIG_SCOPE_LEN, &valueLen);
|
||||||
|
varDataSetLen(scope, valueLen);
|
||||||
|
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
|
||||||
|
colDataSetVal(pColInfo, i, scope, false);
|
||||||
|
|
||||||
numOfRows++;
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,6 +543,27 @@ void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *p
|
||||||
*pLen = len;
|
*pLen = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen) {
|
||||||
|
int32_t len = 0;
|
||||||
|
switch ((int8_t)pItem->tsc) {
|
||||||
|
case CFG_SCOPE_SERVER:
|
||||||
|
len = snprintf(buf, bufSize, "server");
|
||||||
|
break;
|
||||||
|
case CFG_SCOPE_CLIENT:
|
||||||
|
len = snprintf(buf, bufSize, "client");
|
||||||
|
break;
|
||||||
|
case CFG_SCOPE_BOTH:
|
||||||
|
len = snprintf(buf, bufSize, "both");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len > bufSize) {
|
||||||
|
len = bufSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pLen = len;
|
||||||
|
}
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
||||||
if (dump) {
|
if (dump) {
|
||||||
printf(" global config");
|
printf(" global config");
|
||||||
|
|
Loading…
Reference in New Issue