From 4a563b6d50c310077c1c52c5933b6065cb32fcad Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 6 Sep 2022 19:17:11 +0800 Subject: [PATCH 1/2] fix: fix now in alter tag value --- source/libs/executor/src/executil.c | 1 - source/libs/parser/src/parTranslater.c | 23 ++++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 3965b7e5b2..69951e5e1c 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -475,7 +475,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray if (code != TSDB_CODE_SUCCESS) { terrno = code; qError("failed to create result, reason:%s", tstrerror(code)); - terrno = code; goto end; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 240aa0d6c0..bebc2e3e1d 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6603,11 +6603,32 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS } pReq->colId = pSchema->colId; + SValueNode *pVal = NULL; + SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); - if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) { + pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal); + if (pCxt->errCode) { return pCxt->errCode; } +/* + if (QUERY_NODE_FUNCTION == pStmt->pVal->node.type) { + pCxt->errCode = getFuncInfo(pCxt, (SFunctionNode*)pStmt->pVal); + if (pCxt->errCode) { + return pCxt->errCode; + } + + if (DEAL_RES_ERROR == translateFunctionImpl(pCxt, (SFunctionNode**)&pStmt->pVal)) { + return pCxt->errCode; + } + } else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) { + return pCxt->errCode; + } +*/ + + nodesDestroyNode((SNode*)pStmt->pVal); + + pStmt->pVal = pVal; pReq->tagType = targetDt.type; if (targetDt.type == TSDB_DATA_TYPE_JSON) { if (pStmt->pVal->literal && From 851ffe49aea50de8d2dd02eb7bff3788ddb2cf60 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 7 Sep 2022 10:25:21 +0800 Subject: [PATCH 2/2] enh: support set tag value with expr --- source/libs/parser/src/parTranslater.c | 23 ++++++----------------- source/util/test/pageBufferTest.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index bebc2e3e1d..ad9a467dee 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6603,32 +6603,21 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS } pReq->colId = pSchema->colId; - SValueNode *pVal = NULL; - SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); - pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal); - if (pCxt->errCode) { - return pCxt->errCode; - } -/* - if (QUERY_NODE_FUNCTION == pStmt->pVal->node.type) { - pCxt->errCode = getFuncInfo(pCxt, (SFunctionNode*)pStmt->pVal); + if (QUERY_NODE_VALUE != pStmt->pVal->node.type) { + SValueNode *pVal = NULL; + pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal); if (pCxt->errCode) { return pCxt->errCode; } - - if (DEAL_RES_ERROR == translateFunctionImpl(pCxt, (SFunctionNode**)&pStmt->pVal)) { - return pCxt->errCode; - } + + nodesDestroyNode((SNode*)pStmt->pVal); + pStmt->pVal = pVal; } else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) { return pCxt->errCode; } -*/ - nodesDestroyNode((SNode*)pStmt->pVal); - - pStmt->pVal = pVal; pReq->tagType = targetDt.type; if (targetDt.type == TSDB_DATA_TYPE_JSON) { if (pStmt->pVal->literal && diff --git a/source/util/test/pageBufferTest.cpp b/source/util/test/pageBufferTest.cpp index 1a057c5875..534c177587 100644 --- a/source/util/test/pageBufferTest.cpp +++ b/source/util/test/pageBufferTest.cpp @@ -23,9 +23,9 @@ void simpleTest() { ASSERT_EQ(getTotalBufSize(pBuf), 1024); - SIDList list = getDataBufPagesIdList(pBuf, groupId); + SIDList list = getDataBufPagesIdList(pBuf); ASSERT_EQ(taosArrayGetSize(list), 1); - ASSERT_EQ(getNumOfBufGroupId(pBuf), 1); + //ASSERT_EQ(getNumOfBufGroupId(pBuf), 1); releaseBufPage(pBuf, pBufPage); @@ -98,7 +98,7 @@ void writeDownTest() { SFilePage* pBufPagex = static_cast(getBufPage(pBuf, writePageId)); ASSERT_EQ(*(int32_t*)pBufPagex->data, nx); - SArray* pa = getDataBufPagesIdList(pBuf, groupId); + SArray* pa = getDataBufPagesIdList(pBuf); ASSERT_EQ(taosArrayGetSize(pa), 5); destroyDiskbasedBuf(pBuf); @@ -152,7 +152,7 @@ void recyclePageTest() { SFilePage* pBufPagex1 = static_cast(getBufPage(pBuf, 1)); - SArray* pa = getDataBufPagesIdList(pBuf, groupId); + SArray* pa = getDataBufPagesIdList(pBuf); ASSERT_EQ(taosArrayGetSize(pa), 6); destroyDiskbasedBuf(pBuf);