From eb9a70975ae47bc227e246300358ffb4db6b88b6 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 4 Jan 2022 16:13:46 +0800 Subject: [PATCH 1/4] feature/qnode --- source/libs/qcom/src/querymsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index f24b191db3..507650159f 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -247,8 +247,8 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { pOut->metaNum = 2; if (pMetaMsg->dbFname[0]) { - snprintf(pOut->ctbFname, "%s.%s", pMetaMsg->dbFname, pMetaMsg->tbFname); - snprintf(pOut->tbFname, "%s.%s", pMetaMsg->dbFname, pMetaMsg->stbFname); + snprintf(pOut->ctbFname, sizeof(pOut->ctbFname), "%s.%s", pMetaMsg->dbFname, pMetaMsg->tbFname); + snprintf(pOut->tbFname, sizeof(pOut->tbFname), "%s.%s", pMetaMsg->dbFname, pMetaMsg->stbFname); } else { memcpy(pOut->ctbFname, pMetaMsg->tbFname, sizeof(pOut->ctbFname)); memcpy(pOut->tbFname, pMetaMsg->stbFname, sizeof(pOut->tbFname)); From c426ae83836191a36931041fa0b146d30ad1852f Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 4 Jan 2022 03:32:48 -0500 Subject: [PATCH 2/4] TD-12696 bug fix for insert --- source/libs/parser/inc/dataBlockMgt.h | 2 +- source/libs/parser/src/insertParser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/parser/inc/dataBlockMgt.h b/source/libs/parser/inc/dataBlockMgt.h index 69dad4d9f4..cd84222c65 100644 --- a/source/libs/parser/inc/dataBlockMgt.h +++ b/source/libs/parser/inc/dataBlockMgt.h @@ -126,7 +126,7 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t memRowTyp int32_t idx, int32_t *toffset) { int32_t schemaIdx = 0; if (IS_DATA_COL_ORDERED(spd)) { - schemaIdx = spd->boundedColumns[idx]; + schemaIdx = spd->boundedColumns[idx] - 1; if (isDataRowT(memRowType)) { *toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart } else { diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c index c0ba4f40b4..cde426fb9a 100644 --- a/source/libs/parser/src/insertParser.c +++ b/source/libs/parser/src/insertParser.c @@ -425,7 +425,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, // 1. set the parsed value from sql string for (int i = 0; i < spd->numOfBound; ++i) { NEXT_TOKEN(pCxt->pSql, sToken); - SSchema *pSchema = &schema[spd->boundedColumns[i]]; + SSchema *pSchema = &schema[spd->boundedColumns[i] - 1]; param.schema = pSchema; param.compareStat = pBuilder->compareStat; getMemRowAppendInfo(schema, pBuilder->memRowType, spd, i, ¶m.toffset); From e5155adcacfe766176d2d2c9fd36f6716693d877 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 4 Jan 2022 04:05:33 -0500 Subject: [PATCH 3/4] TD-12696 bug fix for insert --- source/libs/parser/src/insertParser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c index cde426fb9a..c63e854051 100644 --- a/source/libs/parser/src/insertParser.c +++ b/source/libs/parser/src/insertParser.c @@ -106,6 +106,7 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { SVgroupInfo vg; CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); + pCxt->pTableMeta->vgId = vg.vgId; // todo remove return TSDB_CODE_SUCCESS; } @@ -425,7 +426,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, // 1. set the parsed value from sql string for (int i = 0; i < spd->numOfBound; ++i) { NEXT_TOKEN(pCxt->pSql, sToken); - SSchema *pSchema = &schema[spd->boundedColumns[i] - 1]; + SSchema *pSchema = &schema[spd->boundedColumns[i] - 1]; param.schema = pSchema; param.compareStat = pBuilder->compareStat; getMemRowAppendInfo(schema, pBuilder->memRowType, spd, i, ¶m.toffset); From b15ea75b996d2705ea7f90a44ed98e212cfeb998 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 4 Jan 2022 04:16:32 -0500 Subject: [PATCH 4/4] TD-12696 bug fix for insert --- source/client/src/clientImpl.c | 5 ++++- source/client/src/clientMain.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 71fd8462af..a4750309e8 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -203,7 +203,10 @@ int32_t getPlan(SRequestObj* pRequest, SQueryNode* pQuery, SQueryDag** pDag) { int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag, void** pJob) { if (TSDB_SQL_INSERT == pRequest->type || TSDB_SQL_CREATE_TABLE == pRequest->type) { - return scheduleExecJob(pRequest->pTscObj->pTransporter, NULL/*todo appInfo.xxx*/, pDag, pJob, &pRequest->affectedRows); + SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf}; + int32_t code = scheduleExecJob(pRequest->pTscObj->pTransporter, NULL, pDag, pJob, &res); + pRequest->affectedRows = res.numOfRows; + return res.code; } return scheduleAsyncExecJob(pRequest->pTscObj->pTransporter, NULL/*todo appInfo.xxx*/, pDag, pJob); diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e5f3eba5c2..2b875b3eb5 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -262,6 +262,8 @@ const char *taos_data_type(int type) { const char *taos_get_client_info() { return version; } -int taos_affected_rows(TAOS_RES *res) { return 1; } +int taos_affected_rows(TAOS_RES *res) { + return ((SRequestObj*)res)->affectedRows; +} int taos_result_precision(TAOS_RES *res) { return TSDB_TIME_PRECISION_MILLI; }