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

@ -676,7 +676,7 @@ typedef struct {
int32_t tsSlowLogThreshold;
int32_t tsSlowLogMaxLen;
int32_t tsSlowLogScope;
int32_t tsSlowLogThresholdTest; //Obsolete
int32_t tsSlowLogThresholdTest; // Obsolete
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
} SMonitorParas;
@ -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
@ -341,7 +342,7 @@ typedef struct SShowStmt {
SNode* pTbName; // SValueNode
EOperatorType tableCondType;
EShowKind showKind; // show databases: user/system, show tables: normal/child, others NULL
bool withFull; // for show users full;
bool withFull; // for show users full;
} SShowStmt;
typedef struct SShowCreateDatabaseStmt {
@ -651,7 +652,7 @@ typedef struct SCreateTSMAStmt {
bool ignoreExists;
char tsmaName[TSDB_TABLE_NAME_LEN];
char dbName[TSDB_DB_NAME_LEN];
char tableName[TSDB_TABLE_NAME_LEN]; // base tb name or base tsma name
char tableName[TSDB_TABLE_NAME_LEN]; // base tb name or base tsma name
char originalTbName[TSDB_TABLE_NAME_LEN];
STSMAOptions* pOptions;
SNode* pPrevQuery;
@ -660,10 +661,10 @@ typedef struct SCreateTSMAStmt {
} SCreateTSMAStmt;
typedef struct SDropTSMAStmt {
ENodeType type;
bool ignoreNotExists;
char dbName[TSDB_DB_NAME_LEN];
char tsmaName[TSDB_TABLE_NAME_LEN];
ENodeType type;
bool ignoreNotExists;
char dbName[TSDB_DB_NAME_LEN];
char tsmaName[TSDB_TABLE_NAME_LEN];
} SDropTSMAStmt;
#ifdef __cplusplus

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_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_COMPARE_MAX_VALUE,
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
@ -638,12 +615,13 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
#define VNODE_HANDLE -3
#define CLIENT_HANDLE -5
#define TSDB_CONFIG_OPTION_LEN 32
#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 TSDB_CONFIG_OPTION_LEN 32
#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 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;
@ -40,7 +40,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
setErrno(pRequest, code);
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0){
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0) {
tscError("failed to remove meta data for table");
}
}
@ -50,7 +50,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -104,7 +104,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
SEpSet dstEpSet = connectRsp.epSet;
if (srcEpSet.numOfEps == 1) {
if (rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn,
dstEpSet.eps[dstEpSet.inUse].fqdn) != 0){
dstEpSet.eps[dstEpSet.inUse].fqdn) != 0) {
tscError("failed to set default addr for rpc");
}
updateEpSet = 0;
@ -146,14 +146,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->authVer = connectRsp.authVer;
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 (taosHashGet(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES) == NULL) {
if (taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo,
POINTER_BYTES) != 0) {
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
}else{
} else {
MonitorSlowLogData data = {0};
data.clusterId = pTscObj->pAppInfo->clusterId;
data.type = SLOW_LOG_READ_BEGINNIG;
(void)monitorPutData2MonitorQueue(data); // ignore
(void)monitorPutData2MonitorQueue(data); // ignore
monitorClientSlowQueryInit(connectRsp.clusterId);
monitorClientSQLReqInit(connectRsp.clusterId);
}
@ -162,7 +163,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
(void)taosThreadMutexLock(&clientHbMgr.lock);
SAppHbMgr* pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx);
if (pAppHbMgr) {
if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0){
if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0) {
tscError("0x%" PRIx64 " failed to register conn to hbMgr", pRequest->requestId);
}
} else {
@ -176,10 +177,10 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->pAppInfo->numOfConns);
End:
if (code != 0){
if (code != 0) {
setErrno(pRequest, code);
}
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
@ -196,7 +197,7 @@ EXIT:
SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if(pMsgSendInfo == NULL) return pMsgSendInfo;
if (pMsgSendInfo == NULL) return pMsgSendInfo;
pMsgSendInfo->requestObjRefId = pRequest->self;
pMsgSendInfo->requestId = pRequest->requestId;
pMsgSendInfo->param = pRequest;
@ -227,11 +228,11 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
char dbFName[TSDB_DB_FNAME_LEN];
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
}
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
}
}
@ -240,7 +241,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -252,19 +253,19 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code ||
TSDB_CODE_MND_DB_IN_DROPPING == code) {
SUseDbRsp usedbRsp = {0};
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
}
struct SCatalog* pCatalog = NULL;
if (usedbRsp.vgVersion >= 0) { // cached in local
int64_t clusterId = pRequest->pTscObj->pAppInfo->clusterId;
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
if (code1 != TSDB_CODE_SUCCESS) {
tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId,
tstrerror(code1));
} else {
if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0){
if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0) {
tscError("0x%" PRIx64 "catalogRemoveDB failed, db:%s, uid:%" PRId64, pRequest->requestId, usedbRsp.db,
usedbRsp.uid);
}
@ -282,7 +283,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, pRequest->code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -291,7 +292,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
SUseDbRsp usedbRsp = {0};
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
}
@ -309,7 +310,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tscTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
SVgroupInfo* pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
if (pInfo == NULL){
if (pInfo == NULL) {
continue;
}
tscTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
@ -319,7 +320,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
SName name = {0};
if(tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) {
if (tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to parse db name:%s", pRequest->requestId, usedbRsp.db);
}
@ -338,7 +339,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
tstrerror(code1));
} else {
if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0){
if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0) {
tscError("0x%" PRIx64 " failed to update db vg info, db:%s, dbId:%" PRId64, pRequest->requestId, output.db,
output.dbId);
}
@ -350,7 +351,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tFreeSUsedbRsp(&usedbRsp);
char db[TSDB_DB_NAME_LEN] = {0};
if(tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) {
if (tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to get db name since %s", pRequest->requestId, tstrerror(code));
}
@ -362,7 +363,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, pRequest->code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -387,7 +388,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
SMCreateStbRsp createRsp = {0};
SDecoder coder = {0};
tDecoderInit(&coder, pMsg->pData, pMsg->len);
if (pMsg->len > 0){
if (pMsg->len > 0) {
code = tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
@ -419,7 +420,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -432,13 +433,13 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
setErrno(pRequest, code);
} else {
SDropDbRsp dropdbRsp = {0};
if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0){
if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SDropDbRsp failed", pRequest->requestId);
}
struct SCatalog* pCatalog = NULL;
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
if (TSDB_CODE_SUCCESS == code) {
if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0){
if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0) {
tscError("0x%" PRIx64 " failed to remove db:%s", pRequest->requestId, dropdbRsp.db);
}
STscObj* pTscObj = pRequest->pTscObj;
@ -451,7 +452,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
}
}
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
@ -465,7 +466,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -480,7 +481,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SMAlterStbRsp alterRsp = {0};
SDecoder coder = {0};
tDecoderInit(&coder, pMsg->pData, pMsg->len);
if (pMsg->len > 0){
if (pMsg->len > 0) {
code = tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len == 0
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
@ -512,7 +513,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -520,8 +521,8 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
int32_t code = 0;
int32_t line = 0;
int32_t code = 0;
int32_t line = 0;
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
TSDB_CHECK_NULL(pBlock, code, line, END, terrno);
pBlock->info.hasVarCol = true;
@ -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++);
@ -605,7 +617,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
*pRsp = taosMemoryCalloc(1, rspSize);
if (NULL == *pRsp) {
code = terrno;
goto _exit;
goto _exit;
}
(*pRsp)->useconds = 0;
@ -617,7 +629,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, SHOW_VARIABLES_RESULT_COLS);
if(len < 0) {
if (len < 0) {
uError("buildShowVariablesRsp error, len:%d", len);
code = terrno;
goto _exit;
@ -639,11 +651,11 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
return TSDB_CODE_SUCCESS;
_exit:
if(*pRsp) {
if (*pRsp) {
taosMemoryFree(*pRsp);
*pRsp = NULL;
}
if(pBlock) {
if (pBlock) {
blockDataDestroy(pBlock);
pBlock = NULL;
}
@ -677,7 +689,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -685,8 +697,8 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) {
int32_t code = 0;
int32_t line = 0;
int32_t code = 0;
int32_t line = 0;
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
TSDB_CHECK_NULL(pBlock, code, line, END, terrno);
pBlock->info.hasVarCol = true;
@ -772,7 +784,7 @@ static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetr
(*pRsp)->numOfCols = htonl(COMPACT_DB_RESULT_COLS);
int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, COMPACT_DB_RESULT_COLS);
if(len < 0) {
if (len < 0) {
uError("buildRetriveTableRspForCompactDb error, len:%d", len);
code = terrno;
goto _exit;
@ -794,24 +806,23 @@ static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetr
return TSDB_CODE_SUCCESS;
_exit:
if(*pRsp) {
if (*pRsp) {
taosMemoryFree(*pRsp);
*pRsp = NULL;
}
if(pBlock) {
if (pBlock) {
blockDataDestroy(pBlock);
pBlock = NULL;
}
return code;
}
int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param;
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
} else {
SCompactDbRsp rsp = {0};
SCompactDbRsp rsp = {0};
SRetrieveTableRsp* pRes = NULL;
code = tDeserializeSCompactDbRsp(pMsg->pData, pMsg->len, &rsp);
if (TSDB_CODE_SUCCESS == code) {
@ -830,9 +841,9 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
taosMemoryFree(pMsg->pEpSet);
if (pRequest->body.queryFp != NULL) {
pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code);
pRequest->body.queryFp(((SSyncQueryParam*)pRequest->body.interParam)->userParam, pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}

View File

@ -77,7 +77,7 @@ static int32_t tSerializeSMonitorParas(SEncoder *encoder, const SMonitorParas *p
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogScope));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogMaxLen));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThreshold));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThresholdTest)); //Obsolete
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThresholdTest)); // Obsolete
TAOS_CHECK_RETURN(tEncodeCStr(encoder, pMonitorParas->tsSlowLogExceptDb));
return 0;
}
@ -88,7 +88,7 @@ static int32_t tDeserializeSMonitorParas(SDecoder *decoder, SMonitorParas *pMoni
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogScope));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogMaxLen));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThreshold));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThresholdTest)); //Obsolete
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThresholdTest)); // Obsolete
TAOS_CHECK_RETURN(tDecodeCStrTo(decoder, pMonitorParas->tsSlowLogExceptDb));
return 0;
}
@ -2255,9 +2255,9 @@ int32_t tSerializeRetrieveAnalAlgoRsp(void *buf, int32_t bufLen, SRetrieveAnalAl
int32_t numOfAlgos = 0;
void *pIter = taosHashIterate(pRsp->hash, NULL);
while (pIter != NULL) {
SAnalyticsUrl *pUrl = pIter;
size_t nameLen = 0;
const char *name = taosHashGetKey(pIter, &nameLen);
SAnalyticsUrl *pUrl = pIter;
size_t nameLen = 0;
const char *name = taosHashGetKey(pIter, &nameLen);
if (nameLen > 0 && nameLen <= TSDB_ANALYTIC_ALGO_KEY_LEN && pUrl->urlLen > 0) {
numOfAlgos++;
}
@ -2270,9 +2270,9 @@ int32_t tSerializeRetrieveAnalAlgoRsp(void *buf, int32_t bufLen, SRetrieveAnalAl
pIter = taosHashIterate(pRsp->hash, NULL);
while (pIter != NULL) {
SAnalyticsUrl *pUrl = pIter;
size_t nameLen = 0;
const char *name = taosHashGetKey(pIter, &nameLen);
SAnalyticsUrl *pUrl = pIter;
size_t nameLen = 0;
const char *name = taosHashGetKey(pIter, &nameLen);
if (nameLen > 0 && pUrl->urlLen > 0) {
TAOS_CHECK_EXIT(tEncodeI32(&encoder, nameLen));
TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (const uint8_t *)name, nameLen));
@ -2310,11 +2310,10 @@ 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;
char name[TSDB_ANALYTIC_ALGO_KEY_LEN];
int32_t numOfAlgos = 0;
int32_t nameLen;
int32_t type;
char name[TSDB_ANALYTIC_ALGO_KEY_LEN];
SAnalyticsUrl url = {0};
TAOS_CHECK_EXIT(tStartDecode(&decoder));
@ -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;
@ -282,7 +282,7 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
locked = 1;
while ((pItem = cfgNextIter(pIter)) != NULL) {
_start:
_start:
col = startCol;
// GRANT_CFG_SKIP;
@ -297,11 +297,11 @@ _start:
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, name, false), NULL, _exit);
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
int32_t valueLen = 0;
char value[TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE] = {0};
int32_t valueLen = 0;
SDiskCfg* pDiskCfg = NULL;
if (strcasecmp(pItem->name, "dataDir") == 0 && exSize > 0) {
char* buf = &value[VARSTR_HEADER_SIZE];
char* buf = &value[VARSTR_HEADER_SIZE];
pDiskCfg = taosArrayGet(pItem->array, index);
valueLen = tsnprintf(buf, TSDB_CONFIG_PATH_LEN, "%s", pDiskCfg->dir);
index++;
@ -330,11 +330,23 @@ _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];
valueLen = tsnprintf(buf, TSDB_CONFIG_INFO_LEN, "level %d primary %d disabled %" PRIi8, pDiskCfg->level,
pDiskCfg->primary, pDiskCfg->disable);
pDiskCfg->primary, pDiskCfg->disable);
} else {
valueLen = 0;
}
@ -351,7 +363,7 @@ _start:
if (index > 0 && index <= exSize) {
goto _start;
}
}
}
pBlock->info.rows = numOfRows;
_exit:
if (locked) cfgUnLock(pConf);

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

@ -223,7 +223,7 @@ static int32_t execDescribe(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp**
if (NULL == pDesc || NULL == pDesc->pMeta) {
return TSDB_CODE_INVALID_PARA;
}
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
SSDataBlock* pBlock = NULL;
int32_t code = buildDescResultDataBlock(&pBlock);
@ -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"
@ -1853,7 +1853,7 @@ static bool clauseSupportAlias(ESqlClause clause) {
return SQL_CLAUSE_GROUP_BY == clause || SQL_CLAUSE_PARTITION_BY == clause || SQL_CLAUSE_ORDER_BY == clause;
}
static EDealRes translateColumnInGroupByClause(STranslateContext* pCxt, SColumnNode** pCol, bool *translateAsAlias) {
static EDealRes translateColumnInGroupByClause(STranslateContext* pCxt, SColumnNode** pCol, bool* translateAsAlias) {
*translateAsAlias = false;
// count(*)/first(*)/last(*) and so on
if (0 == strcmp((*pCol)->colName, "*")) {
@ -1862,7 +1862,7 @@ static EDealRes translateColumnInGroupByClause(STranslateContext* pCxt, SColumnN
if (pCxt->pParseCxt->biMode) {
SNode** ppNode = (SNode**)pCol;
bool ret;
bool ret;
pCxt->errCode = biRewriteToTbnameFunc(pCxt, ppNode, &ret);
if (TSDB_CODE_SUCCESS != pCxt->errCode) return DEAL_RES_ERROR;
if (ret) {
@ -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]);
@ -5480,7 +5481,7 @@ static EDealRes translateGroupPartitionByImpl(SNode** pNode, void* pContext) {
int32_t code = TSDB_CODE_SUCCESS;
STranslateContext* pTransCxt = pCxt->pTranslateCxt;
if (QUERY_NODE_VALUE == nodeType(*pNode)) {
SValueNode* pVal = (SValueNode*) *pNode;
SValueNode* pVal = (SValueNode*)*pNode;
if (DEAL_RES_ERROR == translateValue(pTransCxt, pVal)) {
return DEAL_RES_CONTINUE;
}
@ -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))) {
@ -10595,7 +10595,7 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele
return TSDB_CODE_SUCCESS;
}
SFunctionNode* pFunc = NULL;
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc);
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc);
if (NULL == pFunc) {
return code;
}
@ -10627,7 +10627,7 @@ static int32_t addWstartTsToCreateStreamQueryImpl(STranslateContext* pCxt, SSele
}
static int32_t addTsKeyToCreateStreamQuery(STranslateContext* pCxt, SNode* pStmt, SNodeList* pCols,
SCMCreateStreamReq* pReq) {
SCMCreateStreamReq* pReq) {
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
SHashObj* pUserAliasSet = NULL;
int32_t code = checkProjectAlias(pCxt, pSelect->pProjectionList, &pUserAliasSet);
@ -10990,21 +10990,18 @@ 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,
"When trigger was force window close, Stream unsupported Fill history");
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,
"When trigger was force window close, Stream must not set ignore expired 0");
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,
"When trigger was force window close, Stream must not set ignore update 0");
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY,
"When trigger was force window close, Stream must not set ignore update 0");
}
if (pSelect->pWindow != NULL && QUERY_NODE_INTERVAL_WINDOW == nodeType(pSelect->pWindow)) {
@ -13127,7 +13124,7 @@ static int32_t extractShowCreateViewResultSchema(int32_t* numOfCols, SSchema** p
}
static int32_t extractShowVariablesResultSchema(int32_t* numOfCols, SSchema** pSchema) {
*numOfCols = SHOW_LOCAL_VARIABLES_RESULT_COLS; // SHOW_VARIABLES_RESULT_COLS
*numOfCols = SHOW_LOCAL_VARIABLES_RESULT_COLS; // SHOW_VARIABLES_RESULT_COLS
*pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema));
if (NULL == (*pSchema)) {
return terrno;
@ -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};