fix:[TD-31899] remove void(func)

This commit is contained in:
wangmm0220 2024-09-06 10:16:15 +08:00
parent 5301b9b680
commit 23507b0eac
18 changed files with 329 additions and 183 deletions

View File

@ -37,7 +37,7 @@ typedef struct SName {
char tname[TSDB_TABLE_NAME_LEN];
} SName;
SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName);
void toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName);
int32_t tNameExtractFullName(const SName* name, char* dst);

View File

@ -1636,7 +1636,10 @@ void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) {
SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
if (pReq) {
tFreeClientHbReq(pReq);
(void)taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
code = taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
if (TSDB_CODE_SUCCESS != code) {
tscError("hbDeregisterConn taosHashRemove error, code:%s", tstrerror(TAOS_SYSTEM_ERROR(code)));
}
taosHashRelease(pAppHbMgr->activeInfo, pReq);
(void)atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
}

View File

@ -1313,7 +1313,10 @@ 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,QID:0x%" PRIx64,
pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId);
(void)refreshMeta(pRequest->pTscObj, pRequest); // ignore return code,try again
code = refreshMeta(pRequest->pTscObj, pRequest);
if (code != 0){
uInfo("refresh meta error code:%d, msg:%s", code, tstrerror(code));
}
pRequest->prevCode = code;
doAsyncQuery(pRequest, true);
return;
@ -1492,8 +1495,8 @@ int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId
conn.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
SName tableName;
(void)toName(pTscObj->acctId, db, table, &tableName);
SName tableName = {0};
toName(pTscObj->acctId, db, table, &tableName);
SVgroupInfo vgInfo;
code = catalogGetTableHashVgroup(pCtg, &conn, &tableName, &vgInfo);

View File

@ -68,9 +68,14 @@ static void destroyMonitorClient(void* data) {
if (pMonitor == NULL) {
return;
}
(void)taosTmrStopA(&pMonitor->timer);
if (!taosTmrStopA(&pMonitor->timer)) {
tscError("failed to stop timer, pMonitor:%p", pMonitor);
}
taosHashCleanup(pMonitor->counters);
(void)taos_collector_registry_destroy(pMonitor->registry);
int ret = taos_collector_registry_destroy(pMonitor->registry);
if (ret){
tscError("failed to destroy registry, pMonitor:%p ret:%d", pMonitor, ret);
}
taosMemoryFree(pMonitor);
}
@ -186,7 +191,10 @@ static void generateClusterReport(taos_collector_registry_t* registry, void* pTr
}
if (strlen(pCont) != 0 && sendReport(pTransporter, epSet, pCont, MONITOR_TYPE_COUNTER, NULL) == 0) {
(void)taos_collector_registry_clear_batch(registry);
int ret = taos_collector_registry_clear_batch(registry);
if (ret){
tscError("failed to clear registry, ret:%d", ret);
}
}
taosMemoryFreeClear(pCont);
}
@ -207,7 +215,10 @@ static void reportSendProcess(void* param, void* tmrId) {
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
generateClusterReport(pMonitor->registry, pInst->pTransporter, &ep);
(void)taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
bool reset = taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
if (!reset){
tscError("failed to reset timer, pMonitor:%p", pMonitor);
}
taosRUnLockLatch(&monitorLock);
}
@ -255,7 +266,11 @@ void monitorCreateClient(int64_t clusterId) {
goto fail;
}
(void)taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
int r = taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
if (r){
tscError("failed to register collector, ret:%d", r);
goto fail;
}
pMonitor->counters =
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
if (pMonitor->counters == NULL) {
@ -304,12 +319,18 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char*
MonitorClient* pMonitor = *ppMonitor;
if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0){
tscError("failed to add metric to collector");
(void)taos_counter_destroy(newCounter);
int r = taos_counter_destroy(newCounter);
if (r){
tscError("failed to destroy counter, code: %d", r);
}
goto end;
}
if (taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0) {
tscError("failed to put counter to monitor");
(void)taos_counter_destroy(newCounter);
int r = taos_counter_destroy(newCounter);
if (r){
tscError("failed to destroy counter, code: %d", r);
}
goto end;
}
tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name,
@ -374,7 +395,10 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
SlowLogClient* pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
if (pClient == NULL) {
tscError("failed to allocate memory for slow log client");
(void)taosCloseFile(&pFile);
int32_t ret = taosCloseFile(&pFile);
if (ret != 0){
tscError("failed to close file:%p ret:%d", pFile, ret);
}
return;
}
pClient->lastCheckTime = taosGetMonoTimestampMs();
@ -383,7 +407,10 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP
pClient->pFile = pFile;
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
tscError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
(void)taosCloseFile(&pFile);
int32_t ret = taosCloseFile(&pFile);
if (ret != 0){
tscError("failed to close file:%p ret:%d", pFile, ret);
}
taosMemoryFree(pClient);
return;
}
@ -608,7 +635,11 @@ static void processFileRemoved(SlowLogClient* pClient) {
tscError("failed to unlock file:%s since %d", pClient->path, errno);
return;
}
(void)taosCloseFile(&(pClient->pFile));
int32_t ret = taosCloseFile(&(pClient->pFile));
if (ret != 0){
tscError("failed to close file:%p ret:%d", pClient->pFile, ret);
return;
}
TdFilePtr pFile =
taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
@ -697,7 +728,10 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
}
if (taosLockFile(pFile) < 0) {
tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr());
(void)taosCloseFile(&pFile);
int32_t ret = taosCloseFile(&pFile);
if (ret != 0){
tscError("failed to close file:%p ret:%d", pFile, ret);
}
continue;
}
char* tmp = taosStrdup(filename);
@ -705,7 +739,10 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
taosMemoryFree(tmp);
}
(void)taosCloseDir(&pDir);
int32_t ret = taosCloseDir(&pDir);
if (ret != 0){
tscError("failed to close dir, ret:%d", ret);
}
}
static void* monitorThreadFunc(void* param) {
@ -729,7 +766,9 @@ static void* monitorThreadFunc(void* param) {
}
MonitorSlowLogData* slowLogData = NULL;
(void)taosReadQitem(monitorQueue, (void**)&slowLogData);
if (taosReadQitem(monitorQueue, (void**)&slowLogData) == 0){
tscDebug("monitorThreadFunc get slow log data from queue null");
}
if (slowLogData != NULL) {
if (slowLogData->type == SLOW_LOG_READ_BEGINNIG && quitCnt == 0) {
if (slowLogData->pFile != NULL) {
@ -850,7 +889,9 @@ void monitorClose() {
taosHashCleanup(monitorSlowLogHash);
taosTmrCleanUp(monitorTimer);
taosCloseQueue(monitorQueue);
(void)tsem2_destroy(&monitorSem);
if(tsem2_destroy(&monitorSem) != 0) {
tscError("failed to destroy semaphore");
}
taosWUnLockLatch(&monitorLock);
}
@ -872,7 +913,9 @@ int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) {
tscDebug("[monitor] write slow log to queue, clusterId:%" PRIx64 " type:%s, data:%s", slowLogData->clusterId,
queueTypeStr[slowLogData->type], slowLogData->data);
if (taosWriteQitem(monitorQueue, slowLogData) == 0) {
(void)tsem2_post(&monitorSem);
if(tsem2_post(&monitorSem) != 0) {
tscError("failed to post semaphore");
}
} else {
if (taosCloseFile(&(slowLogData->pFile)) != 0) {
tscError("failed to close file:%p", slowLogData->pFile);

View File

@ -946,7 +946,8 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
pReq.suid);
STscObj* pTscObj = pRequest->pTscObj;
SName tableName = {0};
RAW_RETURN_CHECK(tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name));
toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName);
RAW_RETURN_CHECK(tNameExtractFullName(&tableName, pReq.name));
SCmdMsgInfo pCmdMsg = {0};
pCmdMsg.epSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp);
pCmdMsg.msgType = TDMT_MND_CREATE_STB;
@ -959,6 +960,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
RAW_NULL_CHECK(pCmdMsg.pMsg);
if (tSerializeSMCreateStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
code = TSDB_CODE_INVALID_PARA;
taosMemoryFree(pCmdMsg.pMsg);
goto end;
}
@ -970,15 +972,15 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
taosMemoryFree(pCmdMsg.pMsg);
if (pRequest->code == TSDB_CODE_SUCCESS) {
SCatalog* pCatalog = NULL;
// ignore the return value
(void)catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
(void)catalogRemoveTableMeta(pCatalog, &tableName);
RAW_RETURN_CHECK(catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog));
RAW_RETURN_CHECK(catalogRemoveTableMeta(pCatalog, &tableName));
}
code = pRequest->code;
taosMemoryFree(pCmdMsg.pMsg);
end:
uDebug(LOG_ID_TAG " create stable return, msg:%s", LOG_ID_VALUE, tstrerror(code));
@ -1021,8 +1023,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
.requestObjRefId = pRequest->self,
.mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)};
SName pName = {0};
(void)toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name,
&pName); // ignore the return value, always return pName
toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName);
STableMeta* pTableMeta = NULL;
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
@ -1045,7 +1046,8 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
pReq.suid);
STscObj* pTscObj = pRequest->pTscObj;
SName tableName = {0};
if (tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name) != 0) {
toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName);
if (tNameExtractFullName(&tableName, pReq.name) != 0) {
code = TSDB_CODE_INVALID_PARA;
goto end;
}
@ -1062,6 +1064,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
RAW_NULL_CHECK(pCmdMsg.pMsg);
if (tSerializeSMDropStbReq(pCmdMsg.pMsg, pCmdMsg.msgLen, &pReq) <= 0) {
code = TSDB_CODE_INVALID_PARA;
taosMemoryFree(pCmdMsg.pMsg);
goto end;
}
@ -1072,15 +1075,14 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
pQuery.stableQuery = true;
(void)launchQueryImpl(pRequest, &pQuery, true, NULL); // ignore, because return value is pRequest
taosMemoryFree(pCmdMsg.pMsg);
if (pRequest->code == TSDB_CODE_SUCCESS) {
// ignore the error code
(void)catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog);
(void)catalogRemoveTableMeta(pCatalog, &tableName);
RAW_RETURN_CHECK(catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog));
RAW_RETURN_CHECK(catalogRemoveTableMeta(pCatalog, &tableName));
}
code = pRequest->code;
taosMemoryFree(pCmdMsg.pMsg);
end:
uDebug(LOG_ID_TAG " drop stable return, msg:%s", LOG_ID_VALUE, tstrerror(code));
@ -1150,7 +1152,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
SVgroupInfo pInfo = {0};
SName pName = {0};
(void)toName(pTscObj->acctId, pRequest->pDb, pCreateReq->name, &pName);
toName(pTscObj->acctId, pRequest->pDb, pCreateReq->name, &pName);
code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo);
if (code != TSDB_CODE_SUCCESS) {
goto end;
@ -1163,7 +1165,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
SName sName = {0};
tb_uid_t oldSuid = pCreateReq->ctb.suid;
// pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb);
(void)toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.stbName, &sName);
toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.stbName, &sName);
code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta);
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
code = TSDB_CODE_SUCCESS;
@ -1228,7 +1230,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
if (pRequest->code == TSDB_CODE_SUCCESS) {
(void)removeMeta(pTscObj, pRequest->tableList, false);
RAW_RETURN_CHECK(removeMeta(pTscObj, pRequest->tableList, false));
}
code = pRequest->code;
@ -1307,7 +1309,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
SVgroupInfo pInfo = {0};
SName pName = {0};
(void)toName(pTscObj->acctId, pRequest->pDb, pDropReq->name, &pName);
toName(pTscObj->acctId, pRequest->pDb, pDropReq->name, &pName);
RAW_RETURN_CHECK(catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo));
STableMeta* pTableMeta = NULL;
@ -1357,7 +1359,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
(void)launchQueryImpl(pRequest, pQuery, true, NULL);
if (pRequest->code == TSDB_CODE_SUCCESS) {
(void)removeMeta(pTscObj, pRequest->tableList, false);
RAW_RETURN_CHECK(removeMeta(pTscObj, pRequest->tableList, false));
}
code = pRequest->code;
@ -1451,7 +1453,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) {
SVgroupInfo pInfo = {0};
SName pName = {0};
(void)toName(pTscObj->acctId, pRequest->pDb, req.tbName, &pName);
toName(pTscObj->acctId, pRequest->pDb, req.tbName, &pName);
RAW_RETURN_CHECK(catalogGetTableHashVgroup(pCatalog, &conn, &pName, &pInfo));
pArray = taosArrayInit(1, sizeof(void*));
RAW_NULL_CHECK(pArray);

View File

@ -116,7 +116,7 @@ static int32_t smlCheckAuth(SSmlHandle *info, SRequestConnInfo *conn, const char
return TSDB_CODE_SML_INVALID_DATA;
}
} else {
(void)toName(info->taos->acctId, info->pRequest->pDb, pTabName, &pAuth.tbName); //ignore
toName(info->taos->acctId, info->pRequest->pDb, pTabName, &pAuth.tbName);
}
pAuth.type = type;
@ -1113,7 +1113,10 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray *pColumns,
pReq.commentLen = -1;
pReq.igExists = true;
(void)tNameExtractFullName(pName, pReq.name);
code = tNameExtractFullName(pName, pReq.name);
if (code != TSDB_CODE_SUCCESS) {
goto end;
}
pCmdMsg.epSet = getEpSet_s(&info->taos->pAppInfo->mgmtEp);
pCmdMsg.msgType = TDMT_MND_CREATE_STB;
@ -2214,9 +2217,12 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine,
break;
}
taosMsleep(100);
(void)refreshMeta(request->pTscObj, request); //ignore return code,try again
uInfo("SML:%" PRIx64 " retry:%d/10,ver is old retry or object is creating code:%d, msg:%s", info->id, cnt, code,
tstrerror(code));
code = refreshMeta(request->pTscObj, request);
if (code != 0){
uInfo("SML:%" PRIx64 " refresh meta error code:%d, msg:%s", info->id, code, tstrerror(code));
}
smlDestroyInfo(info);
info = NULL;
taos_free_result(request);

View File

@ -772,7 +772,10 @@ void* stmtBindThreadFunc(void* param) {
continue;
}
(void)stmtAsyncOutput(pStmt, asyncParam);
int ret = stmtAsyncOutput(pStmt, asyncParam);
if (ret != 0){
qError("stmtAsyncOutput failed, reason:%s", tstrerror(ret));
}
}
qInfo("stmt bind thread stopped");

View File

@ -797,11 +797,16 @@ static void generateTimedTask(int64_t refId, int32_t type) {
if (code == TSDB_CODE_SUCCESS) {
*pTaskType = type;
if (taosWriteQitem(tmq->delayedTask, pTaskType) == 0) {
(void)tsem2_post(&tmq->rspSem);
if (tsem2_post(&tmq->rspSem) != 0){
tscError("consumer:0x%" PRIx64 " failed to post sem, type:%d", tmq->consumerId, type);
}
}
}
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
code = taosReleaseRef(tmqMgmt.rsetId, refId);
if (code != 0){
tscError("failed to release ref:%"PRId64 ", type:%d, code:%d", refId, type, code);
}
}
void tmqAssignAskEpTask(void* param, void* tmrId) {
@ -814,8 +819,13 @@ void tmqReplayTask(void* param, void* tmrId) {
tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId);
if (tmq == NULL) return;
(void)tsem2_post(&tmq->rspSem);
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
if (tsem2_post(&tmq->rspSem) != 0){
tscError("consumer:0x%" PRIx64 " failed to post sem, replay", tmq->consumerId);
}
int32_t code = taosReleaseRef(tmqMgmt.rsetId, refId);
if (code != 0){
tscError("failed to release ref:%"PRId64 ", code:%d", refId, code);
}
}
void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
@ -825,17 +835,17 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
if (code != 0) {
goto _return;
goto END;
}
if (pMsg == NULL || param == NULL) {
code = TSDB_CODE_INVALID_PARA;
goto _return;
goto END;
}
SMqHbRsp rsp = {0};
code = tDeserializeSMqHbRsp(pMsg->pData, pMsg->len, &rsp);
if (code != 0) {
goto _return;
goto END;
}
int64_t refId = (int64_t)param;
@ -856,13 +866,15 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) {
}
}
taosWUnLockLatch(&tmq->lock);
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
code = taosReleaseRef(tmqMgmt.rsetId, refId);
if (code != 0){
tscError("failed to release ref:%"PRId64 ", code:%d", refId, code);
}
}
tDestroySMqHbRsp(&rsp);
_return:
END:
taosMemoryFree(pMsg->pData);
taosMemoryFree(pMsg->pEpSet);
return code;
@ -967,7 +979,10 @@ OVER:
if (tmrId != NULL) {
(void)taosTmrReset(tmqSendHbReq, tmq->heartBeatIntervalMs, param, tmqMgmt.timer, &tmq->hbLiveTimer);
}
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
int32_t ret = taosReleaseRef(tmqMgmt.rsetId, refId);
if (ret != 0){
tscError("failed to release ref:%"PRId64 ", code:%d", refId, ret);
}
}
static void defaultCommitCbFn(tmq_t* pTmq, int32_t code, void* param) {
@ -1086,7 +1101,9 @@ int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) {
if (pMsg) {
taosMemoryFree(pMsg->pEpSet);
}
(void)tsem2_post(&pParam->rspSem);
if (tsem2_post(&pParam->rspSem) != 0){
tscError("failed to post sem, subscribe cb");
}
return 0;
}
@ -1658,7 +1675,10 @@ END:
if (tmq) (void)tsem2_post(&tmq->rspSem);
if (pMsg) taosMemoryFreeClear(pMsg->pData);
if (pMsg) taosMemoryFreeClear(pMsg->pEpSet);
(void)taosReleaseRef(tmqMgmt.rsetId, refId);
ret = taosReleaseRef(tmqMgmt.rsetId, refId);
if (ret != 0){
tscError("failed to release ref:%"PRId64 ", code:%d", refId, ret);
}
return code;
}
@ -2903,8 +2923,12 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) {
}
END:
(void)taosReleaseRef(tmqMgmt.rsetId, pParam->refId);
{
int32_t ret = taosReleaseRef(tmqMgmt.rsetId, pParam->refId);
if (ret != 0){
tscError("failed to release ref:%"PRId64 ", code:%d", pParam->refId, ret);
}
}
FAIL:
if (pParam->sync) {
SAskEpInfo* pInfo = pParam->pParam;

View File

@ -87,12 +87,14 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
#endif
SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) {
void toName(int32_t acctId, const char* pDbName, const char* pTableName, SName* pName) {
if (pName == NULL){
return;
}
pName->type = TSDB_TABLE_NAME_T;
pName->acctId = acctId;
snprintf(pName->dbname, sizeof(pName->dbname), "%s", pDbName);
snprintf(pName->tname, sizeof(pName->tname), "%s", pTableName);
return pName;
}
int32_t tNameExtractFullName(const SName* name, char* dst) {

View File

@ -199,7 +199,7 @@ static void storeOffsetRows(SMnode *pMnode, SMqHbReq *req, SMqConsumerObj *pCons
taosWLockLatch(&pSub->lock);
SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t));
if (pConsumerEp) {
(void)taosArrayDestroy(pConsumerEp->offsetRows);
taosArrayDestroy(pConsumerEp->offsetRows);
pConsumerEp->offsetRows = data->offsetRows;
data->offsetRows = NULL;
}

View File

@ -248,7 +248,7 @@ static int32_t processRemovedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash
MND_TMQ_RETURN_CHECK(pushVgDataToHash(pConsumerEp->vgs, pHash, *consumerId, pOutput->pSub->key));
}
(void)taosArrayDestroy(pConsumerEp->vgs);
taosArrayDestroy(pConsumerEp->vgs);
MND_TMQ_RETURN_CHECK(taosHashRemove(pOutput->pSub->consumerHash, consumerId, sizeof(int64_t)));
MND_TMQ_NULL_CHECK(taosArrayPush(pOutput->removedConsumers, consumerId));
actualRemoved++;
@ -682,8 +682,8 @@ END:
static void freeRebalanceItem(void *param) {
SMqRebInfo *pInfo = param;
(void)taosArrayDestroy(pInfo->newConsumers);
(void)taosArrayDestroy(pInfo->removedConsumers);
taosArrayDestroy(pInfo->newConsumers);
taosArrayDestroy(pInfo->removedConsumers);
}
// type = 0 remove type = 1 add
@ -738,9 +738,13 @@ static void checkForVgroupSplit(SMnode *pMnode, SMqConsumerObj *pConsumer, SHash
}
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId);
if (!pVgroup) {
(void)mndGetOrCreateRebSub(rebSubHash, key, NULL);
code = mndGetOrCreateRebSub(rebSubHash, key, NULL);
if (code != 0){
mError("failed to mndGetOrCreateRebSub vgroup:%d, error:%s", pVgEp->vgId, tstrerror(code))
}else{
mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId);
}
}
mndReleaseVgroup(pMnode, pVgroup);
}
taosRUnLockLatch(&pSub->lock);
@ -813,10 +817,10 @@ void mndRebCntDec() {
}
static void clearRebOutput(SMqRebOutputObj *rebOutput) {
(void)taosArrayDestroy(rebOutput->newConsumers);
(void)taosArrayDestroy(rebOutput->modifyConsumers);
(void)taosArrayDestroy(rebOutput->removedConsumers);
(void)taosArrayDestroy(rebOutput->rebVgs);
taosArrayDestroy(rebOutput->newConsumers);
taosArrayDestroy(rebOutput->modifyConsumers);
taosArrayDestroy(rebOutput->removedConsumers);
taosArrayDestroy(rebOutput->rebVgs);
tDeleteSubscribeObj(rebOutput->pSub);
taosMemoryFree(rebOutput->pSub);
}
@ -858,7 +862,7 @@ static int32_t checkConsumer(SMnode *pMnode, SMqSubscribeObj *pSub) {
mError("consumer:0x%" PRIx64 " not exists in sdb for exception", pConsumerEp->consumerId);
MND_TMQ_NULL_CHECK(taosArrayAddAll(pSub->unassignedVgs, pConsumerEp->vgs));
(void)taosArrayDestroy(pConsumerEp->vgs);
taosArrayDestroy(pConsumerEp->vgs);
MND_TMQ_RETURN_CHECK(taosHashRemove(pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)));
}
END:

View File

@ -302,7 +302,7 @@ static int32_t mndTopicActionDelete(SSdb *pSdb, SMqTopicObj *pTopic) {
taosMemoryFreeClear(pTopic->ast);
taosMemoryFreeClear(pTopic->physicalPlan);
if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema);
(void)taosArrayDestroy(pTopic->ntbColIds);
taosArrayDestroy(pTopic->ntbColIds);
return 0;
}
@ -467,7 +467,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
MND_TMQ_NULL_CHECK(topicObj.ntbColIds);
MND_TMQ_RETURN_CHECK(extractTopicTbInfo(pAst, &topicObj));
if (topicObj.ntbUid == 0) {
(void)taosArrayDestroy(topicObj.ntbColIds);
taosArrayDestroy(topicObj.ntbColIds);
topicObj.ntbColIds = NULL;
}
@ -505,7 +505,7 @@ END:
taosMemoryFreeClear(topicObj.physicalPlan);
taosMemoryFreeClear(topicObj.sql);
taosMemoryFreeClear(topicObj.ast);
(void)taosArrayDestroy(topicObj.ntbColIds);
taosArrayDestroy(topicObj.ntbColIds);
if (topicObj.schema.nCols) {
taosMemoryFreeClear(topicObj.schema.pSchema);
}
@ -567,9 +567,15 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
{
SName dbname = {0};
(void)tNameFromString(&dbname, createTopicReq.subDbName, T_NAME_ACCT | T_NAME_DB); // ignore error
int32_t ret = tNameFromString(&dbname, createTopicReq.subDbName, T_NAME_ACCT | T_NAME_DB);
if (ret != 0){
mError("failed to parse db name:%s, ret:%d", createTopicReq.subDbName, ret);
}
SName topicName = {0};
(void)tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); // ignore error
ret = tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
if (ret != 0){
mError("failed to parse topic name:%s, ret:%d", createTopicReq.name, ret);
}
auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname,
createTopicReq.sql, strlen(createTopicReq.sql));
}
@ -735,7 +741,10 @@ END:
}
SName name = {0};
(void)tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); // ignore error
int32_t ret = tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
if (ret != 0) {
mError("topic:%s, failed to drop since %s", dropReq.name, tstrerror(ret));
}
auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen);
tFreeSMDropTopicReq(&dropReq);

View File

@ -344,7 +344,10 @@ int32_t tqProcessPollPush(STQ* pTq, SRpcMsg* pMsg) {
.pCont = pHandle->msg->pCont,
.contLen = pHandle->msg->contLen,
.info = pHandle->msg->info};
(void)tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
int32_t ret = tmsgPutToQueue(&pTq->pVnode->msgCb, QUERY_QUEUE, &msg);
if (ret != 0){
tqError("vgId:%d tmsgPutToQueue failed, consumer:0x%" PRIx64, vgId, pHandle->consumerId);
}
taosMemoryFree(pHandle->msg);
pHandle->msg = NULL;
}
@ -643,7 +646,6 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
tDecoderInit(&dc, (uint8_t*)msg, msgLen);
ret = tDecodeSMqRebVgReq(&dc, &req);
// decode req
if (ret < 0) {
goto end;
}
@ -653,7 +655,10 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
taosRLockLatch(&pTq->lock);
STqHandle* pHandle = NULL;
(void)tqMetaGetHandle(pTq, req.subKey, &pHandle); // ignore return code
int32_t code = tqMetaGetHandle(pTq, req.subKey, &pHandle);
if (code != 0){
tqInfo("vgId:%d, tq process sub req:%s, no such handle, create new one", pTq->pVnode->config.vgId, req.subKey);
}
taosRUnLockLatch(&pTq->lock);
if (pHandle == NULL) {
if (req.oldConsumerId != -1) {
@ -662,6 +667,7 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
}
if (req.newConsumerId == -1) {
tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId);
ret = TSDB_CODE_INVALID_PARA;
goto end;
}
STqHandle handle = {0};

View File

@ -374,7 +374,10 @@ static int32_t tqMetaTransformInfo(TDB* pMetaDB, TTB* pOld, TTB* pNew) {
END:
tdbFree(pKey);
tdbFree(pVal);
(void)tdbTbcClose(pCur);
int32_t ret = tdbTbcClose(pCur);
if (ret != 0) {
tqError("failed to close tbc, ret:%d", ret);
}
return code;
}
@ -446,7 +449,10 @@ static int32_t tqMetaRestoreCheckInfo(STQ* pTq) {
END:
tdbFree(pKey);
tdbFree(pVal);
(void)tdbTbcClose(pCur);
int32_t ret = tdbTbcClose(pCur);
if (ret != 0) {
tqError("failed to close tbc, ret:%d", ret);
}
tDeleteSTqCheckInfo(&info);
return code;
}
@ -461,13 +467,13 @@ int32_t tqMetaOpen(STQ* pTq) {
TQ_ERR_GO_TO_END(tqMetaOpenTdb(pTq));
} else {
TQ_ERR_GO_TO_END(tqMetaTransform(pTq));
(void)taosRemoveFile(maindb);
TQ_ERR_GO_TO_END(taosRemoveFile(maindb));
}
TQ_ERR_GO_TO_END(tqBuildFName(&offsetNew, pTq->path, TQ_OFFSET_NAME));
if(taosCheckExistFile(offsetNew)){
TQ_ERR_GO_TO_END(tqOffsetRestoreFromFile(pTq, offsetNew));
(void)taosRemoveFile(offsetNew);
TQ_ERR_GO_TO_END(taosRemoveFile(offsetNew));
}
TQ_ERR_GO_TO_END(tqMetaRestoreCheckInfo(pTq));
@ -503,7 +509,7 @@ int32_t tqMetaTransform(STQ* pTq) {
if (taosCopyFile(offset, offsetNew) < 0) {
tqError("copy offset file error");
} else {
(void)taosRemoveFile(offset);
TQ_ERR_GO_TO_END(taosRemoveFile(offset));
}
}
@ -511,23 +517,44 @@ END:
taosMemoryFree(offset);
taosMemoryFree(offsetNew);
// return 0 always, so ignore
(void)tdbTbClose(pExecStore);
(void)tdbTbClose(pCheckStore);
(void)tdbClose(pMetaDB);
int32_t ret = tdbTbClose(pExecStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
ret = tdbTbClose(pCheckStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
ret = tdbClose(pMetaDB);
if (ret != 0) {
tqError("failed to close tdb, ret:%d", ret);
}
return code;
}
void tqMetaClose(STQ* pTq) {
int32_t ret = 0;
if (pTq->pExecStore) {
(void)tdbTbClose(pTq->pExecStore);
ret = tdbTbClose(pTq->pExecStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
}
if (pTq->pCheckStore) {
(void)tdbTbClose(pTq->pCheckStore);
ret = tdbTbClose(pTq->pCheckStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
}
if (pTq->pOffsetStore) {
(void)tdbTbClose(pTq->pOffsetStore);
ret = tdbTbClose(pTq->pOffsetStore);
if (ret != 0) {
tqError("failed to close tb, ret:%d", ret);
}
}
ret = tdbClose(pTq->pMetaDB);
if (ret != 0) {
tqError("failed to close tdb, ret:%d", ret);
}
(void)tdbClose(pTq->pMetaDB);
}

View File

@ -77,7 +77,10 @@ _err:
}
void tqSnapReaderClose(STqSnapReader** ppReader) {
(void)tdbTbcClose((*ppReader)->pCur);
int32_t ret = tdbTbcClose((*ppReader)->pCur);
if (ret != 0){
tqError("vgId:%d, vnode snapshot tq reader close failed since %s", TD_VID((*ppReader)->pTq->pVnode), tstrerror(ret));
}
taosMemoryFree(*ppReader);
*ppReader = NULL;
}

View File

@ -2889,7 +2889,7 @@ TEST(apiTest, catalogChkAuth_test) {
SUserAuthInfo authInfo = {0};
SUserAuthRes authRes = {0};
TAOS_STRCPY(authInfo.user, ctgTestUsername);
(void)toName(1, ctgTestDbname, ctgTestSTablename, &authInfo.tbName);
toName(1, ctgTestDbname, ctgTestSTablename, &authInfo.tbName);
authInfo.type = AUTH_TYPE_READ;
bool exists = false;
code = catalogChkAuthFromCache(pCtg, &authInfo, &authRes, &exists);

View File

@ -46,7 +46,7 @@ static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const c
int32_t code = tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName));
if (TSDB_CODE_SUCCESS != code) return code;
} else {
(void)toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName);
toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName);
}
pAuth->type = type;
pAuth->isView = isView;
@ -169,10 +169,11 @@ static EDealRes authSelectImpl(SNode* pNode, void* pContext) {
SNode* pTagCond = NULL;
STableNode* pTable = (STableNode*)pNode;
#ifdef TD_ENTERPRISE
SName name;
SName name = {0};
toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name);
STableMeta* pTableMeta = NULL;
int32_t code = getTargetMetaImpl(
pAuthCxt->pParseCxt, pAuthCxt->pMetaCache, toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name), &pTableMeta, true);
pAuthCxt->pParseCxt, pAuthCxt->pMetaCache, &name, &pTableMeta, true);
if (TSDB_CODE_SUCCESS == code && TSDB_VIEW_TABLE == pTableMeta->tableType) {
isView = true;
}

View File

@ -525,8 +525,9 @@ static int32_t getTargetMeta(STranslateContext* pCxt, const SName* pName, STable
}
static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName, STableMeta** pMeta) {
SName name;
return getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta, false);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
return getTargetMeta(pCxt, &name, pMeta, false);
}
static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCfg** pCfg) {
@ -556,8 +557,8 @@ static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCf
static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
STableMeta** pMeta) {
SParseContext* pParCxt = pCxt->pParseCxt;
SName name;
(void)toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
int32_t code = TSDB_CODE_SUCCESS;
if (pParCxt->async) {
code = getTableMetaFromCache(pCxt->pMetaCache, &name, pMeta);
@ -634,8 +635,9 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName,
SVgroupInfo* pInfo) {
SName name;
return getTableHashVgroupImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pInfo);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name);
return getTableHashVgroupImpl(pCxt, &name, pInfo);
}
static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId,
@ -4015,7 +4017,7 @@ static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNo
SName tsmaTargetTbName = {0};
SVgroupInfo vgInfo = {0};
bool exists = false;
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
pRealTable->table.tableName);
len = taosCreateMD5Hash(buf, len);
@ -4676,10 +4678,9 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare
pRealTable->ratio = (NULL != pCxt->pExplainOpt ? pCxt->pExplainOpt->ratio : 1.0);
// The SRealTableNode created through ROLLUP already has STableMeta.
if (NULL == pRealTable->pMeta) {
SName name;
code = getTargetMeta(
pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name),
&(pRealTable->pMeta), true);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name);
code = getTargetMeta(pCxt, &name, &(pRealTable->pMeta), true);
if (TSDB_CODE_SUCCESS != code) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
}
@ -6228,9 +6229,9 @@ static void findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames
}
for (int j = 0; j < nTbls; ++j) {
SName snameTb;
SName snameTb = {0};
char* tbName = taosArrayGetP(aTbnames, j);
(void)toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb);
SVgroupInfo vgInfo = {0};
bool bExists;
int32_t code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &snameTb, &vgInfo, &bExists);
@ -6255,11 +6256,11 @@ static void findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames
}
static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTableInfo* pInfo) {
SName snameTb;
SName snameTb = {0};
int32_t code = 0;
SRealTableNode* pRealTable = pInfo->pRealTable;
char* tbName = taosArrayGetP(pInfo->aTbnames, 0);
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, tbName, &snameTb);
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, tbName, &snameTb);
STableMeta* pMeta = NULL;
TAOS_CHECK_RETURN(catalogGetCachedTableMeta(pCxt->pParseCxt->pCatalog, &snameTb, &pMeta));
@ -6280,7 +6281,7 @@ static int32_t replaceToChildTableQuery(STranslateContext* pCxt, SEqCondTbNameTa
for (int32_t i = 0; i < pRealTable->pTsmas->size; ++i) {
STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i);
SName tsmaTargetTbName = {0};
(void)toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName);
int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name,
pRealTable->table.tableName);
len = taosCreateMD5Hash(buf, len);
@ -8778,7 +8779,7 @@ static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) {
static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) {
int32_t code = TSDB_CODE_SUCCESS;
SName tableName;
SName tableName = {0};
pReq->igExists = pStmt->ignoreExists;
pReq->delay1 = pStmt->pOptions->maxDelay1;
pReq->delay2 = pStmt->pOptions->maxDelay2;
@ -8810,7 +8811,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
}
if (TSDB_CODE_SUCCESS == code) {
pReq->numOfFuncs = taosArrayGetSize(pReq->pFuncs);
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
code = tNameExtractFullName(&tableName, pReq->name);
}
if (TSDB_CODE_SUCCESS == code)
code = collectUseTable(&tableName, pCxt->pTables);
@ -8852,21 +8854,22 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) {
SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0);
SName tableName;
SName tableName = {0};
if (pStmt->withTsma) return TSDB_CODE_SUCCESS;
return doTranslateDropSuperTable(
pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists);
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName);
return doTranslateDropSuperTable(pCxt, &tableName, pClause->ignoreNotExists);
}
static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableStmt* pStmt) {
SName tableName;
return doTranslateDropSuperTable(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName),
pStmt->ignoreNotExists);
SName tableName = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
return doTranslateDropSuperTable(pCxt, &tableName, pStmt->ignoreNotExists);
}
static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, SMAlterStbReq* pAlterReq) {
SName tableName;
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pAlterReq->name);
SName tableName = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName);
int32_t code = tNameExtractFullName(&tableName, pAlterReq->name);
if (TSDB_CODE_SUCCESS != code) return code;
pAlterReq->alterType = pStmt->alterType;
@ -9381,11 +9384,13 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
}
static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateSmaReq* pReq) {
SName name;
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), pReq->name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
int32_t code = tNameExtractFullName(&name, pReq->name);
if (TSDB_CODE_SUCCESS == code) {
memset(&name, 0, sizeof(SName));
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), pReq->stb);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
code = tNameExtractFullName(&name, pReq->stb);
}
if (TSDB_CODE_SUCCESS == code) {
pReq->igExists = pStmt->ignoreExists;
@ -9532,11 +9537,13 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
}
static int32_t buildCreateTagIndexReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SCreateTagIndexReq* pReq) {
SName name;
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), pReq->idxName);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
int32_t code = tNameExtractFullName(&name, pReq->idxName);
if (TSDB_CODE_SUCCESS == code) {
memset(&name, 0, sizeof(SName));
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), pReq->stbName);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
code = tNameExtractFullName(&name, pReq->stbName);
}
if (TSDB_CODE_SUCCESS == code) {
memset(&name, 0, sizeof(SName));
@ -9570,10 +9577,11 @@ static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateInde
static int32_t translateCreateNormalIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {
int32_t code = 0;
SName name;
SName name = {0};
STableMeta* pMeta = NULL;
code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name), &pMeta, false);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
code = getTargetMeta(pCxt, &name, &pMeta, false);
if (code) {
taosMemoryFree(pMeta);
return code;
@ -9614,8 +9622,9 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p
static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) {
SMDropSmaReq dropSmaReq = {0};
SName name;
int32_t code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name), dropSmaReq.name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->indexDbName, pStmt->indexName, &name);
int32_t code = tNameExtractFullName(&name, dropSmaReq.name);
if (TSDB_CODE_SUCCESS != code) return code;
dropSmaReq.igNotExists = pStmt->ignoreNotExists;
return buildCmdMsg(pCxt, TDMT_MND_DROP_SMA, (FSerializeFunc)tSerializeSMDropSmaReq, &dropSmaReq);
@ -9687,10 +9696,10 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
}
int32_t code = TSDB_CODE_SUCCESS;
SName name;
SName name = {0};
if ('\0' != pStmt->subSTbName[0]) {
pReq->subType = TOPIC_SUB_TYPE__TABLE;
(void)toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
toName(pCxt->pParseCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
(void)tNameGetFullDbName(&name, pReq->subDbName);
if (TSDB_CODE_SUCCESS == code) {
(void)tNameExtractFullName(&name, pReq->subStbName);
@ -9815,10 +9824,10 @@ static int32_t buildQueryForTableTopic(STranslateContext* pCxt, SCreateTopicStmt
.requestId = pParCxt->requestId,
.requestObjRefId = pParCxt->requestRid,
.mgmtEps = pParCxt->mgmtEpSet};
SName name;
SName name = {0};
STableMeta* pMeta = NULL;
int32_t code =
getTargetMeta(pCxt, toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name), &pMeta, false);
toName(pParCxt->acctId, pStmt->subDbName, pStmt->subSTbName, &name);
int32_t code = getTargetMeta(pCxt, &name, &pMeta, false);
if (code) {
taosMemoryFree(pMeta);
return code;
@ -9939,8 +9948,8 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt)
#ifdef TD_ENTERPRISE
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
int32_t origCode = code;
SName name;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
SViewMeta* pMeta = NULL;
code = getViewMetaFromMetaCache(pCxt, &name, &pMeta);
if (TSDB_CODE_SUCCESS != code) {
@ -10057,12 +10066,11 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt
#ifdef TD_ENTERPRISE
SRealTableNode* pRealTable = (SRealTableNode*)((SSelectStmt*)pStmt->pQuery)->pFromTable;
SName name;
SName name = {0};
STableMeta* pMeta = NULL;
int8_t tableType = 0;
int32_t code =
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name),
&pMeta, true);
toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name);
int32_t code = getTargetMeta(pCxt, &name, &pMeta, true);
if (NULL != pMeta) {
tableType = pMeta->tableType;
taosMemoryFree(pMeta);
@ -11298,9 +11306,9 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
#endif
SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA};
SName name;
SName name = {0};
char dbFName[TSDB_DB_FNAME_LEN];
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
(void)tNameGetFullDbName(&name, dbFName);
int32_t code = validateCreateView(pCxt, pStmt);
@ -11340,7 +11348,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt)
#endif
SCMDropViewReq dropReq = {0};
SName name;
SName name = {0};
int32_t code = tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName));
if (TSDB_CODE_SUCCESS == code) {
(void)tNameGetFullDbName(&name, dropReq.dbFName);
@ -11351,7 +11359,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt)
return TSDB_CODE_OUT_OF_MEMORY;
}
dropReq.igNotExists = pStmt->ignoreNotExists;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
code = collectUseTable(&name, pCxt->pTargetTables);
}
@ -11460,9 +11468,9 @@ static int32_t translateGrantTagCond(STranslateContext* pCxt, SGrantStmt* pStmt,
int32_t code = createRealTableForGrantTable(pStmt, &pTable);
if (TSDB_CODE_SUCCESS == code) {
SName name;
code = getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name),
&(pTable->pMeta), false);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pTable->table.dbName, pTable->table.tableName, &name);
code = getTargetMeta(pCxt, &name, &(pTable->pMeta), false);
if (code) {
nodesDestroyNode((SNode*)pTable);
return code;
@ -11502,10 +11510,10 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) {
req.privileges = pStmt->privileges;
#ifdef TD_ENTERPRISE
if (0 != pStmt->tabName[0]) {
SName name;
SName name = {0};
STableMeta* pTableMeta = NULL;
code =
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true);
toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name);
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
if (TSDB_CODE_SUCCESS != code) {
if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
@ -11538,10 +11546,10 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) {
#ifdef TD_ENTERPRISE
if (0 != pStmt->tabName[0]) {
SName name;
SName name = {0};
STableMeta* pTableMeta = NULL;
code =
getTargetMeta(pCxt, toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name), &pTableMeta, true);
toName(pCxt->pParseCxt->acctId, pStmt->objName, pStmt->tabName, &name);
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
if (TSDB_CODE_SUCCESS != code) {
if (TSDB_CODE_PAR_TABLE_NOT_EXIST != code) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
@ -11654,8 +11662,8 @@ static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTabl
}
int32_t code = getDBCfg(pCxt, pStmt->dbName, (SDbCfgInfo*)pStmt->pDbCfg);
if (TSDB_CODE_SUCCESS == code) {
SName name;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
code = getTableCfg(pCxt, &name, (STableCfg**)&pStmt->pTableCfg);
}
return code;
@ -11665,8 +11673,8 @@ static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewS
#ifndef TD_ENTERPRISE
return TSDB_CODE_OPS_NOT_SUPPORT;
#else
SName name;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
return getViewMetaFromMetaCache(pCxt, &name, (SViewMeta**)&pStmt->pViewMeta);
#endif
}
@ -11934,13 +11942,14 @@ static int32_t rewriteTSMAFuncs(STranslateContext* pCxt, SCreateTSMAStmt* pStmt,
static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq,
SName* useTbName) {
SName name;
SName name = {0};
SDbCfgInfo pDbInfo = {0};
int32_t code = TSDB_CODE_SUCCESS;
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), pReq->name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name);
code = tNameExtractFullName(&name, pReq->name);
if (TSDB_CODE_SUCCESS == code) {
memset(&name, 0, sizeof(SName));
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, useTbName);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, useTbName);
code = tNameExtractFullName(useTbName, pReq->stb);
}
if (TSDB_CODE_SUCCESS == code) {
@ -12013,7 +12022,8 @@ static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStm
if (TSDB_CODE_SUCCESS == code) {
memset(useTbName, 0, sizeof(SName));
memcpy(pStmt->originalTbName, pRecursiveTsma->tb, TSDB_TABLE_NAME_LEN);
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pRecursiveTsma->tb, useTbName), pReq->stb);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pRecursiveTsma->tb, useTbName);
code = tNameExtractFullName(useTbName, pReq->stb);
}
if (TSDB_CODE_SUCCESS == code) {
numOfCols = pRecursiveTsma->pUsedCols->size;
@ -12134,7 +12144,7 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData
if (TSDB_CODE_SUCCESS == code) {
SName name = {0};
(void)toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name);
toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name);
code = collectUseTable(&name, cxt.pTargetTables);
}
@ -12151,15 +12161,16 @@ int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSData
static int32_t translateDropTSMA(STranslateContext* pCxt, SDropTSMAStmt* pStmt) {
int32_t code = TSDB_CODE_SUCCESS;
SMDropSmaReq dropReq = {0};
SName name;
SName name = {0};
STableTSMAInfo* pTsma = NULL;
code = tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), dropReq.name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name);
code = tNameExtractFullName(&name, dropReq.name);
if (TSDB_CODE_SUCCESS == code) {
dropReq.igNotExists = pStmt->ignoreNotExists;
code = getTsma(pCxt, &name, &pTsma);
}
if (code == TSDB_CODE_SUCCESS) {
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pTsma->tb, &name);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pTsma->tb, &name);
code = collectUseTable(&name, pCxt->pTargetTables);
}
if (TSDB_CODE_SUCCESS == code)
@ -13057,12 +13068,11 @@ static int32_t rewriteShowVgroups(STranslateContext* pCxt, SQuery* pQuery) {
static int32_t checkShowTags(STranslateContext* pCxt, const SShowStmt* pShow) {
int32_t code = 0;
SName name;
SName name = {0};
STableMeta* pTableMeta = NULL;
code = getTargetMeta(pCxt,
toName(pCxt->pParseCxt->acctId, ((SValueNode*)pShow->pDbName)->literal,
((SValueNode*)pShow->pTbName)->literal, &name),
&pTableMeta, true);
((SValueNode*)pShow->pTbName)->literal, &name);
code = getTargetMeta(pCxt, &name, &pTableMeta, true);
if (TSDB_CODE_SUCCESS != code) {
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code));
goto _exit;
@ -13420,8 +13430,8 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
int32_t code = checkCreateTable(pCxt, pStmt, false);
SVgroupInfo info = {0};
SName name;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
if (TSDB_CODE_SUCCESS == code) {
code = getTableHashVgroupImpl(pCxt, &name, &info);
}
@ -13668,8 +13678,8 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta);
}
if (TSDB_CODE_SUCCESS == code) {
SName name;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name);
code = collectUseTable(&name, pCxt->pTargetTables);
}
@ -14434,8 +14444,8 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch);
FOREACH(pNode, pStmt->pTables) {
SDropTableClause* pClause = (SDropTableClause*)pNode;
SName name;
(void)toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
SName name = {0};
toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name);
int32_t code = buildDropTableVgroupHashmap(pCxt, pClause, &name, &tableType, pVgroupHashmap);
if (TSDB_CODE_SUCCESS != code) {
taosHashCleanup(pVgroupHashmap);
@ -14511,7 +14521,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
SArray* pTsmas = NULL;
int32_t code = TSDB_CODE_SUCCESS;
if (pCxt->pMetaCache) {
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas);
if (code != TSDB_CODE_SUCCESS) return code;
if (pTsmas && pTsmas->size > 0) return TSDB_CODE_TSMA_MUST_BE_DROPPED;
@ -14693,9 +14703,9 @@ static int32_t buildRenameColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
}
if (TSDB_NORMAL_TABLE == pTableMeta->tableType) {
SArray* pTsmas = NULL;
SName tbName;
SName tbName = {0};
int32_t code = 0;
(void)toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName);
if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas);
if (TSDB_CODE_SUCCESS != code) return code;
if (pTsmas && pTsmas->size > 0) {