This commit is contained in:
xiao-77 2024-11-26 16:08:16 +08:00
parent 594bcf1007
commit d778ada8f9
14 changed files with 278 additions and 255 deletions

View File

@ -2210,6 +2210,7 @@ typedef struct {
char name[TSDB_CONFIG_OPTION_LEN + 1];
char value[TSDB_CONFIG_PATH_LEN + 1];
char scope[TSDB_CONFIG_SCOPE_LEN + 1];
char category[TSDB_CONFIG_CATEGORY_LEN + 1];
char info[TSDB_CONFIG_INFO_LEN + 1];
} SVariablesInfo;

View File

@ -42,11 +42,12 @@ 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 4
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 5
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_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 SHOW_LOCAL_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD5_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
#define COMPACT_DB_RESULT_COLS 3
#define COMPACT_DB_RESULT_FIELD1_LEN 32

View File

@ -146,6 +146,7 @@ const char *cfgDtypeStr(ECfgDataType type);
int32_t cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
int32_t cfgDumpItemCategory(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump);

View File

@ -190,45 +190,22 @@ typedef enum EOperatorType {
} EOperatorType;
static const EOperatorType OPERATOR_ARRAY[] = {
OP_TYPE_ADD,
OP_TYPE_SUB,
OP_TYPE_MULTI,
OP_TYPE_DIV,
OP_TYPE_REM,
OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, OP_TYPE_REM,
OP_TYPE_MINUS,
OP_TYPE_BIT_AND,
OP_TYPE_BIT_OR,
OP_TYPE_BIT_AND, OP_TYPE_BIT_OR,
OP_TYPE_GREATER_THAN,
OP_TYPE_GREATER_EQUAL,
OP_TYPE_LOWER_THAN,
OP_TYPE_LOWER_EQUAL,
OP_TYPE_EQUAL,
OP_TYPE_NOT_EQUAL,
OP_TYPE_IN,
OP_TYPE_NOT_IN,
OP_TYPE_LIKE,
OP_TYPE_NOT_LIKE,
OP_TYPE_MATCH,
OP_TYPE_NMATCH,
OP_TYPE_GREATER_THAN, OP_TYPE_GREATER_EQUAL, OP_TYPE_LOWER_THAN, OP_TYPE_LOWER_EQUAL, OP_TYPE_EQUAL,
OP_TYPE_NOT_EQUAL, OP_TYPE_IN, OP_TYPE_NOT_IN, OP_TYPE_LIKE, OP_TYPE_NOT_LIKE, OP_TYPE_MATCH, OP_TYPE_NMATCH,
OP_TYPE_IS_NULL,
OP_TYPE_IS_NOT_NULL,
OP_TYPE_IS_TRUE,
OP_TYPE_IS_FALSE,
OP_TYPE_IS_UNKNOWN,
OP_TYPE_IS_NOT_TRUE,
OP_TYPE_IS_NOT_FALSE,
OP_TYPE_IS_NOT_UNKNOWN,
OP_TYPE_IS_NULL, OP_TYPE_IS_NOT_NULL, OP_TYPE_IS_TRUE, OP_TYPE_IS_FALSE, OP_TYPE_IS_UNKNOWN, OP_TYPE_IS_NOT_TRUE,
OP_TYPE_IS_NOT_FALSE, OP_TYPE_IS_NOT_UNKNOWN,
// OP_TYPE_COMPARE_MAX_VALUE,
OP_TYPE_JSON_GET_VALUE,
OP_TYPE_JSON_CONTAINS,
OP_TYPE_JSON_GET_VALUE, OP_TYPE_JSON_CONTAINS,
OP_TYPE_ASSIGN
};
OP_TYPE_ASSIGN};
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR
@ -644,6 +621,7 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
#define TSDB_CONFIG_NUMBER 16
#define TSDB_CONFIG_PATH_LEN 4096
#define TSDB_CONFIG_INFO_LEN 64
#define TSDB_CONFIG_CATEGORY_LEN 8
#define QUERY_ID_SIZE 20
#define QUERY_OBJ_ID_SIZE 18

View File

@ -47,11 +47,12 @@ enum {
RES_TYPE__TMQ_BATCH_META,
};
#define SHOW_VARIABLES_RESULT_COLS 4
#define SHOW_VARIABLES_RESULT_COLS 5
#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 SHOW_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD5_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)

View File

@ -15,9 +15,10 @@
#include "catalog.h"
#include "clientInt.h"
#include "clientMonitor.h"
#include "clientLog.h"
#include "clientMonitor.h"
#include "cmdnodes.h"
#include "command.h"
#include "os.h"
#include "query.h"
#include "systable.h"
@ -26,7 +27,6 @@
#include "tglobal.h"
#include "tname.h"
#include "tversion.h"
#include "command.h"
extern SClientHbMgr clientHbMgr;
@ -147,7 +147,8 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->whiteListInfo.ver = connectRsp.whiteListVer;
if (taosHashGet(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES) == NULL) {
if(taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo, POINTER_BYTES) != 0){
if (taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo,
POINTER_BYTES) != 0) {
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
} else {
MonitorSlowLogData data = {0};
@ -545,6 +546,10 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD4_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_FIELD5_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);
@ -574,6 +579,13 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
code = colDataSetVal(pColInfo, i, scope, false);
TSDB_CHECK_CODE(code, line, END);
char category[TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE] = {0};
STR_WITH_MAXSIZE_TO_VARSTR(category, pInfo->category, TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE);
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
code = colDataSetVal(pColInfo, i, category, 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++);
@ -805,7 +817,6 @@ _exit:
return code;
}
int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param;
if (code != TSDB_CODE_SUCCESS) {

View File

@ -2310,7 +2310,6 @@ int32_t tDeserializeRetrieveAnalAlgoRsp(void *buf, int32_t bufLen, SRetrieveAnal
int32_t lino;
tDecoderInit(&decoder, buf, bufLen);
int32_t numOfAlgos = 0;
int32_t nameLen;
int32_t type;
@ -5710,6 +5709,7 @@ int32_t tEncodeSVariablesInfo(SEncoder *pEncoder, SVariablesInfo *pInfo) {
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->name));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->value));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->scope));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->category));
return 0;
}
@ -5717,6 +5717,7 @@ int32_t tDecodeSVariablesInfo(SDecoder *pDecoder, SVariablesInfo *pInfo) {
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->name));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->value));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->scope));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->category));
return 0;
}

View File

@ -329,6 +329,7 @@ static const SSysDbTableSchema variablesSchema[] = {
{.name = "name", .bytes = TSDB_CONFIG_OPTION_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 = "category", .bytes = TSDB_CONFIG_CATEGORY_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},
};

View File

@ -2709,7 +2709,7 @@ int32_t globalConfigSerialize(int32_t version, SArray *array, char **serialized)
char buf[30];
cJSON *json = cJSON_CreateObject();
if (json == NULL) goto _exit;
json = cJSON_AddNumberToObject(json, "version", version);
if (cJSON_AddNumberToObject(json, "version", version) == NULL) goto _exit;
if (json == NULL) goto _exit;
int sz = taosArrayGetSize(array);
@ -2725,38 +2725,31 @@ int32_t globalConfigSerialize(int32_t version, SArray *array, char **serialized)
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
cField = cJSON_AddBoolToObject(cField, item->name, item->bval);
if (cField == NULL) goto _exit;
if (cJSON_AddBoolToObject(cField, item->name, item->bval) == NULL) goto _exit;
break;
case CFG_DTYPE_INT32:
cField = cJSON_AddNumberToObject(cField, item->name, item->i32);
if (cField == NULL) goto _exit;
if (cJSON_AddNumberToObject(cField, item->name, item->i32) == NULL) goto _exit;
break;
case CFG_DTYPE_INT64:
(void)sprintf(buf, "%" PRId64, item->i64);
cField = cJSON_AddStringToObject(cField, item->name, buf);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, buf) == NULL) goto _exit;
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
(void)sprintf(buf, "%f", item->fval);
cField = cJSON_AddStringToObject(cField, item->name, buf);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, buf) == NULL) goto _exit;
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
cField = cJSON_AddStringToObject(cField, item->name, item->str);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, item->str) == NULL) goto _exit;
break;
}
}
}
if (!cJSON_AddItemToObject(json, "configs", cField)) {
goto _exit;
}
if (!cJSON_AddItemToObject(json, "configs", cField)) goto _exit;
*serialized = cJSON_Print(json);
_exit:
if (terrno != TSDB_CODE_SUCCESS) {
@ -2784,31 +2777,26 @@ int32_t localConfigSerialize(SArray *array, char **serialized) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
cField = cJSON_AddBoolToObject(cField, item->name, item->bval);
if (cField == NULL) goto _exit;
if (cJSON_AddBoolToObject(cField, item->name, item->bval) == NULL) goto _exit;
break;
case CFG_DTYPE_INT32:
cField = cJSON_AddNumberToObject(cField, item->name, item->i32);
if (cField == NULL) goto _exit;
if (cJSON_AddNumberToObject(cField, item->name, item->i32) == NULL) goto _exit;
break;
case CFG_DTYPE_INT64:
(void)sprintf(buf, "%" PRId64, item->i64);
cField = cJSON_AddStringToObject(cField, item->name, buf);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, buf) == NULL) goto _exit;
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
(void)sprintf(buf, "%f", item->fval);
cField = cJSON_AddStringToObject(cField, item->name, buf);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, buf) == NULL) goto _exit;
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
cField = cJSON_AddStringToObject(cField, item->name, item->str);
if (cField == NULL) goto _exit;
if (cJSON_AddStringToObject(cField, item->name, item->str) == NULL) goto _exit;
break;
}
}
@ -2846,7 +2834,7 @@ int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version
char *serialized = NULL;
TAOS_CHECK_GOTO(globalConfigSerialize(version, array, &serialized), &lino, _exit);
if (taosWriteFile(pConfigFile, serialized, strlen(serialized) < 0)) {
if (taosWriteFile(pConfigFile, serialized, strlen(serialized)) < 0) {
lino = __LINE__;
code = TAOS_SYSTEM_ERROR(errno);
uError("failed to write file:%s since %s", filename, tstrerror(code));

View File

@ -14,10 +14,10 @@
*/
#define _DEFAULT_SOURCE
#include "tmisce.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "tjson.h"
#include "tmisce.h"
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
pEp->port = 0;
@ -330,6 +330,18 @@ _start:
}
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, scope, false), NULL, _exit);
char category[TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE] = {0};
TAOS_CHECK_GOTO(cfgDumpItemCategory(pItem, &category[VARSTR_HEADER_SIZE], TSDB_CONFIG_CATEGORY_LEN, &valueLen),
NULL, _exit);
varDataSetLen(category, valueLen);
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
if (pColInfo == NULL) {
code = terrno;
TAOS_CHECK_GOTO(code, NULL, _exit);
}
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, category, 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];

View File

@ -1079,6 +1079,78 @@ static void getSlowLogScopeString(int32_t scope, char *result) {
}
}
SArray *initVariablesFromItems(SArray *pItems) {
if (pItems == NULL) {
return NULL;
}
int32_t sz = taosArrayGetSize(pItems);
SArray *pInfos = taosArrayInit(sz, sizeof(SVariablesInfo));
for (int32_t i = 0; i < sz; ++i) {
SConfigItem *pItem = taosArrayGet(pItems, i);
SVariablesInfo info = {0};
strcpy(info.name, pItem->name);
// init info value
switch (pItem->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
sprintf(info.value, "%d", pItem->bval);
break;
case CFG_DTYPE_INT32:
sprintf(info.value, "%d", pItem->i32);
break;
case CFG_DTYPE_INT64:
sprintf(info.value, "%" PRId64, pItem->i64);
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
sprintf(info.value, "%f", pItem->fval);
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
sprintf(info.value, "%s", pItem->str);
break;
}
// init info scope
switch (pItem->scope) {
case CFG_SCOPE_SERVER:
strcpy(info.scope, "server");
break;
case CFG_SCOPE_CLIENT:
strcpy(info.scope, "client");
break;
case CFG_SCOPE_BOTH:
strcpy(info.scope, "both");
break;
default:
strcpy(info.scope, "unknown");
break;
}
// init info category
switch (pItem->category) {
case CFG_CATEGORY_GLOBAL:
strcpy(info.category, "global");
break;
case CFG_CATEGORY_LOCAL:
strcpy(info.category, "local");
break;
default:
strcpy(info.category, "unknown");
break;
}
taosArrayPush(pInfos, &info);
}
return pInfos;
}
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
SShowVariablesRsp rsp = {0};
int32_t code = -1;
@ -1087,90 +1159,13 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
goto _OVER;
}
rsp.variables = taosArrayInit(16, sizeof(SVariablesInfo));
if (NULL == rsp.variables) {
mError("failed to alloc SVariablesInfo array while process show variables req");
code = terrno;
goto _OVER;
}
SVariablesInfo info = {0};
(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) {
rsp.variables = initVariablesFromItems(taosGetGlobalCfg(tsCfg));
if (rsp.variables == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "timezone");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "locale");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "charset");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "monitor");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "monitorInterval");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "slowLogThreshold");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "slowLogMaxLen");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
char scopeStr[64] = {0};
getSlowLogScopeString(tsSlowLogScope, scopeStr);
(void)strcpy(info.name, "slowLogScope");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
void *pRsp = rpcMallocCont(rspLen);
if (pRsp == NULL) {

View File

@ -960,6 +960,12 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
goto _exit;
}
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD5_LEN;
if (taosArrayPush(pBlock->pDataBlock, &infoData) == NULL) {
goto _exit;
}
*pOutput = pBlock;
_exit:

View File

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parTranslater.h"
#include "parInt.h"
#include "parTranslater.h"
#include "tdatablock.h"
#include "catalog.h"
@ -1876,9 +1876,8 @@ static EDealRes translateColumnInGroupByClause(STranslateContext* pCxt, SColumnN
} else {
bool found = false;
res = translateColumnWithoutPrefix(pCxt, pCol);
if (!(*pCol)->node.asParam &&
res != DEAL_RES_CONTINUE &&
res != DEAL_RES_END && pCxt->errCode != TSDB_CODE_PAR_AMBIGUOUS_COLUMN) {
if (!(*pCol)->node.asParam && res != DEAL_RES_CONTINUE && res != DEAL_RES_END &&
pCxt->errCode != TSDB_CODE_PAR_AMBIGUOUS_COLUMN) {
res = translateColumnUseAlias(pCxt, pCol, &found);
*translateAsAlias = true;
}
@ -3321,9 +3320,11 @@ static int32_t selectCommonType(SDataType* commonType, const SDataType* newType)
return TSDB_CODE_SUCCESS;
}
if ((resultType == TSDB_DATA_TYPE_VARCHAR) && (IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) {
if ((resultType == TSDB_DATA_TYPE_VARCHAR) &&
(IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) {
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), QUERY_NUMBER_MAX_DISPLAY_LEN);
} else if ((resultType == TSDB_DATA_TYPE_NCHAR) && (IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) {
} else if ((resultType == TSDB_DATA_TYPE_NCHAR) &&
(IS_MATHABLE_TYPE(commonType->type) || IS_MATHABLE_TYPE(newType->type))) {
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), QUERY_NUMBER_MAX_DISPLAY_LEN * TSDB_NCHAR_SIZE);
} else {
commonType->bytes = TMAX(TMAX(commonType->bytes, newType->bytes), TYPE_BYTES[resultType]);
@ -5528,8 +5529,7 @@ static int32_t translateGroupByList(STranslateContext* pCxt, SSelectStmt* pSelec
if (NULL == pSelect->pGroupByList) {
return TSDB_CODE_SUCCESS;
}
SReplaceGroupByAliasCxt cxt = {
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
SReplaceGroupByAliasCxt cxt = {.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
nodesRewriteExprsPostOrder(pSelect->pGroupByList, translateGroupPartitionByImpl, &cxt);
return pCxt->errCode;
@ -5540,8 +5540,7 @@ static int32_t translatePartitionByList(STranslateContext* pCxt, SSelectStmt* pS
return TSDB_CODE_SUCCESS;
}
SReplaceGroupByAliasCxt cxt = {
.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
SReplaceGroupByAliasCxt cxt = {.pTranslateCxt = pCxt, .pProjectionList = pSelect->pProjectionList};
nodesRewriteExprsPostOrder(pSelect->pPartitionByList, translateGroupPartitionByImpl, &cxt);
return pCxt->errCode;
@ -10521,7 +10520,8 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
(void)tNameGetFullDbName(&name, pDbFName);
}
static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* aliasName, int32_t len, char* defaultName[]) {
static void getStreamQueryFirstProjectAliasName(SHashObj* pUserAliasSet, char* aliasName, int32_t len,
char* defaultName[]) {
for (int32_t i = 0; defaultName[i] != NULL; i++) {
if (NULL == taosHashGet(pUserAliasSet, defaultName[i], strlen(defaultName[i]))) {
snprintf(aliasName, len, "%s", defaultName[i]);
@ -10547,8 +10547,8 @@ static int32_t setColumnDefNodePrimaryKey(SColumnDefNode* pNode, bool isPk) {
return code;
}
static int32_t addIrowTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelectStmt* pSelect,
SHashObj* pUserAliasSet, SNodeList* pCols, SCMCreateStreamReq* pReq) {
static int32_t addIrowTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSelectStmt* pSelect, SHashObj* pUserAliasSet,
SNodeList* pCols, SCMCreateStreamReq* pReq) {
SNode* pProj = nodesListGetNode(pSelect->pProjectionList, 0);
if (!pSelect->hasInterpFunc ||
(QUERY_NODE_FUNCTION == nodeType(pProj) && 0 == strcmp("_irowts", ((SFunctionNode*)pProj)->functionName))) {
@ -10990,20 +10990,17 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
if (pStmt->pOptions->triggerType == STREAM_TRIGGER_FORCE_WINDOW_CLOSE) {
if (pStmt->pOptions->fillHistory) {
return generateSyntaxErrMsgExt(
&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
"When trigger was force window close, Stream unsupported Fill history");
}
if (pStmt->pOptions->ignoreExpired != 1) {
return generateSyntaxErrMsgExt(
&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
"When trigger was force window close, Stream must not set ignore expired 0");
}
if (pStmt->pOptions->ignoreUpdate != 1) {
return generateSyntaxErrMsgExt(
&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
"When trigger was force window close, Stream must not set ignore update 0");
}
@ -13146,8 +13143,12 @@ static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pS
strcpy((*pSchema)[2].name, "scope");
(*pSchema)[3].type = TSDB_DATA_TYPE_BINARY;
(*pSchema)[3].bytes = TSDB_CONFIG_INFO_LEN;
strcpy((*pSchema)[3].name, "info");
(*pSchema)[3].bytes = TSDB_CONFIG_CATEGORY_LEN;
strcpy((*pSchema)[3].name, "category");
(*pSchema)[4].type = TSDB_DATA_TYPE_BINARY;
(*pSchema)[4].bytes = TSDB_CONFIG_INFO_LEN;
strcpy((*pSchema)[4].name, "info");
return TSDB_CODE_SUCCESS;
}

View File

@ -822,6 +822,32 @@ int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
int32_t cfgDumpItemCategory(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen) {
int32_t len = 0;
switch (pItem->category) {
case CFG_CATEGORY_LOCAL:
len = tsnprintf(buf, bufSize, "local");
break;
case CFG_CATEGORY_GLOBAL:
len = tsnprintf(buf, bufSize, "global");
break;
default:
uError("invalid category:%d", pItem->category);
TAOS_RETURN(TSDB_CODE_INVALID_CFG);
}
if (len < 0) {
TAOS_RETURN(TAOS_SYSTEM_ERROR(errno));
}
if (len > bufSize) {
len = bufSize;
}
*pLen = len;
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
void cfgDumpCfgArrayS3(SArray *array, bool tsc, bool dump) {
char src[CFG_SRC_PRINT_LEN + 1] = {0};
char name[CFG_NAME_PRINT_LEN + 1] = {0};