From 2ba6ac5fbafef4daa8a95c20b756e59cf9674db9 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 27 Jul 2022 17:11:57 +0800 Subject: [PATCH] feat:add ts,table name from SDeleterRes --- include/common/tmsg.h | 3 +- include/libs/executor/dataSinkMgt.h | 3 +- include/libs/nodes/plannodes.h | 6 +-- source/client/src/tmq.c | 62 +++++++++++----------- source/common/src/tmsg.c | 2 + source/libs/executor/src/dataDeleter.c | 3 +- source/libs/nodes/src/nodesCloneFuncs.c | 2 +- source/libs/nodes/src/nodesCodeFuncs.c | 4 +- source/libs/planner/src/planLogicCreater.c | 6 +-- source/libs/planner/src/planPhysiCreater.c | 4 +- source/libs/qworker/src/qworker.c | 3 +- 11 files changed, 51 insertions(+), 47 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 73238697cb..563d6c766c 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -3044,7 +3044,8 @@ typedef struct SDeleteRes { int64_t skey; int64_t ekey; int64_t affectedRows; - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableFName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; } SDeleteRes; int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes); diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index 90b804b382..47177dc11b 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -38,7 +38,8 @@ typedef struct SDeleterRes { int64_t skey; int64_t ekey; int64_t affectedRows; - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + char tsColName[TSDB_COL_NAME_LEN]; } SDeleterRes; typedef struct SDeleterParam { diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 0e05ed7887..9fe9760bb0 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -151,7 +151,7 @@ typedef struct SVnodeModifyLogicNode { uint64_t tableId; uint64_t stableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; char tsColName[TSDB_COL_NAME_LEN]; STimeWindow deleteTimeRange; SVgroupsInfo* pVgroupList; @@ -494,7 +494,7 @@ typedef struct SQueryInserterNode { uint64_t tableId; uint64_t stableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; int32_t vgId; SEpSet epSet; } SQueryInserterNode; @@ -503,7 +503,7 @@ typedef struct SDataDeleterNode { SDataSinkNode sink; uint64_t tableId; int8_t tableType; // table type - char tableFName[TSDB_TABLE_FNAME_LEN]; + char tableFName[TSDB_TABLE_NAME_LEN]; char tsColName[TSDB_COL_NAME_LEN]; STimeWindow deleteTimeRange; SNode* pAffectedRows; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index df9072fe1a..88ebb099e5 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -2823,35 +2823,35 @@ end: // delete from db.tabl where .. -> delete from tabl where .. // delete from db .tabl where .. -> delete from tabl where .. -static void getTbName(char *sql){ - char *ch = sql; - - bool inBackQuote = false; - int8_t dotIndex = 0; - while(*ch != '\0'){ - if(!inBackQuote && *ch == '`'){ - inBackQuote = true; - ch++; - continue; - } - - if(inBackQuote && *ch == '`'){ - inBackQuote = false; - ch++; - - continue; - } - - if(!inBackQuote && *ch == '.'){ - dotIndex ++; - if(dotIndex == 2){ - memmove(sql, ch + 1, strlen(ch + 1) + 1); - break; - } - } - ch++; - } -} +//static void getTbName(char *sql){ +// char *ch = sql; +// +// bool inBackQuote = false; +// int8_t dotIndex = 0; +// while(*ch != '\0'){ +// if(!inBackQuote && *ch == '`'){ +// inBackQuote = true; +// ch++; +// continue; +// } +// +// if(inBackQuote && *ch == '`'){ +// inBackQuote = false; +// ch++; +// +// continue; +// } +// +// if(!inBackQuote && *ch == '.'){ +// dotIndex ++; +// if(dotIndex == 2){ +// memmove(sql, ch + 1, strlen(ch + 1) + 1); +// break; +// } +// } +// ch++; +// } +//} static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { SDeleteRes req = {0}; @@ -2867,9 +2867,9 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { goto end; } - getTbName(req.tableFName); +// getTbName(req.tableFName); char sql[256] = {0}; - sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, "ts", req.skey, "ts", req.ekey); + sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey); printf("delete sql:%s\n", sql); TAOS_RES* res = taos_query(taos, sql); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 59d3b45e09..68d7a3d292 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5682,6 +5682,7 @@ int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) { if (tEncodeI64v(pCoder, pRes->affectedRows) < 0) return -1; if (tEncodeCStr(pCoder, pRes->tableFName) < 0) return -1; + if (tEncodeCStr(pCoder, pRes->tsColName) < 0) return -1; return 0; } @@ -5700,6 +5701,7 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) { if (tDecodeI64v(pCoder, &pRes->affectedRows) < 0) return -1; if (tDecodeCStrTo(pCoder, pRes->tableFName) < 0) return -1; + if (tDecodeCStrTo(pCoder, pRes->tsColName) < 0) return -1; return 0; } int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) { diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 391aef529f..06b7c13fa2 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -90,7 +90,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp pRes->uidList = pHandle->pParam->pUidList; pRes->skey = pHandle->pDeleter->deleteTimeRange.skey; pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey; - strcpy(pRes->tableFName, pHandle->pDeleter->tableFName); + strcpy(pRes->tableName, pHandle->pDeleter->tableFName); + strcpy(pRes->tsColName, pHandle->pDeleter->tsColName); pRes->affectedRows = *(int64_t*)pColRes->pData; pBuf->useSize += pEntry->dataLen; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index edae8ae118..5fc94c2642 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -401,7 +401,7 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi COPY_SCALAR_FIELD(tableId); COPY_SCALAR_FIELD(stableId); COPY_SCALAR_FIELD(tableType); - COPY_CHAR_ARRAY_FIELD(tableFName); + COPY_CHAR_ARRAY_FIELD(tableName); COPY_CHAR_ARRAY_FIELD(tsColName); COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow)); CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 51bd2c644b..d25b2f3e25 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -2326,7 +2326,7 @@ static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) { code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanTableType, pNode->tableType); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName); + code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName); } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanVgId, pNode->vgId); @@ -2355,7 +2355,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) { code = tjsonGetTinyIntValue(pJson, jkQueryInsertPhysiPlanTableType, &pNode->tableType); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName); + code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName); } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetIntValue(pJson, jkQueryInsertPhysiPlanVgId, &pNode->vgId); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 8f8d666bd3..d405b75003 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1292,8 +1292,7 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet pModify->modifyType = MODIFY_TABLE_TYPE_DELETE; pModify->tableId = pRealTable->pMeta->uid; pModify->tableType = pRealTable->pMeta->tableType; - snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId, - pRealTable->table.dbName, pRealTable->table.tableName); + snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName); strcpy(pModify->tsColName, pRealTable->pMeta->schema->name); pModify->deleteTimeRange = pDelete->timeRange; pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc); @@ -1343,8 +1342,7 @@ static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInser pModify->tableId = pRealTable->pMeta->uid; pModify->stableId = pRealTable->pMeta->suid; pModify->tableType = pRealTable->pMeta->tableType; - snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId, - pRealTable->table.dbName, pRealTable->table.tableName); + snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName); TSWAP(pModify->pVgroupList, pRealTable->pVgroupList); pModify->pInsertCols = nodesCloneList(pInsert->pCols); if (NULL == pModify->pInsertCols) { diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 402989024c..beb3dd0067 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1586,7 +1586,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod pInserter->tableId = pModify->tableId; pInserter->stableId = pModify->stableId; pInserter->tableType = pModify->tableType; - strcpy(pInserter->tableFName, pModify->tableFName); + strcpy(pInserter->tableName, pModify->tableName); pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId; pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet; vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode); @@ -1636,7 +1636,7 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode* pDeleter->tableId = pModify->tableId; pDeleter->tableType = pModify->tableType; - strcpy(pDeleter->tableFName, pModify->tableFName); + strcpy(pDeleter->tableFName, pModify->tableName); strcpy(pDeleter->tsColName, pModify->tsColName); pDeleter->deleteTimeRange = pModify->deleteTimeRange; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index df57d0fef1..d1f8a50dab 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -283,7 +283,8 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes pRes->skey = pDelRes->skey; pRes->ekey = pDelRes->ekey; pRes->affectedRows = pDelRes->affectedRows; - strcpy(pRes->tableFName, pDelRes->tableFName); + strcpy(pRes->tableFName, pDelRes->tableName); + strcpy(pRes->tsColName, pDelRes->tsColName); taosMemoryFree(output.pData); return TSDB_CODE_SUCCESS; -- GitLab