Merge branch '3.0' of https://github.com/taosdata/TDengine into enh/TD-30987-11
This commit is contained in:
commit
1709a98e78
|
@ -112,11 +112,11 @@ int64_t nodesMakeAllocatorWeakRef(int64_t allocatorId);
|
|||
int64_t nodesReleaseAllocatorWeakRef(int64_t allocatorId);
|
||||
void nodesDestroyAllocator(int64_t allocatorId);
|
||||
|
||||
SNode* nodesMakeNode(ENodeType type);
|
||||
int32_t nodesMakeNode(ENodeType type, SNode** ppNodeOut);
|
||||
void nodesDestroyNode(SNode* pNode);
|
||||
void nodesFree(void* p);
|
||||
|
||||
SNodeList* nodesMakeList();
|
||||
int32_t nodesMakeList(SNodeList** ppListOut);
|
||||
int32_t nodesListAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListStrictAppend(SNodeList* pList, SNode* pNode);
|
||||
int32_t nodesListMakeAppend(SNodeList** pList, SNode* pNode);
|
||||
|
@ -156,8 +156,8 @@ bool nodeListNodeEqual(const SNodeList* a, const SNode* b);
|
|||
|
||||
bool nodesMatchNode(const SNode* pSub, const SNode* pNode);
|
||||
|
||||
SNode* nodesCloneNode(const SNode* pNode);
|
||||
SNodeList* nodesCloneList(const SNodeList* pList);
|
||||
int32_t nodesCloneNode(const SNode* pNode, SNode** ppNodeOut);
|
||||
int32_t nodesCloneList(const SNodeList* pList, SNodeList** ppList);
|
||||
|
||||
const char* nodesNodeName(ENodeType type);
|
||||
int32_t nodesNodeToString(const SNode* pNode, bool format, char** pStr, int32_t* pLen);
|
||||
|
|
|
@ -636,9 +636,9 @@ void* nodesGetValueFromNode(SValueNode* pNode);
|
|||
int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value);
|
||||
char* nodesGetStrValueFromNode(SValueNode* pNode);
|
||||
void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
|
||||
SValueNode* nodesMakeValueNodeFromString(char* literal);
|
||||
SValueNode* nodesMakeValueNodeFromBool(bool b);
|
||||
SNode* nodesMakeValueNodeFromInt32(int32_t value);
|
||||
int32_t nodesMakeValueNodeFromString(char* literal, SValueNode** ppValNode);
|
||||
int32_t nodesMakeValueNodeFromBool(bool b, SValueNode** ppValNode);
|
||||
int32_t nodesMakeValueNodeFromInt32(int32_t value, SNode** ppNode);
|
||||
|
||||
char* nodesGetFillModeString(EFillMode mode);
|
||||
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
|
||||
|
|
|
@ -118,6 +118,7 @@ void qDestroyQuery(SQuery* pQueryNode);
|
|||
|
||||
int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pSchema);
|
||||
int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid);
|
||||
int32_t qInitKeywordsTable();
|
||||
void qCleanupKeywordsTable();
|
||||
|
||||
int32_t qAppendStmtTableOutput(SQuery* pQuery, SHashObj* pAllVgHash, STableColsData* pTbData, STableDataCxt* pTbCtx, SStbInterlaceInfo* pBuildInfo);
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef int (*__compar_fn_t)(const void *, const void *);
|
|||
#endif
|
||||
#define ssize_t int
|
||||
#define _SSIZE_T_
|
||||
#define bzero(ptr, size) memset((ptr), 0, (size))
|
||||
#define bzero(ptr, size) (void)memset((ptr), 0, (size))
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define wcsncasecmp _wcsnicmp
|
||||
|
|
|
@ -114,8 +114,6 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
|
|||
|
||||
bool taosValidFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosGetErrorFile(TdFilePtr pFile);
|
||||
|
||||
int32_t taosCompressFile(char *srcFileName, char *destFileName);
|
||||
|
||||
int32_t taosSetFileHandlesLimit();
|
||||
|
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
|
||||
char *taosCharsetReplace(char *charsetstr);
|
||||
void taosGetSystemLocale(char *outLocale, char *outCharset);
|
||||
void taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
int32_t taosSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -49,11 +49,14 @@ typedef BOOL (*FSignalHandler)(DWORD fdwCtrlType);
|
|||
#else
|
||||
typedef void (*FSignalHandler)(int32_t signum, void *sigInfo, void *context);
|
||||
#endif
|
||||
void taosSetSignal(int32_t signum, FSignalHandler sigfp);
|
||||
void taosIgnSignal(int32_t signum);
|
||||
void taosDflSignal(int32_t signum);
|
||||
|
||||
void taosKillChildOnParentStopped();
|
||||
typedef void (*sighandler_t)(int);
|
||||
|
||||
int32_t taosSetSignal(int32_t signum, FSignalHandler sigfp);
|
||||
int32_t taosIgnSignal(int32_t signum);
|
||||
int32_t taosDflSignal(int32_t signum);
|
||||
|
||||
int32_t taosKillChildOnParentStopped();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -159,13 +159,12 @@ TdSocketPtr taosAcceptTcpConnectSocket(TdSocketServerPtr pServerSocket, st
|
|||
|
||||
int32_t taosGetSocketName(TdSocketPtr pSocket, struct sockaddr *destAddr, int *addrLen);
|
||||
|
||||
void taosBlockSIGPIPE();
|
||||
uint32_t taosGetIpv4FromFqdn(const char *);
|
||||
int32_t taosBlockSIGPIPE();
|
||||
int32_t taosGetIpv4FromFqdn(const char *fqdn, uint32_t* ip);
|
||||
int32_t taosGetFqdn(char *);
|
||||
void tinet_ntoa(char *ipstr, uint32_t ip);
|
||||
uint32_t ip2uint(const char *const ip_addr);
|
||||
void taosIgnSIGPIPE();
|
||||
void taosSetMaskSIGPIPE();
|
||||
int32_t taosIgnSIGPIPE();
|
||||
uint32_t taosInetAddr(const char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
|
|||
int32_t taosUcs4ToMbsEx(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs, iconv_t conv);
|
||||
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
|
||||
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
|
||||
TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
int32_t tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
|
||||
bool taosValidateEncodec(const char *encodec);
|
||||
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len);
|
||||
int32_t taosHexDecode(const char *src, char *dst, int32_t len);
|
||||
|
|
|
@ -44,7 +44,7 @@ int64_t taosGetLineCmd(TdCmdPtr pCmd, char **__restrict ptrBuf);
|
|||
|
||||
int32_t taosEOFCmd(TdCmdPtr pCmd);
|
||||
|
||||
int64_t taosCloseCmd(TdCmdPtr *ppCmd);
|
||||
void taosCloseCmd(TdCmdPtr *ppCmd);
|
||||
|
||||
void *taosLoadDll(const char *filename);
|
||||
|
||||
|
@ -54,11 +54,11 @@ void taosCloseDll(void *handle);
|
|||
|
||||
int32_t taosSetConsoleEcho(bool on);
|
||||
|
||||
void taosSetTerminalMode();
|
||||
int32_t taosSetTerminalMode();
|
||||
|
||||
int32_t taosGetOldTerminalMode();
|
||||
|
||||
void taosResetTerminalMode();
|
||||
int32_t taosResetTerminalMode();
|
||||
|
||||
#define STACKSIZE 100
|
||||
|
||||
|
|
|
@ -198,7 +198,8 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_TSC_ENCODE_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0231)
|
||||
#define TSDB_CODE_TSC_ENCODE_PARAM_NULL TAOS_DEF_ERROR_CODE(0, 0X0232)
|
||||
#define TSDB_CODE_TSC_COMPRESS_PARAM_ERROR TAOS_DEF_ERROR_CODE(0, 0X0233)
|
||||
#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234)
|
||||
#define TSDB_CODE_TSC_COMPRESS_LEVEL_ERROR TAOS_DEF_ERROR_CODE(0, 0X0234)
|
||||
#define TSDB_CODE_TSC_FAIL_GENERATE_JSON TAOS_DEF_ERROR_CODE(0, 0X0235)
|
||||
#define TSDB_CODE_TSC_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0X02FF)
|
||||
|
||||
// mnode-common
|
||||
|
|
|
@ -156,7 +156,7 @@ void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp);
|
|||
* @param pBuf
|
||||
* @param pageId
|
||||
*/
|
||||
void dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage);
|
||||
int32_t dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage);
|
||||
|
||||
/**
|
||||
* Print the statistics when closing this buffer
|
||||
|
|
|
@ -75,7 +75,7 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
|||
char buf[TSDB_PASSWORD_LEN + 1];
|
||||
|
||||
buf[TSDB_PASSWORD_LEN] = 0;
|
||||
sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||
(void)sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1],
|
||||
context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
|
||||
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
|
||||
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
|
@ -108,10 +108,10 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
int32_t offset = 0;
|
||||
if (prefix < 0) {
|
||||
offset = -1 * prefix;
|
||||
strncpy(tbName, tbname, offset);
|
||||
(void)strncpy(tbName, tbname, offset);
|
||||
}
|
||||
if (suffix < 0) {
|
||||
strncpy(tbName + offset, tbname + tblen + suffix, -1 * suffix);
|
||||
(void)strncpy(tbName + offset, tbname + tblen + suffix, -1 * suffix);
|
||||
offset += -1 * suffix;
|
||||
}
|
||||
return MurmurHash3_32(tbName, offset);
|
||||
|
|
|
@ -310,7 +310,7 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
|||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4);
|
||||
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
||||
bool convertUcs4);
|
||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
int32_t setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
|
||||
void syncCatalogFn(SMetaData* pResult, void* param, int32_t code);
|
||||
|
@ -348,15 +348,16 @@ __async_send_cb_fn_t getMsgRspHandle(int32_t msgType);
|
|||
|
||||
SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj);
|
||||
|
||||
void* createTscObj(const char* user, const char* auth, const char* db, int32_t connType, SAppInstInfo* pAppInfo);
|
||||
int32_t createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo,
|
||||
STscObj **p);
|
||||
void destroyTscObj(void* pObj);
|
||||
STscObj* acquireTscObj(int64_t rid);
|
||||
int32_t releaseTscObj(int64_t rid);
|
||||
void releaseTscObj(int64_t rid);
|
||||
void destroyAppInst(void* pAppInfo);
|
||||
|
||||
uint64_t generateRequestId();
|
||||
|
||||
void* createRequest(uint64_t connId, int32_t type, int64_t reqid);
|
||||
int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj **pRequest);
|
||||
void destroyRequest(SRequestObj* pRequest);
|
||||
SRequestObj* acquireRequest(int64_t rid);
|
||||
int32_t releaseRequest(int64_t rid);
|
||||
|
@ -370,7 +371,7 @@ void resetConnectDB(STscObj* pTscObj);
|
|||
|
||||
int taos_options_imp(TSDB_OPTION option, const char* str);
|
||||
|
||||
void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
|
||||
int32_t openTransporter(const char* user, const char* auth, int32_t numOfThreads, void **pDnodeConn);
|
||||
void tscStopCrashReport();
|
||||
|
||||
typedef struct AsyncArg {
|
||||
|
@ -381,8 +382,8 @@ typedef struct AsyncArg {
|
|||
bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
|
||||
void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet);
|
||||
|
||||
STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||
uint16_t port, int connType);
|
||||
int32_t taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
|
||||
uint16_t port, int connType, STscObj** pObj);
|
||||
|
||||
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb);
|
||||
|
||||
|
@ -395,11 +396,11 @@ void taos_close_internal(void* taos);
|
|||
|
||||
// --- heartbeat
|
||||
// global, called by mgmt
|
||||
int hbMgrInit();
|
||||
void hbMgrCleanUp();
|
||||
int32_t hbMgrInit();
|
||||
void hbMgrCleanUp();
|
||||
|
||||
// cluster level
|
||||
SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key);
|
||||
int32_t appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key, SAppHbMgr **pAppHbMgr);
|
||||
void appHbMgrCleanup(void);
|
||||
void hbRemoveAppHbMrg(SAppHbMgr** pAppHbMgr);
|
||||
void destroyAllRequests(SHashObj* pRequests);
|
||||
|
@ -408,7 +409,7 @@ void stopAllRequests(SHashObj* pRequests);
|
|||
//SAppInstInfo* getAppInstInfo(const char* clusterKey);
|
||||
|
||||
// conn level
|
||||
int hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||
int32_t hbRegisterConn(SAppHbMgr* pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType);
|
||||
void hbDeregisterConn(STscObj* pTscObj, SClientHbKey connKey);
|
||||
|
||||
typedef struct SSqlCallbackWrapper {
|
||||
|
@ -427,7 +428,7 @@ void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta);
|
|||
int32_t removeMeta(STscObj* pTscObj, SArray* tbList, bool isView);
|
||||
int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog);
|
||||
int32_t handleCreateTbExecRes(void* res, SCatalog* pCatalog);
|
||||
bool qnodeRequired(SRequestObj* pRequest);
|
||||
int32_t qnodeRequired(SRequestObj* pRequest, bool *required);
|
||||
void continueInsertFromCsv(SSqlCallbackWrapper* pWrapper, SRequestObj* pRequest);
|
||||
void destorySqlCallbackWrapper(SSqlCallbackWrapper* pWrapper);
|
||||
void handleQueryAnslyseRes(SSqlCallbackWrapper *pWrapper, SMetaData *pResultMeta, int32_t code);
|
||||
|
@ -443,6 +444,30 @@ void freeQueryParam(SSyncQueryParam* param);
|
|||
int32_t clientParseSqlImpl(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effeciveUser, SParseSqlRes* pRes);
|
||||
#endif
|
||||
|
||||
#define TSC_ERR_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
return _code; \
|
||||
} \
|
||||
} while (0)
|
||||
#define TSC_RET(c) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = _code; \
|
||||
} \
|
||||
return _code; \
|
||||
} while (0)
|
||||
#define TSC_ERR_JRET(c) \
|
||||
do { \
|
||||
code = c; \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
terrno = code; \
|
||||
goto _return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void slowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost);
|
||||
|
||||
|
|
|
@ -44,6 +44,26 @@
|
|||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
||||
#define ENV_JSON_FALSE_CHECK(c) \
|
||||
do { \
|
||||
if (!c) { \
|
||||
tscError("faild to add item to JSON object");\
|
||||
code = TSDB_CODE_TSC_FAIL_GENERATE_JSON; \
|
||||
goto _end; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ENV_ERR_RET(c,info) \
|
||||
do { \
|
||||
int32_t _code = c; \
|
||||
if (_code != TSDB_CODE_SUCCESS) { \
|
||||
errno = _code; \
|
||||
tscInitRes = _code; \
|
||||
tscError(info); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
STscDbg tscDbg = {0};
|
||||
SAppInfo appInfo;
|
||||
int64_t lastClusterId = 0;
|
||||
|
@ -57,8 +77,14 @@ static TdThreadOnce tscinit = PTHREAD_ONCE_INIT;
|
|||
volatile int32_t tscInitRes = 0;
|
||||
|
||||
static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
// connection has been released already, abort creating request.
|
||||
pRequest->self = taosAddRef(clientReqRefPool, pRequest);
|
||||
if (pRequest->self < 0) {
|
||||
tscError("failed to add ref to request");
|
||||
code = terrno;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t num = atomic_add_fetch_32(&pTscObj->numOfReqs, 1);
|
||||
|
||||
|
@ -72,19 +98,23 @@ static int32_t registerRequest(SRequestObj *pRequest, STscObj *pTscObj) {
|
|||
pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static void concatStrings(SArray *list, char* buf, int size){
|
||||
int len = 0;
|
||||
for(int i = 0; i < taosArrayGetSize(list); i++){
|
||||
char* db = taosArrayGet(list, i);
|
||||
if (NULL == db) {
|
||||
tscError("get dbname failed, buf:%s", buf);
|
||||
break;
|
||||
}
|
||||
char* dot = strchr(db, '.');
|
||||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
}
|
||||
if (i != 0){
|
||||
strcat(buf, ",");
|
||||
(void)strcat(buf, ",");
|
||||
len += 1;
|
||||
}
|
||||
int ret = snprintf(buf + len, size - len, "%s", db);
|
||||
|
@ -100,61 +130,70 @@ static void concatStrings(SArray *list, char* buf, int size){
|
|||
}
|
||||
}
|
||||
|
||||
static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration){
|
||||
static int32_t generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_t reqType, int64_t duration){
|
||||
cJSON* json = cJSON_CreateObject();
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (json == NULL) {
|
||||
tscError("[monitor] cJSON_CreateObject failed");
|
||||
return;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
char clusterId[32] = {0};
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRId64, pTscObj->pAppInfo->clusterId) < 0){
|
||||
tscError("failed to generate clusterId:%" PRId64, pTscObj->pAppInfo->clusterId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char startTs[32] = {0};
|
||||
if (snprintf(startTs, sizeof(startTs), "%" PRId64, pRequest->metric.start/1000) < 0){
|
||||
tscError("failed to generate startTs:%" PRId64, pRequest->metric.start/1000);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
char requestId[32] = {0};
|
||||
if (snprintf(requestId, sizeof(requestId), "%" PRIu64, pRequest->requestId) < 0){
|
||||
tscError("failed to generate requestId:%" PRIu64, pRequest->requestId);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId));
|
||||
cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs));
|
||||
cJSON_AddItemToObject(json, "request_id", cJSON_CreateString(requestId));
|
||||
cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration/1000));
|
||||
cJSON_AddItemToObject(json, "code", cJSON_CreateNumber(pRequest->code));
|
||||
cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code)));
|
||||
cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType));
|
||||
cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "request_id", cJSON_CreateString(requestId)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "query_time", cJSON_CreateNumber(duration/1000)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "code", cJSON_CreateNumber(pRequest->code)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code))));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows)));
|
||||
if(pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen){
|
||||
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen];
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = '\0';
|
||||
cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = tmp;
|
||||
}else{
|
||||
cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr)));
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(json, "user", cJSON_CreateString(pTscObj->user));
|
||||
cJSON_AddItemToObject(json, "process_name", cJSON_CreateString(appInfo.appName));
|
||||
cJSON_AddItemToObject(json, "ip", cJSON_CreateString(tsLocalFqdn));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "user", cJSON_CreateString(pTscObj->user)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "process_name", cJSON_CreateString(appInfo.appName)));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "ip", cJSON_CreateString(tsLocalFqdn)));
|
||||
|
||||
char pid[32] = {0};
|
||||
if (snprintf(pid, sizeof(pid), "%d", appInfo.pid) < 0){
|
||||
tscError("failed to generate pid:%d", appInfo.pid);
|
||||
code = TSDB_CODE_FAILED;
|
||||
goto _end;
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid)));
|
||||
if(pRequest->dbList != NULL){
|
||||
char dbList[1024] = {0};
|
||||
concatStrings(pRequest->dbList, dbList, sizeof(dbList) - 1);
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(dbList));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(dbList)));
|
||||
}else if(pRequest->pDb != NULL){
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb)));
|
||||
}else{
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(""));
|
||||
ENV_JSON_FALSE_CHECK(cJSON_AddItemToObject(json, "db", cJSON_CreateString("")));
|
||||
}
|
||||
|
||||
char* value = cJSON_PrintUnformatted(json);
|
||||
|
@ -162,11 +201,15 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
data.clusterId = pTscObj->pAppInfo->clusterId;
|
||||
data.type = SLOW_LOG_WRITE;
|
||||
data.data = value;
|
||||
if(monitorPutData2MonitorQueue(data) < 0){
|
||||
code = monitorPutData2MonitorQueue(data);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(value);
|
||||
goto _end;
|
||||
}
|
||||
|
||||
_end:
|
||||
cJSON_Delete(json);
|
||||
return code;
|
||||
}
|
||||
|
||||
static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
||||
|
@ -176,6 +219,10 @@ static bool checkSlowLogExceptDb(SRequestObj *pRequest, char* exceptDb) {
|
|||
|
||||
for (int i = 0; i < taosArrayGetSize(pRequest->dbList); i++) {
|
||||
char *db = taosArrayGet(pRequest->dbList, i);
|
||||
if (NULL == db) {
|
||||
tscError("get dbname failed, exceptDb:%s", exceptDb);
|
||||
return false;
|
||||
}
|
||||
char *dot = strchr(db, '.');
|
||||
if (dot != NULL) {
|
||||
db = dot + 1;
|
||||
|
@ -215,7 +262,7 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
"us, planCost:%" PRId64 "us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.parseCostUs, pRequest->metric.ctgCostUs, pRequest->metric.analyseCostUs,
|
||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
reqType = SLOW_LOG_TYPE_INSERT;
|
||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||
tscDebug("query duration %" PRId64 "us: parseCost:%" PRId64 "us, ctgCost:%" PRId64 "us, analyseCost:%" PRId64
|
||||
|
@ -223,11 +270,13 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
duration, pRequest->metric.parseCostUs, pRequest->metric.ctgCostUs, pRequest->metric.analyseCostUs,
|
||||
pRequest->metric.planCostUs, pRequest->metric.execCostUs);
|
||||
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
reqType = SLOW_LOG_TYPE_QUERY;
|
||||
}
|
||||
|
||||
nodesSimReleaseAllocator(pRequest->allocatorRefId);
|
||||
if (TSDB_CODE_SUCCESS != nodesSimReleaseAllocator(pRequest->allocatorRefId)) {
|
||||
tscError("failed to release allocator");
|
||||
}
|
||||
}
|
||||
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
|
@ -242,14 +291,16 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
|
||||
if ((duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThreshold * 1000000UL || duration >= pTscObj->pAppInfo->monitorParas.tsSlowLogThresholdTest * 1000000UL) &&
|
||||
checkSlowLogExceptDb(pRequest, pTscObj->pAppInfo->monitorParas.tsSlowLogExceptDb)) {
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1);
|
||||
(void)atomic_add_fetch_64((int64_t *)&pActivity->numOfSlowQueries, 1);
|
||||
if (pTscObj->pAppInfo->monitorParas.tsSlowLogScope & reqType) {
|
||||
taosPrintSlowLog("PID:%d, Conn:%u, QID:0x%" PRIx64 ", Start:%" PRId64 " us, Duration:%" PRId64 "us, SQL:%s",
|
||||
taosGetPId(), pTscObj->connId, pRequest->requestId, pRequest->metric.start, duration,
|
||||
pRequest->sqlstr);
|
||||
if(pTscObj->pAppInfo->monitorParas.tsEnableMonitor){
|
||||
slowQueryLog(pTscObj->id, pRequest->killed, pRequest->code, duration);
|
||||
generateWriteSlowLog(pTscObj, pRequest, reqType, duration);
|
||||
if (TSDB_CODE_SUCCESS != generateWriteSlowLog(pTscObj, pRequest, reqType, duration)) {
|
||||
tscError("failed to generate write slow log");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,9 +340,9 @@ static bool clientRpcTfp(int32_t code, tmsg_t msgType) {
|
|||
}
|
||||
|
||||
// TODO refactor
|
||||
void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
||||
int32_t openTransporter(const char *user, const char *auth, int32_t numOfThread, void **pDnodeConn) {
|
||||
SRpcInit rpcInit;
|
||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
(void)memset(&rpcInit, 0, sizeof(rpcInit));
|
||||
rpcInit.localPort = 0;
|
||||
rpcInit.label = "TSC";
|
||||
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
||||
|
@ -315,15 +366,19 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
|
|||
rpcInit.connLimitNum = connLimitNum;
|
||||
rpcInit.timeToGetConn = tsTimeToGetAvailableConn;
|
||||
|
||||
taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
||||
|
||||
void *pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (pDnodeConn == NULL) {
|
||||
tscError("failed to init connection to server");
|
||||
return NULL;
|
||||
int32_t code = taosVersionStrToInt(version, &(rpcInit.compatibilityVer));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("invalid version string.");
|
||||
return code;
|
||||
}
|
||||
|
||||
return pDnodeConn;
|
||||
*pDnodeConn = rpcOpen(&rpcInit);
|
||||
if (*pDnodeConn == NULL) {
|
||||
tscError("failed to init connection to server.");
|
||||
code = TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void destroyAllRequests(SHashObj *pRequests) {
|
||||
|
@ -334,7 +389,7 @@ void destroyAllRequests(SHashObj *pRequests) {
|
|||
SRequestObj *pRequest = acquireRequest(*rid);
|
||||
if (pRequest) {
|
||||
destroyRequest(pRequest);
|
||||
releaseRequest(*rid);
|
||||
(void)releaseRequest(*rid); // ignore error
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
|
@ -349,7 +404,7 @@ void stopAllRequests(SHashObj *pRequests) {
|
|||
SRequestObj *pRequest = acquireRequest(*rid);
|
||||
if (pRequest) {
|
||||
taos_stop_query(pRequest);
|
||||
releaseRequest(*rid);
|
||||
(void)releaseRequest(*rid); // ignore error
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pRequests, pIter);
|
||||
|
@ -360,18 +415,31 @@ void destroyAppInst(void *info) {
|
|||
SAppInstInfo* pAppInfo = *(SAppInstInfo**)info;
|
||||
tscDebug("destroy app inst mgr %p", pAppInfo);
|
||||
|
||||
taosThreadMutexLock(&appInfo.mutex);
|
||||
int32_t code = taosThreadMutexLock(&appInfo.mutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to lock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
hbRemoveAppHbMrg(&pAppInfo->pAppHbMgr);
|
||||
|
||||
taosThreadMutexUnlock(&appInfo.mutex);
|
||||
code = taosThreadMutexUnlock(&appInfo.mutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to unlock app info, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pAppInfo->instKey);
|
||||
closeTransporter(pAppInfo);
|
||||
|
||||
taosThreadMutexLock(&pAppInfo->qnodeMutex);
|
||||
code = taosThreadMutexLock(&pAppInfo->qnodeMutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to lock qnode mutex, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosArrayDestroy(pAppInfo->pQnodeList);
|
||||
taosThreadMutexUnlock(&pAppInfo->qnodeMutex);
|
||||
code = taosThreadMutexUnlock(&pAppInfo->qnodeMutex);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to unlock qnode mutex, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
|
||||
}
|
||||
|
||||
taosMemoryFree(pAppInfo);
|
||||
}
|
||||
|
@ -396,97 +464,111 @@ void destroyTscObj(void *pObj) {
|
|||
pTscObj->pAppInfo->numOfConns);
|
||||
|
||||
// In any cases, we should not free app inst here. Or an race condition rises.
|
||||
/*int64_t connNum = */ atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
/*int64_t connNum = */ (void)atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1);
|
||||
|
||||
taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
(void)taosThreadMutexDestroy(&pTscObj->mutex);
|
||||
taosMemoryFree(pTscObj);
|
||||
|
||||
tscTrace("end to destroy tscObj %" PRIx64 " p:%p", tscId, pTscObj);
|
||||
}
|
||||
|
||||
void *createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo) {
|
||||
STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||
if (NULL == pObj) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
int32_t createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo,
|
||||
STscObj **pObj) {
|
||||
*pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj));
|
||||
if (NULL == *pObj) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == pObj->pRequests) {
|
||||
taosMemoryFree(pObj);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
(*pObj)->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (NULL == (*pObj)->pRequests) {
|
||||
taosMemoryFree(*pObj);
|
||||
return terrno ? terrno : TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pObj->connType = connType;
|
||||
pObj->pAppInfo = pAppInfo;
|
||||
pObj->appHbMgrIdx = pAppInfo->pAppHbMgr->idx;
|
||||
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
||||
(*pObj)->connType = connType;
|
||||
(*pObj)->pAppInfo = pAppInfo;
|
||||
(*pObj)->appHbMgrIdx = pAppInfo->pAppHbMgr->idx;
|
||||
tstrncpy((*pObj)->user, user, sizeof((*pObj)->user));
|
||||
(void)memcpy((*pObj)->pass, auth, TSDB_PASSWORD_LEN);
|
||||
|
||||
if (db != NULL) {
|
||||
tstrncpy(pObj->db, db, tListLen(pObj->db));
|
||||
tstrncpy((*pObj)->db, db, tListLen((*pObj)->db));
|
||||
}
|
||||
|
||||
taosThreadMutexInit(&pObj->mutex, NULL);
|
||||
pObj->id = taosAddRef(clientConnRefPool, pObj);
|
||||
TSC_ERR_RET(taosThreadMutexInit(&(*pObj)->mutex, NULL));
|
||||
|
||||
atomic_add_fetch_64(&pObj->pAppInfo->numOfConns, 1);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
tscDebug("connObj created, 0x%" PRIx64 ",p:%p", pObj->id, pObj);
|
||||
return pObj;
|
||||
(*pObj)->id = taosAddRef(clientConnRefPool, *pObj);
|
||||
if ((*pObj)->id < 0) {
|
||||
tscError("failed to add object to clientConnRefPool");
|
||||
code = terrno;
|
||||
taosMemoryFree(*pObj);
|
||||
return code;
|
||||
}
|
||||
|
||||
(void)atomic_add_fetch_64(&(*pObj)->pAppInfo->numOfConns, 1);
|
||||
|
||||
tscDebug("connObj created, 0x%" PRIx64 ",p:%p", (*pObj)->id, *pObj);
|
||||
return code;
|
||||
}
|
||||
|
||||
STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientConnRefPool, rid); }
|
||||
|
||||
int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, rid); }
|
||||
void releaseTscObj(int64_t rid) {
|
||||
int32_t code = taosReleaseRef(clientConnRefPool, rid);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscWarn("failed to release TscObj, code:%s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
|
||||
void *createRequest(uint64_t connId, int32_t type, int64_t reqid) {
|
||||
SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||
if (NULL == pRequest) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj **pRequest) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
*pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj));
|
||||
if (NULL == *pRequest) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
STscObj *pTscObj = acquireTscObj(connId);
|
||||
if (pTscObj == NULL) {
|
||||
taosMemoryFree(pRequest);
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||
goto _return;
|
||||
}
|
||||
SSyncQueryParam *interParam = taosMemoryCalloc(1, sizeof(SSyncQueryParam));
|
||||
if (interParam == NULL) {
|
||||
releaseTscObj(connId);
|
||||
doDestroyRequest(pRequest);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
tsem_init(&interParam->sem, 0, 0);
|
||||
interParam->pRequest = pRequest;
|
||||
pRequest->body.interParam = interParam;
|
||||
TSC_ERR_JRET(tsem_init(&interParam->sem, 0, 0));
|
||||
interParam->pRequest = *pRequest;
|
||||
(*pRequest)->body.interParam = interParam;
|
||||
|
||||
pRequest->resType = RES_TYPE__QUERY;
|
||||
pRequest->requestId = reqid == 0 ? generateRequestId() : reqid;
|
||||
pRequest->metric.start = taosGetTimestampUs();
|
||||
(*pRequest)->resType = RES_TYPE__QUERY;
|
||||
(*pRequest)->requestId = reqid == 0 ? generateRequestId() : reqid;
|
||||
(*pRequest)->metric.start = taosGetTimestampUs();
|
||||
|
||||
pRequest->body.resInfo.convertUcs4 = true; // convert ucs4 by default
|
||||
pRequest->type = type;
|
||||
pRequest->allocatorRefId = -1;
|
||||
(*pRequest)->body.resInfo.convertUcs4 = true; // convert ucs4 by default
|
||||
(*pRequest)->type = type;
|
||||
(*pRequest)->allocatorRefId = -1;
|
||||
|
||||
pRequest->pDb = getDbOfConnection(pTscObj);
|
||||
pRequest->pTscObj = pTscObj;
|
||||
pRequest->inCallback = false;
|
||||
(*pRequest)->pDb = getDbOfConnection(pTscObj);
|
||||
(*pRequest)->pTscObj = pTscObj;
|
||||
(*pRequest)->inCallback = false;
|
||||
|
||||
pRequest->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
pRequest->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE;
|
||||
tsem_init(&pRequest->body.rspSem, 0, 0);
|
||||
|
||||
if (registerRequest(pRequest, pTscObj)) {
|
||||
doDestroyRequest(pRequest);
|
||||
return NULL;
|
||||
(*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE);
|
||||
if (NULL == (*pRequest)->msgBuf) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _return;
|
||||
}
|
||||
(*pRequest)->msgBufLen = ERROR_MSG_BUF_DEFAULT_SIZE;
|
||||
TSC_ERR_JRET(tsem_init(&(*pRequest)->body.rspSem, 0, 0));
|
||||
TSC_ERR_JRET(registerRequest(*pRequest, pTscObj));
|
||||
|
||||
return pRequest;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
_return:
|
||||
doDestroyRequest(*pRequest);
|
||||
return code;
|
||||
}
|
||||
|
||||
void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
|
||||
|
@ -521,12 +603,12 @@ int64_t removeFromMostPrevReq(SRequestObj* pRequest) {
|
|||
pTmp = acquireRequest(pTmp->relation.prevRefId);
|
||||
if (pTmp) {
|
||||
mostPrevReqRefId = pTmp->self;
|
||||
releaseRequest(mostPrevReqRefId);
|
||||
(void)releaseRequest(mostPrevReqRefId); // ignore error
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
removeRequest(mostPrevReqRefId);
|
||||
(void)removeRequest(mostPrevReqRefId); // ignore error
|
||||
return mostPrevReqRefId;
|
||||
}
|
||||
|
||||
|
@ -534,8 +616,8 @@ void destroyNextReq(int64_t nextRefId) {
|
|||
if (nextRefId) {
|
||||
SRequestObj* pObj = acquireRequest(nextRefId);
|
||||
if (pObj) {
|
||||
releaseRequest(nextRefId);
|
||||
releaseRequest(nextRefId);
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
(void)releaseRequest(nextRefId); // ignore error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +637,7 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
pTmp = acquireRequest(tmpRefId);
|
||||
if (pTmp) {
|
||||
pReqList[++reqIdx] = pTmp;
|
||||
releaseRequest(tmpRefId);
|
||||
(void)releaseRequest(tmpRefId); // ignore error
|
||||
} else {
|
||||
tscError("prev req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -563,7 +645,7 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
}
|
||||
|
||||
for (int32_t i = reqIdx; i >= 0; i--) {
|
||||
removeRequest(pReqList[i]->self);
|
||||
(void)removeRequest(pReqList[i]->self); // ignore error
|
||||
}
|
||||
|
||||
tmpRefId = pRequest->relation.nextRefId;
|
||||
|
@ -571,8 +653,8 @@ void destroySubRequests(SRequestObj *pRequest) {
|
|||
pTmp = acquireRequest(tmpRefId);
|
||||
if (pTmp) {
|
||||
tmpRefId = pTmp->relation.nextRefId;
|
||||
removeRequest(pTmp->self);
|
||||
releaseRequest(pTmp->self);
|
||||
(void)removeRequest(pTmp->self); // ignore error
|
||||
(void)releaseRequest(pTmp->self); // ignore error
|
||||
} else {
|
||||
tscError("next req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -592,8 +674,10 @@ void doDestroyRequest(void *p) {
|
|||
|
||||
int64_t nextReqRefId = pRequest->relation.nextRefId;
|
||||
|
||||
taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
|
||||
int32_t code = taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("failed to remove request from hash, code:%s", tstrerror(code));
|
||||
}
|
||||
schedulerFreeJob(&pRequest->body.queryJob, 0);
|
||||
|
||||
destorySqlCallbackWrapper(pRequest->pWrapper);
|
||||
|
@ -601,7 +685,7 @@ void doDestroyRequest(void *p) {
|
|||
taosMemoryFreeClear(pRequest->msgBuf);
|
||||
|
||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||
tsem_destroy(&pRequest->body.rspSem);
|
||||
(void)tsem_destroy(&pRequest->body.rspSem);
|
||||
|
||||
taosArrayDestroy(pRequest->tableList);
|
||||
taosArrayDestroy(pRequest->targetTableList);
|
||||
|
@ -615,13 +699,15 @@ void doDestroyRequest(void *p) {
|
|||
taosMemoryFreeClear(pRequest->pDb);
|
||||
taosArrayDestroy(pRequest->dbList);
|
||||
if (pRequest->body.interParam) {
|
||||
tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem);
|
||||
(void)tsem_destroy(&((SSyncQueryParam *)pRequest->body.interParam)->sem);
|
||||
}
|
||||
taosMemoryFree(pRequest->body.interParam);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == nodesSimAcquireAllocator(pRequest->allocatorRefId)) {
|
||||
qDestroyQuery(pRequest->pQuery);
|
||||
nodesSimReleaseAllocator(pRequest->allocatorRefId);
|
||||
if (TSDB_CODE_SUCCESS != nodesSimReleaseAllocator(pRequest->allocatorRefId)) {
|
||||
tscError("failed to release allocator");
|
||||
}
|
||||
}
|
||||
nodesDestroyAllocator(pRequest->allocatorRefId);
|
||||
|
||||
|
@ -638,7 +724,7 @@ void destroyRequest(SRequestObj *pRequest) {
|
|||
}
|
||||
|
||||
taos_stop_query(pRequest);
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
}
|
||||
|
||||
void taosStopQueryImpl(SRequestObj *pRequest) {
|
||||
|
@ -677,7 +763,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
|||
|
||||
for (int32_t i = reqIdx; i >= 0; i--) {
|
||||
taosStopQueryImpl(pReqList[i]);
|
||||
releaseRequest(pReqList[i]->self);
|
||||
(void)releaseRequest(pReqList[i]->self); // ignore error
|
||||
}
|
||||
|
||||
taosStopQueryImpl(pRequest);
|
||||
|
@ -688,7 +774,7 @@ void stopAllQueries(SRequestObj *pRequest) {
|
|||
if (pTmp) {
|
||||
tmpRefId = pTmp->relation.nextRefId;
|
||||
taosStopQueryImpl(pTmp);
|
||||
releaseRequest(pTmp->self);
|
||||
(void)releaseRequest(pTmp->self); // ignore error
|
||||
} else {
|
||||
tscError("next req ref 0x%" PRIx64 " is not there", tmpRefId);
|
||||
break;
|
||||
|
@ -701,7 +787,7 @@ void crashReportThreadFuncUnexpectedStopped(void) { atomic_store_32(&clientStop,
|
|||
static void *tscCrashReportThreadFp(void *param) {
|
||||
setThreadName("client-crashReport");
|
||||
char filepath[PATH_MAX] = {0};
|
||||
snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
||||
(void)snprintf(filepath, sizeof(filepath), "%s%s.taosCrashLog", tsLogDir, TD_DIRSEP);
|
||||
char *pMsg = NULL;
|
||||
int64_t msgLen = 0;
|
||||
TdFilePtr pFile = NULL;
|
||||
|
@ -770,20 +856,27 @@ static void *tscCrashReportThreadFp(void *param) {
|
|||
|
||||
int32_t tscCrashReportInit() {
|
||||
if (!tsEnableCrashReport) {
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
TSC_ERR_JRET(taosThreadAttrInit(&thAttr));
|
||||
TSC_ERR_JRET(taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE));
|
||||
TdThread crashReportThread;
|
||||
if (taosThreadCreate(&crashReportThread, &thAttr, tscCrashReportThreadFp, NULL) != 0) {
|
||||
tscError("failed to create crashReport thread since %s", strerror(errno));
|
||||
return -1;
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
TSC_ERR_RET(errno);
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
_return:
|
||||
if (code) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
TSC_ERR_RET(terrno);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tscStopCrashReport() {
|
||||
|
@ -842,6 +935,11 @@ void taos_init_imp(void) {
|
|||
appInfo.startTime = taosGetTimestampMs();
|
||||
appInfo.pInstMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
appInfo.pInstMapByClusterId = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
||||
tscError("failed to allocate memory when init appInfo");
|
||||
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return;
|
||||
}
|
||||
taosHashSetFreeFp(appInfo.pInstMap, destroyAppInst);
|
||||
deltaToUtcInitOnce();
|
||||
|
||||
|
@ -849,7 +947,7 @@ void taos_init_imp(void) {
|
|||
#ifdef CUS_PROMPT
|
||||
snprintf(logDirName, 64, "%slog", CUS_PROMPT);
|
||||
#else
|
||||
snprintf(logDirName, 64, "taoslog");
|
||||
(void)snprintf(logDirName, 64, "taoslog");
|
||||
#endif
|
||||
if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||
printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
|
||||
|
@ -857,24 +955,12 @@ void taos_init_imp(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {
|
||||
tscInitRes = -1;
|
||||
return;
|
||||
}
|
||||
ENV_ERR_RET(taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1), "failed to init cfg");
|
||||
|
||||
initQueryModuleMsgHandle();
|
||||
|
||||
if (taosConvInit() != 0) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init conv");
|
||||
return;
|
||||
}
|
||||
if (monitorInit() != 0){
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init monitor");
|
||||
return;
|
||||
}
|
||||
rpcInit();
|
||||
ENV_ERR_RET(taosConvInit(), "failed to init conv");
|
||||
ENV_ERR_RET(monitorInit(), "failed to init monitor");
|
||||
ENV_ERR_RET(rpcInit(), "failed to init rpc");
|
||||
|
||||
if (InitRegexCache() != 0) {
|
||||
tscInitRes = -1;
|
||||
|
@ -883,34 +969,26 @@ void taos_init_imp(void) {
|
|||
}
|
||||
|
||||
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
||||
catalogInit(&cfg);
|
||||
ENV_ERR_RET(catalogInit(&cfg), "failed to init catalog");
|
||||
ENV_ERR_RET(schedulerInit(), "failed to init scheduler");
|
||||
|
||||
schedulerInit();
|
||||
tscDebug("starting to initialize TAOS driver");
|
||||
|
||||
#ifndef WINDOWS
|
||||
taosSetCoreDump(true);
|
||||
#endif
|
||||
|
||||
if (initTaskQueue() != 0){
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init task queue");
|
||||
return;
|
||||
}
|
||||
if (fmFuncMgtInit() != TSDB_CODE_SUCCESS) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init function manager");
|
||||
return;
|
||||
}
|
||||
nodesInitAllocatorSet();
|
||||
ENV_ERR_RET(initTaskQueue(), "failed to init task queue");
|
||||
ENV_ERR_RET(fmFuncMgtInit(), "failed to init funcMgt");
|
||||
ENV_ERR_RET(nodesInitAllocatorSet(), "failed to init allocator set");
|
||||
|
||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||
clientReqRefPool = taosOpenRef(40960, doDestroyRequest);
|
||||
|
||||
taosGetAppName(appInfo.appName, NULL);
|
||||
taosThreadMutexInit(&appInfo.mutex, NULL);
|
||||
|
||||
tscCrashReportInit();
|
||||
ENV_ERR_RET(taosGetAppName(appInfo.appName, NULL), "failed to get app name");
|
||||
ENV_ERR_RET(taosThreadMutexInit(&appInfo.mutex, NULL), "failed to init thread mutex");
|
||||
ENV_ERR_RET(tscCrashReportInit(), "failed to init crash report");
|
||||
ENV_ERR_RET(qInitKeywordsTable(), "failed to init parser keywords table");
|
||||
|
||||
tscDebug("client is initialized successfully");
|
||||
}
|
||||
|
@ -957,7 +1035,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
|
|||
return -1;
|
||||
}
|
||||
newstr[0] = '"';
|
||||
memcpy(newstr+1, str, len);
|
||||
(void)memcpy(newstr+1, str, len);
|
||||
newstr[len + 1] = '"';
|
||||
newstr[len + 2] = '\0';
|
||||
str = newstr;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -73,7 +73,7 @@ void jniGetGlobalMethod(JNIEnv *env) {
|
|||
}
|
||||
|
||||
if (g_vm == NULL) {
|
||||
(*env)->GetJavaVM(env, &g_vm);
|
||||
(void)(*env)->GetJavaVM(env, &g_vm);
|
||||
}
|
||||
|
||||
jclass arrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
|
||||
|
@ -582,20 +582,20 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn
|
|||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
case TSDB_DATA_TYPE_GEOMETRY: {
|
||||
memcpy(tmp, row[i], length[i]); // handle the case that terminated does not exist
|
||||
(void)memcpy(tmp, row[i], length[i]); // handle the case that terminated does not exist
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetStringFp, i, (*env)->NewStringUTF(env, tmp));
|
||||
|
||||
memset(tmp, 0, length[i]);
|
||||
(void)memset(tmp, 0, length[i]);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteArrayFp, i,
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_JSON: {
|
||||
(*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteArrayFp, i,
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
jniFromNCharToByteArray(env, (char *)row[i], length[i]));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
|
@ -680,6 +680,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab
|
|||
jsize len = (*env)->GetArrayLength(env, jsql);
|
||||
|
||||
char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1));
|
||||
if (str == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -843,6 +847,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
|
||||
jsize len = (*env)->GetArrayLength(env, tags);
|
||||
char *tagsData = (char *)taosMemoryCalloc(1, len);
|
||||
if (tagsData == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, tags, 0, len, (jbyte *)tagsData);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -850,18 +858,30 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
|
||||
len = (*env)->GetArrayLength(env, lengthList);
|
||||
int32_t *lengthArray = (int32_t *)taosMemoryCalloc(1, len);
|
||||
if (lengthArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, lengthList, 0, len, (jbyte *)lengthArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, typeList);
|
||||
char *typeArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (typeArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, typeList, 0, len, (jbyte *)typeArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, nullList);
|
||||
char *nullArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (nullArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, nullList, 0, len, (jbyte *)nullArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
@ -870,6 +890,10 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
|
|||
char *curTags = tagsData;
|
||||
|
||||
TAOS_MULTI_BIND *tagsBind = taosMemoryCalloc(numOfTags, sizeof(TAOS_MULTI_BIND));
|
||||
if (tagsBind == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tsconn);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < numOfTags; ++i) {
|
||||
tagsBind[i].buffer_type = typeArray[i];
|
||||
tagsBind[i].buffer = curTags;
|
||||
|
@ -916,6 +940,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
|||
// todo refactor
|
||||
jsize len = (*env)->GetArrayLength(env, colDataList);
|
||||
char *colBuf = (char *)taosMemoryCalloc(1, len);
|
||||
if (colBuf == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, colDataList, 0, len, (jbyte *)colBuf);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
// todo handle error
|
||||
|
@ -923,18 +951,30 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp(
|
|||
|
||||
len = (*env)->GetArrayLength(env, lengthList);
|
||||
char *lengthArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (lengthArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, lengthList, 0, len, (jbyte *)lengthArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
len = (*env)->GetArrayLength(env, nullList);
|
||||
char *nullArray = (char *)taosMemoryCalloc(1, len);
|
||||
if (nullArray == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
(*env)->GetByteArrayRegion(env, nullList, 0, len, (jbyte *)nullArray);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
}
|
||||
|
||||
// bind multi-rows with only one invoke.
|
||||
TAOS_MULTI_BIND *b = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND));
|
||||
if (b == NULL) {
|
||||
jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon);
|
||||
return JNI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
b->num = numOfRows;
|
||||
b->buffer_type = dataType; // todo check data type
|
||||
|
@ -1043,14 +1083,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_stmtErrorMsgIm
|
|||
TAOS *tscon = (TAOS *)con;
|
||||
if (tscon == NULL) {
|
||||
jniError("jobj:%p, connection already closed", jobj);
|
||||
sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
||||
(void)sprintf(errMsg, "jobj:%p, connection already closed", jobj);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
TAOS_STMT *pStmt = (TAOS_STMT *)stmt;
|
||||
if (pStmt == NULL) {
|
||||
jniError("jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
(void)sprintf(errMsg, "jobj:%p, conn:%p, invalid stmt", jobj, tscon);
|
||||
return (*env)->NewStringUTF(env, errMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,15 +69,21 @@ void taos_cleanup(void) {
|
|||
qCleanupKeywordsTable();
|
||||
nodesDestroyAllocatorSet();
|
||||
|
||||
cleanupTaskQueue();
|
||||
if (TSDB_CODE_SUCCESS != cleanupTaskQueue()) {
|
||||
tscWarn("failed to cleanup task queue");
|
||||
}
|
||||
|
||||
int32_t id = clientReqRefPool;
|
||||
clientReqRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) {
|
||||
tscWarn("failed to close clientReqRefPool");
|
||||
}
|
||||
|
||||
id = clientConnRefPool;
|
||||
clientConnRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
if (TSDB_CODE_SUCCESS != taosCloseRef(id)) {
|
||||
tscWarn("failed to close clientReqRefPool");
|
||||
}
|
||||
|
||||
DestroyRegexCache();
|
||||
rpcCleanup();
|
||||
|
@ -115,11 +121,19 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
|
|||
pass = TSDB_DEFAULT_PASS;
|
||||
}
|
||||
|
||||
STscObj *pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
|
||||
if (pObj) {
|
||||
STscObj *pObj = NULL;
|
||||
int32_t code = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY, &pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
int64_t *rid = taosMemoryCalloc(1, sizeof(int64_t));
|
||||
if (NULL == rid) {
|
||||
tscError("out of memory when taos connect to %s:%u, user:%s db:%s", ip, port, user, db);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
*rid = pObj->id;
|
||||
return (TAOS *)rid;
|
||||
} else {
|
||||
terrno = code;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -140,24 +154,24 @@ int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type)
|
|||
|
||||
switch (type) {
|
||||
case TAOS_NOTIFY_PASSVER: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->passInfo.fp = fp;
|
||||
pObj->passInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
case TAOS_NOTIFY_WHITELIST_VER: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->whiteListInfo.fp = fp;
|
||||
pObj->whiteListInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
case TAOS_NOTIFY_USER_DROPPED: {
|
||||
taosThreadMutexLock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexLock(&pObj->mutex));
|
||||
pObj->userDroppedInfo.fp = fp;
|
||||
pObj->userDroppedInfo.param = param;
|
||||
taosThreadMutexUnlock(&pObj->mutex);
|
||||
TSC_ERR_RET(taosThreadMutexUnlock(&pObj->mutex));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -189,7 +203,13 @@ int32_t fetchWhiteListCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
}
|
||||
|
||||
SGetUserWhiteListRsp wlRsp;
|
||||
tDeserializeSGetUserWhiteListRsp(pMsg->pData, pMsg->len, &wlRsp);
|
||||
if (TSDB_CODE_SUCCESS != tDeserializeSGetUserWhiteListRsp(pMsg->pData, pMsg->len, &wlRsp)) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFree(pInfo);
|
||||
tFreeSGetUserWhiteListRsp(&wlRsp);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
uint64_t* pWhiteLists = taosMemoryMalloc(wlRsp.numWhiteLists * sizeof(uint64_t));
|
||||
if (pWhiteLists == NULL) {
|
||||
|
@ -229,8 +249,14 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
}
|
||||
|
||||
SGetUserWhiteListReq req;
|
||||
memcpy(req.user, pTsc->user, TSDB_USER_LEN);
|
||||
(void)memcpy(req.user, pTsc->user, TSDB_USER_LEN);
|
||||
int32_t msgLen = tSerializeSGetUserWhiteListReq(NULL, 0, &req);
|
||||
if (msgLen < 0) {
|
||||
fp(param, TSDB_CODE_INVALID_PARA, taos, 0, NULL);
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
}
|
||||
|
||||
void* pReq = taosMemoryMalloc(msgLen);
|
||||
if (pReq == NULL) {
|
||||
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
|
||||
|
@ -274,7 +300,9 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa
|
|||
|
||||
int64_t transportId = 0;
|
||||
SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp);
|
||||
asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo);
|
||||
if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo)) {
|
||||
tscWarn("failed to async send msg to server");
|
||||
}
|
||||
releaseTscObj(connId);
|
||||
return;
|
||||
}
|
||||
|
@ -287,7 +315,7 @@ void taos_close_internal(void *taos) {
|
|||
STscObj *pTscObj = (STscObj *)taos;
|
||||
tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs);
|
||||
|
||||
taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||
(void)taosRemoveRef(clientConnRefPool, pTscObj->id);
|
||||
}
|
||||
|
||||
void taos_close(TAOS *taos) {
|
||||
|
@ -453,6 +481,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
} else {
|
||||
// assert to avoid un-initialization error
|
||||
tscError("invalid result passed to taos_fetch_row");
|
||||
terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +550,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
if(taosAscii2Hex(row[i], charLen, &data, &size) < 0){
|
||||
break;
|
||||
}
|
||||
memcpy(str + len, data, size);
|
||||
(void)memcpy(str + len, data, size);
|
||||
len += size;
|
||||
taosMemoryFree(data);
|
||||
}break;
|
||||
|
@ -539,7 +568,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(str + len, row[i], charLen);
|
||||
(void)memcpy(str + len, row[i], charLen);
|
||||
len += charLen;
|
||||
} break;
|
||||
|
||||
|
@ -686,7 +715,7 @@ int taos_select_db(TAOS *taos, const char *db) {
|
|||
}
|
||||
|
||||
char sql[256] = {0};
|
||||
snprintf(sql, tListLen(sql), "use %s", db);
|
||||
(void)snprintf(sql, tListLen(sql), "use %s", db);
|
||||
|
||||
TAOS_RES *pRequest = taos_query(taos, sql);
|
||||
int32_t code = taos_errno(pRequest);
|
||||
|
@ -742,10 +771,10 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
|||
|
||||
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
doAsyncFetchRows(pRequest, false, true);
|
||||
(void)doAsyncFetchRows(pRequest, false, true);
|
||||
|
||||
// TODO refactor
|
||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||
|
@ -795,10 +824,10 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
|
||||
if (pRequest->type == TSDB_SQL_RETRIEVE_EMPTY_RESULT || pRequest->type == TSDB_SQL_INSERT ||
|
||||
pRequest->code != TSDB_CODE_SUCCESS || taos_num_fields(res) == 0) {
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
doAsyncFetchRows(pRequest, false, false);
|
||||
(void)doAsyncFetchRows(pRequest, false, false);
|
||||
|
||||
SReqResultInfo *pResultInfo = &pRequest->body.resInfo;
|
||||
|
||||
|
@ -806,7 +835,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
(*numOfRows) = pResultInfo->numOfRows;
|
||||
(*pData) = (void *)pResultInfo->pData;
|
||||
|
||||
return 0;
|
||||
return pRequest->code;
|
||||
}
|
||||
|
||||
int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
|
||||
|
@ -864,26 +893,24 @@ const char *taos_get_server_info(TAOS *taos) {
|
|||
int taos_get_current_db(TAOS *taos, char *database, int len, int *required) {
|
||||
STscObj *pTscObj = acquireTscObj(*(int64_t *)taos);
|
||||
if (pTscObj == NULL) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_DISCONNECTED;
|
||||
}
|
||||
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
taosThreadMutexLock(&pTscObj->mutex);
|
||||
(void)taosThreadMutexLock(&pTscObj->mutex);
|
||||
if (database == NULL || len <= 0) {
|
||||
if (required != NULL) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else if (len < strlen(pTscObj->db) + 1) {
|
||||
tstrncpy(database, pTscObj->db, len);
|
||||
if (required) *required = strlen(pTscObj->db) + 1;
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = -1;
|
||||
TSC_ERR_JRET(TSDB_CODE_INVALID_PARA);
|
||||
} else {
|
||||
strcpy(database, pTscObj->db);
|
||||
(void)strcpy(database, pTscObj->db);
|
||||
code = 0;
|
||||
}
|
||||
taosThreadMutexUnlock(&pTscObj->mutex);
|
||||
_return:
|
||||
(void)taosThreadMutexUnlock(&pTscObj->mutex);
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
return code;
|
||||
}
|
||||
|
@ -924,8 +951,8 @@ static void doAsyncQueryFromAnalyse(SMetaData *pResultMeta, void *param, int32_t
|
|||
pRequest->metric.analyseCostUs += taosGetTimestampUs() - analyseStart;
|
||||
|
||||
if (pRequest->parseOnly) {
|
||||
memcpy(&pRequest->parseMeta, pResultMeta, sizeof(*pResultMeta));
|
||||
memset(pResultMeta, 0, sizeof(*pResultMeta));
|
||||
(void)memcpy(&pRequest->parseMeta, pResultMeta, sizeof(*pResultMeta));
|
||||
(void)memset(pResultMeta, 0, sizeof(*pResultMeta));
|
||||
}
|
||||
|
||||
handleQueryAnslyseRes(pWrapper, pResultMeta, code);
|
||||
|
@ -972,10 +999,9 @@ void handleSubQueryFromAnalyse(SSqlCallbackWrapper *pWrapper, SMetaData *pResult
|
|||
return;
|
||||
}
|
||||
|
||||
pNewRequest->pQuery = (SQuery *)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
if (NULL == pNewRequest->pQuery) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
pNewRequest->pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pNewRequest->pQuery);
|
||||
if (pNewRequest->pQuery) {
|
||||
pNewRequest->pQuery->pRoot = pRoot;
|
||||
pRoot = NULL;
|
||||
pNewRequest->pQuery->execStage = QUERY_EXEC_STAGE_ANALYSE;
|
||||
|
@ -1013,10 +1039,12 @@ void handleQueryAnslyseRes(SSqlCallbackWrapper *pWrapper, SMetaData *pResultMeta
|
|||
}
|
||||
|
||||
if (pQuery->haveResultSet) {
|
||||
setResSchemaInfo(&pRequest->body.resInfo, pQuery->pResSchema, pQuery->numOfResCols);
|
||||
code = setResSchemaInfo(&pRequest->body.resInfo, pQuery->pResSchema, pQuery->numOfResCols);
|
||||
setResPrecision(&pRequest->body.resInfo, pQuery->precision);
|
||||
}
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
TSWAP(pRequest->dbList, (pQuery)->pDbList);
|
||||
TSWAP(pRequest->tableList, (pQuery)->pTableList);
|
||||
TSWAP(pRequest->targetTableList, (pQuery)->pTargetTableList);
|
||||
|
@ -1201,7 +1229,7 @@ int32_t prepareAndParseSqlSyntax(SSqlCallbackWrapper **ppWrapper, SRequestObj *p
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
pWrapper->pCatalogReq->forceUpdate = updateMetaForce;
|
||||
pWrapper->pCatalogReq->qNodeRequired = qnodeRequired(pRequest);
|
||||
TSC_ERR_RET(qnodeRequired(pRequest, &pWrapper->pCatalogReq->qNodeRequired));
|
||||
code = qParseSqlSyntax(pWrapper->pParseCtx, &pRequest->pQuery, pWrapper->pCatalogReq);
|
||||
}
|
||||
|
||||
|
@ -1244,7 +1272,7 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
if (NEED_CLIENT_HANDLE_ERROR(code)) {
|
||||
tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64,
|
||||
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
|
||||
refreshMeta(pRequest->pTscObj, pRequest);
|
||||
(void)refreshMeta(pRequest->pTscObj, pRequest); //ignore return code,try again
|
||||
pRequest->prevCode = code;
|
||||
doAsyncQuery(pRequest, true);
|
||||
return;
|
||||
|
@ -1259,13 +1287,13 @@ void doAsyncQuery(SRequestObj *pRequest, bool updateMetaForce) {
|
|||
void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
||||
tscInfo("restart request: %s p: %p", pRequest->sqlstr, pRequest);
|
||||
SRequestObj* pUserReq = pRequest;
|
||||
acquireRequest(pRequest->self);
|
||||
(void)acquireRequest(pRequest->self);
|
||||
while (pUserReq) {
|
||||
if (pUserReq->self == pUserReq->relation.userRefId || pUserReq->relation.userRefId == 0) {
|
||||
break;
|
||||
} else {
|
||||
int64_t nextRefId = pUserReq->relation.nextRefId;
|
||||
releaseRequest(pUserReq->self);
|
||||
(void)releaseRequest(pUserReq->self);
|
||||
if (nextRefId) {
|
||||
pUserReq = acquireRequest(nextRefId);
|
||||
}
|
||||
|
@ -1275,16 +1303,16 @@ void restartAsyncQuery(SRequestObj *pRequest, int32_t code) {
|
|||
if (pUserReq) {
|
||||
destroyCtxInRequest(pUserReq);
|
||||
pUserReq->prevCode = code;
|
||||
memset(&pUserReq->relation, 0, sizeof(pUserReq->relation));
|
||||
(void)memset(&pUserReq->relation, 0, sizeof(pUserReq->relation));
|
||||
} else {
|
||||
tscError("User req is missing");
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
return;
|
||||
}
|
||||
if (hasSubRequest)
|
||||
removeFromMostPrevReq(pRequest);
|
||||
(void)removeFromMostPrevReq(pRequest);
|
||||
else
|
||||
releaseRequest(pUserReq->self);
|
||||
(void)releaseRequest(pUserReq->self);
|
||||
doAsyncQuery(pUserReq, true);
|
||||
}
|
||||
|
||||
|
@ -1374,7 +1402,7 @@ int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInf
|
|||
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
snprintf(dbFName, sizeof(dbFName), "%d.%s", pTscObj->acctId, db);
|
||||
(void)snprintf(dbFName, sizeof(dbFName), "%d.%s", pTscObj->acctId, db);
|
||||
|
||||
code = catalogGetDBVgInfo(pCtg, &conn, dbFName, dbInfo);
|
||||
if (code) {
|
||||
|
@ -1424,7 +1452,7 @@ int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId
|
|||
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
|
||||
|
||||
SName tableName;
|
||||
toName(pTscObj->acctId, db, table, &tableName);
|
||||
(void)toName(pTscObj->acctId, db, table, &tableName);
|
||||
|
||||
SVgroupInfo vgInfo;
|
||||
code = catalogGetTableHashVgroup(pCtg, &conn, &tableName, &vgInfo);
|
||||
|
@ -1545,7 +1573,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
|
|||
}
|
||||
|
||||
SSyncQueryParam *pParam = pRequest->body.interParam;
|
||||
tsem_wait(&pParam->sem);
|
||||
(void)tsem_wait(&pParam->sem);
|
||||
|
||||
_return:
|
||||
destoryCatalogReq(&catalogReq);
|
||||
|
@ -1562,7 +1590,9 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, 0, NULL);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1577,7 +1607,9 @@ TAOS_STMT *taos_stmt_init_with_reqid(TAOS *taos, int64_t reqid) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, reqid, NULL);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1592,7 +1624,9 @@ TAOS_STMT *taos_stmt_init_with_options(TAOS *taos, TAOS_STMT_OPTIONS *options) {
|
|||
}
|
||||
|
||||
TAOS_STMT *pStmt = stmtInit(pObj, options->reqId, options);
|
||||
|
||||
if (NULL == pStmt) {
|
||||
tscError("stmt init failed, errcode:%s", terrstr());
|
||||
}
|
||||
releaseTscObj(*(int64_t *)taos);
|
||||
|
||||
return pStmt;
|
||||
|
@ -1707,7 +1741,11 @@ int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) {
|
|||
}
|
||||
|
||||
int32_t insert = 0;
|
||||
stmtIsInsert(stmt, &insert);
|
||||
int32_t code = stmtIsInsert(stmt, &insert);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("stmt insert failed, errcode:%s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
if (0 == insert && bind->num > 1) {
|
||||
tscError("only one row data allowed for query");
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
@ -1731,7 +1769,11 @@ int taos_stmt_bind_single_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, in
|
|||
}
|
||||
|
||||
int32_t insert = 0;
|
||||
stmtIsInsert(stmt, &insert);
|
||||
int32_t code = stmtIsInsert(stmt, &insert);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tscError("stmt insert failed, errcode:%s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
if (0 == insert && bind->num > 1) {
|
||||
tscError("only one row data allowed for query");
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
|
|
@ -1214,12 +1214,14 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
SArray* pBufArray = NULL;
|
||||
RAW_RETURN_CHECK(serializeVgroupsCreateTableBatch(pVgroupHashmap, &pBufArray));
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_CREATE_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT);
|
||||
code = nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pBufArray));
|
||||
|
@ -1343,13 +1345,14 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
}
|
||||
SArray* pBufArray = NULL;
|
||||
RAW_RETURN_CHECK(serializeVgroupsDropTableBatch(pVgroupHashmap, &pBufArray));
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_DROP_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT);
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
pQuery->pRoot = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pBufArray));
|
||||
|
||||
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
|
||||
|
@ -1486,13 +1489,15 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
pVgData->numOfTables = 1;
|
||||
RAW_NULL_CHECK(taosArrayPush(pArray, &pVgData));
|
||||
|
||||
pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
RAW_NULL_CHECK(pQuery);
|
||||
pQuery = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (NULL == pQuery) goto end;
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->msgType = TDMT_VND_ALTER_TABLE;
|
||||
pQuery->stableQuery = false;
|
||||
pQuery->pRoot = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||
RAW_NULL_CHECK(pQuery->pRoot);
|
||||
pQuery->pRoot = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS != code) goto end;
|
||||
RAW_RETURN_CHECK(rewriteToVnodeModifyOpStmt(pQuery, pArray));
|
||||
|
||||
|
||||
|
@ -1537,8 +1542,8 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pDat
|
|||
SQuery* pQuery = NULL;
|
||||
SHashObj* pVgHash = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw block with field, rows:%d, pData:%p, tbname:%s, fields:%p, numFields:%d", LOG_ID_VALUE,
|
||||
rows, pData, tbname, fields, numFields);
|
||||
|
@ -1597,8 +1602,8 @@ int taos_write_raw_block_with_reqid(TAOS* taos, int rows, char* pData, const cha
|
|||
SQuery* pQuery = NULL;
|
||||
SHashObj* pVgHash = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, reqid, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw block, rows:%d, pData:%p, tbname:%s", LOG_ID_VALUE, rows, pData, tbname);
|
||||
|
||||
|
@ -1667,8 +1672,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
SDecoder decoder = {0};
|
||||
STableMeta* pTableMeta = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw data, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
|
@ -1778,8 +1783,8 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
STableMeta* pTableMeta = NULL;
|
||||
SVCreateTbReq* pCreateReqDst = NULL;
|
||||
|
||||
SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0);
|
||||
RAW_NULL_CHECK(pRequest);
|
||||
SRequestObj* pRequest = NULL;
|
||||
RAW_RETURN_CHECK(createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0, &pRequest));
|
||||
|
||||
uDebug(LOG_ID_TAG " write raw metadata, data:%p, dataLen:%d", LOG_ID_VALUE, data, dataLen);
|
||||
pRequest->syncQuery = true;
|
||||
|
|
|
@ -2137,8 +2137,8 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
|
|||
SSmlHandle *info = NULL;
|
||||
int cnt = 0;
|
||||
while (1) {
|
||||
request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid);
|
||||
if (request == NULL) {
|
||||
code = createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid, &request);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1237,8 +1237,9 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
|
|||
}
|
||||
|
||||
// init connection
|
||||
pTmq->pTscObj = taos_connect_internal(conf->ip, user, pass, NULL, NULL, conf->port, CONN_TYPE__TMQ);
|
||||
if (pTmq->pTscObj == NULL) {
|
||||
code = taos_connect_internal(conf->ip, user, pass, NULL, NULL, conf->port, CONN_TYPE__TMQ, &pTmq->pTscObj);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId);
|
||||
(void)tsem2_destroy(&pTmq->rspSem);
|
||||
SET_ERROR_MSG_TMQ("init tscObj failed")
|
||||
|
|
|
@ -1354,8 +1354,9 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
|||
}
|
||||
|
||||
static int32_t taosCheckGlobalCfg() {
|
||||
uint32_t ipv4 = taosGetIpv4FromFqdn(tsLocalFqdn);
|
||||
if (ipv4 == 0xffffffff) {
|
||||
uint32_t ipv4 = 0;
|
||||
int32_t code = taosGetIpv4FromFqdn(tsLocalFqdn, &ipv4);
|
||||
if (code) {
|
||||
terrno = TSDB_CODE_RPC_FQDN_ERROR;
|
||||
uError("failed to get ip from fqdn:%s since %s, dnode can not be initialized", tsLocalFqdn, terrstr());
|
||||
return -1;
|
||||
|
|
|
@ -12763,7 +12763,7 @@ int32_t tCloneTbTSMAInfo(STableTSMAInfo *pInfo, STableTSMAInfo **pRes) {
|
|||
if (!pRet->ast) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (code) {
|
||||
tFreeTableTSMAInfo(pRet);
|
||||
tFreeAndClearTableTSMAInfo(pRet);
|
||||
pRet = NULL;
|
||||
}
|
||||
*pRes = pRet;
|
||||
|
|
|
@ -138,7 +138,7 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa
|
|||
int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode) {
|
||||
switch (bitmapMode) {
|
||||
case 0:
|
||||
tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
||||
(void)tdGetBitmapValTypeII(pBitmap, colIdx, pValType);
|
||||
break;
|
||||
#if 0
|
||||
case -1:
|
||||
|
@ -354,8 +354,8 @@ bool tdSKvRowGetVal(STSRow *pRow, col_id_t colId, col_id_t colIdx, SCellVal *pVa
|
|||
}
|
||||
|
||||
void *pBitmap = tdGetBitmapAddrKv(pRow, tdRowGetNCols(pRow));
|
||||
tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset,
|
||||
POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx));
|
||||
(void)tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset,
|
||||
POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ bool tdSTpRowGetVal(STSRow *pRow, col_id_t colId, col_type_t colType, int32_t fl
|
|||
return true;
|
||||
}
|
||||
void *pBitmap = tdGetBitmapAddrTp(pRow, flen);
|
||||
tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset, colIdx);
|
||||
(void)tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset, colIdx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -385,9 +385,9 @@ bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal) {
|
|||
}
|
||||
|
||||
if (TD_IS_TP_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
(void)tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetKvVal(pIter, pCol->colId, &pIter->kvIdx, pVal);
|
||||
(void)tdSTSRowIterGetKvVal(pIter, pCol->colId, &pIter->kvIdx, pVal);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -486,8 +486,8 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
|
||||
SRowBuilder rb = {.rowType = rowType};
|
||||
tdSRowInit(&rb, pTSchema->version);
|
||||
tdSRowSetInfo(&rb, pTSchema->numOfCols, nBound, pTSchema->flen);
|
||||
tdSRowResetBuf(&rb, *ppRow);
|
||||
(void)tdSRowSetInfo(&rb, pTSchema->numOfCols, nBound, pTSchema->flen);
|
||||
(void)tdSRowResetBuf(&rb, *ppRow);
|
||||
int32_t iBound = 0;
|
||||
|
||||
iColVal = 0;
|
||||
|
@ -506,7 +506,7 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow, int8_t r
|
|||
} else if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
varDataSetLen(varBuf, pColVal->value.nData);
|
||||
if (pColVal->value.nData != 0) {
|
||||
memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
(void)memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
}
|
||||
val = varBuf;
|
||||
++iBound;
|
||||
|
@ -578,7 +578,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
#ifdef TD_SUPPORT_BITMAP
|
||||
colIdx = POINTER_DISTANCE(pCol, pSchema->columns) / sizeof(STColumn);
|
||||
#endif
|
||||
tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset, colIdx - 1);
|
||||
(void)tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset, colIdx - 1);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
SKvRowIdx *pIdx = (SKvRowIdx *)taosbsearch(&colId, TD_ROW_COL_IDX(pRow), tdRowGetNCols(pRow), sizeof(SKvRowIdx),
|
||||
compareKvRowColId, TD_EQ);
|
||||
|
@ -587,7 +587,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
colIdx = POINTER_DISTANCE(pIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx);
|
||||
}
|
||||
#endif
|
||||
tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
||||
(void)tdGetKvRowValOfCol(pVal, pRow, pIter->pBitmap, pIdx ? pIdx->offset : -1, colIdx);
|
||||
} else {
|
||||
if (COL_REACH_END(colId, pIter->maxColId)) return false;
|
||||
pVal->valType = TD_VTYPE_NONE;
|
||||
|
@ -689,9 +689,9 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
|
|||
}
|
||||
|
||||
if (TD_IS_TP_ROW(pRow)) {
|
||||
tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset);
|
||||
(void)tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset);
|
||||
} else {
|
||||
tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId);
|
||||
(void)tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId);
|
||||
}
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -718,11 +718,11 @@ int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
|
|||
char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row));
|
||||
if (IS_VAR_DATA_TYPE(colType)) {
|
||||
if (isCopyVarData) {
|
||||
memcpy(ptr, val, varDataTLen(val));
|
||||
(void)memcpy(ptr, val, varDataTLen(val));
|
||||
}
|
||||
TD_ROW_LEN(row) += varDataTLen(val);
|
||||
} else {
|
||||
memcpy(ptr, val, TYPE_BYTES[colType]);
|
||||
(void)memcpy(ptr, val, TYPE_BYTES[colType]);
|
||||
TD_ROW_LEN(row) += TYPE_BYTES[colType];
|
||||
}
|
||||
}
|
||||
|
@ -752,11 +752,11 @@ int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
|
|||
// ts key stored in STSRow.ts
|
||||
*(VarDataOffsetT *)POINTER_SHIFT(TD_ROW_DATA(row), offset) = TD_ROW_LEN(row);
|
||||
if (isCopyVarData) {
|
||||
memcpy(POINTER_SHIFT(row, TD_ROW_LEN(row)), val, varDataTLen(val));
|
||||
(void)memcpy(POINTER_SHIFT(row, TD_ROW_LEN(row)), val, varDataTLen(val));
|
||||
}
|
||||
TD_ROW_LEN(row) += varDataTLen(val);
|
||||
} else {
|
||||
memcpy(POINTER_SHIFT(TD_ROW_DATA(row), offset), val, TYPE_BYTES[colType]);
|
||||
(void)memcpy(POINTER_SHIFT(TD_ROW_DATA(row), offset), val, TYPE_BYTES[colType]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,7 +782,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
case TD_ROW_TP:
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
pBuilder->pBitmap = tdGetBitmapAddrTp(pBuilder->pBuf, pBuilder->flen);
|
||||
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
|
||||
(void)memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
|
||||
#endif
|
||||
// the primary TS key is stored separatedly
|
||||
len = TD_ROW_HEAD_LEN + pBuilder->flen + pBuilder->nBitmaps;
|
||||
|
@ -792,7 +792,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
case TD_ROW_KV:
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
pBuilder->pBitmap = tdGetBitmapAddrKv(pBuilder->pBuf, pBuilder->nBoundCols);
|
||||
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBoundBitmaps);
|
||||
(void)memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBoundBitmaps);
|
||||
#endif
|
||||
len = TD_ROW_HEAD_LEN + TD_ROW_NCOLS_LEN + (pBuilder->nBoundCols - 1) * sizeof(SKvRowIdx) +
|
||||
pBuilder->nBoundBitmaps; // add
|
||||
|
@ -937,9 +937,9 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
ASSERT((pTColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) || (iCol > 0));
|
||||
|
||||
if (TD_IS_TP_ROW(pRow)) {
|
||||
tdSTpRowGetVal(pRow, pTColumn->colId, pTColumn->type, pTSchema->flen, pTColumn->offset, iCol - 1, &cv);
|
||||
(void)tdSTpRowGetVal(pRow, pTColumn->colId, pTColumn->type, pTSchema->flen, pTColumn->offset, iCol - 1, &cv);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
tdSKvRowGetVal(pRow, pTColumn->colId, iCol - 1, &cv);
|
||||
(void)tdSKvRowGetVal(pRow, pTColumn->colId, iCol - 1, &cv);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
pColVal->value.nData = varDataLen(cv.val);
|
||||
pColVal->value.pData = varDataVal(cv.val);
|
||||
} else {
|
||||
memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
|
||||
(void)memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -298,12 +298,7 @@ void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma) {
|
|||
sdbRelease(pSdb, pSma);
|
||||
}
|
||||
|
||||
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *smaName) {
|
||||
SName name = {0};
|
||||
tNameFromString(&name, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(&name, db);
|
||||
SDbObj *mndAcquireDbBySma(SMnode *pMnode, const char *db) {
|
||||
|
||||
return mndAcquireDb(pMnode, db);
|
||||
}
|
||||
|
@ -312,7 +307,10 @@ static void *mndBuildVCreateSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSm
|
|||
SEncoder encoder = {0};
|
||||
int32_t contLen = 0;
|
||||
SName name = {0};
|
||||
tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SVCreateTSmaReq req = {0};
|
||||
req.version = 0;
|
||||
|
@ -370,7 +368,7 @@ static void *mndBuildVDropSmaReq(SMnode *pMnode, SVgObj *pVgroup, SSmaObj *pSma,
|
|||
SEncoder encoder = {0};
|
||||
int32_t contLen;
|
||||
SName name = {0};
|
||||
tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
(void)tNameFromString(&name, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
|
||||
SVDropTSmaReq req = {0};
|
||||
req.indexUid = pSma->uid;
|
||||
|
@ -782,10 +780,14 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static void mndGetStreamNameFromSmaName(char *streamName, char *smaName) {
|
||||
static int32_t mndGetStreamNameFromSmaName(char *streamName, char *smaName) {
|
||||
SName n;
|
||||
tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
sprintf(streamName, "%d.%s", n.acctId, n.tname);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
||||
|
@ -817,7 +819,10 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
mndGetStreamNameFromSmaName(streamName, createReq.name);
|
||||
code = mndGetStreamNameFromSmaName(streamName, createReq.name);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||
if (pStream != NULL || code == 0) {
|
||||
|
@ -843,7 +848,15 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
pDb = mndAcquireDbBySma(pMnode, createReq.name);
|
||||
SName name = {0};
|
||||
code = tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, db);
|
||||
if (pDb == NULL) {
|
||||
code = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
goto _OVER;
|
||||
|
@ -964,6 +977,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
SVgObj *pVgroup = NULL;
|
||||
SStbObj *pStb = NULL;
|
||||
STrans *pTrans = NULL;
|
||||
SStreamObj *pStream = NULL;
|
||||
|
||||
pVgroup = mndAcquireVgroup(pMnode, pSma->dstVgId);
|
||||
if (pVgroup == NULL) {
|
||||
|
@ -993,9 +1007,11 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
|
|||
mndTransSetSerial(pTrans);
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
mndGetStreamNameFromSmaName(streamName, pSma->name);
|
||||
code = mndGetStreamNameFromSmaName(streamName, pSma->name);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SStreamObj *pStream = NULL;
|
||||
|
||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||
if (pStream == NULL || pStream->smaId != pSma->uid || code != 0) {
|
||||
|
@ -1054,7 +1070,10 @@ int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *p
|
|||
}
|
||||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
mndGetStreamNameFromSmaName(streamName, pSma->name);
|
||||
code = mndGetStreamNameFromSmaName(streamName, pSma->name);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SStreamObj *pStream = NULL;
|
||||
code = mndAcquireStream(pMnode, streamName, &pStream);
|
||||
|
@ -1144,7 +1163,15 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
pDb = mndAcquireDbBySma(pMnode, dropReq.name);
|
||||
SName name = {0};
|
||||
code = tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, db);
|
||||
if (pDb == NULL) {
|
||||
code = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
goto _OVER;
|
||||
|
@ -1303,7 +1330,11 @@ static int32_t mndProcessGetSmaReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSUserIndexRsp(pRsp, contLen, &rsp);
|
||||
contLen = tSerializeSUserIndexRsp(pRsp, contLen, &rsp);
|
||||
if (contLen < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -1349,7 +1380,11 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeSTableIndexRsp(pRsp, contLen, &rsp);
|
||||
contLen = tSerializeSTableIndexRsp(pRsp, contLen, &rsp);
|
||||
if (contLen < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -1372,6 +1407,7 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
int32_t numOfRows = 0;
|
||||
SSmaObj *pSma = NULL;
|
||||
int32_t cols = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
SDbObj *pDb = NULL;
|
||||
if (strlen(pShow->db) > 0) {
|
||||
|
@ -1391,47 +1427,63 @@ static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
|
|||
cols = 0;
|
||||
|
||||
SName smaName = {0};
|
||||
tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(n1, (char *)tNameGetTableName(&smaName));
|
||||
|
||||
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
|
||||
|
||||
SName stbName = {0};
|
||||
tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char n2[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char n3[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName));
|
||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char n1[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(n1, (char *)tNameGetTableName(&smaName));
|
||||
STR_TO_VARSTR(n2, (char *)mndGetDbStr(pSma->db));
|
||||
code = tNameFromString(&stbName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
}
|
||||
SColumnInfoData* pColInfo = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(n3, (char *)tNameGetTableName(&stbName));
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)n1, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)n2, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)n3, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pSma->dstVgId, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pSma->createdTime, false);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)n1, false);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)n2, false);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)n3, false);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pSma->dstVgId, false);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pSma->createdTime, false);
|
||||
}
|
||||
|
||||
char col[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(col, (char *)"");
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)col, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)col, false);
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
||||
char tag[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(tag, (char *)"sma_index");
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)tag, false);
|
||||
char tag[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(tag, (char *)"sma_index");
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)tag, false);
|
||||
}
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pSma);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
sdbCancelFetch(pMnode->pSdb, pIter->pSmaIter);
|
||||
numOfRows = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
|
@ -1520,7 +1572,7 @@ static void initStreamObj(SStreamObj *pStream, const char *streamName, const SMC
|
|||
pStream->ast = taosStrdup(pSma->ast);
|
||||
}
|
||||
|
||||
static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
||||
static int32_t mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
||||
tstrncpy(pCxt->pCreateStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN);
|
||||
tstrncpy(pCxt->pCreateStreamReq->sourceDB, pCxt->pDb->name, TSDB_DB_FNAME_LEN);
|
||||
tstrncpy(pCxt->pCreateStreamReq->targetStbFullName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN);
|
||||
|
@ -1540,11 +1592,21 @@ static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
|||
pCxt->pCreateStreamReq->lastTs = pCxt->pCreateSmaReq->lastTs;
|
||||
pCxt->pCreateStreamReq->smaId = pCxt->pSma->uid;
|
||||
pCxt->pCreateStreamReq->ast = taosStrdup(pCxt->pCreateSmaReq->ast);
|
||||
if (!pCxt->pCreateStreamReq->ast) {
|
||||
return terrno;
|
||||
}
|
||||
pCxt->pCreateStreamReq->sql = taosStrdup(pCxt->pCreateSmaReq->sql);
|
||||
if (!pCxt->pCreateStreamReq->sql) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
// construct tags
|
||||
pCxt->pCreateStreamReq->pTags = taosArrayInit(pCxt->pCreateStreamReq->numOfTags, sizeof(SField));
|
||||
if (!pCxt->pCreateStreamReq->pTags) {
|
||||
return terrno;
|
||||
}
|
||||
SField f = {0};
|
||||
int32_t code = 0;
|
||||
if (pCxt->pSrcStb) {
|
||||
for (int32_t idx = 0; idx < pCxt->pCreateStreamReq->numOfTags - 1; ++idx) {
|
||||
SSchema *pSchema = &pCxt->pSrcStb->pTags[idx];
|
||||
|
@ -1552,25 +1614,39 @@ static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) {
|
|||
f.type = pSchema->type;
|
||||
f.flags = pSchema->flags;
|
||||
tstrncpy(f.name, pSchema->name, TSDB_COL_NAME_LEN);
|
||||
taosArrayPush(pCxt->pCreateStreamReq->pTags, &f);
|
||||
if (NULL == taosArrayPush(pCxt->pCreateStreamReq->pTags, &f)) {
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
f.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||
f.flags = COL_SMA_ON;
|
||||
f.type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(f.name, "tbname", strlen("tbname") + 1);
|
||||
taosArrayPush(pCxt->pCreateStreamReq->pTags, &f);
|
||||
|
||||
// construct output cols
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pCxt->pProjects) {
|
||||
SExprNode* pExprNode = (SExprNode*)pNode;
|
||||
f.bytes = pExprNode->resType.bytes;
|
||||
f.type = pExprNode->resType.type;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
f.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE;
|
||||
f.flags = COL_SMA_ON;
|
||||
strcpy(f.name, pExprNode->userAlias);
|
||||
taosArrayPush(pCxt->pCreateStreamReq->pCols, &f);
|
||||
f.type = TSDB_DATA_TYPE_BINARY;
|
||||
tstrncpy(f.name, "tbname", strlen("tbname") + 1);
|
||||
if (NULL == taosArrayPush(pCxt->pCreateStreamReq->pTags, &f)) {
|
||||
code = terrno;
|
||||
}
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// construct output cols
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pCxt->pProjects) {
|
||||
SExprNode* pExprNode = (SExprNode*)pNode;
|
||||
f.bytes = pExprNode->resType.bytes;
|
||||
f.type = pExprNode->resType.type;
|
||||
f.flags = COL_SMA_ON;
|
||||
strcpy(f.name, pExprNode->userAlias);
|
||||
if (NULL == taosArrayPush(pCxt->pCreateStreamReq->pCols, &f)) {
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static void mndCreateTSMABuildDropStreamReq(SCreateTSMACxt* pCxt) {
|
||||
|
@ -1733,7 +1809,10 @@ static int32_t mndCreateTSMA(SCreateTSMACxt *pCxt) {
|
|||
}
|
||||
}
|
||||
pCxt->pDropStreamReq = &dropStreamReq;
|
||||
mndCreateTSMABuildCreateStreamReq(pCxt);
|
||||
code = mndCreateTSMABuildCreateStreamReq(pCxt);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
mndCreateTSMABuildDropStreamReq(pCxt);
|
||||
|
||||
if (TSDB_CODE_SUCCESS != (code = mndCreateTSMATxnPrepare(pCxt))) {
|
||||
|
@ -1753,11 +1832,15 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
static void mndTSMAGenerateOutputName(const char* tsmaName, char* streamName, char* targetStbName) {
|
||||
static int32_t mndTSMAGenerateOutputName(const char* tsmaName, char* streamName, char* targetStbName) {
|
||||
SName smaName;
|
||||
tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
int32_t code = tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname);
|
||||
snprintf(targetStbName, TSDB_TABLE_FNAME_LEN, "%s"TSMA_RES_STB_POSTFIX, tsmaName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
||||
|
@ -1799,7 +1882,11 @@ static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
|||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
mndTSMAGenerateOutputName(createReq.name, streamName, streamTargetStbFullName);
|
||||
code = mndTSMAGenerateOutputName(createReq.name, streamName, streamTargetStbFullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
mInfo("tsma:%s, faield to generate name", createReq.name);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pSma = sdbAcquire(pMnode->pSdb, SDB_SMA, createReq.name);
|
||||
if (pSma && createReq.igExists) {
|
||||
|
@ -1828,7 +1915,15 @@ static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
pDb = mndAcquireDbBySma(pMnode, createReq.name);
|
||||
SName name = {0};
|
||||
code = tNameFromString(&name, createReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, db);
|
||||
if (pDb == NULL) {
|
||||
code = TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||
goto _OVER;
|
||||
|
@ -1978,7 +2073,10 @@ static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
|||
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName);
|
||||
code = mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
SStbObj* pStb = mndAcquireStb(pMnode, streamTargetStbFullName);
|
||||
|
||||
|
@ -1991,7 +2089,15 @@ static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) {
|
|||
code = TSDB_CODE_MND_SMA_NOT_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
pDb = mndAcquireDbBySma(pMnode, dropReq.name);
|
||||
SName name = {0};
|
||||
code = tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _OVER;
|
||||
}
|
||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
(void)tNameGetFullDbName(&name, db);
|
||||
|
||||
pDb = mndAcquireDb(pMnode, db);
|
||||
if (!pDb) {
|
||||
code = TSDB_CODE_MND_DB_NOT_EXIST;
|
||||
goto _OVER;
|
||||
|
@ -2032,6 +2138,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
int32_t numOfRows = 0;
|
||||
SSmaObj * pSma = NULL;
|
||||
SMnode * pMnode = pReq->info.node;
|
||||
int32_t code = 0;
|
||||
SColumnInfoData *pColInfo;
|
||||
if (pShow->db[0]) {
|
||||
pDb = mndAcquireDb(pMnode, pShow->db);
|
||||
|
@ -2054,65 +2161,90 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
int32_t cols = 0;
|
||||
SName n = {0};
|
||||
|
||||
tNameFromString(&n, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&n, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char smaName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(smaName, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)smaName, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(smaName, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)smaName, false);
|
||||
}
|
||||
|
||||
char db[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
}
|
||||
|
||||
tNameFromString(&n, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tNameFromString(&n, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
}
|
||||
char srcTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)srcTb, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)srcTb, false);
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)db, false);
|
||||
}
|
||||
|
||||
tNameFromString(&n, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(targetTb, (char*)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)targetTb, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tNameFromString(&n, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
}
|
||||
|
||||
// stream name
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)smaName, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(targetTb, (char*)tNameGetTableName(&n));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)targetTb, false);
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char*)(&pSma->createdTime), false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// stream name
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)smaName, false);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char*)(&pSma->createdTime), false);
|
||||
}
|
||||
|
||||
// interval
|
||||
char interval[64 + VARSTR_HEADER_SIZE] = {0};
|
||||
int32_t len = 0;
|
||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||
} else {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!IS_CALENDAR_TIME_DURATION(pSma->intervalUnit)) {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval,
|
||||
getPrecisionUnit(pSrcDb->cfg.precision));
|
||||
} else {
|
||||
len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, pSma->intervalUnit);
|
||||
}
|
||||
varDataSetLen(interval, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, interval, false);
|
||||
}
|
||||
varDataSetLen(interval, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, interval, false);
|
||||
|
||||
// create sql
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
char buf[TSDB_MAX_SAVED_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// create sql
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
}
|
||||
|
||||
// func list
|
||||
len = 0;
|
||||
char * start = buf + VARSTR_HEADER_SIZE;
|
||||
SNode *pNode = NULL, *pFunc = NULL;
|
||||
nodesStringToNode(pSma->ast, &pNode);
|
||||
if (pNode) {
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesStringToNode(pSma->ast, &pNode);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char * start = buf + VARSTR_HEADER_SIZE;
|
||||
FOREACH(pFunc, ((SSelectStmt *)pNode)->pProjectionList) {
|
||||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||
|
@ -2128,13 +2260,21 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
}
|
||||
nodesDestroyNode(pNode);
|
||||
}
|
||||
varDataSetLen(buf, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
varDataSetLen(buf, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
code = colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
}
|
||||
|
||||
numOfRows++;
|
||||
mndReleaseSma(pMnode, pSma);
|
||||
mndReleaseDb(pMnode, pSrcDb);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
sdbCancelFetch(pMnode->pSdb, pIter->pSmaIter);
|
||||
numOfRows = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
pShow->numOfRows += numOfRows;
|
||||
|
@ -2163,13 +2303,22 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
pInfo->tsmaId = pSma->uid;
|
||||
pInfo->destTbUid = pDestStb->uid;
|
||||
SName sName = {0};
|
||||
tNameFromString(&sName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&sName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
tstrncpy(pInfo->name, sName.tname, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pInfo->targetDbFName, pSma->db, TSDB_DB_FNAME_LEN);
|
||||
tNameFromString(&sName, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&sName, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
tstrncpy(pInfo->targetTb, sName.tname, TSDB_TABLE_NAME_LEN);
|
||||
tstrncpy(pInfo->dbFName, pSma->db, TSDB_DB_FNAME_LEN);
|
||||
tNameFromString(&sName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&sName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
tstrncpy(pInfo->tb, sName.tname, TSDB_TABLE_NAME_LEN);
|
||||
pInfo->pFuncs = taosArrayInit(8, sizeof(STableTSMAFuncInfo));
|
||||
if (!pInfo->pFuncs) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -2206,7 +2355,10 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
for (int32_t i = 0; i < pDestStb->numOfTags; ++i) {
|
||||
taosArrayPush(pInfo->pTags, &pDestStb->pTags[i]);
|
||||
if (NULL == taosArrayPush(pInfo->pTags, &pDestStb->pTags[i])) {
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2217,7 +2369,10 @@ int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STa
|
|||
else {
|
||||
// skip _wstart, _wend, _duration
|
||||
for (int32_t i = 1; i < pDestStb->numOfColumns - 2; ++i) {
|
||||
taosArrayPush(pInfo->pUsedCols, &pDestStb->pColumns[i]);
|
||||
if (NULL == taosArrayPush(pInfo->pUsedCols, &pDestStb->pColumns[i])) {
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2280,12 +2435,12 @@ static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rs
|
|||
sdbRelease(pMnode->pSdb, pSma);
|
||||
if (pBaseTsma) mndReleaseSma(pMnode, pBaseTsma);
|
||||
if (terrno) {
|
||||
tFreeTableTSMAInfo(pTsma);
|
||||
tFreeAndClearTableTSMAInfo(pTsma);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (NULL == taosArrayPush(rsp->pTsmas, &pTsma)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeTableTSMAInfo(pTsma);
|
||||
tFreeAndClearTableTSMAInfo(pTsma);
|
||||
}
|
||||
*exist = true;
|
||||
}
|
||||
|
@ -2320,7 +2475,11 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
|||
|
||||
SName smaName;
|
||||
char streamName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
sdbRelease(pSdb, pSma);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname);
|
||||
pStream = NULL;
|
||||
|
||||
|
@ -2351,13 +2510,13 @@ static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilt
|
|||
sdbRelease(pSdb, pSma);
|
||||
if (pBaseTsma) mndReleaseSma(pMnode, pBaseTsma);
|
||||
if (terrno) {
|
||||
tFreeTableTSMAInfo(pTsma);
|
||||
tFreeAndClearTableTSMAInfo(pTsma);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
if (NULL == taosArrayPush(pRsp->pTsmas, &pTsma)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
tFreeTableTSMAInfo(pTsma);
|
||||
tFreeAndClearTableTSMAInfo(pTsma);
|
||||
sdbCancelFetch(pSdb, pIter);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -2418,7 +2577,11 @@ static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeTableTSMAInfoRsp(pRsp, contLen, &rsp);
|
||||
int32_t len = tSerializeTableTSMAInfoRsp(pRsp, contLen, &rsp);
|
||||
if (len < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pReq->info.rsp = pRsp;
|
||||
pReq->info.rspLen = contLen;
|
||||
|
@ -2434,7 +2597,7 @@ _OVER:
|
|||
static int32_t mkNonExistTSMAInfo(const STSMAVersion *pTsmaVer, STableTSMAInfo **ppTsma) {
|
||||
STableTSMAInfo *pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo));
|
||||
if (!pInfo) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
pInfo->pFuncs = NULL;
|
||||
pInfo->tsmaId = pTsmaVer->tsmaId;
|
||||
|
@ -2443,6 +2606,10 @@ static int32_t mkNonExistTSMAInfo(const STSMAVersion *pTsmaVer, STableTSMAInfo *
|
|||
tstrncpy(pInfo->name, pTsmaVer->name, TSDB_TABLE_NAME_LEN);
|
||||
pInfo->dbId = pTsmaVer->dbId;
|
||||
pInfo->ast = taosMemoryCalloc(1, 1);
|
||||
if (!pInfo->ast) {
|
||||
taosMemoryFree(pInfo);
|
||||
return terrno;
|
||||
}
|
||||
*ppTsma = pInfo;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -2458,7 +2625,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
|
||||
hbRsp.pTsmas = taosArrayInit(numOfTsmas, POINTER_BYTES);
|
||||
if (!hbRsp.pTsmas) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
@ -2473,7 +2640,11 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
if (!pSma) {
|
||||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||
if (code) goto _OVER;
|
||||
taosArrayPush(hbRsp.pTsmas, &pTsmaInfo);
|
||||
if (NULL == taosArrayPush(hbRsp.pTsmas, &pTsmaInfo)) {
|
||||
code = terrno;
|
||||
tFreeAndClearTableTSMAInfo(pTsmaInfo);
|
||||
goto _OVER;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2482,7 +2653,11 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||
mndReleaseSma(pMnode, pSma);
|
||||
if (code) goto _OVER;
|
||||
taosArrayPush(hbRsp.pTsmas, &pTsmaInfo);
|
||||
if (NULL == taosArrayPush(hbRsp.pTsmas, &pTsmaInfo)) {
|
||||
code = terrno;
|
||||
tFreeAndClearTableTSMAInfo(pTsmaInfo);
|
||||
goto _OVER;
|
||||
}
|
||||
continue;
|
||||
} else if (pSma->version == pTsmaVer->version) {
|
||||
mndReleaseSma(pMnode, pSma);
|
||||
|
@ -2495,7 +2670,11 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
code = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo);
|
||||
mndReleaseSma(pMnode, pSma);
|
||||
if (code) goto _OVER;
|
||||
taosArrayPush(hbRsp.pTsmas, &pTsmaInfo);
|
||||
if (NULL == taosArrayPush(hbRsp.pTsmas, &pTsmaInfo)) {
|
||||
code = terrno;
|
||||
tFreeAndClearTableTSMAInfo(pTsmaInfo);
|
||||
goto _OVER;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2503,7 +2682,7 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
STableTSMAInfo * pInfo = NULL;
|
||||
pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo));
|
||||
if (!pInfo) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
mndReleaseSma(pMnode, pSma);
|
||||
mndReleaseStb(pMnode, pDestStb);
|
||||
goto _OVER;
|
||||
|
@ -2517,27 +2696,35 @@ int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t
|
|||
mndReleaseSma(pMnode, pSma);
|
||||
if (pBaseSma) mndReleaseSma(pMnode, pBaseSma);
|
||||
if (terrno) {
|
||||
tFreeTableTSMAInfo(pInfo);
|
||||
tFreeAndClearTableTSMAInfo(pInfo);
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
taosArrayPush(hbRsp.pTsmas, pInfo);
|
||||
if (NULL == taosArrayPush(hbRsp.pTsmas, pInfo)) {
|
||||
code = terrno;
|
||||
tFreeAndClearTableTSMAInfo(pInfo);
|
||||
goto _OVER;
|
||||
}
|
||||
}
|
||||
|
||||
rspLen = tSerializeTSMAHbRsp(NULL, 0, &hbRsp);
|
||||
if (rspLen < 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
pRsp = taosMemoryMalloc(rspLen);
|
||||
if (!pRsp) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
rspLen = 0;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
tSerializeTSMAHbRsp(pRsp, rspLen, &hbRsp);
|
||||
rspLen = tSerializeTSMAHbRsp(pRsp, rspLen, &hbRsp);
|
||||
if (rspLen < 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
code = 0;
|
||||
_OVER:
|
||||
tFreeTSMAHbRsp(&hbRsp);
|
||||
|
|
|
@ -142,12 +142,12 @@ static int32_t ipWhiteMgtInit() {
|
|||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
ipWhiteMgt.ver = 0;
|
||||
taosThreadRwlockInit(&ipWhiteMgt.rw, NULL);
|
||||
(void)taosThreadRwlockInit(&ipWhiteMgt.rw, NULL);
|
||||
TAOS_RETURN(0);
|
||||
}
|
||||
void ipWhiteMgtCleanup() {
|
||||
destroyIpWhiteTab(ipWhiteMgt.pIpWhiteTab);
|
||||
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
||||
}
|
||||
|
||||
int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
||||
|
@ -155,7 +155,7 @@ int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
|||
int32_t lino = 0;
|
||||
bool update = true;
|
||||
SArray *fqdns = NULL;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
|
||||
if (ppList == NULL || *ppList == NULL) {
|
||||
|
@ -212,7 +212,7 @@ int32_t ipWhiteMgtUpdate(SMnode *pMnode, char *user, SIpWhiteList *pNew) {
|
|||
if (update) ipWhiteMgt.ver++;
|
||||
|
||||
_OVER:
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
taosArrayDestroyP(fqdns, (FDelete)taosMemoryFree);
|
||||
if (code < 0) {
|
||||
mError("failed to update ip white list for user: %s at line %d since %s", user, lino, tstrerror(code));
|
||||
|
@ -221,17 +221,17 @@ _OVER:
|
|||
}
|
||||
int32_t ipWhiteMgtRemove(char *user) {
|
||||
bool update = true;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
if (ppList == NULL || *ppList == NULL) {
|
||||
update = false;
|
||||
} else {
|
||||
taosMemoryFree(*ppList);
|
||||
taosHashRemove(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
(void)taosHashRemove(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
}
|
||||
|
||||
if (update) ipWhiteMgt.ver++;
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ bool isRangeInWhiteList(SIpWhiteList *pList, SIpV4Range *range) {
|
|||
}
|
||||
#if 0
|
||||
int32_t ipWhiteUpdateForAllUser(SIpWhiteList *pList) {
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
|
||||
SHashObj *pIpWhiteTab = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK);
|
||||
void *pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, NULL);
|
||||
|
@ -267,8 +267,8 @@ int32_t ipWhiteUpdateForAllUser(SIpWhiteList *pList) {
|
|||
if (clone->num != 0) {
|
||||
int32_t sz = clone->num + p->num;
|
||||
val = taosMemoryCalloc(1, sizeof(SIpWhiteList) + sz * sizeof(SIpV4Range));
|
||||
memcpy(val->pIpRange, p->pIpRange, sizeof(SIpV4Range) * p->num);
|
||||
memcpy(((char *)val->pIpRange) + sizeof(SIpV4Range) * p->num, (char *)clone->pIpRange,
|
||||
(void)memcpy(val->pIpRange, p->pIpRange, sizeof(SIpV4Range) * p->num);
|
||||
(void)memcpy(((char *)val->pIpRange) + sizeof(SIpV4Range) * p->num, (char *)clone->pIpRange,
|
||||
sizeof(SIpV4Range) * clone->num);
|
||||
|
||||
} else {
|
||||
|
@ -285,7 +285,7 @@ int32_t ipWhiteUpdateForAllUser(SIpWhiteList *pList) {
|
|||
|
||||
ipWhiteMgt.pIpWhiteTab = pIpWhiteTab;
|
||||
ipWhiteMgt.ver++;
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -305,29 +305,29 @@ static int32_t ipWhiteMgtUpdateAll(SMnode *pMnode) {
|
|||
|
||||
#if 0
|
||||
void ipWhiteMgtUpdate2(SMnode *pMnode) {
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
|
||||
ipWhiteMgtUpdateAll(pMnode);
|
||||
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
}
|
||||
#endif
|
||||
|
||||
int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
||||
int64_t ver = 0;
|
||||
int32_t code = 0;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
if (ipWhiteMgt.ver == 0) {
|
||||
// get user and dnode ip white list
|
||||
if ((code = ipWhiteMgtUpdateAll(pMnode)) != 0) {
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
mError("%s failed to update ip white list since %s", __func__, tstrerror(code));
|
||||
return ver;
|
||||
}
|
||||
ipWhiteMgt.ver = taosGetTimestampMs();
|
||||
}
|
||||
ver = ipWhiteMgt.ver;
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
|
||||
if (mndEnableIpWhiteList(pMnode) == 0 || tsEnableWhiteList == false) {
|
||||
ver = 0;
|
||||
|
@ -337,10 +337,13 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
|||
}
|
||||
|
||||
int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8_t type, bool *pUpdate) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
bool update = false;
|
||||
SIpV4Range range = {.ip = taosGetIpv4FromFqdn(fqdn), .mask = 32};
|
||||
SIpV4Range range = {.ip = 0, .mask = 32};
|
||||
int32_t code = taosGetIpv4FromFqdn(fqdn, &range.ip);
|
||||
if (code) {
|
||||
//TODO
|
||||
}
|
||||
mDebug("ip-white-list may update for user: %s, fqdn: %s", user, fqdn);
|
||||
SIpWhiteList **ppList = taosHashGet(pIpWhiteTab, user, strlen(user));
|
||||
SIpWhiteList *pList = NULL;
|
||||
|
@ -354,7 +357,7 @@ int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8
|
|||
if (pNewList == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memcpy(pNewList->pIpRange, &range, sizeof(SIpV4Range));
|
||||
(void)memcpy(pNewList->pIpRange, &range, sizeof(SIpV4Range));
|
||||
pNewList->num = 1;
|
||||
|
||||
if ((code = taosHashPut(pIpWhiteTab, user, strlen(user), &pNewList, sizeof(void *))) != 0) {
|
||||
|
@ -369,7 +372,7 @@ int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8
|
|||
if (pNewList == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memcpy(pNewList->pIpRange, pList->pIpRange, sizeof(SIpV4Range) * (pList->num));
|
||||
(void)memcpy(pNewList->pIpRange, pList->pIpRange, sizeof(SIpV4Range) * (pList->num));
|
||||
pNewList->pIpRange[pList->num].ip = range.ip;
|
||||
pNewList->pIpRange[pList->num].mask = range.mask;
|
||||
|
||||
|
@ -387,7 +390,7 @@ int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8
|
|||
if (pList != NULL) {
|
||||
if (isRangeInWhiteList(pList, &range)) {
|
||||
if (pList->num == 1) {
|
||||
taosHashRemove(pIpWhiteTab, user, strlen(user));
|
||||
(void)taosHashRemove(pIpWhiteTab, user, strlen(user));
|
||||
taosMemoryFree(pList);
|
||||
} else {
|
||||
int32_t idx = 0;
|
||||
|
@ -430,14 +433,14 @@ _OVER:
|
|||
|
||||
int32_t mndRefreshUserIpWhiteList(SMnode *pMnode) {
|
||||
int32_t code = 0;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
|
||||
if ((code = ipWhiteMgtUpdateAll(pMnode)) != 0) {
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
ipWhiteMgt.ver = taosGetTimestampMs();
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
@ -448,7 +451,7 @@ int32_t mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_
|
|||
bool update = false;
|
||||
|
||||
if (lock) {
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
if (ipWhiteMgt.ver == 0) {
|
||||
TAOS_CHECK_GOTO(ipWhiteMgtUpdateAll(pMnode), &lino, _OVER);
|
||||
ipWhiteMgt.ver = taosGetTimestampMs();
|
||||
|
@ -467,7 +470,7 @@ int32_t mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_
|
|||
if (keyDup == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memcpy(keyDup, key, klen);
|
||||
(void)memcpy(keyDup, key, klen);
|
||||
bool upd = false;
|
||||
code = mndUpdateIpWhiteImpl(ipWhiteMgt.pIpWhiteTab, keyDup, fqdn, type, &upd);
|
||||
update |= upd;
|
||||
|
@ -482,7 +485,7 @@ int32_t mndUpdateIpWhiteForAllUser(SMnode *pMnode, char *user, char *fqdn, int8_
|
|||
|
||||
_OVER:
|
||||
if (update) ipWhiteMgt.ver++;
|
||||
if (lock) taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
if (lock) (void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
if (code < 0) {
|
||||
mError("failed to update ip-white-list for user: %s, fqdn: %s at line %d since %s", user, fqdn, lino,
|
||||
tstrerror(code));
|
||||
|
@ -493,13 +496,13 @@ _OVER:
|
|||
|
||||
static int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
||||
int64_t ver = 0;
|
||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
ver = ipWhiteMgt.ver;
|
||||
int32_t num = taosHashGetSize(ipWhiteMgt.pIpWhiteTab);
|
||||
|
||||
pUpdate->pUserIpWhite = taosMemoryCalloc(1, num * sizeof(SUpdateUserIpWhite));
|
||||
if (pUpdate->pUserIpWhite == NULL) {
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -513,14 +516,14 @@ static int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
|||
char *key = taosHashGetKey(pIter, &klen);
|
||||
if (list->num != 0) {
|
||||
pUser->ver = ver;
|
||||
memcpy(pUser->user, key, klen);
|
||||
(void)memcpy(pUser->user, key, klen);
|
||||
pUser->numOfRange = list->num;
|
||||
pUser->pIpRanges = taosMemoryCalloc(1, list->num * sizeof(SIpV4Range));
|
||||
if (pUser->pIpRanges == NULL) {
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(pUser->pIpRanges, list->pIpRange, list->num * sizeof(SIpV4Range));
|
||||
(void)memcpy(pUser->pIpRanges, list->pIpRange, list->num * sizeof(SIpV4Range));
|
||||
i++;
|
||||
}
|
||||
pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, pIter);
|
||||
|
@ -528,7 +531,7 @@ static int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
|||
pUpdate->numOfUser = i;
|
||||
pUpdate->ver = ver;
|
||||
|
||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
(void)taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||
TAOS_RETURN(0);
|
||||
}
|
||||
|
||||
|
@ -681,7 +684,7 @@ static void ipRangeToStr(SIpV4Range *range, char *buf) {
|
|||
|
||||
uv_inet_ntop(AF_INET, &addr, buf, 32);
|
||||
if (range->mask != 32) {
|
||||
sprintf(buf + strlen(buf), "/%d", range->mask);
|
||||
(void)sprintf(buf + strlen(buf), "/%d", range->mask);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1311,7 +1314,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1320,7 +1323,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->readTbs, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1334,7 +1337,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1343,7 +1346,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->writeTbs, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1358,7 +1361,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1367,7 +1370,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->alterTbs, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1381,7 +1384,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1390,7 +1393,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->readViews, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1404,7 +1407,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1413,7 +1416,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->writeViews, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1427,7 +1430,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t valuelen = 0;
|
||||
|
@ -1436,7 +1439,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (value == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(value, 0, valuelen);
|
||||
(void)memset(value, 0, valuelen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, value, valuelen, _OVER)
|
||||
|
||||
TAOS_CHECK_GOTO(taosHashPut(pUser->alterViews, key, keyLen, value, valuelen), &lino, _OVER);
|
||||
|
@ -1451,7 +1454,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
|
|||
if (key == NULL) {
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
memset(key, 0, keyLen);
|
||||
(void)memset(key, 0, keyLen);
|
||||
SDB_GET_BINARY(pRaw, dataPos, key, keyLen, _OVER);
|
||||
|
||||
int32_t ref = 0;
|
||||
|
@ -1642,7 +1645,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
|
|||
pOld->sysInfo = pNew->sysInfo;
|
||||
pOld->enable = pNew->enable;
|
||||
pOld->flag = pNew->flag;
|
||||
memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
||||
(void)memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN);
|
||||
TSWAP(pOld->readDbs, pNew->readDbs);
|
||||
TSWAP(pOld->writeDbs, pNew->writeDbs);
|
||||
TSWAP(pOld->topics, pNew->topics);
|
||||
|
@ -1660,7 +1663,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
|
|||
taosWUnLockLatch(&pOld->lock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(pOld->pIpWhiteList, pNew->pIpWhiteList, sz);
|
||||
(void)memcpy(pOld->pIpWhiteList, pNew->pIpWhiteList, sz);
|
||||
pOld->ipWhiteListVer = pNew->ipWhiteListVer;
|
||||
|
||||
taosWUnLockLatch(&pOld->lock);
|
||||
|
@ -1851,13 +1854,13 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
|
|||
if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
||||
char detail[1000] = {0};
|
||||
sprintf(detail, "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable, createReq.superUser,
|
||||
createReq.sysInfo);
|
||||
(void)sprintf(detail, "enable:%d, superUser:%d, sysInfo:%d, password:xxx", createReq.enable, createReq.superUser,
|
||||
createReq.sysInfo);
|
||||
char operation[15] = {0};
|
||||
if (createReq.isImport == 1) {
|
||||
strcpy(operation, "importUser");
|
||||
(void)strcpy(operation, "importUser");
|
||||
} else {
|
||||
strcpy(operation, "createUser");
|
||||
(void)strcpy(operation, "createUser");
|
||||
}
|
||||
|
||||
auditRecord(pReq, pMnode->clusterId, operation, "", createReq.user, detail, strlen(detail));
|
||||
|
@ -2034,7 +2037,7 @@ static int32_t mndTablePriviledge(SMnode *pMnode, SHashObj *hash, SHashObj *useD
|
|||
void *pIter = NULL;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
|
||||
snprintf(tbFName, sizeof(tbFName), "%s.%s", alterReq->objname, alterReq->tabName);
|
||||
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", alterReq->objname, alterReq->tabName);
|
||||
int32_t len = strlen(tbFName) + 1;
|
||||
|
||||
if (alterReq->tagCond != NULL && alterReq->tagCondLen != 0) {
|
||||
|
@ -2064,7 +2067,7 @@ static int32_t mndRemoveTablePriviledge(SMnode *pMnode, SHashObj *hash, SHashObj
|
|||
SSdb *pSdb) {
|
||||
void *pIter = NULL;
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
snprintf(tbFName, sizeof(tbFName), "%s.%s", alterReq->objname, alterReq->tabName);
|
||||
(void)snprintf(tbFName, sizeof(tbFName), "%s.%s", alterReq->objname, alterReq->tabName);
|
||||
int32_t len = strlen(tbFName) + 1;
|
||||
|
||||
if (taosHashRemove(hash, tbFName, len) != 0) {
|
||||
|
@ -2320,7 +2323,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
if (alterReq.alterType == TSDB_ALTER_USER_PASSWD) {
|
||||
char pass[TSDB_PASSWORD_LEN + 1] = {0};
|
||||
taosEncryptPass_c((uint8_t *)alterReq.pass, strlen(alterReq.pass), pass);
|
||||
memcpy(newUser.pass, pass, TSDB_PASSWORD_LEN);
|
||||
(void)memcpy(newUser.pass, pass, TSDB_PASSWORD_LEN);
|
||||
if (0 != strncmp(pUser->pass, pass, TSDB_PASSWORD_LEN)) {
|
||||
++newUser.passVersion;
|
||||
}
|
||||
|
@ -2358,12 +2361,12 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
}
|
||||
|
||||
bool exist = false;
|
||||
memcpy(pNew->pIpRange, pUser->pIpWhiteList->pIpRange, sizeof(SIpV4Range) * idx);
|
||||
(void)memcpy(pNew->pIpRange, pUser->pIpWhiteList->pIpRange, sizeof(SIpV4Range) * idx);
|
||||
for (int i = 0; i < alterReq.numIpRanges; i++) {
|
||||
SIpV4Range *range = &(alterReq.pIpRanges[i]);
|
||||
if (!isRangeInIpWhiteList(pUser->pIpWhiteList, range)) {
|
||||
// already exist, just ignore;
|
||||
memcpy(&pNew->pIpRange[idx], range, sizeof(SIpV4Range));
|
||||
(void)memcpy(&pNew->pIpRange[idx], range, sizeof(SIpV4Range));
|
||||
idx++;
|
||||
continue;
|
||||
} else {
|
||||
|
@ -2413,7 +2416,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
if (localHost) break;
|
||||
|
||||
if (found == false) {
|
||||
memcpy(&pNew->pIpRange[idx], oldRange, sizeof(SIpV4Range));
|
||||
(void)memcpy(&pNew->pIpRange[idx], oldRange, sizeof(SIpV4Range));
|
||||
idx++;
|
||||
} else {
|
||||
noexist = false;
|
||||
|
@ -2442,9 +2445,9 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
|
||||
if (alterReq.alterType == TSDB_ALTER_USER_PASSWD) {
|
||||
char detail[1000] = {0};
|
||||
sprintf(detail, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx",
|
||||
mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo,
|
||||
alterReq.createdb ? 1 : 0, alterReq.tabName);
|
||||
(void)sprintf(detail, "alterType:%s, enable:%d, superUser:%d, sysInfo:%d, createdb:%d, tabName:%s, password:xxx",
|
||||
mndUserAuditTypeStr(alterReq.alterType), alterReq.enable, alterReq.superUser, alterReq.sysInfo,
|
||||
alterReq.createdb ? 1 : 0, alterReq.tabName);
|
||||
auditRecord(pReq, pMnode->clusterId, "alterUser", "", alterReq.user, detail, strlen(detail));
|
||||
} else if (alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || alterReq.alterType == TSDB_ALTER_USER_ENABLE ||
|
||||
alterReq.alterType == TSDB_ALTER_USER_SYSINFO || alterReq.alterType == TSDB_ALTER_USER_CREATEDB) {
|
||||
|
@ -2457,7 +2460,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
ALTER_USER_ADD_ALL_TB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)) {
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
SName name = {0};
|
||||
tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", name.dbname, alterReq.user, alterReq.sql,
|
||||
alterReq.sqlLen);
|
||||
} else {
|
||||
|
@ -2472,7 +2475,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
} else {
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
SName name = {0};
|
||||
tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", name.dbname, alterReq.user, alterReq.sql,
|
||||
alterReq.sqlLen);
|
||||
} else {
|
||||
|
@ -2655,7 +2658,7 @@ static int32_t mndRetrieveUsers(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
}
|
||||
varDataSetLen(varstr, tlen);
|
||||
memcpy(varDataVal(varstr), buf, tlen);
|
||||
(void)memcpy(varDataVal(varstr), buf, tlen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
COL_DATA_SET_VAL_GOTO((const char *)varstr, false, pUser, _exit);
|
||||
|
@ -2740,7 +2743,7 @@ static int32_t mndRetrieveUsersFull(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _exit);
|
||||
}
|
||||
varDataSetLen(varstr, tlen);
|
||||
memcpy(varDataVal(varstr), buf, tlen);
|
||||
(void)memcpy(varDataVal(varstr), buf, tlen);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
COL_DATA_SET_VAL_GOTO((const char *)varstr, false, pUser, _exit);
|
||||
|
@ -2831,7 +2834,7 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i
|
|||
nodesDestroyNode(pAst);
|
||||
} else {
|
||||
sqlLen = 5;
|
||||
sprintf(*sql, "error");
|
||||
(void)sprintf(*sql, "error");
|
||||
}
|
||||
|
||||
STR_WITH_MAXSIZE_TO_VARSTR((*condition), (*sql), pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
@ -2975,8 +2978,8 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
|
||||
SName name = {0};
|
||||
char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameGetDbName(&name, varDataVal(objName));
|
||||
(void)tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameGetDbName(&name, varDataVal(objName));
|
||||
varDataSetLen(objName, strlen(varDataVal(objName)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
COL_DATA_SET_VAL_GOTO((const char *)objName, false, pUser, _exit);
|
||||
|
@ -3019,8 +3022,8 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
|
||||
SName name = {0};
|
||||
char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
tNameGetDbName(&name, varDataVal(objName));
|
||||
(void)tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
(void)tNameGetDbName(&name, varDataVal(objName));
|
||||
varDataSetLen(objName, strlen(varDataVal(objName)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
COL_DATA_SET_VAL_GOTO((const char *)objName, false, pUser, _exit);
|
||||
|
@ -3140,7 +3143,7 @@ int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_
|
|||
if (pUser == NULL) {
|
||||
if (TSDB_CODE_MND_USER_NOT_EXIST == code) {
|
||||
SGetUserAuthRsp rsp = {.dropped = 1};
|
||||
memcpy(rsp.user, pUsers[i].user, TSDB_USER_LEN);
|
||||
(void)memcpy(rsp.user, pUsers[i].user, TSDB_USER_LEN);
|
||||
(void)taosArrayPush(batchRsp.pArray, &rsp);
|
||||
}
|
||||
mError("user:%s, failed to auth user since %s", pUsers[i].user, terrstr());
|
||||
|
|
|
@ -103,7 +103,7 @@ void smaCleanUp() {
|
|||
}
|
||||
|
||||
if (old == 1) {
|
||||
taosCloseRef(smaMgmt.rsetId);
|
||||
(void)taosCloseRef(smaMgmt.rsetId);
|
||||
taosHashCleanup(smaMgmt.refHash);
|
||||
smaMgmt.refHash = NULL;
|
||||
taosTmrCleanUp(smaMgmt.tmrHandle);
|
||||
|
@ -174,10 +174,10 @@ static void tRSmaInfoHashFreeNode(void *data) {
|
|||
|
||||
if ((pRSmaInfo = *(SRSmaInfo **)data)) {
|
||||
if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 0)) && pItem->level) {
|
||||
taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
|
||||
(void)taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
|
||||
}
|
||||
if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 1)) && pItem->level) {
|
||||
taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
|
||||
(void)taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
|
||||
}
|
||||
tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo);
|
||||
}
|
||||
|
@ -378,16 +378,16 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
|
|||
}
|
||||
|
||||
// init sma env
|
||||
tdLockSma(pSma);
|
||||
(void)tdLockSma(pSma);
|
||||
pEnv = (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_load_ptr(&SMA_TSMA_ENV(pSma))
|
||||
: atomic_load_ptr(&SMA_RSMA_ENV(pSma));
|
||||
if (!pEnv) {
|
||||
if ((code = tdInitSmaEnv(pSma, smaType, &pEnv)) < 0) {
|
||||
tdUnLockSma(pSma);
|
||||
(void)tdUnLockSma(pSma);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
tdUnLockSma(pSma);
|
||||
(void)tdUnLockSma(pSma);
|
||||
|
||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -395,15 +395,15 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
|
|||
void *tdRSmaExecutorFunc(void *param) {
|
||||
setThreadName("vnode-rsma");
|
||||
|
||||
tdRSmaProcessExecImpl((SSma *)param, RSMA_EXEC_OVERFLOW);
|
||||
(void)tdRSmaProcessExecImpl((SSma *)param, RSMA_EXEC_OVERFLOW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t tdRsmaStartExecutor(const SSma *pSma) {
|
||||
int32_t code = 0;
|
||||
TdThreadAttr thAttr = {0};
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
(void)taosThreadAttrInit(&thAttr);
|
||||
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
|
||||
SSmaStat *pStat = SMA_ENV_STAT(pEnv);
|
||||
|
@ -418,7 +418,7 @@ static int32_t tdRsmaStartExecutor(const SSma *pSma) {
|
|||
smaDebug("vgId:%d, success to create pthread for rsma", SMA_VID(pSma));
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
(void)taosThreadAttrDestroy(&thAttr);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
|
|||
for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) {
|
||||
if (taosCheckPthreadValid(pthread[i])) {
|
||||
smaDebug("vgId:%d, start to join pthread for rsma:%" PRId64 "", SMA_VID(pSma), taosGetPthreadId(pthread[i]));
|
||||
taosThreadJoin(pthread[i], NULL);
|
||||
(void)taosThreadJoin(pthread[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ int32_t smaOpen(SVnode *pVnode, int8_t rollback, bool force) {
|
|||
pVnode->pSma = pSma;
|
||||
|
||||
pSma->pVnode = pVnode;
|
||||
taosThreadMutexInit(&pSma->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pSma->mutex, NULL);
|
||||
pSma->locked = false;
|
||||
|
||||
if (VND_IS_RSMA(pVnode)) {
|
||||
|
@ -173,8 +173,8 @@ _exit:
|
|||
|
||||
int32_t smaClose(SSma *pSma) {
|
||||
if (pSma) {
|
||||
smaPreClose(pSma);
|
||||
taosThreadMutexDestroy(&pSma->mutex);
|
||||
(void)smaPreClose(pSma);
|
||||
(void)taosThreadMutexDestroy(&pSma->mutex);
|
||||
SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma));
|
||||
SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma));
|
||||
if SMA_RSMA_TSDB0 (pSma) tsdbClose(&SMA_RSMA_TSDB0(pSma));
|
||||
|
|
|
@ -89,7 +89,7 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
|
|||
if (pItem->tmrId) {
|
||||
smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pItem->tmrId,
|
||||
pInfo->suid, i + 1);
|
||||
taosTmrStopA(&pItem->tmrId);
|
||||
(void)taosTmrStopA(&pItem->tmrId);
|
||||
}
|
||||
|
||||
if (pItem->pStreamState) {
|
||||
|
@ -246,7 +246,7 @@ static void tdRSmaTaskInit(SStreamMeta *pMeta, SRSmaInfoItem *pItem, SStreamTask
|
|||
}
|
||||
|
||||
static void tdRSmaTaskRemove(SStreamMeta *pMeta, int64_t streamId, int32_t taskId) {
|
||||
streamMetaUnregisterTask(pMeta, streamId, taskId);
|
||||
(void)streamMetaUnregisterTask(pMeta, streamId, taskId);
|
||||
streamMetaWLock(pMeta);
|
||||
int32_t numOfTasks = streamMetaGetNumOfTasks(pMeta);
|
||||
if (streamMetaCommit(pMeta) < 0) {
|
||||
|
@ -296,7 +296,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
if (!pStreamTask->exec.qmsg) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
sprintf(pStreamTask->exec.qmsg, "%s", RSMA_EXEC_TASK_FLAG);
|
||||
(void)sprintf(pStreamTask->exec.qmsg, "%s", RSMA_EXEC_TASK_FLAG);
|
||||
pStreamTask->chkInfo.checkpointId = streamMetaGetLatestCheckpointId(pStreamTask->pMeta);
|
||||
tdRSmaTaskInit(pStreamTask->pMeta, pItem, &pStreamTask->id);
|
||||
|
||||
|
@ -347,7 +347,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
|
|||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
(void)taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
|
||||
smaInfo("vgId:%d, open rsma task:%p table:%" PRIi64 " level:%" PRIi8 ", checkpointId:%" PRIi64
|
||||
", submitReqVer:%" PRIi64 ", fetchResultVer:%" PRIi64 ", maxdelay:%" PRIi64 " watermark:%" PRIi64
|
||||
|
@ -799,7 +799,7 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, int64_t version, const void *p
|
|||
*(int32_t *)pItem = len;
|
||||
pItem = POINTER_SHIFT(pItem, sizeof(int32_t));
|
||||
*(int64_t *)pItem = version;
|
||||
memcpy(POINTER_SHIFT(pItem, sizeof(int64_t)), pMsg, len);
|
||||
(void)memcpy(POINTER_SHIFT(pItem, sizeof(int64_t)), pMsg, len);
|
||||
|
||||
TAOS_CHECK_RETURN(taosWriteQitem(pInfo->queue, qItem));
|
||||
|
||||
|
@ -810,7 +810,7 @@ static int32_t tdExecuteRSmaImplAsync(SSma *pSma, int64_t version, const void *p
|
|||
int64_t nItems = atomic_fetch_add_64(&pRSmaStat->nBufItems, 1);
|
||||
|
||||
if (atomic_load_8(&pInfo->assigned) == 0) {
|
||||
tsem_post(&(pRSmaStat->notEmpty));
|
||||
(void)tsem_post(&(pRSmaStat->notEmpty));
|
||||
}
|
||||
|
||||
// smoothing consume
|
||||
|
@ -1339,7 +1339,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) {
|
||||
smaWarn("rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
|
||||
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
(void)taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1348,8 +1348,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
if ((code = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid, &pRSmaInfo)) != 0) {
|
||||
smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
|
||||
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
(void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
(void)taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1357,8 +1357,8 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%d refId:%" PRIi64 ")", smaMgmt.rsetId,
|
||||
pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
|
||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
(void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
(void)taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1376,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
}
|
||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
(void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
|
@ -1393,7 +1393,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
atomic_store_8(&pItem->fetchLevel, 1);
|
||||
|
||||
if (atomic_load_8(&pRSmaInfo->assigned) == 0) {
|
||||
tsem_post(&(pStat->notEmpty));
|
||||
(void)tsem_post(&(pStat->notEmpty));
|
||||
}
|
||||
} break;
|
||||
case TASK_TRIGGER_STAT_INACTIVE: {
|
||||
|
@ -1414,7 +1414,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
_end:
|
||||
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
|
||||
tdReleaseRSmaInfo(pSma, pRSmaInfo);
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
(void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
|
||||
}
|
||||
|
||||
static void tdFreeRSmaSubmitItems(SArray *pItems, int32_t type) {
|
||||
|
@ -1507,7 +1507,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
|
|||
|
||||
// the submitReq/deleteReq msg may exsit alternately in the msg queue, consume them sequentially in batch mode
|
||||
while (1) {
|
||||
taosGetQitem(qall, (void **)&msg);
|
||||
(void)taosGetQitem(qall, (void **)&msg);
|
||||
if (msg) {
|
||||
int8_t inputType = RSMA_EXEC_MSG_TYPE(msg);
|
||||
if (inputType == STREAM_INPUT__DATA_SUBMIT) {
|
||||
|
@ -1574,7 +1574,7 @@ _exit:
|
|||
tdFreeRSmaSubmitItems(pSubmitArr, nSubmit ? STREAM_INPUT__MERGED_SUBMIT : STREAM_INPUT__REF_DATA_BLOCK);
|
||||
while (1) {
|
||||
void *msg = NULL;
|
||||
taosGetQitem(qall, (void **)&msg);
|
||||
(void)taosGetQitem(qall, (void **)&msg);
|
||||
if (msg) {
|
||||
taosFreeQitem(msg);
|
||||
} else {
|
||||
|
@ -1687,7 +1687,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
break;
|
||||
}
|
||||
|
||||
tsem_wait(&pRSmaStat->notEmpty);
|
||||
(void)tsem_wait(&pRSmaStat->notEmpty);
|
||||
|
||||
if ((pEnv->flag & SMA_ENV_FLG_CLOSE) && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) {
|
||||
smaDebug("vgId:%d, exec task end, flag:%" PRIi8 ", nBufItems:%" PRIi64, SMA_VID(pSma), pEnv->flag,
|
||||
|
|
|
@ -93,7 +93,7 @@ int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData) {
|
|||
_exit:
|
||||
if (code) {
|
||||
smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pReader->pSma), __func__, lino, tstrerror(code));
|
||||
rsmaSnapReaderClose(&pReader);
|
||||
(void)rsmaSnapReaderClose(&pReader);
|
||||
} else {
|
||||
smaInfo("vgId:%d, vnode snapshot rsma read succeed", SMA_VID(pReader->pSma));
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader) {
|
|||
|
||||
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
|
||||
if (pReader->pDataReader[i]) {
|
||||
tsdbSnapReaderClose(&pReader->pDataReader[i]);
|
||||
(void)tsdbSnapReaderClose(&pReader->pDataReader[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,10 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
|
|||
continue;
|
||||
}
|
||||
|
||||
taosArrayPush(pReq->aSubmitTbData, &tbData);
|
||||
if( taosArrayPush(pReq->aSubmitTbData, &tbData) == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t size = (int32_t)taosArrayGetSize(pReq->aSubmitTbData) - 1;
|
||||
TAOS_CHECK_EXIT(taosHashPut(pTableIndexMap, &groupId, sizeof(groupId), &size, sizeof(size)));
|
||||
|
|
|
@ -19,19 +19,19 @@
|
|||
void tdRSmaQTaskInfoGetFullPath(SVnode *pVnode, tb_uid_t suid, int8_t level, STfs *pTfs, char *outputName) {
|
||||
tdRSmaGetDirName(pVnode, pTfs, true, outputName);
|
||||
int32_t rsmaLen = strlen(outputName);
|
||||
snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8 "%s%" PRIi64, level, TD_DIRSEP, suid);
|
||||
(void)snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8 "%s%" PRIi64, level, TD_DIRSEP, suid);
|
||||
}
|
||||
|
||||
void tdRSmaGetDirName(SVnode *pVnode, STfs *pTfs, bool endWithSep, char *outputName) {
|
||||
int32_t offset = 0;
|
||||
|
||||
// vnode
|
||||
vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pTfs, outputName, TSDB_FILENAME_LEN);
|
||||
(void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pTfs, outputName, TSDB_FILENAME_LEN);
|
||||
offset = strlen(outputName);
|
||||
|
||||
// rsma
|
||||
snprintf(outputName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s%s", TD_DIRSEP, VNODE_RSMA_DIR,
|
||||
(endWithSep ? TD_DIRSEP : ""));
|
||||
(void)snprintf(outputName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s%s", TD_DIRSEP, VNODE_RSMA_DIR,
|
||||
(endWithSep ? TD_DIRSEP : ""));
|
||||
}
|
||||
|
||||
// smaXXXUtil ================
|
||||
|
|
|
@ -2672,7 +2672,7 @@ _return:
|
|||
ctgReleaseVgInfoToCache(pCtg, pDbCache);
|
||||
}
|
||||
if (pTsma) {
|
||||
tFreeTableTSMAInfo(pTsma);
|
||||
tFreeAndClearTableTSMAInfo(pTsma);
|
||||
pTsma = NULL;
|
||||
}
|
||||
if (pVgHash) {
|
||||
|
|
|
@ -3546,15 +3546,23 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
|
|||
continue;
|
||||
}
|
||||
|
||||
int32_t schemaExtSize = 0;
|
||||
if (stbMeta->schemaExt != NULL) {
|
||||
schemaExtSize = stbMeta->tableInfo.numOfColumns * sizeof(SSchemaExt);
|
||||
}
|
||||
metaSize = CTG_META_SIZE(stbMeta);
|
||||
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize);
|
||||
pTableMeta = taosMemoryRealloc(pTableMeta, metaSize + schemaExtSize);
|
||||
if (NULL == pTableMeta) {
|
||||
ctgReleaseTbMetaToCache(pCtg, dbCache, pCache);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize - sizeof(SCTableMeta));
|
||||
pTableMeta->schemaExt = NULL;
|
||||
TAOS_MEMCPY(&pTableMeta->sversion, &stbMeta->sversion, metaSize + schemaExtSize - sizeof(SCTableMeta));
|
||||
if (stbMeta->schemaExt != NULL) {
|
||||
pTableMeta->schemaExt = (SSchemaExt *)((char *)pTableMeta + metaSize);
|
||||
} else {
|
||||
pTableMeta->schemaExt = NULL;
|
||||
}
|
||||
|
||||
CTG_UNLOCK(CTG_READ, &pCache->metaLock);
|
||||
taosHashRelease(dbCache->tbCache, pCache);
|
||||
|
|
|
@ -163,10 +163,10 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo
|
|||
SNodeList *pPhysiChildren = pNode->pChildren;
|
||||
|
||||
if (pPhysiChildren) {
|
||||
*pChildren = nodesMakeList();
|
||||
int32_t code = nodesMakeList(pChildren);
|
||||
if (NULL == *pChildren) {
|
||||
qError("nodesMakeList failed");
|
||||
QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
QRY_ERR_RET(code);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -364,6 +364,7 @@ typedef struct STagScanFilterContext {
|
|||
SHashObj* colHash;
|
||||
int32_t index;
|
||||
SArray* cInfoList;
|
||||
int32_t code;
|
||||
} STagScanFilterContext;
|
||||
|
||||
typedef struct STagScanInfo {
|
||||
|
|
|
@ -380,7 +380,7 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
|
|||
|
||||
for (int32_t k = numOfCols; k < slotId + 1; ++k) {
|
||||
void* tmp = taosArrayPush(pBlock->pDataBlock, &colInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
} else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) {
|
||||
|
|
|
@ -132,20 +132,20 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
|||
}
|
||||
|
||||
SArray* pCidList = taosArrayInit(numOfCols, sizeof(int16_t));
|
||||
QUERY_CHECK_NULL(pCidList, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pCidList, code, lino, _error, terrno);
|
||||
|
||||
pInfo->pFuncTypeList = taosArrayInit(taosArrayGetSize(pScanNode->pFuncTypes), sizeof(int32_t));
|
||||
QUERY_CHECK_NULL(pInfo->pFuncTypeList, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pFuncTypeList, code, lino, _error, terrno);
|
||||
|
||||
void* tmp = taosArrayAddAll(pInfo->pFuncTypeList, pScanNode->pFuncTypes);
|
||||
if (!tmp && taosArrayGetSize(pScanNode->pFuncTypes) > 0) {
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, terrno);
|
||||
}
|
||||
|
||||
for (int i = 0; i < TARRAY_SIZE(pInfo->matchInfo.pList); ++i) {
|
||||
SColMatchItem* pColInfo = taosArrayGet(pInfo->matchInfo.pList, i);
|
||||
void* tmp = taosArrayPush(pCidList, &pColInfo->colId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, terrno);
|
||||
if (pInfo->pFuncTypeList != NULL && taosArrayGetSize(pInfo->pFuncTypeList) > i) {
|
||||
pColInfo->funcType = *(int32_t*)taosArrayGet(pInfo->pFuncTypeList, i);
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pC
|
|||
|
||||
size_t size = taosArrayGetSize(pColMatchInfo->pList);
|
||||
SArray* pMatchInfo = taosArrayInit(size, sizeof(SColMatchItem));
|
||||
QUERY_CHECK_NULL(pMatchInfo, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pMatchInfo, code, lino, _end, terrno);
|
||||
|
||||
for (int32_t i = 0; i < size; ++i) {
|
||||
SColMatchItem* pColInfo = taosArrayGet(pColMatchInfo->pList, i);
|
||||
|
@ -480,10 +480,10 @@ int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pC
|
|||
SSlotDescNode* pDesc = (SSlotDescNode*)nodesListGetNode(pList, slotId);
|
||||
if (pDesc->dataType.type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
void* tmp = taosArrayPush(pMatchInfo, pColInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else if (FUNCTION_TYPE_CACHE_LAST_ROW == pColInfo->funcType) {
|
||||
void* tmp = taosArrayPush(pMatchInfo, pColInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ SOperatorInfo* createEventwindowOperatorInfo(SOperatorInfo* downstream, SPhysiNo
|
|||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
||||
SSDataBlock* pResBlock = createDataBlockFromDescNode(pEventWindowNode->window.node.pOutputDataBlockDesc);
|
||||
QUERY_CHECK_NULL(pResBlock, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pResBlock, code, lino, _error, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pResBlock, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
|
|
@ -547,7 +547,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas
|
|||
size_t totalSources = taosArrayGetSize(pExchangeInfo->pSources);
|
||||
|
||||
SFetchRspHandleWrapper* pWrapper = taosMemoryCalloc(1, sizeof(SFetchRspHandleWrapper));
|
||||
QUERY_CHECK_NULL(pWrapper, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pWrapper, code, lino, _end, terrno);
|
||||
pWrapper->exchangeId = pExchangeInfo->self;
|
||||
pWrapper->sourceIndex = sourceIndex;
|
||||
|
||||
|
@ -764,12 +764,12 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
|
|||
if (pRetrieveRsp->compressed) { // decompress the data
|
||||
if (pDataInfo->decompBuf == NULL) {
|
||||
pDataInfo->decompBuf = taosMemoryMalloc(pRetrieveRsp->payloadLen);
|
||||
QUERY_CHECK_NULL(pDataInfo->decompBuf, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pDataInfo->decompBuf, code, lino, _end, terrno);
|
||||
pDataInfo->decompBufSize = pRetrieveRsp->payloadLen;
|
||||
} else {
|
||||
if (pDataInfo->decompBufSize < pRetrieveRsp->payloadLen) {
|
||||
char* p = taosMemoryRealloc(pDataInfo->decompBuf, pRetrieveRsp->payloadLen);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
if (p != NULL) {
|
||||
pDataInfo->decompBuf = p;
|
||||
pDataInfo->decompBufSize = pRetrieveRsp->payloadLen;
|
||||
|
@ -787,7 +787,7 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
|
|||
blockDataCleanup(pb);
|
||||
} else {
|
||||
pb = createOneDataBlock(pExchangeInfo->pDummyBlock, false);
|
||||
QUERY_CHECK_NULL(pb, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pb, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
int32_t compLen = *(int32_t*)pStart;
|
||||
|
@ -811,7 +811,7 @@ int32_t doExtractResultBlocks(SExchangeInfo* pExchangeInfo, SSourceDataInfo* pDa
|
|||
}
|
||||
|
||||
void* tmp = taosArrayPush(pExchangeInfo->pResultBlockList, &pb);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
_end:
|
||||
|
|
|
@ -33,8 +33,14 @@ typedef struct tagFilterAssist {
|
|||
SHashObj* colHash;
|
||||
int32_t index;
|
||||
SArray* cInfoList;
|
||||
int32_t code;
|
||||
} tagFilterAssist;
|
||||
|
||||
typedef struct STransTagExprCtx {
|
||||
int32_t code;
|
||||
SMetaReader* pReader;
|
||||
} STransTagExprCtx;
|
||||
|
||||
typedef enum {
|
||||
FILTER_NO_LOGIC = 1,
|
||||
FILTER_AND,
|
||||
|
@ -300,8 +306,9 @@ int32_t prepareDataBlockBuf(SSDataBlock* pDataBlock, SColMatchInfo* pMatchInfo)
|
|||
}
|
||||
|
||||
EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
|
||||
SMetaReader* mr = (SMetaReader*)pContext;
|
||||
bool isTagCol = false, isTbname = false;
|
||||
STransTagExprCtx* pCtx = pContext;
|
||||
SMetaReader* mr = pCtx->pReader;
|
||||
bool isTagCol = false, isTbname = false;
|
||||
if (nodeType(*pNode) == QUERY_NODE_COLUMN) {
|
||||
SColumnNode* pCol = (SColumnNode*)*pNode;
|
||||
if (pCol->colType == COLUMN_TYPE_TBNAME)
|
||||
|
@ -315,7 +322,8 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
|
|||
if (isTagCol) {
|
||||
SColumnNode* pSColumnNode = *(SColumnNode**)pNode;
|
||||
|
||||
SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* res = NULL;
|
||||
pCtx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -345,7 +353,8 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
|
|||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
} else if (isTbname) {
|
||||
SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* res = NULL;
|
||||
pCtx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -377,10 +386,20 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pTagCondTmp = nodesCloneNode(pTagCond);
|
||||
|
||||
nodesRewriteExprPostOrder(&pTagCondTmp, doTranslateTagExpr, &mr);
|
||||
SNode* pTagCondTmp = NULL;
|
||||
code = nodesCloneNode(pTagCond, &pTagCondTmp);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
*pQualified = false;
|
||||
return code;
|
||||
}
|
||||
STransTagExprCtx ctx = {.code = 0, .pReader = &mr};
|
||||
nodesRewriteExprPostOrder(&pTagCondTmp, doTranslateTagExpr, &ctx);
|
||||
pAPI->metaReaderFn.clearReader(&mr);
|
||||
if (TSDB_CODE_SUCCESS != ctx.code) {
|
||||
*pQualified = false;
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
SNode* pNew = NULL;
|
||||
code = scalarCalculateConstants(pTagCondTmp, &pNew);
|
||||
|
@ -400,13 +419,14 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle,
|
|||
}
|
||||
|
||||
static EDealRes getColumn(SNode** pNode, void* pContext) {
|
||||
tagFilterAssist* pData = (tagFilterAssist*)pContext;
|
||||
SColumnNode* pSColumnNode = NULL;
|
||||
if (QUERY_NODE_COLUMN == nodeType((*pNode))) {
|
||||
pSColumnNode = *(SColumnNode**)pNode;
|
||||
} else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) {
|
||||
SFunctionNode* pFuncNode = *(SFunctionNode**)(pNode);
|
||||
if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) {
|
||||
pSColumnNode = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
pData->code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pSColumnNode);
|
||||
if (NULL == pSColumnNode) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -423,7 +443,6 @@ static EDealRes getColumn(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
tagFilterAssist* pData = (tagFilterAssist*)pContext;
|
||||
void* data = taosHashGet(pData->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId));
|
||||
if (!data) {
|
||||
int32_t tempRes =
|
||||
|
@ -521,7 +540,7 @@ static int32_t genTbGroupDigest(const SNode* pGroup, uint8_t* filterDigest, T_MD
|
|||
|
||||
if (filterDigest[0]) {
|
||||
payload = taosMemoryRealloc(payload, len + tListLen(pContext->digest));
|
||||
QUERY_CHECK_NULL(payload, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(payload, code, lino, _end, terrno);
|
||||
memcpy(payload + len, filterDigest + 1, tListLen(pContext->digest));
|
||||
len += tListLen(pContext->digest);
|
||||
}
|
||||
|
@ -571,12 +590,20 @@ int32_t getColInfoResultForGroupby(void* pVnode, SNodeList* group, STableListInf
|
|||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, group) {
|
||||
nodesRewriteExprPostOrder(&pNode, getColumn, (void*)&ctx);
|
||||
if (TSDB_CODE_SUCCESS != ctx.code) {
|
||||
code = ctx.code;
|
||||
goto end;
|
||||
}
|
||||
REPLACE_NODE(pNode);
|
||||
}
|
||||
|
||||
T_MD5_CTX context = {0};
|
||||
if (tsTagFilterCache) {
|
||||
SNodeListNode* listNode = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode* listNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&listNode);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto end;
|
||||
}
|
||||
listNode->pNodeList = group;
|
||||
code = genTbGroupDigest((SNode*)listNode, digest, &context);
|
||||
QUERY_CHECK_CODE(code, lino, end);
|
||||
|
@ -597,13 +624,13 @@ int32_t getColInfoResultForGroupby(void* pVnode, SNodeList* group, STableListInf
|
|||
}
|
||||
|
||||
pUidTagList = taosArrayInit(8, sizeof(STUidTagInfo));
|
||||
QUERY_CHECK_NULL(pUidTagList, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pUidTagList, code, lino, end, terrno);
|
||||
|
||||
for (int32_t i = 0; i < rows; ++i) {
|
||||
STableKeyInfo* pkeyInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||
STUidTagInfo info = {.uid = pkeyInfo->uid};
|
||||
void* tmp = taosArrayPush(pUidTagList, &info);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, terrno);
|
||||
}
|
||||
|
||||
code = pAPI->metaFn.getTableTags(pVnode, pTableListInfo->idInfo.suid, pUidTagList);
|
||||
|
@ -622,13 +649,13 @@ int32_t getColInfoResultForGroupby(void* pVnode, SNodeList* group, STableListInf
|
|||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
|
||||
pBlockList = taosArrayInit(2, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, end, terrno);
|
||||
|
||||
void* tmp = taosArrayPush(pBlockList, &pResBlock);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, terrno);
|
||||
|
||||
groupData = taosArrayInit(2, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(groupData, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(groupData, code, lino, end, terrno);
|
||||
|
||||
FOREACH(pNode, group) {
|
||||
SScalarParam output = {0};
|
||||
|
@ -668,7 +695,7 @@ int32_t getColInfoResultForGroupby(void* pVnode, SNodeList* group, STableListInf
|
|||
}
|
||||
|
||||
void* tmp = taosArrayPush(groupData, &output.columnData);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, terrno);
|
||||
}
|
||||
|
||||
int32_t keyLen = 0;
|
||||
|
@ -792,7 +819,7 @@ static SArray* getTableNameList(const SNodeListNode* pList) {
|
|||
SListCell* cell = pList->pNodeList->pHead;
|
||||
|
||||
SArray* pTbList = taosArrayInit(len, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pTbList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pTbList, code, lino, _end, terrno);
|
||||
|
||||
for (int i = 0; i < pList->pNodeList->length; i++) {
|
||||
SValueNode* valueNode = (SValueNode*)cell->pNode;
|
||||
|
@ -804,7 +831,7 @@ static SArray* getTableNameList(const SNodeListNode* pList) {
|
|||
|
||||
char* name = varDataVal(valueNode->datum.p);
|
||||
void* tmp = taosArrayPush(pTbList, &name);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
cell = cell->pNext;
|
||||
}
|
||||
|
||||
|
@ -816,7 +843,7 @@ static SArray* getTableNameList(const SNodeListNode* pList) {
|
|||
// remove the duplicates
|
||||
SArray* pNewList = taosArrayInit(taosArrayGetSize(pTbList), sizeof(void*));
|
||||
void* tmp = taosArrayPush(pNewList, taosArrayGet(pTbList, 0));
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
for (int32_t i = 1; i < numOfTables; ++i) {
|
||||
char** name = taosArrayGetLast(pNewList);
|
||||
|
@ -826,7 +853,7 @@ static SArray* getTableNameList(const SNodeListNode* pList) {
|
|||
}
|
||||
|
||||
tmp = taosArrayPush(pNewList, nameInOldList);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
_end:
|
||||
|
@ -1051,7 +1078,7 @@ SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTables, S
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
} else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
||||
char* tmp = taosMemoryMalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
varDataSetLen(tmp, tagVal.nData);
|
||||
memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData);
|
||||
code = colDataSetVal(pColInfo, i, tmp, false);
|
||||
|
@ -1166,12 +1193,16 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
|
|||
}
|
||||
|
||||
nodesRewriteExprPostOrder(&pTagCond, getColumn, (void*)&ctx);
|
||||
if (TSDB_CODE_SUCCESS != ctx.code) {
|
||||
terrno = code = ctx.code;
|
||||
goto end;
|
||||
}
|
||||
|
||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||
|
||||
// int64_t stt = taosGetTimestampUs();
|
||||
pUidTagList = taosArrayInit(10, sizeof(STUidTagInfo));
|
||||
QUERY_CHECK_NULL(pUidTagList, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pUidTagList, code, lino, end, terrno);
|
||||
|
||||
code = copyExistedUids(pUidTagList, pUidList);
|
||||
QUERY_CHECK_CODE(code, lino, end);
|
||||
|
@ -1189,7 +1220,7 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
|
|||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
STUidTagInfo* pInfo = taosArrayGet(pUidTagList, i);
|
||||
void* tmp = taosArrayPush(pUidList, &pInfo->uid);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, terrno);
|
||||
}
|
||||
terrno = 0;
|
||||
} else {
|
||||
|
@ -1219,10 +1250,10 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN
|
|||
// int64_t st1 = taosGetTimestampUs();
|
||||
// qDebug("generate tag block rows:%d, cost:%ld us", rows, st1-st);
|
||||
pBlockList = taosArrayInit(2, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, end, terrno);
|
||||
|
||||
void* tmp = taosArrayPush(pBlockList, &pResBlock);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, end, terrno);
|
||||
|
||||
code = createResultData(&type, numOfTables, &output);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -1270,14 +1301,14 @@ int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, S
|
|||
pListInfo->idInfo.tableType = pScanNode->tableType;
|
||||
|
||||
SArray* pUidList = taosArrayInit(8, sizeof(uint64_t));
|
||||
QUERY_CHECK_NULL(pUidList, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pUidList, code, lino, _error, terrno);
|
||||
|
||||
SIdxFltStatus status = SFLT_NOT_INDEX;
|
||||
if (pScanNode->tableType != TSDB_SUPER_TABLE) {
|
||||
pListInfo->idInfo.uid = pScanNode->uid;
|
||||
if (pStorageAPI->metaFn.isTableExisted(pVnode, pScanNode->uid)) {
|
||||
void* tmp = taosArrayPush(pUidList, &pScanNode->uid);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, terrno);
|
||||
}
|
||||
code = doFilterByTagCond(pListInfo, pUidList, pTagCond, pVnode, status, pStorageAPI, false, &listAdded);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -1334,7 +1365,7 @@ int32_t getTableList(void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, S
|
|||
if (tsTagFilterCache) {
|
||||
size_t size = numOfTables * sizeof(uint64_t) + sizeof(int32_t);
|
||||
char* pPayload = taosMemoryMalloc(size);
|
||||
QUERY_CHECK_NULL(pPayload, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pPayload, code, lino, _end, terrno);
|
||||
|
||||
*(int32_t*)pPayload = numOfTables;
|
||||
if (numOfTables > 0) {
|
||||
|
@ -1414,9 +1445,20 @@ int32_t getGroupIdFromTagsVal(void* pVnode, uint64_t uid, SNodeList* pGroupNode,
|
|||
return TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
}
|
||||
|
||||
SNodeList* groupNew = nodesCloneList(pGroupNode);
|
||||
SNodeList* groupNew = NULL;
|
||||
int32_t code = nodesCloneList(pGroupNode, &groupNew);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
pAPI->metaReaderFn.clearReader(&mr);
|
||||
return code;
|
||||
}
|
||||
|
||||
nodesRewriteExprsPostOrder(groupNew, doTranslateTagExpr, &mr);
|
||||
STransTagExprCtx ctx = {.code = 0, .pReader = &mr};
|
||||
nodesRewriteExprsPostOrder(groupNew, doTranslateTagExpr, &ctx);
|
||||
if (TSDB_CODE_SUCCESS != ctx.code) {
|
||||
nodesDestroyList(groupNew);
|
||||
pAPI->metaReaderFn.clearReader(&mr);
|
||||
return code;
|
||||
}
|
||||
char* isNull = (char*)keyBuf;
|
||||
char* pStart = (char*)keyBuf + sizeof(int8_t) * LIST_LENGTH(pGroupNode);
|
||||
|
||||
|
@ -1531,7 +1573,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
|
|||
c.isPk = pColNode->isPk;
|
||||
c.dataType = pColNode->node.resType;
|
||||
void* tmp = taosArrayPush(pList, &c);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1650,7 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
|
||||
QUERY_CHECK_NULL(pExp->pExpr, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pExp->pExpr, code, lino, _end, terrno);
|
||||
|
||||
pExp->pExpr->_function.num = 1;
|
||||
pExp->pExpr->_function.functionId = -1;
|
||||
|
@ -1620,7 +1662,7 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
SColumnNode* pColNode = (SColumnNode*)pNode;
|
||||
|
||||
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
QUERY_CHECK_NULL(pExp->base.pParam, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pExp->base.pParam, code, lino, _end, terrno);
|
||||
|
||||
pExp->base.numOfParams = 1;
|
||||
|
||||
|
@ -1635,7 +1677,7 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
SValueNode* pValNode = (SValueNode*)pNode;
|
||||
|
||||
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||
QUERY_CHECK_NULL(pExp->base.pParam, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pExp->base.pParam, code, lino, _end, terrno);
|
||||
|
||||
pExp->base.numOfParams = 1;
|
||||
|
||||
|
@ -1667,9 +1709,13 @@ int32_t createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
|||
|
||||
if (!pFuncNode->pParameterList && (memcmp(pExprNode->_function.functionName, name, len) == 0) &&
|
||||
pExprNode->_function.functionName[len] == 0) {
|
||||
pFuncNode->pParameterList = nodesMakeList();
|
||||
SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == res) { // todo handle error
|
||||
pFuncNode->pParameterList = NULL;
|
||||
int32_t code = nodesMakeList(&pFuncNode->pParameterList);
|
||||
SValueNode* res = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) { // todo handle error
|
||||
} else {
|
||||
res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
|
||||
code = nodesListAppend(pFuncNode->pParameterList, (SNode*)res);
|
||||
|
@ -1898,9 +1944,9 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
|
||||
pCtx->input.numOfInputCols = pFunct->numOfParams;
|
||||
pCtx->input.pData = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pCtx->input.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pCtx->input.pData, code, lino, _end, terrno);
|
||||
pCtx->input.pColumnDataAgg = taosMemoryCalloc(pFunct->numOfParams, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pCtx->input.pColumnDataAgg, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pCtx->input.pColumnDataAgg, code, lino, _end, terrno);
|
||||
|
||||
pCtx->pTsOutput = NULL;
|
||||
pCtx->resDataInfo.bytes = pFunct->resSchema.bytes;
|
||||
|
@ -2238,12 +2284,12 @@ int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t
|
|||
int32_t lino = 0;
|
||||
if (pTableList->map == NULL) {
|
||||
pTableList->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
QUERY_CHECK_NULL(pTableList->map, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pTableList->map, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
STableKeyInfo keyInfo = {.uid = uid, .groupId = gid};
|
||||
void* tmp = taosArrayPush(pTableList->pTableList, &keyInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
int32_t slot = (int32_t)taosArrayGetSize(pTableList->pTableList) - 1;
|
||||
code = taosHashPut(pTableList->map, &uid, sizeof(uid), &slot, sizeof(slot));
|
||||
|
|
|
@ -63,31 +63,31 @@ static int32_t doSetSMABlock(SOperatorInfo* pOperator, void* input, size_t numOf
|
|||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||
SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData));
|
||||
void* tmp = taosArrayPush(pInfo->pBlockLists, pReq);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
void* tmp = taosArrayPush(pInfo->pBlockLists, &input);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||
SPackedData tmp = {.pDataBlock = pDataBlock};
|
||||
void* tmpItem = taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, terrno);
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
} else if (type == STREAM_INPUT__CHECKPOINT) {
|
||||
SPackedData tmp = {.pDataBlock = input};
|
||||
void* tmpItem = taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, terrno);
|
||||
pInfo->blockType = STREAM_INPUT__CHECKPOINT;
|
||||
} else if (type == STREAM_INPUT__REF_DATA_BLOCK) {
|
||||
for (int32_t i = 0; i < numOfBlocks; ++i) {
|
||||
SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData));
|
||||
void* tmp = taosArrayPush(pInfo->pBlockLists, pReq);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
}
|
||||
|
@ -164,13 +164,13 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
for (int32_t i = 0; i < numOfBlocks; i++) {
|
||||
SPackedData* pReq = POINTER_SHIFT(input, i * sizeof(SPackedData));
|
||||
void* tmp = taosArrayPush(pInfo->pBlockLists, pReq);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
} else if (type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
void* tmp = taosArrayPush(pInfo->pBlockLists, input);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
|
||||
} else if (type == STREAM_INPUT__DATA_BLOCK) {
|
||||
|
@ -178,14 +178,14 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
SSDataBlock* pDataBlock = &((SSDataBlock*)input)[i];
|
||||
SPackedData tmp = {.pDataBlock = pDataBlock};
|
||||
void* tmpItem = taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
pInfo->blockType = STREAM_INPUT__DATA_BLOCK;
|
||||
} else if (type == STREAM_INPUT__CHECKPOINT_TRIGGER) {
|
||||
SPackedData tmp = {.pDataBlock = input};
|
||||
void* tmpItem = taosArrayPush(pInfo->pBlockLists, &tmp);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmpItem, code, lino, _end, terrno);
|
||||
|
||||
pInfo->blockType = STREAM_INPUT__CHECKPOINT;
|
||||
} else {
|
||||
|
@ -435,7 +435,7 @@ static int32_t filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S
|
|||
|
||||
// handle multiple partition
|
||||
void* tmp = taosArrayPush(qa, id);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
pAPI->metaReaderFn.clearReader(&mr);
|
||||
|
@ -698,7 +698,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
if (blockIndex >= taosArrayGetSize(pTaskInfo->pResultBlockList)) {
|
||||
SSDataBlock* p1 = createOneDataBlock(pRes, true);
|
||||
void* tmp = taosArrayPush(pTaskInfo->pResultBlockList, &p1);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
p = p1;
|
||||
} else {
|
||||
p = *(SSDataBlock**)taosArrayGet(pTaskInfo->pResultBlockList, blockIndex);
|
||||
|
@ -711,7 +711,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo
|
|||
current += p->info.rows;
|
||||
ASSERT(p->info.rows > 0 || p->info.type == STREAM_CHECKPOINT);
|
||||
void* tmp = taosArrayPush(pResList, &p);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
if (current >= rowsThreshold) {
|
||||
break;
|
||||
|
@ -1464,13 +1464,13 @@ SArray* qGetQueriedTableListInfo(qTaskInfo_t tinfo) {
|
|||
STableListInfo* pTableListInfo = taosArrayGetP(plist, 0);
|
||||
|
||||
SArray* pUidList = taosArrayInit(10, sizeof(uint64_t));
|
||||
QUERY_CHECK_NULL(pUidList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pUidList, code, lino, _end, terrno);
|
||||
|
||||
int32_t numOfTables = tableListGetSize(pTableListInfo);
|
||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||
STableKeyInfo* pKeyInfo = tableListGetInfo(pTableListInfo, i);
|
||||
void* tmp = taosArrayPush(pUidList, &pKeyInfo->uid);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
taosArrayDestroy(plist);
|
||||
|
@ -1492,11 +1492,11 @@ static void extractTableList(SArray* pList, const SOperatorInfo* pOperator) {
|
|||
SStreamScanInfo* pScanInfo = pOperator->info;
|
||||
STableScanInfo* pTableScanInfo = pScanInfo->pTableScanOp->info;
|
||||
void* tmp = taosArrayPush(pList, &pTableScanInfo->base.pTableListInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) {
|
||||
STableScanInfo* pScanInfo = pOperator->info;
|
||||
void* tmp = taosArrayPush(pList, &pScanInfo->base.pTableListInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else {
|
||||
if (pOperator->pDownstream != NULL && pOperator->pDownstream[0] != NULL) {
|
||||
extractTableList(pList, pOperator->pDownstream[0]);
|
||||
|
|
|
@ -267,7 +267,7 @@ static int32_t doCreateConstantValColumnInfo(SInputColumnInfoData* pInput, SFunc
|
|||
SColumnInfoData* pColInfo = NULL;
|
||||
if (pInput->pData[paramIndex] == NULL) {
|
||||
pColInfo = taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
QUERY_CHECK_NULL(pColInfo, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pColInfo, code, lino, _end, terrno);
|
||||
|
||||
// Set the correct column info (data type and bytes)
|
||||
pColInfo->info.type = pFuncParam->param.nType;
|
||||
|
|
|
@ -753,13 +753,13 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
|
|||
}
|
||||
if (pGroupInfo->blockForNotLoaded == NULL) {
|
||||
pGroupInfo->blockForNotLoaded = taosArrayInit(0, sizeof(SSDataBlock*));
|
||||
QUERY_CHECK_NULL(pGroupInfo->blockForNotLoaded, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pGroupInfo->blockForNotLoaded, code, lino, _end, terrno);
|
||||
pGroupInfo->offsetForNotLoaded = 0;
|
||||
}
|
||||
dataNotLoadBlock->info.id.groupId = pGroupInfo->groupId;
|
||||
dataNotLoadBlock->info.dataLoad = 0;
|
||||
void* tmp = taosArrayPush(pGroupInfo->blockForNotLoaded, &dataNotLoadBlock);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
|
|||
if (p == NULL) { // it is a new group
|
||||
SDataGroupInfo gi = {0};
|
||||
gi.pPageList = taosArrayInit(100, sizeof(int32_t));
|
||||
QUERY_CHECK_NULL(gi.pPageList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(gi.pPageList, code, lino, _end, terrno);
|
||||
|
||||
code = taosHashPut(pInfo->pGroupSet, pInfo->keyBuf, len, &gi, sizeof(SDataGroupInfo));
|
||||
if (code == TSDB_CODE_DUP_KEY) {
|
||||
|
@ -797,7 +797,7 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
|
|||
}
|
||||
|
||||
void* tmp = taosArrayPush(p->pPageList, &pageId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
*(int32_t*)pPage = 0;
|
||||
} else {
|
||||
|
@ -822,7 +822,7 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
|
|||
}
|
||||
|
||||
void* tmp = taosArrayPush(p->pPageList, &pageId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
memset(pPage, 0, getBufPageSize(pInfo->pBuf));
|
||||
}
|
||||
|
@ -1030,13 +1030,13 @@ static int32_t hashPartitionNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
|
|||
}
|
||||
|
||||
SArray* groupArray = taosArrayInit(taosHashGetSize(pInfo->pGroupSet), sizeof(SDataGroupInfo));
|
||||
QUERY_CHECK_NULL(groupArray, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(groupArray, code, lino, _end, terrno);
|
||||
|
||||
void* pGroupIter = taosHashIterate(pInfo->pGroupSet, NULL);
|
||||
while (pGroupIter != NULL) {
|
||||
SDataGroupInfo* pGroupInfo = pGroupIter;
|
||||
void* tmp = taosArrayPush(groupArray, pGroupInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
pGroupIter = taosHashIterate(pInfo->pGroupSet, pGroupIter);
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1129,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
|
|||
goto _error;
|
||||
}
|
||||
void* tmp = taosArrayPush(pInfo->pOrderInfoArr, &order);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, terrno);
|
||||
}
|
||||
|
||||
if (pPartNode->pExprs != NULL) {
|
||||
|
@ -1409,13 +1409,13 @@ static void doStreamHashPartitionImpl(SStreamPartitionOperatorInfo* pInfo, SSDat
|
|||
(SPartitionDataInfo*)taosHashGet(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen);
|
||||
if (pParData) {
|
||||
void* tmp = taosArrayPush(pParData->rowIds, &i);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else {
|
||||
SPartitionDataInfo newParData = {0};
|
||||
newParData.groupId = calcGroupId(pInfo->partitionSup.keyBuf, keyLen);
|
||||
newParData.rowIds = taosArrayInit(64, sizeof(int32_t));
|
||||
void* tmp = taosArrayPush(newParData.rowIds, &i);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
code =
|
||||
taosHashPut(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen, &newParData, sizeof(SPartitionDataInfo));
|
||||
|
@ -1594,7 +1594,7 @@ SSDataBlock* buildCreateTableBlock(SExprSupp* tbName, SExprSupp* tag) {
|
|||
pBlock->info.rowSize += infoData.info.bytes;
|
||||
// sub table name
|
||||
void* tmp = taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
SColumnInfoData gpIdData = {0};
|
||||
gpIdData.info.type = TSDB_DATA_TYPE_UBIGINT;
|
||||
|
@ -1602,7 +1602,7 @@ SSDataBlock* buildCreateTableBlock(SExprSupp* tbName, SExprSupp* tag) {
|
|||
pBlock->info.rowSize += gpIdData.info.bytes;
|
||||
// group id
|
||||
tmp = taosArrayPush(pBlock->pDataBlock, &gpIdData);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
for (int32_t i = 0; i < tag->numOfExprs; i++) {
|
||||
SColumnInfoData tagCol = {0};
|
||||
|
@ -1611,7 +1611,7 @@ SSDataBlock* buildCreateTableBlock(SExprSupp* tbName, SExprSupp* tag) {
|
|||
tagCol.info.precision = tag->pExprInfo[i].base.resSchema.precision;
|
||||
// tag info
|
||||
tmp = taosArrayPush(pBlock->pDataBlock, &tagCol);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
pBlock->info.rowSize += tagCol.info.bytes;
|
||||
}
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
pInfo->tbnameCalSup.numOfExprs = 0;
|
||||
if (pPartNode->pSubtable != NULL) {
|
||||
SExprInfo* pSubTableExpr = taosMemoryCalloc(1, sizeof(SExprInfo));
|
||||
QUERY_CHECK_NULL(pSubTableExpr, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pSubTableExpr, code, lino, _error, terrno);
|
||||
|
||||
pInfo->tbnameCalSup.pExprInfo = pSubTableExpr;
|
||||
code = createExprFromOneNode(pSubTableExpr, pPartNode->pSubtable, 0);
|
||||
|
@ -1666,7 +1666,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
if (pPartNode->pTags != NULL) {
|
||||
int32_t numOfTags;
|
||||
SExprInfo* pTagExpr = createExpr(pPartNode->pTags, &numOfTags);
|
||||
QUERY_CHECK_NULL(pTagExpr, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pTagExpr, code, lino, _error, terrno);
|
||||
|
||||
code = initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags, &pTaskInfo->storageAPI.functionStore);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
@ -1674,7 +1674,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
|
||||
if (pInfo->tbnameCalSup.numOfExprs != 0 || pInfo->tagCalSup.numOfExprs != 0) {
|
||||
pInfo->pCreateTbRes = buildCreateTableBlock(&pInfo->tbnameCalSup, &pInfo->tagCalSup);
|
||||
QUERY_CHECK_NULL(pInfo->pCreateTbRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pCreateTbRes, code, lino, _error, terrno);
|
||||
} else {
|
||||
pInfo->pCreateTbRes = NULL;
|
||||
}
|
||||
|
@ -1687,7 +1687,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
pInfo->partitionSup.needCalc = true;
|
||||
|
||||
pInfo->binfo.pRes = createDataBlockFromDescNode(pPartNode->part.node.pOutputDataBlockDesc);
|
||||
QUERY_CHECK_NULL(pInfo->binfo.pRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->binfo.pRes, code, lino, _error, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pInfo->binfo.pRes, 4096);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
@ -1701,7 +1701,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
|||
taosHashSetFreeFp(pInfo->pPartitions, freePartItem);
|
||||
pInfo->tsColIndex = 0;
|
||||
pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
|
||||
QUERY_CHECK_NULL(pInfo->pDelRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pDelRes, code, lino, _error, terrno);
|
||||
|
||||
int32_t numOfCols = 0;
|
||||
SExprInfo* pExprInfo = createExprInfo(pPartNode->part.pTargets, NULL, &numOfCols);
|
||||
|
@ -1750,7 +1750,7 @@ int32_t extractColumnInfo(SNodeList* pNodeList, SArray** pArrayRes) {
|
|||
|
||||
SColumn c = extractColumnFromColumnNode(pColNode);
|
||||
void* tmp = taosArrayPush(pList, &c);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else if (nodeType(pNode->pExpr) == QUERY_NODE_VALUE) {
|
||||
SValueNode* pValNode = (SValueNode*)pNode->pExpr;
|
||||
SColumn c = {0};
|
||||
|
@ -1762,7 +1762,7 @@ int32_t extractColumnInfo(SNodeList* pNodeList, SArray** pArrayRes) {
|
|||
c.precision = pValNode->node.resType.precision;
|
||||
|
||||
void* tmp = taosArrayPush(pList, &c);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca
|
|||
}
|
||||
}
|
||||
|
||||
// free the sma info, since it should not be involved in later computing process.
|
||||
// free the sma info, since it should not be involved in *later computing process.
|
||||
taosMemoryFreeClear(pBlock->pBlockAgg);
|
||||
|
||||
// try to filter data block according to current results
|
||||
|
@ -1725,7 +1725,7 @@ static int32_t doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32_t ts
|
|||
|
||||
if (pInfo->partitionSup.needCalc) {
|
||||
SSDataBlock* tmpBlock = createOneDataBlock(pResult, true);
|
||||
QUERY_CHECK_NULL(tmpBlock, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmpBlock, code, lino, _end, terrno);
|
||||
|
||||
blockDataCleanup(pResult);
|
||||
for (int32_t i = 0; i < tmpBlock->info.rows; i++) {
|
||||
|
@ -2549,7 +2549,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
pBlockInfo->id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
||||
|
||||
SArray* pColList = taosArrayInit(4, sizeof(int32_t));
|
||||
QUERY_CHECK_NULL(pColList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pColList, code, lino, _end, terrno);
|
||||
|
||||
// todo extract method
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
||||
|
@ -2568,7 +2568,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
|
||||
colExists = true;
|
||||
void* tmp = taosArrayPush(pColList, &pColMatchInfo->dstSlotId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2578,7 +2578,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->dstSlotId);
|
||||
colDataSetNNULL(pDst, 0, pBlockInfo->rows);
|
||||
void* tmp = taosArrayPush(pColList, &pColMatchInfo->dstSlotId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2597,7 +2597,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
|||
|
||||
for (int32_t i = 0; i < pInfo->numOfPseudoExpr; ++i) {
|
||||
void* tmp = taosArrayPush(pColList, &pInfo->pPseudoExpr[i].base.resSchema.slotId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3405,7 +3405,7 @@ static int32_t extractTableIdList(const STableListInfo* pTableListInfo, SArray**
|
|||
for (int32_t i = 0; i < size; ++i) {
|
||||
STableKeyInfo* pkeyInfo = tableListGetInfo(pTableListInfo, i);
|
||||
void* tmp = taosArrayPush(tableIdList, &pkeyInfo->uid);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
(*ppArrayRes) = tableIdList;
|
||||
|
@ -3500,10 +3500,10 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
tmpMetaRsp.metaRsp = data;
|
||||
if (!pTaskInfo->streamInfo.btMetaRsp.batchMetaReq) {
|
||||
pTaskInfo->streamInfo.btMetaRsp.batchMetaReq = taosArrayInit(4, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pTaskInfo->streamInfo.btMetaRsp.batchMetaReq, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pTaskInfo->streamInfo.btMetaRsp.batchMetaReq, code, lino, _end, terrno);
|
||||
|
||||
pTaskInfo->streamInfo.btMetaRsp.batchMetaLen = taosArrayInit(4, sizeof(int32_t));
|
||||
QUERY_CHECK_NULL(pTaskInfo->streamInfo.btMetaRsp.batchMetaLen, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pTaskInfo->streamInfo.btMetaRsp.batchMetaLen, code, lino, _end, terrno);
|
||||
}
|
||||
int32_t tempRes = TSDB_CODE_SUCCESS;
|
||||
uint32_t len = 0;
|
||||
|
@ -3516,7 +3516,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
|
||||
int32_t tLen = sizeof(SMqRspHead) + len;
|
||||
void* tBuf = taosMemoryCalloc(1, tLen);
|
||||
QUERY_CHECK_NULL(tBuf, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tBuf, code, lino, _end, terrno);
|
||||
|
||||
void* metaBuff = POINTER_SHIFT(tBuf, sizeof(SMqRspHead));
|
||||
SEncoder encoder = {0};
|
||||
|
@ -3531,10 +3531,10 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) {
|
|||
}
|
||||
taosMemoryFreeClear(data);
|
||||
void* tmp = taosArrayPush(pTaskInfo->streamInfo.btMetaRsp.batchMetaReq, &tBuf);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
tmp = taosArrayPush(pTaskInfo->streamInfo.btMetaRsp.batchMetaLen, &tLen);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
(*ppRes) = NULL;
|
||||
|
@ -3741,7 +3741,7 @@ int32_t addPrimaryKeyCol(SSDataBlock* pBlock, uint8_t type, int32_t bytes) {
|
|||
infoData.info.type = type;
|
||||
infoData.info.bytes = bytes;
|
||||
void* tmp = taosArrayPush(pBlock->pDataBlock, &infoData);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
_end:
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -3788,7 +3788,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
|
||||
int16_t colId = id->colId;
|
||||
void* tmp = taosArrayPush(pColIds, &colId);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _error, terrno);
|
||||
|
||||
if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
pInfo->primaryTsIndex = id->dstSlotId;
|
||||
|
@ -3880,7 +3880,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
|||
pInfo->readHandle = *pHandle;
|
||||
pTaskInfo->streamInfo.snapshotVer = pHandle->version;
|
||||
pInfo->pCreateTbRes = buildCreateTableBlock(&pInfo->tbnameCalSup, &pInfo->tagCalSup);
|
||||
QUERY_CHECK_NULL(pInfo->pCreateTbRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pCreateTbRes, code, lino, _error, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pInfo->pCreateTbRes, 8);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
@ -4073,15 +4073,17 @@ static int32_t tagScanCreateResultData(SDataType* pType, int32_t numOfRows, SSca
|
|||
}
|
||||
|
||||
static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STagScanFilterContext* pCtx = (STagScanFilterContext*)pContext;
|
||||
SColumnNode* pSColumnNode = NULL;
|
||||
if (QUERY_NODE_COLUMN == nodeType((*pNode))) {
|
||||
pSColumnNode = *(SColumnNode**)pNode;
|
||||
} else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) {
|
||||
SFunctionNode* pFuncNode = *(SFunctionNode**)(pNode);
|
||||
if (pFuncNode->funcType == FUNCTION_TYPE_TBNAME) {
|
||||
pSColumnNode = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
pSColumnNode = NULL;
|
||||
pCtx->code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pSColumnNode);
|
||||
if (NULL == pSColumnNode) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -4098,8 +4100,7 @@ static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
STagScanFilterContext* pCtx = (STagScanFilterContext*)pContext;
|
||||
void* data = taosHashGet(pCtx->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId));
|
||||
void* data = taosHashGet(pCtx->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId));
|
||||
if (!data) {
|
||||
code = taosHashPut(pCtx->colHash, &pSColumnNode->colId, sizeof(pSColumnNode->colId), pNode, sizeof((*pNode)));
|
||||
if (code == TSDB_CODE_DUP_KEY) {
|
||||
|
@ -4111,7 +4112,7 @@ static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) {
|
|||
.type = pSColumnNode->node.resType.type,
|
||||
.bytes = pSColumnNode->node.resType.bytes};
|
||||
void* tmp = taosArrayPush(pCtx->cInfoList, &cInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
} else {
|
||||
SColumnNode* col = *(SColumnNode**)data;
|
||||
pSColumnNode->slotId = col->slotId;
|
||||
|
@ -4132,13 +4133,13 @@ static int32_t tagScanFilterByTagCond(SArray* aUidTags, SNode* pTagCond, SArray*
|
|||
int32_t numOfTables = taosArrayGetSize(aUidTags);
|
||||
|
||||
SSDataBlock* pResBlock = createTagValBlockForFilter(pInfo->filterCtx.cInfoList, numOfTables, aUidTags, pVnode, pAPI);
|
||||
QUERY_CHECK_NULL(pResBlock, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pResBlock, code, lino, _end, terrno);
|
||||
|
||||
SArray* pBlockList = taosArrayInit(1, POINTER_BYTES);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pBlockList, code, lino, _end, terrno);
|
||||
|
||||
void* tmp = taosArrayPush(pBlockList, &pResBlock);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)};
|
||||
|
||||
|
@ -4153,7 +4154,7 @@ static int32_t tagScanFilterByTagCond(SArray* aUidTags, SNode* pTagCond, SArray*
|
|||
for (int32_t i = 0; i < numOfTables; ++i) {
|
||||
if (result[i]) {
|
||||
void* tmp = taosArrayPush(aFilterIdxs, &i);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4203,7 +4204,7 @@ static int32_t tagScanFillOneCellWithTag(SOperatorInfo* pOperator, const STUidTa
|
|||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
} else if (IS_VAR_DATA_TYPE(pColInfo->info.type)) {
|
||||
char* tmp = taosMemoryMalloc(tagVal.nData + VARSTR_HEADER_SIZE + 1);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
varDataSetLen(tmp, tagVal.nData);
|
||||
memcpy(tmp + VARSTR_HEADER_SIZE, tagVal.pData, tagVal.nData);
|
||||
|
@ -4274,7 +4275,7 @@ static int32_t doTagScanFromCtbIdxNext(SOperatorInfo* pOperator, SSDataBlock** p
|
|||
|
||||
if (pInfo->pCtbCursor == NULL) {
|
||||
pInfo->pCtbCursor = pAPI->metaFn.openCtbCursor(pInfo->readHandle.vnode, pInfo->suid, 1);
|
||||
QUERY_CHECK_NULL(pInfo->pCtbCursor, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pCtbCursor, code, lino, _end, terrno);
|
||||
} else {
|
||||
code = pAPI->metaFn.resumeCtbCursor(pInfo->pCtbCursor, 0);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -4300,7 +4301,7 @@ static int32_t doTagScanFromCtbIdxNext(SOperatorInfo* pOperator, SSDataBlock** p
|
|||
info.pTagVal = taosMemoryMalloc(pCur->vLen);
|
||||
memcpy(info.pTagVal, pCur->pVal, pCur->vLen);
|
||||
void* tmp = taosArrayPush(aUidTags, &info);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
++numTables;
|
||||
}
|
||||
|
||||
|
@ -4463,7 +4464,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
|||
|
||||
pInfo->pTableListInfo = pTableListInfo;
|
||||
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
||||
|
||||
pInfo->readHandle = *pReadHandle;
|
||||
pInfo->curPos = 0;
|
||||
|
@ -4477,22 +4478,23 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
|||
|
||||
if (pTagScanNode->onlyMetaCtbIdx) {
|
||||
pInfo->aUidTags = taosArrayInit(pOperator->resultInfo.capacity, sizeof(STUidTagInfo));
|
||||
QUERY_CHECK_NULL(pInfo->aUidTags, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->aUidTags, code, lino, _error, terrno);
|
||||
|
||||
pInfo->aFilterIdxs = taosArrayInit(pOperator->resultInfo.capacity, sizeof(int32_t));
|
||||
QUERY_CHECK_NULL(pInfo->aFilterIdxs, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->aFilterIdxs, code, lino, _error, terrno);
|
||||
|
||||
pInfo->filterCtx.colHash =
|
||||
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK);
|
||||
QUERY_CHECK_NULL(pInfo->filterCtx.colHash, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->filterCtx.colHash, code, lino, _error, terrno);
|
||||
|
||||
pInfo->filterCtx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
||||
|
||||
if (pInfo->pTagCond != NULL) {
|
||||
nodesRewriteExprPostOrder(&pTagCond, tagScanRewriteTagColumn, (void*)&pInfo->filterCtx);
|
||||
}
|
||||
}
|
||||
//TODO wjm check pInfo->filterCtx.code
|
||||
__optr_fn_t tagScanNextFn = (pTagScanNode->onlyMetaCtbIdx) ? doTagScanFromCtbIdx : doTagScanFromMetaEntry;
|
||||
pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, tagScanNextFn, NULL, destroyTagScanOperatorInfo,
|
||||
optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL);
|
||||
|
@ -4563,7 +4565,7 @@ int32_t dumpQueryTableCond(const SQueryTableDataCond* src, SQueryTableDataCond*
|
|||
int32_t lino = 0;
|
||||
memcpy((void*)dst, (void*)src, sizeof(SQueryTableDataCond));
|
||||
dst->colList = taosMemoryCalloc(src->numOfCols, sizeof(SColumnInfo));
|
||||
QUERY_CHECK_NULL(dst->colList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(dst->colList, code, lino, _end, terrno);
|
||||
for (int i = 0; i < src->numOfCols; i++) {
|
||||
dst->colList[i] = src->colList[i];
|
||||
}
|
||||
|
@ -5038,7 +5040,7 @@ static void tableMergeScanDoSkipTable(uint64_t uid, void* pTableMergeOpInfo) {
|
|||
if (pInfo->mSkipTables == NULL) {
|
||||
pInfo->mSkipTables = taosHashInit(pInfo->tableEndIndex - pInfo->tableStartIndex + 1,
|
||||
taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_NO_LOCK);
|
||||
QUERY_CHECK_NULL(pInfo->mSkipTables, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->mSkipTables, code, lino, _end, terrno);
|
||||
}
|
||||
int bSkip = 1;
|
||||
if (pInfo->mSkipTables != NULL) {
|
||||
|
@ -5209,10 +5211,10 @@ int32_t generateSortByTsPkInfo(SArray* colMatchInfo, int32_t order, SArray** ppS
|
|||
}
|
||||
|
||||
void* tmp = taosArrayPush(pSortInfo, &biTs);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
if (pkTargetSlotId != -1) {
|
||||
tmp = taosArrayPush(pSortInfo, &biPk);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
(*ppSortArray) = pSortInfo;
|
||||
|
@ -5625,7 +5627,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1024);
|
||||
pInfo->pResBlock = createDataBlockFromDescNode(pDescNode);
|
||||
QUERY_CHECK_NULL(pInfo->pResBlock, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pResBlock, code, lino, _error, terrno);
|
||||
code = blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
if (!hasLimit && blockDataGetRowSize(pInfo->pResBlock) >= 256 && !pTableScanNode->smallDataTsSort) {
|
||||
|
@ -5640,7 +5642,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
|||
code = generateSortByTsPkInfo(pInfo->base.matchInfo.pList, pInfo->base.cond.order, &pInfo->pSortInfo);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
pInfo->pReaderBlock = createOneDataBlock(pInfo->pResBlock, false);
|
||||
QUERY_CHECK_NULL(pInfo->pReaderBlock, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pReaderBlock, code, lino, _error, terrno);
|
||||
|
||||
pInfo->needCountEmptyTable = tsCountAlwaysReturnValue && pTableScanNode->needCountEmptyTable;
|
||||
|
||||
|
@ -5807,7 +5809,7 @@ SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* readHandle, STableC
|
|||
SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc;
|
||||
initResultSizeInfo(&pOperator->resultInfo, 1);
|
||||
pInfo->pRes = createDataBlockFromDescNode(pDescNode);
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pRes, code, lino, _error, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _error);
|
||||
|
@ -6030,7 +6032,7 @@ static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountSca
|
|||
if (pSupp->groupByStbName) {
|
||||
if (pInfo->stbUidList == NULL) {
|
||||
pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t));
|
||||
QUERY_CHECK_NULL(pInfo->stbUidList, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->stbUidList, code, lino, _end, terrno);
|
||||
code = pAPI->metaFn.storeGetTableList(pInfo->readHandle.vnode, TSDB_SUPER_TABLE, pInfo->stbUidList);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
}
|
||||
|
|
|
@ -754,7 +754,7 @@ void streamCountReleaseState(SOperatorInfo* pOperator) {
|
|||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
int32_t resSize = sizeof(TSKEY);
|
||||
char* pBuff = taosMemoryCalloc(1, resSize);
|
||||
QUERY_CHECK_NULL(pBuff, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pBuff, code, lino, _end, terrno);
|
||||
|
||||
memcpy(pBuff, &pInfo->twAggSup.maxTs, sizeof(TSKEY));
|
||||
qDebug("===stream=== count window operator relase state. ");
|
||||
|
|
|
@ -694,7 +694,7 @@ static int32_t doStreamEventAggNext(SOperatorInfo* pOperator, SSDataBlock** ppRe
|
|||
|
||||
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
|
||||
pInfo->pAllUpdated = tSimpleHashInit(64, hashFn);
|
||||
QUERY_CHECK_NULL(pInfo->pAllUpdated, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pAllUpdated, code, lino, _end, terrno);
|
||||
|
||||
code = getMaxTsWins(pHisWins, pInfo->historyWins);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -915,18 +915,18 @@ SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhys
|
|||
|
||||
if (pInfo->isHistoryOp) {
|
||||
pInfo->pAllUpdated = tSimpleHashInit(64, hashFn);
|
||||
QUERY_CHECK_NULL(pInfo->pAllUpdated, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pAllUpdated, code, lino, _error, terrno);
|
||||
} else {
|
||||
pInfo->pAllUpdated = NULL;
|
||||
}
|
||||
|
||||
pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT);
|
||||
QUERY_CHECK_NULL(pInfo->pCheckpointRes, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pCheckpointRes, code, lino, _error, terrno);
|
||||
|
||||
pInfo->reCkBlock = false;
|
||||
pInfo->recvGetAll = false;
|
||||
pInfo->pPkDeleted = tSimpleHashInit(64, hashFn);
|
||||
QUERY_CHECK_NULL(pInfo->pPkDeleted, code, lino, _error, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pPkDeleted, code, lino, _error, terrno);
|
||||
pInfo->destHasPrimaryKey = pEventNode->window.destHasPrimayKey;
|
||||
|
||||
setOperatorInfo(pOperator, "StreamEventAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT, true, OP_NOT_OPENED,
|
||||
|
|
|
@ -1905,7 +1905,11 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
|
|||
initResultRowInfo(&pInfo->binfo.resultRowInfo);
|
||||
|
||||
pInfo->numOfChild = numOfChild;
|
||||
pInfo->pPhyNode = (SPhysiNode*)nodesCloneNode((SNode*)pPhyNode);
|
||||
pInfo->pPhyNode = NULL;
|
||||
code = nodesCloneNode((SNode*)pPhyNode, (SNode**)&pInfo->pPhyNode);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
goto _error;
|
||||
}
|
||||
|
||||
pInfo->pPullWins = taosArrayInit(8, sizeof(SPullWindowInfo));
|
||||
pInfo->pullIndex = 0;
|
||||
|
|
|
@ -1055,7 +1055,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
|||
char* tagJson = NULL;
|
||||
parseTagDatatoJson(tagData, &tagJson);
|
||||
tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE);
|
||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, terrno);
|
||||
memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson));
|
||||
varDataSetLen(tagVarChar, strlen(tagJson));
|
||||
taosMemoryFree(tagJson);
|
||||
|
@ -1063,7 +1063,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
|||
int32_t bufSize = IS_VAR_DATA_TYPE(tagType) ? (tagLen + VARSTR_HEADER_SIZE)
|
||||
: (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE);
|
||||
tagVarChar = taosMemoryCalloc(1, bufSize + 1);
|
||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, terrno);
|
||||
int32_t len = -1;
|
||||
if (tagLen > 0)
|
||||
convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
|
||||
|
@ -1258,7 +1258,7 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TABLES);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(p, capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -1542,7 +1542,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
|
|||
varDataSetLen(dbname, strlen(varDataVal(dbname)));
|
||||
|
||||
SSDataBlock* p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_TABLES);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
code = blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -2362,7 +2362,7 @@ int32_t optSysIntersection(SArray* in, SArray* out) {
|
|||
goto _end;
|
||||
}
|
||||
MergeIndex* mi = taosMemoryCalloc(sz, sizeof(MergeIndex));
|
||||
QUERY_CHECK_NULL(mi, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(mi, code, lino, _end, terrno);
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SArray* t = taosArrayGetP(in, i);
|
||||
mi[i].len = (int32_t)taosArrayGetSize(t);
|
||||
|
@ -2591,7 +2591,7 @@ static int32_t doBlockInfoScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes
|
|||
|
||||
int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo);
|
||||
char* p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
|
||||
|
||||
int32_t tempRes = tSerializeBlockDistInfo(varDataVal(p), len, &blockDistInfo);
|
||||
if (tempRes < 0) {
|
||||
|
|
|
@ -296,19 +296,19 @@ static int32_t initBeforeAfterDataBuf(SFillInfo* pFillInfo) {
|
|||
SGroupKeys key = {0};
|
||||
SResSchema* pSchema = &pCol->pExpr->base.resSchema;
|
||||
key.pData = taosMemoryMalloc(pSchema->bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
key.isNull = true;
|
||||
key.bytes = pSchema->bytes;
|
||||
key.type = pSchema->type;
|
||||
|
||||
void* tmp = taosArrayPush(pFillInfo->next.pRowVal, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
key.pData = taosMemoryMalloc(pSchema->bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
|
||||
tmp = taosArrayPush(pFillInfo->prev.pRowVal, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
_end:
|
||||
|
@ -522,7 +522,7 @@ void taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillC
|
|||
}
|
||||
|
||||
SFillInfo* pFillInfo = taosMemoryCalloc(1, sizeof(SFillInfo));
|
||||
QUERY_CHECK_NULL(pFillInfo, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pFillInfo, code, lino, _end, terrno);
|
||||
|
||||
pFillInfo->order = order;
|
||||
pFillInfo->srcTsSlotId = primaryTsSlotId;
|
||||
|
@ -546,10 +546,10 @@ void taosCreateFillInfo(TSKEY skey, int32_t numOfFillCols, int32_t numOfNotFillC
|
|||
pFillInfo->interval = *pInterval;
|
||||
|
||||
pFillInfo->next.pRowVal = taosArrayInit(pFillInfo->numOfCols, sizeof(SGroupKeys));
|
||||
QUERY_CHECK_NULL(pFillInfo->next.pRowVal, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pFillInfo->next.pRowVal, code, lino, _end, terrno);
|
||||
|
||||
pFillInfo->prev.pRowVal = taosArrayInit(pFillInfo->numOfCols, sizeof(SGroupKeys));
|
||||
QUERY_CHECK_NULL(pFillInfo->prev.pRowVal, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pFillInfo->prev.pRowVal, code, lino, _end, terrno);
|
||||
|
||||
code = initBeforeAfterDataBuf(pFillInfo);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
|
|
@ -435,7 +435,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
|||
}
|
||||
|
||||
current.val = taosMemoryCalloc(pLinearInfo->bytes, 1);
|
||||
QUERY_CHECK_NULL(current.val, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(current.val, code, lino, _end, terrno);
|
||||
taosGetLinearInterpolationVal(¤t, pLinearInfo->type, &start, &end, pLinearInfo->type);
|
||||
code = colDataSetVal(pDst, rows, (char*)current.val, false);
|
||||
QUERY_CHECK_CODE(code, lino, _end);
|
||||
|
@ -558,9 +558,9 @@ static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
|
|||
key.type = pColInfo->info.type;
|
||||
key.isNull = false;
|
||||
key.pData = taosMemoryCalloc(1, pColInfo->info.bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
void* tmp = taosArrayPush(pInfo->pPrevRow, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
pInfo->isPrevRowSet = false;
|
||||
|
@ -593,10 +593,10 @@ static int32_t initNextRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
|
|||
key.type = pColInfo->info.type;
|
||||
key.isNull = false;
|
||||
key.pData = taosMemoryCalloc(1, pColInfo->info.bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
|
||||
void* tmp = taosArrayPush(pInfo->pNextRow, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
pInfo->isNextRowSet = false;
|
||||
|
@ -628,16 +628,16 @@ static int32_t initFillLinearInfo(STimeSliceOperatorInfo* pInfo, SSDataBlock* pB
|
|||
linearInfo.start.key = INT64_MIN;
|
||||
linearInfo.end.key = INT64_MIN;
|
||||
linearInfo.start.val = taosMemoryCalloc(1, pColInfo->info.bytes);
|
||||
QUERY_CHECK_NULL(linearInfo.start.val, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(linearInfo.start.val, code, lino, _end, terrno);
|
||||
|
||||
linearInfo.end.val = taosMemoryCalloc(1, pColInfo->info.bytes);
|
||||
QUERY_CHECK_NULL(linearInfo.end.val, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(linearInfo.end.val, code, lino, _end, terrno);
|
||||
linearInfo.isStartSet = false;
|
||||
linearInfo.isEndSet = false;
|
||||
linearInfo.type = pColInfo->info.type;
|
||||
linearInfo.bytes = pColInfo->info.bytes;
|
||||
void* tmp = taosArrayPush(pInfo->pLinearInfo, &linearInfo);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
|
||||
_end:
|
||||
|
|
|
@ -1210,10 +1210,10 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
|
||||
if (needed) {
|
||||
pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn));
|
||||
QUERY_CHECK_NULL(pInfo->pInterpCols, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pInterpCols, code, lino, _end, terrno);
|
||||
|
||||
pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys));
|
||||
QUERY_CHECK_NULL(pInfo->pPrevValues, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(pInfo->pPrevValues, code, lino, _end, terrno);
|
||||
|
||||
{ // ts column
|
||||
SColumn c = {0};
|
||||
|
@ -1222,17 +1222,17 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
c.type = TSDB_DATA_TYPE_TIMESTAMP;
|
||||
c.bytes = sizeof(int64_t);
|
||||
tmp = taosArrayPush(pInfo->pInterpCols, &c);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
SGroupKeys key;
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = true; // to denote no value is assigned yet
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
|
||||
tmp = taosArrayPush(pInfo->pPrevValues, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1244,17 +1244,17 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
|
|||
|
||||
SColumn c = *pParam->pCol;
|
||||
tmp = taosArrayPush(pInfo->pInterpCols, &c);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
|
||||
SGroupKeys key = {0};
|
||||
key.bytes = c.bytes;
|
||||
key.type = c.type;
|
||||
key.isNull = false;
|
||||
key.pData = taosMemoryCalloc(1, c.bytes);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(key.pData, code, lino, _end, terrno);
|
||||
|
||||
tmp = taosArrayPush(pInfo->pPrevValues, &key);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, TSDB_CODE_OUT_OF_MEMORY);
|
||||
QUERY_CHECK_NULL(tmp, code, lino, _end, terrno);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,8 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
|
|||
|
||||
if (pLast->num <= sizeof(SFilePage)) {
|
||||
// this is empty
|
||||
dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
|
||||
// TODO check ret
|
||||
(void)dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
|
||||
releaseBufPage(pHashObj->pBuf, pFirst);
|
||||
taosArrayRemove(pBucket->pPageIdList, numOfPages - 1);
|
||||
return;
|
||||
|
@ -178,7 +179,8 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
|
|||
pStart += nodeSize;
|
||||
if (pLast->num <= sizeof(SFilePage)) {
|
||||
// this is empty
|
||||
dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
|
||||
// TODO check ret
|
||||
(void)dBufSetBufPageRecycled(pHashObj->pBuf, pLast);
|
||||
releaseBufPage(pHashObj->pBuf, pFirst);
|
||||
taosArrayRemove(pBucket->pPageIdList, numOfPages - 1);
|
||||
break;
|
||||
|
|
|
@ -305,14 +305,16 @@ static int32_t jtMergeEqCond(SNode** ppDst, SNode** ppSrc) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode* pLogicCond = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
pLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
pLogicCond->pParameterList = nodesMakeList();
|
||||
pLogicCond->pParameterList = NULL;
|
||||
code = nodesMakeList(&pLogicCond->pParameterList);
|
||||
assert(0 == nodesListStrictAppend(pLogicCond->pParameterList, *ppSrc));
|
||||
assert(0 == nodesListStrictAppend(pLogicCond->pParameterList, *ppDst));
|
||||
|
||||
|
@ -387,8 +389,10 @@ void createTargetSlotList(SSortMergeJoinPhysiNode* p) {
|
|||
jtCtx.keyColOffset = dstOffset;
|
||||
}
|
||||
|
||||
STargetNode* pTarget = (STargetNode*)nodesMakeNode(QUERY_NODE_TARGET);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
STargetNode* pTarget = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_TARGET, (SNode**)&pTarget);
|
||||
SColumnNode* pCol = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol);
|
||||
assert(NULL != pTarget && NULL != pCol);
|
||||
pCol->dataBlockId = LEFT_BLK_ID;
|
||||
pCol->slotId = i;
|
||||
|
@ -412,8 +416,10 @@ void createTargetSlotList(SSortMergeJoinPhysiNode* p) {
|
|||
jtCtx.keyColOffset = dstOffset;
|
||||
}
|
||||
|
||||
STargetNode* pTarget = (STargetNode*)nodesMakeNode(QUERY_NODE_TARGET);
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
STargetNode* pTarget = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_TARGET, (SNode**)&pTarget);
|
||||
SColumnNode* pCol = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol);
|
||||
assert(NULL != pTarget && NULL != pCol);
|
||||
pCol->dataBlockId = RIGHT_BLK_ID;
|
||||
pCol->slotId = i;
|
||||
|
@ -454,9 +460,9 @@ void createColEqCondStart(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
for (int32_t i = 0; i < MAX_SLOT_NUM; ++i) {
|
||||
if (jtCtx.colEqList[i]) {
|
||||
SColumnNode* pCol1 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol1 = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol1);
|
||||
assert(pCol1);
|
||||
|
||||
pCol1->dataBlockId = LEFT_BLK_ID;
|
||||
pCol1->slotId = i;
|
||||
pCol1->node.resType.type = jtInputColType[i];
|
||||
|
@ -464,7 +470,8 @@ void createColEqCondStart(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
assert(0 == nodesListMakeStrictAppend(&p->pEqLeft, (SNode*)pCol1));
|
||||
|
||||
SColumnNode* pCol2 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol2 = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol2);
|
||||
pCol2->dataBlockId = RIGHT_BLK_ID;
|
||||
pCol2->slotId = i;
|
||||
pCol2->node.resType.type = jtInputColType[i];
|
||||
|
@ -511,7 +518,7 @@ void createColEqCondEnd(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
SLogicConditionNode* pLogic = NULL;
|
||||
if (jtCtx.colEqNum > 1) {
|
||||
pLogic = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogic);
|
||||
assert(pLogic);
|
||||
pLogic->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogic->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
|
@ -520,21 +527,24 @@ void createColEqCondEnd(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
for (int32_t i = 0; i < MAX_SLOT_NUM; ++i) {
|
||||
if (jtCtx.colEqList[i]) {
|
||||
SColumnNode* pCol1 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol1 = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol1);
|
||||
assert(pCol1);
|
||||
pCol1->dataBlockId = RES_BLK_ID;
|
||||
pCol1->slotId = getDstSlotId(i);
|
||||
pCol1->node.resType.type = jtInputColType[i];
|
||||
pCol1->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
|
||||
SColumnNode* pCol2 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol2 = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol2);
|
||||
assert(pCol2);
|
||||
pCol2->dataBlockId = RES_BLK_ID;
|
||||
pCol2->slotId = getDstSlotId(MAX_SLOT_NUM + i);
|
||||
pCol2->node.resType.type = jtInputColType[i];
|
||||
pCol2->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
assert(pOp);
|
||||
pOp->opType = OP_TYPE_EQUAL;
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -563,7 +573,7 @@ void createColOnCondEnd(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
SLogicConditionNode* pLogic = NULL;
|
||||
if (jtCtx.colOnNum > 1) {
|
||||
pLogic = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogic);
|
||||
assert(pLogic);
|
||||
pLogic->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogic->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
|
@ -572,21 +582,24 @@ void createColOnCondEnd(SSortMergeJoinPhysiNode* p) {
|
|||
|
||||
for (int32_t i = 0; i < MAX_SLOT_NUM; ++i) {
|
||||
if (jtCtx.colOnList[i]) {
|
||||
SColumnNode* pCol1 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol1 = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol1);
|
||||
assert(pCol1);
|
||||
pCol1->dataBlockId = RES_BLK_ID;
|
||||
pCol1->slotId = getDstSlotId(i);
|
||||
pCol1->node.resType.type = jtInputColType[i];
|
||||
pCol1->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
|
||||
SColumnNode* pCol2 = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol2 = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol2);
|
||||
assert(pCol2);
|
||||
pCol2->dataBlockId = RES_BLK_ID;
|
||||
pCol2->slotId = getDstSlotId(MAX_SLOT_NUM + i);
|
||||
pCol2->node.resType.type = jtInputColType[i];
|
||||
pCol2->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
assert(pOp);
|
||||
pOp->opType = OP_TYPE_GREATER_THAN;
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -607,7 +620,8 @@ void createColOnCondEnd(SSortMergeJoinPhysiNode* p) {
|
|||
p->pColOnCond = (SNode*)pLogic;
|
||||
}
|
||||
|
||||
SNode* pTmp = nodesCloneNode(p->pColOnCond);
|
||||
SNode* pTmp = NULL;
|
||||
int32_t code = nodesCloneNode(p->pColOnCond, &pTmp);
|
||||
assert(pTmp);
|
||||
assert(0 == jtMergeEqCond(&p->pFullOnCond, &pTmp));
|
||||
}
|
||||
|
@ -721,7 +735,7 @@ void createFilterEnd(SSortMergeJoinPhysiNode* p, bool filter) {
|
|||
|
||||
SLogicConditionNode* pLogic = NULL;
|
||||
if ((jtCtx.leftFilterNum + jtCtx.rightFilterNum) > 1) {
|
||||
pLogic = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogic);
|
||||
assert(pLogic);
|
||||
pLogic->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogic->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
|
@ -730,7 +744,8 @@ void createFilterEnd(SSortMergeJoinPhysiNode* p, bool filter) {
|
|||
|
||||
for (int32_t i = 0; i < MAX_SLOT_NUM; ++i) {
|
||||
if (jtCtx.leftFilterColList[i]) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN,(SNode**)&pCol);
|
||||
assert(pCol);
|
||||
pCol->dataBlockId = RES_BLK_ID;
|
||||
pCol->slotId = getDstSlotId(i);
|
||||
|
@ -738,13 +753,15 @@ void createFilterEnd(SSortMergeJoinPhysiNode* p, bool filter) {
|
|||
pCol->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
(void)sprintf(pCol->colName, "l%d", i);
|
||||
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
assert(pVal);
|
||||
pVal->node.resType.type = jtInputColType[i];
|
||||
pVal->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
assert(0 == nodesSetValueNodeValue(pVal, getFilterValue(jtInputColType[i])));
|
||||
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
assert(pOp);
|
||||
pOp->opType = OP_TYPE_GREATER_THAN;
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -763,7 +780,8 @@ void createFilterEnd(SSortMergeJoinPhysiNode* p, bool filter) {
|
|||
|
||||
for (int32_t i = 0; i < MAX_SLOT_NUM; ++i) {
|
||||
if (jtCtx.rightFilterColList[i]) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol);
|
||||
assert(pCol);
|
||||
pCol->dataBlockId = RES_BLK_ID;
|
||||
pCol->slotId = getDstSlotId(MAX_SLOT_NUM + i);
|
||||
|
@ -771,13 +789,15 @@ void createFilterEnd(SSortMergeJoinPhysiNode* p, bool filter) {
|
|||
pCol->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
(void)sprintf(pCol->colName, "r%d", i);
|
||||
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
assert(pVal);
|
||||
pVal->node.resType.type = jtInputColType[i];
|
||||
pVal->node.resType.bytes = tDataTypes[jtInputColType[i]].bytes;
|
||||
assert(0 == nodesSetValueNodeValue(pVal, getFilterValue(jtInputColType[i])));
|
||||
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
assert(pOp);
|
||||
pOp->opType = OP_TYPE_GREATER_THAN;
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
|
@ -810,13 +830,15 @@ void updateColRowInfo() {
|
|||
}
|
||||
|
||||
void createBlockDescNode(SDataBlockDescNode** ppNode) {
|
||||
SDataBlockDescNode* pDesc = (SDataBlockDescNode*)nodesMakeNode(QUERY_NODE_DATABLOCK_DESC);
|
||||
SDataBlockDescNode* pDesc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_DATABLOCK_DESC, (SNode**)&pDesc);
|
||||
assert(pDesc);
|
||||
pDesc->dataBlockId = RES_BLK_ID;
|
||||
pDesc->totalRowSize = jtCtx.resColSize - MAX_SLOT_NUM * 2 * sizeof(bool);
|
||||
pDesc->outputRowSize = pDesc->totalRowSize;
|
||||
for (int32_t i = 0; i < jtCtx.resColNum; ++i) {
|
||||
SSlotDescNode* pSlot = (SSlotDescNode*)nodesMakeNode(QUERY_NODE_SLOT_DESC);
|
||||
SSlotDescNode* pSlot = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_SLOT_DESC, (SNode**)&pSlot);
|
||||
assert(pSlot);
|
||||
pSlot->slotId = i;
|
||||
int32_t slotIdx = jtCtx.resColInSlot[i] >= MAX_SLOT_NUM ? jtCtx.resColInSlot[i] - MAX_SLOT_NUM : jtCtx.resColInSlot[i];
|
||||
|
@ -830,14 +852,16 @@ void createBlockDescNode(SDataBlockDescNode** ppNode) {
|
|||
}
|
||||
|
||||
SSortMergeJoinPhysiNode* createDummySortMergeJoinPhysiNode(SJoinTestParam* param) {
|
||||
SSortMergeJoinPhysiNode* p = (SSortMergeJoinPhysiNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN);
|
||||
SSortMergeJoinPhysiNode* p = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, (SNode**)&p);
|
||||
assert(p);
|
||||
p->joinType = param->joinType;
|
||||
p->subType = param->subType;
|
||||
p->asofOpType = param->asofOp;
|
||||
p->grpJoin = param->grpJoin;
|
||||
if (p->subType == JOIN_STYPE_WIN || param->jLimit > 1 || taosRand() % 2) {
|
||||
SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT);
|
||||
SLimitNode* limitNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_LIMIT, (SNode**)&limitNode);
|
||||
assert(limitNode);
|
||||
limitNode->limit = param->jLimit;
|
||||
p->pJLimit = (SNode*)limitNode;
|
||||
|
@ -847,11 +871,14 @@ SSortMergeJoinPhysiNode* createDummySortMergeJoinPhysiNode(SJoinTestParam* param
|
|||
p->rightPrimSlotId = JT_PRIM_TS_SLOT_ID;
|
||||
p->node.inputTsOrder = param->asc ? ORDER_ASC : ORDER_DESC;
|
||||
if (JOIN_STYPE_WIN == p->subType) {
|
||||
SWindowOffsetNode* pOffset = (SWindowOffsetNode*)nodesMakeNode(QUERY_NODE_WINDOW_OFFSET);
|
||||
SWindowOffsetNode* pOffset = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_WINDOW_OFFSET, (SNode**)&pOffset);
|
||||
assert(pOffset);
|
||||
SValueNode* pStart = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pStart = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pStart);
|
||||
assert(pStart);
|
||||
SValueNode* pEnd = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pEnd = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pEnd);
|
||||
assert(pEnd);
|
||||
pStart->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||
pStart->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
|
||||
|
|
|
@ -216,9 +216,10 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
}
|
||||
int32_t len = (int32_t)strlen(buf);
|
||||
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
if (pVal == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pVal->literal = strndup(buf, len);
|
||||
|
@ -238,7 +239,7 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
varDataSetLen(pVal->datum.p, len);
|
||||
(void)strncpy(varDataVal(pVal->datum.p), pVal->literal, len);
|
||||
|
||||
int32_t code = nodesListAppend(pList, (SNode*)pVal);
|
||||
code = nodesListAppend(pList, (SNode*)pVal);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return code;
|
||||
|
@ -247,9 +248,10 @@ static int32_t addTimezoneParam(SNodeList* pList) {
|
|||
}
|
||||
|
||||
static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) {
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
if (pVal == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pVal->literal = NULL;
|
||||
|
@ -261,7 +263,7 @@ static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) {
|
|||
pVal->datum.i = (int64_t)precision;
|
||||
pVal->typeData = (int64_t)precision;
|
||||
|
||||
int32_t code = nodesListMakeAppend(pList, (SNode*)pVal);
|
||||
code = nodesListMakeAppend(pList, (SNode*)pVal);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
return code;
|
||||
|
@ -835,9 +837,13 @@ static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
static int32_t reserveFirstMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) {
|
||||
int32_t code = nodesListMakeAppend(pParameters, pPartialRes);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(*pParameters, nodesCloneNode(nodesListGetNode(pRawParameters, 1)));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(nodesListGetNode(pRawParameters, 1), &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(*pParameters, pNew);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t topBotCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) {
|
||||
|
@ -847,7 +853,11 @@ int32_t topBotCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SN
|
|||
int32_t apercentileCreateMergeParam(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters) {
|
||||
int32_t code = reserveFirstMergeParam(pRawParameters, pPartialRes, pParameters);
|
||||
if (TSDB_CODE_SUCCESS == code && pRawParameters->length >= 3) {
|
||||
code = nodesListStrictAppend(*pParameters, nodesCloneNode(nodesListGetNode(pRawParameters, 2)));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(nodesListGetNode(pRawParameters, 2), &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(*pParameters, pNew);
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -382,29 +382,30 @@ static int32_t getFuncInfo(SFunctionNode* pFunc) {
|
|||
return fmGetFuncInfo(pFunc, msg, sizeof(msg));
|
||||
}
|
||||
|
||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc) {
|
||||
*pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
if (NULL == *pFunc) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** ppFunc) {
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)ppFunc);
|
||||
if (NULL == *ppFunc) {
|
||||
return code;
|
||||
}
|
||||
(void)snprintf((*pFunc)->functionName, sizeof((*pFunc)->functionName), "%s", pName);
|
||||
(*pFunc)->pParameterList = pParameterList;
|
||||
int32_t code = getFuncInfo((*pFunc));
|
||||
(void)snprintf((*ppFunc)->functionName, sizeof((*ppFunc)->functionName), "%s", pName);
|
||||
(*ppFunc)->pParameterList = pParameterList;
|
||||
code = getFuncInfo((*ppFunc));
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
(*pFunc)->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)*pFunc);
|
||||
(*ppFunc)->pParameterList = NULL;
|
||||
nodesDestroyNode((SNode*)*ppFunc);
|
||||
*ppFunc = NULL;
|
||||
return code;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** pCol) {
|
||||
*pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
if (NULL == *pCol) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
static int32_t createColumnByFunc(const SFunctionNode* pFunc, SColumnNode** ppCol) {
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)ppCol);
|
||||
if (NULL == *ppCol) {
|
||||
return code;
|
||||
}
|
||||
(void)strcpy((*pCol)->colName, pFunc->node.aliasName);
|
||||
(*pCol)->node.resType = pFunc->node.resType;
|
||||
(void)strcpy((*ppCol)->colName, pFunc->node.aliasName);
|
||||
(*ppCol)->node.resType = pFunc->node.resType;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -419,11 +420,12 @@ bool fmIsDistExecFunc(int32_t funcId) {
|
|||
}
|
||||
|
||||
static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNode** pPartialFunc) {
|
||||
SNodeList* pParameterList = nodesCloneList(pSrcFunc->pParameterList);
|
||||
SNodeList* pParameterList = NULL;
|
||||
int32_t code = nodesCloneList(pSrcFunc->pParameterList, &pParameterList);
|
||||
if (NULL == pParameterList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
int32_t code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pParameterList,pPartialFunc );
|
||||
code = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pPartialFunc, pParameterList,pPartialFunc );
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParameterList);
|
||||
return code;
|
||||
|
@ -542,12 +544,13 @@ char* fmGetFuncName(int32_t funcId) {
|
|||
/// @retval 0 for succ, otherwise err occured
|
||||
static int32_t fmCreateStateFunc(const SFunctionNode* pFunc, SFunctionNode** pStateFunc) {
|
||||
if (funcMgtBuiltins[pFunc->funcId].pStateFunc) {
|
||||
SNodeList* pParams = nodesCloneList(pFunc->pParameterList);
|
||||
if (!pParams) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
int32_t code = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams, pStateFunc);
|
||||
SNodeList* pParams = NULL;
|
||||
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
||||
if (!pParams) return code;
|
||||
code = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams, pStateFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParams);
|
||||
return TSDB_CODE_FUNC_FUNTION_ERROR;
|
||||
return code;
|
||||
}
|
||||
(void)strcpy((*pStateFunc)->node.aliasName, pFunc->node.aliasName);
|
||||
(void)strcpy((*pStateFunc)->node.userAlias, pFunc->node.userAlias);
|
||||
|
@ -588,9 +591,10 @@ int32_t fmCreateStateFuncs(SNodeList* pFuncs) {
|
|||
|
||||
static int32_t fmCreateStateMergeFunc(SFunctionNode* pFunc, SFunctionNode** pStateMergeFunc) {
|
||||
if (funcMgtBuiltins[pFunc->funcId].pMergeFunc) {
|
||||
SNodeList* pParams = nodesCloneList(pFunc->pParameterList);
|
||||
if (!pParams) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
int32_t code = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams, pStateMergeFunc);
|
||||
SNodeList* pParams = NULL;
|
||||
int32_t code = nodesCloneList(pFunc->pParameterList, &pParams);
|
||||
if (!pParams) return code;
|
||||
code = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams, pStateMergeFunc);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pParams);
|
||||
return code;
|
||||
|
|
|
@ -47,37 +47,37 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_FIELD(fldname) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
(pDst)->fldname = nodesCloneNode((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
#define CLONE_NODE_FIELD(fldname) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
int32_t code = nodesCloneNode((pSrc)->fldname, &((pDst)->fldname)); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return code; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_FIELD_EX(fldname, nodePtrType) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
(pDst)->fldname = (nodePtrType)nodesCloneNode((SNode*)(pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
#define CLONE_NODE_FIELD_EX(fldname, nodePtrType) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
int32_t code = nodesCloneNode((SNode*)(pSrc)->fldname, (SNode**)&((pDst)->fldname)); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return code; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_NODE_LIST_FIELD(fldname) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
(pDst)->fldname = nodesCloneList((pSrc)->fldname); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return TSDB_CODE_OUT_OF_MEMORY; \
|
||||
} \
|
||||
#define CLONE_NODE_LIST_FIELD(fldname) \
|
||||
do { \
|
||||
if (NULL == (pSrc)->fldname) { \
|
||||
break; \
|
||||
} \
|
||||
int32_t code = nodesCloneList((pSrc)->fldname, &((pDst)->fldname)); \
|
||||
if (NULL == (pDst)->fldname) { \
|
||||
return code; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CLONE_OBJECT_FIELD(fldname, cloneFunc) \
|
||||
|
@ -869,18 +869,17 @@ static int32_t setOperatorCopy(const SSetOperator* pSrc, SSetOperator* pDst) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* nodesCloneNode(const SNode* pNode) {
|
||||
int32_t nodesCloneNode(const SNode* pNode, SNode** ppNode) {
|
||||
if (NULL == pNode) {
|
||||
return NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pDst = nodesMakeNode(nodeType(pNode));
|
||||
if (NULL == pDst) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
SNode* pDst = NULL;
|
||||
int32_t code = nodesMakeNode(nodeType(pNode), &pDst);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (nodeType(pNode)) {
|
||||
case QUERY_NODE_COLUMN:
|
||||
code = columnNodeCopy((const SColumnNode*)pNode, (SColumnNode*)pDst);
|
||||
|
@ -1058,25 +1057,32 @@ SNode* nodesCloneNode(const SNode* pNode) {
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode(pDst);
|
||||
nodesError("nodesCloneNode failed node = %s", nodesNodeName(nodeType(pNode)));
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
return pDst;
|
||||
*ppNode = pDst;
|
||||
return code;
|
||||
}
|
||||
|
||||
SNodeList* nodesCloneList(const SNodeList* pList) {
|
||||
int32_t nodesCloneList(const SNodeList* pList, SNodeList** ppList) {
|
||||
if (NULL == pList) {
|
||||
return NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNodeList* pDst = NULL;
|
||||
SNode* pNode;
|
||||
FOREACH(pNode, pList) {
|
||||
int32_t code = nodesListMakeStrictAppend(&pDst, nodesCloneNode(pNode));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesCloneNode(pNode, &pNew);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyList(pDst);
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
code = nodesListMakeStrictAppend(&pDst, pNew);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyList(pDst);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return pDst;
|
||||
*ppList = pDst;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -456,9 +456,9 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList*
|
|||
static int32_t jsonToNodeListImpl(const SJson* pJsonArray, SNodeList** pList) {
|
||||
int32_t size = (NULL == pJsonArray ? 0 : tjsonGetArraySize(pJsonArray));
|
||||
if (size > 0) {
|
||||
*pList = nodesMakeList();
|
||||
int32_t code = nodesMakeList(pList);
|
||||
if (NULL == *pList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ static int32_t jsonToLogicDynQueryCtrlNode(const SJson* pJson, void* pObj) {
|
|||
tjsonGetNumberValue(pJson, jkDynQueryCtrlLogicPlanQueryType, pNode->qType, code);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetBoolValue(pJson, jkDynQueryCtrlLogicPlanStbJoinBatchFetch, &pNode->stbJoin.batchFetch);
|
||||
code = tjsonGetBoolValue(pJson, jkDynQueryCtrlLogicPlanStbJoinBatchFetch, &pNode->stbJoin.batchFetch);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeList(pJson, jkDynQueryCtrlLogicPlanStbJoinVgList, &pNode->stbJoin.pVgList);
|
||||
|
@ -3031,10 +3031,10 @@ static int32_t physiPartitionNodeToJson(const void* pObj, SJson* pJson) {
|
|||
code = nodeListToJson(pJson, jkPartitionPhysiPlanTargets, pNode->pTargets);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonAddBoolToObject(pJson, jkPartitionPhysiPlanNeedBlockOutputTsOrder, pNode->needBlockOutputTsOrder);
|
||||
code = tjsonAddBoolToObject(pJson, jkPartitionPhysiPlanNeedBlockOutputTsOrder, pNode->needBlockOutputTsOrder);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonAddIntegerToObject(pJson, jkPartitionPhysiPlanTsSlotId, pNode->tsSlotId);
|
||||
code = tjsonAddIntegerToObject(pJson, jkPartitionPhysiPlanTsSlotId, pNode->tsSlotId);
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -7390,7 +7390,7 @@ static int32_t jsonToTSMAOption(const SJson* pJson, void* pObj) {
|
|||
code = jsonToNodeObject(pJson, jkTSMAOptionInterval, &pNode->pInterval);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetUTinyIntValue(pJson, jkTSMAOptionTsPrecision, &pNode->tsPrecision);
|
||||
code = tjsonGetUTinyIntValue(pJson, jkTSMAOptionTsPrecision, &pNode->tsPrecision);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -8212,9 +8212,9 @@ static int32_t makeNodeByJson(const SJson* pJson, SNode** pNode) {
|
|||
int32_t val = 0;
|
||||
int32_t code = tjsonGetIntValue(pJson, jkNodeType, &val);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pNode = nodesMakeNode(val);
|
||||
code = nodesMakeNode(val, pNode);
|
||||
if (NULL == *pNode) {
|
||||
return TSDB_CODE_FAILED;
|
||||
return code;
|
||||
}
|
||||
code = jsonToNode(pJson, *pNode);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct STlvDecoder {
|
|||
|
||||
typedef int32_t (*FToMsg)(const void* pObj, STlvEncoder* pEncoder);
|
||||
typedef int32_t (*FToObject)(STlvDecoder* pDecoder, void* pObj);
|
||||
typedef void* (*FMakeObject)(int16_t type);
|
||||
typedef int32_t (*FMakeObject)(int16_t type, SNode** ppNode);
|
||||
typedef int32_t (*FSetObject)(STlv* pTlv, void* pObj);
|
||||
|
||||
static int32_t nodeToMsg(const void* pObj, STlvEncoder* pEncoder);
|
||||
|
@ -568,9 +568,9 @@ static int32_t tlvDecodeObjArrayFromTlv(STlv* pTlv, FToObject func, void* pArray
|
|||
}
|
||||
|
||||
static int32_t tlvDecodeDynObjFromTlv(STlv* pTlv, FMakeObject makeFunc, FToObject toFunc, void** pObj) {
|
||||
*pObj = makeFunc(pTlv->type);
|
||||
int32_t code = makeFunc(pTlv->type, (SNode**)pObj);
|
||||
if (NULL == *pObj) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
return tlvDecodeObjFromTlv(pTlv, toFunc, *pObj);
|
||||
}
|
||||
|
@ -4786,9 +4786,10 @@ static int32_t SArrayToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
|
||||
|
||||
static int32_t msgToNodeList(STlvDecoder* pDecoder, void** pObj) {
|
||||
SNodeList* pList = nodesMakeList();
|
||||
|
||||
SNodeList* pList = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = nodesMakeList(&pList);
|
||||
|
||||
while (TSDB_CODE_SUCCESS == code && !tlvDecodeEnd(pDecoder)) {
|
||||
SNode* pNode = NULL;
|
||||
code = msgToNode(pDecoder, (void**)&pNode);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,9 @@ class NodesCloneTest : public testing::Test {
|
|||
void registerCheckFunc(const std::function<void(const SNode*, const SNode*)>& func) { checkFunc_ = func; }
|
||||
|
||||
void run(const SNode* pSrc) {
|
||||
std::unique_ptr<SNode, void (*)(SNode*)> pDst(nodesCloneNode(pSrc), nodesDestroyNode);
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesCloneNode(pSrc, &pNew);
|
||||
std::unique_ptr<SNode, void (*)(SNode*)> pDst(pNew, nodesDestroyNode);
|
||||
checkFunc_(pSrc, pDst.get());
|
||||
}
|
||||
|
||||
|
@ -43,9 +45,13 @@ TEST_F(NodesCloneTest, tempTable) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_TEMP_TABLE));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_TEMP_TABLE, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
STempTableNode* pNode = (STempTableNode*)srcNode.get();
|
||||
pNode->pSubquery = nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
pNew = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_SELECT_STMT, &pNew);
|
||||
pNode->pSubquery = pNew;
|
||||
return srcNode.get();
|
||||
}());
|
||||
}
|
||||
|
@ -66,12 +72,14 @@ TEST_F(NodesCloneTest, joinTable) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_JOIN_TABLE));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_JOIN_TABLE, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SJoinTableNode* pNode = (SJoinTableNode*)srcNode.get();
|
||||
pNode->joinType = JOIN_TYPE_INNER;
|
||||
pNode->pLeft = nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
pNode->pRight = nodesMakeNode(QUERY_NODE_REAL_TABLE);
|
||||
pNode->pOnCond = nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
code = nodesMakeNode(QUERY_NODE_REAL_TABLE, &pNode->pLeft);
|
||||
code = nodesMakeNode(QUERY_NODE_REAL_TABLE, &pNode->pRight);
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, &pNode->pOnCond);
|
||||
return srcNode.get();
|
||||
}());
|
||||
}
|
||||
|
@ -88,10 +96,12 @@ TEST_F(NodesCloneTest, stateWindow) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_STATE_WINDOW));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_STATE_WINDOW, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SStateWindowNode* pNode = (SStateWindowNode*)srcNode.get();
|
||||
pNode->pCol = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
pNode->pExpr = nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, &pNode->pCol);
|
||||
code = nodesMakeNode(QUERY_NODE_OPERATOR, &pNode->pExpr);
|
||||
return srcNode.get();
|
||||
}());
|
||||
}
|
||||
|
@ -108,10 +118,12 @@ TEST_F(NodesCloneTest, sessionWindow) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_SESSION_WINDOW));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_SESSION_WINDOW, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SSessionWindowNode* pNode = (SSessionWindowNode*)srcNode.get();
|
||||
pNode->pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
pNode->pGap = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pNode->pCol);
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pNode->pGap);
|
||||
return srcNode.get();
|
||||
}());
|
||||
}
|
||||
|
@ -136,12 +148,14 @@ TEST_F(NodesCloneTest, intervalWindow) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SIntervalWindowNode* pNode = (SIntervalWindowNode*)srcNode.get();
|
||||
pNode->pInterval = nodesMakeNode(QUERY_NODE_VALUE);
|
||||
pNode->pOffset = nodesMakeNode(QUERY_NODE_VALUE);
|
||||
pNode->pSliding = nodesMakeNode(QUERY_NODE_VALUE);
|
||||
pNode->pFill = nodesMakeNode(QUERY_NODE_FILL);
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, &pNode->pInterval);
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, &pNode->pOffset);
|
||||
code = nodesMakeNode(QUERY_NODE_VALUE, &pNode->pSliding);
|
||||
code = nodesMakeNode(QUERY_NODE_FILL, &pNode->pFill);
|
||||
return srcNode.get();
|
||||
}());
|
||||
}
|
||||
|
@ -163,11 +177,13 @@ TEST_F(NodesCloneTest, fill) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_FILL));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FILL, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SFillNode* pNode = (SFillNode*)srcNode.get();
|
||||
pNode->mode = FILL_MODE_VALUE;
|
||||
pNode->pValues = nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
pNode->pWStartTs = nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, &pNode->pValues);
|
||||
code = nodesMakeNode(QUERY_NODE_COLUMN, &pNode->pWStartTs);
|
||||
pNode->timeRange.skey = 1666756692907;
|
||||
pNode->timeRange.ekey = 1666756699907;
|
||||
return srcNode.get();
|
||||
|
@ -188,7 +204,9 @@ TEST_F(NodesCloneTest, logicSubplan) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SLogicSubplan* pNode = (SLogicSubplan*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -208,7 +226,9 @@ TEST_F(NodesCloneTest, physiScan) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN));
|
||||
SNode* pNew = nullptr;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
STagScanPhysiNode* pNode = (STagScanPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -227,7 +247,9 @@ TEST_F(NodesCloneTest, physiSystemTableScan) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SSystemTableScanPhysiNode* pNode = (SSystemTableScanPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -244,7 +266,9 @@ TEST_F(NodesCloneTest, physiStreamSemiSessionWinodw) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SStreamSemiSessionWinodwPhysiNode* pNode = (SStreamSemiSessionWinodwPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -261,7 +285,9 @@ TEST_F(NodesCloneTest, physiStreamFinalSessionWinodw) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SStreamFinalSessionWinodwPhysiNode* pNode = (SStreamFinalSessionWinodwPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -277,7 +303,9 @@ TEST_F(NodesCloneTest, physiStreamPartition) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SStreamPartitionPhysiNode* pNode = (SStreamPartitionPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
@ -293,7 +321,9 @@ TEST_F(NodesCloneTest, physiPartition) {
|
|||
std::unique_ptr<SNode, void (*)(SNode*)> srcNode(nullptr, nodesDestroyNode);
|
||||
|
||||
run([&]() {
|
||||
srcNode.reset(nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_PARTITION));
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_PARTITION, &pNew);
|
||||
srcNode.reset(pNew);
|
||||
SPartitionPhysiNode* pNode = (SPartitionPhysiNode*)srcNode.get();
|
||||
return srcNode.get();
|
||||
}());
|
||||
|
|
|
@ -26,7 +26,8 @@ static EDealRes rewriterTest(SNode** pNode, void* pContext) {
|
|||
if (QUERY_NODE_VALUE != nodeType(pOp->pLeft) || QUERY_NODE_VALUE != nodeType(pOp->pRight)) {
|
||||
*pRes = DEAL_RES_ERROR;
|
||||
}
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
string tmp = to_string(stoi(((SValueNode*)(pOp->pLeft))->literal) + stoi(((SValueNode*)(pOp->pRight))->literal));
|
||||
pVal->literal = taosStrdup(tmp.c_str());
|
||||
nodesDestroyNode(*pNode);
|
||||
|
@ -36,15 +37,18 @@ static EDealRes rewriterTest(SNode** pNode, void* pContext) {
|
|||
}
|
||||
|
||||
TEST(NodesTest, traverseTest) {
|
||||
SNode* pRoot = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SNode* pRoot = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR,(SNode**)&pRoot);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SOperatorNode* pOp = (SOperatorNode*)pRoot;
|
||||
SOperatorNode* pLeft = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
pLeft->pLeft = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SOperatorNode* pLeft = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pLeft));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pLeft));
|
||||
((SValueNode*)(pLeft->pLeft))->literal = taosStrdup("10");
|
||||
pLeft->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pRight));
|
||||
((SValueNode*)(pLeft->pRight))->literal = taosStrdup("5");
|
||||
pOp->pLeft = (SNode*)pLeft;
|
||||
pOp->pRight = (SNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pOp->pRight));
|
||||
((SValueNode*)(pOp->pRight))->literal = taosStrdup("3");
|
||||
|
||||
EXPECT_EQ(nodeType(pRoot), QUERY_NODE_OPERATOR);
|
||||
|
@ -90,27 +94,32 @@ void assert_sort_result(SNodeList* pList) {
|
|||
}
|
||||
|
||||
TEST(NodesTest, sort) {
|
||||
SValueNode *vn1 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vn1 = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&vn1));
|
||||
vn1->datum.i = 4;
|
||||
|
||||
SValueNode *vn2 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vn2 = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&vn2));
|
||||
vn2->datum.i = 3;
|
||||
|
||||
SValueNode *vn3 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vn3 = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&vn3));
|
||||
vn3->datum.i = 2;
|
||||
|
||||
SValueNode *vn4 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vn4 = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&vn4));
|
||||
vn4->datum.i = 1;
|
||||
|
||||
SValueNode *vn5 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *vn5 = NULL;
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&vn5));
|
||||
vn5->datum.i = 0;
|
||||
|
||||
SNodeList* l = NULL;
|
||||
nodesListMakeAppend(&l, (SNode*)vn1);
|
||||
nodesListMakeAppend(&l, (SNode*)vn2);
|
||||
nodesListMakeAppend(&l, (SNode*)vn3);
|
||||
nodesListMakeAppend(&l, (SNode*)vn4);
|
||||
nodesListMakeAppend(&l, (SNode*)vn5);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesListMakeAppend(&l, (SNode*)vn1));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesListMakeAppend(&l, (SNode*)vn2));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesListMakeAppend(&l, (SNode*)vn3));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesListMakeAppend(&l, (SNode*)vn4));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesListMakeAppend(&l, (SNode*)vn5));
|
||||
|
||||
nodesSortList(&l, compareValueNode);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag
|
|||
SArray *tagName, uint8_t tagNum, int32_t ttl);
|
||||
int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo);
|
||||
void insResetBoundColsInfo(SBoundColInfo *pInfo);
|
||||
void insInitColValues(STableMeta *pTableMeta, SArray *aColValues);
|
||||
int32_t insInitColValues(STableMeta *pTableMeta, SArray *aColValues);
|
||||
void insCheckTableDataOrder(STableDataCxt *pTableCxt, SRowKey *rowKey);
|
||||
int32_t insGetTableDataCxt(SHashObj *pHash, void *id, int32_t idLen, STableMeta *pTableMeta,
|
||||
SVCreateTbReq **pCreateTbReq, STableDataCxt **pTableCxt, bool colMode, bool ignoreColVals);
|
||||
|
|
|
@ -182,7 +182,8 @@ _end:
|
|||
return (i < pToken->n) ? TK_NK_ILLEGAL : type;
|
||||
}
|
||||
|
||||
void taosCleanupKeywordsTable();
|
||||
int32_t taosInitKeywordsTable();
|
||||
void taosCleanupKeywordsTable();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
|||
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput);
|
||||
int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes);
|
||||
void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request);
|
||||
SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint);
|
||||
int32_t createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint, SNode** ppSelect);
|
||||
int32_t getTableTsmasFromCache(SParseMetaCache* pMetaCache, const SName* pTbName, SArray** pTsmas);
|
||||
int32_t getTsmaFromCache(SParseMetaCache* pMetaCache, const SName* pTsmaName, STableTSMAInfo** pTsma);
|
||||
|
||||
|
|
|
@ -1107,7 +1107,7 @@ expr_or_subquery(A) ::= expression(B).
|
|||
//expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); }
|
||||
|
||||
expression(A) ::= literal(B). { A = B; }
|
||||
expression(A) ::= pseudo_column(B). { A = B; setRawExprNodeIsPseudoColumn(pCxt, A, true); }
|
||||
expression(A) ::= pseudo_column(B). { A = B; (void)setRawExprNodeIsPseudoColumn(pCxt, A, true); }
|
||||
expression(A) ::= column_reference(B). { A = B; }
|
||||
expression(A) ::= function_expression(B). { A = B; }
|
||||
expression(A) ::= case_when_expression(B). { A = B; }
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,9 +30,10 @@ extern void ParseFree(void*, FFree);
|
|||
extern void ParseTrace(FILE*, char*);
|
||||
|
||||
int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues) {
|
||||
*pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
*pQuery = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)pQuery);
|
||||
if (NULL == *pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
(*pQuery)->pRoot = pRootNode;
|
||||
(*pQuery)->placeholderNum = placeholderNo;
|
||||
|
@ -424,7 +425,7 @@ static int32_t collectMetaKeyFromDescribe(SCollectMetaKeyCxt* pCxt, SDescribeStm
|
|||
#ifdef TD_ENTERPRISE
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(&name, dbFName);
|
||||
(void)tNameGetFullDbName(&name, dbFName);
|
||||
code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->tableName, 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -439,9 +440,9 @@ static int32_t collectMetaKeyFromCreateStream(SCollectMetaKeyCxt* pCxt, SCreateS
|
|||
reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->targetDbName, pStmt->targetTabName, pCxt->pMetaCache);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pStmt->pSubtable && NULL != pStmt->pQuery) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery;
|
||||
pSelect->pSubtable = nodesCloneNode(pStmt->pSubtable);
|
||||
int32_t code = nodesCloneNode(pStmt->pSubtable, &pSelect->pSubtable);
|
||||
if (NULL == pSelect->pSubtable) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -724,7 +725,7 @@ static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowC
|
|||
strcpy(name.dbname, pStmt->dbName);
|
||||
strcpy(name.tname, pStmt->viewName);
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(&name, dbFName);
|
||||
(void)tNameGetFullDbName(&name, dbFName);
|
||||
int32_t code = catalogRemoveViewMeta(pCxt->pParseCxt->pCatalog, dbFName, 0, pStmt->viewName, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveViewUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pUser, pStmt->dbName, pStmt->viewName,
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct SAuthRewriteCxt {
|
|||
|
||||
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt);
|
||||
|
||||
static void setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
||||
static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
|
||||
bool isView, bool effective, SUserAuthInfo* pAuth) {
|
||||
if (effective) {
|
||||
snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pEffectiveUser ? pCxt->pEffectiveUser : "");
|
||||
|
@ -43,12 +43,14 @@ static void setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char
|
|||
}
|
||||
|
||||
if (NULL == pTabName) {
|
||||
tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName));
|
||||
int32_t code = tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName));
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
} else {
|
||||
toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName);
|
||||
(void)toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName);
|
||||
}
|
||||
pAuth->type = type;
|
||||
pAuth->isView = isView;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond, bool isView, bool effective) {
|
||||
|
@ -59,8 +61,8 @@ static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pT
|
|||
|
||||
AUTH_RES_TYPE auth_res_type = isView ? AUTH_RES_VIEW : AUTH_RES_BASIC;
|
||||
SUserAuthInfo authInfo = {0};
|
||||
setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t code = setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo);
|
||||
if (TSDB_CODE_SUCCESS != code) return code;
|
||||
SUserAuthRes authRes = {0};
|
||||
if (NULL != pCxt->pMetaCache) {
|
||||
code = getUserAuthFromCache(pCxt->pMetaCache, &authInfo, &authRes);
|
||||
|
@ -105,14 +107,15 @@ static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
|
|||
}
|
||||
|
||||
static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
|
||||
SLogicConditionNode* pLogicCond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SLogicConditionNode* pLogicCond = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond);
|
||||
if (NULL == pLogicCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
|
||||
pLogicCond->condType = LOGIC_COND_TYPE_AND;
|
||||
int32_t code = nodesListMakeStrictAppend(&pLogicCond->pParameterList, pTagCond);
|
||||
code = nodesListMakeStrictAppend(&pLogicCond->pParameterList, pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pLogicCond->pParameterList, *pWhere);
|
||||
}
|
||||
|
@ -136,9 +139,10 @@ EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
|
|||
}
|
||||
|
||||
static int32_t rewriteAppendStableTagCond(SNode** pWhere, SNode* pTagCond, STableNode* pTable) {
|
||||
SNode* pTagCondCopy = nodesCloneNode(pTagCond);
|
||||
SNode* pTagCondCopy = NULL;
|
||||
int32_t code = nodesCloneNode(pTagCond, &pTagCondCopy);
|
||||
if (NULL == pTagCondCopy) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
SAuthRewriteCxt cxt = {.pTarget = pTable};
|
||||
|
|
|
@ -72,9 +72,10 @@ static bool isCondition(const SNode* pNode) {
|
|||
}
|
||||
|
||||
static int32_t rewriteIsTrue(SNode* pSrc, SNode** pIsTrue) {
|
||||
SOperatorNode* pOp = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode* pOp = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOp);
|
||||
if (NULL == pOp) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pOp->opType = OP_TYPE_IS_TRUE;
|
||||
pOp->pLeft = pSrc;
|
||||
|
@ -179,9 +180,9 @@ static EDealRes doFindAndReplaceNode(SNode** pNode, void* pContext) {
|
|||
char aliasName[TSDB_COL_NAME_LEN] = {0};
|
||||
strcpy(aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = nodesCloneNode(pCxt->replaceCxt.pNew);
|
||||
*pNode = NULL;
|
||||
pCxt->code = nodesCloneNode(pCxt->replaceCxt.pNew, pNode);
|
||||
if (NULL == *pNode) {
|
||||
pCxt->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
strcpy(((SExprNode*)*pNode)->aliasName, aliasName);
|
||||
|
@ -231,12 +232,14 @@ static int32_t calcConstProject(SCalcConstContext* pCxt, SNode* pProject, bool d
|
|||
SArray* pOrigAss = NULL;
|
||||
TSWAP(((SExprNode*)*pCol)->pAssociation, pOrigAss);
|
||||
nodesDestroyNode(*pCol);
|
||||
*pCol = nodesCloneNode(*pNew);
|
||||
TSWAP(pOrigAss, ((SExprNode*)*pCol)->pAssociation);
|
||||
*pCol = NULL;
|
||||
code = nodesCloneNode(*pNew, pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
strcpy(((SExprNode*)*pCol)->aliasName, aliasName);
|
||||
TSWAP(pOrigAss, ((SExprNode*)*pCol)->pAssociation);
|
||||
}
|
||||
taosArrayDestroy(pOrigAss);
|
||||
strcpy(((SExprNode*)*pCol)->aliasName, aliasName);
|
||||
if (NULL == *pCol) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -276,17 +279,23 @@ static bool isUselessCol(SExprNode* pProj) {
|
|||
return NULL == ((SExprNode*)pProj)->pAssociation;
|
||||
}
|
||||
|
||||
static SNode* createConstantValue() {
|
||||
SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
static int32_t createConstantValue(SValueNode** ppNode) {
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pVal);
|
||||
if (NULL == pVal) {
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
pVal->node.resType.type = TSDB_DATA_TYPE_INT;
|
||||
pVal->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes;
|
||||
const int32_t val = 1;
|
||||
nodesSetValueNodeValue(pVal, (void*)&val);
|
||||
pVal->translate = true;
|
||||
return (SNode*)pVal;
|
||||
code = nodesSetValueNodeValue(pVal, (void*)&val);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pVal->translate = true;
|
||||
*ppNode = pVal;
|
||||
} else {
|
||||
nodesDestroyNode((SNode*)pVal);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) {
|
||||
|
@ -306,7 +315,11 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
|
|||
WHERE_NEXT;
|
||||
}
|
||||
if (0 == LIST_LENGTH(pSelect->pProjectionList)) {
|
||||
return nodesListStrictAppend(pSelect->pProjectionList, createConstantValue());
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListStrictAppend(pSelect->pProjectionList, (SNode*)pVal);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -412,12 +425,12 @@ static SNodeList* getChildProjection(SNode* pStmt) {
|
|||
|
||||
static void eraseSetOpChildProjection(SSetOperator* pSetOp, int32_t index) {
|
||||
SNodeList* pLeftProjs = getChildProjection(pSetOp->pLeft);
|
||||
nodesListErase(pLeftProjs, nodesListGetCell(pLeftProjs, index));
|
||||
(void)nodesListErase(pLeftProjs, nodesListGetCell(pLeftProjs, index));
|
||||
if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pLeft)) {
|
||||
eraseSetOpChildProjection((SSetOperator*)pSetOp->pLeft, index);
|
||||
}
|
||||
SNodeList* pRightProjs = getChildProjection(pSetOp->pRight);
|
||||
nodesListErase(pRightProjs, nodesListGetCell(pRightProjs, index));
|
||||
(void)nodesListErase(pRightProjs, nodesListGetCell(pRightProjs, index));
|
||||
if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pRight)) {
|
||||
eraseSetOpChildProjection((SSetOperator*)pSetOp->pRight, index);
|
||||
}
|
||||
|
@ -495,7 +508,11 @@ static int32_t calcConstSetOpProjections(SCalcConstContext* pCxt, SSetOperator*
|
|||
WHERE_NEXT;
|
||||
}
|
||||
if (0 == LIST_LENGTH(pSetOp->pProjectionList)) {
|
||||
return nodesListStrictAppend(pSetOp->pProjectionList, createConstantValue());
|
||||
SValueNode* pVal = NULL;
|
||||
int32_t code = createConstantValue(&pVal);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListStrictAppend(pSetOp->pProjectionList, (SNode*)pVal);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -296,13 +296,13 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
|
||||
int ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
buildInvalidOperationMsg(&pBuf, "init bound cols error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "init bound cols error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = smlBoundColumnData(tags, &bindTags, pTagsSchema, true);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
buildInvalidOperationMsg(&pBuf, "bound tags error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound tags error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -347,20 +347,20 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
||||
ret = smlBoundColumnData(colsSchema, &pTableCxt->boundColsInfo, pSchema, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
buildInvalidOperationMsg(&pBuf, "bound cols error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound cols error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = initTableColSubmitData(pTableCxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
buildInvalidOperationMsg(&pBuf, "initTableColSubmitData error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "initTableColSubmitData error");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
if (errno == E2BIG) {
|
||||
uError("sml bind taosMbsToUcs4 error, kv length:%d, bytes:%d, kv->value:%s", (int)kv->length,
|
||||
pColSchema->bytes, kv->value);
|
||||
buildInvalidOperationMsg(&pBuf, "value too long");
|
||||
(void)buildInvalidOperationMsg(&pBuf, "value too long");
|
||||
ret = TSDB_CODE_PAR_VALUE_TOO_LONG;
|
||||
goto end;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
}
|
||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
buildInvalidOperationMsg(&pBuf, "tRowBuild error");
|
||||
ret = buildInvalidOperationMsg(&pBuf, "tRowBuild error");
|
||||
goto end;
|
||||
}
|
||||
SRowKey key;
|
||||
|
@ -459,19 +459,21 @@ end:
|
|||
|
||||
int32_t smlInitHandle(SQuery** query) {
|
||||
*query = NULL;
|
||||
SQuery* pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
SQuery* pQuery = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (NULL == pQuery) {
|
||||
uError("create pQuery error");
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
SVnodeModifyOpStmt* stmt = (SVnodeModifyOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT);
|
||||
SVnodeModifyOpStmt* stmt = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&stmt);
|
||||
if (NULL == stmt) {
|
||||
uError("create SVnodeModifyOpStmt error");
|
||||
qDestroyQuery(pQuery);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
stmt->pTableBlockHashObj = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (stmt->pTableBlockHashObj == NULL){
|
||||
|
|
|
@ -142,7 +142,10 @@ static int32_t parseDuplicateUsingClause(SInsertParseContext* pCxt, SVnodeModify
|
|||
*pDuplicate = false;
|
||||
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableMeta** pMeta = taosHashGet(pStmt->pSubTableHashObj, tbFName, strlen(tbFName));
|
||||
if (NULL != pMeta) {
|
||||
*pDuplicate = true;
|
||||
|
@ -708,7 +711,10 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema,
|
|||
// input pStmt->pSql: [(tag1_name, ...)] TAGS (tag1_value, ...) ...
|
||||
// output pStmt->pSql: TAGS (tag1_value, ...) ...
|
||||
static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) {
|
||||
insInitBoundColsInfo(getNumOfTags(pStmt->pTableMeta), &pCxt->tags);
|
||||
int32_t code = insInitBoundColsInfo(getNumOfTags(pStmt->pTableMeta), &pCxt->tags);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
SToken token;
|
||||
int32_t index = 0;
|
||||
|
@ -725,7 +731,9 @@ int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SS
|
|||
SArray* pTagName, SArray* pTagVals, STag** pTag) {
|
||||
bool isNull = isNullValue(pTagSchema->type, pToken);
|
||||
if (!isNull && pTagName) {
|
||||
taosArrayPush(pTagName, pTagSchema->name);
|
||||
if (NULL == taosArrayPush(pTagName, pTagSchema->name)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
|
@ -745,7 +753,9 @@ int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SS
|
|||
STagVal val = {0};
|
||||
int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
taosArrayPush(pTagVals, &val);
|
||||
if (NULL == taosArrayPush(pTagVals, &val)){
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -796,9 +806,10 @@ typedef struct SRewriteTagCondCxt {
|
|||
} SRewriteTagCondCxt;
|
||||
|
||||
static int32_t rewriteTagCondColumnImpl(STagVal* pVal, SNode** pNode) {
|
||||
SValueNode* pValue = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode* pValue = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue);
|
||||
if (NULL == pValue) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pValue->node.resType = ((SColumnNode*)*pNode)->node.resType;
|
||||
|
@ -1028,8 +1039,16 @@ static int32_t storeChildTableMeta(SInsertParseContext* pCxt, SVnodeModifyOpStmt
|
|||
}
|
||||
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
return taosHashPut(pStmt->pSubTableHashObj, tbFName, strlen(tbFName), &pBackup, POINTER_BYTES);
|
||||
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(pBackup);
|
||||
return code;
|
||||
}
|
||||
code = taosHashPut(pStmt->pSubTableHashObj, tbFName, strlen(tbFName), &pBackup, POINTER_BYTES);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFree(pBackup);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t parseTableOptions(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) {
|
||||
|
@ -1215,13 +1234,16 @@ static int32_t getTargetTableMetaAndVgroup(SInsertParseContext* pCxt, SVnodeModi
|
|||
|
||||
static int32_t collectUseTable(const SName* pName, SHashObj* pTable) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
return taosHashPut(pTable, fullName, strlen(fullName), pName, sizeof(SName));
|
||||
}
|
||||
|
||||
static int32_t collectUseDatabase(const SName* pName, SHashObj* pDbs) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN] = {0};
|
||||
tNameGetFullDbName(pName, dbFName);
|
||||
(void)tNameGetFullDbName(pName, dbFName);
|
||||
return taosHashPut(pDbs, dbFName, strlen(dbFName), dbFName, sizeof(dbFName));
|
||||
}
|
||||
|
||||
|
@ -1240,7 +1262,8 @@ static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifyOpStm
|
|||
pCxt->needTableTagVal = (NULL != pTagCond);
|
||||
pCxt->missCache = (NULL != pTagCond);
|
||||
} else {
|
||||
pStmt->pTagCond = nodesCloneNode(pTagCond);
|
||||
pStmt->pTagCond = NULL;
|
||||
code = nodesCloneNode(pTagCond, &pStmt->pTagCond);
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pTagCond);
|
||||
|
@ -1357,7 +1380,10 @@ static int32_t getTableDataCxt(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS
|
|||
}
|
||||
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
int32_t code = tNameExtractFullName(&pStmt->targetTableName, tbFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
if (pStmt->usingTableProcessing) {
|
||||
pStmt->pTableMeta->uid = 0;
|
||||
}
|
||||
|
@ -1860,9 +1886,11 @@ static int32_t getStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS
|
|||
}
|
||||
|
||||
bool ctbFirst = true;
|
||||
char ctbFName[TSDB_TABLE_FNAME_LEN];
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
char ctbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
||||
code = tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STableMeta** pCtbMeta = taosHashGet(pStmt->pSubTableHashObj, ctbFName, strlen(ctbFName));
|
||||
ctbFirst = (pCtbMeta == NULL);
|
||||
if (!ctbFirst) {
|
||||
|
@ -1899,23 +1927,31 @@ static int32_t processCtbAutoCreationAndCtbMeta(SInsertParseContext* pCxt, SVnod
|
|||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
char ctbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
||||
code = tNameExtractFullName(&pStbRowsCxt->ctbName, ctbFName);
|
||||
SVgroupInfo vg;
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pComCxt->pTransporter,
|
||||
.requestId = pCxt->pComCxt->requestId,
|
||||
.requestObjRefId = pCxt->pComCxt->requestRid,
|
||||
.mgmtEps = pCxt->pComCxt->mgmtEpSet};
|
||||
code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStbRowsCxt->ctbName, &vg);
|
||||
.requestId = pCxt->pComCxt->requestId,
|
||||
.requestObjRefId = pCxt->pComCxt->requestRid,
|
||||
.mgmtEps = pCxt->pComCxt->mgmtEpSet};
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = catalogGetTableHashVgroup(pCxt->pComCxt->pCatalog, &conn, &pStbRowsCxt->ctbName, &vg);
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
taosHashPut(pStmt->pVgroupsHashObj, (const char*)(&vg.vgId), sizeof(vg.vgId), &vg, sizeof(vg));
|
||||
code = taosHashPut(pStmt->pVgroupsHashObj, (const char*)(&vg.vgId), sizeof(vg.vgId), &vg, sizeof(vg));
|
||||
}
|
||||
STableMeta* pBackup = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pStbRowsCxt->pCtbMeta->uid = taosHashGetSize(pStmt->pSubTableHashObj) + 1;
|
||||
pStbRowsCxt->pCtbMeta->vgId = vg.vgId;
|
||||
|
||||
STableMeta* pBackup = NULL;
|
||||
cloneTableMeta(pStbRowsCxt->pCtbMeta, &pBackup);
|
||||
taosHashPut(pStmt->pSubTableHashObj, ctbFName, strlen(ctbFName), &pBackup, POINTER_BYTES);
|
||||
code = cloneTableMeta(pStbRowsCxt->pCtbMeta, &pBackup);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = taosHashPut(pStmt->pSubTableHashObj, ctbFName, strlen(ctbFName), &pBackup, POINTER_BYTES);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = collectUseTable(&pStbRowsCxt->ctbName, pStmt->pTableNameHashObj);
|
||||
}
|
||||
collectUseTable(&pStbRowsCxt->ctbName, pStmt->pTableNameHashObj);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -2126,7 +2162,7 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt
|
|||
bool gotRow = false;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SToken token;
|
||||
strtolower(pLine, pLine);
|
||||
(void)strtolower(pLine, pLine);
|
||||
const char* pRow = pLine;
|
||||
if (!pStmt->stbSyntax) {
|
||||
code = parseOneRow(pCxt, (const char**)&pRow, rowsDataCxt.pTableDataCxt, &gotRow, &token);
|
||||
|
@ -2137,8 +2173,11 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt
|
|||
if (code == TSDB_CODE_SUCCESS) {
|
||||
SStbRowsDataContext* pStbRowsCxt = rowsDataCxt.pStbRowsCxt;
|
||||
void* pData = pTableDataCxt;
|
||||
taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), &pData,
|
||||
code = taosHashPut(pStmt->pTableCxtHashObj, &pStbRowsCxt->pCtbMeta->uid, sizeof(pStbRowsCxt->pCtbMeta->uid), &pData,
|
||||
POINTER_BYTES);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (code && firstLine) {
|
||||
|
@ -2175,6 +2214,9 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
|||
// init only for file
|
||||
if (NULL == pStmt->pTableCxtHashObj) {
|
||||
pStmt->pTableCxtHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (!pStmt->pTableCxtHashObj) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
int32_t numOfRows = 0;
|
||||
int32_t code = parseCsvFile(pCxt, pStmt, rowsDataCxt, &numOfRows);
|
||||
|
@ -2186,7 +2228,10 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
|||
rowsDataCxt.pTableDataCxt->pData->flags |= SUBMIT_REQ_FROM_FILE;
|
||||
}
|
||||
if (!pStmt->fileProcessing) {
|
||||
taosCloseFile(&pStmt->fp);
|
||||
code = taosCloseFile(&pStmt->fp);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
parserWarn("0x%" PRIx64 " failed to close file.", pCxt->pComCxt->requestId);
|
||||
}
|
||||
} else {
|
||||
parserDebug("0x%" PRIx64 " insert from csv. File is too large, do it in batches.", pCxt->pComCxt->requestId);
|
||||
}
|
||||
|
@ -2198,7 +2243,7 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
|
|||
// just record pTableCxt whose data come from file
|
||||
if (!pStmt->stbSyntax && numOfRows > 0) {
|
||||
void* pData = rowsDataCxt.pTableDataCxt;
|
||||
taosHashPut(pStmt->pTableCxtHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), &pData,
|
||||
code = taosHashPut(pStmt->pTableCxtHashObj, &pStmt->pTableMeta->uid, sizeof(pStmt->pTableMeta->uid), &pData,
|
||||
POINTER_BYTES);
|
||||
}
|
||||
|
||||
|
@ -2209,7 +2254,7 @@ static int32_t parseDataFromFile(SInsertParseContext* pCxt, SVnodeModifyOpStmt*
|
|||
SRowsDataContext rowsDataCxt) {
|
||||
char filePathStr[TSDB_FILENAME_LEN] = {0};
|
||||
if (TK_NK_STRING == pFilePath->type) {
|
||||
trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr));
|
||||
(void)trimString(pFilePath->z, pFilePath->n, filePathStr, sizeof(filePathStr));
|
||||
} else {
|
||||
strncpy(filePathStr, pFilePath->z, pFilePath->n);
|
||||
}
|
||||
|
@ -2275,32 +2320,54 @@ static int32_t constructStbRowsDataContext(SVnodeModifyOpStmt* pStmt, SStbRowsDa
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
tNameAssign(&pStbRowsCxt->stbName, &pStmt->targetTableName);
|
||||
collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj);
|
||||
collectUseDatabase(&pStbRowsCxt->stbName, pStmt->pDbFNameHashObj);
|
||||
int32_t code = collectUseTable(&pStbRowsCxt->stbName, pStmt->pTableNameHashObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = collectUseDatabase(&pStbRowsCxt->stbName, pStmt->pDbFNameHashObj);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pStbRowsCxt->ctbName.type = TSDB_TABLE_NAME_T;
|
||||
pStbRowsCxt->ctbName.acctId = pStbRowsCxt->stbName.acctId;
|
||||
memcpy(pStbRowsCxt->ctbName.dbname, pStbRowsCxt->stbName.dbname, sizeof(pStbRowsCxt->stbName.dbname));
|
||||
|
||||
pStbRowsCxt->ctbName.type = TSDB_TABLE_NAME_T;
|
||||
pStbRowsCxt->ctbName.acctId = pStbRowsCxt->stbName.acctId;
|
||||
memcpy(pStbRowsCxt->ctbName.dbname, pStbRowsCxt->stbName.dbname, sizeof(pStbRowsCxt->stbName.dbname));
|
||||
pStbRowsCxt->pTagCond = pStmt->pTagCond;
|
||||
pStbRowsCxt->pStbMeta = pStmt->pTableMeta;
|
||||
|
||||
pStbRowsCxt->pTagCond = pStmt->pTagCond;
|
||||
pStbRowsCxt->pStbMeta = pStmt->pTableMeta;
|
||||
code = cloneTableMeta(pStbRowsCxt->pStbMeta, &pStbRowsCxt->pCtbMeta);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pStbRowsCxt->pCtbMeta->tableType = TSDB_CHILD_TABLE;
|
||||
pStbRowsCxt->pCtbMeta->suid = pStbRowsCxt->pStbMeta->uid;
|
||||
|
||||
cloneTableMeta(pStbRowsCxt->pStbMeta, &pStbRowsCxt->pCtbMeta);
|
||||
pStbRowsCxt->pCtbMeta->tableType = TSDB_CHILD_TABLE;
|
||||
pStbRowsCxt->pCtbMeta->suid = pStbRowsCxt->pStbMeta->uid;
|
||||
|
||||
pStbRowsCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
pStbRowsCxt->aTagVals = taosArrayInit(8, sizeof(STagVal));
|
||||
|
||||
// col values and bound cols info of STableDataContext is not used
|
||||
pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal));
|
||||
insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals);
|
||||
|
||||
STableComInfo tblInfo = getTableInfo(pStmt->pTableMeta);
|
||||
insInitBoundColsInfo(tblInfo.numOfColumns + tblInfo.numOfTags + 1, &pStbRowsCxt->boundColsInfo);
|
||||
|
||||
*ppStbRowsCxt = pStbRowsCxt;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
pStbRowsCxt->aTagNames = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
if (!pStbRowsCxt->aTagNames) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pStbRowsCxt->aTagVals = taosArrayInit(8, sizeof(STagVal));
|
||||
if (!pStbRowsCxt->aTagVals) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// col values and bound cols info of STableDataContext is not used
|
||||
pStbRowsCxt->aColVals = taosArrayInit(getNumOfColumns(pStbRowsCxt->pStbMeta), sizeof(SColVal));
|
||||
if (!pStbRowsCxt->aColVals)
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = insInitColValues(pStbRowsCxt->pStbMeta, pStbRowsCxt->aColVals);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
STableComInfo tblInfo = getTableInfo(pStmt->pTableMeta);
|
||||
code = insInitBoundColsInfo(tblInfo.numOfColumns + tblInfo.numOfTags + 1, &pStbRowsCxt->boundColsInfo);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*ppStbRowsCxt = pStbRowsCxt;
|
||||
} else {
|
||||
clearStbRowsDataContext(pStbRowsCxt);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t parseInsertStbClauseBottom(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) {
|
||||
|
@ -2535,9 +2602,10 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pS
|
|||
static void destroySubTableHashElem(void* p) { taosMemoryFree(*(STableMeta**)p); }
|
||||
|
||||
static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, SNode** pOutput) {
|
||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT);
|
||||
SVnodeModifyOpStmt* pStmt = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&pStmt);
|
||||
if (NULL == pStmt) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
if (pCxt->pComCxt->pStmtCb) {
|
||||
|
@ -2575,16 +2643,17 @@ static int32_t createVnodeModifOpStmt(SInsertParseContext* pCxt, bool reentry, S
|
|||
}
|
||||
|
||||
static int32_t createInsertQuery(SInsertParseContext* pCxt, SQuery** pOutput) {
|
||||
SQuery* pQuery = (SQuery*)nodesMakeNode(QUERY_NODE_QUERY);
|
||||
SQuery* pQuery = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (NULL == pQuery) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
|
||||
int32_t code = createVnodeModifOpStmt(pCxt, false, &pQuery->pRoot);
|
||||
code = createVnodeModifOpStmt(pCxt, false, &pQuery->pRoot);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = pQuery;
|
||||
} else {
|
||||
|
@ -2601,10 +2670,10 @@ static int32_t checkAuthFromMetaData(const SArray* pUsers, SNode** pTagCond) {
|
|||
SMetaRes* pRes = taosArrayGet(pUsers, 0);
|
||||
if (TSDB_CODE_SUCCESS == pRes->code) {
|
||||
SUserAuthRes* pAuth = pRes->pRes;
|
||||
if (NULL != pAuth->pCond) {
|
||||
*pTagCond = nodesCloneNode(pAuth->pCond[AUTH_RES_BASIC]);
|
||||
pRes->code = nodesCloneNode(pAuth->pCond[AUTH_RES_BASIC], pTagCond);
|
||||
if (TSDB_CODE_SUCCESS == pRes->code) {
|
||||
return pAuth->pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
}
|
||||
return pAuth->pass[AUTH_RES_BASIC] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
}
|
||||
return pRes->code;
|
||||
}
|
||||
|
@ -2649,10 +2718,16 @@ static int32_t buildTagNameFromMeta(STableMeta* pMeta, SArray** pTagName) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SSchema* pSchema = getTableTagSchema(pMeta);
|
||||
int32_t code = 0;
|
||||
for (int32_t i = 0; i < pMeta->tableInfo.numOfTags; ++i) {
|
||||
taosArrayPush(*pTagName, pSchema[i].name);
|
||||
if (NULL == taosArrayPush(*pTagName, pSchema[i].name)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosArrayDestroy(*pTagName);
|
||||
*pTagName = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkSubtablePrivilegeForTable(const SArray* pTables, SVnodeModifyOpStmt* pStmt) {
|
||||
|
@ -2740,17 +2815,19 @@ static int32_t resetVnodeModifOpStmt(SInsertParseContext* pCxt, SQuery* pQuery)
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot;
|
||||
|
||||
(*pCxt->pComCxt->pStmtCb->getExecInfoFn)(pCxt->pComCxt->pStmtCb->pStmt, &pStmt->pVgroupsHashObj,
|
||||
&pStmt->pTableBlockHashObj);
|
||||
if (NULL == pStmt->pVgroupsHashObj) {
|
||||
pStmt->pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
}
|
||||
if (NULL == pStmt->pTableBlockHashObj) {
|
||||
pStmt->pTableBlockHashObj =
|
||||
code = (*pCxt->pComCxt->pStmtCb->getExecInfoFn)(pCxt->pComCxt->pStmtCb->pStmt, &pStmt->pVgroupsHashObj,
|
||||
&pStmt->pTableBlockHashObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == pStmt->pVgroupsHashObj) {
|
||||
pStmt->pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||
}
|
||||
if (NULL == pStmt->pTableBlockHashObj) {
|
||||
pStmt->pTableBlockHashObj =
|
||||
taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
}
|
||||
if (NULL == pStmt->pVgroupsHashObj || NULL == pStmt->pTableBlockHashObj) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (NULL == pStmt->pVgroupsHashObj || NULL == pStmt->pTableBlockHashObj) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2778,28 +2855,45 @@ static int32_t initInsertQuery(SInsertParseContext* pCxt, SCatalogReq* pCatalogR
|
|||
|
||||
static int32_t setRefreshMeta(SQuery* pQuery) {
|
||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)pQuery->pRoot;
|
||||
int32_t code = 0;
|
||||
|
||||
if (taosHashGetSize(pStmt->pTableNameHashObj) > 0) {
|
||||
taosArrayDestroy(pQuery->pTableList);
|
||||
pQuery->pTableList = taosArrayInit(taosHashGetSize(pStmt->pTableNameHashObj), sizeof(SName));
|
||||
SName* pTable = taosHashIterate(pStmt->pTableNameHashObj, NULL);
|
||||
while (NULL != pTable) {
|
||||
taosArrayPush(pQuery->pTableList, pTable);
|
||||
pTable = taosHashIterate(pStmt->pTableNameHashObj, pTable);
|
||||
if (!pQuery->pTableList) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
SName* pTable = taosHashIterate(pStmt->pTableNameHashObj, NULL);
|
||||
while (NULL != pTable) {
|
||||
if (NULL == taosArrayPush(pQuery->pTableList, pTable)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosHashCancelIterate(pStmt->pTableNameHashObj, pTable);
|
||||
break;
|
||||
}
|
||||
pTable = taosHashIterate(pStmt->pTableNameHashObj, pTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (taosHashGetSize(pStmt->pDbFNameHashObj) > 0) {
|
||||
if (TSDB_CODE_SUCCESS == code && taosHashGetSize(pStmt->pDbFNameHashObj) > 0) {
|
||||
taosArrayDestroy(pQuery->pDbList);
|
||||
pQuery->pDbList = taosArrayInit(taosHashGetSize(pStmt->pDbFNameHashObj), TSDB_DB_FNAME_LEN);
|
||||
char* pDb = taosHashIterate(pStmt->pDbFNameHashObj, NULL);
|
||||
while (NULL != pDb) {
|
||||
taosArrayPush(pQuery->pDbList, pDb);
|
||||
pDb = taosHashIterate(pStmt->pDbFNameHashObj, pDb);
|
||||
if (!pQuery->pDbList) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
char* pDb = taosHashIterate(pStmt->pDbFNameHashObj, NULL);
|
||||
while (NULL != pDb) {
|
||||
if (NULL == taosArrayPush(pQuery->pDbList, pDb)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosHashCancelIterate(pStmt->pDbFNameHashObj, pDb);
|
||||
break;
|
||||
}
|
||||
pDb = taosHashIterate(pStmt->pDbFNameHashObj, pDb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
// INSERT INTO
|
||||
|
@ -2868,7 +2962,11 @@ static int32_t buildInsertTableReq(SName* pName, SArray** pTables) {
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
taosArrayPush(*pTables, pName);
|
||||
if (NULL == taosArrayPush(*pTables, pName)) {
|
||||
taosArrayDestroy(*pTables);
|
||||
*pTables = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2881,11 +2979,13 @@ static int32_t buildInsertDbReq(SName* pName, SArray** pDbs) {
|
|||
}
|
||||
|
||||
STablesReq req = {0};
|
||||
tNameGetFullDbName(pName, req.dbFName);
|
||||
buildInsertTableReq(pName, &req.pTables);
|
||||
taosArrayPush(*pDbs, &req);
|
||||
(void)tNameGetFullDbName(pName, req.dbFName);
|
||||
int32_t code = buildInsertTableReq(pName, &req.pTables);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL == taosArrayPush(*pDbs, &req)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t buildInsertUserAuthReq(const char* pUser, SName* pName, SArray** pUserAuth) {
|
||||
|
@ -2897,7 +2997,11 @@ static int32_t buildInsertUserAuthReq(const char* pUser, SName* pName, SArray**
|
|||
SUserAuthInfo userAuth = {.type = AUTH_TYPE_WRITE};
|
||||
snprintf(userAuth.user, sizeof(userAuth.user), "%s", pUser);
|
||||
memcpy(&userAuth.tbName, pName, sizeof(SName));
|
||||
taosArrayPush(*pUserAuth, &userAuth);
|
||||
if (NULL == taosArrayPush(*pUserAuth, &userAuth)) {
|
||||
taosArrayDestroy(*pUserAuth);
|
||||
*pUserAuth = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,17 @@ int32_t qCloneCurrentTbData(STableDataCxt* pDataBlock, SSubmitTbData** pData) {
|
|||
|
||||
*pNew = *pDataBlock->pData;
|
||||
|
||||
cloneSVreateTbReq(pDataBlock->pData->pCreateTbReq, &pNew->pCreateTbReq);
|
||||
int32_t code = cloneSVreateTbReq(pDataBlock->pData->pCreateTbReq, &pNew->pCreateTbReq);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosMemoryFreeClear(*pData);
|
||||
return code;
|
||||
}
|
||||
pNew->aCol = taosArrayDup(pDataBlock->pData->aCol, NULL);
|
||||
if (!pNew->aCol) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFreeClear(*pData);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t colNum = taosArrayGetSize(pNew->aCol);
|
||||
for (int32_t i = 0; i < colNum; ++i) {
|
||||
|
@ -152,7 +161,10 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
|||
goto end;
|
||||
}
|
||||
}
|
||||
taosArrayPush(tagName, pTagSchema->name);
|
||||
if (NULL == taosArrayPush(tagName, pTagSchema->name)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
if (pTagSchema->type == TSDB_DATA_TYPE_JSON) {
|
||||
if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) {
|
||||
code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer);
|
||||
|
@ -198,7 +210,10 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch
|
|||
} else {
|
||||
memcpy(&val.i64, bind[c].buffer, colLen);
|
||||
}
|
||||
taosArrayPush(pTagArray, &val);
|
||||
if (NULL == taosArrayPush(pTagArray, &val)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,7 +448,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, SArray* pCols, TAOS_MULTI_BIND* bi
|
|||
pBind = bind;
|
||||
}
|
||||
|
||||
tColDataAddValueByBind(pCol, pBind, IS_VAR_DATA_TYPE(pColSchema->type) ? pColSchema->bytes - VARSTR_HEADER_SIZE : -1);
|
||||
code = tColDataAddValueByBind(pCol, pBind, IS_VAR_DATA_TYPE(pColSchema->type) ? pColSchema->bytes - VARSTR_HEADER_SIZE : -1);
|
||||
|
||||
qDebug("stmt col %d bind %d rows data", colIdx, rowNum);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ int32_t insCreateSName(SName* pName, SToken* pTableName, int32_t acctId, const c
|
|||
|
||||
char tbname[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
strncpy(tbname, p + 1, tbLen);
|
||||
/*tbLen = */ strdequote(tbname);
|
||||
/*tbLen = */ (void)strdequote(tbname);
|
||||
|
||||
code = tNameFromString(pName, tbname, T_NAME_TABLE);
|
||||
if (code != 0) {
|
||||
|
@ -110,7 +110,7 @@ int32_t insCreateSName(SName* pName, SToken* pTableName, int32_t acctId, const c
|
|||
|
||||
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
strncpy(name, pTableName->z, pTableName->n);
|
||||
strdequote(name);
|
||||
(void)strdequote(name);
|
||||
|
||||
if (dbName == NULL) {
|
||||
return buildInvalidOperationMsg(pMsgBuf, msg3);
|
||||
|
@ -167,15 +167,20 @@ static void initBoundCols(int32_t ncols, int16_t* pBoundCols) {
|
|||
}
|
||||
}
|
||||
|
||||
static void initColValues(STableMeta* pTableMeta, SArray* pValues) {
|
||||
static int32_t initColValues(STableMeta* pTableMeta, SArray* pValues) {
|
||||
SSchema* pSchemas = getTableColumnSchema(pTableMeta);
|
||||
int32_t code = 0;
|
||||
for (int32_t i = 0; i < pTableMeta->tableInfo.numOfColumns; ++i) {
|
||||
SColVal val = COL_VAL_NONE(pSchemas[i].colId, pSchemas[i].type);
|
||||
taosArrayPush(pValues, &val);
|
||||
if (NULL == taosArrayPush(pValues, &val)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
void insInitColValues(STableMeta* pTableMeta, SArray* aColValues) { initColValues(pTableMeta, aColValues); }
|
||||
int32_t insInitColValues(STableMeta* pTableMeta, SArray* aColValues) { return initColValues(pTableMeta, aColValues); }
|
||||
|
||||
int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo* pInfo) {
|
||||
pInfo->numOfCols = numOfBound;
|
||||
|
@ -253,7 +258,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat
|
|||
if (NULL == pTableCxt->pValues) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
} else {
|
||||
initColValues(pTableMeta, pTableCxt->pValues);
|
||||
code = initColValues(pTableMeta, pTableCxt->pValues);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -281,9 +286,12 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pOutput = pTableCxt;
|
||||
qDebug("tableDataCxt created, code:%d, uid:%" PRId64 ", vgId:%d", code, pTableMeta->uid, pTableMeta->vgId);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = pTableCxt;
|
||||
qDebug("tableDataCxt created, code:%d, uid:%" PRId64 ", vgId:%d", code, pTableMeta->uid, pTableMeta->vgId);
|
||||
} else {
|
||||
insDestroyTableDataCxt(pTableCxt);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -301,24 +309,27 @@ static int32_t rebuildTableData(SSubmitTbData* pSrc, SSubmitTbData** pDst) {
|
|||
pTmp->pCreateTbReq = NULL;
|
||||
if (pTmp->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) {
|
||||
if (pSrc->pCreateTbReq) {
|
||||
cloneSVreateTbReq(pSrc->pCreateTbReq, &pTmp->pCreateTbReq);
|
||||
code = cloneSVreateTbReq(pSrc->pCreateTbReq, &pTmp->pCreateTbReq);
|
||||
} else {
|
||||
pTmp->flags &= ~SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTmp->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||
pTmp->aCol = taosArrayInit(128, sizeof(SColData));
|
||||
if (NULL == pTmp->aCol) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pTmp);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (pTmp->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||
pTmp->aCol = taosArrayInit(128, sizeof(SColData));
|
||||
if (NULL == pTmp->aCol) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pTmp);
|
||||
}
|
||||
} else {
|
||||
pTmp->aRowP = taosArrayInit(128, POINTER_BYTES);
|
||||
if (NULL == pTmp->aRowP) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pTmp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pTmp->aRowP = taosArrayInit(128, POINTER_BYTES);
|
||||
if (NULL == pTmp->aRowP) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
taosMemoryFree(pTmp);
|
||||
}
|
||||
taosMemoryFree(pTmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,16 +458,19 @@ static int32_t fillVgroupDataCxt(STableDataCxt* pTableCxt, SVgroupDataCxt* pVgCx
|
|||
}
|
||||
|
||||
// push data to submit, rebuild empty data for next submit
|
||||
taosArrayPush(pVgCxt->pData->aSubmitTbData, pTableCxt->pData);
|
||||
if (NULL == taosArrayPush(pVgCxt->pData->aSubmitTbData, pTableCxt->pData)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = 0;
|
||||
if (isRebuild) {
|
||||
rebuildTableData(pTableCxt->pData, &pTableCxt->pData);
|
||||
code = rebuildTableData(pTableCxt->pData, &pTableCxt->pData);
|
||||
} else if (clear) {
|
||||
taosMemoryFreeClear(pTableCxt->pData);
|
||||
}
|
||||
|
||||
qDebug("add tableDataCxt uid:%" PRId64 " to vgId:%d", pTableCxt->pMeta->uid, pVgCxt->vgId);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHash, SArray* pVgroupList,
|
||||
|
@ -474,7 +488,11 @@ static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHa
|
|||
pVgCxt->vgId = pTableCxt->pMeta->vgId;
|
||||
int32_t code = taosHashPut(pVgroupHash, &pVgCxt->vgId, sizeof(pVgCxt->vgId), &pVgCxt, POINTER_BYTES);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
taosArrayPush(pVgroupList, &pVgCxt);
|
||||
if (NULL == taosArrayPush(pVgroupList, &pVgCxt)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
insDestroyVgroupDataCxt(pVgCxt);
|
||||
return code;
|
||||
}
|
||||
// uDebug("td23101 2vgId:%d, uid:%" PRIu64, pVgCxt->vgId, pTableCxt->pMeta->uid);
|
||||
*pOutput = pVgCxt;
|
||||
} else {
|
||||
|
@ -531,7 +549,10 @@ int32_t insGetStmtTableVgUid(SHashObj* pAllVgHash, SStbInterlaceInfo* pBuildInfo
|
|||
|
||||
if (NULL == pTbInfo) {
|
||||
SName sname;
|
||||
qCreateSName(&sname, pTbData->tbName, pBuildInfo->acctId, pBuildInfo->dbname, NULL, 0);
|
||||
code = qCreateSName(&sname, pTbData->tbName, pBuildInfo->acctId, pBuildInfo->dbname, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SRequestConnInfo conn = {.pTrans = pBuildInfo->transport,
|
||||
|
@ -553,9 +574,10 @@ int32_t insGetStmtTableVgUid(SHashObj* pAllVgHash, SStbInterlaceInfo* pBuildInfo
|
|||
*vgId = pTableMeta->vgId;
|
||||
|
||||
STableVgUid tbInfo = {.uid = *uid, .vgid = *vgId};
|
||||
tSimpleHashPut(pBuildInfo->pTableHash, pTbData->tbName, strlen(pTbData->tbName), &tbInfo, sizeof(tbInfo));
|
||||
|
||||
code = insTryAddTableVgroupInfo(pAllVgHash, pBuildInfo, vgId, pTbData, &sname);
|
||||
code = tSimpleHashPut(pBuildInfo->pTableHash, pTbData->tbName, strlen(pTbData->tbName), &tbInfo, sizeof(tbInfo));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = insTryAddTableVgroupInfo(pAllVgHash, pBuildInfo, vgId, pTbData, &sname);
|
||||
}
|
||||
|
||||
taosMemoryFree(pTableMeta);
|
||||
} else {
|
||||
|
|
|
@ -352,22 +352,23 @@ static const char isIdChar[] = {
|
|||
|
||||
static void* keywordHashTable = NULL;
|
||||
|
||||
static void doInitKeywordsTable(void) {
|
||||
static int32_t doInitKeywordsTable(void) {
|
||||
int numOfEntries = tListLen(keywordTable);
|
||||
|
||||
keywordHashTable = taosHashInit(numOfEntries, MurmurHash3_32, true, false);
|
||||
for (int32_t i = 0; i < numOfEntries; i++) {
|
||||
keywordTable[i].len = (uint8_t)strlen(keywordTable[i].name);
|
||||
void* ptr = &keywordTable[i];
|
||||
taosHashPut(keywordHashTable, keywordTable[i].name, keywordTable[i].len, (void*)&ptr, POINTER_BYTES);
|
||||
int32_t code = taosHashPut(keywordHashTable, keywordTable[i].name, keywordTable[i].len, (void*)&ptr, POINTER_BYTES);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosHashCleanup(keywordHashTable);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static TdThreadOnce keywordsHashTableInit = PTHREAD_ONCE_INIT;
|
||||
|
||||
static int32_t tKeywordCode(const char* z, int n) {
|
||||
taosThreadOnce(&keywordsHashTableInit, doInitKeywordsTable);
|
||||
|
||||
char key[512] = {0};
|
||||
if (n > tListLen(key)) { // too long token, can not be any other token type
|
||||
return TK_NK_ID;
|
||||
|
@ -792,7 +793,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreC
|
|||
|
||||
// check the table name is '?', db.?asf is not valid.
|
||||
if (TK_NK_QUESTION == type) {
|
||||
tGetToken(&str[*i + t0.n + 2], &type);
|
||||
(void)tGetToken(&str[*i + t0.n + 2], &type);
|
||||
if (TK_NK_SPACE != type) {
|
||||
t0.type = TK_NK_ILLEGAL;
|
||||
t0.n = 0;
|
||||
|
@ -821,6 +822,10 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreC
|
|||
|
||||
bool taosIsKeyWordToken(const char* z, int32_t len) { return (tKeywordCode((char*)z, len) != TK_NK_ID); }
|
||||
|
||||
int32_t taosInitKeywordsTable() {
|
||||
return doInitKeywordsTable();
|
||||
}
|
||||
|
||||
void taosCleanupKeywordsTable() {
|
||||
void* m = keywordHashTable;
|
||||
if (m != NULL && atomic_val_compare_exchange_ptr(&keywordHashTable, m, 0) == m) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -233,7 +233,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
|
|||
int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, errCode);
|
||||
vsnprintf(pBuf->buf, pBuf->len, getSyntaxErrFormat(errCode), vArgList);
|
||||
(void)vsnprintf(pBuf->buf, pBuf->len, getSyntaxErrFormat(errCode), vArgList);
|
||||
va_end(vArgList);
|
||||
return errCode;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
|
|||
int32_t generateSyntaxErrMsgExt(SMsgBuf* pBuf, int32_t errCode, const char* pFormat, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, pFormat);
|
||||
vsnprintf(pBuf->buf, pBuf->len, pFormat, vArgList);
|
||||
(void)vsnprintf(pBuf->buf, pBuf->len, pFormat, vArgList);
|
||||
va_end(vArgList);
|
||||
return errCode;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ int32_t buildInvalidOperationMsg(SMsgBuf* pBuf, const char* msg) {
|
|||
int32_t buildInvalidOperationMsgExt(SMsgBuf* pBuf, const char* pFormat, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, pFormat);
|
||||
vsnprintf(pBuf->buf, pBuf->len, pFormat, vArgList);
|
||||
(void)vsnprintf(pBuf->buf, pBuf->len, pFormat, vArgList);
|
||||
va_end(vArgList);
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
@ -423,6 +423,10 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
|||
}
|
||||
|
||||
keyHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false);
|
||||
if (!keyHash) {
|
||||
retCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
cJSON* item = cJSON_GetArrayItem(root, i);
|
||||
if (!item) {
|
||||
|
@ -448,8 +452,11 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
|||
STagVal val = {0};
|
||||
// strcpy(val.colName, colName);
|
||||
val.pKey = jsonKey;
|
||||
taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||
retCode = taosHashPut(keyHash, jsonKey, keyLen, &keyLen,
|
||||
CHAR_BYTES); // add key to hash to remove dumplicate, value is useless
|
||||
if (TSDB_CODE_SUCCESS != retCode) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (item->type == cJSON_String) { // add json value format: type|data
|
||||
char* jsonValue = item->valuestring;
|
||||
|
@ -486,7 +493,10 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
|||
retCode = buildSyntaxErrMsg(pMsgBuf, "invalidate json value", json);
|
||||
goto end;
|
||||
}
|
||||
taosArrayPush(pTagVals, &val);
|
||||
if (NULL == taosArrayPush(pTagVals, &val)) {
|
||||
retCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -534,10 +544,11 @@ static int32_t getInsTagsTableTargetNameFromOp(int32_t acctId, SOperatorNode* pO
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void getInsTagsTableTargetObjName(int32_t acctId, SNode* pNode, SName* pName) {
|
||||
static int32_t getInsTagsTableTargetObjName(int32_t acctId, SNode* pNode, SName* pName) {
|
||||
if (QUERY_NODE_OPERATOR == nodeType(pNode)) {
|
||||
getInsTagsTableTargetNameFromOp(acctId, (SOperatorNode*)pNode, pName);
|
||||
return getInsTagsTableTargetNameFromOp(acctId, (SOperatorNode*)pNode, pName);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t getInsTagsTableTargetNameFromCond(int32_t acctId, SLogicConditionNode* pCond, SName* pName) {
|
||||
|
@ -546,7 +557,12 @@ static int32_t getInsTagsTableTargetNameFromCond(int32_t acctId, SLogicCondition
|
|||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pCond->pParameterList) { getInsTagsTableTargetObjName(acctId, pNode, pName); }
|
||||
FOREACH(pNode, pCond->pParameterList) {
|
||||
int32_t code = getInsTagsTableTargetObjName(acctId, pNode, pName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
if ('\0' == pName->dbname[0]) {
|
||||
pName->type = 0;
|
||||
}
|
||||
|
@ -634,8 +650,18 @@ static int32_t buildTableReq(SHashObj* pTablesHash, SArray** pTables) {
|
|||
char fullName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
strncpy(fullName, pKey, len);
|
||||
SName name = {0};
|
||||
tNameFromString(&name, fullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
taosArrayPush(*pTables, &name);
|
||||
int32_t code = tNameFromString(&name, fullName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == taosArrayPush(*pTables, &name)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosHashCancelIterate(pTablesHash, p);
|
||||
taosArrayDestroy(*pTables);
|
||||
*pTables = NULL;
|
||||
return code;
|
||||
}
|
||||
p = taosHashIterate(pTablesHash, p);
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +680,12 @@ static int32_t buildDbReq(SHashObj* pDbsHash, SArray** pDbs) {
|
|||
char* pKey = taosHashGetKey(p, &len);
|
||||
char fullName[TSDB_DB_FNAME_LEN] = {0};
|
||||
strncpy(fullName, pKey, len);
|
||||
taosArrayPush(*pDbs, fullName);
|
||||
if (NULL == taosArrayPush(*pDbs, fullName)) {
|
||||
taosHashCancelIterate(pDbsHash, p);
|
||||
taosArrayDestroy(*pDbs);
|
||||
*pDbs = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
p = taosHashIterate(pDbsHash, p);
|
||||
}
|
||||
}
|
||||
|
@ -673,8 +704,18 @@ static int32_t buildTableReqFromDb(SHashObj* pDbsHash, SArray** pDbs) {
|
|||
while (NULL != p) {
|
||||
STablesReq req = {0};
|
||||
strcpy(req.dbFName, p->dbFName);
|
||||
buildTableReq(p->pTables, &req.pTables);
|
||||
taosArrayPush(*pDbs, &req);
|
||||
int32_t code = buildTableReq(p->pTables, &req.pTables);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == taosArrayPush(*pDbs, &req)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
taosHashCancelIterate(pDbsHash, p);
|
||||
taosArrayDestroy(*pDbs);
|
||||
*pDbs = NULL;
|
||||
return code;
|
||||
}
|
||||
p = taosHashIterate(pDbsHash, p);
|
||||
}
|
||||
}
|
||||
|
@ -695,7 +736,12 @@ static int32_t buildUserAuthReq(SHashObj* pUserAuthHash, SArray** pUserAuth) {
|
|||
strncpy(key, pKey, len);
|
||||
SUserAuthInfo userAuth = {0};
|
||||
stringToUserAuth(key, len, &userAuth);
|
||||
taosArrayPush(*pUserAuth, &userAuth);
|
||||
if (NULL == taosArrayPush(*pUserAuth, &userAuth)) {
|
||||
taosHashCancelIterate(pUserAuthHash, p);
|
||||
taosArrayDestroy(*pUserAuth);
|
||||
*pUserAuth = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
p = taosHashIterate(pUserAuthHash, p);
|
||||
}
|
||||
}
|
||||
|
@ -714,7 +760,12 @@ static int32_t buildUdfReq(SHashObj* pUdfHash, SArray** pUdf) {
|
|||
char* pFunc = taosHashGetKey(p, &len);
|
||||
char func[TSDB_FUNC_NAME_LEN] = {0};
|
||||
strncpy(func, pFunc, len);
|
||||
taosArrayPush(*pUdf, func);
|
||||
if (NULL == taosArrayPush(*pUdf, func)) {
|
||||
taosHashCancelIterate(pUdfHash, p);
|
||||
taosArrayDestroy(*pUdf);
|
||||
*pUdf = NULL;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
p = taosHashIterate(pUdfHash, p);
|
||||
}
|
||||
}
|
||||
|
@ -762,10 +813,11 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
|
|||
return code;
|
||||
}
|
||||
|
||||
SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint) {
|
||||
SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT);
|
||||
int32_t createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint, SNode** ppSelect) {
|
||||
SSelectStmt* select = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_SELECT_STMT, (SNode**)&select);
|
||||
if (NULL == select) {
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
select->isDistinct = isDistinct;
|
||||
select->pProjectionList = pProjectionList;
|
||||
|
@ -777,7 +829,8 @@ SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode*
|
|||
select->timeRange = TSWINDOW_INITIALIZER;
|
||||
select->pHint = pHint;
|
||||
select->lastProcessByRowFuncId = -1;
|
||||
return (SNode*)select;
|
||||
*ppSelect = (SNode*)select;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t putMetaDataToHash(const char* pKey, int32_t len, const SArray* pData, int32_t index, SHashObj** pHash) {
|
||||
|
@ -806,7 +859,10 @@ static int32_t putTableDataToCache(const SArray* pTableReq, const SArray* pTable
|
|||
int32_t ntables = taosArrayGetSize(pTableReq);
|
||||
for (int32_t i = 0; i < ntables; ++i) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(taosArrayGet(pTableReq, i), fullName);
|
||||
int32_t code = tNameExtractFullName(taosArrayGet(pTableReq, i), fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != putMetaDataToHash(fullName, strlen(fullName), pTableData, i, pTable)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -834,7 +890,10 @@ static int32_t putDbTableDataToCache(const SArray* pDbReq, const SArray* pTableD
|
|||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(taosArrayGet(pReq->pTables, j), fullName);
|
||||
int32_t code = tNameExtractFullName(taosArrayGet(pReq->pTables, j), fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != putMetaDataToHash(fullName, strlen(fullName), pTableData, tableNo, pTable)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -962,9 +1021,12 @@ int32_t reserveTableMetaInCacheExt(const SName* pName, SParseMetaCache* pMetaCac
|
|||
|
||||
int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableMeta* pTableMeta = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableMeta, (void**)&pTableMeta);
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableMeta, (void**)&pTableMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pMeta = tableMetaDup(pTableMeta);
|
||||
if (NULL == *pMeta) {
|
||||
|
@ -996,9 +1058,12 @@ int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta) {
|
|||
|
||||
int32_t getViewMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
SViewMeta* pViewMeta = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pViews, (void**)&pViewMeta);
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pViews, (void**)&pViewMeta);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = buildTableMetaFromViewMeta(pMeta, pViewMeta);
|
||||
}
|
||||
|
@ -1044,9 +1109,12 @@ int32_t reserveTableVgroupInCacheExt(const SName* pName, SParseMetaCache* pMetaC
|
|||
|
||||
int32_t getTableVgroupFromCache(SParseMetaCache* pMetaCache, const SName* pName, SVgroupInfo* pVgroup) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
SVgroupInfo* pVg = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableVgroup, (void**)&pVg);
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableVgroup, (void**)&pVg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
memcpy(pVgroup, pVg, sizeof(SVgroupInfo));
|
||||
}
|
||||
|
@ -1178,9 +1246,10 @@ int32_t reserveTSMAInfoInCache(int32_t acctId, const char* pDb, const char* pTsm
|
|||
|
||||
int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) return code;;
|
||||
SArray* pSmaIndexes = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableIndex, (void**)&pSmaIndexes);
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableIndex, (void**)&pSmaIndexes);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSmaIndexes) {
|
||||
*pIndexes = smaIndexesDup(pSmaIndexes);
|
||||
if (NULL == *pIndexes) {
|
||||
|
@ -1192,9 +1261,12 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
|
|||
|
||||
int32_t getTableTsmasFromCache(SParseMetaCache* pMetaCache, const SName* pTbName, SArray** pTsmas) {
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pTbName, tbFName);
|
||||
int32_t code = tNameExtractFullName(pTbName, tbFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableTSMAInfoRsp* pTsmasRsp = NULL;
|
||||
int32_t code = getMetaDataFromHash(tbFName, strlen(tbFName), pMetaCache->pTableTSMAs, (void**)&pTsmasRsp);
|
||||
code = getMetaDataFromHash(tbFName, strlen(tbFName), pMetaCache->pTableTSMAs, (void**)&pTsmasRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && pTsmasRsp) {
|
||||
*pTsmas = pTsmasRsp->pTsmas;
|
||||
}
|
||||
|
@ -1203,9 +1275,12 @@ int32_t getTableTsmasFromCache(SParseMetaCache* pMetaCache, const SName* pTbName
|
|||
|
||||
int32_t getTsmaFromCache(SParseMetaCache* pMetaCache, const SName* pTsmaName, STableTSMAInfo** pTsma) {
|
||||
char tsmaFName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pTsmaName, tsmaFName);
|
||||
int32_t code = tNameExtractFullName(pTsmaName, tsmaFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableTSMAInfoRsp* pTsmaRsp = NULL;
|
||||
int32_t code = getMetaDataFromHash(tsmaFName, strlen(tsmaFName), pMetaCache->pTSMAs, (void**)&pTsmaRsp);
|
||||
code = getMetaDataFromHash(tsmaFName, strlen(tsmaFName), pMetaCache->pTSMAs, (void**)&pTsmaRsp);
|
||||
if (TSDB_CODE_SUCCESS == code && pTsmaRsp) {
|
||||
ASSERT(pTsmaRsp->pTsmas->size == 1);
|
||||
*pTsma = taosArrayGetP(pTsmaRsp->pTsmas, 0);
|
||||
|
@ -1250,9 +1325,12 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
|
|||
|
||||
int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput) {
|
||||
char fullName[TSDB_TABLE_FNAME_LEN];
|
||||
tNameExtractFullName(pName, fullName);
|
||||
int32_t code = tNameExtractFullName(pName, fullName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
STableCfg* pCfg = NULL;
|
||||
int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
||||
code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg);
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pCfg) {
|
||||
*pOutput = tableCfgDup(pCfg);
|
||||
if (NULL == *pOutput) {
|
||||
|
|
|
@ -283,7 +283,7 @@ int32_t qParseSqlSyntax(SParseContext* pCxt, SQuery** pQuery, struct SCatalogReq
|
|||
code = parseQuerySyntax(pCxt, pQuery, pCatalogReq);
|
||||
}
|
||||
}
|
||||
nodesReleaseAllocator(pCxt->allocatorId);
|
||||
(void)nodesReleaseAllocator(pCxt->allocatorId);
|
||||
terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ int32_t qAnalyseSqlSemantic(SParseContext* pCxt, const struct SCatalogReq* pCata
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = analyseSemantic(pCxt, pQuery, &metaCache);
|
||||
}
|
||||
nodesReleaseAllocator(pCxt->allocatorId);
|
||||
(void)nodesReleaseAllocator(pCxt->allocatorId);
|
||||
destoryParseMetaCache(&metaCache, false);
|
||||
terrno = code;
|
||||
return code;
|
||||
|
@ -410,6 +410,10 @@ int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int32_t qInitKeywordsTable() {
|
||||
return taosInitKeywordsTable();
|
||||
}
|
||||
|
||||
void qCleanupKeywordsTable() { taosCleanupKeywordsTable(); }
|
||||
|
||||
int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx) {
|
||||
|
@ -429,9 +433,10 @@ int32_t qStmtBindParams(SQuery* pQuery, TAOS_MULTI_BIND* pParams, int32_t colIdx
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code && (colIdx < 0 || colIdx + 1 == pQuery->placeholderNum)) {
|
||||
nodesDestroyNode(pQuery->pRoot);
|
||||
pQuery->pRoot = nodesCloneNode(pQuery->pPrepareRoot);
|
||||
pQuery->pRoot = NULL;
|
||||
code = nodesCloneNode(pQuery->pPrepareRoot, &pQuery->pRoot);
|
||||
if (NULL == pQuery->pRoot) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = code;
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
|
|
@ -46,12 +46,12 @@ class TableBuilder : public ITableBuilder {
|
|||
schema()->vgId = vgid;
|
||||
|
||||
SVgroupInfo vgroup = {vgid, 0, 0, {0}, 0};
|
||||
addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030);
|
||||
addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030);
|
||||
addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030);
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_1", 6030));
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_2", 6030));
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&vgroup.epSet, "dnode_3", 6030));
|
||||
vgroup.epSet.inUse = 0;
|
||||
|
||||
meta_->vgs.emplace_back(vgroup);
|
||||
(void)meta_->vgs.emplace_back(vgroup);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class MockCatalogServiceImpl {
|
|||
std::unique_ptr<STableMeta> table;
|
||||
|
||||
char db[TSDB_DB_NAME_LEN] = {0};
|
||||
tNameGetDbName(pTableName, db);
|
||||
(void)tNameGetDbName(pTableName, db);
|
||||
|
||||
const char* tname = tNameGetTableName(pTableName);
|
||||
int32_t code = copyTableSchemaMeta(db, tname, &table);
|
||||
|
@ -140,7 +140,7 @@ class MockCatalogServiceImpl {
|
|||
|
||||
int32_t catalogGetTableDistVgInfo(const SName* pTableName, SArray** vgList) const {
|
||||
char db[TSDB_DB_NAME_LEN] = {0};
|
||||
tNameGetDbName(pTableName, db);
|
||||
(void)tNameGetDbName(pTableName, db);
|
||||
return copyTableVgroup(db, tNameGetTableName(pTableName), vgList);
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,10 @@ class MockCatalogServiceImpl {
|
|||
|
||||
int32_t catalogGetTableIndex(const SName* pTableName, SArray** pIndexes) const {
|
||||
char tbFName[TSDB_TABLE_FNAME_LEN] = {0};
|
||||
tNameExtractFullName(pTableName, tbFName);
|
||||
int32_t code = tNameExtractFullName(pTableName, tbFName);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
auto it = index_.find(tbFName);
|
||||
if (index_.end() == it) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -183,15 +186,26 @@ class MockCatalogServiceImpl {
|
|||
for (const auto& index : it->second) {
|
||||
STableIndexInfo info;
|
||||
|
||||
taosArrayPush(*pIndexes, copyTableIndexInfo(&info, &index));
|
||||
if (nullptr == taosArrayPush(*pIndexes, copyTableIndexInfo(&info, &index))) {
|
||||
taosArrayDestroy(*pIndexes);
|
||||
*pIndexes = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t catalogGetDnodeList(SArray** pDnodes) const {
|
||||
*pDnodes = taosArrayInit(dnode_.size(), sizeof(SEpSet));
|
||||
if (!pDnodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (const auto& dnode : dnode_) {
|
||||
taosArrayPush(*pDnodes, &dnode.second);
|
||||
if (nullptr == taosArrayPush(*pDnodes, &dnode.second)) {
|
||||
taosArrayDestroy(*pDnodes);
|
||||
*pDnodes = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -252,9 +266,9 @@ class MockCatalogServiceImpl {
|
|||
SVgroupInfo vgroup = {vgid, 0, 0, {0}, 0};
|
||||
genEpSet(&vgroup.epSet);
|
||||
|
||||
meta_[db][tbname]->vgs.emplace_back(vgroup);
|
||||
(void)meta_[db][tbname]->vgs.emplace_back(vgroup);
|
||||
// super table
|
||||
meta_[db][stbname]->vgs.emplace_back(vgroup);
|
||||
(void)meta_[db][stbname]->vgs.emplace_back(vgroup);
|
||||
}
|
||||
|
||||
void showTables() const {
|
||||
|
@ -345,7 +359,7 @@ class MockCatalogServiceImpl {
|
|||
|
||||
void createDnode(int32_t dnodeId, const string& host, int16_t port) {
|
||||
SEpSet epSet = {0};
|
||||
addEpIntoEpSet(&epSet, host.c_str(), port);
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(&epSet, host.c_str(), port));
|
||||
dnode_.insert(std::make_pair(dnodeId, epSet));
|
||||
}
|
||||
|
||||
|
@ -370,9 +384,9 @@ class MockCatalogServiceImpl {
|
|||
uint64_t getNextId() { return id_++; }
|
||||
|
||||
void genEpSet(SEpSet* pEpSet) {
|
||||
addEpIntoEpSet(pEpSet, "dnode_1", 6030);
|
||||
addEpIntoEpSet(pEpSet, "dnode_2", 6030);
|
||||
addEpIntoEpSet(pEpSet, "dnode_3", 6030);
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(pEpSet, "dnode_1", 6030));
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(pEpSet, "dnode_2", 6030));
|
||||
assert(TSDB_CODE_SUCCESS == addEpIntoEpSet(pEpSet, "dnode_3", 6030));
|
||||
pEpSet->inUse = 0;
|
||||
}
|
||||
|
||||
|
@ -456,8 +470,15 @@ class MockCatalogServiceImpl {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
*vgList = taosArrayInit(table->vgs.size(), sizeof(SVgroupInfo));
|
||||
if (!*vgList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (const SVgroupInfo& vg : table->vgs) {
|
||||
taosArrayPush(*vgList, &vg);
|
||||
if (nullptr == taosArrayPush(*vgList, &vg)) {
|
||||
taosArrayDestroy(*vgList);
|
||||
*vgList = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
@ -478,13 +499,21 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pTableMetaReq) {
|
||||
int32_t ndbs = taosArrayGetSize(pTableMetaReq);
|
||||
*pTableMetaData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
if (!*pTableMetaData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
STablesReq* pReq = (STablesReq*)taosArrayGet(pTableMetaReq, i);
|
||||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
SMetaRes res = {0};
|
||||
res.code = catalogGetTableMeta((const SName*)taosArrayGet(pReq->pTables, j), (STableMeta**)&res.pRes);
|
||||
taosArrayPush(*pTableMetaData, &res);
|
||||
if (nullptr == taosArrayPush(*pTableMetaData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pTableMetaData, MockCatalogService::destoryMetaRes);
|
||||
*pTableMetaData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -495,14 +524,27 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pTableVgroupReq) {
|
||||
int32_t ndbs = taosArrayGetSize(pTableVgroupReq);
|
||||
*pTableVgroupData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
if (!*pTableVgroupData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
STablesReq* pReq = (STablesReq*)taosArrayGet(pTableVgroupReq, i);
|
||||
int32_t ntables = taosArrayGetSize(pReq->pTables);
|
||||
for (int32_t j = 0; j < ntables; ++j) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SVgroupInfo));
|
||||
if (!res.pRes) {
|
||||
taosArrayDestroyEx(*pTableVgroupData, MockCatalogService::destoryMetaRes);
|
||||
*pTableVgroupData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
res.code = catalogGetTableHashVgroup((const SName*)taosArrayGet(pReq->pTables, j), (SVgroupInfo*)res.pRes);
|
||||
taosArrayPush(*pTableVgroupData, &res);
|
||||
if (nullptr == taosArrayPush(*pTableVgroupData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pTableVgroupData, MockCatalogService::destoryMetaRes);
|
||||
*pTableVgroupData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,9 +556,16 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pDbVgroupReq) {
|
||||
int32_t ndbs = taosArrayGetSize(pDbVgroupReq);
|
||||
*pDbVgroupData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
if (!*pDbVgroupData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
SMetaRes res = {0};
|
||||
taosArrayPush(*pDbVgroupData, &res);
|
||||
if (nullptr == taosArrayPush(*pDbVgroupData, &res)) {
|
||||
taosArrayDestroyEx(*pDbVgroupData, MockCatalogService::destoryMetaRes);
|
||||
*pDbVgroupData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
|
@ -529,11 +578,17 @@ class MockCatalogServiceImpl {
|
|||
}
|
||||
std::set<int32_t> vgSet;
|
||||
*pVgList = taosArrayInit(it->second.size(), sizeof(SVgroupInfo));
|
||||
if (!*pVgList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (const auto& vgs : it->second) {
|
||||
for (const auto& vg : vgs.second->vgs) {
|
||||
if (0 == vgSet.count(vg.vgId)) {
|
||||
taosArrayPush(*pVgList, &vg);
|
||||
vgSet.insert(vg.vgId);
|
||||
if (nullptr == taosArrayPush(*pVgList, &vg)) {
|
||||
taosArrayDestroy(*pVgList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)vgSet.insert(vg.vgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -543,12 +598,18 @@ class MockCatalogServiceImpl {
|
|||
int32_t catalogGetAllDBVgList(SArray** pVgList) const {
|
||||
std::set<int32_t> vgSet;
|
||||
*pVgList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVgroupInfo));
|
||||
if (!*pVgList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (const auto& db : meta_) {
|
||||
for (const auto& vgs : db.second) {
|
||||
for (const auto& vg : vgs.second->vgs) {
|
||||
if (0 == vgSet.count(vg.vgId)) {
|
||||
taosArrayPush(*pVgList, &vg);
|
||||
vgSet.insert(vg.vgId);
|
||||
if (nullptr == taosArrayPush(*pVgList, &vg)) {
|
||||
taosArrayDestroy(*pVgList);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)vgSet.insert(vg.vgId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,11 +622,24 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pDbCfgReq) {
|
||||
int32_t ndbs = taosArrayGetSize(pDbCfgReq);
|
||||
*pDbCfgData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
if (!*pDbCfgData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SDbCfgInfo));
|
||||
if (!res.pRes) {
|
||||
taosArrayDestroyEx(*pDbCfgData, MockCatalogService::destoryMetaRes);
|
||||
*pDbCfgData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
res.code = catalogGetDBCfg((const char*)taosArrayGet(pDbCfgReq, i), (SDbCfgInfo*)res.pRes);
|
||||
taosArrayPush(*pDbCfgData, &res);
|
||||
if (nullptr == taosArrayPush(*pDbCfgData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pDbCfgData, MockCatalogService::destoryMetaRes);
|
||||
*pDbCfgData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
|
@ -576,10 +650,18 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pDbInfoReq) {
|
||||
int32_t ndbs = taosArrayGetSize(pDbInfoReq);
|
||||
*pDbInfoData = taosArrayInit(ndbs, sizeof(SMetaRes));
|
||||
if (!*pDbInfoData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < ndbs; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SDbInfo));
|
||||
taosArrayPush(*pDbInfoData, &res);
|
||||
if (!res.pRes || (nullptr == taosArrayPush(*pDbInfoData, &res))) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pDbInfoData, MockCatalogService::destoryMetaRes);
|
||||
*pDbInfoData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
|
@ -590,11 +672,25 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pUserAuthReq) {
|
||||
int32_t num = taosArrayGetSize(pUserAuthReq);
|
||||
*pUserAuthData = taosArrayInit(num, sizeof(SMetaRes));
|
||||
if (!*pUserAuthData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SUserAuthRes));
|
||||
if (!res.pRes) {
|
||||
taosArrayDestroy(*pUserAuthData);
|
||||
*pUserAuthData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
((SUserAuthRes*)res.pRes)->pass[0] = true;
|
||||
taosArrayPush(*pUserAuthData, &res);
|
||||
if (nullptr == taosArrayPush(*pUserAuthData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pUserAuthData, MockCatalogService::destoryMetaRes);
|
||||
*pUserAuthData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return code;
|
||||
|
@ -604,11 +700,24 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pUdfReq) {
|
||||
int32_t num = taosArrayGetSize(pUdfReq);
|
||||
*pUdfData = taosArrayInit(num, sizeof(SMetaRes));
|
||||
if (!*pUdfData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(SFuncInfo));
|
||||
if (!res.pRes) {
|
||||
taosArrayDestroyEx(*pUdfData, MockCatalogService::destoryMetaRes);
|
||||
*pUdfData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
res.code = catalogGetUdfInfo((char*)taosArrayGet(pUdfReq, i), (SFuncInfo*)res.pRes);
|
||||
taosArrayPush(*pUdfData, &res);
|
||||
if (nullptr == taosArrayPush(*pUdfData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pUdfData, MockCatalogService::destoryMetaRes);
|
||||
*pUdfData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -618,10 +727,18 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pTableIndex) {
|
||||
int32_t num = taosArrayGetSize(pTableIndex);
|
||||
*pTableIndexData = taosArrayInit(num, sizeof(SMetaRes));
|
||||
if (!*pTableIndexData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.code = catalogGetTableIndex((const SName*)taosArrayGet(pTableIndex, i), (SArray**)(&res.pRes));
|
||||
taosArrayPush(*pTableIndexData, &res);
|
||||
if (nullptr == taosArrayPush(*pTableIndexData, &res)) {
|
||||
MockCatalogService::destoryMetaRes(&res);
|
||||
taosArrayDestroyEx(*pTableIndexData, MockCatalogService::destoryMetaRes);
|
||||
*pTableIndexData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -631,11 +748,20 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pTableCfgReq) {
|
||||
int32_t ntables = taosArrayGetSize(pTableCfgReq);
|
||||
*pTableCfgData = taosArrayInit(ntables, sizeof(SMetaRes));
|
||||
if (!*pTableCfgData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
int32_t code = 0;
|
||||
for (int32_t i = 0; i < ntables; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(STableCfg));
|
||||
res.code = TSDB_CODE_SUCCESS;
|
||||
taosArrayPush(*pTableCfgData, &res);
|
||||
res.pRes = taosMemoryCalloc(1, sizeof(STableCfg));
|
||||
if (!res.pRes || (nullptr == taosArrayPush(*pTableCfgData, &res))) {
|
||||
taosMemoryFree(res.pRes);
|
||||
taosArrayDestroy(*pTableCfgData);
|
||||
*pTableCfgData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -645,11 +771,18 @@ class MockCatalogServiceImpl {
|
|||
if (NULL != pViewMetaReq) {
|
||||
int32_t nviews = taosArrayGetSize(pViewMetaReq);
|
||||
*pViewMetaData = taosArrayInit(nviews, sizeof(SMetaRes));
|
||||
if (!*pViewMetaData) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < nviews; ++i) {
|
||||
SMetaRes res = {0};
|
||||
res.pRes = NULL;
|
||||
res.pRes = nullptr;
|
||||
res.code = TSDB_CODE_PAR_TABLE_NOT_EXIST;
|
||||
taosArrayPush(*pViewMetaData, &res);
|
||||
if (nullptr == taosArrayPush(*pViewMetaData, &res)) {
|
||||
taosArrayDestroyEx(*pViewMetaData, MockCatalogService::destoryMetaRes);
|
||||
*pViewMetaData = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -657,9 +790,20 @@ class MockCatalogServiceImpl {
|
|||
|
||||
int32_t getAllDnodeList(SArray** pDnodes) const {
|
||||
SMetaRes res = {0};
|
||||
catalogGetDnodeList((SArray**)&res.pRes);
|
||||
int32_t code = catalogGetDnodeList((SArray**)&res.pRes);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
*pDnodes = taosArrayInit(1, sizeof(SMetaRes));
|
||||
taosArrayPush(*pDnodes, &res);
|
||||
if (!*pDnodes) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (nullptr == taosArrayPush(*pDnodes, &res)) {
|
||||
MockCatalogService::destoryMetaArrayRes(&res);
|
||||
taosArrayDestroyEx(*pDnodes, MockCatalogService::destoryMetaArrayRes);
|
||||
*pDnodes = nullptr;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -358,9 +358,9 @@ TEST_F(ParserInitialATest, alterLocal) {
|
|||
};
|
||||
|
||||
auto setAlterLocal = [&](const char* pConfig, const char* pValue = nullptr) {
|
||||
expect.first.assign(pConfig);
|
||||
(void)expect.first.assign(pConfig);
|
||||
if (nullptr != pValue) {
|
||||
expect.second.assign(pValue);
|
||||
(void)expect.second.assign(pValue);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -429,9 +429,10 @@ TEST_F(ParserInitialATest, alterSTable) {
|
|||
expect.numOfFields = numOfFields;
|
||||
if (NULL == expect.pFields) {
|
||||
expect.pFields = taosArrayInit(2, sizeof(TAOS_FIELD));
|
||||
ASSERT_TRUE(expect.pFields);
|
||||
TAOS_FIELD field = {0};
|
||||
taosArrayPush(expect.pFields, &field);
|
||||
taosArrayPush(expect.pFields, &field);
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pFields, &field));
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pFields, &field));
|
||||
}
|
||||
|
||||
TAOS_FIELD* pField = (TAOS_FIELD*)taosArrayGet(expect.pFields, 0);
|
||||
|
@ -706,9 +707,10 @@ TEST_F(ParserInitialATest, alterTable) {
|
|||
expect.numOfFields = numOfFields;
|
||||
if (NULL == expect.pFields) {
|
||||
expect.pFields = taosArrayInit(2, sizeof(TAOS_FIELD));
|
||||
ASSERT_TRUE(expect.pFields);
|
||||
TAOS_FIELD field = {0};
|
||||
taosArrayPush(expect.pFields, &field);
|
||||
taosArrayPush(expect.pFields, &field);
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pFields, &field));
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pFields, &field));
|
||||
}
|
||||
|
||||
TAOS_FIELD* pField = (TAOS_FIELD*)taosArrayGet(expect.pFields, 0);
|
||||
|
|
|
@ -192,8 +192,9 @@ TEST_F(ParserInitialCTest, createDatabase) {
|
|||
retention.keepUnit = keepUnit;
|
||||
if (NULL == expect.pRetensions) {
|
||||
expect.pRetensions = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SRetention));
|
||||
ASSERT_TRUE(expect.pRetensions);
|
||||
}
|
||||
taosArrayPush(expect.pRetensions, &retention);
|
||||
ASSERT_TRUE(taosArrayPush(expect.pRetensions, &retention) != nullptr);
|
||||
++expect.numOfRetensions;
|
||||
};
|
||||
auto setDbSchemaless = [&](int8_t schemaless) { expect.schemaless = schemaless; };
|
||||
|
@ -449,7 +450,7 @@ TEST_F(ParserInitialCTest, createFunction) {
|
|||
file << 123 << "abc" << '\n';
|
||||
file.close();
|
||||
}
|
||||
~udfFile() { remove(path_.c_str()); }
|
||||
~udfFile() { assert(0 == remove(path_.c_str())); }
|
||||
std::string path_;
|
||||
} udffile("udf");
|
||||
|
||||
|
@ -506,7 +507,7 @@ TEST_F(ParserInitialCTest, createView) {
|
|||
if (NULL == expect.pTags) {
|
||||
expect.pTags = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField));
|
||||
}
|
||||
taosArrayPush(expect.pTags, &field);
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pTags, &field));
|
||||
expect.numOfTags += 1;
|
||||
};
|
||||
|
||||
|
@ -684,7 +685,7 @@ TEST_F(ParserInitialCTest, createSmaIndex) {
|
|||
pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, pStmt->pReq);
|
||||
pCmdMsg->pMsg = taosMemoryMalloc(pCmdMsg->msgLen);
|
||||
if (!pCmdMsg->pMsg) FAIL();
|
||||
tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq);
|
||||
ASSERT_TRUE(0 < tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq));
|
||||
((SQuery*)pQuery)->pCmdMsg = pCmdMsg;
|
||||
ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||
|
||||
|
@ -797,13 +798,13 @@ TEST_F(ParserInitialCTest, createStable) {
|
|||
if (NULL == expect.pColumns) {
|
||||
expect.pColumns = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField));
|
||||
}
|
||||
taosArrayPush(expect.pColumns, &field);
|
||||
ASSERT_TRUE(nullptr != taosArrayPush(expect.pColumns, &field));
|
||||
expect.numOfColumns += 1;
|
||||
} else {
|
||||
if (NULL == expect.pTags) {
|
||||
expect.pTags = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField));
|
||||
}
|
||||
taosArrayPush(expect.pTags, &field);
|
||||
ASSERT_TRUE(taosArrayPush(expect.pTags, &field) != nullptr);
|
||||
expect.numOfTags += 1;
|
||||
}
|
||||
};
|
||||
|
@ -983,7 +984,7 @@ TEST_F(ParserInitialCTest, createStream) {
|
|||
if (NULL == expect.pTags) {
|
||||
expect.pTags = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SField));
|
||||
}
|
||||
taosArrayPush(expect.pTags, &field);
|
||||
ASSERT_TRUE(taosArrayPush(expect.pTags, &field) != nullptr);
|
||||
expect.numOfTags += 1;
|
||||
};
|
||||
|
||||
|
@ -1123,8 +1124,9 @@ TEST_F(ParserInitialCTest, createTable) {
|
|||
++expect.nReqs;
|
||||
if (nullptr == expect.pArray) {
|
||||
expect.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVCreateTbReq));
|
||||
ASSERT_TRUE(expect.pArray != nullptr);
|
||||
}
|
||||
taosArrayPush(expect.pArray, &req);
|
||||
ASSERT_TRUE(taosArrayPush(expect.pArray, &req) != nullptr);
|
||||
};
|
||||
|
||||
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
||||
|
@ -1200,11 +1202,11 @@ TEST_F(ParserInitialCTest, createTableSemanticCheck) {
|
|||
string sql = "CREATE TABLE st1(ts TIMESTAMP, ";
|
||||
for (int32_t i = 1; i < 4096; ++i) {
|
||||
if (i > 1) {
|
||||
sql.append(", ");
|
||||
(void)sql.append(", ");
|
||||
}
|
||||
sql.append("c" + to_string(i) + " INT");
|
||||
(void)sql.append("c" + to_string(i) + " INT");
|
||||
}
|
||||
sql.append(") TAGS (t1 int)");
|
||||
(void)sql.append(") TAGS (t1 int)");
|
||||
|
||||
run(sql, TSDB_CODE_PAR_TOO_MANY_COLUMNS);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ namespace ParserTest {
|
|||
class ParserEnv : public testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
// TODO(smj) : How to handle return value of fmFuncMgtInit
|
||||
(void)fmFuncMgtInit();
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, fmFuncMgtInit());
|
||||
initMetaDataEnv();
|
||||
generateMetaData();
|
||||
initLog(TD_TMP_DIR_PATH "td");
|
||||
|
@ -71,7 +70,7 @@ class ParserEnv : public testing::Environment {
|
|||
tsAsyncLog = 0;
|
||||
|
||||
taosRemoveDir(path);
|
||||
taosMkDir(path);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, taosMkDir(path));
|
||||
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||
if (taosInitLog("taoslog", 1) != 0) {
|
||||
std::cout << "failed to init log file" << std::endl;
|
||||
|
@ -118,7 +117,7 @@ static void parseArg(int argc, char* argv[]) {
|
|||
} // namespace ParserTest
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
testing::AddGlobalTestEnvironment(new ParserTest::ParserEnv());
|
||||
(void)testing::AddGlobalTestEnvironment(new ParserTest::ParserEnv());
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
ParserTest::parseArg(argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
@ -66,6 +66,7 @@ int32_t getLogLevel() { return g_logLevel; }
|
|||
class ParserTestBaseImpl {
|
||||
public:
|
||||
ParserTestBaseImpl(ParserTestBase* pBase) : pBase_(pBase), sqlNo_(0), sqlNum_(0) {
|
||||
assert(TSDB_CODE_SUCCESS == qInitKeywordsTable());
|
||||
caseEnv_.numOfSkipSql_ = g_skipSql;
|
||||
caseEnv_.numOfLimitSql_ = g_limitSql;
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ class ParserTestBaseImpl {
|
|||
|
||||
void setParseContext(const string& sql, SParseContext* pCxt, bool async = false) {
|
||||
stmtEnv_.sql_ = sql;
|
||||
strtolower((char*)stmtEnv_.sql_.c_str(), sql.c_str());
|
||||
(void)strtolower((char*)stmtEnv_.sql_.c_str(), sql.c_str());
|
||||
|
||||
pCxt->acctId = atoi(caseEnv_.acctId_.c_str());
|
||||
pCxt->db = caseEnv_.db_.c_str();
|
||||
|
|
|
@ -65,7 +65,7 @@ int32_t tagScanSetExecutionMode(SScanLogicNode* pScan);
|
|||
#define CLONE_LIMIT 1
|
||||
#define CLONE_SLIMIT 1 << 1
|
||||
#define CLONE_LIMIT_SLIMIT (CLONE_LIMIT | CLONE_SLIMIT)
|
||||
bool cloneLimit(SLogicNode* pParent, SLogicNode* pChild, uint8_t cloneWhat);
|
||||
int32_t cloneLimit(SLogicNode* pParent, SLogicNode* pChild, uint8_t cloneWhat, bool* pCloned);
|
||||
int32_t sortPriKeyOptGetSequencingNodesImpl(SLogicNode* pNode, bool groupSort, SSortLogicNode* pSort,
|
||||
bool* pNotOptimize, SNodeList** pSequencingNodes, bool* keepSort);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -21,12 +21,16 @@ typedef struct SScaleOutContext {
|
|||
} SScaleOutContext;
|
||||
|
||||
static SLogicSubplan* singleCloneSubLogicPlan(SScaleOutContext* pCxt, SLogicSubplan* pSrc, int32_t level) {
|
||||
SLogicSubplan* pDst = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
SLogicSubplan* pDst = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, (SNode**)&pDst);
|
||||
if (NULL == pDst) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
pDst->pNode = (SLogicNode*)nodesCloneNode((SNode*)pSrc->pNode);
|
||||
pDst->pNode = NULL;
|
||||
code = nodesCloneNode((SNode*)pSrc->pNode, (SNode**)&pDst->pNode);
|
||||
if (NULL == pDst->pNode) {
|
||||
terrno = code;
|
||||
nodesDestroyNode((SNode*)pDst);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -69,7 +73,7 @@ static int32_t scaleOutByVgroups(SScaleOutContext* pCxt, SLogicSubplan* pSubplan
|
|||
for (int32_t i = 0; i < pSubplan->pVgroupList->numOfVgroups; ++i) {
|
||||
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||
if (NULL == pNewSubplan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
code = setScanVgroup(pNewSubplan->pNode, pSubplan->pVgroupList->vgroups + i);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -90,14 +94,15 @@ static int32_t scaleOutForInsertValues(SScaleOutContext* pCxt, SLogicSubplan* pS
|
|||
SNodeList* pGroup) {
|
||||
SVnodeModifyLogicNode* pNode = (SVnodeModifyLogicNode*)pSubplan->pNode;
|
||||
size_t numOfVgroups = taosArrayGetSize(pNode->pDataBlocks);
|
||||
int32_t code = 0;
|
||||
for (int32_t i = 0; i < numOfVgroups; ++i) {
|
||||
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||
if (NULL == pNewSubplan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
((SVnodeModifyLogicNode*)pNewSubplan->pNode)->pVgDataBlocks = (SVgDataBlocks*)taosArrayGetP(pNode->pDataBlocks, i);
|
||||
if (TSDB_CODE_SUCCESS != nodesListStrictAppend(pGroup, (SNode*)pNewSubplan)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (TSDB_CODE_SUCCESS != (code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan))) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -132,7 +137,7 @@ static int32_t scaleOutForCompute(SScaleOutContext* pCxt, SLogicSubplan* pSubpla
|
|||
for (int32_t i = 0; i < pSubplan->numOfComputeNodes; ++i) {
|
||||
SLogicSubplan* pNewSubplan = singleCloneSubLogicPlan(pCxt, pSubplan, level);
|
||||
if (NULL == pNewSubplan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
code = nodesListStrictAppend(pGroup, (SNode*)pNewSubplan);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
|
@ -196,12 +201,12 @@ static int32_t pushHierarchicalPlan(SNodeList* pParentsGroup, SNodeList* pCurren
|
|||
}
|
||||
|
||||
static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32_t level, SNodeList* pParentsGroup) {
|
||||
SNodeList* pCurrentGroup = nodesMakeList();
|
||||
SNodeList* pCurrentGroup = NULL;
|
||||
int32_t code = nodesMakeList(&pCurrentGroup);
|
||||
if (NULL == pCurrentGroup) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (pSubplan->subplanType) {
|
||||
case SUBPLAN_TYPE_MERGE:
|
||||
code = scaleOutForMerge(pCxt, pSubplan, level, pCurrentGroup);
|
||||
|
@ -243,13 +248,17 @@ static int32_t doScaleOut(SScaleOutContext* pCxt, SLogicSubplan* pSubplan, int32
|
|||
}
|
||||
|
||||
static SQueryLogicPlan* makeQueryLogicPlan() {
|
||||
SQueryLogicPlan* pLogicPlan = (SQueryLogicPlan*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN);
|
||||
SQueryLogicPlan* pLogicPlan = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN, (SNode**)&pLogicPlan);
|
||||
if (NULL == pLogicPlan) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
pLogicPlan->pTopSubplans = nodesMakeList();
|
||||
pLogicPlan->pTopSubplans = NULL;
|
||||
code = nodesMakeList(&pLogicPlan->pTopSubplans);
|
||||
if (NULL == pLogicPlan->pTopSubplans) {
|
||||
nodesDestroyNode((SNode*)pLogicPlan);
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
return pLogicPlan;
|
||||
|
@ -258,7 +267,7 @@ static SQueryLogicPlan* makeQueryLogicPlan() {
|
|||
int32_t scaleOutLogicPlan(SPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SQueryLogicPlan** pLogicPlan) {
|
||||
SQueryLogicPlan* pPlan = makeQueryLogicPlan();
|
||||
if (NULL == pPlan) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SScaleOutContext cxt = {.pPlanCxt = pCxt, .subplanId = 1};
|
||||
|
|
|
@ -59,7 +59,8 @@ static void splSetSubplanVgroups(SLogicSubplan* pSubplan, SLogicNode* pNode) {
|
|||
}
|
||||
|
||||
static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SLogicNode* pNode, int32_t flag) {
|
||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
SLogicSubplan* pSubplan = NULL;
|
||||
terrno = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, (SNode**)&pSubplan);
|
||||
if (NULL == pSubplan) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -93,37 +94,44 @@ static void splSetSubplanType(SLogicSubplan* pSubplan) {
|
|||
pSubplan->subplanType = splHasScan(pSubplan->pNode) ? SUBPLAN_TYPE_SCAN : SUBPLAN_TYPE_MERGE;
|
||||
}
|
||||
|
||||
static SLogicSubplan* splCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode) {
|
||||
SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN);
|
||||
static int32_t splCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode, SLogicSubplan** ppSubplan) {
|
||||
SLogicSubplan* pSubplan = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN, (SNode**)&pSubplan);
|
||||
if (NULL == pSubplan) {
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
pSubplan->id.queryId = pCxt->queryId;
|
||||
pSubplan->id.groupId = pCxt->groupId;
|
||||
pSubplan->pNode = pNode;
|
||||
pNode->pParent = NULL;
|
||||
splSetSubplanType(pSubplan);
|
||||
return pSubplan;
|
||||
*ppSubplan = pSubplan;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pChild, SExchangeLogicNode** pOutput) {
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE, (SNode**)&pExchange);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pExchange->srcStartGroupId = pCxt->groupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId;
|
||||
pExchange->node.precision = pChild->precision;
|
||||
pExchange->node.dynamicOp = pChild->dynamicOp;
|
||||
pExchange->node.pTargets = nodesCloneList(pChild->pTargets);
|
||||
pExchange->node.pTargets = NULL;
|
||||
code = nodesCloneList(pChild->pTargets, &pExchange->node.pTargets);
|
||||
if (NULL == pExchange->node.pTargets) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return code;
|
||||
}
|
||||
if (NULL != pChild->pLimit) {
|
||||
pExchange->node.pLimit = nodesCloneNode(pChild->pLimit);
|
||||
pExchange->node.pLimit = NULL;
|
||||
code = nodesCloneNode(pChild->pLimit, &pExchange->node.pLimit);
|
||||
if (NULL == pExchange->node.pLimit) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return code;
|
||||
}
|
||||
((SLimitNode*)pChild->pLimit)->limit += ((SLimitNode*)pChild->pLimit)->offset;
|
||||
((SLimitNode*)pChild->pLimit)->offset = 0;
|
||||
|
@ -368,18 +376,14 @@ static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFu
|
|||
SFunctionNode* pMergeFunc = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (fmIsWindowPseudoColumnFunc(pFunc->funcId)) {
|
||||
pPartFunc = (SFunctionNode*)nodesCloneNode(pNode);
|
||||
pMergeFunc = (SFunctionNode*)nodesCloneNode(pNode);
|
||||
if (NULL == pPartFunc || NULL == pMergeFunc) {
|
||||
nodesDestroyNode((SNode*)pPartFunc);
|
||||
nodesDestroyNode((SNode*)pMergeFunc);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = nodesCloneNode(pNode, (SNode**)&pPartFunc);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesCloneNode(pNode, (SNode**)&pMergeFunc);
|
||||
}
|
||||
if(pMidFuncs != NULL){
|
||||
pMidFunc = (SFunctionNode*)nodesCloneNode(pNode);
|
||||
if(TSDB_CODE_SUCCESS == code && pMidFuncs != NULL){
|
||||
code = nodesCloneNode(pNode, (SNode**)&pMidFunc);
|
||||
if (NULL == pMidFunc) {
|
||||
nodesDestroyNode((SNode*)pMidFunc);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -419,19 +423,20 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex, uint8_t pr
|
|||
++index;
|
||||
}
|
||||
|
||||
SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pWStart = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pWStart);
|
||||
if (NULL == pWStart) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
strcpy(pWStart->functionName, "_wstart");
|
||||
int64_t pointer = (int64_t)pWStart;
|
||||
char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWStart->functionName, pointer);
|
||||
taosCreateMD5Hash(name, len);
|
||||
(void)taosCreateMD5Hash(name, len);
|
||||
strncpy(pWStart->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
pWStart->node.resType.precision = precision;
|
||||
|
||||
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||
code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pFuncs, (SNode*)pWStart);
|
||||
}
|
||||
|
@ -450,18 +455,19 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
|||
++index;
|
||||
}
|
||||
|
||||
SFunctionNode* pWEnd = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pWEnd = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pWEnd);
|
||||
if (NULL == pWEnd) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
strcpy(pWEnd->functionName, "_wend");
|
||||
int64_t pointer = (int64_t)pWEnd;
|
||||
char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWEnd->functionName, pointer);
|
||||
taosCreateMD5Hash(name, len);
|
||||
(void)taosCreateMD5Hash(name, len);
|
||||
strncpy(pWEnd->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
|
||||
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
||||
code = fmGetFuncInfo(pWEnd, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pWin->pFuncs, (SNode*)pWEnd);
|
||||
}
|
||||
|
@ -482,9 +488,10 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
SNode* pConditions = pMergeWindow->node.pConditions;
|
||||
pMergeWindow->node.pConditions = NULL;
|
||||
|
||||
SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
||||
SWindowLogicNode* pPartWin = NULL;
|
||||
int32_t code = nodesCloneNode((SNode*)pMergeWindow, (SNode**)&pPartWin);
|
||||
if (NULL == pPartWin) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pPartWin->node.groupAction = GROUP_ACTION_KEEP;
|
||||
|
@ -494,7 +501,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
splSetParent((SLogicNode*)pPartWin);
|
||||
|
||||
int32_t index = 0;
|
||||
int32_t code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, NULL, &pMergeWindow->pFuncs);
|
||||
code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, NULL, &pMergeWindow->pFuncs);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplAppendWStart(pPartWin->pFuncs, &index, ((SColumnNode*)pMergeWindow->pTspk)->node.resType.precision);
|
||||
}
|
||||
|
@ -503,10 +510,8 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
|||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyNode(pMergeWindow->pTspk);
|
||||
pMergeWindow->pTspk = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index));
|
||||
if (NULL == pMergeWindow->pTspk) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeWindow->pTspk = NULL;
|
||||
code = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index), &pMergeWindow->pTspk);
|
||||
}
|
||||
|
||||
nodesDestroyList(pFunc);
|
||||
|
@ -529,14 +534,17 @@ static int32_t stbSplCreatePartMidWindowNode(SWindowLogicNode* pMergeWindow, SLo
|
|||
SNode* pConditions = pMergeWindow->node.pConditions;
|
||||
pMergeWindow->node.pConditions = NULL;
|
||||
|
||||
SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
||||
SWindowLogicNode* pPartWin = NULL;
|
||||
int32_t code = nodesCloneNode((SNode*)pMergeWindow, (SNode**)&pPartWin);
|
||||
if (NULL == pPartWin) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
SWindowLogicNode* pMidWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
||||
SWindowLogicNode* pMidWin = NULL;
|
||||
code = nodesCloneNode((SNode*)pMergeWindow, (SNode**)&pMidWin);
|
||||
if (NULL == pMidWin) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode((SNode*)pPartWin);
|
||||
return code;
|
||||
}
|
||||
|
||||
pPartWin->node.groupAction = GROUP_ACTION_KEEP;
|
||||
|
@ -550,7 +558,7 @@ static int32_t stbSplCreatePartMidWindowNode(SWindowLogicNode* pMergeWindow, SLo
|
|||
SNodeList* pFuncPart = NULL;
|
||||
SNodeList* pFuncMid = NULL;
|
||||
SNodeList* pFuncMerge = NULL;
|
||||
int32_t code = stbSplRewriteFuns(pFunc, &pFuncPart, &pFuncMid, &pFuncMerge);
|
||||
code = stbSplRewriteFuns(pFunc, &pFuncPart, &pFuncMid, &pFuncMerge);
|
||||
pPartWin->pFuncs = pFuncPart;
|
||||
pMidWin->pFuncs = pFuncMid;
|
||||
pMergeWindow->pFuncs = pFuncMerge;
|
||||
|
@ -565,10 +573,8 @@ static int32_t stbSplCreatePartMidWindowNode(SWindowLogicNode* pMergeWindow, SLo
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyNode(pMidWin->pTspk);
|
||||
pMidWin->pTspk = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index));
|
||||
if (NULL == pMidWin->pTspk) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMidWin->pTspk = NULL;
|
||||
code = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index), &pMidWin->pTspk);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -580,10 +586,7 @@ static int32_t stbSplCreatePartMidWindowNode(SWindowLogicNode* pMergeWindow, SLo
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyNode(pMergeWindow->pTspk);
|
||||
pMergeWindow->pTspk = nodesCloneNode(nodesListGetNode(pMidWin->node.pTargets, index));
|
||||
if (NULL == pMergeWindow->pTspk) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
code = nodesCloneNode(nodesListGetNode(pMidWin->node.pTargets, index), &pMergeWindow->pTspk);
|
||||
}
|
||||
|
||||
nodesDestroyList(pFunc);
|
||||
|
@ -649,9 +652,10 @@ static int32_t stbSplRewriteFromMergeNode(SMergeLogicNode* pMerge, SLogicNode* p
|
|||
|
||||
static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode,
|
||||
SNodeList* pMergeKeys, SLogicNode* pPartChild, bool groupSort, bool needSort) {
|
||||
SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE);
|
||||
SMergeLogicNode* pMerge = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE, (SNode**)&pMerge);
|
||||
if (NULL == pMerge) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pMerge->needSort = needSort;
|
||||
pMerge->numOfChannels = stbSplGetNumOfVgroups(pPartChild);
|
||||
|
@ -662,22 +666,19 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
|
|||
pMerge->groupSort = groupSort;
|
||||
pMerge->numOfSubplans = 1;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
pMerge->pInputs = nodesCloneList(pPartChild->pTargets);
|
||||
// NULL != pSubplan means 'merge node' replaces 'split node'.
|
||||
if (NULL == pSubplan) {
|
||||
pMerge->node.pTargets = nodesCloneList(pPartChild->pTargets);
|
||||
} else {
|
||||
pMerge->node.pTargets = nodesCloneList(pSplitNode->pTargets);
|
||||
}
|
||||
if (NULL == pMerge->node.pTargets || NULL == pMerge->pInputs) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
pMerge->pInputs = NULL;
|
||||
code = nodesCloneList(pPartChild->pTargets, &pMerge->pInputs);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
// NULL != pSubplan means 'merge node' replaces 'split node'.
|
||||
if (NULL == pSubplan) {
|
||||
code = nodesCloneList(pPartChild->pTargets, &pMerge->node.pTargets);
|
||||
} else {
|
||||
code = nodesCloneList(pSplitNode->pTargets, &pMerge->node.pTargets);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pSplitNode->pLimit) {
|
||||
pMerge->node.pLimit = nodesCloneNode(pSplitNode->pLimit);
|
||||
if (NULL == pMerge->node.pLimit) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMerge->node.pLimit = NULL;
|
||||
code = nodesCloneNode(pSplitNode->pLimit, &pMerge->node.pLimit);
|
||||
((SLimitNode*)pSplitNode->pLimit)->limit += ((SLimitNode*)pSplitNode->pLimit)->offset;
|
||||
((SLimitNode*)pSplitNode->pLimit)->offset = 0;
|
||||
}
|
||||
|
@ -708,14 +709,16 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
|
|||
}
|
||||
|
||||
static int32_t stbSplCreateMergeKeysByExpr(SNode* pExpr, EOrder order, SNodeList** pMergeKeys) {
|
||||
SOrderByExprNode* pOrderByExpr = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
SOrderByExprNode* pOrderByExpr = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR, (SNode**)&pOrderByExpr);
|
||||
if (NULL == pOrderByExpr) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pOrderByExpr->pExpr = nodesCloneNode(pExpr);
|
||||
pOrderByExpr->pExpr = NULL;
|
||||
code = nodesCloneNode(pExpr, &pOrderByExpr->pExpr);
|
||||
if (NULL == pOrderByExpr->pExpr) {
|
||||
nodesDestroyNode((SNode*)pOrderByExpr);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pOrderByExpr->order = order;
|
||||
pOrderByExpr->nullOrder = (order == ORDER_ASC) ? NULL_ORDER_FIRST : NULL_ORDER_LAST;
|
||||
|
@ -745,7 +748,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
|
|||
SLogicSubplan* pSplitSubPlan = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSplitSubPlan = splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT);
|
||||
if (!pSplitSubPlan) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pSplitSubPlan) code = terrno;
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
SNode* pNode;
|
||||
|
@ -793,11 +796,14 @@ static int32_t stbSplSplitIntervalForStreamMultiAgg(SSplitContext* pCxt, SStable
|
|||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNode* subPlan = (SNode*)splCreateSubplan(pCxt, pMidWindow);
|
||||
((SLogicSubplan*)subPlan)->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
SNode* subPlan = NULL;
|
||||
code = splCreateSubplan(pCxt, pMidWindow, (SLogicSubplan**)&subPlan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
((SLogicSubplan*)subPlan)->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
|
||||
code = nodesListMakeStrictAppend(&((SLogicSubplan*)subPlan)->pChildren,
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
code = nodesListMakeStrictAppend(&((SLogicSubplan*)subPlan)->pChildren,
|
||||
(SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT));
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, subPlan);
|
||||
}
|
||||
|
@ -828,9 +834,10 @@ static int32_t stbSplSplitSessionForStream(SSplitContext* pCxt, SStableSplitInfo
|
|||
int32_t code = stbSplAppendWEnd(pPartWin, &index);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
nodesDestroyNode(pMergeWin->pTsEnd);
|
||||
pMergeWin->pTsEnd = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index));
|
||||
pMergeWin->pTsEnd = NULL;
|
||||
code = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index), &pMergeWin->pTsEnd);
|
||||
if (NULL == pMergeWin->pTsEnd) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = code;
|
||||
}
|
||||
}
|
||||
code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartWindow);
|
||||
|
@ -1006,24 +1013,21 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
|
|||
SNode* pConditions = pMergeAgg->node.pConditions;
|
||||
pMergeAgg->node.pConditions = NULL;
|
||||
|
||||
SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg);
|
||||
SAggLogicNode* pPartAgg = NULL;
|
||||
int32_t code = nodesCloneNode((SNode*)pMergeAgg, (SNode**)&pPartAgg);
|
||||
if (NULL == pPartAgg) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
|
||||
pPartAgg->node.groupAction = GROUP_ACTION_KEEP;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
if (NULL != pGroupKeys) {
|
||||
pPartAgg->pGroupKeys = pGroupKeys;
|
||||
code = createColumnByRewriteExprs(pPartAgg->pGroupKeys, &pPartAgg->node.pTargets);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeys) {
|
||||
pMergeAgg->pGroupKeys = nodesCloneList(pPartAgg->node.pTargets);
|
||||
if (NULL == pMergeAgg->pGroupKeys) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
pMergeAgg->pGroupKeys = NULL;
|
||||
code = nodesCloneList(pPartAgg->node.pTargets, &pMergeAgg->pGroupKeys);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pMergeAgg->node.pConditions = pConditions;
|
||||
|
@ -1090,7 +1094,7 @@ static int32_t stbSplAggNodeCreateMerge(SSplitContext* pCtx, SStableSplitInfo* p
|
|||
if (idx++ < originalLen) continue;
|
||||
SFunctionNode* pGroupKeyFunc = createGroupKeyAggFunc((SColumnNode*)node);
|
||||
if (!pGroupKeyFunc) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
break;
|
||||
}
|
||||
code = nodesListMakeStrictAppend(&extraAggFuncs, (SNode*)pGroupKeyFunc);
|
||||
|
@ -1104,7 +1108,7 @@ static int32_t stbSplAggNodeCreateMerge(SSplitContext* pCtx, SStableSplitInfo* p
|
|||
code = createColumnByRewriteExprs(extraAggFuncs, &pChildAgg->pTargets);
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
nodesListAppendList(((SAggLogicNode*)pChildAgg)->pAggFuncs, extraAggFuncs);
|
||||
code = nodesListAppendList(((SAggLogicNode*)pChildAgg)->pAggFuncs, extraAggFuncs);
|
||||
extraAggFuncs = NULL;
|
||||
}
|
||||
|
||||
|
@ -1165,7 +1169,7 @@ static int32_t stbSplSplitAggNodeForCrossTableMulSubplan(SSplitContext* pCxt, SS
|
|||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
pFirstScanSubplan = splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT);
|
||||
if (!pFirstScanSubplan) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pFirstScanSubplan) code = terrno;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1220,7 +1224,7 @@ static int32_t stbSplSplitAggNodeForCrossTable(SSplitContext* pCxt, SStableSplit
|
|||
SLogicSubplan* pScanSubplan = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pScanSubplan = splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT);
|
||||
if (!pScanSubplan) code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (!pScanSubplan) code = terrno;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
|
@ -1242,10 +1246,11 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
return stbSplSplitAggNodeForCrossTable(pCxt, pInfo);
|
||||
}
|
||||
|
||||
static SNode* stbSplCreateColumnNode(SExprNode* pExpr) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
static int32_t stbSplCreateColumnNode(SExprNode* pExpr, SNode** ppNode) {
|
||||
SColumnNode* pCol = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol);
|
||||
if (NULL == pCol) {
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
strcpy(pCol->dbName, ((SColumnNode*)pExpr)->dbName);
|
||||
|
@ -1258,22 +1263,26 @@ static SNode* stbSplCreateColumnNode(SExprNode* pExpr) {
|
|||
strcpy(pCol->node.aliasName, pExpr->aliasName);
|
||||
strcpy(pCol->node.userAlias, pExpr->userAlias);
|
||||
pCol->node.resType = pExpr->resType;
|
||||
return (SNode*)pCol;
|
||||
*ppNode = (SNode*)pCol;
|
||||
return code;
|
||||
}
|
||||
|
||||
static SNode* stbSplCreateOrderByExpr(SOrderByExprNode* pSortKey, SNode* pCol) {
|
||||
SOrderByExprNode* pOutput = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
||||
static int32_t stbSplCreateOrderByExpr(SOrderByExprNode* pSortKey, SNode* pCol, SNode** ppNode) {
|
||||
SOrderByExprNode* pOutput = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR, (SNode**)&pOutput);
|
||||
if (NULL == pOutput) {
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
pOutput->pExpr = nodesCloneNode(pCol);
|
||||
pOutput->pExpr = NULL;
|
||||
code = nodesCloneNode(pCol, &pOutput->pExpr);
|
||||
if (NULL == pOutput->pExpr) {
|
||||
nodesDestroyNode((SNode*)pOutput);
|
||||
return NULL;
|
||||
return code;
|
||||
}
|
||||
pOutput->order = pSortKey->order;
|
||||
pOutput->nullOrder = pSortKey->nullOrder;
|
||||
return (SNode*)pOutput;
|
||||
*ppNode = (SNode*)pOutput;
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets, SNodeList** pOutput) {
|
||||
|
@ -1288,7 +1297,11 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
|
|||
FOREACH(pTarget, pTargets) {
|
||||
if ((QUERY_NODE_COLUMN == nodeType(pSortExpr) && nodesEqualNode((SNode*)pSortExpr, pTarget)) ||
|
||||
(0 == strcmp(pSortExpr->aliasName, ((SColumnNode*)pTarget)->colName))) {
|
||||
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pTarget));
|
||||
SNode* pNew = NULL;
|
||||
code = stbSplCreateOrderByExpr(pSortKey, pTarget, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pMergeKeys, pNew);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
|
@ -1296,8 +1309,15 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
|
|||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !found) {
|
||||
SNode* pCol = stbSplCreateColumnNode(pSortExpr);
|
||||
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pCol));
|
||||
SNode* pCol = NULL;
|
||||
code = stbSplCreateColumnNode(pSortExpr, &pCol);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
SNode* pNew = NULL;
|
||||
code = stbSplCreateOrderByExpr(pSortKey, pCol, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pMergeKeys, pNew);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pTargets, pCol);
|
||||
} else {
|
||||
|
@ -1324,9 +1344,10 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut
|
|||
pSort->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SSortLogicNode* pPartSort = (SSortLogicNode*)nodesCloneNode((SNode*)pSort);
|
||||
SSortLogicNode* pPartSort = NULL;
|
||||
code = nodesCloneNode((SNode*)pSort, (SNode**)&pPartSort);
|
||||
if (NULL == pPartSort) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = code;
|
||||
}
|
||||
|
||||
SNodeList* pMergeKeys = NULL;
|
||||
|
@ -1392,9 +1413,10 @@ static int32_t stbSplGetSplitNodeForScan(SStableSplitInfo* pInfo, SLogicNode** p
|
|||
!((SProjectLogicNode*)pInfo->pSplitNode->pParent)->inputIgnoreGroup) {
|
||||
*pSplitNode = pInfo->pSplitNode->pParent;
|
||||
if (NULL != pInfo->pSplitNode->pLimit) {
|
||||
(*pSplitNode)->pLimit = nodesCloneNode(pInfo->pSplitNode->pLimit);
|
||||
(*pSplitNode)->pLimit = NULL;
|
||||
int32_t code = nodesCloneNode(pInfo->pSplitNode->pLimit, &(*pSplitNode)->pLimit);
|
||||
if (NULL == (*pSplitNode)->pLimit) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
((SLimitNode*)pInfo->pSplitNode->pLimit)->limit += ((SLimitNode*)pInfo->pSplitNode->pLimit)->offset;
|
||||
((SLimitNode*)pInfo->pSplitNode->pLimit)->offset = 0;
|
||||
|
@ -1436,7 +1458,7 @@ static int32_t stbSplSplitScanNodeWithPartTags(SSplitContext* pCxt, SStableSplit
|
|||
return code;
|
||||
}
|
||||
|
||||
static SNode* stbSplFindPrimaryKeyFromScan(SScanLogicNode* pScan) {
|
||||
static int32_t stbSplFindPrimaryKeyFromScan(SScanLogicNode* pScan, SNode** ppNode) {
|
||||
bool find = false;
|
||||
SNode* pCol = NULL;
|
||||
FOREACH(pCol, pScan->pScanCols) {
|
||||
|
@ -1446,19 +1468,29 @@ static SNode* stbSplFindPrimaryKeyFromScan(SScanLogicNode* pScan) {
|
|||
}
|
||||
}
|
||||
if (!find) {
|
||||
return NULL;
|
||||
*ppNode = NULL;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SNode* pTarget = NULL;
|
||||
FOREACH(pTarget, pScan->node.pTargets) {
|
||||
if (nodesEqualNode(pTarget, pCol)) {
|
||||
return pCol;
|
||||
*ppNode = pCol;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
nodesListStrictAppend(pScan->node.pTargets, nodesCloneNode(pCol));
|
||||
return pCol;
|
||||
SNode* pNew = NULL;
|
||||
int32_t code = nodesCloneNode(pCol, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pScan->node.pTargets, pNew);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*ppNode = pCol;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static SNode* stbSplFindPkFromScan(SScanLogicNode* pScan) {
|
||||
static int32_t stbSplFindPkFromScan(SScanLogicNode* pScan, SNode** ppNode) {
|
||||
int32_t code = 0;
|
||||
bool find = false;
|
||||
SNode* pCol = NULL;
|
||||
FOREACH(pCol, pScan->pScanCols) {
|
||||
|
@ -1468,16 +1500,25 @@ static SNode* stbSplFindPkFromScan(SScanLogicNode* pScan) {
|
|||
}
|
||||
}
|
||||
if (!find) {
|
||||
return NULL;
|
||||
*ppNode = NULL;
|
||||
return code;
|
||||
}
|
||||
SNode* pTarget = NULL;
|
||||
FOREACH(pTarget, pScan->node.pTargets) {
|
||||
if (nodesEqualNode(pTarget, pCol)) {
|
||||
return pCol;
|
||||
*ppNode = pCol;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
nodesListStrictAppend(pScan->node.pTargets, nodesCloneNode(pCol));
|
||||
return pCol;
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCol, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pScan->node.pTargets, pNew);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*ppNode = pCol;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t stbSplCreateMergeScanNode(SScanLogicNode* pScan, SLogicNode** pOutputMergeScan,
|
||||
|
@ -1486,9 +1527,10 @@ static int32_t stbSplCreateMergeScanNode(SScanLogicNode* pScan, SLogicNode** pOu
|
|||
pScan->node.pChildren = NULL;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SScanLogicNode* pMergeScan = (SScanLogicNode*)nodesCloneNode((SNode*)pScan);
|
||||
SScanLogicNode* pMergeScan = NULL;
|
||||
code = nodesCloneNode((SNode*)pScan, (SNode**)&pMergeScan);
|
||||
if (NULL == pMergeScan) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = code;
|
||||
}
|
||||
|
||||
SNodeList* pMergeKeys = NULL;
|
||||
|
@ -1498,9 +1540,15 @@ static int32_t stbSplCreateMergeScanNode(SScanLogicNode* pScan, SLogicNode** pOu
|
|||
pMergeScan->node.pChildren = pChildren;
|
||||
splSetParent((SLogicNode*)pMergeScan);
|
||||
|
||||
SNode* pTs = stbSplFindPrimaryKeyFromScan(pMergeScan);
|
||||
code = stbSplCreateMergeKeysByPrimaryKey(pTs, pMergeScan->scanSeq[0] > 0 ? ORDER_ASC : ORDER_DESC, &pMergeKeys);
|
||||
SNode* pPk = stbSplFindPkFromScan(pMergeScan);
|
||||
SNode* pTs = NULL;
|
||||
code = stbSplFindPrimaryKeyFromScan(pMergeScan, &pTs);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplCreateMergeKeysByPrimaryKey(pTs, pMergeScan->scanSeq[0] > 0 ? ORDER_ASC : ORDER_DESC, &pMergeKeys);
|
||||
}
|
||||
SNode* pPk = NULL;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplFindPkFromScan(pMergeScan, &pPk);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pPk) {
|
||||
code = stbSplCreateMergeKeysByExpr(pPk, pMergeScan->scanSeq[0] > 0 ? ORDER_ASC : ORDER_DESC, &pMergeKeys);
|
||||
}
|
||||
|
@ -1589,11 +1637,16 @@ static int32_t stbSplSplitJoinNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
|
|||
|
||||
static int32_t stbSplCreateMergeKeysForPartitionNode(SLogicNode* pPart, SNodeList** pMergeKeys) {
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pPart->pChildren, 0);
|
||||
SNode* pPrimaryKey = nodesCloneNode(stbSplFindPrimaryKeyFromScan(pScan));
|
||||
if (NULL == pPrimaryKey) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
SNode* pPK = NULL;
|
||||
SNode* pPrimaryKey = NULL;
|
||||
int32_t code = stbSplFindPrimaryKeyFromScan(pScan, &pPK);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesCloneNode(pPK, &pPrimaryKey);
|
||||
}
|
||||
int32_t code = nodesListAppend(pPart->pTargets, pPrimaryKey);
|
||||
if (NULL == pPrimaryKey) {
|
||||
return code;
|
||||
}
|
||||
code = nodesListStrictAppend(pPart->pTargets, pPrimaryKey);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = stbSplCreateMergeKeysByPrimaryKey(pPrimaryKey, pScan->scanSeq[0] > 0 ? ORDER_ASC : ORDER_DESC, pMergeKeys);
|
||||
}
|
||||
|
@ -1711,8 +1764,11 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
|
|||
|
||||
SNode* pChild = NULL;
|
||||
FOREACH(pChild, pSplitNode->pChildren) {
|
||||
SLogicSubplan* pNewSubplan = splCreateSubplan(pCxt, (SLogicNode*)pChild);
|
||||
code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan);
|
||||
SLogicSubplan* pNewSubplan = NULL;
|
||||
code = splCreateSubplan(pCxt, (SLogicNode*)pChild, &pNewSubplan);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pUnionSubplan->pChildren, (SNode*)pNewSubplan);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
REPLACE_NODE(NULL);
|
||||
code = splMountSubplan(pNewSubplan, pSubplanChildren);
|
||||
|
@ -1725,7 +1781,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL != pSubplanChildren) {
|
||||
if (pSubplanChildren->length > 0) {
|
||||
nodesListMakeStrictAppendList(&pUnionSubplan->pChildren, pSubplanChildren);
|
||||
code = nodesListMakeStrictAppendList(&pUnionSubplan->pChildren, pSubplanChildren);
|
||||
} else {
|
||||
nodesDestroyList(pSubplanChildren);
|
||||
}
|
||||
|
@ -1752,17 +1808,25 @@ static bool unAllSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan,
|
|||
|
||||
static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGroupId, SLogicSubplan* pSubplan,
|
||||
SProjectLogicNode* pProject) {
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE, (SNode**)&pExchange);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pExchange->srcStartGroupId = startGroupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId - 1;
|
||||
pExchange->node.precision = pProject->node.precision;
|
||||
pExchange->node.pTargets = nodesCloneList(pProject->node.pTargets);
|
||||
pExchange->node.pConditions = nodesCloneNode(pProject->node.pConditions);
|
||||
if (NULL == pExchange->node.pTargets || (NULL != pProject->node.pConditions && NULL == pExchange->node.pConditions)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
pExchange->node.pTargets = NULL;
|
||||
code = nodesCloneList(pProject->node.pTargets, &pExchange->node.pTargets);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return code;
|
||||
}
|
||||
pExchange->node.pConditions = NULL;
|
||||
code = nodesCloneNode(pProject->node.pConditions, &pExchange->node.pConditions);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return code;
|
||||
}
|
||||
TSWAP(pExchange->node.pLimit, pProject->node.pLimit);
|
||||
|
||||
|
@ -1808,21 +1872,24 @@ typedef struct SUnionDistinctSplitInfo {
|
|||
|
||||
static int32_t unDistSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGroupId, SLogicSubplan* pSubplan,
|
||||
SAggLogicNode* pAgg) {
|
||||
SExchangeLogicNode* pExchange = (SExchangeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE);
|
||||
SExchangeLogicNode* pExchange = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE, (SNode**)&pExchange);
|
||||
if (NULL == pExchange) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
pExchange->srcStartGroupId = startGroupId;
|
||||
pExchange->srcEndGroupId = pCxt->groupId - 1;
|
||||
pExchange->node.precision = pAgg->node.precision;
|
||||
pExchange->node.pTargets = nodesCloneList(pAgg->pGroupKeys);
|
||||
pExchange->node.pTargets = NULL;
|
||||
code = nodesCloneList(pAgg->pGroupKeys, &pExchange->node.pTargets);
|
||||
if (NULL == pExchange->node.pTargets) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
nodesDestroyNode((SNode*)pExchange);
|
||||
return code;
|
||||
}
|
||||
|
||||
pSubplan->subplanType = SUBPLAN_TYPE_MERGE;
|
||||
|
||||
return nodesListMakeAppend(&pAgg->node.pChildren, (SNode*)pExchange);
|
||||
return nodesListMakeStrictAppend(&pAgg->node.pChildren, (SNode*)pExchange);
|
||||
}
|
||||
|
||||
static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
|
||||
|
@ -1910,10 +1977,7 @@ static int32_t insertSelectSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
|||
SNodeList* pSubplanChildren = info.pSubplan->pChildren;
|
||||
int32_t code = splCreateExchangeNodeForSubplan(pCxt, info.pSubplan, info.pQueryRoot, SUBPLAN_TYPE_MODIFY);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pNewSubplan = splCreateSubplan(pCxt, info.pQueryRoot);
|
||||
if (NULL == pNewSubplan) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
code = splCreateSubplan(pCxt, info.pQueryRoot, &pNewSubplan);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pNewSubplan);
|
||||
|
@ -1967,7 +2031,7 @@ static int32_t qnodeSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
|
|||
}
|
||||
code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, (SNode*)pScanSubplan);
|
||||
} else {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
}
|
||||
}
|
||||
info.pSubplan->subplanType = SUBPLAN_TYPE_COMPUTE;
|
||||
|
@ -1989,25 +2053,32 @@ static const SSplitRule splitRuleSet[] = {
|
|||
|
||||
static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
|
||||
|
||||
static void dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) {
|
||||
static int32_t dumpLogicSubplan(const char* pRuleName, SLogicSubplan* pSubplan) {
|
||||
int32_t code = 0;
|
||||
if (!tsQueryPlannerTrace) {
|
||||
return;
|
||||
return code;
|
||||
}
|
||||
char* pStr = NULL;
|
||||
nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL);
|
||||
if (NULL == pRuleName) {
|
||||
qDebugL("before split, JsonPlan: %s", pStr);
|
||||
} else {
|
||||
qDebugL("apply split %s rule, JsonPlan: %s", pRuleName, pStr);
|
||||
code = nodesNodeToString((SNode*)pSubplan, false, &pStr, NULL);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (NULL == pRuleName) {
|
||||
qDebugL("before split, JsonPlan: %s", pStr);
|
||||
} else {
|
||||
qDebugL("apply split %s rule, JsonPlan: %s", pRuleName, pStr);
|
||||
}
|
||||
taosMemoryFree(pStr);
|
||||
}
|
||||
taosMemoryFree(pStr);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t applySplitRule(SPlanContext* pCxt, SLogicSubplan* pSubplan) {
|
||||
SSplitContext cxt = {
|
||||
.pPlanCxt = pCxt, .queryId = pSubplan->id.queryId, .groupId = pSubplan->id.groupId + 1, .split = false};
|
||||
bool split = false;
|
||||
dumpLogicSubplan(NULL, pSubplan);
|
||||
int32_t code = dumpLogicSubplan(NULL, pSubplan);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
do {
|
||||
split = false;
|
||||
for (int32_t i = 0; i < splitRuleNum; ++i) {
|
||||
|
@ -2018,7 +2089,10 @@ static int32_t applySplitRule(SPlanContext* pCxt, SLogicSubplan* pSubplan) {
|
|||
}
|
||||
if (cxt.split) {
|
||||
split = true;
|
||||
dumpLogicSubplan(splitRuleSet[i].pName, pSubplan);
|
||||
code = dumpLogicSubplan(splitRuleSet[i].pName, pSubplan);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (split);
|
||||
|
|
|
@ -35,7 +35,7 @@ static char* getUsageErrFormat(int32_t errCode) {
|
|||
int32_t generateUsageErrMsg(char* pBuf, int32_t len, int32_t errCode, ...) {
|
||||
va_list vArgList;
|
||||
va_start(vArgList, errCode);
|
||||
vsnprintf(pBuf, len, getUsageErrFormat(errCode), vArgList);
|
||||
(void)vsnprintf(pBuf, len, getUsageErrFormat(errCode), vArgList);
|
||||
va_end(vArgList);
|
||||
return errCode;
|
||||
}
|
||||
|
@ -49,7 +49,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
|||
SCreateColumnCxt* pCxt = (SCreateColumnCxt*)pContext;
|
||||
switch (nodeType(pNode)) {
|
||||
case QUERY_NODE_COLUMN: {
|
||||
SNode* pCol = nodesCloneNode(pNode);
|
||||
SNode* pCol = NULL;
|
||||
pCxt->errCode = nodesCloneNode(pNode, &pCol);
|
||||
if (NULL == pCol) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -61,7 +62,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
|||
case QUERY_NODE_FUNCTION:
|
||||
case QUERY_NODE_CASE_WHEN: {
|
||||
SExprNode* pExpr = (SExprNode*)pNode;
|
||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SColumnNode* pCol = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_COLUMN, (SNode**)&pCol);
|
||||
if (NULL == pCol) {
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
@ -88,9 +90,12 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
|||
}
|
||||
|
||||
int32_t createColumnByRewriteExprs(SNodeList* pExprs, SNodeList** pList) {
|
||||
SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList)};
|
||||
if (NULL == cxt.pList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = *pList};
|
||||
if (!cxt.pList) {
|
||||
int32_t code = nodesMakeList(&cxt.pList);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
nodesWalkExprs(pExprs, doCreateColumn, &cxt);
|
||||
|
@ -105,9 +110,12 @@ int32_t createColumnByRewriteExprs(SNodeList* pExprs, SNodeList** pList) {
|
|||
}
|
||||
|
||||
int32_t createColumnByRewriteExpr(SNode* pExpr, SNodeList** pList) {
|
||||
SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList)};
|
||||
if (NULL == cxt.pList) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
SCreateColumnCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pList = *pList};
|
||||
if (!cxt.pList) {
|
||||
int32_t code = nodesMakeList(&cxt.pList);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
nodesWalkExpr(pExpr, doCreateColumn, &cxt);
|
||||
|
@ -517,17 +525,26 @@ int32_t collectTableAliasFromNodes(SNode* pNode, SSHashObj** ppRes) {
|
|||
}
|
||||
}
|
||||
|
||||
tSimpleHashPut(*ppRes, pCol->tableAlias, strlen(pCol->tableAlias), NULL, 0);
|
||||
}
|
||||
|
||||
FOREACH(pNode, pCurr->pChildren) {
|
||||
code = collectTableAliasFromNodes(pNode, ppRes);
|
||||
code = tSimpleHashPut(*ppRes, pCol->tableAlias, strlen(pCol->tableAlias), NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
FOREACH(pNode, pCurr->pChildren) {
|
||||
code = collectTableAliasFromNodes(pNode, ppRes);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
tSimpleHashCleanup(*ppRes);
|
||||
*ppRes = NULL;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
bool isPartTagAgg(SAggLogicNode* pAgg) {
|
||||
|
@ -545,25 +562,35 @@ bool isPartTableWinodw(SWindowLogicNode* pWindow) {
|
|||
return pWindow->isPartTb || keysHasTbname(stbGetPartKeys((SLogicNode*)nodesListGetNode(pWindow->node.pChildren, 0)));
|
||||
}
|
||||
|
||||
bool cloneLimit(SLogicNode* pParent, SLogicNode* pChild, uint8_t cloneWhat) {
|
||||
SLimitNode* pLimit;
|
||||
bool cloned = false;
|
||||
int32_t cloneLimit(SLogicNode* pParent, SLogicNode* pChild, uint8_t cloneWhat, bool* pCloned) {
|
||||
SLimitNode* pLimit = NULL, *pSlimit = NULL;
|
||||
int32_t code = 0;
|
||||
bool cloned = false;
|
||||
if (pParent->pLimit && (cloneWhat & CLONE_LIMIT)) {
|
||||
pChild->pLimit = nodesCloneNode(pParent->pLimit);
|
||||
pLimit = (SLimitNode*)pChild->pLimit;
|
||||
pLimit->limit += pLimit->offset;
|
||||
pLimit->offset = 0;
|
||||
cloned = true;
|
||||
code = nodesCloneNode(pParent->pLimit, (SNode**)&pLimit);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pLimit->limit += pLimit->offset;
|
||||
pLimit->offset = 0;
|
||||
cloned = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (pParent->pSlimit && (cloneWhat & CLONE_SLIMIT)) {
|
||||
pChild->pSlimit = nodesCloneNode(pParent->pSlimit);
|
||||
pLimit = (SLimitNode*)pChild->pSlimit;
|
||||
pLimit->limit += pLimit->offset;
|
||||
pLimit->offset = 0;
|
||||
cloned = true;
|
||||
code = nodesCloneNode(pParent->pSlimit, (SNode**)&pSlimit);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pSlimit->limit += pSlimit->offset;
|
||||
pSlimit->offset = 0;
|
||||
cloned = true;
|
||||
}
|
||||
}
|
||||
return cloned;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pChild->pLimit = (SNode*)pLimit;
|
||||
pChild->pSlimit = (SNode*)pSlimit;
|
||||
*pCloned = cloned;
|
||||
} else {
|
||||
nodesDestroyNode((SNode*)pLimit);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) {
|
||||
|
@ -583,12 +610,17 @@ bool keysHasCol(SNodeList* pKeys) {
|
|||
}
|
||||
|
||||
SFunctionNode* createGroupKeyAggFunc(SColumnNode* pGroupCol) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
SFunctionNode* pFunc = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunc);
|
||||
if (pFunc) {
|
||||
strcpy(pFunc->functionName, "_group_key");
|
||||
strcpy(pFunc->node.aliasName, pGroupCol->node.aliasName);
|
||||
strcpy(pFunc->node.userAlias, pGroupCol->node.userAlias);
|
||||
int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode((SNode*)pGroupCol));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode((SNode*)pGroupCol, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeStrictAppend(&pFunc->pParameterList, pNew);
|
||||
}
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
code = fmGetFuncInfo(pFunc, NULL, 0);
|
||||
}
|
||||
|
@ -596,10 +628,17 @@ SFunctionNode* createGroupKeyAggFunc(SColumnNode* pGroupCol) {
|
|||
nodesDestroyNode((SNode*)pFunc);
|
||||
pFunc = NULL;
|
||||
}
|
||||
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name) - 1, "%s.%p", pFunc->functionName, pFunc);
|
||||
taosCreateMD5Hash(name, len);
|
||||
strncpy(pFunc->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0};
|
||||
int32_t len = snprintf(name, sizeof(name) - 1, "%s.%p", pFunc->functionName, pFunc);
|
||||
(void)taosCreateMD5Hash(name, len);
|
||||
strncpy(pFunc->node.aliasName, name, TSDB_COL_NAME_LEN - 1);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
terrno = code;
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
pFunc = NULL;
|
||||
}
|
||||
return pFunc;
|
||||
}
|
||||
|
@ -656,14 +695,20 @@ int32_t tagScanSetExecutionMode(SScanLogicNode* pScan) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SNode* pCond = nodesCloneNode(pScan->node.pConditions);
|
||||
SNode* pCond = NULL;
|
||||
int32_t code = nodesCloneNode(pScan->node.pConditions, &pCond);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
SNode* pTagCond = NULL;
|
||||
SNode* pTagIndexCond = NULL;
|
||||
filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL);
|
||||
if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) {
|
||||
pScan->onlyMetaCtbIdx = false;
|
||||
} else {
|
||||
pScan->onlyMetaCtbIdx = true;
|
||||
code = filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) {
|
||||
pScan->onlyMetaCtbIdx = false;
|
||||
} else {
|
||||
pScan->onlyMetaCtbIdx = true;
|
||||
}
|
||||
}
|
||||
nodesDestroyNode(pCond);
|
||||
nodesDestroyNode(pTagIndexCond);
|
||||
|
|
|
@ -19,22 +19,28 @@
|
|||
#include "scalar.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
static void debugPrintNode(SNode* pNode) {
|
||||
static int32_t debugPrintNode(SNode* pNode) {
|
||||
char* pStr = NULL;
|
||||
nodesNodeToString(pNode, false, &pStr, NULL);
|
||||
printf("%s\n", pStr);
|
||||
taosMemoryFree(pStr);
|
||||
return;
|
||||
int32_t code = nodesNodeToString(pNode, false, &pStr, NULL);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
(void)printf("%s\n", pStr);
|
||||
taosMemoryFree(pStr);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static void dumpQueryPlan(SQueryPlan* pPlan) {
|
||||
static int32_t dumpQueryPlan(SQueryPlan* pPlan) {
|
||||
int32_t code = 0;
|
||||
if (!tsQueryPlannerTrace) {
|
||||
return;
|
||||
return code;
|
||||
}
|
||||
char* pStr = NULL;
|
||||
nodesNodeToString((SNode*)pPlan, false, &pStr, NULL);
|
||||
planDebugL("QID:0x%" PRIx64 " Query Plan, JsonPlan: %s", pPlan->queryId, pStr);
|
||||
taosMemoryFree(pStr);
|
||||
code = nodesNodeToString((SNode*)pPlan, false, &pStr, NULL);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
planDebugL("QID:0x%" PRIx64 " Query Plan, JsonPlan: %s", pPlan->queryId, pStr);
|
||||
taosMemoryFree(pStr);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNodeList) {
|
||||
|
@ -61,9 +67,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
|
|||
code = validateQueryPlan(pCxt, *pPlan);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
dumpQueryPlan(*pPlan);
|
||||
code = dumpQueryPlan(*pPlan);
|
||||
}
|
||||
nodesReleaseAllocator(pCxt->allocatorId);
|
||||
(void)nodesReleaseAllocator(pCxt->allocatorId);
|
||||
|
||||
nodesDestroyNode((SNode*)pLogicSubplan);
|
||||
nodesDestroyNode((SNode*)pLogicPlan);
|
||||
|
@ -72,10 +78,15 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
|
|||
}
|
||||
|
||||
static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDownstreamSourceNode* pSource) {
|
||||
int32_t code = 0;
|
||||
if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == nodeType(pNode)) {
|
||||
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pNode;
|
||||
if (groupId >= pExchange->srcStartGroupId && groupId <= pExchange->srcEndGroupId) {
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode((SNode*)pSource, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, pNew);
|
||||
}
|
||||
}
|
||||
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) {
|
||||
SMergePhysiNode* pMerge = (SMergePhysiNode*)pNode;
|
||||
|
@ -87,17 +98,23 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown
|
|||
} else {
|
||||
--(pMerge->numOfChannels);
|
||||
}
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, nodesCloneNode((SNode*)pSource));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode((SNode*)pSource, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
return nodesListMakeStrictAppend(&pExchange->pSrcEndPoints, pNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SNode* pChild = NULL;
|
||||
FOREACH(pChild, pNode->pChildren) {
|
||||
if (TSDB_CODE_SUCCESS != setSubplanExecutionNode((SPhysiNode*)pChild, groupId, pSource)) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
FOREACH(pChild, pNode->pChildren) {
|
||||
if (TSDB_CODE_SUCCESS != (code = setSubplanExecutionNode((SPhysiNode*)pChild, groupId, pSource))) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t qContinuePlanPostQuery(void *pPostPlan) {
|
||||
|
|
|
@ -146,8 +146,8 @@ TEST_F(PlanStmtTest, basic) {
|
|||
{
|
||||
prepare("SELECT * FROM t1 WHERE c1 = ? AND c2 = ?");
|
||||
TAOS_MULTI_BIND* pBindParams = createBindParams(2);
|
||||
buildIntegerParam(pBindParams, 0, 10, TSDB_DATA_TYPE_INT);
|
||||
buildStringParam(pBindParams, 1, "abc", TSDB_DATA_TYPE_VARCHAR, strlen("abc"));
|
||||
(void)buildIntegerParam(pBindParams, 0, 10, TSDB_DATA_TYPE_INT);
|
||||
(void)buildStringParam(pBindParams, 1, "abc", TSDB_DATA_TYPE_VARCHAR, strlen("abc"));
|
||||
bindParams(pBindParams, -1);
|
||||
exec();
|
||||
destoryBindParams(pBindParams, 2);
|
||||
|
@ -156,8 +156,8 @@ TEST_F(PlanStmtTest, basic) {
|
|||
{
|
||||
prepare("SELECT MAX(?), MAX(?) FROM t1");
|
||||
TAOS_MULTI_BIND* pBindParams = createBindParams(2);
|
||||
buildIntegerParam(pBindParams, 0, 10, TSDB_DATA_TYPE_TINYINT);
|
||||
buildIntegerParam(pBindParams, 1, 20, TSDB_DATA_TYPE_INT);
|
||||
(void)buildIntegerParam(pBindParams, 0, 10, TSDB_DATA_TYPE_TINYINT);
|
||||
(void)buildIntegerParam(pBindParams, 1, 20, TSDB_DATA_TYPE_INT);
|
||||
bindParams(pBindParams, -1);
|
||||
exec();
|
||||
destoryBindParams(pBindParams, 2);
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
class PlannerEnv : public testing::Environment {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
// TODO(smj) : How to handle return value of fmFuncMgtInit
|
||||
(void)fmFuncMgtInit();
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, fmFuncMgtInit());
|
||||
initMetaDataEnv();
|
||||
generateMetaData();
|
||||
initLog(TD_TMP_DIR_PATH "td");
|
||||
initCfg();
|
||||
nodesInitAllocatorSet();
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesInitAllocatorSet());
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
|
@ -66,7 +65,7 @@ class PlannerEnv : public testing::Environment {
|
|||
tsAsyncLog = 0;
|
||||
|
||||
taosRemoveDir(path);
|
||||
taosMkDir(path);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS,taosMkDir(path));
|
||||
tstrncpy(tsLogDir, path, PATH_MAX);
|
||||
if (taosInitLog("taoslog", 1) != 0) {
|
||||
std::cout << "failed to init log file" << std::endl;
|
||||
|
@ -117,7 +116,7 @@ static void parseArg(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
testing::AddGlobalTestEnvironment(new PlannerEnv());
|
||||
(void)testing::AddGlobalTestEnvironment(new PlannerEnv());
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
parseArg(argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
@ -93,7 +93,7 @@ int32_t getLogLevel() { return g_logLevel; }
|
|||
|
||||
class PlannerTestBaseImpl {
|
||||
public:
|
||||
PlannerTestBaseImpl() : sqlNo_(0), sqlNum_(0) {}
|
||||
PlannerTestBaseImpl() : sqlNo_(0), sqlNum_(0) { assert(qInitKeywordsTable() == 0); }
|
||||
|
||||
void useDb(const string& user, const string& db) {
|
||||
caseEnv_.acctId_ = 0;
|
||||
|
@ -131,8 +131,8 @@ class PlannerTestBaseImpl {
|
|||
void runImpl(const string& sql, int32_t queryPolicy) {
|
||||
int64_t allocatorId = 0;
|
||||
if (g_useNodeAllocator) {
|
||||
nodesCreateAllocator(sqlNo_, 32 * 1024, &allocatorId);
|
||||
nodesAcquireAllocator(allocatorId);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesCreateAllocator(sqlNo_, 32 * 1024, &allocatorId));
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesAcquireAllocator(allocatorId));
|
||||
}
|
||||
|
||||
reset();
|
||||
|
@ -166,12 +166,12 @@ class PlannerTestBaseImpl {
|
|||
dump(g_dumpModule);
|
||||
} catch (...) {
|
||||
dump(DUMP_MODULE_ALL);
|
||||
nodesReleaseAllocator(allocatorId);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesReleaseAllocator(allocatorId));
|
||||
nodesDestroyAllocator(allocatorId);
|
||||
throw;
|
||||
}
|
||||
|
||||
nodesReleaseAllocator(allocatorId);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesReleaseAllocator(allocatorId));
|
||||
nodesDestroyAllocator(allocatorId);
|
||||
}
|
||||
|
||||
|
@ -448,12 +448,12 @@ class PlannerTestBaseImpl {
|
|||
pCmdMsg->msgLen = tSerializeSMCreateSmaReq(NULL, 0, pStmt->pReq);
|
||||
pCmdMsg->pMsg = taosMemoryMalloc(pCmdMsg->msgLen);
|
||||
if (!pCmdMsg->pMsg) FAIL();
|
||||
tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq);
|
||||
ASSERT_TRUE(0 < tSerializeSMCreateSmaReq(pCmdMsg->pMsg, pCmdMsg->msgLen, pStmt->pReq));
|
||||
((SQuery*)pQuery)->pCmdMsg = pCmdMsg;
|
||||
|
||||
tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, tDeserializeSMCreateSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req));
|
||||
g_mockCatalogService->createSmaIndex(&req);
|
||||
nodesStringToNode(req.ast, &pCxt->pAstRoot);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesStringToNode(req.ast, &pCxt->pAstRoot));
|
||||
pCxt->deleteMark = req.deleteMark;
|
||||
tFreeSMCreateSmaReq(&req);
|
||||
nodesDestroyNode(pQuery->pRoot);
|
||||
|
|
|
@ -3931,8 +3931,9 @@ int32_t fltSclGetOrCreateColumnRange(SColumnNode *colNode, SArray *colRangeList,
|
|||
}
|
||||
// TODO(smj):wait for nodesCloneNode change it's return value, use terrno for now.
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
SColumnNode *pColumnNode = (SColumnNode *)nodesCloneNode((SNode *)colNode);
|
||||
FLT_ERR_RET(terrno);
|
||||
SColumnNode *pColumnNode = NULL;
|
||||
int32_t code = nodesCloneNode((SNode *)colNode, (SNode**)&pColumnNode);
|
||||
FLT_ERR_RET(code);
|
||||
SFltSclColumnRange newColRange = {.colNode = pColumnNode, .points = taosArrayInit(4, sizeof(SFltSclPoint))};
|
||||
if (NULL == newColRange.points) {
|
||||
FLT_ERR_RET(terrno);
|
||||
|
@ -4915,16 +4916,22 @@ static int32_t fltSclCollectOperatorFromNode(SNode *pNode, SArray *sclOpList) {
|
|||
|
||||
SValueNode *valNode = (SValueNode *)pOper->pRight;
|
||||
if (IS_NUMERIC_TYPE(valNode->node.resType.type) || valNode->node.resType.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
SFltSclOperator sclOp = {.colNode = (SColumnNode *)nodesCloneNode(pOper->pLeft),
|
||||
.valNode = (SValueNode *)nodesCloneNode(pOper->pRight),
|
||||
SNode* pLeft = NULL, *pRight = NULL;
|
||||
int32_t code = nodesCloneNode(pOper->pLeft, &pLeft);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
code = nodesCloneNode(pOper->pRight, &pRight);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
nodesDestroyNode(pLeft);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SFltSclOperator sclOp = {.colNode = (SColumnNode *)pLeft,
|
||||
.valNode = (SValueNode *)pRight,
|
||||
.type = pOper->opType};
|
||||
if (NULL == sclOp.colNode) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == sclOp.valNode) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == taosArrayPush(sclOpList, &sclOp)) {
|
||||
nodesDestroyNode(pLeft);
|
||||
nodesDestroyNode(pRight);
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
|
@ -5209,8 +5216,12 @@ EConditionType filterClassifyCondition(SNode *pNode) {
|
|||
}
|
||||
|
||||
int32_t filterIsMultiTableColsCond(SNode *pCond, bool *res) {
|
||||
SNodeList *pCondCols = nodesMakeList();
|
||||
int32_t code = nodesCollectColumnsFromNode(pCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols);
|
||||
SNodeList *pCondCols = NULL;
|
||||
int32_t code = nodesMakeList(&pCondCols);
|
||||
if (TSDB_CODE_SUCCESS!= code) {
|
||||
return code;
|
||||
}
|
||||
code = nodesCollectColumnsFromNode(pCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
if (LIST_LENGTH(pCondCols) >= 2) {
|
||||
SColumnNode *pFirstCol = (SColumnNode *)nodesListGetNode(pCondCols, 0);
|
||||
|
@ -5249,32 +5260,56 @@ static int32_t partitionLogicCond(SNode **pCondition, SNode **pPrimaryKeyCond, S
|
|||
}
|
||||
if (result) {
|
||||
if (NULL != pOtherCond) {
|
||||
code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pOtherConds, pNew);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (filterClassifyCondition(pCond)) {
|
||||
case COND_TYPE_PRIMARY_KEY:
|
||||
if (NULL != pPrimaryKeyCond) {
|
||||
code = nodesListMakeAppend(&pPrimaryKeyConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pPrimaryKeyConds, pNew);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG_INDEX:
|
||||
if (NULL != pTagIndexCond) {
|
||||
code = nodesListMakeAppend(&pTagIndexConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pTagIndexConds, pNew);
|
||||
}
|
||||
}
|
||||
if (NULL != pTagCond) {
|
||||
code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pTagConds, pNew);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_TAG:
|
||||
if (NULL != pTagCond) {
|
||||
code = nodesListMakeAppend(&pTagConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pTagConds, pNew);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COND_TYPE_NORMAL:
|
||||
default:
|
||||
if (NULL != pOtherCond) {
|
||||
code = nodesListMakeAppend(&pOtherConds, nodesCloneNode(pCond));
|
||||
SNode* pNew = NULL;
|
||||
code = nodesCloneNode(pCond, &pNew);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListMakeAppend(&pOtherConds, pNew);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -5361,9 +5396,10 @@ int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode *
|
|||
if (NULL != pTagCond) {
|
||||
SNode *pTempCond = *pCondition;
|
||||
if (NULL != pTagIndexCond) {
|
||||
pTempCond = nodesCloneNode(*pCondition);
|
||||
pTempCond = NULL;
|
||||
int32_t code = nodesCloneNode(*pCondition, &pTempCond);
|
||||
if (NULL == pTempCond) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
*pTagCond = pTempCond;
|
||||
|
|
|
@ -1028,10 +1028,10 @@ _return:
|
|||
|
||||
EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||
if (opType <= OP_TYPE_CALC_MAX) {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1040,10 +1040,10 @@ EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opTy
|
|||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode *)res;
|
||||
} else {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1221,11 +1221,11 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1295,11 +1295,11 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1345,11 +1345,11 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1408,11 +1408,11 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
|||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,10 @@ void flttInitLogFile() {
|
|||
}
|
||||
|
||||
int32_t flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SValueNode *vnode = (SValueNode *)node;
|
||||
vnode->node.resType.type = dataType;
|
||||
|
@ -90,9 +91,10 @@ int32_t flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
|
|||
void *value) {
|
||||
static uint64_t dbidx = 0;
|
||||
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SColumnNode *rnode = (SColumnNode *)node;
|
||||
rnode->node.resType.type = dataType;
|
||||
|
@ -170,9 +172,10 @@ int32_t flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
|
|||
}
|
||||
|
||||
int32_t flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
onode->node.resType.type = resType;
|
||||
|
@ -187,16 +190,18 @@ int32_t flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNo
|
|||
}
|
||||
|
||||
int32_t flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||
onode->condType = opType;
|
||||
onode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
onode->node.resType.bytes = sizeof(bool);
|
||||
|
||||
onode->pParameterList = nodesMakeList();
|
||||
onode->pParameterList = NULL;
|
||||
code = nodesMakeList(&onode->pParameterList);
|
||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||
FLT_ERR_RET(nodesListAppend(onode->pParameterList, nodeList[i]));
|
||||
}
|
||||
|
@ -206,9 +211,10 @@ int32_t flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nod
|
|||
}
|
||||
|
||||
int32_t flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeList *nodeList) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||
onode->condType = opType;
|
||||
|
@ -222,9 +228,10 @@ int32_t flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNo
|
|||
}
|
||||
|
||||
int32_t flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_NODE_LIST, &node);
|
||||
if (NULL == node) {
|
||||
FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->node.resType.type = resType;
|
||||
|
|
|
@ -56,8 +56,8 @@
|
|||
|
||||
class constantTest {
|
||||
public:
|
||||
constantTest() { InitRegexCache(); }
|
||||
~constantTest() { DestroyRegexCache(); }
|
||||
constantTest() { (void)InitRegexCache(); }
|
||||
~constantTest() { (void)DestroyRegexCache(); }
|
||||
};
|
||||
static constantTest test;
|
||||
namespace {
|
||||
|
@ -143,9 +143,10 @@ int32_t scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t
|
|||
}
|
||||
|
||||
int32_t scltMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_VALUE, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SValueNode *vnode = (SValueNode *)node;
|
||||
vnode->node.resType.type = dataType;
|
||||
|
@ -168,9 +169,10 @@ int32_t scltMakeValueNode(SNode **pNode, int32_t dataType, void *value) {
|
|||
|
||||
int32_t scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum,
|
||||
void *value) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_COLUMN, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SColumnNode *rnode = (SColumnNode *)node;
|
||||
rnode->node.resType.type = dataType;
|
||||
|
@ -182,7 +184,6 @@ int32_t scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
|
|||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == *block) {
|
||||
SSDataBlock *res = createDataBlock();
|
||||
for (int32_t i = 0; i < 2; ++i) {
|
||||
|
@ -266,9 +267,10 @@ int32_t scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType,
|
|||
|
||||
int32_t scltMakeOpNode2(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight,
|
||||
bool isReverse) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
onode->node.resType.type = resType;
|
||||
|
@ -288,9 +290,10 @@ int32_t scltMakeOpNode2(SNode **pNode, EOperatorType opType, int32_t resType, SN
|
|||
}
|
||||
|
||||
int32_t scltMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
onode->node.resType.type = resType;
|
||||
|
@ -305,9 +308,10 @@ int32_t scltMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNo
|
|||
}
|
||||
|
||||
int32_t scltMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_NODE_LIST, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SNodeListNode *lnode = (SNodeListNode *)node;
|
||||
lnode->node.resType.type = resType;
|
||||
|
@ -318,16 +322,21 @@ int32_t scltMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) {
|
|||
}
|
||||
|
||||
int32_t scltMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
SLogicConditionNode *onode = (SLogicConditionNode *)node;
|
||||
onode->condType = opType;
|
||||
onode->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
onode->node.resType.bytes = sizeof(bool);
|
||||
|
||||
onode->pParameterList = nodesMakeList();
|
||||
onode->pParameterList = NULL;
|
||||
code = nodesMakeList(&onode->pParameterList);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||
SCL_ERR_RET(nodesListAppend(onode->pParameterList, nodeList[i]));
|
||||
}
|
||||
|
@ -337,9 +346,10 @@ int32_t scltMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nod
|
|||
}
|
||||
|
||||
int32_t scltMakeTargetNode(SNode **pNode, int16_t dataBlockId, int16_t slotId, SNode *snode) {
|
||||
SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_TARGET);
|
||||
SNode *node = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_TARGET, &node);
|
||||
if (NULL == node) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
STargetNode *onode = (STargetNode *)node;
|
||||
onode->pExpr = snode;
|
||||
|
@ -632,7 +642,8 @@ TEST(constantTest, int_in_smallint1) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList *list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -669,7 +680,8 @@ TEST(constantTest, int_in_smallint2) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList* list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -704,7 +716,8 @@ TEST(constantTest, int_not_in_smallint1) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList *list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -741,7 +754,8 @@ TEST(constantTest, int_not_in_smallint2) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList *list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -2084,7 +2098,8 @@ TEST(columnTest, int_column_in_double_list) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList *list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv1);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -2157,7 +2172,8 @@ TEST(columnTest, binary_column_in_binary_list) {
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
code = scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
SNodeList *list = nodesMakeList();
|
||||
SNodeList *list = NULL;
|
||||
code = nodesMakeList(&list);
|
||||
ASSERT_NE(list, nullptr);
|
||||
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[0]);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
|
|
@ -154,24 +154,29 @@ void schtBuildQueryDag(SQueryPlan *dag) {
|
|||
|
||||
dag->queryId = qId;
|
||||
dag->numOfSubplans = 2;
|
||||
dag->pSubplans = nodesMakeList();
|
||||
dag->pSubplans = NULL;
|
||||
int32_t code = nodesMakeList(&dag->pSubplans);
|
||||
if (NULL == dag->pSubplans) {
|
||||
return;
|
||||
}
|
||||
SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *scan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&scan);
|
||||
if (NULL == scan) {
|
||||
return;
|
||||
}
|
||||
SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *merge = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&merge);
|
||||
if (NULL == merge) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSubplan *scanPlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan *scanPlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&scanPlan);
|
||||
if (NULL == scanPlan) {
|
||||
return;
|
||||
}
|
||||
SSubplan *mergePlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan *mergePlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&mergePlan);
|
||||
if (NULL == mergePlan) {
|
||||
return;
|
||||
}
|
||||
|
@ -187,11 +192,13 @@ void schtBuildQueryDag(SQueryPlan *dag) {
|
|||
|
||||
scanPlan->pChildren = NULL;
|
||||
scanPlan->level = 1;
|
||||
scanPlan->pParents = nodesMakeList();
|
||||
scanPlan->pParents = NULL;
|
||||
code = nodesMakeList(&scanPlan->pParents);
|
||||
if (NULL == scanPlan->pParents) {
|
||||
return;
|
||||
}
|
||||
scanPlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
||||
scanPlan->pNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, (SNode**)&scanPlan->pNode);
|
||||
if (NULL == scanPlan->pNode) {
|
||||
return;
|
||||
}
|
||||
|
@ -204,22 +211,26 @@ void schtBuildQueryDag(SQueryPlan *dag) {
|
|||
mergePlan->level = 0;
|
||||
mergePlan->execNode.epSet.numOfEps = 0;
|
||||
|
||||
mergePlan->pChildren = nodesMakeList();
|
||||
mergePlan->pChildren = NULL;
|
||||
code = nodesMakeList(&mergePlan->pChildren);
|
||||
if (NULL == mergePlan->pChildren) {
|
||||
return;
|
||||
}
|
||||
mergePlan->pParents = NULL;
|
||||
mergePlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
||||
mergePlan->pNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE, (SNode**)&mergePlan->pNode);
|
||||
if (NULL == mergePlan->pNode) {
|
||||
return;
|
||||
}
|
||||
mergePlan->msgType = TDMT_SCH_QUERY;
|
||||
|
||||
merge->pNodeList = nodesMakeList();
|
||||
merge->pNodeList = NULL;
|
||||
code = nodesMakeList(&merge->pNodeList);
|
||||
if (NULL == merge->pNodeList) {
|
||||
return;
|
||||
}
|
||||
scan->pNodeList = nodesMakeList();
|
||||
scan->pNodeList = NULL;
|
||||
code = nodesMakeList(&scan->pNodeList);
|
||||
if (NULL == scan->pNodeList) {
|
||||
return;
|
||||
}
|
||||
|
@ -240,40 +251,48 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
|||
|
||||
dag->queryId = qId;
|
||||
dag->numOfSubplans = 2;
|
||||
dag->pSubplans = nodesMakeList();
|
||||
dag->pSubplans = NULL;
|
||||
int32_t code = nodesMakeList(&dag->pSubplans);
|
||||
if (NULL == dag->pSubplans) {
|
||||
return;
|
||||
}
|
||||
SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *scan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&scan);
|
||||
if (NULL == scan) {
|
||||
return;
|
||||
}
|
||||
SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *merge = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&merge);
|
||||
if (NULL == merge) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSubplan *mergePlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan *mergePlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&mergePlan);
|
||||
if (NULL == mergePlan) {
|
||||
return;
|
||||
}
|
||||
|
||||
merge->pNodeList = nodesMakeList();
|
||||
merge->pNodeList = NULL;
|
||||
code = nodesMakeList(&merge->pNodeList);
|
||||
if (NULL == merge->pNodeList) {
|
||||
return;
|
||||
}
|
||||
scan->pNodeList = nodesMakeList();
|
||||
scan->pNodeList = NULL;
|
||||
code = nodesMakeList(&scan->pNodeList);
|
||||
if (NULL == scan->pNodeList) {
|
||||
return;
|
||||
}
|
||||
|
||||
mergePlan->pChildren = nodesMakeList();
|
||||
mergePlan->pChildren = NULL;
|
||||
code = nodesMakeList(&mergePlan->pChildren);
|
||||
if (NULL == mergePlan->pChildren) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < scanPlanNum; ++i) {
|
||||
SSubplan *scanPlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan *scanPlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&scanPlan);
|
||||
if (NULL == scanPlan) {
|
||||
return;
|
||||
}
|
||||
|
@ -292,11 +311,13 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
|||
|
||||
scanPlan->pChildren = NULL;
|
||||
scanPlan->level = 1;
|
||||
scanPlan->pParents = nodesMakeList();
|
||||
scanPlan->pParents = NULL;
|
||||
code = nodesMakeList(&scanPlan->pParents);
|
||||
if (NULL == scanPlan->pParents) {
|
||||
return;
|
||||
}
|
||||
scanPlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
|
||||
scanPlan->pNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, (SNode**)&scanPlan->pNode);
|
||||
if (NULL == scanPlan->pNode) {
|
||||
return;
|
||||
}
|
||||
|
@ -316,7 +337,8 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
|||
mergePlan->execNode.epSet.numOfEps = 0;
|
||||
|
||||
mergePlan->pParents = NULL;
|
||||
mergePlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE);
|
||||
mergePlan->pNode = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE, (SNode**)&mergePlan->pNode);
|
||||
if (NULL == mergePlan->pNode) {
|
||||
return;
|
||||
}
|
||||
|
@ -335,20 +357,24 @@ void schtBuildInsertDag(SQueryPlan *dag) {
|
|||
|
||||
dag->queryId = qId;
|
||||
dag->numOfSubplans = 2;
|
||||
dag->pSubplans = nodesMakeList();
|
||||
dag->pSubplans = NULL;
|
||||
int32_t code = nodesMakeList(&dag->pSubplans);
|
||||
if (NULL == dag->pSubplans) {
|
||||
return;
|
||||
}
|
||||
SNodeListNode *inserta = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST);
|
||||
SNodeListNode *inserta = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_NODE_LIST, (SNode**)&inserta);
|
||||
if (NULL == inserta) {
|
||||
return;
|
||||
}
|
||||
inserta->pNodeList = nodesMakeList();
|
||||
inserta->pNodeList = NULL;
|
||||
code = nodesMakeList(&inserta->pNodeList);
|
||||
if (NULL == inserta->pNodeList) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSubplan *insertPlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
SSubplan *insertPlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&insertPlan);
|
||||
if (NULL == insertPlan) {
|
||||
return;
|
||||
}
|
||||
|
@ -366,7 +392,8 @@ void schtBuildInsertDag(SQueryPlan *dag) {
|
|||
insertPlan->pChildren = NULL;
|
||||
insertPlan->pParents = NULL;
|
||||
insertPlan->pNode = NULL;
|
||||
insertPlan->pDataSink = (SDataSinkNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT);
|
||||
insertPlan->pDataSink = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT, (SNode**)&insertPlan->pDataSink);
|
||||
if (NULL == insertPlan->pDataSink) {
|
||||
return;
|
||||
}
|
||||
|
@ -379,7 +406,8 @@ void schtBuildInsertDag(SQueryPlan *dag) {
|
|||
|
||||
(void)nodesListAppend(inserta->pNodeList, (SNode *)insertPlan);
|
||||
|
||||
insertPlan = (SSubplan *)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN);
|
||||
insertPlan = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN, (SNode**)&insertPlan);
|
||||
if (NULL == insertPlan) {
|
||||
return;
|
||||
}
|
||||
|
@ -397,7 +425,8 @@ void schtBuildInsertDag(SQueryPlan *dag) {
|
|||
insertPlan->pChildren = NULL;
|
||||
insertPlan->pParents = NULL;
|
||||
insertPlan->pNode = NULL;
|
||||
insertPlan->pDataSink = (SDataSinkNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT);
|
||||
insertPlan->pDataSink = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT, (SNode**)&insertPlan->pDataSink);
|
||||
if (NULL == insertPlan->pDataSink) {
|
||||
return;
|
||||
}
|
||||
|
@ -640,11 +669,12 @@ void *schtRunJobThread(void *aa) {
|
|||
char *dbname = "1.db1";
|
||||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
SQueryPlan *dag = (SQueryPlan *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
assert(code == 0);
|
||||
schtInitLogFile();
|
||||
|
||||
int32_t code = schedulerInit();
|
||||
code = schedulerInit();
|
||||
assert(code == 0);
|
||||
|
||||
schtSetPlanToString();
|
||||
|
@ -828,7 +858,9 @@ TEST(queryTest, normalCase) {
|
|||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
int64_t job = 0;
|
||||
SQueryPlan *dag = (SQueryPlan *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
||||
SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad));
|
||||
|
||||
|
@ -838,7 +870,7 @@ TEST(queryTest, normalCase) {
|
|||
load.addr.epSet.eps[0].port = 6031;
|
||||
assert(taosArrayPush(qnodeList, &load) != NULL);
|
||||
|
||||
int32_t code = schedulerInit();
|
||||
code = schedulerInit();
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schtBuildQueryDag(dag);
|
||||
|
@ -942,7 +974,9 @@ TEST(queryTest, readyFirstCase) {
|
|||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
int64_t job = 0;
|
||||
SQueryPlan *dag = (SQueryPlan *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, code);
|
||||
|
||||
SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad));
|
||||
|
||||
|
@ -952,7 +986,7 @@ TEST(queryTest, readyFirstCase) {
|
|||
load.addr.epSet.eps[0].port = 6031;
|
||||
assert(NULL != taosArrayPush(qnodeList, &load));
|
||||
|
||||
int32_t code = schedulerInit();
|
||||
code = schedulerInit();
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schtBuildQueryDag(dag);
|
||||
|
@ -1055,7 +1089,9 @@ TEST(queryTest, flowCtrlCase) {
|
|||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
int64_t job = 0;
|
||||
SQueryPlan *dag = (SQueryPlan *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, code);
|
||||
|
||||
schtInitLogFile();
|
||||
|
||||
|
@ -1069,7 +1105,7 @@ TEST(queryTest, flowCtrlCase) {
|
|||
load.addr.epSet.eps[0].port = 6031;
|
||||
assert(NULL != taosArrayPush(qnodeList, &load));
|
||||
|
||||
int32_t code = schedulerInit();
|
||||
code = schedulerInit();
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schtBuildQueryFlowCtrlDag(dag);
|
||||
|
@ -1151,7 +1187,9 @@ TEST(insertTest, normalCase) {
|
|||
char *dbname = "1.db1";
|
||||
char *tablename = "table1";
|
||||
SVgroupInfo vgInfo = {0};
|
||||
SQueryPlan *dag = (SQueryPlan *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN);
|
||||
SQueryPlan *dag = NULL;
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||
ASSERT_EQ(TSDB_CODE_SUCCESS, code);
|
||||
uint64_t numOfRows = 0;
|
||||
|
||||
SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad));
|
||||
|
@ -1162,7 +1200,7 @@ TEST(insertTest, normalCase) {
|
|||
load.addr.epSet.eps[0].port = 6031;
|
||||
assert(NULL != taosArrayPush(qnodeList, &load));
|
||||
|
||||
int32_t code = schedulerInit();
|
||||
code = schedulerInit();
|
||||
ASSERT_EQ(code, 0);
|
||||
|
||||
schtBuildInsertDag(dag);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue