feat:add ts,table name from SDeleterRes
This commit is contained in:
parent
0952c98609
commit
2ba6ac5fba
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue