From d3518fbc89b964232828dd0a2d052d34d3555557 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Tue, 3 Sep 2024 15:24:33 +0800 Subject: [PATCH 01/26] fix:TD-31587:Repeated insert performance degradation --- include/libs/monitorfw/taos_counter.h | 3 ++ source/dnode/mgmt/mgmt_dnode/inc/dmInt.h | 1 + source/dnode/mgmt/mgmt_dnode/src/dmInt.c | 1 + source/dnode/mgmt/mgmt_dnode/src/dmWorker.c | 1 + source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 24 ++++++++++++ source/dnode/mgmt/node_mgmt/inc/dmMgmt.h | 1 + source/dnode/mgmt/node_mgmt/inc/dmNodes.h | 2 + source/dnode/mgmt/node_mgmt/src/dmEnv.c | 1 + source/dnode/mgmt/node_mgmt/src/dmMonitor.c | 18 +++++++++ source/dnode/mgmt/node_util/inc/dmUtil.h | 2 + .../monitorfw/inc/taos_metric_formatter_i.h | 1 + source/libs/monitorfw/src/taos_counter.c | 38 +++++++++++++++++++ .../monitorfw/src/taos_metric_formatter.c | 15 ++++++++ 13 files changed, 108 insertions(+) diff --git a/include/libs/monitorfw/taos_counter.h b/include/libs/monitorfw/taos_counter.h index 28a9eed41c..1fdb6f7f7a 100644 --- a/include/libs/monitorfw/taos_counter.h +++ b/include/libs/monitorfw/taos_counter.h @@ -99,4 +99,7 @@ int taos_counter_inc(taos_counter_t *self, const char **label_values); */ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values); +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys,int32_t **vgroup_ids); +int taos_counter_get_keys_size(taos_counter_t *self); +int taos_counter_delete(taos_counter_t *self, char *key); #endif // TAOS_COUNTER_H diff --git a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h index be9ff56674..5a55af24b1 100644 --- a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h +++ b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h @@ -37,6 +37,7 @@ typedef struct SDnodeMgmt { ProcessAlterNodeTypeFp processAlterNodeTypeFp; ProcessDropNodeFp processDropNodeFp; SendMonitorReportFp sendMonitorReportFp; + MonitorCleanExpiredSamplesFp monitorCleanExpiredSamplesFp; SendAuditRecordsFp sendAuditRecordsFp; GetVnodeLoadsFp getVnodeLoadsFp; GetVnodeLoadsFp getVnodeLoadsLiteFp; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c index 958b411881..d7170398fb 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmInt.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmInt.c @@ -65,6 +65,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) { pMgmt->processAlterNodeTypeFp = pInput->processAlterNodeTypeFp; pMgmt->processDropNodeFp = pInput->processDropNodeFp; pMgmt->sendMonitorReportFp = pInput->sendMonitorReportFp; + pMgmt->monitorCleanExpiredSamplesFp = pInput->monitorCleanExpiredSamplesFp; pMgmt->sendAuditRecordsFp = pInput->sendAuditRecordFp; pMgmt->getVnodeLoadsFp = pInput->getVnodeLoadsFp; pMgmt->getVnodeLoadsLiteFp = pInput->getVnodeLoadsLiteFp; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index aeb519596d..4cfadc8f59 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -168,6 +168,7 @@ static void *dmMonitorThreadFp(void *param) { float interval = (curTime - lastTime) / 1000.0f; if (interval >= tsMonitorInterval) { (*pMgmt->sendMonitorReportFp)(); + (*pMgmt->monitorCleanExpiredSamplesFp)(); lastTime = curTime; trimCount = (trimCount + 1) % TRIM_FREQ; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 4cb6c5c724..685a35d9ff 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -15,6 +15,9 @@ #define _DEFAULT_SOURCE #include "vmInt.h" +#include "taos_monitor.h" + +extern taos_counter_t *tsInsertCounter; void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) { pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad)); @@ -117,6 +120,27 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) { taosArrayDestroy(pVloads); } +int vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { + int list_size = taos_counter_get_keys_size(tsInsertCounter); + if (list_size == 0) return 0; + int32_t *vgroup_ids; + char **keys; + taos_counter_get_vgroup_ids(tsInsertCounter,&keys,&vgroup_ids); + int r = 0; + (void)taosThreadRwlockWrlock(&pMgmt->lock); + for (int i = 0; ihash, &vgroup_id, sizeof(int32_t)); + if (vnode == NULL) { + r = taos_counter_delete(tsInsertCounter, keys[i]); + } + } + (void)taosThreadRwlockUnlock(&pMgmt->lock); + taosMemoryFree(vgroup_ids); + taosMemoryFree(keys); + return r; +} + static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { memcpy(pCfg, &vnodeCfgDefault, sizeof(SVnodeCfg)); diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index 9548d0cad9..5196987f28 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -128,6 +128,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); // dmMonitor.c void dmSendMonitorReport(); +void dmMonitorCleanExpiredSamples(); void dmSendAuditRecords(); void dmGetVnodeLoads(SMonVloadInfo *pInfo); void dmGetVnodeLoadsLite(SMonVloadInfo *pInfo); diff --git a/source/dnode/mgmt/node_mgmt/inc/dmNodes.h b/source/dnode/mgmt/node_mgmt/inc/dmNodes.h index 7d635c6bdc..c0ef92b537 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmNodes.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmNodes.h @@ -39,6 +39,8 @@ void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo); void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo); void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo); +int vmCleanExpriedSamples(void *pMgmt); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 0a75847d96..620aed709f 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -409,6 +409,7 @@ SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper) { .processAlterNodeTypeFp = dmProcessAlterNodeTypeReq, .processDropNodeFp = dmProcessDropNodeReq, .sendMonitorReportFp = dmSendMonitorReport, + .monitorCleanExpiredSamplesFp = dmMonitorCleanExpiredSamples, .sendAuditRecordFp = auditSendRecordsInBatch, .getVnodeLoadsFp = dmGetVnodeLoads, .getVnodeLoadsLiteFp = dmGetVnodeLoadsLite, diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index d3197282b6..a2658b26cb 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -52,6 +52,16 @@ static void dmGetDmMonitorInfo(SDnode *pDnode) { monSetDmInfo(&dmInfo); } +int dmCleanExpriedSamples(SDnode *pDnode) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE]; + if (dmMarkWrapper(pWrapper) == 0) { + if (pWrapper->pMgmt != NULL) { + return vmCleanExpriedSamples(pWrapper->pMgmt); + } + } + return 0; +} + static void dmGetDmMonitorInfoBasic(SDnode *pDnode) { SMonDmInfo dmInfo = {0}; dmGetMonitorBasicInfoBasic(pDnode, &dmInfo.basic); @@ -123,6 +133,14 @@ void dmSendMonitorReport() { monGenAndSendReport(); } +void dmMonitorCleanExpiredSamples() { + if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; + dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort); + + SDnode *pDnode = dmInstance(); + (void)dmCleanExpriedSamples(pDnode); +} + //Todo: put this in seperate file in the future void dmSendAuditRecords() { auditSendRecordsInBatch(); diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 4ad4ea7c30..a66b8d7b67 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -116,6 +116,7 @@ typedef enum { typedef int32_t (*ProcessCreateNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg); typedef int32_t (*ProcessDropNodeFp)(EDndNodeType ntype, SRpcMsg *pMsg); typedef void (*SendMonitorReportFp)(); +typedef void (*MonitorCleanExpiredSamplesFp)(); typedef void (*SendAuditRecordsFp)(); typedef void (*GetVnodeLoadsFp)(SMonVloadInfo *pInfo); typedef void (*GetMnodeLoadsFp)(SMonMloadInfo *pInfo); @@ -155,6 +156,7 @@ typedef struct { ProcessAlterNodeTypeFp processAlterNodeTypeFp; ProcessDropNodeFp processDropNodeFp; SendMonitorReportFp sendMonitorReportFp; + MonitorCleanExpiredSamplesFp monitorCleanExpiredSamplesFp; SendAuditRecordsFp sendAuditRecordFp; GetVnodeLoadsFp getVnodeLoadsFp; GetVnodeLoadsFp getVnodeLoadsLiteFp; diff --git a/source/libs/monitorfw/inc/taos_metric_formatter_i.h b/source/libs/monitorfw/inc/taos_metric_formatter_i.h index ab60359f4a..dee25f4c06 100644 --- a/source/libs/monitorfw/inc/taos_metric_formatter_i.h +++ b/source/libs/monitorfw/inc/taos_metric_formatter_i.h @@ -80,4 +80,5 @@ int taos_metric_formatter_clear(taos_metric_formatter_t *self); */ char *taos_metric_formatter_dump(taos_metric_formatter_t *metric_formatter); +int32_t taos_metric_formatter_get_vgroup_id(char *key); #endif // TAOS_METRIC_FORMATTER_I_H diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index ef7d41cf2c..c01322295d 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -27,6 +27,7 @@ #include "taos_metric_sample_i.h" #include "taos_metric_sample_t.h" #include "taos_metric_t.h" +#include "taos_metric_formatter_i.h" taos_counter_t *taos_counter_new(const char *name, const char *help, size_t label_key_count, const char **label_keys) { return (taos_counter_t *)taos_metric_new(TAOS_COUNTER, name, help, label_key_count, label_keys); @@ -64,3 +65,40 @@ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_va if (sample == NULL) return 1; return taos_metric_sample_add(sample, r_value); } + +int taos_counter_get_keys_size(taos_counter_t *self) { + return self->samples->keys->size; +} + +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys,int32_t **vgroup_ids) { + TAOS_TEST_PARA(self != NULL); + if (self == NULL) return 1; + if (self->type != TAOS_COUNTER) { + TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); + return 1; + } + if (self->samples == NULL) return 1; + taos_linked_list_t *key_list = self->samples->keys; + int r = 0; + *vgroup_ids = (int32_t *)taos_malloc(key_list->size*sizeof(int32_t)); + *keys = (char **)taos_malloc(key_list->size*sizeof(char *)); + int index = 0; + for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL;current_key = current_key->next) { + char *key = (char *)current_key->item; + int32_t vgroup_id = taos_metric_formatter_get_vgroup_id(key); + (*vgroup_ids)[index] = vgroup_id; + (*keys)[index] = key; + index++; + } + return r; +} + +int taos_counter_delete(taos_counter_t *self, char *key) { + TAOS_TEST_PARA(self != NULL); + if (self == NULL) return 1; + if (self->type != TAOS_COUNTER) { + TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); + return 1; + } + return taos_map_delete(self->samples, key); +} \ No newline at end of file diff --git a/source/libs/monitorfw/src/taos_metric_formatter.c b/source/libs/monitorfw/src/taos_metric_formatter.c index a20a8d919c..1d5925f565 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter.c +++ b/source/libs/monitorfw/src/taos_metric_formatter.c @@ -156,6 +156,21 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char } return 0; } +int32_t taos_metric_formatter_get_vgroup_id(char *key) { + char *start,*end; + char vgroupid[10]; + start = strstr(key, "vgroup_id=\""); + if (start) { + start += strlen("vgroup_id=\""); + end = strchr(start, '\"'); + if (end) { + strncpy(vgroupid, start, end - start); + vgroupid[end - start] = '\0'; + } + return strtol(vgroupid, NULL, 10); + } + return 0; +} /* int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample, char *ts, char *format) { From 81615362c3a93fa802f75ec4716eab1d2f2bbaa0 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Tue, 3 Sep 2024 16:25:40 +0800 Subject: [PATCH 02/26] format --- include/libs/monitorfw/taos_counter.h | 2 +- source/dnode/mgmt/mgmt_dnode/inc/dmInt.h | 40 +++++++++---------- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 18 ++++----- source/dnode/mgmt/node_mgmt/src/dmMonitor.c | 12 +++--- source/dnode/mgmt/node_util/inc/dmUtil.h | 30 +++++++------- .../monitorfw/inc/taos_metric_formatter_i.h | 4 +- source/libs/monitorfw/src/taos_counter.c | 22 +++++----- .../monitorfw/src/taos_metric_formatter.c | 24 +++++------ 8 files changed, 74 insertions(+), 78 deletions(-) diff --git a/include/libs/monitorfw/taos_counter.h b/include/libs/monitorfw/taos_counter.h index 1fdb6f7f7a..816d8ea7b9 100644 --- a/include/libs/monitorfw/taos_counter.h +++ b/include/libs/monitorfw/taos_counter.h @@ -99,7 +99,7 @@ int taos_counter_inc(taos_counter_t *self, const char **label_values); */ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values); -int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys,int32_t **vgroup_ids); +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids); int taos_counter_get_keys_size(taos_counter_t *self); int taos_counter_delete(taos_counter_t *self, char *key); #endif // TAOS_COUNTER_H diff --git a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h index 5a55af24b1..18b3f66a60 100644 --- a/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h +++ b/source/dnode/mgmt/mgmt_dnode/inc/dmInt.h @@ -23,27 +23,27 @@ extern "C" { #endif typedef struct SDnodeMgmt { - SDnodeData *pData; - SMsgCb msgCb; - const char *path; - const char *name; - TdThread statusThread; - TdThread notifyThread; - TdThread monitorThread; - TdThread auditThread; - TdThread crashReportThread; - SSingleWorker mgmtWorker; - ProcessCreateNodeFp processCreateNodeFp; - ProcessAlterNodeTypeFp processAlterNodeTypeFp; - ProcessDropNodeFp processDropNodeFp; - SendMonitorReportFp sendMonitorReportFp; + SDnodeData *pData; + SMsgCb msgCb; + const char *path; + const char *name; + TdThread statusThread; + TdThread notifyThread; + TdThread monitorThread; + TdThread auditThread; + TdThread crashReportThread; + SSingleWorker mgmtWorker; + ProcessCreateNodeFp processCreateNodeFp; + ProcessAlterNodeTypeFp processAlterNodeTypeFp; + ProcessDropNodeFp processDropNodeFp; + SendMonitorReportFp sendMonitorReportFp; MonitorCleanExpiredSamplesFp monitorCleanExpiredSamplesFp; - SendAuditRecordsFp sendAuditRecordsFp; - GetVnodeLoadsFp getVnodeLoadsFp; - GetVnodeLoadsFp getVnodeLoadsLiteFp; - GetMnodeLoadsFp getMnodeLoadsFp; - GetQnodeLoadsFp getQnodeLoadsFp; - int32_t statusSeq; + SendAuditRecordsFp sendAuditRecordsFp; + GetVnodeLoadsFp getVnodeLoadsFp; + GetVnodeLoadsFp getVnodeLoadsLiteFp; + GetMnodeLoadsFp getMnodeLoadsFp; + GetQnodeLoadsFp getQnodeLoadsFp; + int32_t statusSeq; } SDnodeMgmt; // dmHandle.c diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 685a35d9ff..8ec51b637b 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -14,8 +14,8 @@ */ #define _DEFAULT_SOURCE -#include "vmInt.h" #include "taos_monitor.h" +#include "vmInt.h" extern taos_counter_t *tsInsertCounter; @@ -124,16 +124,16 @@ int vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { int list_size = taos_counter_get_keys_size(tsInsertCounter); if (list_size == 0) return 0; int32_t *vgroup_ids; - char **keys; - taos_counter_get_vgroup_ids(tsInsertCounter,&keys,&vgroup_ids); + char **keys; + taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids); int r = 0; (void)taosThreadRwlockWrlock(&pMgmt->lock); - for (int i = 0; ihash, &vgroup_id, sizeof(int32_t)); - if (vnode == NULL) { - r = taos_counter_delete(tsInsertCounter, keys[i]); - } + for (int i = 0; i < list_size; i++) { + int32_t vgroup_id = vgroup_ids[i]; + void *vnode = taosHashGet(pMgmt->hash, &vgroup_id, sizeof(int32_t)); + if (vnode == NULL) { + r = taos_counter_delete(tsInsertCounter, keys[i]); + } } (void)taosThreadRwlockUnlock(&pMgmt->lock); taosMemoryFree(vgroup_ids); diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index a2658b26cb..61cdd5a272 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -14,9 +14,9 @@ */ #define _DEFAULT_SOURCE +#include "audit.h" #include "dmMgmt.h" #include "dmNodes.h" -#include "audit.h" static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { pInfo->protocol = 1; @@ -33,8 +33,8 @@ static void dmGetMonitorBasicInfoBasic(SDnode *pDnode, SMonBasicInfo *pInfo) { } static void dmGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) { - //pInfo->uptime = (taosGetTimestampMs() - pDnode->data.rebootTime) / (86400000.0f); - pInfo->uptime = (taosGetTimestampMs() - pDnode->data.rebootTime) /1000.0f; + // pInfo->uptime = (taosGetTimestampMs() - pDnode->data.rebootTime) / (86400000.0f); + pInfo->uptime = (taosGetTimestampMs() - pDnode->data.rebootTime) / 1000.0f; pInfo->has_mnode = pDnode->wrappers[MNODE].required; pInfo->has_qnode = pDnode->wrappers[QNODE].required; pInfo->has_snode = pDnode->wrappers[SNODE].required; @@ -141,10 +141,8 @@ void dmMonitorCleanExpiredSamples() { (void)dmCleanExpriedSamples(pDnode); } -//Todo: put this in seperate file in the future -void dmSendAuditRecords() { - auditSendRecordsInBatch(); -} +// Todo: put this in seperate file in the future +void dmSendAuditRecords() { auditSendRecordsInBatch(); } void dmGetVnodeLoads(SMonVloadInfo *pInfo) { SDnode *pDnode = dmInstance(); diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index a66b8d7b67..425f10392f 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -147,22 +147,22 @@ typedef struct { } SDnodeData; typedef struct { - const char *path; - const char *name; - STfs *pTfs; - SDnodeData *pData; - SMsgCb msgCb; - ProcessCreateNodeFp processCreateNodeFp; - ProcessAlterNodeTypeFp processAlterNodeTypeFp; - ProcessDropNodeFp processDropNodeFp; - SendMonitorReportFp sendMonitorReportFp; + const char *path; + const char *name; + STfs *pTfs; + SDnodeData *pData; + SMsgCb msgCb; + ProcessCreateNodeFp processCreateNodeFp; + ProcessAlterNodeTypeFp processAlterNodeTypeFp; + ProcessDropNodeFp processDropNodeFp; + SendMonitorReportFp sendMonitorReportFp; MonitorCleanExpiredSamplesFp monitorCleanExpiredSamplesFp; - SendAuditRecordsFp sendAuditRecordFp; - GetVnodeLoadsFp getVnodeLoadsFp; - GetVnodeLoadsFp getVnodeLoadsLiteFp; - GetMnodeLoadsFp getMnodeLoadsFp; - GetQnodeLoadsFp getQnodeLoadsFp; - StopDnodeFp stopDnodeFp; + SendAuditRecordsFp sendAuditRecordFp; + GetVnodeLoadsFp getVnodeLoadsFp; + GetVnodeLoadsFp getVnodeLoadsLiteFp; + GetMnodeLoadsFp getMnodeLoadsFp; + GetQnodeLoadsFp getQnodeLoadsFp; + StopDnodeFp stopDnodeFp; } SMgmtInputOpt; typedef struct { diff --git a/source/libs/monitorfw/inc/taos_metric_formatter_i.h b/source/libs/monitorfw/inc/taos_metric_formatter_i.h index dee25f4c06..5c330b50e7 100644 --- a/source/libs/monitorfw/inc/taos_metric_formatter_i.h +++ b/source/libs/monitorfw/inc/taos_metric_formatter_i.h @@ -57,8 +57,8 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *metric_formatter /** * @brief API PRIVATE Loads the formatter with a metric sample */ -int taos_metric_formatter_load_sample(taos_metric_formatter_t *metric_formatter, taos_metric_sample_t *sample, - char *ts, char *format); +int taos_metric_formatter_load_sample(taos_metric_formatter_t *metric_formatter, taos_metric_sample_t *sample, char *ts, + char *format); /** * @brief API PRIVATE Loads a metric in the string exposition format diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index c01322295d..84e29b5f93 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -20,14 +20,14 @@ #include "taos_alloc.h" // Private -#include "taos_test.h" #include "taos_errors.h" #include "taos_log.h" +#include "taos_metric_formatter_i.h" #include "taos_metric_i.h" #include "taos_metric_sample_i.h" #include "taos_metric_sample_t.h" #include "taos_metric_t.h" -#include "taos_metric_formatter_i.h" +#include "taos_test.h" taos_counter_t *taos_counter_new(const char *name, const char *help, size_t label_key_count, const char **label_keys) { return (taos_counter_t *)taos_metric_new(TAOS_COUNTER, name, help, label_key_count, label_keys); @@ -66,11 +66,9 @@ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_va return taos_metric_sample_add(sample, r_value); } -int taos_counter_get_keys_size(taos_counter_t *self) { - return self->samples->keys->size; -} +int taos_counter_get_keys_size(taos_counter_t *self) { return self->samples->keys->size; } -int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys,int32_t **vgroup_ids) { +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids) { TAOS_TEST_PARA(self != NULL); if (self == NULL) return 1; if (self->type != TAOS_COUNTER) { @@ -79,12 +77,12 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys,int32_t **vgr } if (self->samples == NULL) return 1; taos_linked_list_t *key_list = self->samples->keys; - int r = 0; - *vgroup_ids = (int32_t *)taos_malloc(key_list->size*sizeof(int32_t)); - *keys = (char **)taos_malloc(key_list->size*sizeof(char *)); + int r = 0; + *vgroup_ids = (int32_t *)taos_malloc(key_list->size * sizeof(int32_t)); + *keys = (char **)taos_malloc(key_list->size * sizeof(char *)); int index = 0; - for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL;current_key = current_key->next) { - char *key = (char *)current_key->item; + for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) { + char *key = (char *)current_key->item; int32_t vgroup_id = taos_metric_formatter_get_vgroup_id(key); (*vgroup_ids)[index] = vgroup_id; (*keys)[index] = key; @@ -100,5 +98,5 @@ int taos_counter_delete(taos_counter_t *self, char *key) { TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); return 1; } - return taos_map_delete(self->samples, key); + return taos_map_delete(self->samples, key); } \ No newline at end of file diff --git a/source/libs/monitorfw/src/taos_metric_formatter.c b/source/libs/monitorfw/src/taos_metric_formatter.c index 1d5925f565..cb1edd30b6 100644 --- a/source/libs/monitorfw/src/taos_metric_formatter.c +++ b/source/libs/monitorfw/src/taos_metric_formatter.c @@ -157,19 +157,19 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char return 0; } int32_t taos_metric_formatter_get_vgroup_id(char *key) { - char *start,*end; - char vgroupid[10]; - start = strstr(key, "vgroup_id=\""); - if (start) { - start += strlen("vgroup_id=\""); - end = strchr(start, '\"'); - if (end) { - strncpy(vgroupid, start, end - start); - vgroupid[end - start] = '\0'; - } - return strtol(vgroupid, NULL, 10); + char *start, *end; + char vgroupid[10]; + start = strstr(key, "vgroup_id=\""); + if (start) { + start += strlen("vgroup_id=\""); + end = strchr(start, '\"'); + if (end) { + strncpy(vgroupid, start, end - start); + vgroupid[end - start] = '\0'; } - return 0; + return strtol(vgroupid, NULL, 10); + } + return 0; } /* int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample, From 97bcdfb86c27c2f7e536079b8d57f64f0aa8620a Mon Sep 17 00:00:00 2001 From: xiao77 Date: Tue, 3 Sep 2024 20:09:06 +0800 Subject: [PATCH 03/26] resolve comments --- include/libs/monitorfw/taos_counter.h | 2 +- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 20 ++++++++++++++------ source/dnode/mgmt/node_mgmt/inc/dmNodes.h | 2 +- source/dnode/mgmt/node_mgmt/src/dmMonitor.c | 13 +++++++------ source/libs/monitorfw/src/taos_counter.c | 11 +++++++---- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/include/libs/monitorfw/taos_counter.h b/include/libs/monitorfw/taos_counter.h index 816d8ea7b9..910f6e1aed 100644 --- a/include/libs/monitorfw/taos_counter.h +++ b/include/libs/monitorfw/taos_counter.h @@ -99,7 +99,7 @@ int taos_counter_inc(taos_counter_t *self, const char **label_values); */ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values); -int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids); +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids, int *list_size); int taos_counter_get_keys_size(taos_counter_t *self); int taos_counter_delete(taos_counter_t *self, char *key); #endif // TAOS_COUNTER_H diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 8ec51b637b..cf0f38243e 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -120,25 +120,33 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) { taosArrayDestroy(pVloads); } -int vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { +void vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { int list_size = taos_counter_get_keys_size(tsInsertCounter); - if (list_size == 0) return 0; + if (list_size == 0) return; int32_t *vgroup_ids; char **keys; - taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids); - int r = 0; - (void)taosThreadRwlockWrlock(&pMgmt->lock); + int r = 0; + r = taos_counter_get_vgroup_ids(tsInsertCounter, &keys, &vgroup_ids, &list_size); + if (r) { + dError("failed to get vgroup ids"); + return; + } + (void)taosThreadRwlockRdlock(&pMgmt->lock); for (int i = 0; i < list_size; i++) { int32_t vgroup_id = vgroup_ids[i]; void *vnode = taosHashGet(pMgmt->hash, &vgroup_id, sizeof(int32_t)); if (vnode == NULL) { r = taos_counter_delete(tsInsertCounter, keys[i]); + if (r) { + dError("failed to delete key:%s", keys[i]); + return; + } } } (void)taosThreadRwlockUnlock(&pMgmt->lock); taosMemoryFree(vgroup_ids); taosMemoryFree(keys); - return r; + return; } static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { diff --git a/source/dnode/mgmt/node_mgmt/inc/dmNodes.h b/source/dnode/mgmt/node_mgmt/inc/dmNodes.h index c0ef92b537..2561a13b92 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmNodes.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmNodes.h @@ -39,7 +39,7 @@ void vmGetVnodeLoadsLite(void *pMgmt, SMonVloadInfo *pInfo); void mmGetMnodeLoads(void *pMgmt, SMonMloadInfo *pInfo); void qmGetQnodeLoads(void *pMgmt, SQnodeLoad *pInfo); -int vmCleanExpriedSamples(void *pMgmt); +void vmCleanExpriedSamples(void *pMgmt); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index 61cdd5a272..68a851569c 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -14,9 +14,9 @@ */ #define _DEFAULT_SOURCE -#include "audit.h" #include "dmMgmt.h" #include "dmNodes.h" +#include "audit.h" static void dmGetMonitorBasicInfo(SDnode *pDnode, SMonBasicInfo *pInfo) { pInfo->protocol = 1; @@ -52,14 +52,15 @@ static void dmGetDmMonitorInfo(SDnode *pDnode) { monSetDmInfo(&dmInfo); } -int dmCleanExpriedSamples(SDnode *pDnode) { +void dmCleanExpriedSamples(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[VNODE]; if (dmMarkWrapper(pWrapper) == 0) { if (pWrapper->pMgmt != NULL) { - return vmCleanExpriedSamples(pWrapper->pMgmt); + vmCleanExpriedSamples(pWrapper->pMgmt); } } - return 0; + dmReleaseWrapper(pWrapper); + return; } static void dmGetDmMonitorInfoBasic(SDnode *pDnode) { @@ -134,8 +135,8 @@ void dmSendMonitorReport() { } void dmMonitorCleanExpiredSamples() { - if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; - dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort); + if (!tsEnableMonitor) return; + dTrace("clean monitor expired samples"); SDnode *pDnode = dmInstance(); (void)dmCleanExpriedSamples(pDnode); diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index 84e29b5f93..829a05aa4e 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -68,7 +68,7 @@ int taos_counter_add(taos_counter_t *self, double r_value, const char **label_va int taos_counter_get_keys_size(taos_counter_t *self) { return self->samples->keys->size; } -int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids) { +int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vgroup_ids, int *list_size) { TAOS_TEST_PARA(self != NULL); if (self == NULL) return 1; if (self->type != TAOS_COUNTER) { @@ -77,9 +77,12 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg } if (self->samples == NULL) return 1; taos_linked_list_t *key_list = self->samples->keys; - int r = 0; - *vgroup_ids = (int32_t *)taos_malloc(key_list->size * sizeof(int32_t)); - *keys = (char **)taos_malloc(key_list->size * sizeof(char *)); + *list_size = key_list->size; + int r = 0; + *vgroup_ids = (int32_t *)taos_malloc(*list_size * sizeof(int32_t)); + if (vgroup_ids == NULL) return 1; + *keys = (char **)taos_malloc(*list_size * sizeof(char *)); + if (keys == NULL) return 1; int index = 0; for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) { char *key = (char *)current_key->item; From 6497290926f7e9ca8d9668be46a212abb81ca415 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Tue, 3 Sep 2024 20:22:26 +0800 Subject: [PATCH 04/26] add rd lock while range keys --- source/libs/monitorfw/src/taos_counter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index 829a05aa4e..be5e1f781f 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -84,6 +84,7 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg *keys = (char **)taos_malloc(*list_size * sizeof(char *)); if (keys == NULL) return 1; int index = 0; + pthread_rwlock_rdlock(self->rwlock); for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) { char *key = (char *)current_key->item; int32_t vgroup_id = taos_metric_formatter_get_vgroup_id(key); @@ -91,6 +92,7 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg (*keys)[index] = key; index++; } + pthread_rwlock_unlock(self->rwlock); return r; } From 2eb1f9522491bdf4b5d6cd54bc4046802a10d482 Mon Sep 17 00:00:00 2001 From: Jing Sima Date: Wed, 4 Sep 2024 11:33:13 +0800 Subject: [PATCH 05/26] fix:[TS-5349] fix wrong dbFName setted in mndPerfsInitMeta. --- source/dnode/mnode/impl/src/mndPerfSchema.c | 2 +- source/libs/qcom/src/querymsg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index 8ff9f8f27e..da5e201c05 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -42,7 +42,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) { int32_t code = 0; STableMetaRsp meta = {0}; - tstrncpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB, sizeof(meta.dbFName)); + tstrncpy(meta.dbFName, TSDB_PERFORMANCE_SCHEMA_DB, sizeof(meta.dbFName)); meta.tableType = TSDB_SYSTEM_TABLE; meta.sversion = 1; meta.tversion = 1; diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 207bd91bd9..b5b660a51b 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -574,7 +574,7 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) { goto PROCESS_META_OVER; } - if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) && + if (!IS_SYS_DBNAME(metaRsp.dbFName) && !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) { code = TSDB_CODE_TSC_INVALID_VALUE; goto PROCESS_META_OVER; From 8a8ba407ba4cf53866103467891b2cfb0a46a2b0 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 11:01:38 +0800 Subject: [PATCH 06/26] fix ci --- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 3 +-- source/dnode/mgmt/node_mgmt/src/dmMonitor.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index cf0f38243e..35b25cb85a 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -138,8 +138,7 @@ void vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { if (vnode == NULL) { r = taos_counter_delete(tsInsertCounter, keys[i]); if (r) { - dError("failed to delete key:%s", keys[i]); - return; + dError("failed to delete monitor sample key:%s", keys[i]); } } } diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index 68a851569c..ce0b2b59e0 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -135,7 +135,7 @@ void dmSendMonitorReport() { } void dmMonitorCleanExpiredSamples() { - if (!tsEnableMonitor) return; + if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; dTrace("clean monitor expired samples"); SDnode *pDnode = dmInstance(); From e4f8485697731bd514217f38bb04781e8a7865df Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 11:12:50 +0800 Subject: [PATCH 07/26] fix thread mutex unlock and mem free --- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 4 ++-- source/libs/monitorfw/src/taos_counter.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 35b25cb85a..2abf292e73 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -143,8 +143,8 @@ void vmCleanExpriedSamples(SVnodeMgmt *pMgmt) { } } (void)taosThreadRwlockUnlock(&pMgmt->lock); - taosMemoryFree(vgroup_ids); - taosMemoryFree(keys); + if (vgroup_ids) taosMemoryFree(vgroup_ids); + if (keys) taosMemoryFree(keys); return; } diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index be5e1f781f..e60e5a5f3f 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -76,15 +76,21 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg return 1; } if (self->samples == NULL) return 1; + pthread_rwlock_rdlock(self->rwlock); taos_linked_list_t *key_list = self->samples->keys; *list_size = key_list->size; int r = 0; *vgroup_ids = (int32_t *)taos_malloc(*list_size * sizeof(int32_t)); - if (vgroup_ids == NULL) return 1; + if (vgroup_ids == NULL) { + pthread_rwlock_unlock(self->rwlock); + return 1; + } *keys = (char **)taos_malloc(*list_size * sizeof(char *)); - if (keys == NULL) return 1; + if (keys == NULL) { + pthread_rwlock_unlock(self->rwlock); + return 1; + } int index = 0; - pthread_rwlock_rdlock(self->rwlock); for (taos_linked_list_node_t *current_key = key_list->head; current_key != NULL; current_key = current_key->next) { char *key = (char *)current_key->item; int32_t vgroup_id = taos_metric_formatter_get_vgroup_id(key); From 3c4de6f1e6c4d8f125070f5b949abd655a2f3b92 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 12:23:28 +0800 Subject: [PATCH 08/26] feat: add query table not exist as empty --- include/common/tglobal.h | 1 + source/client/inc/clientInt.h | 10 +++++----- source/client/src/clientImpl.c | 4 ++++ source/common/src/tglobal.c | 6 ++++++ source/libs/parser/src/parTranslater.c | 3 ++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 7ecdd2a1b7..2d4d437649 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -158,6 +158,7 @@ extern int32_t tsCacheLazyLoadThreshold; // cost threshold for last/last_row lo // query client extern int32_t tsQueryPolicy; +extern bool tsQueryTbNotExistAsEmpty; extern int32_t tsQueryRspPolicy; extern int64_t tsQueryMaxConcurrentTables; extern int32_t tsQuerySmaOptimize; diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 30424adecd..0df1a7428d 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -52,11 +52,11 @@ enum { #define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE) #define SHOW_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE) -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) -#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) -#define TD_RES_TMQ_METADATA(res) (*(int8_t*)res == RES_TYPE__TMQ_METADATA) -#define TD_RES_TMQ_BATCH_META(res) (*(int8_t*)res == RES_TYPE__TMQ_BATCH_META) +#define TD_RES_QUERY(res) (*(int8_t*)(res) == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)(res) == RES_TYPE__TMQ) +#define TD_RES_TMQ_META(res) (*(int8_t*)(res) == RES_TYPE__TMQ_META) +#define TD_RES_TMQ_METADATA(res) (*(int8_t*)(res) == RES_TYPE__TMQ_METADATA) +#define TD_RES_TMQ_BATCH_META(res) (*(int8_t*)(res) == RES_TYPE__TMQ_BATCH_META) typedef struct SAppInstInfo SAppInstInfo; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 78ff40bb4f..332191a938 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -2953,6 +2953,10 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param void doRequestCallback(SRequestObj* pRequest, int32_t code) { pRequest->inCallback = true; int64_t this = pRequest->self; + if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { + code = TSDB_CODE_SUCCESS; + pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; + } pRequest->body.queryFp(((SSyncQueryParam*)pRequest->body.interParam)->userParam, pRequest, code); SRequestObj* pReq = acquireRequest(this); if (pReq != NULL) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 100a24f44d..367eb68865 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -162,6 +162,7 @@ int32_t tmqMaxTopicNum = 20; int32_t tmqRowSize = 4096; // query int32_t tsQueryPolicy = 1; +bool tsQueryTbNotExistAsEmpty = false; int32_t tsQueryRspPolicy = 0; int64_t tsQueryMaxConcurrentTables = 200; // unit is TSDB_TABLE_NUM_UNIT bool tsEnableQueryHb = true; @@ -569,6 +570,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { TAOS_CHECK_RETURN( cfgAddInt32(pCfg, "compressMsgSize", tsCompressMsgSize, -1, 100000000, CFG_SCOPE_BOTH, CFG_DYN_CLIENT)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "queryPolicy", tsQueryPolicy, 1, 4, CFG_SCOPE_CLIENT, CFG_DYN_ENT_CLIENT)); + TAOS_CHECK_RETURN(cfgAddBool(pCfg, "queryTableNotExistAsEmpty", tsQueryTbNotExistAsEmpty, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT)); TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableQueryHb", tsEnableQueryHb, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT)); TAOS_CHECK_RETURN(cfgAddBool(pCfg, "enableScience", tsEnableScience, CFG_SCOPE_CLIENT, CFG_DYN_NONE)); TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "querySmaOptimize", tsQuerySmaOptimize, 0, 1, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT)); @@ -1181,6 +1183,9 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryPolicy"); tsQueryPolicy = pItem->i32; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "queryTableNotExistAsEmpty"); + tsQueryTbNotExistAsEmpty = pItem->bval; + TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "enableQueryHb"); tsEnableQueryHb = pItem->bval; @@ -2218,6 +2223,7 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, const char *name) { {"numOfLogLines", &tsNumOfLogLines}, {"querySmaOptimize", &tsQuerySmaOptimize}, {"queryPolicy", &tsQueryPolicy}, + {"queryTableNotExistAsEmpty", &tsQueryTbNotExistAsEmpty}, {"queryPlannerTrace", &tsQueryPlannerTrace}, {"queryNodeChunkSize", &tsQueryNodeChunkSize}, {"queryUseNodeAllocator", &tsQueryUseNodeAllocator}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 6c86a6c12f..111b41dc50 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4681,7 +4681,8 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta), true); if (TSDB_CODE_SUCCESS != code) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + return code; } #ifdef TD_ENTERPRISE if (TSDB_VIEW_TABLE == pRealTable->pMeta->tableType && (!pCurrSmt->tagScan || pCxt->pParseCxt->biMode)) { From 771912e58c4c5bffacd4317bd4a03f70a86c7393 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 12:44:50 +0800 Subject: [PATCH 09/26] opt parameter --- include/util/tdef.h | 2 +- source/libs/transport/src/transSvr.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/util/tdef.h b/include/util/tdef.h index a750074953..46a0d01457 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -499,7 +499,7 @@ typedef enum ELogicConditionType { #ifdef WINDOWS #define TSDB_MAX_RPC_THREADS 4 // windows pipe only support 4 connections. #else -#define TSDB_MAX_RPC_THREADS 10 +#define TSDB_MAX_RPC_THREADS 50 #endif #define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 53a7dee7be..e25851fa23 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -373,6 +373,7 @@ static bool uvHandleReq(SSvrConn* pConn) { STrans* pTransInst = pConn->pTransInst; SWorkThrd* pThrd = pConn->hostThrd; + int8_t acquire = 0; STransMsgHead* pHead = NULL; int8_t resetBuf = pConn->status == ConnAcquire ? 0 : 1; @@ -459,7 +460,13 @@ static bool uvHandleReq(SSvrConn* pConn) { // 2. once send out data, cli conn released to conn pool immediately // 3. not mixed with persist transMsg.info.ahandle = (void*)pHead->ahandle; - transMsg.info.handle = (void*)transAcquireExHandle(transGetRefMgt(), pConn->refId); + + if (pHead->noResp == 1) { + transMsg.info.handle = NULL; + } else { + transMsg.info.handle = (void*)transAcquireExHandle(transGetRefMgt(), pConn->refId); + acquire = 1; + } transMsg.info.refId = pConn->refId; transMsg.info.traceId = pHead->traceId; transMsg.info.cliVer = htonl(pHead->compatibilityVer); @@ -483,7 +490,7 @@ static bool uvHandleReq(SSvrConn* pConn) { pConnInfo->clientPort = pConn->port; tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user)); - (void)transReleaseExHandle(transGetRefMgt(), pConn->refId); + if (acquire) transReleaseExHandle(transGetRefMgt(), pConn->refId); (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); return true; From 96f46edffccc8edf04e0d92401ac05dbb3d47324 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 12:52:19 +0800 Subject: [PATCH 10/26] opt parameter --- source/libs/transport/src/transSvr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index e25851fa23..ad3e132de4 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -475,10 +475,10 @@ static bool uvHandleReq(SSvrConn* pConn) { tGTrace("%s handle %p conn:%p translated to app, refId:%" PRIu64, transLabel(pTransInst), transMsg.info.handle, pConn, pConn->refId); - if (transMsg.info.handle == NULL) { - tError("%s handle %p conn:%p handle failed to init" PRIu64, transLabel(pTransInst), transMsg.info.handle, pConn); - return false; - } + // if (transMsg.info.handle == NULL) { + // tError("%s handle %p conn:%p handle failed to init" PRIu64, transLabel(pTransInst), transMsg.info.handle, pConn); + // return false; + // } if (pHead->noResp == 1) { transMsg.info.refId = -1; From 59946626d9a1c26ea3b73278d53ce9f87fa9f553 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 13:25:41 +0800 Subject: [PATCH 11/26] opt parameter --- source/libs/transport/src/transComm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 1758ca65cc..1329489be6 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -20,6 +20,7 @@ static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; static int32_t refMgt; +static int32_t svrRefMgt; static int32_t instMgt; static int32_t transSyncMsgMgt; @@ -704,12 +705,14 @@ bool transEpSetIsEqual2(SEpSet* a, SEpSet* b) { static void transInitEnv() { refMgt = transOpenRefMgt(50000, transDestroyExHandle); + svrRefMgt = transOpenRefMgt(50000, transDestroyExHandle); instMgt = taosOpenRef(50, rpcCloseImpl); transSyncMsgMgt = taosOpenRef(50, transDestroySyncMsg); (void)uv_os_setenv("UV_TCP_SINGLE_ACCEPT", "1"); } static void transDestroyEnv() { transCloseRefMgt(refMgt); + transCloseRefMgt(svrRefMgt); transCloseRefMgt(instMgt); transCloseRefMgt(transSyncMsgMgt); } @@ -724,6 +727,7 @@ int32_t transInit() { } int32_t transGetRefMgt() { return refMgt; } +int32_t transGetSvrRefMgt() { return svrRefMgt; } int32_t transGetInstMgt() { return instMgt; } int32_t transGetSyncMsgMgt() { return transSyncMsgMgt; } From ccea816fb9e4cd68c785697d082ffc7f54e387de Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 13:25:56 +0800 Subject: [PATCH 12/26] opt transport --- source/libs/transport/inc/transComm.h | 1 + source/libs/transport/src/transSvr.c | 50 +++++++++++++-------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 84f0ffc8cb..8664305208 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -443,6 +443,7 @@ int32_t transReleaseExHandle(int32_t refMgt, int64_t refId); void transDestroyExHandle(void* handle); int32_t transGetRefMgt(); +int32_t transGetSvrRefMgt(); int32_t transGetInstMgt(); int32_t transGetSyncMsgMgt(); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index ad3e132de4..11aa468b19 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -464,7 +464,7 @@ static bool uvHandleReq(SSvrConn* pConn) { if (pHead->noResp == 1) { transMsg.info.handle = NULL; } else { - transMsg.info.handle = (void*)transAcquireExHandle(transGetRefMgt(), pConn->refId); + transMsg.info.handle = (void*)transAcquireExHandle(transGetSvrRefMgt(), pConn->refId); acquire = 1; } transMsg.info.refId = pConn->refId; @@ -490,7 +490,7 @@ static bool uvHandleReq(SSvrConn* pConn) { pConnInfo->clientPort = pConn->port; tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user)); - if (acquire) transReleaseExHandle(transGetRefMgt(), pConn->refId); + if (acquire) transReleaseExHandle(transGetSvrRefMgt(), pConn->refId); (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); return true; @@ -777,15 +777,15 @@ void uvWorkerAsyncCb(uv_async_t* handle) { SExHandle* exh1 = transMsg.info.handle; int64_t refId = transMsg.info.refId; - SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), refId); + SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), refId); if (exh2 == NULL || exh1 != exh2) { tTrace("handle except msg %p, ignore it", exh1); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); destroySmsg(msg); continue; } msg->pConn = exh1->handle; - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); (*transAsyncHandle[msg->type])(msg, pThrd); } } @@ -881,15 +881,15 @@ static void uvPrepareCb(uv_prepare_t* handle) { SExHandle* exh1 = transMsg.info.handle; int64_t refId = transMsg.info.refId; - SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), refId); + SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), refId); if (exh2 == NULL || exh1 != exh2) { tTrace("handle except msg %p, ignore it", exh1); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); destroySmsg(msg); continue; } msg->pConn = exh1->handle; - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); (*transAsyncHandle[msg->type])(msg, pThrd); } } @@ -1222,14 +1222,14 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) { exh->handle = pConn; exh->pThrd = pThrd; - exh->refId = transAddExHandle(transGetRefMgt(), exh); + exh->refId = transAddExHandle(transGetSvrRefMgt(), exh); if (exh->refId < 0) { TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); } QUEUE_INIT(&exh->q); - SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + SExHandle* pSelf = transAcquireExHandle(transGetSvrRefMgt(), exh->refId); if (pSelf != exh) { TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); } @@ -1291,8 +1291,8 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) { } static int32_t reallocConnRef(SSvrConn* conn) { if (conn->refId > 0) { - (void)transReleaseExHandle(transGetRefMgt(), conn->refId); - (void)transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId); } // avoid app continue to send msg on invalid handle SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); @@ -1302,14 +1302,14 @@ static int32_t reallocConnRef(SSvrConn* conn) { exh->handle = conn; exh->pThrd = conn->hostThrd; - exh->refId = transAddExHandle(transGetRefMgt(), exh); + exh->refId = transAddExHandle(transGetSvrRefMgt(), exh); if (exh->refId < 0) { taosMemoryFree(exh); return TSDB_CODE_REF_INVALID_ID; } QUEUE_INIT(&exh->q); - SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + SExHandle* pSelf = transAcquireExHandle(transGetSvrRefMgt(), exh->refId); if (pSelf != exh) { tError("conn %p failed to acquire handle", conn); taosMemoryFree(exh); @@ -1328,8 +1328,8 @@ static void uvDestroyConn(uv_handle_t* handle) { } SWorkThrd* thrd = conn->hostThrd; - (void)transReleaseExHandle(transGetRefMgt(), conn->refId); - (void)transRemoveExHandle(transGetRefMgt(), conn->refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), conn->refId); + (void)transRemoveExHandle(transGetSvrRefMgt(), conn->refId); STrans* pTransInst = thrd->pTransInst; tDebug("%s conn %p destroy", transLabel(pTransInst), conn); @@ -1759,15 +1759,15 @@ int32_t transReleaseSrvHandle(void* handle) { tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; } - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to send to release handle", exh); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; _return2: tDebug("handle %p failed to send to release handle", exh); @@ -1810,17 +1810,17 @@ int32_t transSendResponse(const STransMsg* msg) { tGDebug("conn %p start to send resp (1/2)", exh->handle); if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; } - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; _return2: tDebug("handle %p failed to send resp", exh); @@ -1855,17 +1855,17 @@ int32_t transRegisterMsg(const STransMsg* msg) { tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle); if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; } - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return 0; _return1: tDebug("handle %p failed to register brokenlink", exh); rpcFreeCont(msg->pCont); - (void)transReleaseExHandle(transGetRefMgt(), refId); + (void)transReleaseExHandle(transGetSvrRefMgt(), refId); return code; _return2: tDebug("handle %p failed to register brokenlink", exh); From ab2477510b479f892ff68611de7e14ff03fc37fa Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 13:38:51 +0800 Subject: [PATCH 13/26] thread lock result --- source/libs/monitorfw/src/taos_counter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/monitorfw/src/taos_counter.c b/source/libs/monitorfw/src/taos_counter.c index e60e5a5f3f..096d19c190 100644 --- a/source/libs/monitorfw/src/taos_counter.c +++ b/source/libs/monitorfw/src/taos_counter.c @@ -76,18 +76,18 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg return 1; } if (self->samples == NULL) return 1; - pthread_rwlock_rdlock(self->rwlock); + (void)pthread_rwlock_rdlock(self->rwlock); taos_linked_list_t *key_list = self->samples->keys; *list_size = key_list->size; int r = 0; *vgroup_ids = (int32_t *)taos_malloc(*list_size * sizeof(int32_t)); if (vgroup_ids == NULL) { - pthread_rwlock_unlock(self->rwlock); + (void)pthread_rwlock_unlock(self->rwlock); return 1; } *keys = (char **)taos_malloc(*list_size * sizeof(char *)); if (keys == NULL) { - pthread_rwlock_unlock(self->rwlock); + (void)pthread_rwlock_unlock(self->rwlock); return 1; } int index = 0; @@ -98,7 +98,7 @@ int taos_counter_get_vgroup_ids(taos_counter_t *self, char ***keys, int32_t **vg (*keys)[index] = key; index++; } - pthread_rwlock_unlock(self->rwlock); + (void)pthread_rwlock_unlock(self->rwlock); return r; } From 667da97c3a10f964a04148185a0a53578a5e6239 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 13:48:17 +0800 Subject: [PATCH 14/26] opt transport --- source/libs/transport/inc/transComm.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 8664305208..4bf9acfac4 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -272,19 +272,19 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); } \ } while (0) -#define ASYNC_CHECK_HANDLE(exh1, id) \ - do { \ - if (id > 0) { \ - SExHandle* exh2 = transAcquireExHandle(transGetRefMgt(), id); \ - if (exh2 == NULL || id != exh2->refId) { \ - tDebug("ref:%" PRId64 " already released" PRIu64, id); \ - code = terrno; \ - goto _return1; \ - } \ - } else { \ - tWarn("invalid handle to release"); \ - goto _return2; \ - } \ +#define ASYNC_CHECK_HANDLE(exh1, id) \ + do { \ + if (id > 0) { \ + SExHandle* exh2 = transAcquireExHandle(transGetSvrRefMgt(), id); \ + if (exh2 == NULL || id != exh2->refId) { \ + tDebug("ref:%" PRId64 " already released", id); \ + code = terrno; \ + goto _return1; \ + } \ + } else { \ + tWarn("invalid handle to release"); \ + goto _return2; \ + } \ } while (0) int32_t transInitBuffer(SConnBuffer* buf); From 27d22b79b907775524c90307aad9efe3a893ba36 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 13:52:08 +0800 Subject: [PATCH 15/26] opt transport --- source/libs/transport/inc/transComm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 4bf9acfac4..95ea6944e3 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -282,7 +282,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); goto _return1; \ } \ } else { \ - tWarn("invalid handle to release"); \ + tDebug("invalid handle to release"); \ goto _return2; \ } \ } while (0) From 93e6e278ab4e67d4f1fc889e1930448dd824ad25 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 13:54:45 +0800 Subject: [PATCH 16/26] fix: add return code --- source/libs/parser/src/parTranslater.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 111b41dc50..e864a2b1eb 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4681,7 +4681,7 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta), true); if (TSDB_CODE_SUCCESS != code) { - generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); + (void)generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GET_META_ERROR, tstrerror(code)); return code; } #ifdef TD_ENTERPRISE From 9e3b093d001d6150b2bb136320ac7d0007a89407 Mon Sep 17 00:00:00 2001 From: Jing Sima Date: Thu, 5 Sep 2024 14:01:18 +0800 Subject: [PATCH 17/26] fix:[TD-31921] Free memory when error occurs in filterExecute. --- source/libs/scalar/src/filter.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 382b83012d..696222784e 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -5238,22 +5238,20 @@ int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; return TSDB_CODE_SUCCESS; } - + int32_t code = TSDB_CODE_SUCCESS; SScalarParam output = {0}; SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; - int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + FLT_ERR_JRET(sclCreateColumnInfoData(&type, pSrc->info.rows, &output)); if (info->scalarMode) { SArray *pList = taosArrayInit(1, POINTER_BYTES); if (NULL == pList) { - FLT_ERR_RET(terrno); + FLT_ERR_JRET(terrno); } if (NULL == taosArrayPush(pList, &pSrc)) { - FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + taosArrayDestroy(pList); + FLT_ERR_JRET(terrno); } code = scalarCalculate(info->sclCtx.node, pList, &output); @@ -5261,7 +5259,7 @@ int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, *p = output.columnData; - FLT_ERR_RET(code); + FLT_ERR_JRET(code); if (output.numOfQualified == output.numOfRows) { *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; @@ -5277,11 +5275,12 @@ int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, output.numOfRows = pSrc->info.rows; if (*p == NULL) { - return TSDB_CODE_APP_ERROR; + fltError("filterExecute failed, column data is NULL"); + FLT_ERR_JRET(TSDB_CODE_APP_ERROR); } bool keepAll = false; - FLT_ERR_RET((info->func)(info, pSrc->info.rows, *p, statis, numOfCols, &output.numOfQualified, &keepAll)); + FLT_ERR_JRET((info->func)(info, pSrc->info.rows, *p, statis, numOfCols, &output.numOfQualified, &keepAll)); // todo this should be return during filter procedure if (keepAll) { @@ -5304,6 +5303,10 @@ int32_t filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, } return TSDB_CODE_SUCCESS; +_return: + sclFreeParam(&output); + *p = NULL; + return code; } typedef struct SClassifyConditionCxt { From b75adfcd9fc6ff046265b50c6059485c1ba2b581 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 14:18:13 +0800 Subject: [PATCH 18/26] fix: only query issue --- include/libs/parser/parser.h | 3 +++ source/client/inc/clientInt.h | 1 + source/client/src/clientImpl.c | 14 ++++++++++++-- source/libs/parser/src/parTranslater.c | 8 ++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index cefce8a9c0..a808fccc4a 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -65,6 +65,8 @@ typedef struct SParseCsvCxt { const char* pLastSqlPos; // the location of the last parsed sql } SParseCsvCxt; +typedef void(*setQueryFn)(int64_t); + typedef struct SParseContext { uint64_t requestId; int64_t requestRid; @@ -98,6 +100,7 @@ typedef struct SParseContext { void* parseSqlParam; int8_t biMode; SArray* pSubMetaList; + setQueryFn setQueryFp; } SParseContext; int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0df1a7428d..cf62ad73b4 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -284,6 +284,7 @@ typedef struct SRequestObj { bool isSubReq; bool inCallback; bool isStmtBind; // is statement bind parameter + bool isQuery; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t retry; int64_t allocatorRefId; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 332191a938..e2f6eb5ff4 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -31,6 +31,15 @@ static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet); static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInfo); +void setQueryRequest(int64_t rId) { + SRequestObj* pReq = acquireRequest(rId); + if (pReq != NULL) { + pReq->isQuery = true; + (void)releaseRequest(rId); + } + +} + static bool stringLengthCheck(const char* str, size_t maxsize) { if (str == NULL) { return false; @@ -286,7 +295,8 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC .enableSysInfo = pTscObj->sysInfo, .svrVer = pTscObj->sVer, .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes), - .isStmtBind = pRequest->isStmtBind}; + .isStmtBind = pRequest->isStmtBind, + .setQueryFp = setQueryRequest}; cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog); @@ -2953,7 +2963,7 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param void doRequestCallback(SRequestObj* pRequest, int32_t code) { pRequest->inCallback = true; int64_t this = pRequest->self; - if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { + if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { code = TSDB_CODE_SUCCESS; pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index e864a2b1eb..62943cb6d5 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6784,6 +6784,10 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect } static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) { + (*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid); + } + if (NULL == pSelect->pFromTable) { return translateSelectWithoutFrom(pCxt, pSelect); } else { @@ -6908,6 +6912,10 @@ static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) { } static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) { + if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) { + (*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid); + } + int32_t code = translateQuery(pCxt, pSetOperator->pLeft); if (TSDB_CODE_SUCCESS == code) { code = resetHighLevelTranslateNamespace(pCxt); From 2e3e5d0a9913580a16f070396da2b896b6fdf52b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 14:40:14 +0800 Subject: [PATCH 19/26] fix mem leak --- source/client/src/clientImpl.c | 8 ++--- source/client/src/clientMain.c | 28 ++++++++-------- source/client/src/clientMonitor.c | 39 +++++++++++----------- source/client/src/clientTmq.c | 28 +++++++--------- source/libs/executor/src/dataInserter.c | 27 +++++++-------- source/libs/executor/src/sysscanoperator.c | 9 +++-- 6 files changed, 68 insertions(+), 71 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 78ff40bb4f..ca0e3cb998 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -339,8 +339,8 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { STscObj* pTscObj = pRequest->pTscObj; SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest); - int64_t transporterId = 0; - TSC_ERR_RET(asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg)); + // int64_t transporterId = 0; + TSC_ERR_RET(asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &pMsgInfo->epSet, NULL, pSendMsg)); (void)tsem_wait(&pRequest->body.rspSem); return TSDB_CODE_SUCCESS; } @@ -396,8 +396,8 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { SAppInstInfo* pAppInfo = getAppInfo(pRequest); SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest); - int64_t transporterId = 0; - int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg); + // int64_t transporterId = 0; + int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, NULL, pSendMsg); if (code) { doRequestCallback(pRequest, code); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 4a78ce957d..f4fb945f39 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -296,9 +296,9 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa pSendInfo->fp = fetchWhiteListCallbackFn; pSendInfo->msgType = TDMT_MND_GET_USER_WHITELIST; - int64_t transportId = 0; - SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp); - if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo)) { + // int64_t transportId = 0; + SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp); + if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, NULL, pSendInfo)) { tscWarn("failed to async send msg to server"); } releaseTscObj(connId); @@ -860,9 +860,9 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) { return pResInfo->pCol[columnIndex].offset; } -int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows){ - if (res == NULL || result == NULL || rows == NULL || *rows <= 0 || - columnIndex < 0 || TD_RES_TMQ_META(res) || TD_RES_TMQ_BATCH_META(res)) { +int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *rows) { + if (res == NULL || result == NULL || rows == NULL || *rows <= 0 || columnIndex < 0 || TD_RES_TMQ_META(res) || + TD_RES_TMQ_BATCH_META(res)) { return TSDB_CODE_INVALID_PARA; } @@ -875,22 +875,22 @@ int taos_is_null_by_column(TAOS_RES *res, int columnIndex, bool result[], int *r TAOS_FIELD *pField = &pResInfo->userFields[columnIndex]; SResultColumn *pCol = &pResInfo->pCol[columnIndex]; - if (*rows > pResInfo->numOfRows){ + if (*rows > pResInfo->numOfRows) { *rows = pResInfo->numOfRows; } if (IS_VAR_DATA_TYPE(pField->type)) { - for(int i = 0; i < *rows; i++){ - if(pCol->offset[i] == -1){ + for (int i = 0; i < *rows; i++) { + if (pCol->offset[i] == -1) { result[i] = true; - }else{ + } else { result[i] = false; } } - }else{ - for(int i = 0; i < *rows; i++){ - if (colDataIsNull_f(pCol->nullbitmap, i)){ + } else { + for (int i = 0; i < *rows; i++) { + if (colDataIsNull_f(pCol->nullbitmap, i)) { result[i] = true; - }else{ + } else { result[i] = false; } } diff --git a/source/client/src/clientMonitor.c b/source/client/src/clientMonitor.c index 612f57ecdd..9ed6512352 100644 --- a/source/client/src/clientMonitor.c +++ b/source/client/src/clientMonitor.c @@ -113,15 +113,15 @@ static int32_t monitorReportAsyncCB(void* param, SDataBuf* pMsg, int32_t code) { tscError("failed to send slow log:%s, clusterId:%" PRIx64, p->data, p->clusterId); } MonitorSlowLogData tmp = {.clusterId = p->clusterId, - .type = p->type, - .fileName = p->fileName, - .pFile = p->pFile, - .offset = p->offset, - .data = NULL}; + .type = p->type, + .fileName = p->fileName, + .pFile = p->pFile, + .offset = p->offset, + .data = NULL}; if (monitorPutData2MonitorQueue(tmp) == 0) { p->fileName = NULL; } else { - if(taosCloseFile(&(p->pFile)) != 0) { + if (taosCloseFile(&(p->pFile)) != 0) { tscError("failed to close file:%p", p->pFile); } } @@ -165,8 +165,8 @@ static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITO pInfo->requestId = tGenIdPI64(); pInfo->requestObjRefId = 0; - int64_t transporterId = 0; - return asyncSendMsgToServer(pTransporter, epSet, &transporterId, pInfo); + // int64_t transporterId = 0; + return asyncSendMsgToServer(pTransporter, epSet, NULL, pInfo); FAILED: if (taosCloseFile(&(((MonitorSlowLogData*)param)->pFile)) != 0) { @@ -286,7 +286,7 @@ void monitorCreateClient(int64_t clusterId) { return; - fail: +fail: destroyMonitorClient(&pMonitor); taosWUnLockLatch(&monitorLock); } @@ -302,7 +302,7 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* taos_counter_t* newCounter = taos_counter_new(name, help, label_key_count, label_keys); if (newCounter == NULL) return; MonitorClient* pMonitor = *ppMonitor; - if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0){ + if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0) { tscError("failed to add metric to collector"); (void)taos_counter_destroy(newCounter); goto end; @@ -315,7 +315,7 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name, newCounter); - end: +end: taosWUnLockLatch(&monitorLock); } @@ -338,13 +338,13 @@ void monitorCounterInc(int64_t clusterId, const char* counterName, const char** tscError("monitorCounterInc not found pCounter %" PRIx64 ":%s.", clusterId, counterName); goto end; } - if (taos_counter_inc(*ppCounter, label_values) != 0){ + if (taos_counter_inc(*ppCounter, label_values) != 0) { tscError("monitorCounterInc failed to inc %" PRIx64 ":%s.", clusterId, counterName); goto end; } tscDebug("[monitor] monitorCounterInc %" PRIx64 "(%p):%s", pMonitor->clusterId, pMonitor, counterName); - end: +end: taosWUnLockLatch(&monitorLock); } @@ -413,7 +413,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) { return NULL; } - if((size <= *offset)){ + if ((size <= *offset)) { tscError("invalid size:%" PRId64 ", offset:%" PRId64, size, *offset); terrno = TSDB_CODE_TSC_INTERNAL_ERROR; return NULL; @@ -510,13 +510,13 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs } SEpSet ep = getEpSet_s(&pInst->mgmtEp); char* data = readFile(pFile, offset, size); - if(data == NULL) return terrno; + if (data == NULL) return terrno; return sendSlowLog(clusterId, data, (type == SLOW_LOG_READ_BEGINNIG ? pFile : NULL), *offset, type, fileName, pInst->pTransporter, &ep); } static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, TdFilePtr pFile, int64_t offset) { - if (fileName == NULL){ + if (fileName == NULL) { return; } int64_t size = getFileSize(*fileName); @@ -525,10 +525,11 @@ static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, Td tscDebug("[monitor] monitorSendSlowLogAtBeginning delete file:%s", *fileName); } else { int32_t code = monitorReadSend(clusterId, pFile, &offset, size, SLOW_LOG_READ_BEGINNIG, *fileName); - if (code == 0){ + if (code == 0) { tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log succ, clusterId:%" PRId64, clusterId); - }else{ - tscError("[monitor] monitorSendSlowLogAtBeginning send slow log failed, clusterId:%" PRId64 ",ret:%d", clusterId, code); + } else { + tscError("[monitor] monitorSendSlowLogAtBeginning send slow log failed, clusterId:%" PRId64 ",ret:%d", clusterId, + code); } *fileName = NULL; } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 3927172b61..783815d97f 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -552,9 +552,9 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse pMsgSendInfo->fp = tmqCommitCb; pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET; - int64_t transporterId = 0; + // int64_t transporterId = 0; (void)atomic_add_fetch_32(&pParamSet->waitingRspNum, 1); - code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, &transporterId, pMsgSendInfo); + code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, NULL, pMsgSendInfo); if (code != 0) { (void)atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); return code; @@ -955,8 +955,7 @@ void tmqSendHbReq(void* param, void* tmrId) { SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); - int64_t transporterId = 0; - int32_t code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); + int32_t code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo); if (code != 0) { tscError("tmqSendHbReq asyncSendMsgToServer failed"); } @@ -1436,8 +1435,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); - int64_t transporterId = 0; - code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); + code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo); if (code != 0) { goto FAIL; } @@ -2044,10 +2042,10 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p sendInfo->fp = tmqPollCb; sendInfo->msgType = TDMT_VND_TMQ_CONSUME; - int64_t transporterId = 0; - char offsetFormatBuf[TSDB_OFFSET_LEN] = {0}; + // int64_t transporterId = 0; + char offsetFormatBuf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.endOffset); - code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); + code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, NULL, sendInfo); tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s,QID:0x%" PRIx64, pTmq->consumerId, pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId); if (code != 0) { @@ -3221,8 +3219,7 @@ int64_t getCommittedFromServer(tmq_t* tmq, char* tname, int32_t vgId, SEpSet* ep sendInfo->fp = tmCommittedCb; sendInfo->msgType = TDMT_VND_TMQ_VG_COMMITTEDINFO; - int64_t transporterId = 0; - code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, &transporterId, sendInfo); + code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, NULL, sendInfo); if (code != 0) { (void)tsem2_destroy(&pParam->sem); taosMemoryFree(pParam); @@ -3498,13 +3495,13 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a sendInfo->fp = tmqGetWalInfoCb; sendInfo->msgType = TDMT_VND_TMQ_VG_WALINFO; - int64_t transporterId = 0; - char offsetFormatBuf[TSDB_OFFSET_LEN] = {0}; + // int64_t transporterId = 0; + char offsetFormatBuf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pClientVg->offsetInfo.beginOffset); tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s,QID:0x%" PRIx64, tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId); - code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pClientVg->epSet, &transporterId, sendInfo); + code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pClientVg->epSet, NULL, sendInfo); if (code != 0) { goto end; } @@ -3668,8 +3665,7 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_ sendInfo->fp = tmqSeekCb; sendInfo->msgType = TDMT_VND_TMQ_SEEK; - int64_t transporterId = 0; - code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); + code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, NULL, sendInfo); if (code != 0) { (void)tsem2_destroy(&pParam->sem); taosMemoryFree(pParam); diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index 44342b0ac9..5ed97c8db6 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -61,14 +61,14 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { if (code) { pInserter->submitRes.code = code; } - + if (code == TSDB_CODE_SUCCESS) { pInserter->submitRes.pRsp = taosMemoryCalloc(1, sizeof(SSubmitRsp2)); if (NULL == pInserter->submitRes.pRsp) { pInserter->submitRes.code = terrno; goto _return; } - + SDecoder coder = {0}; tDecoderInit(&coder, pMsg->pData, pMsg->len); code = tDecodeSSubmitRsp2(&coder, pInserter->submitRes.pRsp); @@ -108,7 +108,7 @@ _return: (void)tsem_post(&pInserter->ready); taosMemoryFree(pMsg->pData); - + return TSDB_CODE_SUCCESS; } @@ -136,8 +136,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, void* pMsg, int pMsgSendInfo->msgType = TDMT_VND_SUBMIT; pMsgSendInfo->fp = inserterCallback; - int64_t transporterId = 0; - return asyncSendMsgToServer(pTransporter, pEpset, &transporterId, pMsgSendInfo); + return asyncSendMsgToServer(pTransporter, pEpset, NULL, pMsgSendInfo); } static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int32_t* pLen) { @@ -166,7 +165,7 @@ static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int } else { taosMemoryFree(pBuf); } - + return code; } @@ -228,14 +227,15 @@ int32_t buildSubmitReqFromBlock(SDataInserterHandle* pInserter, SSubmitReq2** pp terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; goto _end; } - void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); + void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes); switch (pColInfoData->info.type) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY if (pColInfoData->info.type != pCol->type) { - qError("column:%d type:%d in block dismatch with schema col:%d type:%d", colIdx, pColInfoData->info.type, k, pCol->type); + qError("column:%d type:%d in block dismatch with schema col:%d type:%d", colIdx, pColInfoData->info.type, k, + pCol->type); terrno = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR; goto _end; } @@ -331,11 +331,11 @@ _end: tDestroySubmitReq(pReq, TSDB_MSG_FLG_ENCODE); taosMemoryFree(pReq); } - + return terrno; } *ppReq = pReq; - + return TSDB_CODE_SUCCESS; } @@ -462,7 +462,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat inserter->explain = pInserterNode->explain; int64_t suid = 0; - int32_t code = pManager->pAPI->metaFn.getTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid); + int32_t code = pManager->pAPI->metaFn.getTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, + &inserter->pSchema, &suid); if (code) { terrno = code; goto _return; @@ -484,9 +485,9 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); if (NULL == inserter->pCols) { - goto _return; + goto _return; } - + SNode* pNode = NULL; int32_t i = 0; FOREACH(pNode, pInserterNode->pCols) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 7e22e38c95..85a8b035da 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1575,8 +1575,8 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { SMetaReader mr = {0}; pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); - code = doSetUserTableMetaInfo(&pAPI->metaReaderFn, &pAPI->metaFn, pInfo->readHandle.vnode, &mr, *uid, dbname, vgId, p, - numOfRows, GET_TASKID(pTaskInfo)); + code = doSetUserTableMetaInfo(&pAPI->metaReaderFn, &pAPI->metaFn, pInfo->readHandle.vnode, &mr, *uid, dbname, vgId, + p, numOfRows, GET_TASKID(pTaskInfo)); pAPI->metaReaderFn.clearReader(&mr); QUERY_CHECK_CODE(code, lino, _end); @@ -2170,8 +2170,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca pMsgSendInfo->fp = loadSysTableCallback; pMsgSendInfo->requestId = pTaskInfo->id.queryId; - int64_t transporterId = 0; - code = asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, &transporterId, pMsgSendInfo); + code = asyncSendMsgToServer(pInfo->readHandle.pMsgCb->clientRpc, &pInfo->epSet, NULL, pMsgSendInfo); if (code != TSDB_CODE_SUCCESS) { qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); pTaskInfo->code = code; @@ -2880,7 +2879,7 @@ int32_t createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanP code = tableListGetSize(pTableListInfo, &num); QUERY_CHECK_CODE(code, lino, _error); - void* pList = tableListGetInfo(pTableListInfo, 0); + void* pList = tableListGetInfo(pTableListInfo, 0); code = readHandle->api.tsdReader.tsdReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, (void**)&pInfo->pHandle, pTaskInfo->id.str, NULL); From 9a1e02cf76cc7fe3659d04f631233fa1f7aa2a90 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 14:42:25 +0800 Subject: [PATCH 20/26] fix: set query fp not set issue --- source/client/inc/clientInt.h | 1 + source/client/src/clientMain.c | 3 ++- source/client/src/clientStmt.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index cf62ad73b4..9811003254 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -421,6 +421,7 @@ typedef struct SSqlCallbackWrapper { void* pPlanInfo; } SSqlCallbackWrapper; +void setQueryRequest(int64_t rId); SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQuery, void** res); int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList); void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta, SSqlCallbackWrapper* pWrapper); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 4a78ce957d..721f995719 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -1235,7 +1235,8 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext **pCxt, SS .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes), .allocatorId = pRequest->allocatorRefId, .parseSqlFp = clientParseSql, - .parseSqlParam = pWrapper}; + .parseSqlParam = pWrapper, + .setQueryFp = setQueryRequest}; int8_t biMode = atomic_load_8(&((STscObj *)pTscObj)->biMode); (*pCxt)->biMode = biMode; return TSDB_CODE_SUCCESS; diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 9f7aeabbe4..52b56abb91 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -1241,7 +1241,9 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { .msgLen = ERROR_MSG_BUF_DEFAULT_SIZE, .pTransporter = pStmt->taos->pAppInfo->pTransporter, .pStmtCb = NULL, - .pUser = pStmt->taos->user}; + .pUser = pStmt->taos->user, + .setQueryFp = setQueryRequest}; + ctx.mgmtEpSet = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp); STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &ctx.pCatalog)); From cb8aa061098ab35fc01408d93ce275f7efdc9a3b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 5 Sep 2024 14:43:41 +0800 Subject: [PATCH 21/26] fix mem leakak --- source/client/src/clientMain.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index f4fb945f39..940752c41e 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -296,7 +296,6 @@ void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *pa pSendInfo->fp = fetchWhiteListCallbackFn; pSendInfo->msgType = TDMT_MND_GET_USER_WHITELIST; - // int64_t transportId = 0; SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp); if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, NULL, pSendInfo)) { tscWarn("failed to async send msg to server"); From d5525293f6be68bd508d8903aef2b3d74b945562 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 14:56:41 +0800 Subject: [PATCH 22/26] fix windows make error --- include/libs/monitorfw/taos_counter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libs/monitorfw/taos_counter.h b/include/libs/monitorfw/taos_counter.h index 910f6e1aed..7797c695ab 100644 --- a/include/libs/monitorfw/taos_counter.h +++ b/include/libs/monitorfw/taos_counter.h @@ -15,8 +15,8 @@ #ifndef TAOS_COUNTER_H #define TAOS_COUNTER_H - #include +#include "os.h" #include "taos_metric.h" From ca78fd35991a120e0d691ce97b4dcd8e94e5eb7d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 5 Sep 2024 15:04:55 +0800 Subject: [PATCH 23/26] enh: more fix --- source/common/src/tmsg.c | 1602 ++++++++++++++++++++------------------ 1 file changed, 842 insertions(+), 760 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 4302d5dce8..5f8a0e99aa 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -8159,25 +8159,28 @@ _exit: int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) { SDecoder decoder = {0}; + int32_t code = 0; + int32_t lino; tDecoderInit(&decoder, (char *)buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); int32_t sz = 0; - if (tDecodeI32(&decoder, &sz) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz)); if (sz > 0) { pRsp->topicPrivileges = taosArrayInit(sz, sizeof(STopicPrivilege)); if (NULL == pRsp->topicPrivileges) return -1; for (int32_t i = 0; i < sz; ++i) { STopicPrivilege *data = taosArrayReserve(pRsp->topicPrivileges, 1); - if (tDecodeCStrTo(&decoder, data->topic) < 0) return -1; - if (tDecodeI8(&decoder, &data->noPrivilege) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, data->topic)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &data->noPrivilege)); } } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tDestroySMqHbReq(SMqHbReq *pReq) { @@ -8190,78 +8193,94 @@ void tDestroySMqHbReq(SMqHbReq *pReq) { int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { SEncoder encoder = {0}; + int32_t code = 0; + int32_t lino; + int32_t tlen; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epoch) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->consumerId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epoch)); int32_t sz = taosArrayGetSize(pReq->topics); - if (tEncodeI32(&encoder, sz) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, sz)); for (int32_t i = 0; i < sz; ++i) { TopicOffsetRows *vgs = (TopicOffsetRows *)taosArrayGet(pReq->topics, i); - if (tEncodeCStr(&encoder, vgs->topicName) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, vgs->topicName)); int32_t szVgs = taosArrayGetSize(vgs->offsetRows); - if (tEncodeI32(&encoder, szVgs) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, szVgs)); for (int32_t j = 0; j < szVgs; ++j) { OffsetRows *offRows = taosArrayGet(vgs->offsetRows, j); - if (tEncodeI32(&encoder, offRows->vgId) < 0) return -1; - if (tEncodeI64(&encoder, offRows->rows) < 0) return -1; - if (tEncodeSTqOffsetVal(&encoder, &offRows->offset) < 0) return -1; - if (tEncodeI64(&encoder, offRows->ever) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, offRows->vgId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, offRows->rows)); + TAOS_CHECK_EXIT(tEncodeSTqOffsetVal(&encoder, &offRows->offset)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, offRows->ever)); } } - if (tEncodeI8(&encoder, pReq->pollFlag) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->pollFlag)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; +_exit: + if (code) { + tlen = code; + } else { + tlen = encoder.pos; + } tEncoderClear(&encoder); - return tlen; } int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { + int32_t code = 0; + int32_t lino; SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->consumerId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epoch)); int32_t sz = 0; - if (tDecodeI32(&decoder, &sz) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sz)); if (sz > 0) { pReq->topics = taosArrayInit(sz, sizeof(TopicOffsetRows)); - if (NULL == pReq->topics) return -1; + if (NULL == pReq->topics) { + TAOS_CHECK_EXIT(terrno); + } for (int32_t i = 0; i < sz; ++i) { TopicOffsetRows *data = taosArrayReserve(pReq->topics, 1); - if (tDecodeCStrTo(&decoder, data->topicName) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, data->topicName)); int32_t szVgs = 0; - if (tDecodeI32(&decoder, &szVgs) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &szVgs)); if (szVgs > 0) { data->offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows)); - if (NULL == data->offsetRows) return -1; + if (NULL == data->offsetRows) { + TAOS_CHECK_EXIT(terrno); + } for (int32_t j = 0; j < szVgs; ++j) { OffsetRows *offRows = taosArrayReserve(data->offsetRows, 1); - if (tDecodeI32(&decoder, &offRows->vgId) < 0) return -1; - if (tDecodeI64(&decoder, &offRows->rows) < 0) return -1; - if (tDecodeSTqOffsetVal(&decoder, &offRows->offset) < 0) return -1; - if (tDecodeI64(&decoder, &offRows->ever) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &offRows->vgId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &offRows->rows)); + TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(&decoder, &offRows->offset)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &offRows->ever)); } } } } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI8(&decoder, &pReq->pollFlag) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->pollFlag)); } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) { + int32_t code = 0; + int32_t lino; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8269,40 +8288,50 @@ int32_t tSerializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) { } SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->subKey) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->consumerId)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->subKey)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->head.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->head.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSMqSeekReq(void *buf, int32_t bufLen, SMqSeekReq *pReq) { - int32_t headLen = sizeof(SMsgHead); - + int32_t code = 0; + int32_t lino; + int32_t headLen = sizeof(SMsgHead); SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->subKey) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->consumerId)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->subKey)); tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) { + int32_t code = 0; + int32_t lino; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8311,40 +8340,47 @@ int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1; - if (tEncodeI64(&encoder, pReq->refId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->execId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->msgMask) < 0) return -1; - if (tEncodeI8(&encoder, pReq->taskType) < 0) return -1; - if (tEncodeI8(&encoder, pReq->explain) < 0) return -1; - if (tEncodeI8(&encoder, pReq->needFetch) < 0) return -1; - if (tEncodeI8(&encoder, pReq->compress) < 0) return -1; - if (tEncodeU32(&encoder, pReq->sqlLen) < 0) return -1; - if (tEncodeCStrWithLen(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1; - if (tEncodeU32(&encoder, pReq->msgLen) < 0) return -1; - if (tEncodeBinary(&encoder, (uint8_t *)pReq->msg, pReq->msgLen) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->taskId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->refId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->msgMask)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->taskType)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->explain)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->needFetch)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->compress)); + TAOS_CHECK_EXIT(tEncodeU32(&encoder, pReq->sqlLen)); + TAOS_CHECK_EXIT(tEncodeCStrWithLen(&encoder, pReq->sql, pReq->sqlLen)); + TAOS_CHECK_EXIT(tEncodeU32(&encoder, pReq->msgLen)); + TAOS_CHECK_EXIT(tEncodeBinary(&encoder, (uint8_t *)pReq->msg, pReq->msgLen)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) { - int32_t headLen = sizeof(SMsgHead); - + int32_t code = 0; + int32_t lino; + int32_t headLen = sizeof(SMsgHead); SMsgHead *pHead = buf; pHead->vgId = pReq->header.vgId; pHead->contLen = pReq->header.contLen; @@ -8352,27 +8388,28 @@ int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->msgMask) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->taskType) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->explain) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->needFetch) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->compress) < 0) return -1; - if (tDecodeU32(&decoder, &pReq->sqlLen) < 0) return -1; - if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; - if (tDecodeU32(&decoder, &pReq->msgLen) < 0) return -1; - if (tDecodeBinaryAlloc(&decoder, (void **)&pReq->msg, NULL) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->taskId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->refId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->execId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->msgMask)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->taskType)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->explain)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->needFetch)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->compress)); + TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pReq->sqlLen)); + TAOS_CHECK_EXIT(tDecodeCStrAlloc(&decoder, &pReq->sql)); + TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pReq->msgLen)); + TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&pReq->msg, NULL)); tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tFreeSSubQueryMsg(SSubQueryMsg *pReq) { @@ -8385,17 +8422,17 @@ void tFreeSSubQueryMsg(SSubQueryMsg *pReq) { } int32_t tSerializeSOperatorParam(SEncoder *pEncoder, SOperatorParam *pOpParam) { - if (tEncodeI32(pEncoder, pOpParam->opType) < 0) return -1; - if (tEncodeI32(pEncoder, pOpParam->downstreamIdx) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pOpParam->opType)); + TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pOpParam->downstreamIdx)); switch (pOpParam->opType) { case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: { STableScanOperatorParam *pScan = (STableScanOperatorParam *)pOpParam->value; - if (tEncodeI8(pEncoder, pScan->tableSeq) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pScan->tableSeq)); int32_t uidNum = taosArrayGetSize(pScan->pUidList); - if (tEncodeI32(pEncoder, uidNum) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI32(pEncoder, uidNum)); for (int32_t m = 0; m < uidNum; ++m) { int64_t *pUid = taosArrayGet(pScan->pUidList, m); - if (tEncodeI64(pEncoder, *pUid) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI64(pEncoder, *pUid)); } break; } @@ -8404,33 +8441,39 @@ int32_t tSerializeSOperatorParam(SEncoder *pEncoder, SOperatorParam *pOpParam) { } int32_t n = taosArrayGetSize(pOpParam->pChildren); - if (tEncodeI32(pEncoder, n) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI32(pEncoder, n)); for (int32_t i = 0; i < n; ++i) { SOperatorParam *pChild = *(SOperatorParam **)taosArrayGet(pOpParam->pChildren, i); - if (tSerializeSOperatorParam(pEncoder, pChild) < 0) return -1; + TAOS_CHECK_RETURN(tSerializeSOperatorParam(pEncoder, pChild)); } return 0; } int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam *pOpParam) { - if (tDecodeI32(pDecoder, &pOpParam->opType) < 0) return -1; - if (tDecodeI32(pDecoder, &pOpParam->downstreamIdx) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pOpParam->opType)); + TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pOpParam->downstreamIdx)); switch (pOpParam->opType) { case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: { STableScanOperatorParam *pScan = taosMemoryMalloc(sizeof(STableScanOperatorParam)); - if (NULL == pScan) return -1; - if (tDecodeI8(pDecoder, (int8_t *)&pScan->tableSeq) < 0) return -1; + if (NULL == pScan) { + TAOS_CHECK_RETURN(terrno); + } + TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&pScan->tableSeq)); int32_t uidNum = 0; int64_t uid = 0; - if (tDecodeI32(pDecoder, &uidNum) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &uidNum)); if (uidNum > 0) { pScan->pUidList = taosArrayInit(uidNum, sizeof(int64_t)); - if (NULL == pScan->pUidList) return -1; + if (NULL == pScan->pUidList) { + TAOS_CHECK_RETURN(terrno); + } for (int32_t m = 0; m < uidNum; ++m) { - if (tDecodeI64(pDecoder, &uid) < 0) return -1; - if (taosArrayPush(pScan->pUidList, &uid) == NULL) return -1; + TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &uid)); + if (taosArrayPush(pScan->pUidList, &uid) == NULL) { + TAOS_CHECK_RETURN(terrno); + } } } else { pScan->pUidList = NULL; @@ -8443,16 +8486,22 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam *pOpParam) } int32_t childrenNum = 0; - if (tDecodeI32(pDecoder, &childrenNum) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &childrenNum)); if (childrenNum > 0) { pOpParam->pChildren = taosArrayInit(childrenNum, POINTER_BYTES); - if (NULL == pOpParam->pChildren) return -1; + if (NULL == pOpParam->pChildren) { + TAOS_CHECK_RETURN(terrno); + } for (int32_t i = 0; i < childrenNum; ++i) { SOperatorParam *pChild = taosMemoryCalloc(1, sizeof(SOperatorParam)); - if (NULL == pChild) return -1; - if (tDeserializeSOperatorParam(pDecoder, pChild) < 0) return -1; - if (taosArrayPush(pOpParam->pChildren, &pChild) == NULL) return -1; + if (NULL == pChild) { + TAOS_CHECK_RETURN(terrno); + } + TAOS_CHECK_RETURN(tDeserializeSOperatorParam(pDecoder, pChild)); + if (taosArrayPush(pOpParam->pChildren, &pChild) == NULL) { + TAOS_CHECK_RETURN(terrno); + } } } else { pOpParam->pChildren = NULL; @@ -8462,6 +8511,8 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam *pOpParam) } int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) { + int32_t code = 0; + int32_t lino; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8470,34 +8521,42 @@ int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->execId) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->taskId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId)); if (pReq->pOpParam) { - if (tEncodeI32(&encoder, 1) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, 1)); if (tSerializeSOperatorParam(&encoder, pReq->pOpParam) < 0) return -1; } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, 0)); } tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) { + int32_t code = 0; + int32_t lino; int32_t headLen = sizeof(SMsgHead); SMsgHead *pHead = buf; @@ -8507,29 +8566,34 @@ int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->taskId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->execId)); int32_t paramNum = 0; - if (tDecodeI32(&decoder, ¶mNum) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, ¶mNum)); if (paramNum > 0) { pReq->pOpParam = taosMemoryMalloc(sizeof(*pReq->pOpParam)); - if (NULL == pReq->pOpParam) return -1; - if (tDeserializeSOperatorParam(&decoder, pReq->pOpParam) < 0) return -1; + if (NULL == pReq->pOpParam) { + TAOS_CHECK_EXIT(terrno); + } + TAOS_CHECK_EXIT(tDeserializeSOperatorParam(&decoder, pReq->pOpParam)); } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { int32_t headLen = sizeof(SMsgHead); + int32_t code = 0; + int32_t lino; if (buf != NULL) { buf = (char *)buf + headLen; bufLen -= headLen; @@ -8537,73 +8601,84 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeCStr(&encoder, pReq->subKey) < 0) return -1; - if (tEncodeI8(&encoder, pReq->withTbName) < 0) return -1; - if (tEncodeI8(&encoder, pReq->useSnapshot) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epoch) < 0) return -1; - if (tEncodeU64(&encoder, pReq->reqId) < 0) return -1; - if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1; - if (tEncodeI64(&encoder, pReq->timeout) < 0) return -1; - if (tEncodeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1; - if (tEncodeI8(&encoder, pReq->enableReplay) < 0) return -1; - if (tEncodeI8(&encoder, pReq->sourceExcluded) < 0) return -1; - if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->subKey)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->withTbName)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->useSnapshot)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epoch)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->reqId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->consumerId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->timeout)); + TAOS_CHECK_EXIT(tEncodeSTqOffsetVal(&encoder, &pReq->reqOffset)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->enableReplay)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->sourceExcluded)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->enableBatchMeta)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->head.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->head.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { - int32_t headLen = sizeof(SMsgHead); - + int32_t code = 0; + int32_t lino; + int32_t headLen = sizeof(SMsgHead); SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeCStrTo(&decoder, pReq->subKey) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->withTbName) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->useSnapshot) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->reqId) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->timeout) < 0) return -1; - if (tDecodeSTqOffsetVal(&decoder, &pReq->reqOffset) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->subKey)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->withTbName)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->useSnapshot)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epoch)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->reqId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->consumerId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->timeout)); + TAOS_CHECK_EXIT(tDecodeSTqOffsetVal(&decoder, &pReq->reqOffset)); if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI8(&decoder, &pReq->enableReplay) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->enableReplay)); } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI8(&decoder, &pReq->sourceExcluded) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->sourceExcluded)); } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI8(&decoder, &pReq->enableBatchMeta) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->enableBatchMeta)); } else { pReq->enableBatchMeta = false; } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tDestroySMqPollReq(SMqPollReq *pReq) { tOffsetDestroy(&pReq->reqOffset); } int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) { + int32_t code = 0; + int32_t lino; + int32_t tlen; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8612,30 +8687,38 @@ int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1; - if (tEncodeI64(&encoder, pReq->refId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->execId) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->taskId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->refId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) { int32_t headLen = sizeof(SMsgHead); + int32_t code = 0; + int32_t lino; SMsgHead *pHead = buf; pHead->vgId = pReq->header.vgId; @@ -8644,21 +8727,25 @@ int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->taskId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->refId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->execId)); tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSTaskNotifyReq(void *buf, int32_t bufLen, STaskNotifyReq *pReq) { + int32_t code = 0; + int32_t lino; + int32_t tlen; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8667,31 +8754,39 @@ int32_t tSerializeSTaskNotifyReq(void *buf, int32_t bufLen, STaskNotifyReq *pReq SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1; - if (tEncodeI64(&encoder, pReq->refId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->execId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->type) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->taskId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->refId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->execId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->type)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSTaskNotifyReq(void *buf, int32_t bufLen, STaskNotifyReq *pReq) { int32_t headLen = sizeof(SMsgHead); + int32_t code = 0; + int32_t lino; SMsgHead *pHead = buf; pHead->vgId = pReq->header.vgId; @@ -8700,74 +8795,92 @@ int32_t tDeserializeSTaskNotifyReq(void *buf, int32_t bufLen, STaskNotifyReq *pR SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1; - if (tDecodeI32(&decoder, (int32_t *)&pReq->type) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->taskId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->refId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->execId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, (int32_t *)&pReq->type)); tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp) { SEncoder encoder = {0}; + int32_t code = 0; + int32_t lino; + int32_t tlen; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); - if (tEncodeI32(&encoder, pRsp->code) < 0) return -1; - if (tEncodeI64(&encoder, pRsp->affectedRows) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->code)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pRsp->affectedRows)); int32_t tbNum = taosArrayGetSize(pRsp->tbVerInfo); - if (tEncodeI32(&encoder, tbNum) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, tbNum)); if (tbNum > 0) { for (int32_t i = 0; i < tbNum; ++i) { STbVerInfo *pVer = taosArrayGet(pRsp->tbVerInfo, i); - if (tEncodeCStr(&encoder, pVer->tbFName) < 0) return -1; - if (tEncodeI32(&encoder, pVer->sversion) < 0) return -1; - if (tEncodeI32(&encoder, pVer->tversion) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pVer->tbFName)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pVer->sversion)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pVer->tversion)); } } tEndEncode(&encoder); - int32_t tlen = encoder.pos; +_exit: + if (code) { + tlen = code; + } else { + tlen = encoder.pos; + } tEncoderClear(&encoder); - return tlen; } int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp) { SDecoder decoder = {0}; + int32_t code = 0; + int32_t lino; tDecoderInit(&decoder, (char *)buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); - if (tDecodeI32(&decoder, &pRsp->code) < 0) return -1; - if (tDecodeI64(&decoder, &pRsp->affectedRows) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->code)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pRsp->affectedRows)); int32_t tbNum = 0; - if (tDecodeI32(&decoder, &tbNum) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &tbNum)); if (tbNum > 0) { pRsp->tbVerInfo = taosArrayInit(tbNum, sizeof(STbVerInfo)); - if (NULL == pRsp->tbVerInfo) return -1; + if (NULL == pRsp->tbVerInfo) { + TAOS_CHECK_EXIT(terrno); + } STbVerInfo tbVer; - if (tDecodeCStrTo(&decoder, tbVer.tbFName) < 0) return -1; - if (tDecodeI32(&decoder, &tbVer.sversion) < 0) return -1; - if (tDecodeI32(&decoder, &tbVer.tversion) < 0) return -1; - if (NULL == taosArrayPush(pRsp->tbVerInfo, &tbVer)) return -1; + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, tbVer.tbFName)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &tbVer.sversion)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &tbVer.tversion)); + if (NULL == taosArrayPush(pRsp->tbVerInfo, &tbVer)) { + TAOS_CHECK_EXIT(terrno); + } } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq) { + int32_t code = 0; + int32_t lino; + int32_t tlen; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -8777,208 +8890,185 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; - if (tEncodeU16(&encoder, pReq->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->epId.nodeId)); + TAOS_CHECK_EXIT(tEncodeU16(&encoder, pReq->epId.ep.port)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->epId.ep.fqdn)); if (pReq->taskAction) { int32_t num = taosArrayGetSize(pReq->taskAction); - if (tEncodeI32(&encoder, num) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, num)); for (int32_t i = 0; i < num; ++i) { STaskAction *action = taosArrayGet(pReq->taskAction, i); - if (tEncodeU64(&encoder, action->queryId) < 0) return -1; - if (tEncodeU64(&encoder, action->taskId) < 0) return -1; - if (tEncodeI8(&encoder, action->action) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, action->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, action->taskId)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, action->action)); } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, 0)); } tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq) { - int32_t headLen = sizeof(SMsgHead); - + int32_t headLen = sizeof(SMsgHead); SMsgHead *pHead = buf; pHead->vgId = pReq->header.vgId; pHead->contLen = pReq->header.contLen; + int32_t code = 0; + int32_t lino; SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->epId.nodeId) < 0) return -1; - if (tDecodeU16(&decoder, &pReq->epId.ep.port) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->epId.ep.fqdn) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->epId.nodeId)); + TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pReq->epId.ep.port)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->epId.ep.fqdn)); int32_t num = 0; - if (tDecodeI32(&decoder, &num) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &num)); if (num > 0) { pReq->taskAction = taosArrayInit(num, sizeof(STaskStatus)); - if (NULL == pReq->taskAction) return -1; + if (NULL == pReq->taskAction) { + TAOS_CHECK_EXIT(terrno); + } for (int32_t i = 0; i < num; ++i) { STaskAction action = {0}; - if (tDecodeU64(&decoder, &action.queryId) < 0) return -1; - if (tDecodeU64(&decoder, &action.taskId) < 0) return -1; - if (tDecodeI8(&decoder, &action.action) < 0) return -1; - if (taosArrayPush(pReq->taskAction, &action) == NULL) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &action.queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &action.taskId)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &action.action)); + if (taosArrayPush(pReq->taskAction, &action) == NULL) { + TAOS_CHECK_EXIT(terrno); + } } } else { pReq->taskAction = NULL; } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq) { taosArrayDestroy(pReq->taskAction); } int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp) { SEncoder encoder = {0}; + int32_t code = 0; + int32_t lino; + int32_t tlen; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; - if (tEncodeU16(&encoder, pRsp->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->epId.nodeId)); + TAOS_CHECK_EXIT(tEncodeU16(&encoder, pRsp->epId.ep.port)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pRsp->epId.ep.fqdn)); if (pRsp->taskStatus) { int32_t num = taosArrayGetSize(pRsp->taskStatus); - if (tEncodeI32(&encoder, num) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, num)); for (int32_t i = 0; i < num; ++i) { STaskStatus *status = taosArrayGet(pRsp->taskStatus, i); - if (tEncodeU64(&encoder, status->queryId) < 0) return -1; - if (tEncodeU64(&encoder, status->taskId) < 0) return -1; - if (tEncodeI64(&encoder, status->refId) < 0) return -1; - if (tEncodeI32(&encoder, status->execId) < 0) return -1; - if (tEncodeI8(&encoder, status->status) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeU64(&encoder, status->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, status->taskId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, status->refId)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, status->execId)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, status->status)); } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, 0)); } tEndEncode(&encoder); - int32_t tlen = encoder.pos; +_exit: + if (code) { + tlen = code; + } else { + tlen = encoder.pos; + } tEncoderClear(&encoder); return tlen; } int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp) { SDecoder decoder = {0}; + int32_t code = 0; + int32_t lino; tDecoderInit(&decoder, buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->epId.nodeId) < 0) return -1; - if (tDecodeU16(&decoder, &pRsp->epId.ep.port) < 0) return -1; - if (tDecodeCStrTo(&decoder, pRsp->epId.ep.fqdn) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->epId.nodeId)); + TAOS_CHECK_EXIT(tDecodeU16(&decoder, &pRsp->epId.ep.port)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pRsp->epId.ep.fqdn)); int32_t num = 0; - if (tDecodeI32(&decoder, &num) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &num)); if (num > 0) { pRsp->taskStatus = taosArrayInit(num, sizeof(STaskStatus)); if (NULL == pRsp->taskStatus) return -1; for (int32_t i = 0; i < num; ++i) { STaskStatus status = {0}; - if (tDecodeU64(&decoder, &status.queryId) < 0) return -1; - if (tDecodeU64(&decoder, &status.taskId) < 0) return -1; - if (tDecodeI64(&decoder, &status.refId) < 0) return -1; - if (tDecodeI32(&decoder, &status.execId) < 0) return -1; - if (tDecodeI8(&decoder, &status.status) < 0) return -1; - if (taosArrayPush(pRsp->taskStatus, &status) == NULL) return -1; + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &status.queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &status.taskId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &status.refId)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &status.execId)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &status.status)); + if (taosArrayPush(pRsp->taskStatus, &status) == NULL) { + TAOS_CHECK_EXIT(terrno); + } } } else { pRsp->taskStatus = NULL; } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tFreeSSchedulerHbRsp(SSchedulerHbRsp *pRsp) { taosArrayDestroy(pRsp->taskStatus); } -// int32_t tSerializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) { -// // SEncoder encoder = {0}; -// // tEncoderInit(&encoder, buf, bufLen); - -// // if (tStartEncode(&encoder) < 0) return -1; -// // if (pRsp->rspList) { -// // int32_t num = taosArrayGetSize(pRsp->rspList); -// // if (tEncodeI32(&encoder, num) < 0) return -1; -// // for (int32_t i = 0; i < num; ++i) { -// // SVCreateTbRsp *rsp = taosArrayGet(pRsp->rspList, i); -// // if (tEncodeI32(&encoder, rsp->code) < 0) return -1; -// // } -// // } else { -// // if (tEncodeI32(&encoder, 0) < 0) return -1; -// // } -// // tEndEncode(&encoder); - -// // int32_t tlen = encoder.pos; -// // tEncoderClear(&encoder); -// // reture tlen; -// return 0; -// } - -// int32_t tDeserializeSVCreateTbBatchRsp(void *buf, int32_t bufLen, SVCreateTbBatchRsp *pRsp) { -// SDecoder decoder = {0}; -// int32_t num = 0; -// tDecoderInit(&decoder, buf, bufLen); - -// if (tStartDecode(&decoder) < 0) return -1; -// if (tDecodeI32(&decoder, &num) < 0) return -1; -// if (num > 0) { -// pRsp->rspList = taosArrayInit(num, sizeof(SVCreateTbRsp)); -// if (NULL == pRsp->rspList) return -1; -// for (int32_t i = 0; i < num; ++i) { -// SVCreateTbRsp rsp = {0}; -// if (tDecodeI32(&decoder, &rsp.code) < 0) return -1; -// if (NULL == taosArrayPush(pRsp->rspList, &rsp)) return -1; -// } -// } else { -// pRsp->rspList = NULL; -// } -// tEndDecode(&decoder); - -// tDecoderClear(&decoder); -// return 0; -//} - int tEncodeSVCreateTbBatchRsp(SEncoder *pCoder, const SVCreateTbBatchRsp *pRsp) { int32_t nRsps = taosArrayGetSize(pRsp->pArray); SVCreateTbRsp *pCreateRsp; - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI32v(pCoder, nRsps) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI32v(pCoder, nRsps)); for (int32_t i = 0; i < nRsps; i++) { pCreateRsp = taosArrayGet(pRsp->pArray, i); - if (tEncodeSVCreateTbRsp(pCoder, pCreateRsp) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSVCreateTbRsp(pCoder, pCreateRsp)); } tEndEncode(pCoder); - return 0; } int tDecodeSVCreateTbBatchRsp(SDecoder *pCoder, SVCreateTbBatchRsp *pRsp) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI32v(pCoder, &pRsp->nRsps) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pRsp->nRsps)); pRsp->pRsps = (SVCreateTbRsp *)tDecoderMalloc(pCoder, sizeof(*pRsp->pRsps) * pRsp->nRsps); + if (pRsp->pRsps == NULL) { + TAOS_CHECK_RETURN(terrno); + } for (int32_t i = 0; i < pRsp->nRsps; i++) { - if (tDecodeSVCreateTbRsp(pCoder, pRsp->pRsps + i) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeSVCreateTbRsp(pCoder, pRsp->pRsps + i)); } tEndDecode(pCoder); @@ -8986,119 +9076,110 @@ int tDecodeSVCreateTbBatchRsp(SDecoder *pCoder, SVCreateTbBatchRsp *pRsp) { } int32_t tEncodeTSma(SEncoder *pCoder, const STSma *pSma) { - if (tEncodeI8(pCoder, pSma->version) < 0) return -1; - if (tEncodeI8(pCoder, pSma->intervalUnit) < 0) return -1; - if (tEncodeI8(pCoder, pSma->slidingUnit) < 0) return -1; - if (tEncodeI8(pCoder, pSma->timezoneInt) < 0) return -1; - if (tEncodeI32(pCoder, pSma->dstVgId) < 0) return -1; - if (tEncodeCStr(pCoder, pSma->indexName) < 0) return -1; - if (tEncodeI32(pCoder, pSma->exprLen) < 0) return -1; - if (tEncodeI32(pCoder, pSma->tagsFilterLen) < 0) return -1; - if (tEncodeI64(pCoder, pSma->indexUid) < 0) return -1; - if (tEncodeI64(pCoder, pSma->tableUid) < 0) return -1; - if (tEncodeI64(pCoder, pSma->dstTbUid) < 0) return -1; - if (tEncodeCStr(pCoder, pSma->dstTbName) < 0) return -1; - if (tEncodeI64(pCoder, pSma->interval) < 0) return -1; - if (tEncodeI64(pCoder, pSma->offset) < 0) return -1; - if (tEncodeI64(pCoder, pSma->sliding) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pSma->version)); + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pSma->intervalUnit)); + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pSma->slidingUnit)); + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pSma->timezoneInt)); + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pSma->dstVgId)); + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pSma->indexName)); + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pSma->exprLen)); + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pSma->tagsFilterLen)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->indexUid)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->tableUid)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->dstTbUid)); + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pSma->dstTbName)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->interval)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->offset)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pSma->sliding)); if (pSma->exprLen > 0) { - if (tEncodeCStr(pCoder, pSma->expr) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pSma->expr)); } if (pSma->tagsFilterLen > 0) { - if (tEncodeCStr(pCoder, pSma->tagsFilter) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pSma->tagsFilter)); } - if (tEncodeSSchemaWrapper(pCoder, &pSma->schemaRow) < 0) return -1; - if (tEncodeSSchemaWrapper(pCoder, &pSma->schemaTag) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pSma->schemaRow)); + TAOS_CHECK_RETURN(tEncodeSSchemaWrapper(pCoder, &pSma->schemaTag)); return 0; } int32_t tDecodeTSma(SDecoder *pCoder, STSma *pSma, bool deepCopy) { - if (tDecodeI8(pCoder, &pSma->version) < 0) return -1; - if (tDecodeI8(pCoder, &pSma->intervalUnit) < 0) return -1; - if (tDecodeI8(pCoder, &pSma->slidingUnit) < 0) return -1; - if (tDecodeI8(pCoder, &pSma->timezoneInt) < 0) return -1; - if (tDecodeI32(pCoder, &pSma->dstVgId) < 0) return -1; - if (tDecodeCStrTo(pCoder, pSma->indexName) < 0) return -1; - if (tDecodeI32(pCoder, &pSma->exprLen) < 0) return -1; - if (tDecodeI32(pCoder, &pSma->tagsFilterLen) < 0) return -1; - if (tDecodeI64(pCoder, &pSma->indexUid) < 0) return -1; - if (tDecodeI64(pCoder, &pSma->tableUid) < 0) return -1; - if (tDecodeI64(pCoder, &pSma->dstTbUid) < 0) return -1; + int32_t code = 0; + int32_t lino; + + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pSma->version)); + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pSma->intervalUnit)); + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pSma->slidingUnit)); + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pSma->timezoneInt)); + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pSma->dstVgId)); + TAOS_CHECK_EXIT(tDecodeCStrTo(pCoder, pSma->indexName)); + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pSma->exprLen)); + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pSma->tagsFilterLen)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->indexUid)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->tableUid)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->dstTbUid)); if (deepCopy) { - if (tDecodeCStrAlloc(pCoder, &pSma->dstTbName) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrAlloc(pCoder, &pSma->dstTbName)); } else { - if (tDecodeCStr(pCoder, &pSma->dstTbName) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pSma->dstTbName)); } - if (tDecodeI64(pCoder, &pSma->interval) < 0) return -1; - if (tDecodeI64(pCoder, &pSma->offset) < 0) return -1; - if (tDecodeI64(pCoder, &pSma->sliding) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->interval)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->offset)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pSma->sliding)); if (pSma->exprLen > 0) { if (deepCopy) { - if (tDecodeCStrAlloc(pCoder, &pSma->expr) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrAlloc(pCoder, &pSma->expr)); } else { - if (tDecodeCStr(pCoder, &pSma->expr) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pSma->expr)); } } else { pSma->expr = NULL; } if (pSma->tagsFilterLen > 0) { if (deepCopy) { - if (tDecodeCStrAlloc(pCoder, &pSma->tagsFilter) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrAlloc(pCoder, &pSma->tagsFilter)); } else { - if (tDecodeCStr(pCoder, &pSma->tagsFilter) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pSma->tagsFilter)); } } else { pSma->tagsFilter = NULL; } // only needed in dstVgroup - if (tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaRow) < 0) return -1; - if (tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaTag) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaRow)); + TAOS_CHECK_EXIT(tDecodeSSchemaWrapperEx(pCoder, &pSma->schemaTag)); - return 0; +_exit: + return code; } int32_t tEncodeSVCreateTSmaReq(SEncoder *pCoder, const SVCreateTSmaReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeTSma(pCoder, pReq) < 0) return -1; - + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeTSma(pCoder, pReq)); tEndEncode(pCoder); return 0; } int32_t tDecodeSVCreateTSmaReq(SDecoder *pCoder, SVCreateTSmaReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeTSma(pCoder, pReq, false) < 0) return -1; - + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeTSma(pCoder, pReq, false)); tEndDecode(pCoder); return 0; } int32_t tEncodeSVDropTSmaReq(SEncoder *pCoder, const SVDropTSmaReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI64(pCoder, pReq->indexUid) < 0) return -1; - if (tEncodeCStr(pCoder, pReq->indexName) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pReq->indexUid)); + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pReq->indexName)); tEndEncode(pCoder); return 0; } -// int32_t tDecodeSVDropTSmaReq(SDecoder *pCoder, SVDropTSmaReq *pReq) { -// if (tStartDecode(pCoder) < 0) return -1; - -// if (tDecodeI64(pCoder, &pReq->indexUid) < 0) return -1; -// if (tDecodeCStrTo(pCoder, pReq->indexName) < 0) return -1; - -// tEndDecode(pCoder); -// return 0; -// } - int32_t tSerializeSVDeleteReq(void *buf, int32_t bufLen, SVDeleteReq *pReq) { + int32_t code = 0; + int32_t lino; int32_t headLen = sizeof(SMsgHead); if (buf != NULL) { buf = (char *)buf + headLen; @@ -9108,31 +9189,38 @@ int32_t tSerializeSVDeleteReq(void *buf, int32_t bufLen, SVDeleteReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1; - if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1; - if (tEncodeU32(&encoder, pReq->sqlLen) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; - if (tEncodeBinary(&encoder, pReq->msg, pReq->phyLen) < 0) return -1; - if (tEncodeI8(&encoder, pReq->source) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->sId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->queryId)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->taskId)); + TAOS_CHECK_EXIT(tEncodeU32(&encoder, pReq->sqlLen)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->sql)); + TAOS_CHECK_EXIT(tEncodeBinary(&encoder, pReq->msg, pReq->phyLen)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->source)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); - if (buf != NULL) { - SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); - pHead->vgId = htonl(pReq->header.vgId); - pHead->contLen = htonl(tlen + headLen); + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; } - - return tlen + headLen; } int32_t tDeserializeSVDeleteReq(void *buf, int32_t bufLen, SVDeleteReq *pReq) { - int32_t headLen = sizeof(SMsgHead); - + int32_t code = 0; + int32_t lino; + int32_t headLen = sizeof(SMsgHead); SMsgHead *pHead = buf; pHead->vgId = pReq->header.vgId; pHead->contLen = pReq->header.contLen; @@ -9140,41 +9228,40 @@ int32_t tDeserializeSVDeleteReq(void *buf, int32_t bufLen, SVDeleteReq *pReq) { SDecoder decoder = {0}; tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1; - if (tDecodeU32(&decoder, &pReq->sqlLen) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->sId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->queryId)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->taskId)); + TAOS_CHECK_EXIT(tDecodeU32(&decoder, &pReq->sqlLen)); pReq->sql = taosMemoryCalloc(1, pReq->sqlLen + 1); - if (NULL == pReq->sql) return -1; - if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; + if (NULL == pReq->sql) { + TAOS_CHECK_EXIT(terrno); + } + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->sql)); uint64_t msgLen = 0; - if (tDecodeBinaryAlloc(&decoder, (void **)&pReq->msg, &msgLen) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeBinaryAlloc(&decoder, (void **)&pReq->msg, &msgLen)); pReq->phyLen = msgLen; if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI8(&decoder, &pReq->source) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->source)); } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); return 0; } int32_t tEncodeSVDeleteRsp(SEncoder *pCoder, const SVDeleteRsp *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI64(pCoder, pReq->affectedRows) < 0) return -1; - + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pReq->affectedRows)); tEndEncode(pCoder); return 0; } int32_t tDecodeSVDeleteRsp(SDecoder *pCoder, SVDeleteRsp *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI64(pCoder, &pReq->affectedRows) < 0) return -1; - + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pReq->affectedRows)); tEndDecode(pCoder); return 0; } @@ -9187,69 +9274,77 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); + int32_t code = 0; + int32_t lino; - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->sourceDB) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->targetStbFullName) < 0) return -1; - if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; - if (tEncodeI8(&encoder, pReq->fillHistory) < 0) return -1; - if (tEncodeI32(&encoder, sqlLen) < 0) return -1; - if (tEncodeI32(&encoder, astLen) < 0) return -1; - if (tEncodeI8(&encoder, pReq->triggerType) < 0) return -1; - if (tEncodeI64(&encoder, pReq->maxDelay) < 0) return -1; - if (tEncodeI64(&encoder, pReq->watermark) < 0) return -1; - if (tEncodeI8(&encoder, pReq->igExpired) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->name)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->sourceDB)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->targetStbFullName)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igExists)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->fillHistory)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, sqlLen)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, astLen)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->triggerType)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->maxDelay)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->watermark)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igExpired)); if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; - if (tEncodeI32(&encoder, pReq->numOfTags) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numOfTags)); for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField *pField = taosArrayGet(pReq->pTags, i); - if (tEncodeI8(&encoder, pField->type) < 0) return -1; - if (tEncodeI8(&encoder, pField->flags) < 0) return -1; - if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; - if (tEncodeCStr(&encoder, pField->name) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pField->type)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pField->flags)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pField->bytes)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pField->name)); } - if (tEncodeI8(&encoder, pReq->createStb) < 0) return -1; - if (tEncodeU64(&encoder, pReq->targetStbUid) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->createStb)); + TAOS_CHECK_EXIT(tEncodeU64(&encoder, pReq->targetStbUid)); - if (tEncodeI32(&encoder, taosArrayGetSize(pReq->fillNullCols)) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, taosArrayGetSize(pReq->fillNullCols))); for (int32_t i = 0; i < taosArrayGetSize(pReq->fillNullCols); ++i) { SColLocation *pCol = taosArrayGet(pReq->fillNullCols, i); - if (tEncodeI16(&encoder, pCol->slotId) < 0) return -1; - if (tEncodeI16(&encoder, pCol->colId) < 0) return -1; - if (tEncodeI8(&encoder, pCol->type) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI16(&encoder, pCol->slotId)); + TAOS_CHECK_EXIT(tEncodeI16(&encoder, pCol->colId)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pCol->type)); } - if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1; - if (tEncodeI8(&encoder, pReq->igUpdate) < 0) return -1; - if (tEncodeI64(&encoder, pReq->lastTs) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->deleteMark)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igUpdate)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->lastTs)); - if (tEncodeI32(&encoder, taosArrayGetSize(pReq->pVgroupVerList)) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, taosArrayGetSize(pReq->pVgroupVerList))); for (int32_t i = 0; i < taosArrayGetSize(pReq->pVgroupVerList); ++i) { SVgroupVer *p = taosArrayGet(pReq->pVgroupVerList, i); - if (tEncodeI32(&encoder, p->vgId) < 0) return -1; - if (tEncodeI64(&encoder, p->ver) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, p->vgId)); + TAOS_CHECK_EXIT(tEncodeI64(&encoder, p->ver)); } int32_t colSize = taosArrayGetSize(pReq->pCols); - if (tEncodeI32(&encoder, colSize) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(&encoder, colSize)); for (int32_t i = 0; i < colSize; ++i) { SFieldWithOptions *pField = taosArrayGet(pReq->pCols, i); - if (tEncodeI8(&encoder, pField->type) < 0) return -1; - if (tEncodeI8(&encoder, pField->flags) < 0) return -1; - if (tEncodeI32(&encoder, pField->bytes) < 0) return -1; - if (tEncodeCStr(&encoder, pField->name) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pField->type)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pField->flags)); + TAOS_CHECK_EXIT(tEncodeI32(&encoder, pField->bytes)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pField->name)); } - if (tEncodeI64(&encoder, pReq->smaId) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->smaId)); tEndEncode(&encoder); - int32_t tlen = encoder.pos; - tEncoderClear(&encoder); - return tlen; +_exit: + if (code) { + tEncoderClear(&encoder); + return code; + } else { + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; + } } int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStreamReq *pReq) { @@ -9260,183 +9355,171 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea SDecoder decoder = {0}; tDecoderInit(&decoder, buf, bufLen); + int32_t code = 0; + int32_t lino; - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->sourceDB) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->targetStbFullName) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->fillHistory) < 0) return -1; - if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; - if (tDecodeI32(&decoder, &astLen) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->triggerType) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->maxDelay) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->watermark) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->igExpired) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->name)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->sourceDB)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->targetStbFullName)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->igExists)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->fillHistory)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &sqlLen)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &astLen)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->triggerType)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->maxDelay)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->watermark)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->igExpired)); if (sqlLen > 0) { pReq->sql = taosMemoryCalloc(1, sqlLen + 1); - if (pReq->sql == NULL) return -1; - if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; + if (pReq->sql == NULL) { + TAOS_CHECK_EXIT(terrno); + } + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->sql)); } if (astLen > 0) { pReq->ast = taosMemoryCalloc(1, astLen + 1); - if (pReq->ast == NULL) return -1; - if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; + if (pReq->ast == NULL) { + TAOS_CHECK_EXIT(terrno); + } + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->ast)); } - if (tDecodeI32(&decoder, &pReq->numOfTags) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->numOfTags)); if (pReq->numOfTags > 0) { pReq->pTags = taosArrayInit(pReq->numOfTags, sizeof(SField)); if (pReq->pTags == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } for (int32_t i = 0; i < pReq->numOfTags; ++i) { SField field = {0}; - if (tDecodeI8(&decoder, &field.type) < 0) return -1; - if (tDecodeI8(&decoder, &field.flags) < 0) return -1; - if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; - if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &field.type)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &field.flags)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &field.bytes)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, field.name)); if (taosArrayPush(pReq->pTags, &field) == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } } } - if (tDecodeI8(&decoder, &pReq->createStb) < 0) return -1; - if (tDecodeU64(&decoder, &pReq->targetStbUid) < 0) return -1; - if (tDecodeI32(&decoder, &numOfFillNullCols) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->createStb)); + TAOS_CHECK_EXIT(tDecodeU64(&decoder, &pReq->targetStbUid)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &numOfFillNullCols)); if (numOfFillNullCols > 0) { pReq->fillNullCols = taosArrayInit(numOfFillNullCols, sizeof(SColLocation)); if (pReq->fillNullCols == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } for (int32_t i = 0; i < numOfFillNullCols; ++i) { SColLocation col = {0}; - if (tDecodeI16(&decoder, &col.slotId) < 0) return -1; - if (tDecodeI16(&decoder, &col.colId) < 0) return -1; - if (tDecodeI8(&decoder, &col.type) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI16(&decoder, &col.slotId)); + TAOS_CHECK_EXIT(tDecodeI16(&decoder, &col.colId)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &col.type)); if (taosArrayPush(pReq->fillNullCols, &col) == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } } } - if (tDecodeI64(&decoder, &pReq->deleteMark) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->igUpdate) < 0) return -1; - if (tDecodeI64(&decoder, &pReq->lastTs) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->deleteMark)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->igUpdate)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->lastTs)); - if (tDecodeI32(&decoder, &numOfVgVer) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &numOfVgVer)); if (numOfVgVer > 0) { pReq->pVgroupVerList = taosArrayInit(numOfVgVer, sizeof(SVgroupVer)); if (pReq->pVgroupVerList == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } for (int32_t i = 0; i < numOfVgVer; ++i) { SVgroupVer v = {0}; - if (tDecodeI32(&decoder, &v.vgId) < 0) return -1; - if (tDecodeI64(&decoder, &v.ver) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &v.vgId)); + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &v.ver)); if (taosArrayPush(pReq->pVgroupVerList, &v) == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } } } int32_t colSize = 0; - if (tDecodeI32(&decoder, &colSize) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &colSize)); if (colSize > 0) { pReq->pCols = taosArrayInit(colSize, sizeof(SField)); if (pReq->pCols == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } for (int32_t i = 0; i < colSize; ++i) { SField field = {0}; - if (tDecodeI8(&decoder, &field.type) < 0) return -1; - if (tDecodeI8(&decoder, &field.flags) < 0) return -1; - if (tDecodeI32(&decoder, &field.bytes) < 0) return -1; - if (tDecodeCStrTo(&decoder, field.name) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &field.type)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &field.flags)); + TAOS_CHECK_EXIT(tDecodeI32(&decoder, &field.bytes)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, field.name)); if (taosArrayPush(pReq->pCols, &field) == NULL) { - return -1; + TAOS_CHECK_EXIT(terrno); } } } if (!tDecodeIsEnd(&decoder)) { - if (tDecodeI64(&decoder, &pReq->smaId) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->smaId)); } tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - - return 0; + return code; } int32_t tSerializeSMDropStreamReq(void *buf, int32_t bufLen, const SMDropStreamReq *pReq) { + int32_t code = 0; + int32_t lino; + int32_t tlen; SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); - if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; - if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(&encoder)); + TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->name)); + TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->igNotExists)); ENCODESQL(); tEndEncode(&encoder); - int32_t tlen = encoder.pos; +_exit: + if (code) { + tlen = code; + } else { + tlen = encoder.pos; + } tEncoderClear(&encoder); return tlen; } int32_t tDeserializeSMDropStreamReq(void *buf, int32_t bufLen, SMDropStreamReq *pReq) { SDecoder decoder = {0}; + int32_t code = 0; + int32_t lino; tDecoderInit(&decoder, buf, bufLen); - if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; - if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(&decoder)); + TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->name)); + TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->igNotExists)); DECODESQL(); tEndDecode(&decoder); +_exit: tDecoderClear(&decoder); - return 0; + return code; } void tFreeMDropStreamReq(SMDropStreamReq *pReq) { FREESQL(); } -// int32_t tSerializeSMRecoverStreamReq(void *buf, int32_t bufLen, const SMRecoverStreamReq *pReq) { -// SEncoder encoder = {0}; -// tEncoderInit(&encoder, buf, bufLen); - -// if (tStartEncode(&encoder) < 0) return -1; -// if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; -// if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; - -// tEndEncode(&encoder); - -// int32_t tlen = encoder.pos; -// tEncoderClear(&encoder); -// return tlen; -// } - -// int32_t tDeserializeSMRecoverStreamReq(void *buf, int32_t bufLen, SMRecoverStreamReq *pReq) { -// SDecoder decoder = {0}; -// tDecoderInit(&decoder, buf, bufLen); - -// if (tStartDecode(&decoder) < 0) return -1; -// if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; -// if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; - -// tEndDecode(&decoder); - -// tDecoderClear(&decoder); -// return 0; -// } - void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { if (NULL == pReq) { return; @@ -9450,215 +9533,253 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { } int32_t tEncodeSRSmaParam(SEncoder *pCoder, const SRSmaParam *pRSmaParam) { + int32_t code = 0; + int32_t lino; for (int32_t i = 0; i < 2; ++i) { - if (tEncodeI64v(pCoder, pRSmaParam->maxdelay[i]) < 0) return -1; - if (tEncodeI64v(pCoder, pRSmaParam->watermark[i]) < 0) return -1; - if (tEncodeI32v(pCoder, pRSmaParam->qmsgLen[i]) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI64v(pCoder, pRSmaParam->maxdelay[i])); + TAOS_CHECK_EXIT(tEncodeI64v(pCoder, pRSmaParam->watermark[i])); + TAOS_CHECK_EXIT(tEncodeI32v(pCoder, pRSmaParam->qmsgLen[i])); if (pRSmaParam->qmsgLen[i] > 0) { - if (tEncodeBinary(pCoder, pRSmaParam->qmsg[i], (uint64_t)pRSmaParam->qmsgLen[i]) < - 0) // qmsgLen contains len of '\0' - return -1; + TAOS_CHECK_EXIT(tEncodeBinary(pCoder, pRSmaParam->qmsg[i], (uint64_t)pRSmaParam->qmsgLen[i])); } } - return 0; +_exit: + return code; } int32_t tDecodeSRSmaParam(SDecoder *pCoder, SRSmaParam *pRSmaParam) { + int32_t code = 0; + int32_t lino; for (int32_t i = 0; i < 2; ++i) { - if (tDecodeI64v(pCoder, &pRSmaParam->maxdelay[i]) < 0) return -1; - if (tDecodeI64v(pCoder, &pRSmaParam->watermark[i]) < 0) return -1; - if (tDecodeI32v(pCoder, &pRSmaParam->qmsgLen[i]) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI64v(pCoder, &pRSmaParam->maxdelay[i])); + TAOS_CHECK_EXIT(tDecodeI64v(pCoder, &pRSmaParam->watermark[i])); + TAOS_CHECK_EXIT(tDecodeI32v(pCoder, &pRSmaParam->qmsgLen[i])); if (pRSmaParam->qmsgLen[i] > 0) { - if (tDecodeBinary(pCoder, (uint8_t **)&pRSmaParam->qmsg[i], NULL) < 0) return -1; // qmsgLen contains len of '\0' + TAOS_CHECK_EXIT(tDecodeBinary(pCoder, (uint8_t **)&pRSmaParam->qmsg[i], NULL)); // qmsgLen contains len of '\0' } else { pRSmaParam->qmsg[i] = NULL; } } - return 0; +_exit: + return code; } int32_t tEncodeSColCmprWrapper(SEncoder *pCoder, const SColCmprWrapper *pWrapper) { - if (tEncodeI32v(pCoder, pWrapper->nCols) < 0) return -1; - if (tEncodeI32v(pCoder, pWrapper->version) < 0) return -1; + int32_t code = 0; + int32_t lino; + + TAOS_CHECK_EXIT(tEncodeI32v(pCoder, pWrapper->nCols)); + TAOS_CHECK_EXIT(tEncodeI32v(pCoder, pWrapper->version)); for (int32_t i = 0; i < pWrapper->nCols; i++) { SColCmpr *p = &pWrapper->pColCmpr[i]; - if (tEncodeI16v(pCoder, p->id) < 0) return -1; - if (tEncodeU32(pCoder, p->alg) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI16v(pCoder, p->id)); + TAOS_CHECK_EXIT(tEncodeU32(pCoder, p->alg)); } - return 0; + +_exit: + return code; } + int32_t tDecodeSColCmprWrapperEx(SDecoder *pDecoder, SColCmprWrapper *pWrapper) { - if (tDecodeI32v(pDecoder, &pWrapper->nCols) < 0) return -1; - if (tDecodeI32v(pDecoder, &pWrapper->version) < 0) return -1; + int32_t code = 0; + int32_t lino; + + TAOS_CHECK_EXIT(tDecodeI32v(pDecoder, &pWrapper->nCols)); + TAOS_CHECK_EXIT(tDecodeI32v(pDecoder, &pWrapper->version)); pWrapper->pColCmpr = (SColCmpr *)tDecoderMalloc(pDecoder, pWrapper->nCols * sizeof(SColCmpr)); - if (pWrapper->pColCmpr == NULL) return -1; + if (pWrapper->pColCmpr == NULL) { + TAOS_CHECK_EXIT(terrno); + } for (int i = 0; i < pWrapper->nCols; i++) { SColCmpr *p = &pWrapper->pColCmpr[i]; - if (tDecodeI16v(pDecoder, &p->id) < 0) goto END; - if (tDecodeU32(pDecoder, &p->alg) < 0) goto END; + TAOS_CHECK_EXIT(tDecodeI16v(pDecoder, &p->id)); + TAOS_CHECK_EXIT(tDecodeU32(pDecoder, &p->alg)); } - return 0; -END: - taosMemoryFree(pWrapper->pColCmpr); - return -1; + +_exit: + if (code) { + taosMemoryFree(pWrapper->pColCmpr); + } + return code; } + int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; + int32_t code = 0; + int32_t lino; - if (tEncodeCStr(pCoder, pReq->name) < 0) return -1; - if (tEncodeI64(pCoder, pReq->suid) < 0) return -1; - if (tEncodeI8(pCoder, pReq->rollup) < 0) return -1; - if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaRow) < 0) return -1; - if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(pCoder)); + + TAOS_CHECK_EXIT(tEncodeCStr(pCoder, pReq->name)); + TAOS_CHECK_EXIT(tEncodeI64(pCoder, pReq->suid)); + TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->rollup)); + TAOS_CHECK_EXIT(tEncodeSSchemaWrapper(pCoder, &pReq->schemaRow)); + TAOS_CHECK_EXIT(tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag)); if (pReq->rollup) { - if (tEncodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeSRSmaParam(pCoder, &pReq->rsmaParam)); } - if (tEncodeI32(pCoder, pReq->alterOriDataLen) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(pCoder, pReq->alterOriDataLen)); if (pReq->alterOriDataLen > 0) { - if (tEncodeBinary(pCoder, pReq->alterOriData, pReq->alterOriDataLen) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeBinary(pCoder, pReq->alterOriData, pReq->alterOriDataLen)); } - if (tEncodeI8(pCoder, pReq->source) < 0) return -1; - - if (tEncodeI8(pCoder, pReq->colCmpred) < 0) return -1; - if (tEncodeSColCmprWrapper(pCoder, &pReq->colCmpr) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->source)); + TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->colCmpred)); + TAOS_CHECK_EXIT(tEncodeSColCmprWrapper(pCoder, &pReq->colCmpr)); tEndEncode(pCoder); - return 0; + +_exit: + return code; } int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; + int32_t code = 0; + int32_t lino; - if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1; - if (tDecodeI8(pCoder, &pReq->rollup) < 0) return -1; - if (tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaRow) < 0) return -1; - if (tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaTag) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(pCoder)); + + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pReq->name)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pReq->suid)); + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pReq->rollup)); + TAOS_CHECK_EXIT(tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaRow)); + TAOS_CHECK_EXIT(tDecodeSSchemaWrapperEx(pCoder, &pReq->schemaTag)); if (pReq->rollup) { - if (tDecodeSRSmaParam(pCoder, &pReq->rsmaParam) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeSRSmaParam(pCoder, &pReq->rsmaParam)); } - if (tDecodeI32(pCoder, &pReq->alterOriDataLen) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->alterOriDataLen)); if (pReq->alterOriDataLen > 0) { - if (tDecodeBinary(pCoder, (uint8_t **)&pReq->alterOriData, NULL) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeBinary(pCoder, (uint8_t **)&pReq->alterOriData, NULL)); } if (!tDecodeIsEnd(pCoder)) { - if (tDecodeI8(pCoder, &pReq->source) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pReq->source)); if (!tDecodeIsEnd(pCoder)) { - if (tDecodeI8(pCoder, &pReq->colCmpred) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pReq->colCmpred)); } if (!tDecodeIsEnd(pCoder)) { - if (tDecodeSColCmprWrapperEx(pCoder, &pReq->colCmpr) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeSColCmprWrapperEx(pCoder, &pReq->colCmpr)); } } - tEndDecode(pCoder); - return 0; + +_exit: + return code; } int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; + int32_t code = 0; + int32_t lino; - if (tEncodeI32v(pCoder, pReq->flags) < 0) return -1; - if (tEncodeCStr(pCoder, pReq->name) < 0) return -1; - if (tEncodeI64(pCoder, pReq->uid) < 0) return -1; - if (tEncodeI64(pCoder, pReq->btime) < 0) return -1; - if (tEncodeI32(pCoder, pReq->ttl) < 0) return -1; - if (tEncodeI8(pCoder, pReq->type) < 0) return -1; - if (tEncodeI32(pCoder, pReq->commentLen) < 0) return -1; + TAOS_CHECK_EXIT(tStartEncode(pCoder)); + + TAOS_CHECK_EXIT(tEncodeI32v(pCoder, pReq->flags)); + TAOS_CHECK_EXIT(tEncodeCStr(pCoder, pReq->name)); + TAOS_CHECK_EXIT(tEncodeI64(pCoder, pReq->uid)); + TAOS_CHECK_EXIT(tEncodeI64(pCoder, pReq->btime)); + TAOS_CHECK_EXIT(tEncodeI32(pCoder, pReq->ttl)); + TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->type)); + TAOS_CHECK_EXIT(tEncodeI32(pCoder, pReq->commentLen)); if (pReq->commentLen > 0) { - if (tEncodeCStr(pCoder, pReq->comment) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(pCoder, pReq->comment)); } if (pReq->type == TSDB_CHILD_TABLE) { - if (tEncodeCStr(pCoder, pReq->ctb.stbName) < 0) return -1; - if (tEncodeU8(pCoder, pReq->ctb.tagNum) < 0) return -1; - if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1; - if (tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(pCoder, pReq->ctb.stbName)); + TAOS_CHECK_EXIT(tEncodeU8(pCoder, pReq->ctb.tagNum)); + TAOS_CHECK_EXIT(tEncodeI64(pCoder, pReq->ctb.suid)); + TAOS_CHECK_EXIT(tEncodeTag(pCoder, (const STag *)pReq->ctb.pTag)); int32_t len = taosArrayGetSize(pReq->ctb.tagName); - if (tEncodeI32(pCoder, len) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(pCoder, len)); for (int32_t i = 0; i < len; i++) { char *name = taosArrayGet(pReq->ctb.tagName, i); - if (tEncodeCStr(pCoder, name) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeCStr(pCoder, name)); } } else if (pReq->type == TSDB_NORMAL_TABLE) { - if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schemaRow)); } else { return TSDB_CODE_INVALID_MSG; } // ENCODESQL - if (tEncodeI32(pCoder, pReq->sqlLen) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeI32(pCoder, pReq->sqlLen)); if (pReq->sqlLen > 0) { - if (tEncodeBinary(pCoder, pReq->sql, pReq->sqlLen) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeBinary(pCoder, pReq->sql, pReq->sqlLen)); } // Encode Column Options: encode compress level if (pReq->type == TSDB_SUPER_TABLE || pReq->type == TSDB_NORMAL_TABLE) { - if (tEncodeSColCmprWrapper(pCoder, &pReq->colCmpr) < 0) return -1; + TAOS_CHECK_EXIT(tEncodeSColCmprWrapper(pCoder, &pReq->colCmpr)); } tEndEncode(pCoder); - return 0; +_exit: + return code; } int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; + int32_t code = 0; + int32_t lino; - if (tDecodeI32v(pCoder, &pReq->flags) < 0) return -1; - if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->uid) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->btime) < 0) return -1; - if (tDecodeI32(pCoder, &pReq->ttl) < 0) return -1; - if (tDecodeI8(pCoder, &pReq->type) < 0) return -1; - if (tDecodeI32(pCoder, &pReq->commentLen) < 0) return -1; + TAOS_CHECK_EXIT(tStartDecode(pCoder)); + + TAOS_CHECK_EXIT(tDecodeI32v(pCoder, &pReq->flags)); + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pReq->name)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pReq->uid)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pReq->btime)); + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->ttl)); + TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pReq->type)); + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->commentLen)); if (pReq->commentLen > 0) { pReq->comment = taosMemoryMalloc(pReq->commentLen + 1); if (pReq->comment == NULL) return -1; - if (tDecodeCStrTo(pCoder, pReq->comment) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStrTo(pCoder, pReq->comment)); } if (pReq->type == TSDB_CHILD_TABLE) { - if (tDecodeCStr(pCoder, &pReq->ctb.stbName) < 0) return -1; - if (tDecodeU8(pCoder, &pReq->ctb.tagNum) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1; - if (tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &pReq->ctb.stbName)); + TAOS_CHECK_EXIT(tDecodeU8(pCoder, &pReq->ctb.tagNum)); + TAOS_CHECK_EXIT(tDecodeI64(pCoder, &pReq->ctb.suid)); + TAOS_CHECK_EXIT(tDecodeTag(pCoder, (STag **)&pReq->ctb.pTag)); int32_t len = 0; - if (tDecodeI32(pCoder, &len) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &len)); pReq->ctb.tagName = taosArrayInit(len, TSDB_COL_NAME_LEN); - if (pReq->ctb.tagName == NULL) return -1; + if (pReq->ctb.tagName == NULL) { + TAOS_CHECK_EXIT(terrno); + } for (int32_t i = 0; i < len; i++) { char name[TSDB_COL_NAME_LEN] = {0}; char *tmp = NULL; - if (tDecodeCStr(pCoder, &tmp) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &tmp)); strncpy(name, tmp, TSDB_COL_NAME_LEN - 1); - if (taosArrayPush(pReq->ctb.tagName, name) == NULL) return -1; + if (taosArrayPush(pReq->ctb.tagName, name) == NULL) { + TAOS_CHECK_EXIT(terrno); + } } } else if (pReq->type == TSDB_NORMAL_TABLE) { - if (tDecodeSSchemaWrapperEx(pCoder, &pReq->ntb.schemaRow) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeSSchemaWrapperEx(pCoder, &pReq->ntb.schemaRow)); } else { return TSDB_CODE_INVALID_MSG; } // DECODESQL if (!tDecodeIsEnd(pCoder)) { - if (tDecodeI32(pCoder, &pReq->sqlLen) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeI32(pCoder, &pReq->sqlLen)); if (pReq->sqlLen > 0) { - if (tDecodeBinaryAlloc(pCoder, (void **)&pReq->sql, NULL) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeBinaryAlloc(pCoder, (void **)&pReq->sql, NULL)); } if (pReq->type == TSDB_NORMAL_TABLE || pReq->type == TSDB_SUPER_TABLE) if (!tDecodeIsEnd(pCoder)) { - if (tDecodeSColCmprWrapperEx(pCoder, &pReq->colCmpr) < 0) return -1; + TAOS_CHECK_EXIT(tDecodeSColCmprWrapperEx(pCoder, &pReq->colCmpr)); } } tEndDecode(pCoder); - return 0; +_exit: + return code; } void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) { @@ -9691,31 +9812,32 @@ void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) { int tEncodeSVCreateTbBatchReq(SEncoder *pCoder, const SVCreateTbBatchReq *pReq) { int32_t nReq = taosArrayGetSize(pReq->pArray); - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI32v(pCoder, nReq) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI32v(pCoder, nReq)); for (int iReq = 0; iReq < nReq; iReq++) { - if (tEncodeSVCreateTbReq(pCoder, (SVCreateTbReq *)taosArrayGet(pReq->pArray, iReq)) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSVCreateTbReq(pCoder, (SVCreateTbReq *)taosArrayGet(pReq->pArray, iReq))); } - if (tEncodeI8(pCoder, pReq->source) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pReq->source)); tEndEncode(pCoder); return 0; } int tDecodeSVCreateTbBatchReq(SDecoder *pCoder, SVCreateTbBatchReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); - if (tDecodeI32v(pCoder, &pReq->nReqs) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pReq->nReqs)); pReq->pReqs = (SVCreateTbReq *)tDecoderMalloc(pCoder, sizeof(SVCreateTbReq) * pReq->nReqs); - if (pReq->pReqs == NULL) return -1; + if (pReq->pReqs == NULL) { + TAOS_CHECK_RETURN(terrno); + } for (int iReq = 0; iReq < pReq->nReqs; iReq++) { - if (tDecodeSVCreateTbReq(pCoder, pReq->pReqs + iReq) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeSVCreateTbReq(pCoder, pReq->pReqs + iReq)); } if (!tDecodeIsEnd(pCoder)) { - if (tDecodeI8(pCoder, &pReq->source) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pReq->source)); } tEndDecode(pCoder); @@ -9735,12 +9857,12 @@ void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq *pReq) { } int tEncodeSVCreateTbRsp(SEncoder *pCoder, const SVCreateTbRsp *pRsp) { - if (tStartEncode(pCoder) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); - if (tEncodeI32(pCoder, pRsp->code) < 0) return -1; - if (tEncodeI32(pCoder, pRsp->pMeta ? 1 : 0) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pRsp->code)); + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pRsp->pMeta ? 1 : 0)); if (pRsp->pMeta) { - if (tEncodeSTableMetaRsp(pCoder, pRsp->pMeta) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSTableMetaRsp(pCoder, pRsp->pMeta)); } tEndEncode(pCoder); @@ -9748,16 +9870,18 @@ int tEncodeSVCreateTbRsp(SEncoder *pCoder, const SVCreateTbRsp *pRsp) { } int tDecodeSVCreateTbRsp(SDecoder *pCoder, SVCreateTbRsp *pRsp) { - if (tStartDecode(pCoder) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); - if (tDecodeI32(pCoder, &pRsp->code) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pRsp->code)); int32_t meta = 0; - if (tDecodeI32(pCoder, &meta) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeI32(pCoder, &meta)); if (meta) { pRsp->pMeta = taosMemoryCalloc(1, sizeof(STableMetaRsp)); - if (NULL == pRsp->pMeta) return -1; - if (tDecodeSTableMetaRsp(pCoder, pRsp->pMeta) < 0) return -1; + if (NULL == pRsp->pMeta) { + TAOS_CHECK_RETURN(terrno); + } + TAOS_CHECK_RETURN(tDecodeSTableMetaRsp(pCoder, pRsp->pMeta)); } else { pRsp->pMeta = NULL; } @@ -9781,41 +9905,35 @@ void tFreeSVCreateTbRsp(void *param) { // TDMT_VND_DROP_TABLE ================= static int32_t tEncodeSVDropTbReq(SEncoder *pCoder, const SVDropTbReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeCStr(pCoder, pReq->name) < 0) return -1; - if (tEncodeU64(pCoder, pReq->suid) < 0) return -1; - if (tEncodeI8(pCoder, pReq->igNotExists) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pReq->name)); + TAOS_CHECK_RETURN(tEncodeU64(pCoder, pReq->suid)); + TAOS_CHECK_RETURN(tEncodeI8(pCoder, pReq->igNotExists)); tEndEncode(pCoder); return 0; } static int32_t tDecodeSVDropTbReq(SDecoder *pCoder, SVDropTbReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1; - if (tDecodeU64(pCoder, &pReq->suid) < 0) return -1; - if (tDecodeI8(pCoder, &pReq->igNotExists) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pReq->name)); + TAOS_CHECK_RETURN(tDecodeU64(pCoder, &pReq->suid)); + TAOS_CHECK_RETURN(tDecodeI8(pCoder, &pReq->igNotExists)); tEndDecode(pCoder); return 0; } static int32_t tEncodeSVDropTbRsp(SEncoder *pCoder, const SVDropTbRsp *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI32(pCoder, pReq->code) < 0) return -1; - + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI32(pCoder, pReq->code)); tEndEncode(pCoder); return 0; } static int32_t tDecodeSVDropTbRsp(SDecoder *pCoder, SVDropTbRsp *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI32(pCoder, &pReq->code) < 0) return -1; - + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeI32(pCoder, &pReq->code)); tEndDecode(pCoder); return 0; } @@ -9824,12 +9942,11 @@ int32_t tEncodeSVDropTbBatchReq(SEncoder *pCoder, const SVDropTbBatchReq *pReq) int32_t nReqs = taosArrayGetSize(pReq->pArray); SVDropTbReq *pDropTbReq; - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI32v(pCoder, nReqs) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI32v(pCoder, nReqs)); for (int iReq = 0; iReq < nReqs; iReq++) { pDropTbReq = (SVDropTbReq *)taosArrayGet(pReq->pArray, iReq); - if (tEncodeSVDropTbReq(pCoder, pDropTbReq) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSVDropTbReq(pCoder, pDropTbReq)); } tEndEncode(pCoder); @@ -9837,13 +9954,14 @@ int32_t tEncodeSVDropTbBatchReq(SEncoder *pCoder, const SVDropTbBatchReq *pReq) } int32_t tDecodeSVDropTbBatchReq(SDecoder *pCoder, SVDropTbBatchReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI32v(pCoder, &pReq->nReqs) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pReq->nReqs)); pReq->pReqs = (SVDropTbReq *)tDecoderMalloc(pCoder, sizeof(SVDropTbReq) * pReq->nReqs); - if (pReq->pReqs == NULL) return -1; + if (pReq->pReqs == NULL) { + TAOS_CHECK_RETURN(terrno); + } for (int iReq = 0; iReq < pReq->nReqs; iReq++) { - if (tDecodeSVDropTbReq(pCoder, pReq->pReqs + iReq) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeSVDropTbReq(pCoder, pReq->pReqs + iReq)); } tEndDecode(pCoder); @@ -9852,11 +9970,10 @@ int32_t tDecodeSVDropTbBatchReq(SDecoder *pCoder, SVDropTbBatchReq *pReq) { int32_t tEncodeSVDropTbBatchRsp(SEncoder *pCoder, const SVDropTbBatchRsp *pRsp) { int32_t nRsps = taosArrayGetSize(pRsp->pArray); - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeI32v(pCoder, nRsps) < 0) return -1; + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeI32v(pCoder, nRsps)); for (int iRsp = 0; iRsp < nRsps; iRsp++) { - if (tEncodeSVDropTbRsp(pCoder, (SVDropTbRsp *)taosArrayGet(pRsp->pArray, iRsp)) < 0) return -1; + TAOS_CHECK_RETURN(tEncodeSVDropTbRsp(pCoder, (SVDropTbRsp *)taosArrayGet(pRsp->pArray, iRsp))); } tEndEncode(pCoder); @@ -9864,13 +9981,14 @@ int32_t tEncodeSVDropTbBatchRsp(SEncoder *pCoder, const SVDropTbBatchRsp *pRsp) } int32_t tDecodeSVDropTbBatchRsp(SDecoder *pCoder, SVDropTbBatchRsp *pRsp) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeI32v(pCoder, &pRsp->nRsps) < 0) return -1; + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeI32v(pCoder, &pRsp->nRsps)); pRsp->pRsps = (SVDropTbRsp *)tDecoderMalloc(pCoder, sizeof(SVDropTbRsp) * pRsp->nRsps); - if (pRsp->pRsps == NULL) return -1; + if (pRsp->pRsps == NULL) { + TAOS_CHECK_RETURN(terrno); + } for (int iRsp = 0; iRsp < pRsp->nRsps; iRsp++) { - if (tDecodeSVDropTbRsp(pCoder, pRsp->pRsps + iRsp) < 0) return -1; + TAOS_CHECK_RETURN(tDecodeSVDropTbRsp(pCoder, pRsp->pRsps + iRsp)); } tEndDecode(pCoder); @@ -9878,57 +9996,21 @@ int32_t tDecodeSVDropTbBatchRsp(SDecoder *pCoder, SVDropTbBatchRsp *pRsp) { } int32_t tEncodeSVDropStbReq(SEncoder *pCoder, const SVDropStbReq *pReq) { - if (tStartEncode(pCoder) < 0) return -1; - - if (tEncodeCStr(pCoder, pReq->name) < 0) return -1; - if (tEncodeI64(pCoder, pReq->suid) < 0) return -1; - + TAOS_CHECK_RETURN(tStartEncode(pCoder)); + TAOS_CHECK_RETURN(tEncodeCStr(pCoder, pReq->name)); + TAOS_CHECK_RETURN(tEncodeI64(pCoder, pReq->suid)); tEndEncode(pCoder); return 0; } int32_t tDecodeSVDropStbReq(SDecoder *pCoder, SVDropStbReq *pReq) { - if (tStartDecode(pCoder) < 0) return -1; - - if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1; - if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1; - + TAOS_CHECK_RETURN(tStartDecode(pCoder)); + TAOS_CHECK_RETURN(tDecodeCStr(pCoder, &pReq->name)); + TAOS_CHECK_RETURN(tDecodeI64(pCoder, &pReq->suid)); tEndDecode(pCoder); return 0; } -// static int32_t tEncodeSVSubmitBlk(SEncoder *pCoder, const SVSubmitBlk *pBlock, int32_t flags) { -// if (tStartEncode(pCoder) < 0) return -1; - -// if (tEncodeI64(pCoder, pBlock->suid) < 0) return -1; -// if (tEncodeI64(pCoder, pBlock->uid) < 0) return -1; -// if (tEncodeI32v(pCoder, pBlock->sver) < 0) return -1; -// if (tEncodeBinary(pCoder, pBlock->pData, pBlock->nData) < 0) return -1; - -// if (flags & TD_AUTO_CREATE_TABLE) { -// if (tEncodeSVCreateTbReq(pCoder, &pBlock->cTbReq) < 0) return -1; -// } - -// tEndEncode(pCoder); -// return 0; -// } - -// static int32_t tDecodeSVSubmitBlk(SDecoder *pCoder, SVSubmitBlk *pBlock, int32_t flags) { -// if (tStartDecode(pCoder) < 0) return -1; - -// if (tDecodeI64(pCoder, &pBlock->suid) < 0) return -1; -// if (tDecodeI64(pCoder, &pBlock->uid) < 0) return -1; -// if (tDecodeI32v(pCoder, &pBlock->sver) < 0) return -1; -// if (tDecodeBinary(pCoder, &pBlock->pData, &pBlock->nData) < 0) return -1; - -// if (flags & TD_AUTO_CREATE_TABLE) { -// if (tDecodeSVCreateTbReq(pCoder, &pBlock->cTbReq) < 0) return -1; -// } - -// tEndDecode(pCoder); -// return 0; -// } - static int32_t tEncodeSSubmitBlkRsp(SEncoder *pEncoder, const SSubmitBlkRsp *pBlock) { if (tStartEncode(pEncoder) < 0) return -1; From ae530db81889a2e5954df328d3b8c2741ba12774 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 15:28:13 +0800 Subject: [PATCH 24/26] fix windows make error --- include/libs/monitorfw/taos_counter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libs/monitorfw/taos_counter.h b/include/libs/monitorfw/taos_counter.h index 7797c695ab..a9d196d8ec 100644 --- a/include/libs/monitorfw/taos_counter.h +++ b/include/libs/monitorfw/taos_counter.h @@ -15,8 +15,8 @@ #ifndef TAOS_COUNTER_H #define TAOS_COUNTER_H +#include #include -#include "os.h" #include "taos_metric.h" From 5503e07181f8587c49a43860ffeed243a442a885 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 15:57:23 +0800 Subject: [PATCH 25/26] fix: ut error code --- source/libs/parser/test/parSelectTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 028bb8f910..61d9134f41 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -366,9 +366,9 @@ TEST_F(ParserSelectTest, semanticCheck) { run("SELECT t1.c1, t1.cc1 FROM t1", TSDB_CODE_PAR_INVALID_COLUMN); // TSDB_CODE_PAR_GET_META_ERROR - run("SELECT * FROM t10", TSDB_CODE_PAR_GET_META_ERROR); + run("SELECT * FROM t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); - run("SELECT * FROM test.t10", TSDB_CODE_PAR_GET_META_ERROR); + run("SELECT * FROM test.t10", TSDB_CODE_PAR_TABLE_NOT_EXIST); // TSDB_CODE_PAR_TABLE_NOT_EXIST run("SELECT t2.c1 FROM t1", TSDB_CODE_PAR_TABLE_NOT_EXIST); From 84a54f88f62187567140baf5c9d94437e0a0e5e7 Mon Sep 17 00:00:00 2001 From: xiao77 Date: Thu, 5 Sep 2024 16:09:44 +0800 Subject: [PATCH 26/26] fix windows make error --- source/libs/monitorfw/inc/taos_metric_formatter_i.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libs/monitorfw/inc/taos_metric_formatter_i.h b/source/libs/monitorfw/inc/taos_metric_formatter_i.h index 5c330b50e7..54e683fa91 100644 --- a/source/libs/monitorfw/inc/taos_metric_formatter_i.h +++ b/source/libs/monitorfw/inc/taos_metric_formatter_i.h @@ -16,6 +16,7 @@ #ifndef TAOS_METRIC_FORMATTER_I_H #define TAOS_METRIC_FORMATTER_I_H +#include // Private #include "taos_metric_formatter_t.h"