From b9471b8115b61224d4f5c832a0216ac76cb84e25 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 28 Mar 2022 11:13:59 +0800 Subject: [PATCH 01/45] [TD-14222] add test for encode/decode ResultRow --- source/libs/executor/src/executorimpl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 2417bd352a..b739ffb2b9 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6363,6 +6363,16 @@ static int32_t doOpenAggregateOptr(SOperatorInfo *pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); doAggregateImpl(pOperator, 0, pInfo->pCtx); + + char *result = NULL; + int32_t length = 0; + pOperator->encodeResultRow(pOperator, &result, &length); + SAggSupporter *pSup = &pAggInfo->aggSup; + taosHashClear(pSup->pResultRowHashTable); + pOperator->decodeResultRow(pOperator, result, length); + if(result){ + free(result); + } } finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput); @@ -6486,7 +6496,7 @@ static bool aggDecodeResultRow(SOperatorInfo* pOperator, char *result, int32_t l initResultRow(resultRow); - pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; + //pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; } if (offset != length){ From c941a2c7109ff651877f362b0ae833236565459f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 29 Mar 2022 18:16:40 +0800 Subject: [PATCH 02/45] add test for encode/decode ResultRow in group by and interval --- include/libs/nodes/nodes.h | 3 +- source/libs/executor/src/executorimpl.c | 76 ++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 411d34063c..9698f0e13e 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -141,7 +141,8 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_DISPATCH, QUERY_NODE_PHYSICAL_PLAN_INSERT, QUERY_NODE_PHYSICAL_SUBPLAN, - QUERY_NODE_PHYSICAL_PLAN + QUERY_NODE_PHYSICAL_PLAN, + QUERY_NODE_PHYSICAL_PLAN_GROUPBY } ENodeType; /** diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 5d6495b52a..5ec5d8cd70 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6346,7 +6346,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo *pOperator) { taosHashClear(pSup->pResultRowHashTable); pOperator->decodeResultRow(pOperator, result, length); if(result){ - free(result); + taosMemoryFree(result); } } @@ -6377,8 +6377,27 @@ static SSDataBlock* getAggregateResult(SOperatorInfo *pOperator, bool* newgroup) } static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t *length) { - SAggOperatorInfo *pAggInfo = pOperator->info; - SAggSupporter *pSup = &pAggInfo->aggSup; + SAggSupporter *pSup = NULL; + switch(pOperator->operatorType){ + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggOperatorInfo *pAggInfo = pOperator->info; + pSup = &pAggInfo->aggSup; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_GROUPBY:{ + SGroupbyOperatorInfo *pAggInfo = pOperator->info; + pSup = &pAggInfo->aggSup; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + STableIntervalOperatorInfo *pAggInfo = pOperator->info; + pSup = &pAggInfo->aggSup; + break; + } + default:{ + qDebug("invalid operatorType: %d", pOperator->operatorType); + } + } int32_t size = taosHashGetSize(pSup->pResultRowHashTable); size_t keyLen = POINTER_BYTES; // estimate the key length @@ -6434,9 +6453,28 @@ static bool aggDecodeResultRow(SOperatorInfo* pOperator, char *result, int32_t l return false; } - SAggOperatorInfo *pAggInfo = pOperator->info; - SAggSupporter *pSup = &pAggInfo->aggSup; - SOptrBasicInfo *pInfo = &pAggInfo->binfo; + SAggSupporter *pSup = NULL; + switch(pOperator->operatorType){ + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggOperatorInfo *pAggInfo = pOperator->info; + //SOptrBasicInfo *pInfo = &pAggInfo->binfo; + pSup = &pAggInfo->aggSup; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_GROUPBY:{ + SGroupbyOperatorInfo *pAggInfo = pOperator->info; + pSup = &pAggInfo->aggSup; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + STableIntervalOperatorInfo *pAggInfo = pOperator->info; + pSup = &pAggInfo->aggSup; + break; + } + default:{ + qDebug("invalid operatorType: %d", pOperator->operatorType); + } + } // int32_t size = taosHashGetSize(pSup->pResultRowHashTable); int32_t count = *(int32_t*)(result); @@ -6733,6 +6771,16 @@ static int32_t doOpenIntervalAgg(SOperatorInfo *pOperator) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); + + char *result = NULL; + int32_t length = 0; + pOperator->encodeResultRow(pOperator, &result, &length); + SAggSupporter *pSup = &pInfo->aggSup; + taosHashClear(pSup->pResultRowHashTable); + pOperator->decodeResultRow(pOperator, result, length); + if(result){ + taosMemoryFree(result); + } } closeAllResultRows(&pInfo->binfo.resultRowInfo); @@ -7149,6 +7197,16 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); // setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput); doHashGroupbyAgg(pOperator, pBlock); + + char *result = NULL; + int32_t length = 0; + pOperator->encodeResultRow(pOperator, &result, &length); + SAggSupporter *pSup = &pInfo->aggSup; + taosHashClear(pSup->pResultRowHashTable); + pOperator->decodeResultRow(pOperator, result, length); + if(result){ + taosMemoryFree(result); + } } pOperator->status = OP_RES_TO_RETURN; @@ -7693,6 +7751,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->_openFn = doOpenIntervalAgg; pOperator->getNextFn = doBuildIntervalResult; pOperator->closeFn = destroyIntervalOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; + pOperator->decodeResultRow = aggDecodeResultRow; code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -7903,13 +7963,15 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pOperator->name = "GroupbyAggOperator"; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; -// pOperator->operatorType = OP_Groupby; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUPBY; pOperator->pExpr = pExprInfo; pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; pOperator->_openFn = operatorDummyOpenFn; pOperator->getNextFn = hashGroupbyAggregate; pOperator->closeFn = destroyGroupbyOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; + pOperator->decodeResultRow = aggDecodeResultRow; code = appendDownstream(pOperator, &downstream, 1); return pOperator; From bceb557809114fd62a896fa7f318a50739b03745 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 30 Mar 2022 10:05:20 +0800 Subject: [PATCH 03/45] rm useless code --- source/libs/executor/src/dataDispatcher.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 34894c235b..e527e3a315 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -125,7 +125,6 @@ static void toDataCacheEntry(const SDataDispatchHandle* pHandle, const SInputDat pBuf->useSize = sizeof(SRetrieveTableRsp); copyData(pInput, pHandle->pSchema, pEntry->data, pEntry->compressed, &pEntry->dataLen); - pEntry->dataLen = pEntry->dataLen; pBuf->useSize += pEntry->dataLen; } From 70980e84b51f09ee8564956df05c5f5ba829d397 Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 7 Apr 2022 10:48:20 +0800 Subject: [PATCH 04/45] add complex sim case --- tests/script/tsim/query/complex_select.sim | 426 +++++++++++++++++++++ 1 file changed, 426 insertions(+) create mode 100644 tests/script/tsim/query/complex_select.sim diff --git a/tests/script/tsim/query/complex_select.sim b/tests/script/tsim/query/complex_select.sim new file mode 100644 index 0000000000..1cb58237c4 --- /dev/null +++ b/tests/script/tsim/query/complex_select.sim @@ -0,0 +1,426 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 2 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now ) + +print =============== insert data into child table ct2 (d) +sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) +sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) +sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) +sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) +sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) +sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now ) +sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now ) + +print =============== insert data into child table ct3 (n) +sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) +sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) +sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) +sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) +sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) +sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) +sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) +sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) +sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) +sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) +sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) +sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) +sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== +print ================ query 1 limit/offset +sql select * from ct1 limit 1 +print ====> sql : select * from ct1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi + +sql select * from ct1 limit 9 +print ====> sql : select * from ct1 limit 9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct1 limit 1 offset 2 +print ====> sql : select * from ct1 limit 1 offset 2 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql select * from ct1 limit 2 offset 1 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from ct1 limit 2 offset 7 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select * from ct1 limit 2 offset 10 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + +sql select c1 from stb1 limit 1 +print ====> sql : select c1 from stb1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 50 +print ====> sql : select c1 from stb1 limit 50 +print ====> rows: $rows +if $rows != 33 then + return -1 +endi + +sql select c1 from stb1 limit 1 offset 2 +print ====> sql : select c1 from stb1 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 1 +print ====> sql : select c1 from stb1 limit 2 offset 1 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 32 +print ====> sql : select c1 from stb1 limit 2 offset 32 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 40 +print ====> sql : select c1 from stb1 limit 2 offset 40 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + +print ================ query 2 where condition +sql select * from ct3 where c1 < 5 +print ====> sql : select * from ct3 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 > 5 and c1 <= 6 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 8 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> sql : select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from ct3 where ts != 0 +sql select * from ct3 where ts <> 0 +print ====> sql : select * from ct3 where ts <> 0 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c1 between 1 and 3 +print ====> sql : select * from ct3 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql_error select * from ct3 where c7 between false and true + +sql select * from ct3 where c1 in (1,2,3) +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql select * from ct3 where c1 in (‘true','false') +print ====> sql : select * from ct3 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c9 like "_char_" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c8 like "bi%" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select c1 from stb1 where c1 < 5 +print ====> sql : select c1 from stb1 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 16 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where stb1 > 5 and c1 <= 6 +print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : sselect c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 32 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> sql : select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 17 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from stb1 where ts != 0 +sql select c1 from stb1 where ts <> 0 +print ====> sql : select c1 from stb1 where ts <> 0 +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c1 between 1 and 3 +print ====> sql : select c1 from stb1 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql_error select c1 from stb1 where c7 between false and true + +sql select c1 from stb1 where c1 in (1,2,3) +print ====> sql : select c1 from stb1 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql select c1 from stb1 where c1 in (‘true','false') +print ====> sql : select c1 from stb1 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c9 like "_char_" +print ====> sql : select c1 from stb1 where c9 like "_char_" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c8 like "bi%" +print ====> sql : select c1 from stb1 where c8 like "bi%" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + + +## TODO : group by +print ================ query 3 group by filter + + + +## TODO : complex +print ================ query 4 scalar function + where + group by + limit/offset + + + + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +#================================================= +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 30def824b64e961cc08858e3ed65f3f0ebabc5a7 Mon Sep 17 00:00:00 2001 From: cpwu Date: Thu, 7 Apr 2022 16:09:38 +0800 Subject: [PATCH 05/45] add group by --- tests/script/tsim/query/complex_select.sim | 123 ++++++++++++++++----- 1 file changed, 94 insertions(+), 29 deletions(-) diff --git a/tests/script/tsim/query/complex_select.sim b/tests/script/tsim/query/complex_select.sim index 1cb58237c4..4a710c4b58 100644 --- a/tests/script/tsim/query/complex_select.sim +++ b/tests/script/tsim/query/complex_select.sim @@ -50,42 +50,42 @@ if $rows != 4 then endi print =============== insert data into child table ct1 (s) -sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) -sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) -sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) -sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) -sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) -sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) -sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now ) -sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now ) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) print =============== insert data into child table ct2 (d) -sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) -sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) -sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) -sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) -sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) -sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now ) -sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now ) +sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a ) +sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a ) print =============== insert data into child table ct3 (n) sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) -sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) -sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) -sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) -sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) -sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) -sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) +sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) print =============== insert data into child table ct4 (y) -sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now ) -sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now ) -sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now ) -sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now ) -sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now ) -sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now ) +sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) @@ -372,12 +372,77 @@ if $rows != 32 then endi -## TODO : group by print ================ query 3 group by filter +sql select count(*) from ct3 group by c1 +print ====> sql : select count(*) from ct3 group by c1 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi +sql select count(*) from ct3 group by c2 +print ====> sql : select count(*) from ct3 group by c2 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi +sql select count(*) from ct3 group by c3 +print ====> sql : select count(*) from ct3 group by c3 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c4 +print ====> sql : select count(*) from ct3 group by c4 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c5 +print ====> sql : select count(*) from ct3 group by c5 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c6 +print ====> sql : select count(*) from ct3 group by c6 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c7 +print ====> sql : select count(*) from ct3 group by c7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select count(*) from ct3 group by c8 +print ====> sql : select count(*) from ct3 group by c8 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c9 +print ====> sql : select count(*) from ct3 group by c9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c10 +print ====> sql : select count(*) from ct3 group by c10 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi -## TODO : complex print ================ query 4 scalar function + where + group by + limit/offset From 36670708b28c1a5b32c6fda2eccecfe62ff978de Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 7 Apr 2022 17:41:16 +0800 Subject: [PATCH 06/45] add create index msg --- include/common/tmsg.h | 43 +-- source/common/src/tmsg.c | 32 ++- source/libs/parser/src/parTranslater.c | 348 +++++++++++++------------ 3 files changed, 231 insertions(+), 192 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a8361582ba..03b1b02987 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -273,11 +273,11 @@ typedef struct { char name[TSDB_COL_NAME_LEN]; } SSchemaEx; -#define SSCHMEA_TYPE(s) ((s)->type) -#define SSCHMEA_SMA(s) ((s)->sma) +#define SSCHMEA_TYPE(s) ((s)->type) +#define SSCHMEA_SMA(s) ((s)->sma) #define SSCHMEA_COLID(s) ((s)->colId) #define SSCHMEA_BYTES(s) ((s)->bytes) -#define SSCHMEA_NAME(s) ((s)->name) +#define SSCHMEA_NAME(s) ((s)->name) typedef struct { char name[TSDB_TABLE_FNAME_LEN]; @@ -934,12 +934,12 @@ typedef struct SExplainExecInfo { uint64_t startupCost; uint64_t totalCost; uint64_t numOfRows; - void *verboseInfo; + void* verboseInfo; } SExplainExecInfo; typedef struct { int32_t numOfPlans; - SExplainExecInfo *subplanInfo; + SExplainExecInfo* subplanInfo; } SExplainRsp; int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp); @@ -989,8 +989,8 @@ int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq typedef struct { int32_t dnodeId; -} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq, SMCreateSnodeReq, SMDropSnodeReq, - SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq; +} SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq, SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, + SMDropBnodeReq, SDCreateBnodeReq, SDDropBnodeReq; int32_t tSerializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq); int32_t tDeserializeSMCreateDropQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq); @@ -1432,12 +1432,12 @@ typedef struct SVCreateTbReq { }; union { struct { - tb_uid_t suid; - col_id_t nCols; - col_id_t nBSmaCols; - SSchemaEx* pSchema; - col_id_t nTagCols; - SSchema* pTagSchema; + tb_uid_t suid; + col_id_t nCols; + col_id_t nBSmaCols; + SSchemaEx* pSchema; + col_id_t nTagCols; + SSchema* pTagSchema; SRSmaParam* pRSmaParam; } stbCfg; struct { @@ -1445,9 +1445,9 @@ typedef struct SVCreateTbReq { SKVRow pTag; } ctbCfg; struct { - col_id_t nCols; - col_id_t nBSmaCols; - SSchemaEx* pSchema; + col_id_t nCols; + col_id_t nBSmaCols; + SSchemaEx* pSchema; SRSmaParam* pRSmaParam; } ntbCfg; }; @@ -2224,6 +2224,13 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) { return buf; } +typedef struct { +} SMCreateFullTextReq; + +int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq); +int32_t tDeserializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq); +void tFreeSMCreateFullTextReq(SMCreateFullTextReq* pReq); + typedef struct { int8_t mqMsgType; int32_t code; @@ -2293,9 +2300,7 @@ static FORCE_INLINE void* tDecodeSMqSubVgEp(void* buf, SMqSubVgEp* pVgEp) { return buf; } -static FORCE_INLINE void tDeleteSMqCMGetSubEpRsp(SMqCMGetSubEpRsp* pRsp) { - taosArrayDestroyEx(pRsp->topics, (void (*)(void*))tDeleteSMqSubTopicEp); -} +static FORCE_INLINE void tDeleteSMqCMGetSubEpRsp(SMqCMGetSubEpRsp* pRsp) { taosArrayDestroyEx(pRsp->topics, (void (*)(void*))tDeleteSMqSubTopicEp); } static FORCE_INLINE int32_t tEncodeSMqSubTopicEp(void** buf, const SMqSubTopicEp* pTopicEp) { int32_t tlen = 0; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index acb77648ae..66cf0d5ed0 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -385,7 +385,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { if (pReq->rollup) { pReq->stbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam)); SRSmaParam *param = pReq->stbCfg.pRSmaParam; - buf = taosDecodeBinaryTo(buf, (void*)¶m->xFilesFactor, sizeof(param->xFilesFactor)); + buf = taosDecodeBinaryTo(buf, (void *)¶m->xFilesFactor, sizeof(param->xFilesFactor)); buf = taosDecodeFixedI32(buf, ¶m->delay); buf = taosDecodeFixedI8(buf, ¶m->nFuncIds); if (param->nFuncIds > 0) { @@ -418,7 +418,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) { if (pReq->rollup) { pReq->ntbCfg.pRSmaParam = (SRSmaParam *)taosMemoryMalloc(sizeof(SRSmaParam)); SRSmaParam *param = pReq->ntbCfg.pRSmaParam; - buf = taosDecodeBinaryTo(buf, (void*)¶m->xFilesFactor, sizeof(param->xFilesFactor)); + buf = taosDecodeBinaryTo(buf, (void *)¶m->xFilesFactor, sizeof(param->xFilesFactor)); buf = taosDecodeFixedI32(buf, ¶m->delay); buf = taosDecodeFixedI8(buf, ¶m->nFuncIds); if (param->nFuncIds > 0) { @@ -808,6 +808,30 @@ int32_t tDeserializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) tCoderClear(&decoder); return 0; } +int32_t tSerializeSMCreateFullTextReq(void *buf, int32_t bufLen, SMCreateFullTextReq *pReq) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + + tEndEncode(&encoder); + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} +int32_t tDeserializeSMCreateFullTextReq(void *buf, int32_t bufLen, SMCreateFullTextReq *pReq) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + if (tStartDecode(&decoder) < 0) return -1; + + tEndDecode(&decoder); + tCoderClear(&decoder); + return 0; +} +void tFreeSMCreateFullTextReq(SMCreateFullTextReq *pReq) { + // impl later + return; +} int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { SCoder encoder = {0}; @@ -2769,7 +2793,7 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq) return 0; } -int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp) { +int32_t tSerializeSExplainRsp(void *buf, int32_t bufLen, SExplainRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -2789,7 +2813,7 @@ int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp) { return tlen; } -int32_t tDeserializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp) { +int32_t tDeserializeSExplainRsp(void *buf, int32_t bufLen, SExplainRsp *pRsp) { SCoder decoder = {0}; tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 35166b47fa..a53e0b8285 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -22,16 +22,16 @@ #include "ttime.h" typedef struct STranslateContext { - SParseContext* pParseCxt; - int32_t errCode; - SMsgBuf msgBuf; - SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* - int32_t currLevel; - ESqlClause currClause; - SSelectStmt* pCurrStmt; - SCmdMsgInfo* pCmdMsg; - SHashObj* pDbs; - SHashObj* pTables; + SParseContext* pParseCxt; + int32_t errCode; + SMsgBuf msgBuf; + SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* + int32_t currLevel; + ESqlClause currClause; + SSelectStmt* pCurrStmt; + SCmdMsgInfo* pCmdMsg; + SHashObj* pDbs; + SHashObj* pTables; SExplainOptions* pExplainOpt; } STranslateContext; @@ -42,19 +42,15 @@ typedef struct SFullDatabaseName { static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode); static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode); -static bool afterGroupBy(ESqlClause clause) { - return clause > SQL_CLAUSE_GROUP_BY; -} +static bool afterGroupBy(ESqlClause clause) { return clause > SQL_CLAUSE_GROUP_BY; } -static bool beforeHaving(ESqlClause clause) { - return clause < SQL_CLAUSE_HAVING; -} +static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; } -#define generateDealNodeErrMsg(pCxt, code, ...) \ - ({ \ +#define generateDealNodeErrMsg(pCxt, code, ...) \ + ({ \ generateSyntaxErrMsg(&pCxt->msgBuf, code, ##__VA_ARGS__); \ - pCxt->errCode = code; \ - DEAL_RES_ERROR; \ + pCxt->errCode = code; \ + DEAL_RES_ERROR; \ }) static int32_t addNamespace(STranslateContext* pCxt, void* pTable) { @@ -103,7 +99,7 @@ static int32_t collectUseTable(const SName* pName, SHashObj* pDbs) { static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STableMeta** pMeta) { SParseContext* pParCxt = pCxt->pParseCxt; - int32_t code = collectUseDatabase(pName, pCxt->pDbs); + int32_t code = collectUseDatabase(pName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(pName, pCxt->pTables); } @@ -111,13 +107,14 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa code = catalogGetTableMeta(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pMeta); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); + parserError("catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, + pName->tname); } return code; } static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName, STableMeta** pMeta) { - SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pDbName); strcpy(name.tname, pTableName); return getTableMetaImpl(pCxt, &name, pMeta); @@ -125,7 +122,7 @@ static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const static int32_t getTableDistVgInfo(STranslateContext* pCxt, const SName* pName, SArray** pVgInfo) { SParseContext* pParCxt = pCxt->pParseCxt; - int32_t code = collectUseDatabase(pName, pCxt->pDbs); + int32_t code = collectUseDatabase(pName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(pName, pCxt->pTables); } @@ -133,14 +130,15 @@ static int32_t getTableDistVgInfo(STranslateContext* pCxt, const SName* pName, S code = catalogGetTableDistVgInfo(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pVgInfo); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); + parserError("catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, + pName->tname); } return code; } static int32_t getDBVgInfoImpl(STranslateContext* pCxt, const SName* pName, SArray** pVgInfo) { SParseContext* pParCxt = pCxt->pParseCxt; - char fullDbName[TSDB_DB_FNAME_LEN]; + char fullDbName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pName, fullDbName); int32_t code = collectUseDatabaseImpl(fullDbName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { @@ -162,7 +160,7 @@ static int32_t getDBVgInfo(STranslateContext* pCxt, const char* pDbName, SArray* static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pName, SVgroupInfo* pInfo) { SParseContext* pParCxt = pCxt->pParseCxt; - int32_t code = collectUseDatabase(pName, pCxt->pDbs); + int32_t code = collectUseDatabase(pName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { code = collectUseTable(pName, pCxt->pTables); } @@ -170,21 +168,24 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam code = catalogGetTableHashVgroup(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pInfo); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); + parserError("catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, + pName->tname); } return code; } -static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName, SVgroupInfo* pInfo) { - SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; +static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName, + SVgroupInfo* pInfo) { + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pDbName); strcpy(name.tname, pTableName); return getTableHashVgroupImpl(pCxt, &name, pInfo); } -static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, int32_t* pTableNum) { +static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, + int32_t* pTableNum) { SParseContext* pParCxt = pCxt->pParseCxt; - int32_t code = collectUseDatabaseImpl(pDbFName, pCxt->pDbs); + int32_t code = collectUseDatabaseImpl(pDbFName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { code = catalogGetDBVgVersion(pParCxt->pCatalog, pDbFName, pVersion, pDbId, pTableNum); } @@ -214,7 +215,8 @@ static SNodeList* getProjectList(SNode* pNode) { return NULL; } -static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, bool isTag, SColumnNode* pCol) { +static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, bool isTag, + SColumnNode* pCol) { strcpy(pCol->dbName, pTable->table.dbName); strcpy(pCol->tableAlias, pTable->table.tableAlias); strcpy(pCol->tableName, pTable->table.tableName); @@ -251,7 +253,8 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode* pTable, SNodeList* pList) { if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; - int32_t nums = pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0); + int32_t nums = + pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0); for (int32_t i = 0; i < nums; ++i) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -262,7 +265,7 @@ static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode } } else { SNodeList* pProjectList = getProjectList(((STempTableNode*)pTable)->pSubquery); - SNode* pNode; + SNode* pNode; FOREACH(pNode, pProjectList) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -293,7 +296,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { } } else { SNodeList* pProjectList = getProjectList(((STempTableNode*)pTable)->pSubquery); - SNode* pNode; + SNode* pNode; FOREACH(pNode, pProjectList) { SExprNode* pExpr = (SExprNode*)pNode; if (0 == strcmp(pCol->colName, pExpr->aliasName)) { @@ -308,8 +311,8 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); - size_t nums = taosArrayGetSize(pTables); - bool foundTable = false; + size_t nums = taosArrayGetSize(pTables); + bool foundTable = false; for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); if (belongTable(pCxt->pParseCxt->db, pCol, pTable)) { @@ -328,8 +331,8 @@ static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); - size_t nums = taosArrayGetSize(pTables); - bool found = false; + size_t nums = taosArrayGetSize(pTables); + bool found = false; for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); if (findAndSetColumn(pCol, pTable)) { @@ -347,12 +350,12 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) { SNodeList* pProjectionList = pCxt->pCurrStmt->pProjectionList; - SNode* pNode; + SNode* pNode; FOREACH(pNode, pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; if (0 == strcmp(pCol->colName, pExpr->aliasName)) { - setColumnInfoByExpr(NULL, pExpr, pCol); - return true; + setColumnInfoByExpr(NULL, pExpr, pCol); + return true; } } return false; @@ -375,7 +378,8 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { - if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { + if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, + pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } } else { @@ -419,7 +423,8 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { break; } case TSDB_DATA_TYPE_TIMESTAMP: { - if (taosParseTime(pVal->literal, &pVal->datum.i, pVal->node.resType.bytes, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) { + if (taosParseTime(pVal->literal, &pVal->datum.i, pVal->node.resType.bytes, pVal->node.resType.precision, + tsDaylight) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } break; @@ -450,15 +455,15 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; if (nodesIsArithmeticOp(pOp)) { - if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || - TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { + if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || + TSDB_DATA_TYPE_BLOB == rdt.type) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; } else if (nodesIsComparisonOp(pOp)) { - if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || - TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { + if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || + TSDB_DATA_TYPE_BLOB == rdt.type) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; @@ -524,9 +529,7 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) { return pCxt->errCode; } -static bool isAliasColumn(SColumnNode* pCol) { - return ('\0' == pCol->tableAlias[0]); -} +static bool isAliasColumn(SColumnNode* pCol) { return ('\0' == pCol->tableAlias[0]); } static bool isDistinctOrderBy(STranslateContext* pCxt) { return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct); @@ -558,7 +561,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) { if (!nodesIsExprNode(pNode) || (QUERY_NODE_COLUMN == nodeType(pNode) && isAliasColumn((SColumnNode*)pNode))) { return DEAL_RES_CONTINUE; } - if (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && !isDistinctOrderBy(pCxt)) { + if (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && + !isDistinctOrderBy(pCxt)) { return DEAL_RES_IGNORE_CHILD; } SNode* pGroupNode; @@ -568,7 +572,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) { } } if (QUERY_NODE_COLUMN == nodeType(pNode) || - (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && isDistinctOrderBy(pCxt))) { + (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && + isDistinctOrderBy(pCxt))) { return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt)); } return DEAL_RES_CONTINUE; @@ -589,8 +594,8 @@ static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList typedef struct CheckAggColCoexistCxt { STranslateContext* pTranslateCxt; - bool existAggFunc; - bool existCol; + bool existAggFunc; + bool existCol; } CheckAggColCoexistCxt; static EDealRes doCheckAggColCoexist(SNode* pNode, void* pContext) { @@ -609,7 +614,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) if (NULL != pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; } - CheckAggColCoexistCxt cxt = { .pTranslateCxt = pCxt, .existAggFunc = false, .existCol = false }; + CheckAggColCoexistCxt cxt = {.pTranslateCxt = pCxt, .existAggFunc = false, .existCol = false}; nodesWalkExprs(pSelect->pProjectionList, doCheckAggColCoexist, &cxt); if (!pSelect->isDistinct) { nodesWalkExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); @@ -628,7 +633,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) { } (*pVgsInfo)->numOfVgroups = vgroupNum; for (int32_t i = 0; i < vgroupNum; ++i) { - SVgroupInfo *vg = taosArrayGet(pVgs, i); + SVgroupInfo* vg = taosArrayGet(pVgs, i); (*pVgsInfo)->vgroups[i] = *vg; } return TSDB_CODE_SUCCESS; @@ -688,8 +693,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { SRealTableNode* pRealTable = (SRealTableNode*)pTable; pRealTable->ratio = (NULL != pCxt->pExplainOpt ? pCxt->pExplainOpt->ratio : 1.0); SName name; - code = getTableMetaImpl(pCxt, - toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta)); + code = getTableMetaImpl( + pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), + &(pRealTable->pMeta)); if (TSDB_CODE_SUCCESS != code) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName); } @@ -725,16 +731,16 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { } static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect, bool* pIsSelectStar) { - if (NULL == pSelect->pProjectionList) { // select * ... + if (NULL == pSelect->pProjectionList) { // select * ... SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); - size_t nums = taosArrayGetSize(pTables); + size_t nums = taosArrayGetSize(pTables); pSelect->pProjectionList = nodesMakeList(); if (NULL == pSelect->pProjectionList) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); } for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); - int32_t code = createColumnNodeByTable(pCxt, pTable, pSelect->pProjectionList); + int32_t code = createColumnNodeByTable(pCxt, pTable, pSelect->pProjectionList); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -769,14 +775,15 @@ static int32_t getPositionValue(const SValueNode* pVal) { case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_UBIGINT: - return pVal->datum.u; + return pVal->datum.u; default: break; } return -1; } -static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList, bool* pOther) { +static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList, + bool* pOther) { *pOther = false; SNode* pNode; FOREACH(pNode, pOrderByList) { @@ -809,7 +816,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro } static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { - bool other; + bool other; int32_t code = translateOrderByPosition(pCxt, pSelect->pProjectionList, pSelect->pOrderByList, &other); if (TSDB_CODE_SUCCESS != code) { return code; @@ -826,7 +833,7 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { } static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) { - bool isSelectStar = false; + bool isSelectStar = false; int32_t code = translateStar(pCxt, pSelect, &isSelectStar); if (TSDB_CODE_SUCCESS == code && !isSelectStar) { pCxt->currClause = SQL_CLAUSE_SELECT; @@ -868,7 +875,7 @@ static int32_t translateIntervalWindow(STranslateContext* pCxt, SIntervalWindowN static int32_t doTranslateWindow(STranslateContext* pCxt, SNode* pWindow) { switch (nodeType(pWindow)) { case QUERY_NODE_INTERVAL_WINDOW: - return translateIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow); + return translateIntervalWindow(pCxt, (SIntervalWindowNode*)pWindow); default: break; } @@ -940,19 +947,15 @@ static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbRe } SValueNode* pFreq = NULL; SValueNode* pKeep = NULL; - SNode* pNode = NULL; - int32_t index = 0; + SNode* pNode = NULL; + int32_t index = 0; FOREACH(pNode, pRetentions) { if (0 == ((index++) & 1)) { pFreq = (SValueNode*)pNode; } else { pKeep = (SValueNode*)pNode; SRetention retention = { - .freq = pFreq->datum.i, - .freqUnit = pFreq->unit, - .keep = pKeep->datum.i, - .keepUnit = pKeep->unit - }; + .freq = pFreq->datum.i, .freqUnit = pFreq->unit, .keep = pKeep->datum.i, .keepUnit = pKeep->unit}; taosArrayPush(pReq->pRetensions, &retention); } } @@ -1028,7 +1031,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* pStmt) { SDropDbReq dropReq = {0}; - SName name = {0}; + SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, dropReq.db); dropReq.ignoreNotExists = pStmt->ignoreNotExists; @@ -1100,7 +1103,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) { SNode* pNode; FOREACH(pNode, pList) { SColumnDefNode* pCol = (SColumnDefNode*)pNode; - SField field = { .type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType) }; + SField field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)}; strcpy(field.name, pCol->colName); taosArrayPush(*pArray, &field); } @@ -1112,7 +1115,7 @@ static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { SNode* pNode; FOREACH(pNode, pList) { SColumnNode* pCol = (SColumnNode*)pNode; - SField field = { .type = pCol->node.resType.type, .bytes = calcTypeBytes(pCol->node.resType) }; + SField field = {.type = pCol->node.resType.type, .bytes = calcTypeBytes(pCol->node.resType)}; strcpy(field.name, pCol->colName); taosArrayPush(*pArray, &field); } @@ -1132,11 +1135,9 @@ static SColumnDefNode* findColDef(SNodeList* pCols, const SColumnNode* pCol) { static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { if (NULL != pStmt->pOptions->pSma) { SNode* pNode = NULL; - FOREACH(pNode, pStmt->pCols) { - ((SColumnDefNode*)pNode)->sma = false; - } + FOREACH(pNode, pStmt->pCols) { ((SColumnDefNode*)pNode)->sma = false; } FOREACH(pNode, pStmt->pOptions->pSma) { - SColumnNode* pSmaCol = (SColumnNode*)pNode; + SColumnNode* pSmaCol = (SColumnNode*)pNode; SColumnDefNode* pColDef = findColDef(pStmt->pCols, pSmaCol); if (NULL == pColDef) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN, pSmaCol->colName); @@ -1184,7 +1185,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt createReq.numOfSmas = LIST_LENGTH(pStmt->pOptions->pSma); } - SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName tableName = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(tableName.dbname, pStmt->dbName); strcpy(tableName.tname, pStmt->tableName); tNameExtractFullName(&tableName, createReq.name); @@ -1233,8 +1234,8 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt SDropTableClause* pClause = nodesListGetNode(pStmt->pTables, 0); STableMeta* pTableMeta = NULL; - SName tableName; - int32_t code = getTableMetaImpl( + SName tableName; + int32_t code = getTableMetaImpl( pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); if ((TSDB_CODE_TDB_INVALID_TABLE_ID == code || TSDB_CODE_VND_TB_NOT_EXIST == code) && pClause->ignoreNotExists) { return TSDB_CODE_SUCCESS; @@ -1253,7 +1254,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt } static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableStmt* pStmt) { - SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName tableName = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(tableName.dbname, pStmt->dbName); strcpy(tableName.tname, pStmt->tableName); return doTranslateDropSuperTable(pCxt, &tableName, pStmt->ignoreNotExists); @@ -1272,7 +1273,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe case TSDB_ALTER_TABLE_DROP_COLUMN: case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: { - TAOS_FIELD field = { .type = pStmt->dataType.type, .bytes = pStmt->dataType.bytes }; + TAOS_FIELD field = {.type = pStmt->dataType.type, .bytes = pStmt->dataType.bytes}; strcpy(field.name, pStmt->colName); taosArrayPush(pAlterReq->pFields, &field); break; @@ -1296,7 +1297,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { SMAltertbReq alterReq = {0}; - SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName tableName = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(tableName.dbname, pStmt->dbName); strcpy(tableName.tname, pStmt->tableName); tNameExtractFullName(&tableName, alterReq.name); @@ -1328,7 +1329,7 @@ static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pSt static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) { SUseDbReq usedbReq = {0}; - SName name = {0}; + SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameExtractFullName(&name, usedbReq.db); int32_t code = getDBVgVersion(pCxt, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable); @@ -1398,7 +1399,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt } tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) { @@ -1489,7 +1490,7 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt static int32_t nodeTypeToShowType(ENodeType nt) { switch (nt) { case QUERY_NODE_SHOW_APPS_STMT: - return 0; // todo + return 0; // todo case QUERY_NODE_SHOW_CONNECTIONS_STMT: return TSDB_MGMT_TABLE_CONNS; case QUERY_NODE_SHOW_LICENCE_STMT: @@ -1497,9 +1498,9 @@ static int32_t nodeTypeToShowType(ENodeType nt) { case QUERY_NODE_SHOW_QUERIES_STMT: return TSDB_MGMT_TABLE_QUERIES; case QUERY_NODE_SHOW_SCORES_STMT: - return 0; // todo + return 0; // todo case QUERY_NODE_SHOW_TOPICS_STMT: - return 0; // todo + return 0; // todo case QUERY_NODE_SHOW_VARIABLE_STMT: return TSDB_MGMT_TABLE_VARIABLES; default: @@ -1509,7 +1510,7 @@ static int32_t nodeTypeToShowType(ENodeType nt) { } static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { - SShowReq showReq = { .type = nodeTypeToShowType(nodeType(pStmt)) }; + SShowReq showReq = {.type = nodeTypeToShowType(nodeType(pStmt))}; pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); if (NULL == pCxt->pCmdMsg) { @@ -1529,7 +1530,7 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) { SVgroupInfo vg = {0}; - int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg); + int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg); if (TSDB_CODE_SUCCESS == code) { *pVgId = vg.vgId; } @@ -1571,9 +1572,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS return TSDB_CODE_OUT_OF_MEMORY; } SNode* pProject = NULL; - FOREACH(pProject, pSelect->pProjectionList) { - sprintf(((SExprNode*)pProject)->aliasName, "#sma_%p", pProject); - } + FOREACH(pProject, pSelect->pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#sma_%p", pProject); } SIntervalWindowNode* pInterval = nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); if (NULL == pInterval) { @@ -1585,7 +1584,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS pInterval->pInterval = nodesCloneNode(pStmt->pOptions->pInterval); pInterval->pOffset = nodesCloneNode(pStmt->pOptions->pOffset); pInterval->pSliding = nodesCloneNode(pStmt->pOptions->pSliding); - if (NULL == pInterval->pCol || NULL == pInterval->pInterval || + if (NULL == pInterval->pCol || NULL == pInterval->pInterval || (NULL != pStmt->pOptions->pOffset && NULL == pInterval->pOffset) || (NULL != pStmt->pOptions->pSliding && NULL == pInterval->pSliding)) { nodesDestroyNode(pSelect); @@ -1603,7 +1602,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS } static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateSmaReq* pReq) { - SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pCxt->pParseCxt->db); strcpy(name.tname, pStmt->indexName); tNameExtractFullName(&name, pReq->name); @@ -1614,8 +1613,10 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; pReq->offset = (NULL != pStmt->pOptions->pOffset ? ((SValueNode*)pStmt->pOptions->pOffset)->datum.i : 0); - pReq->sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); - pReq->slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); + pReq->sliding = + (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); + pReq->slidingUnit = + (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId); if (TSDB_CODE_SUCCESS == code) { @@ -1633,13 +1634,15 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || - (NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || - (NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { + (NULL != pStmt->pOptions->pOffset && + DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || + (NULL != pStmt->pOptions->pSliding && + DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { return pCxt->errCode; } SMCreateSmaReq createSmaReq = {0}; - int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); + int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -1660,11 +1663,12 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt return TSDB_CODE_SUCCESS; } +static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {} static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { if (INDEX_TYPE_SMA == pStmt->indexType) { return translateCreateSmaIndex(pCxt, pStmt); - } else { + } else if (INDEX_TYPE_FULLTEXT == pStmt->indexType) { // todo fulltext index return TSDB_CODE_FAILED; } @@ -1692,7 +1696,7 @@ static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt } static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { - SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; + SMCreateQnodeReq createReq = {.dnodeId = pStmt->dnodeId}; pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); if (NULL == pCxt->pCmdMsg) { @@ -1711,7 +1715,7 @@ static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* p } static int32_t translateDropQnode(STranslateContext* pCxt, SDropQnodeStmt* pStmt) { - SDDropQnodeReq dropReq = { .dnodeId = pStmt->dnodeId }; + SDDropQnodeReq dropReq = {.dnodeId = pStmt->dnodeId}; pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); if (NULL == pCxt->pCmdMsg) { @@ -1738,19 +1742,19 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p if (TSDB_CODE_SUCCESS == code) { code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); } - if (TSDB_CODE_SUCCESS != code ) { + if (TSDB_CODE_SUCCESS != code) { return code; } } else { strcpy(createReq.subscribeDbName, pStmt->subscribeDbName); } - + createReq.sql = strdup(pCxt->pParseCxt->pSql); if (NULL == createReq.sql) { return TSDB_CODE_OUT_OF_MEMORY; } - SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pCxt->pParseCxt->db); strcpy(name.tname, pStmt->topicName); tNameExtractFullName(&name, createReq.name); @@ -1776,7 +1780,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) { SMDropTopicReq dropReq = {0}; - SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pCxt->pParseCxt->db); strcpy(name.tname, pStmt->topicName); tNameExtractFullName(&name, dropReq.name); @@ -1911,9 +1915,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { ++(pCxt->currLevel); - ESqlClause currClause = pCxt->currClause; + ESqlClause currClause = pCxt->currClause; SSelectStmt* pCurrStmt = pCxt->pCurrStmt; - int32_t code = translateQuery(pCxt, pNode); + int32_t code = translateQuery(pCxt, pNode); --(pCxt->currLevel); pCxt->currClause = currClause; pCxt->pCurrStmt = pCurrStmt; @@ -1927,7 +1931,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu return TSDB_CODE_OUT_OF_MEMORY; } - SNode* pNode; + SNode* pNode; int32_t index = 0; FOREACH(pNode, pSelect->pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; @@ -1935,7 +1939,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu (*pSchema)[index].bytes = pExpr->resType.bytes; (*pSchema)[index].colId = index + 1; strcpy((*pSchema)[index].name, pExpr->aliasName); - index +=1; + index += 1; } return TSDB_CODE_SUCCESS; @@ -2122,7 +2126,8 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) SNode* pDbCond = NULL; SNode* pTbCond = NULL; if (TSDB_CODE_SUCCESS != createOperatorNode(OP_TYPE_EQUAL, "db_name", pShow->pDbName, &pDbCond) || - TSDB_CODE_SUCCESS != createOperatorNode(OP_TYPE_LIKE, getTbNameColName(nodeType(pShow)), pShow->pTbNamePattern, &pTbCond)) { + TSDB_CODE_SUCCESS != + createOperatorNode(OP_TYPE_LIKE, getTbNameColName(nodeType(pShow)), pShow->pTbNamePattern, &pTbCond)) { nodesDestroyNode(pDbCond); nodesDestroyNode(pTbCond); return TSDB_CODE_OUT_OF_MEMORY; @@ -2147,7 +2152,7 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) static int32_t rewriteShow(STranslateContext* pCxt, SQuery* pQuery) { SSelectStmt* pStmt = NULL; - int32_t code = createSelectStmtForShow(nodeType(pQuery->pRoot), &pStmt); + int32_t code = createSelectStmtForShow(nodeType(pQuery->pRoot), &pStmt); if (TSDB_CODE_SUCCESS == code) { code = createShowCondition((SShowStmt*)pQuery->pRoot, pStmt); } @@ -2196,17 +2201,16 @@ static int32_t buildSmaParam(STableOptions* pOptions, SVCreateTbReq* pReq) { return TSDB_CODE_OUT_OF_MEMORY; } int32_t index = 0; - SNode* pFunc = NULL; - FOREACH(pFunc, pOptions->pFuncs) { - pReq->ntbCfg.pRSmaParam->pFuncIds[index++] = ((SFunctionNode*)pFunc)->funcId; - } + SNode* pFunc = NULL; + FOREACH(pFunc, pOptions->pFuncs) { pReq->ntbCfg.pRSmaParam->pFuncIds[index++] = ((SFunctionNode*)pFunc)->funcId; } return TSDB_CODE_SUCCESS; } -static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pVgroupInfo, SVgroupTablesBatch* pBatch) { - char dbFName[TSDB_DB_FNAME_LEN] = {0}; - SName name = { .type = TSDB_DB_NAME_T, .acctId = acctId }; +static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pVgroupInfo, + SVgroupTablesBatch* pBatch) { + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; strcpy(name.dbname, pStmt->dbName); tNameGetFullDbName(&name, dbFName); @@ -2220,7 +2224,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* destroyCreateTbReq(&req); return TSDB_CODE_OUT_OF_MEMORY; } - SNode* pCol; + SNode* pCol; col_id_t index = 0; FOREACH(pCol, pStmt->pCols) { toSchemaEx((SColumnDefNode*)pCol, index + 1, req.ntbCfg.pSchema + index); @@ -2244,7 +2248,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* } static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray* pBufArray) { - int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req)); + int tlen = sizeof(SMsgHead) + tSerializeSVCreateTbBatchReq(NULL, &(pTbBatch->req)); void* buf = taosMemoryMalloc(tlen); if (NULL == buf) { return TSDB_CODE_OUT_OF_MEMORY; @@ -2258,10 +2262,10 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray* if (NULL == pVgData) { return TSDB_CODE_OUT_OF_MEMORY; } - pVgData->vg = pTbBatch->info; + pVgData->vg = pTbBatch->info; pVgData->pData = buf; - pVgData->size = tlen; - pVgData->numOfTables = (int32_t) taosArrayGetSize(pTbBatch->req.pArray); + pVgData->size = tlen; + pVgData->numOfTables = (int32_t)taosArrayGetSize(pTbBatch->req.pArray); taosArrayPush(pBufArray, &pVgData); return TSDB_CODE_SUCCESS; @@ -2269,7 +2273,7 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray* static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) { size_t size = taosArrayGetSize(pTbBatch->req.pArray); - for(int32_t i = 0; i < size; ++i) { + for (int32_t i = 0; i < size; ++i) { SVCreateTbReq* pTableReq = taosArrayGet(pTbBatch->req.pArray, i); taosMemoryFreeClear(pTableReq->dbFName); taosMemoryFreeClear(pTableReq->name); @@ -2306,14 +2310,15 @@ static void destroyCreateTbReqArray(SArray* pArray) { taosArrayDestroy(pArray); } -static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) { +static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, + SArray** pBufArray) { *pBufArray = taosArrayInit(1, POINTER_BYTES); if (NULL == *pBufArray) { return TSDB_CODE_OUT_OF_MEMORY; } SVgroupTablesBatch tbatch = {0}; - int32_t code = buildNormalTableBatchReq(acctId, pStmt, pInfo, &tbatch); + int32_t code = buildNormalTableBatchReq(acctId, pStmt, pInfo, &tbatch); if (TSDB_CODE_SUCCESS == code) { code = serializeVgroupTablesBatch(&tbatch, *pBufArray); } @@ -2328,7 +2333,7 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { SCreateTableStmt* pStmt = (SCreateTableStmt*)pQuery->pRoot; - int32_t code = checkCreateTable(pCxt, pStmt); + int32_t code = checkCreateTable(pCxt, pStmt); SVgroupInfo info = {0}; if (TSDB_CODE_SUCCESS == code) { code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); @@ -2347,17 +2352,17 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { return code; } -static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, - const char* pDbName, const char* pTableName, SKVRow row, uint64_t suid, SVgroupInfo* pVgInfo) { - char dbFName[TSDB_DB_FNAME_LEN] = {0}; - SName name = { .type = TSDB_DB_NAME_T, .acctId = acctId }; +static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, const char* pDbName, + const char* pTableName, SKVRow row, uint64_t suid, SVgroupInfo* pVgInfo) { + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; strcpy(name.dbname, pDbName); tNameGetFullDbName(&name, dbFName); struct SVCreateTbReq req = {0}; - req.type = TD_CHILD_TABLE; - req.dbFName = strdup(dbFName); - req.name = strdup(pTableName); + req.type = TD_CHILD_TABLE; + req.dbFName = strdup(dbFName); + req.name = strdup(pTableName); req.ctbCfg.suid = suid; req.ctbCfg.pTag = row; @@ -2376,13 +2381,14 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, } } -static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SSchema* pSchema, SKVRowBuilder* pBuilder) { +static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SSchema* pSchema, + SKVRowBuilder* pBuilder) { if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) { return pCxt->errCode; } SVariant var; valueNodeToVariant(pVal, &var); - char tagVal[TSDB_MAX_TAGS_LEN] = {0}; + char tagVal[TSDB_MAX_TAGS_LEN] = {0}; int32_t code = taosVariantDump(&var, tagVal, pSchema->type, true); if (TSDB_CODE_SUCCESS == code) { tdAddColToKVRow(pBuilder, pSchema->colId, pSchema->type, tagVal); @@ -2390,21 +2396,23 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS return code; } -static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, SKVRowBuilder* pBuilder) { +static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, + SKVRowBuilder* pBuilder) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); - if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { + if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || + numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); - SNode* pTag, *pVal; + SNode * pTag, *pVal; FORBOTH(pTag, pStmt->pSpecificTags, pVal, pStmt->pValsOfTags) { SColumnNode* pCol = (SColumnNode*)pTag; - SSchema* pSchema = NULL; + SSchema* pSchema = NULL; for (int32_t i = 0; i < numOfTags; ++i) { if (0 == strcmp(pCol->colName, pTagSchema[i].name)) { - pSchema = pTagSchema + i; - break; + pSchema = pTagSchema + i; + break; } } if (NULL == pSchema) { @@ -2419,14 +2427,15 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla return TSDB_CODE_SUCCESS; } -static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, SKVRowBuilder* pBuilder) { +static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, + SKVRowBuilder* pBuilder) { if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); - SNode* pVal; - int32_t index = 0; + SNode* pVal; + int32_t index = 0; FOREACH(pVal, pStmt->pValsOfTags) { int32_t code = addValToKVRow(pCxt, (SValueNode*)pVal, pTagSchema + index++, pBuilder); if (TSDB_CODE_SUCCESS != code) { @@ -2439,7 +2448,8 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau static int32_t checkCreateSubTable(STranslateContext* pCxt, SCreateSubTableClause* pStmt) { if (0 != strcmp(pStmt->dbName, pStmt->useDbName)) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR);; + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR); + ; } return TSDB_CODE_SUCCESS; } @@ -2458,9 +2468,9 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla if (TSDB_CODE_SUCCESS == code) { if (NULL != pStmt->pSpecificTags) { - code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &kvRowBuilder); + code = buildKVRowForBindTags(pCxt, pStmt, pSuperTableMeta, &kvRowBuilder); } else { - code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &kvRowBuilder); + code = buildKVRowForAllTags(pCxt, pStmt, pSuperTableMeta, &kvRowBuilder); } } @@ -2472,14 +2482,15 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla } else { tdSortKVRowByColIdx(row); } - } + } SVgroupInfo info = {0}; if (TSDB_CODE_SUCCESS == code) { code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt->dbName, pStmt->tableName, row, pSuperTableMeta->uid, &info); + addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt->dbName, pStmt->tableName, row, + pSuperTableMeta->uid, &info); } taosMemoryFreeClear(pSuperTableMeta); @@ -2493,7 +2504,7 @@ static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHash return NULL; } - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SVgroupTablesBatch* pTbBatch = NULL; do { pTbBatch = taosHashIterate(pVgroupHashmap, pTbBatch); @@ -2517,7 +2528,7 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) } int32_t code = TSDB_CODE_SUCCESS; - SNode* pNode; + SNode* pNode; FOREACH(pNode, pStmt->pSubTables) { code = rewriteCreateSubTable(pCxt, (SCreateSubTableClause*)pNode, pVgroupHashmap); if (TSDB_CODE_SUCCESS != code) { @@ -2607,7 +2618,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { return TSDB_CODE_OUT_OF_MEMORY; } } - + if (NULL != pCxt->pDbs) { pQuery->pDbList = taosArrayInit(taosHashGetSize(pCxt->pDbs), TSDB_DB_FNAME_LEN); if (NULL == pQuery->pDbList) { @@ -2637,15 +2648,14 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) { STranslateContext cxt = { - .pParseCxt = pParseCxt, - .errCode = TSDB_CODE_SUCCESS, - .msgBuf = { .buf = pParseCxt->pMsg, .len = pParseCxt->msgLen }, - .pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES), - .currLevel = 0, - .currClause = 0, - .pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK), - .pTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK) - }; + .pParseCxt = pParseCxt, + .errCode = TSDB_CODE_SUCCESS, + .msgBuf = {.buf = pParseCxt->pMsg, .len = pParseCxt->msgLen}, + .pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES), + .currLevel = 0, + .currClause = 0, + .pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK), + .pTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)}; if (NULL == cxt.pNsLevel) { return TSDB_CODE_OUT_OF_MEMORY; } From e23ead7da8d5984086503668ec47dea3db8f7f09 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 7 Apr 2022 21:32:30 +0800 Subject: [PATCH 07/45] add create index msg --- include/common/tmsg.h | 1 + include/common/tmsgdef.h | 2 + source/libs/parser/src/parTranslater.c | 164 ++++++++++++------------- 3 files changed, 82 insertions(+), 85 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 03b1b02987..6820536663 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2225,6 +2225,7 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) { } typedef struct { + int idx; } SMCreateFullTextReq; int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq); diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 1d4667cda0..72628300e3 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -155,6 +155,8 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_CREATE_STREAM, "mnode-create-stream", SCMCreateStreamReq, SCMCreateStreamRsp) TD_DEF_MSG_TYPE(TDMT_MND_ALTER_STREAM, "mnode-alter-stream", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_DROP_STREAM, "mnode-drop-stream", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_CREATE_INDEX, "mnode-create-index", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "mnode-drop-index", NULL, NULL) // Requests handled by VNODE TD_NEW_MSG_SEG(TDMT_VND_MSG) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a53e0b8285..9a29a5f513 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -107,8 +107,7 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa code = catalogGetTableMeta(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pMeta); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, - pName->tname); + parserError("catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); } return code; } @@ -130,8 +129,7 @@ static int32_t getTableDistVgInfo(STranslateContext* pCxt, const SName* pName, S code = catalogGetTableDistVgInfo(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pVgInfo); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, - pName->tname); + parserError("catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); } return code; } @@ -168,22 +166,19 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam code = catalogGetTableHashVgroup(pParCxt->pCatalog, pParCxt->pTransporter, &pParCxt->mgmtEpSet, pName, pInfo); } if (TSDB_CODE_SUCCESS != code) { - parserError("catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, - pName->tname); + parserError("catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, pName->tname); } return code; } -static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName, - SVgroupInfo* pInfo) { +static int32_t getTableHashVgroup(STranslateContext* pCxt, const char* pDbName, const char* pTableName, SVgroupInfo* pInfo) { SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; strcpy(name.dbname, pDbName); strcpy(name.tname, pTableName); return getTableHashVgroupImpl(pCxt, &name, pInfo); } -static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, - int32_t* pTableNum) { +static int32_t getDBVgVersion(STranslateContext* pCxt, const char* pDbFName, int32_t* pVersion, int64_t* pDbId, int32_t* pTableNum) { SParseContext* pParCxt = pCxt->pParseCxt; int32_t code = collectUseDatabaseImpl(pDbFName, pCxt->pDbs); if (TSDB_CODE_SUCCESS == code) { @@ -215,8 +210,7 @@ static SNodeList* getProjectList(SNode* pNode) { return NULL; } -static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, bool isTag, - SColumnNode* pCol) { +static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* pColSchema, bool isTag, SColumnNode* pCol) { strcpy(pCol->dbName, pTable->table.dbName); strcpy(pCol->tableAlias, pTable->table.tableAlias); strcpy(pCol->tableName, pTable->table.tableName); @@ -253,8 +247,7 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode* pTable, SNodeList* pList) { if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; - int32_t nums = - pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0); + int32_t nums = pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0); for (int32_t i = 0; i < nums; ++i) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -378,8 +371,7 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { - if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, - pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { + if (parseNatualDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } } else { @@ -423,8 +415,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { break; } case TSDB_DATA_TYPE_TIMESTAMP: { - if (taosParseTime(pVal->literal, &pVal->datum.i, pVal->node.resType.bytes, pVal->node.resType.precision, - tsDaylight) != TSDB_CODE_SUCCESS) { + if (taosParseTime(pVal->literal, &pVal->datum.i, pVal->node.resType.bytes, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } break; @@ -455,15 +446,13 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; if (nodesIsArithmeticOp(pOp)) { - if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || - TSDB_DATA_TYPE_BLOB == rdt.type) { + if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; } else if (nodesIsComparisonOp(pOp)) { - if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || - TSDB_DATA_TYPE_BLOB == rdt.type) { + if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); } pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; @@ -531,9 +520,7 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) { static bool isAliasColumn(SColumnNode* pCol) { return ('\0' == pCol->tableAlias[0]); } -static bool isDistinctOrderBy(STranslateContext* pCxt) { - return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct); -} +static bool isDistinctOrderBy(STranslateContext* pCxt) { return (SQL_CLAUSE_ORDER_BY == pCxt->currClause && pCxt->pCurrStmt->isDistinct); } static SNodeList* getGroupByList(STranslateContext* pCxt) { if (isDistinctOrderBy(pCxt)) { @@ -561,8 +548,7 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) { if (!nodesIsExprNode(pNode) || (QUERY_NODE_COLUMN == nodeType(pNode) && isAliasColumn((SColumnNode*)pNode))) { return DEAL_RES_CONTINUE; } - if (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && - !isDistinctOrderBy(pCxt)) { + if (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && !isDistinctOrderBy(pCxt)) { return DEAL_RES_IGNORE_CHILD; } SNode* pGroupNode; @@ -572,8 +558,7 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) { } } if (QUERY_NODE_COLUMN == nodeType(pNode) || - (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && - isDistinctOrderBy(pCxt))) { + (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId) && isDistinctOrderBy(pCxt))) { return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt)); } return DEAL_RES_CONTINUE; @@ -693,9 +678,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { SRealTableNode* pRealTable = (SRealTableNode*)pTable; pRealTable->ratio = (NULL != pCxt->pExplainOpt ? pCxt->pExplainOpt->ratio : 1.0); SName name; - code = getTableMetaImpl( - pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), - &(pRealTable->pMeta)); + code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, pRealTable->table.tableName, &name), &(pRealTable->pMeta)); if (TSDB_CODE_SUCCESS != code) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TABLE_NOT_EXIST, pRealTable->table.tableName); } @@ -782,8 +765,7 @@ static int32_t getPositionValue(const SValueNode* pVal) { return -1; } -static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList, - bool* pOther) { +static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList, bool* pOther) { *pOther = false; SNode* pNode; FOREACH(pNode, pOrderByList) { @@ -954,8 +936,7 @@ static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbRe pFreq = (SValueNode*)pNode; } else { pKeep = (SValueNode*)pNode; - SRetention retention = { - .freq = pFreq->datum.i, .freqUnit = pFreq->unit, .keep = pKeep->datum.i, .keepUnit = pKeep->unit}; + SRetention retention = {.freq = pFreq->datum.i, .freqUnit = pFreq->unit, .keep = pKeep->datum.i, .keepUnit = pKeep->unit}; taosArrayPush(pReq->pRetensions, &retention); } } @@ -1235,8 +1216,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt STableMeta* pTableMeta = NULL; SName tableName; - int32_t code = getTableMetaImpl( - pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); + int32_t code = getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), &pTableMeta); if ((TSDB_CODE_TDB_INVALID_TABLE_ID == code || TSDB_CODE_VND_TB_NOT_EXIST == code) && pClause->ignoreNotExists) { return TSDB_CODE_SUCCESS; } @@ -1584,8 +1564,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS pInterval->pInterval = nodesCloneNode(pStmt->pOptions->pInterval); pInterval->pOffset = nodesCloneNode(pStmt->pOptions->pOffset); pInterval->pSliding = nodesCloneNode(pStmt->pOptions->pSliding); - if (NULL == pInterval->pCol || NULL == pInterval->pInterval || - (NULL != pStmt->pOptions->pOffset && NULL == pInterval->pOffset) || + if (NULL == pInterval->pCol || NULL == pInterval->pInterval || (NULL != pStmt->pOptions->pOffset && NULL == pInterval->pOffset) || (NULL != pStmt->pOptions->pSliding && NULL == pInterval->pSliding)) { nodesDestroyNode(pSelect); return TSDB_CODE_OUT_OF_MEMORY; @@ -1613,10 +1592,8 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; pReq->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; pReq->offset = (NULL != pStmt->pOptions->pOffset ? ((SValueNode*)pStmt->pOptions->pOffset)->datum.i : 0); - pReq->sliding = - (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); - pReq->slidingUnit = - (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); + pReq->sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : pReq->interval); + pReq->slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : pReq->intervalUnit); int32_t code = getSmaIndexDstVgId(pCxt, pStmt->tableName, &pReq->dstVgId); if (TSDB_CODE_SUCCESS == code) { @@ -1634,15 +1611,14 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || - (NULL != pStmt->pOptions->pOffset && - DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || - (NULL != pStmt->pOptions->pSliding && - DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { + (NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || + (NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { return pCxt->errCode; } SMCreateSmaReq createSmaReq = {0}; - int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); + + int32_t code = buildCreateSmaReq(pCxt, pStmt, &createSmaReq); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -1663,12 +1639,44 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt return TSDB_CODE_SUCCESS; } -static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) {} +static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SMCreateFullTextReq* pReq) { + // impl later + return 0; +} +static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || + (NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || + (NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { + return pCxt->errCode; + } + SMCreateFullTextReq createFTReq = {0}; + + int32_t code = buildCreateFullTextReq(pCxt, pStmt, &createFTReq); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_INDEX; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateFullTextReq(NULL, 0, &createFTReq); + pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateFullTextReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createFTReq); + tFreeSMCreateFullTextReq(&createFTReq); + + return TSDB_CODE_SUCCESS; +} static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { if (INDEX_TYPE_SMA == pStmt->indexType) { return translateCreateSmaIndex(pCxt, pStmt); } else if (INDEX_TYPE_FULLTEXT == pStmt->indexType) { + return translateCreateFullTextIndex(pCxt, pStmt); // todo fulltext index return TSDB_CODE_FAILED; } @@ -1814,9 +1822,7 @@ static int32_t translateExplain(STranslateContext* pCxt, SExplainStmt* pStmt) { return translateQuery(pCxt, pStmt->pQuery); } -static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) { - return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); -} +static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) { return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); } static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; @@ -2097,9 +2103,7 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN return TSDB_CODE_SUCCESS; } -static const char* getTbNameColName(ENodeType type) { - return (QUERY_NODE_SHOW_STABLES_STMT == type ? "stable_name" : "table_name"); -} +static const char* getTbNameColName(ENodeType type) { return (QUERY_NODE_SHOW_STABLES_STMT == type ? "stable_name" : "table_name"); } static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) { SLogicConditionNode* pCondition = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); @@ -2112,8 +2116,7 @@ static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond) nodesDestroyNode(pCondition); return TSDB_CODE_OUT_OF_MEMORY; } - if (TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond1) || - TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond2)) { + if (TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond1) || TSDB_CODE_SUCCESS != nodesListAppend(pCondition->pParameterList, pCond2)) { nodesDestroyNode(pCondition); return TSDB_CODE_OUT_OF_MEMORY; } @@ -2126,8 +2129,7 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect) SNode* pDbCond = NULL; SNode* pTbCond = NULL; if (TSDB_CODE_SUCCESS != createOperatorNode(OP_TYPE_EQUAL, "db_name", pShow->pDbName, &pDbCond) || - TSDB_CODE_SUCCESS != - createOperatorNode(OP_TYPE_LIKE, getTbNameColName(nodeType(pShow)), pShow->pTbNamePattern, &pTbCond)) { + TSDB_CODE_SUCCESS != createOperatorNode(OP_TYPE_LIKE, getTbNameColName(nodeType(pShow)), pShow->pTbNamePattern, &pTbCond)) { nodesDestroyNode(pDbCond); nodesDestroyNode(pTbCond); return TSDB_CODE_OUT_OF_MEMORY; @@ -2207,8 +2209,7 @@ static int32_t buildSmaParam(STableOptions* pOptions, SVCreateTbReq* pReq) { return TSDB_CODE_SUCCESS; } -static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pVgroupInfo, - SVgroupTablesBatch* pBatch) { +static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pVgroupInfo, SVgroupTablesBatch* pBatch) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; strcpy(name.dbname, pStmt->dbName); @@ -2310,8 +2311,7 @@ static void destroyCreateTbReqArray(SArray* pArray) { taosArrayDestroy(pArray); } -static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, - SArray** pBufArray) { +static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt* pStmt, const SVgroupInfo* pInfo, SArray** pBufArray) { *pBufArray = taosArrayInit(1, POINTER_BYTES); if (NULL == *pBufArray) { return TSDB_CODE_OUT_OF_MEMORY; @@ -2352,8 +2352,8 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) { return code; } -static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, const char* pDbName, - const char* pTableName, SKVRow row, uint64_t suid, SVgroupInfo* pVgInfo) { +static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, const char* pDbName, const char* pTableName, SKVRow row, uint64_t suid, + SVgroupInfo* pVgInfo) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId}; strcpy(name.dbname, pDbName); @@ -2381,8 +2381,7 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, c } } -static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SSchema* pSchema, - SKVRowBuilder* pBuilder) { +static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SSchema* pSchema, SKVRowBuilder* pBuilder) { if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) { return pCxt->errCode; } @@ -2396,11 +2395,9 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS return code; } -static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - SKVRowBuilder* pBuilder) { +static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, SKVRowBuilder* pBuilder) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); - if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || - numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { + if (LIST_LENGTH(pStmt->pValsOfTags) != LIST_LENGTH(pStmt->pSpecificTags) || numOfTags < LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } @@ -2427,8 +2424,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla return TSDB_CODE_SUCCESS; } -static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, - SKVRowBuilder* pBuilder) { +static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, SKVRowBuilder* pBuilder) { if (getNumOfTags(pSuperTableMeta) != LIST_LENGTH(pStmt->pValsOfTags)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_TAGS_NOT_MATCHED); } @@ -2489,8 +2485,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla code = getTableHashVgroup(pCxt, pStmt->dbName, pStmt->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt->dbName, pStmt->tableName, row, - pSuperTableMeta->uid, &info); + addCreateTbReqIntoVgroup(pCxt->pParseCxt->acctId, pVgroupHashmap, pStmt->dbName, pStmt->tableName, row, pSuperTableMeta->uid, &info); } taosMemoryFreeClear(pSuperTableMeta); @@ -2647,15 +2642,14 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { } int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) { - STranslateContext cxt = { - .pParseCxt = pParseCxt, - .errCode = TSDB_CODE_SUCCESS, - .msgBuf = {.buf = pParseCxt->pMsg, .len = pParseCxt->msgLen}, - .pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES), - .currLevel = 0, - .currClause = 0, - .pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK), - .pTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)}; + STranslateContext cxt = {.pParseCxt = pParseCxt, + .errCode = TSDB_CODE_SUCCESS, + .msgBuf = {.buf = pParseCxt->pMsg, .len = pParseCxt->msgLen}, + .pNsLevel = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES), + .currLevel = 0, + .currClause = 0, + .pDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK), + .pTables = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK)}; if (NULL == cxt.pNsLevel) { return TSDB_CODE_OUT_OF_MEMORY; } From acc9d3d9a7f84973fbd2980ff3e85cb50340e87c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 7 Apr 2022 22:04:38 +0800 Subject: [PATCH 08/45] add create index msg --- include/common/tmsg.h | 11 +++++++++-- source/common/src/tmsg.c | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 45cea85737..852d92f1e3 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -483,8 +483,7 @@ typedef struct { int32_t tz; // query client timezone char intervalUnit; char slidingUnit; - char - offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration. + char offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration. int8_t precision; int64_t interval; int64_t sliding; @@ -2264,6 +2263,14 @@ int32_t tSerializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTex int32_t tDeserializeSMCreateFullTextReq(void* buf, int32_t bufLen, SMCreateFullTextReq* pReq); void tFreeSMCreateFullTextReq(SMCreateFullTextReq* pReq); +typedef struct { + char name[TSDB_TABLE_FNAME_LEN]; + int8_t igNotExists; +} SMDropFullTextReq; + +int32_t tSerializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq); +int32_t tDeserializeSMDropFullTextReq(void* buf, int32_t bufLen, SMDropFullTextReq* pReq); + typedef struct { int8_t mqMsgType; int32_t code; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 66cf0d5ed0..4923d09c9e 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -832,6 +832,26 @@ void tFreeSMCreateFullTextReq(SMCreateFullTextReq *pReq) { // impl later return; } +int32_t tSerializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextReq *pReq) { + SCoder encoder = {0}; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); + + if (tStartEncode(&encoder) < 0) return -1; + + tEndEncode(&encoder); + int32_t tlen = encoder.pos; + tCoderClear(&encoder); + return tlen; +} +int32_t tDeserializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextReq *pReq) { + SCoder decoder = {0}; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); + if (tStartDecode(&decoder) < 0) return -1; + + tEndDecode(&decoder); + tCoderClear(&decoder); + return 0; +} int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { SCoder encoder = {0}; From 9cc076ac83b632a3b18deab100a2b3711d18c08e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 8 Apr 2022 16:36:30 +0800 Subject: [PATCH 09/45] handle except --- source/common/src/tmsg.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 4923d09c9e..b79702e2bf 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -788,6 +788,7 @@ int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeI8(&encoder, pReq->igNotExists) < 0) return -1; tEndEncode(&encoder); @@ -838,6 +839,10 @@ int32_t tSerializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextReq 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; tCoderClear(&encoder); @@ -847,6 +852,8 @@ int32_t tDeserializeSMDropFullTextReq(void *buf, int32_t bufLen, SMDropFullTextR SCoder decoder = {0}; tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->igNotExists) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); From c7dd60ff85b566437ccc6fccd218d1543ce657b7 Mon Sep 17 00:00:00 2001 From: cpwu Date: Sat, 9 Apr 2022 14:07:27 +0800 Subject: [PATCH 10/45] fix the case --- tests/script/tsim/query/complex_select.sim | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/tests/script/tsim/query/complex_select.sim b/tests/script/tsim/query/complex_select.sim index 4a710c4b58..1696d22da7 100644 --- a/tests/script/tsim/query/complex_select.sim +++ b/tests/script/tsim/query/complex_select.sim @@ -444,9 +444,103 @@ if $rows != 8 then endi print ================ query 4 scalar function + where + group by + limit/offset +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi print =================== count all rows sql select count(c1) from stb1 From c33f31b6d5e9c7ba0cc123e65fa106c82d67eb7f Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 9 Apr 2022 18:12:15 +0800 Subject: [PATCH 11/45] feature/qnode --- source/libs/command/src/explain.c | 14 ++++++-------- source/libs/qworker/inc/qworkerInt.h | 1 + source/libs/qworker/src/qworker.c | 10 +++++++--- source/libs/qworker/src/qworkerMsg.c | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 605d8f41da..155da8de49 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -52,16 +52,14 @@ void qExplainFreeCtx(SExplainCtx *pCtx) { void *pIter = taosHashIterate(pCtx->groupHash, NULL); while (pIter) { SExplainGroup *group = (SExplainGroup *)pIter; - if (NULL == group->nodeExecInfo) { - continue; + if (group->nodeExecInfo) { + int32_t num = taosArrayGetSize(group->nodeExecInfo); + for (int32_t i = 0; i < num; ++i) { + SExplainRsp *rsp = taosArrayGet(group->nodeExecInfo, i); + taosMemoryFreeClear(rsp->subplanInfo); + } } - int32_t num = taosArrayGetSize(group->nodeExecInfo); - for (int32_t i = 0; i < num; ++i) { - SExplainRsp *rsp = taosArrayGet(group->nodeExecInfo, i); - taosMemoryFreeClear(rsp->subplanInfo); - } - pIter = taosHashIterate(pCtx->groupHash, pIter); } } diff --git a/source/libs/qworker/inc/qworkerInt.h b/source/libs/qworker/inc/qworkerInt.h index cfd4a3ec7b..d62f9f04b8 100644 --- a/source/libs/qworker/inc/qworkerInt.h +++ b/source/libs/qworker/inc/qworkerInt.h @@ -79,6 +79,7 @@ typedef struct SQWConnInfo { typedef struct SQWMsg { void *node; + int32_t code; char *msg; int32_t msgLen; SQWConnInfo connInfo; diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index f0f04a8a9b..67871dfe62 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -536,6 +536,8 @@ int32_t qwDropTask(QW_FPARAMS_DEF) { QW_ERR_RET(qwDropTaskStatus(QW_FPARAMS())); QW_ERR_RET(qwDropTaskCtx(QW_FPARAMS())); + QW_TASK_DLOG_E("task is dropped"); + return TSDB_CODE_SUCCESS; } @@ -1239,8 +1241,10 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { QW_ERR_JRET(qwKillTaskHandle(QW_FPARAMS(), ctx)); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROPPING); } else if (ctx->phase > 0) { - qwBuildAndSendDropRsp(&qwMsg->connInfo, code); - QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code)); + if (0 == qwMsg->code) { + qwBuildAndSendDropRsp(&qwMsg->connInfo, code); + QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code)); + } QW_ERR_JRET(qwDropTask(QW_FPARAMS())); rsped = true; @@ -1273,7 +1277,7 @@ _return: qwReleaseTaskCtx(mgmt, ctx); } - if (TSDB_CODE_SUCCESS != code) { + if ((TSDB_CODE_SUCCESS != code) && (0 == qwMsg->code)) { qwBuildAndSendDropRsp(&qwMsg->connInfo, code); QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code)); } diff --git a/source/libs/qworker/src/qworkerMsg.c b/source/libs/qworker/src/qworkerMsg.c index bf8f97aa4c..15a42d3a31 100644 --- a/source/libs/qworker/src/qworkerMsg.c +++ b/source/libs/qworker/src/qworkerMsg.c @@ -549,7 +549,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { uint64_t tId = msg->taskId; int64_t rId = msg->refId; - SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; + SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code}; qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.ahandle = pMsg->ahandle; From f052e64103d49cf9c3344ddaa2e157ceaeda91c2 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Sat, 9 Apr 2022 18:12:53 +0800 Subject: [PATCH 12/45] feature/qnode --- tests/script/general/explain/explain.sim | 102 +++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/script/general/explain/explain.sim diff --git a/tests/script/general/explain/explain.sim b/tests/script/general/explain/explain.sim new file mode 100644 index 0000000000..666e4040b7 --- /dev/null +++ b/tests/script/general/explain/explain.sim @@ -0,0 +1,102 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wallevel -v 2 +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 + +print ========= start dnode1 as master +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print ======== step1 +sql create database db1 vgroups 3; +sql use db1; +sql show databases; +sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int); +sql create stable st2 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int); +sql create table tb1 using st1 tags(1); +sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)"); + +sql create table tb2 using st1 tags(2); +sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)"); +sql create table tb3 using st1 tags(3); +sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)"); +sql create table tb4 using st1 tags(4); +sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)"); + +sql create table tb1 using st2 tags(1); +sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)"); + +sql create table tb2 using st2 tags(2); +sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)"); +sql create table tb3 using st2 tags(3); +sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)"); +sql create table tb4 using st2 tags(4); +sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)"); + + +print ======== step2 +sql explain select * from st1 where -2; +sql explain select ts from tb1; +sql explain select * from st1; +sql explain select * from st1 order by ts; +sql explain select * from information_schema.user_stables; +sql explain select count(*),sum(f1) from tb1; +sql explain select count(*),sum(f1) from st1; +sql explain select count(*),sum(f1) from st1 group by f1; +sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n); + +print ======== step3 +sql explain verbose true select * from st1 where -2; +sql explain verbose true select ts from tb1 where f1 > 0; +sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00'; +sql explain verbose true select * from information_schema.user_stables where db_name='db2'; +sql explain verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0; + +print ======== step4 +sql explain analyze select ts from st1 where -2; +sql explain analyze select ts from tb1; +sql explain analyze select ts from st1; +sql explain analyze select ts from st1; +sql explain analyze select ts from st1 order by ts; +sql explain analyze select * from information_schema.user_stables; +sql explain analyze select count(*),sum(f1) from tb1; +sql explain analyze select count(*),sum(f1) from st1; +sql explain analyze select count(*),sum(f1) from st1 group by f1; +sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n); + +print ======== step5 +sql explain analyze verbose true select ts from st1 where -2; +sql explain analyze verbose true select ts from tb1; +sql explain analyze verbose true select ts from st1; +sql explain analyze verbose true select ts from st1; +sql explain analyze verbose true select ts from st1 order by ts; +sql explain analyze verbose true select * from information_schema.user_stables; +sql explain analyze verbose true select count(*),sum(f1) from tb1; +sql explain analyze verbose true select count(*),sum(f1) from st1; +sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1; +sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev); +sql explain analyze verbose true select ts from tb1 where f1 > 0; +sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00'; +sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2'; +sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0; +sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n); +sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0; + +#not pass case +#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa; +#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts; +#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts; +#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1s, 2d) sliding(3s) order by ts; +#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(3n) fill(linear) order by ts; +#sql explain select max(f1) from tb1 SESSION(ts, 1s); +#sql explain select max(f1) from st1 SESSION(ts, 1s); +#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts; +#sql explain select * from st1, st2 where tb1.ts=tb2.ts; +#sql explain analyze verbose true select sum(a+b) from (select _rowts, min(f1) b,count(*) a from st1 where f1 > 0 interval(1a)) where a < 0 interval(1s); + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From c1b3afa92d303901463a2707205c18402cccffb6 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 9 Apr 2022 19:00:52 +0800 Subject: [PATCH 13/45] feat[cluster]: create and drop mnode --- include/util/taoserror.h | 3 + source/dnode/mgmt/inc/mmInt.h | 1 + source/dnode/mgmt/mm/mmInt.c | 14 +-- source/dnode/mgmt/mm/mmWorker.c | 24 +++-- source/dnode/mnode/impl/inc/mndInt.h | 3 +- source/dnode/mnode/impl/inc/mndMnode.h | 14 +-- source/dnode/mnode/impl/src/mndBnode.c | 2 +- source/dnode/mnode/impl/src/mndDb.c | 2 +- source/dnode/mnode/impl/src/mndDnode.c | 8 ++ source/dnode/mnode/impl/src/mndMnode.c | 131 +++++++++++++------------ source/dnode/mnode/impl/src/mndQnode.c | 4 +- source/dnode/mnode/impl/src/mndSnode.c | 2 +- source/dnode/mnode/impl/src/mndSync.c | 5 +- source/dnode/mnode/impl/src/mnode.c | 2 +- source/util/src/terror.c | 3 + 15 files changed, 121 insertions(+), 97 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index d009f16f62..b1eb17a00f 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -195,6 +195,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_SNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0355) #define TSDB_CODE_MND_BNODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0356) #define TSDB_CODE_MND_BNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0357) +#define TSDB_CODE_MND_TOO_FEW_MNODES TAOS_DEF_ERROR_CODE(0, 0x0358) +#define TSDB_CODE_MND_MNODE_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0359) +#define TSDB_CODE_MND_CANT_DROP_MASTER TAOS_DEF_ERROR_CODE(0, 0x035A) // mnode-acct #define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) diff --git a/source/dnode/mgmt/inc/mmInt.h b/source/dnode/mgmt/inc/mmInt.h index df63e22059..74b1cc44bf 100644 --- a/source/dnode/mgmt/inc/mmInt.h +++ b/source/dnode/mgmt/inc/mmInt.h @@ -62,6 +62,7 @@ int32_t mmProcessSyncMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); int32_t mmProcessReadMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); int32_t mmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg); + int32_t mmPutMsgToQueryQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); int32_t mmPutMsgToReadQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); int32_t mmPutMsgToWriteQueue(SMgmtWrapper *pWrapper, SRpcMsg *pRpc); diff --git a/source/dnode/mgmt/mm/mmInt.c b/source/dnode/mgmt/mm/mmInt.c index 8d4ac80e72..64daf09bf9 100644 --- a/source/dnode/mgmt/mm/mmInt.c +++ b/source/dnode/mgmt/mm/mmInt.c @@ -48,15 +48,13 @@ static void mmInitOption(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) { } static void mmBuildOptionForDeploy(SMnodeMgmt *pMgmt, SMnodeOpt *pOption) { - SDnode *pDnode = pMgmt->pDnode; - mmInitOption(pMgmt, pOption); pOption->replica = 1; pOption->selfIndex = 0; SReplica *pReplica = &pOption->replicas[0]; pReplica->id = 1; - pReplica->port = pDnode->serverPort; - tstrncpy(pReplica->fqdn, pDnode->localFqdn, TSDB_FQDN_LEN); + pReplica->port = pMgmt->pDnode->serverPort; + tstrncpy(pReplica->fqdn, pMgmt->pDnode->localFqdn, TSDB_FQDN_LEN); pOption->deploy = true; pMgmt->selfIndex = pOption->selfIndex; @@ -151,12 +149,9 @@ static void mmCloseImp(SMnodeMgmt *pMgmt) { int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pReq) { SMnodeOpt option = {0}; - if (pReq != NULL) { - if (mmBuildOptionFromReq(pMgmt, &option, pReq) != 0) { - return -1; - } + if (mmBuildOptionFromReq(pMgmt, &option, pReq) != 0) { + return -1; } - return mndAlter(pMgmt->pMnode, &option); } @@ -240,4 +235,3 @@ void mmSetMgmtFp(SMgmtWrapper *pWrapper) { pWrapper->name = "mnode"; pWrapper->fp = mgmtFp; } - diff --git a/source/dnode/mgmt/mm/mmWorker.c b/source/dnode/mgmt/mm/mmWorker.c index 44bac61906..c575266b44 100644 --- a/source/dnode/mgmt/mm/mmWorker.c +++ b/source/dnode/mgmt/mm/mmWorker.c @@ -16,6 +16,15 @@ #define _DEFAULT_SOURCE #include "mmInt.h" +static inline void mmSendRsp(SNodeMsg *pMsg, int32_t code) { + SRpcMsg rsp = {.handle = pMsg->rpcMsg.handle, + .ahandle = pMsg->rpcMsg.ahandle, + .code = code, + .pCont = pMsg->pRsp, + .contLen = pMsg->rspLen}; + tmsgSendRsp(&rsp); +} + static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; @@ -35,8 +44,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { if (pRpc->msgType & 1U) { if (pRpc->handle != NULL && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { if (code != 0 && terrno != 0) code = terrno; - SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .contLen = pMsg->rspLen, .pCont = pMsg->pRsp}; - tmsgSendRsp(&rsp); + mmSendRsp(pMsg, code); } } @@ -48,7 +56,7 @@ static void mmProcessQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; - dTrace("msg:%p, get from mnode query queue", pMsg); + dTrace("msg:%p, get from mnode-query queue", pMsg); SRpcMsg *pRpc = &pMsg->rpcMsg; int32_t code = -1; @@ -58,8 +66,7 @@ static void mmProcessQueryQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) { if (pRpc->msgType & 1U) { if (pRpc->handle != NULL && code != 0) { dError("msg:%p, failed to process since %s", pMsg, terrstr()); - SRpcMsg rsp = {.handle = pRpc->handle, .code = code, .ahandle = pRpc->ahandle}; - tmsgSendRsp(&rsp); + mmSendRsp(pMsg, code); } } @@ -98,11 +105,8 @@ int32_t mmProcessQueryMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { } int32_t mmProcessMonitorMsg(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) { - SMnodeMgmt *pMgmt = pWrapper->pMgmt; - SSingleWorker *pWorker = &pMgmt->monitorWorker; - - dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name); - taosWriteQitem(pWorker->queue, pMsg); + SMnodeMgmt *pMgmt = pWrapper->pMgmt; + mmPutMsgToWorker(&pMgmt->monitorWorker, pMsg); return 0; } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 1cb0c78aa5..0197e68531 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -100,6 +100,7 @@ typedef struct { } SGrantInfo; typedef struct SMnode { + int32_t selfId; int64_t clusterId; int8_t replica; int8_t selfIndex; @@ -121,7 +122,7 @@ typedef struct SMnode { SHashObj *infosMeta; SGrantInfo grant; MndMsgFp msgFp[TDMT_MAX]; - SMsgCb msgCb; + SMsgCb msgCb; } SMnode; void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp); diff --git a/source/dnode/mnode/impl/inc/mndMnode.h b/source/dnode/mnode/impl/inc/mndMnode.h index 5df1391563..8041cc8fef 100644 --- a/source/dnode/mnode/impl/inc/mndMnode.h +++ b/source/dnode/mnode/impl/inc/mndMnode.h @@ -22,12 +22,14 @@ extern "C" { #endif -int32_t mndInitMnode(SMnode *pMnode); -void mndCleanupMnode(SMnode *pMnode); -bool mndIsMnode(SMnode *pMnode, int32_t dnodeId); -void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet); -char *mndGetRoleStr(int32_t role); -void mndUpdateMnodeRole(SMnode *pMnode); +int32_t mndInitMnode(SMnode *pMnode); +void mndCleanupMnode(SMnode *pMnode); +SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId); +void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj); +bool mndIsMnode(SMnode *pMnode, int32_t dnodeId); +void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet); +void mndUpdateMnodeRole(SMnode *pMnode); +const char *mndGetRoleStr(int32_t role); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index a8b1ec393b..652e5794df 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -396,7 +396,7 @@ static int32_t mndProcessDropBnodeReq(SNodeMsg *pReq) { mDebug("bnode:%d, start to drop", dropReq.dnodeId); if (dropReq.dnodeId <= 0) { - terrno = TSDB_CODE_SDB_APP_ERROR; + terrno = TSDB_CODE_INVALID_MSG; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 260b1db410..60de1c2723 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1040,7 +1040,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; - while (true) { + while (1) { SVgObj *pVgroup = NULL; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); if (pIter == NULL) break; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index c38106b915..6a16f09204 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -552,6 +552,7 @@ static int32_t mndProcessDropDnodeReq(SNodeMsg *pReq) { int32_t code = -1; SUserObj *pUser = NULL; SDnodeObj *pDnode = NULL; + SMnodeObj *pMObj = NULL; SMDropMnodeReq dropReq = {0}; if (tDeserializeSCreateDropMQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { @@ -572,6 +573,12 @@ static int32_t mndProcessDropDnodeReq(SNodeMsg *pReq) { goto DROP_DNODE_OVER; } + pMObj = mndAcquireMnode(pMnode, dropReq.dnodeId); + if (pMObj != NULL) { + terrno = TSDB_CODE_MND_MNODE_DEPLOYED; + goto DROP_DNODE_OVER; + } + pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; @@ -592,6 +599,7 @@ DROP_DNODE_OVER: mndReleaseDnode(pMnode, pDnode); mndReleaseUser(pMnode, pUser); + mndReleaseMnode(pMnode, pMObj); return code; } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 8543ac7c7d..c4f928e8a9 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -21,8 +21,8 @@ #include "mndTrans.h" #include "mndUser.h" -#define TSDB_MNODE_VER_NUMBER 1 -#define TSDB_MNODE_RESERVE_SIZE 64 +#define MNODE_VER_NUMBER 1 +#define MNODE_RESERVE_SIZE 64 static int32_t mndCreateDefaultMnode(SMnode *pMnode); static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj); @@ -64,21 +64,20 @@ int32_t mndInitMnode(SMnode *pMnode) { void mndCleanupMnode(SMnode *pMnode) {} -static SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId) { - SSdb *pSdb = pMnode->pSdb; - SMnodeObj *pObj = sdbAcquire(pSdb, SDB_MNODE, &mnodeId); +SMnodeObj *mndAcquireMnode(SMnode *pMnode, int32_t mnodeId) { + SMnodeObj *pObj = sdbAcquire(pMnode->pSdb, SDB_MNODE, &mnodeId); if (pObj == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) { terrno = TSDB_CODE_MND_MNODE_NOT_EXIST; } return pObj; } -static void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) { +void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) { SSdb *pSdb = pMnode->pSdb; - sdbRelease(pSdb, pObj); + sdbRelease(pMnode->pSdb, pObj); } -char *mndGetRoleStr(int32_t showType) { +const char *mndGetRoleStr(int32_t showType) { switch (showType) { case TAOS_SYNC_STATE_FOLLOWER: return "unsynced"; @@ -130,18 +129,18 @@ static int32_t mndCreateDefaultMnode(SMnode *pMnode) { static SSdbRaw *mndMnodeActionEncode(SMnodeObj *pObj) { terrno = TSDB_CODE_OUT_OF_MEMORY; - SSdbRaw *pRaw = sdbAllocRaw(SDB_MNODE, TSDB_MNODE_VER_NUMBER, sizeof(SMnodeObj) + TSDB_MNODE_RESERVE_SIZE); - if (pRaw == NULL) goto MNODE_ENCODE_OVER; + SSdbRaw *pRaw = sdbAllocRaw(SDB_MNODE, MNODE_VER_NUMBER, sizeof(SMnodeObj) + MNODE_RESERVE_SIZE); + if (pRaw == NULL) goto _OVER; int32_t dataPos = 0; - SDB_SET_INT32(pRaw, dataPos, pObj->id, MNODE_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pObj->createdTime, MNODE_ENCODE_OVER) - SDB_SET_INT64(pRaw, dataPos, pObj->updateTime, MNODE_ENCODE_OVER) - SDB_SET_RESERVE(pRaw, dataPos, TSDB_MNODE_RESERVE_SIZE, MNODE_ENCODE_OVER) + SDB_SET_INT32(pRaw, dataPos, pObj->id, _OVER) + SDB_SET_INT64(pRaw, dataPos, pObj->createdTime, _OVER) + SDB_SET_INT64(pRaw, dataPos, pObj->updateTime, _OVER) + SDB_SET_RESERVE(pRaw, dataPos, MNODE_RESERVE_SIZE, _OVER) terrno = 0; -MNODE_ENCODE_OVER: +_OVER: if (terrno != 0) { mError("mnode:%d, failed to encode to raw:%p since %s", pObj->id, pRaw, terrstr()); sdbFreeRaw(pRaw); @@ -158,26 +157,26 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; - if (sver != TSDB_MNODE_VER_NUMBER) { + if (sver != MNODE_VER_NUMBER) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; - goto MNODE_DECODE_OVER; + goto _OVER; } SSdbRow *pRow = sdbAllocRow(sizeof(SMnodeObj)); - if (pRow == NULL) goto MNODE_DECODE_OVER; + if (pRow == NULL) goto _OVER; SMnodeObj *pObj = sdbGetRowObj(pRow); - if (pObj == NULL) goto MNODE_DECODE_OVER; + if (pObj == NULL) goto _OVER; int32_t dataPos = 0; - SDB_GET_INT32(pRaw, dataPos, &pObj->id, MNODE_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pObj->createdTime, MNODE_DECODE_OVER) - SDB_GET_INT64(pRaw, dataPos, &pObj->updateTime, MNODE_DECODE_OVER) - SDB_GET_RESERVE(pRaw, dataPos, TSDB_MNODE_RESERVE_SIZE, MNODE_DECODE_OVER) + SDB_GET_INT32(pRaw, dataPos, &pObj->id, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pObj->createdTime, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pObj->updateTime, _OVER) + SDB_GET_RESERVE(pRaw, dataPos, MNODE_RESERVE_SIZE, _OVER) terrno = 0; -MNODE_DECODE_OVER: +_OVER: if (terrno != 0) { mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); taosMemoryFreeClear(pRow); @@ -188,8 +187,6 @@ MNODE_DECODE_OVER: return pRow; } -static void mnodeResetMnode(SMnodeObj *pObj) { pObj->role = TAOS_SYNC_STATE_FOLLOWER; } - static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) { mTrace("mnode:%d, perform insert action, row:%p", pObj->id, pObj); pObj->pDnode = sdbAcquire(pSdb, SDB_DNODE, &pObj->id); @@ -199,7 +196,7 @@ static int32_t mndMnodeActionInsert(SSdb *pSdb, SMnodeObj *pObj) { return -1; } - mnodeResetMnode(pObj); + pObj->role = TAOS_SYNC_STATE_FOLLOWER; return 0; } @@ -233,7 +230,6 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) { void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { SSdb *pSdb = pMnode->pSdb; - pEpSet->numOfEps = 0; void *pIter = NULL; @@ -241,14 +237,15 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) { SMnodeObj *pObj = NULL; pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pObj); if (pIter == NULL) break; - if (pObj->pDnode == NULL) break; - - if (pObj->role == TAOS_SYNC_STATE_LEADER) { - pEpSet->inUse = pEpSet->numOfEps; + if (pObj->pDnode == NULL) { + mError("mnode:%d, no corresponding dnode exists", pObj->id); + } else { + if (pObj->role == TAOS_SYNC_STATE_LEADER) { + pEpSet->inUse = pEpSet->numOfEps; + } + addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port); + sdbRelease(pSdb, pObj); } - - addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port); - sdbRelease(pSdb, pObj); } } @@ -364,18 +361,18 @@ static int32_t mndCreateMnode(SMnode *pMnode, SNodeMsg *pReq, SDnodeObj *pDnode, mnodeObj.updateTime = mnodeObj.createdTime; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_CREATE_MNODE, &pReq->rpcMsg); - if (pTrans == NULL) goto CREATE_MNODE_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to create mnode:%d", pTrans->id, pCreate->dnodeId); - if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto CREATE_MNODE_OVER; - if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto CREATE_MNODE_OVER; - if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto CREATE_MNODE_OVER; + if (mndSetCreateMnodeRedoLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER; + if (mndSetCreateMnodeCommitLogs(pMnode, pTrans, &mnodeObj) != 0) goto _OVER; + if (mndSetCreateMnodeRedoActions(pMnode, pTrans, pDnode, &mnodeObj) != 0) goto _OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto CREATE_MNODE_OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -CREATE_MNODE_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -390,7 +387,7 @@ static int32_t mndProcessCreateMnodeReq(SNodeMsg *pReq) { if (tDeserializeSCreateDropMQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto CREATE_MNODE_OVER; + goto _OVER; } mDebug("mnode:%d, start to create", createReq.dnodeId); @@ -398,31 +395,31 @@ static int32_t mndProcessCreateMnodeReq(SNodeMsg *pReq) { pObj = mndAcquireMnode(pMnode, createReq.dnodeId); if (pObj != NULL) { terrno = TSDB_CODE_MND_MNODE_ALREADY_EXIST; - goto CREATE_MNODE_OVER; + goto _OVER; } else if (terrno != TSDB_CODE_MND_MNODE_NOT_EXIST) { - goto CREATE_MNODE_OVER; + goto _OVER; } pDnode = mndAcquireDnode(pMnode, createReq.dnodeId); if (pDnode == NULL) { terrno = TSDB_CODE_MND_DNODE_NOT_EXIST; - goto CREATE_MNODE_OVER; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; - goto CREATE_MNODE_OVER; + goto _OVER; } if (mndCheckNodeAuth(pUser)) { - goto CREATE_MNODE_OVER; + goto _OVER; } code = mndCreateMnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -CREATE_MNODE_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("mnode:%d, failed to create since %s", createReq.dnodeId, terrstr()); } @@ -531,18 +528,18 @@ static int32_t mndDropMnode(SMnode *pMnode, SNodeMsg *pReq, SMnodeObj *pObj) { int32_t code = -1; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_TYPE_DROP_MNODE, &pReq->rpcMsg); - if (pTrans == NULL) goto DROP_MNODE_OVER; + if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop mnode:%d", pTrans->id, pObj->id); - if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) goto DROP_MNODE_OVER; - if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) goto DROP_MNODE_OVER; - if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) goto DROP_MNODE_OVER; - if (mndTransPrepare(pMnode, pTrans) != 0) goto DROP_MNODE_OVER; + if (mndSetDropMnodeRedoLogs(pMnode, pTrans, pObj) != 0) goto _OVER; + if (mndSetDropMnodeCommitLogs(pMnode, pTrans, pObj) != 0) goto _OVER; + if (mndSetDropMnodeRedoActions(pMnode, pTrans, pObj->pDnode, pObj) != 0) goto _OVER; + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; -DROP_MNODE_OVER: +_OVER: mndTransDrop(pTrans); return code; } @@ -556,35 +553,45 @@ static int32_t mndProcessDropMnodeReq(SNodeMsg *pReq) { if (tDeserializeSCreateDropMQSBNodeReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; - goto DROP_MNODE_OVER; + goto _OVER; } mDebug("mnode:%d, start to drop", dropReq.dnodeId); if (dropReq.dnodeId <= 0) { - terrno = TSDB_CODE_SDB_APP_ERROR; - goto DROP_MNODE_OVER; + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; } pObj = mndAcquireMnode(pMnode, dropReq.dnodeId); if (pObj == NULL) { - goto DROP_MNODE_OVER; + goto _OVER; + } + + if (pMnode->selfId == dropReq.dnodeId) { + terrno = TSDB_CODE_MND_CANT_DROP_MASTER; + goto _OVER; + } + + if (sdbGetSize(pMnode->pSdb, SDB_MNODE) <= 1) { + terrno = TSDB_CODE_MND_TOO_FEW_MNODES; + goto _OVER; } pUser = mndAcquireUser(pMnode, pReq->user); if (pUser == NULL) { terrno = TSDB_CODE_MND_NO_USER_FROM_CONN; - goto DROP_MNODE_OVER; + goto _OVER; } if (mndCheckNodeAuth(pUser)) { - goto DROP_MNODE_OVER; + goto _OVER; } code = mndDropMnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_MND_ACTION_IN_PROGRESS; -DROP_MNODE_OVER: +_OVER: if (code != 0 && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) { mError("mnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr()); } @@ -687,7 +694,7 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, char *data, in cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - char *roles = mndGetRoleStr(pObj->role); + const char *roles = mndGetRoleStr(pObj->role); STR_WITH_MAXSIZE_TO_VARSTR(pWrite, roles, pShow->bytes[cols]); cols++; diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 5204bc95bb..24bd897b63 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -398,7 +398,7 @@ static int32_t mndProcessDropQnodeReq(SNodeMsg *pReq) { mDebug("qnode:%d, start to drop", dropReq.dnodeId); if (dropReq.dnodeId <= 0) { - terrno = TSDB_CODE_SDB_APP_ERROR; + terrno = TSDB_CODE_INVALID_MSG; goto _OVER; } @@ -453,7 +453,7 @@ static int32_t mndProcessQnodeListReq(SNodeMsg *pReq) { goto _OVER; } - while (true) { + while (1) { void *pIter = sdbFetch(pSdb, SDB_QNODE, NULL, (void **)&pObj); if (pIter == NULL) break; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 87e5962f6b..731dcd087a 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -406,7 +406,7 @@ static int32_t mndProcessDropSnodeReq(SNodeMsg *pReq) { mDebug("snode:%d, start to drop", dropReq.dnodeId); if (dropReq.dnodeId <= 0) { - terrno = TSDB_CODE_SDB_APP_ERROR; + terrno = TSDB_CODE_INVALID_MSG; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 8a14d882da..15a70e3311 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -105,7 +105,6 @@ static int32_t mndRestoreWal(SMnode *pMnode) { if (walEndSnapshot(pWal) < 0) { goto WAL_RESTORE_OVER; } - } code = 0; @@ -129,7 +128,9 @@ int32_t mndInitSync(SMnode *pMnode) { return -1; } - pMgmt->state = TAOS_SYNC_STATE_LEADER; + if (pMnode->selfId == 1) { + pMgmt->state = TAOS_SYNC_STATE_LEADER; + } pMgmt->pSyncNode = NULL; return 0; } diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 86bbc0257b..5a1780530c 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -215,7 +215,6 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) { } else { if (mndAllocStep(pMnode, "mnode-sdb-read", mndReadSdb, NULL) != 0) return -1; } - // if (mndAllocStep(pMnode, "mnode-timer", mndInitTimer, NULL) != 0) return -1; if (mndAllocStep(pMnode, "mnode-profile", mndInitProfile, mndCleanupProfile) != 0) return -1; if (mndAllocStep(pMnode, "mnode-show", mndInitShow, mndCleanupShow) != 0) return -1; if (mndAllocStep(pMnode, "mnode-query", mndInitQuery, mndCleanupQuery) != 0) return -1; @@ -272,6 +271,7 @@ static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) { pMnode->selfIndex = pOption->selfIndex; memcpy(&pMnode->replicas, pOption->replicas, sizeof(SReplica) * TSDB_MAX_REPLICA); pMnode->msgCb = pOption->msgCb; + pMnode->selfId = pOption->replicas[pOption->selfIndex].id; } SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) { diff --git a/source/util/src/terror.c b/source/util/src/terror.c index e4771c95f8..a14ba94515 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -201,6 +201,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SNODE_ALREADY_EXIST, "Snode already exists" TAOS_DEFINE_ERROR(TSDB_CODE_MND_SNODE_NOT_EXIST, "Snode not there") TAOS_DEFINE_ERROR(TSDB_CODE_MND_BNODE_ALREADY_EXIST, "Bnode already exists") TAOS_DEFINE_ERROR(TSDB_CODE_MND_BNODE_NOT_EXIST, "Bnode not there") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_FEW_MNODES, "Too few mnodes") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_MNODE_DEPLOYED, "Mnode deployed in this dnode") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_CANT_DROP_MASTER, "Can't drop mnode which is master") // mnode-acct TAOS_DEFINE_ERROR(TSDB_CODE_MND_ACCT_ALREADY_EXIST, "Account already exists") From faec543f73b95c71f1216c05662acdaf0ec1e287 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 9 Apr 2022 19:38:49 +0800 Subject: [PATCH 14/45] test[cluster]: create and drop mnode --- tests/script/jenkins/basic.txt | 3 + tests/script/tsim/mnode/basic1.sim | 118 +++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 tests/script/tsim/mnode/basic1.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 61e9b0b650..2d18167337 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -42,6 +42,9 @@ # ---- bnode ./test.sh -f tsim/bnode/basic1.sim +# ---- mnode +./test.sh -f tsim/bnode/basic1.sim + # ---- show ./test.sh -f tsim/show/basic.sim diff --git a/tests/script/tsim/mnode/basic1.sim b/tests/script/tsim/mnode/basic1.sim new file mode 100644 index 0000000000..74ec44328d --- /dev/null +++ b/tests/script/tsim/mnode/basic1.sim @@ -0,0 +1,118 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== show dnodes +sql show dnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +sql show mnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data02 != master then + return -1 +endi + +print =============== create dnodes +sql create dnode $hostname port 7200 +sleep 2000 + +sql show dnodes; +if $rows != 2 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data10 != 2 then + return -1 +endi + +print $data02 +if $data02 != 0 then + return -1 +endi + +if $data12 != 0 then + return -1 +endi + +if $data04 != ready then + return -1 +endi + +if $data14 != ready then + return -1 +endi + +sql show mnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + +if $data02 != master then + return -1 +endi + +return +print =============== create drop mnode 1 +sql_error create mnode on dnode 1 +sql_error drop mnode on dnode 1 + +print =============== create drop mnode 2 +sql create mnode on dnode 2 +sql show mnodes +if $rows != 2 then + return -1 +endi +sql_error create mnode on dnode 2 + +sql drop mnode on dnode 2 +sql show mnodes +if $rows != 1 then + return -1 +endi +sql_error drop mnode on dnode 2 + +print =============== create drop mnodes +sql create mnode on dnode 2 +sql show mnodes +if $rows != 2 then + return -1 +endi + +print =============== restart +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start + +sleep 2000 +sql show mnodes +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT From b8bdbed3dbc89c831afc94a1b75f1e99cb7b8085 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 10 Apr 2022 13:47:28 +0800 Subject: [PATCH 15/45] fix[cluster]: redirect meg when node not deployed --- include/util/taoserror.h | 13 +++++++------ source/dnode/mgmt/main/dndInt.c | 4 ++-- source/dnode/mgmt/main/dndTransport.c | 13 ++++++------- source/util/src/terror.c | 1 + 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index b1eb17a00f..93efbdb989 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -286,14 +286,15 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2) // mnode-sma -#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0400) -#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0401) -#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0402) +#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480) +#define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481) +#define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482) // dnode -#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x04A1) -#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A3) -#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x04A4) +#define TSDB_CODE_NODE_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0400) +#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401) +#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0403) +#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0404) // vnode #define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) diff --git a/source/dnode/mgmt/main/dndInt.c b/source/dnode/mgmt/main/dndInt.c index d406b0c02e..7b207fd496 100644 --- a/source/dnode/mgmt/main/dndInt.c +++ b/source/dnode/mgmt/main/dndInt.c @@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + terrno = TSDB_CODE_NODE_REDIRECT; pRetWrapper = NULL; } taosRUnLockLatch(&pWrapper->latch); @@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + terrno = TSDB_CODE_NODE_REDIRECT; code = -1; } taosRUnLockLatch(&pWrapper->latch); diff --git a/source/dnode/mgmt/main/dndTransport.c b/source/dnode/mgmt/main/dndTransport.c index 5e4f403b1e..75722c8f9c 100644 --- a/source/dnode/mgmt/main/dndTransport.c +++ b/source/dnode/mgmt/main/dndTransport.c @@ -85,6 +85,7 @@ _OVER: } else { dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr()); if (pRpc->msgType & 1U) { + if (terrno != 0) code = terrno; SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; tmsgSendRsp(&rsp); } @@ -347,14 +348,12 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p } static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { - if (pRsp->code == TSDB_CODE_APP_NOT_READY) { - if (pWrapper->ntype == MNODE) { - dmSendRedirectRsp(pWrapper->pMgmt, pRsp); - return; - } + if (pRsp->code == TSDB_CODE_APP_NOT_READY || pRsp->code == TSDB_CODE_NODE_REDIRECT || + pRsp->code == TSDB_CODE_NODE_OFFLINE) { + dmSendRedirectRsp(pWrapper->pMgmt, pRsp); + } else { + rpcSendResponse(pRsp); } - - rpcSendResponse(pRsp); } static int32_t dndSendReq(SMgmtWrapper *pWrapper, const SEpSet *pEpSet, SRpcMsg *pReq) { diff --git a/source/util/src/terror.c b/source/util/src/terror.c index a14ba94515..ded42365b6 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -283,6 +283,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_NOT_EXIST, "SMA does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma option") // dnode +TAOS_DEFINE_ERROR(TSDB_CODE_NODE_REDIRECT, "Node need redirect") TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, "Node is offline") TAOS_DEFINE_ERROR(TSDB_CODE_NODE_ALREADY_DEPLOYED, "Node already deployed") TAOS_DEFINE_ERROR(TSDB_CODE_NODE_NOT_DEPLOYED, "Node not deployed") From a3ac72079e4dd92bcc99b479077d519a5b610eee Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 10 Apr 2022 14:04:44 +0800 Subject: [PATCH 16/45] fix[cluster]: redirect msg when node not deployed --- source/dnode/mgmt/test/bnode/CMakeLists.txt | 8 ++++---- source/dnode/mgmt/test/mnode/CMakeLists.txt | 8 ++++---- source/dnode/mgmt/test/mnode/dmnode.cpp | 2 +- source/dnode/mgmt/test/qnode/CMakeLists.txt | 8 ++++---- source/dnode/mgmt/test/snode/CMakeLists.txt | 8 ++++---- source/dnode/mgmt/test/vnode/CMakeLists.txt | 8 ++++---- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/dnode/mgmt/test/bnode/CMakeLists.txt b/source/dnode/mgmt/test/bnode/CMakeLists.txt index 22edc9b257..0c0006488d 100644 --- a/source/dnode/mgmt/test/bnode/CMakeLists.txt +++ b/source/dnode/mgmt/test/bnode/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. BQTEST_SRC) -add_executable(dnode_test_bnode ${BQTEST_SRC}) +add_executable(dbnodeTest ${BQTEST_SRC}) target_link_libraries( - dnode_test_bnode + dbnodeTest PUBLIC sut ) add_test( - NAME dnode_test_bnode - COMMAND dnode_test_bnode + NAME dbnodeTest + COMMAND dbnodeTest ) diff --git a/source/dnode/mgmt/test/mnode/CMakeLists.txt b/source/dnode/mgmt/test/mnode/CMakeLists.txt index be29b93b02..3237487242 100644 --- a/source/dnode/mgmt/test/mnode/CMakeLists.txt +++ b/source/dnode/mgmt/test/mnode/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. DMTEST_SRC) -add_executable(dnode_test_mnode ${DMTEST_SRC}) +add_executable(dmnodeTest ${DMTEST_SRC}) target_link_libraries( - dnode_test_mnode + dmnodeTest PUBLIC sut ) add_test( - NAME dnode_test_mnode - COMMAND dnode_test_mnode + NAME dmnodeTest + COMMAND dmnodeTest ) diff --git a/source/dnode/mgmt/test/mnode/dmnode.cpp b/source/dnode/mgmt/test/mnode/dmnode.cpp index e92e51fa39..348eb50c8f 100644 --- a/source/dnode/mgmt/test/mnode/dmnode.cpp +++ b/source/dnode/mgmt/test/mnode/dmnode.cpp @@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_REDIRECT); } { diff --git a/source/dnode/mgmt/test/qnode/CMakeLists.txt b/source/dnode/mgmt/test/qnode/CMakeLists.txt index 2536001231..d118a8723a 100644 --- a/source/dnode/mgmt/test/qnode/CMakeLists.txt +++ b/source/dnode/mgmt/test/qnode/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. DQTEST_SRC) -add_executable(dnode_test_qnode ${DQTEST_SRC}) +add_executable(dqnodeTest ${DQTEST_SRC}) target_link_libraries( - dnode_test_qnode + dqnodeTest PUBLIC sut ) add_test( - NAME dnode_test_qnode - COMMAND dnode_test_qnode + NAME dqnodeTest + COMMAND dqnodeTest ) diff --git a/source/dnode/mgmt/test/snode/CMakeLists.txt b/source/dnode/mgmt/test/snode/CMakeLists.txt index 9c163d1999..eaabc5647b 100644 --- a/source/dnode/mgmt/test/snode/CMakeLists.txt +++ b/source/dnode/mgmt/test/snode/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. SQTEST_SRC) -add_executable(dnode_test_snode ${SQTEST_SRC}) +add_executable(dsnodeTest ${SQTEST_SRC}) target_link_libraries( - dnode_test_snode + dsnodeTest PUBLIC sut ) add_test( - NAME dnode_test_snode - COMMAND dnode_test_snode + NAME dsnodeTest + COMMAND dsnodeTest ) diff --git a/source/dnode/mgmt/test/vnode/CMakeLists.txt b/source/dnode/mgmt/test/vnode/CMakeLists.txt index 6fb8bb4ba4..e2cd868513 100644 --- a/source/dnode/mgmt/test/vnode/CMakeLists.txt +++ b/source/dnode/mgmt/test/vnode/CMakeLists.txt @@ -1,11 +1,11 @@ aux_source_directory(. VNODE_SRC) -add_executable(dnode_test_vnode ${VNODE_SRC}) +add_executable(dvnodeTest ${VNODE_SRC}) target_link_libraries( - dnode_test_vnode + dvnodeTest PUBLIC sut ) add_test( - NAME dnode_test_vnode - COMMAND dnode_test_vnode + NAME dvnodeTest + COMMAND dvnodeTest ) From 1df069814a28903da29596789f7363dd25f46b49 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 10 Apr 2022 15:35:09 +0800 Subject: [PATCH 17/45] feat[query]:add time slice operator. --- source/client/test/clientTests.cpp | 5 +- source/libs/executor/inc/executorimpl.h | 10 +++- source/libs/executor/src/executorimpl.c | 70 ++++++++++++------------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 772f9049e5..fd2abbb559 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -400,7 +400,7 @@ TEST(testCase, show_vgroup_Test) { taos_free_result(pRes); taos_close(pConn); } -#endif + TEST(testCase, create_multiple_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -653,6 +653,7 @@ TEST(testCase, projection_query_stables) { taos_free_result(pRes); taos_close(pConn); } +#endif TEST(testCase, agg_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); @@ -661,7 +662,7 @@ TEST(testCase, agg_query_tables) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); taos_free_result(pRes); - pRes = taos_query(pConn, "select count(*) from tu"); + pRes = taos_query(pConn, "select length('abc') from tu"); if (taos_errno(pRes) != 0) { printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 32a5140da2..b1f15482a9 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -609,6 +609,12 @@ typedef struct SSessionAggOperatorInfo { SColumnInfoData timeWindowData; // query time window info for scalar function execution. } SSessionAggOperatorInfo; +typedef struct STimeSliceOperatorInfo { + SOptrBasicInfo binfo; + SInterval interval; + SGroupResInfo groupResInfo; // multiple results build supporter +} STimeSliceOperatorInfo; + typedef struct SStateWindowOperatorInfo { SOptrBasicInfo binfo; SAggSupporter aggSup; @@ -707,6 +713,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo); + #if 0 SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, @@ -716,7 +724,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput); +SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema, int32_t numOfOutput); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ee5c675989..1bc84f85d7 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -5429,58 +5429,48 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { return NULL; } - STableIntervalOperatorInfo* pIntervalInfo = pOperator->info; - - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; + STimeSliceOperatorInfo* pSliceInfo = pOperator->info; if (pOperator->status == OP_RES_TO_RETURN) { // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); - - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { + if (pSliceInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pSliceInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } - return pIntervalInfo->binfo.pRes; + return pSliceInfo->binfo.pRes; } - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - int32_t order = pQueryAttr->order.order; - STimeWindow win = pQueryAttr->window; - + int32_t order = TSDB_ORDER_ASC; +// STimeWindow win = pQueryAttr->window; SOperatorInfo* downstream = pOperator->pDownstream[0]; while (1) { publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); - if (pBlock == NULL) { break; } // setTagValue(pOperator, pRuntimeEnv->current->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput); - // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order); - hashAllIntervalAgg(pOperator, &pIntervalInfo->binfo.resultRowInfo, pBlock, 0); + setInputDataBlock(pOperator, pSliceInfo->binfo.pCtx, pBlock, order); + hashAllIntervalAgg(pOperator, &pSliceInfo->binfo.resultRowInfo, pBlock, 0); } // restore the value - pQueryAttr->order.order = order; - pQueryAttr->window = win; - pOperator->status = OP_RES_TO_RETURN; - closeAllResultRows(&pIntervalInfo->binfo.resultRowInfo); + closeAllResultRows(&pSliceInfo->binfo.resultRowInfo); setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - finalizeQueryResult(pIntervalInfo->binfo.pCtx, pOperator->numOfOutput); + finalizeQueryResult(pSliceInfo->binfo.pCtx, pOperator->numOfOutput); - initGroupResInfo(&pRuntimeEnv->groupResInfo, &pIntervalInfo->binfo.resultRowInfo); - // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); + initGroupResInfo(&pSliceInfo->groupResInfo, &pSliceInfo->binfo.resultRowInfo); + // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pSliceInfo->pRes); - if (pIntervalInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { + if (pSliceInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pSliceInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; } - return pIntervalInfo->binfo.pRes->info.rows == 0 ? NULL : pIntervalInfo->binfo.pRes; + return pSliceInfo->binfo.pRes->info.rows == 0 ? NULL : pSliceInfo->binfo.pRes; } static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup) { @@ -6238,28 +6228,34 @@ _error: return NULL; } -SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, - SExprInfo* pExpr, int32_t numOfOutput) { - STableIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableIntervalOperatorInfo)); +SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo) { + STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pOperator == NULL || pInfo == NULL) { + goto _error; + } - // pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); - // pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - - pOperator->name = "AllTimeIntervalAggOperator"; + pOperator->name = "TimeSliceOperator"; // pOperator->operatorType = OP_AllTimeWindow; pOperator->blockingOptr = true; - pOperator->status = OP_NOT_OPENED; - pOperator->pExpr = pExpr; - pOperator->numOfOutput = numOfOutput; - pOperator->info = pInfo; - pOperator->getNextFn = doAllIntervalAgg; - pOperator->closeFn = destroyBasicOperatorInfo; + pOperator->status = OP_NOT_OPENED; + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->getNextFn = doAllIntervalAgg; + pOperator->closeFn = destroyBasicOperatorInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; + + _error: + taosMemoryFree(pInfo); + taosMemoryFree(pOperator); + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { From 14ec5b672a2cd70264c42a4f8cec5511ca7ea76d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 10 Apr 2022 18:24:16 +0800 Subject: [PATCH 18/45] fix[cluster]: redirect msg when mnode not deployed --- source/dnode/mgmt/main/dndInt.c | 4 ++-- source/dnode/mgmt/main/dndTransport.c | 16 +++++++++++----- tests/script/tsim/mnode/basic1.sim | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/dnode/mgmt/main/dndInt.c b/source/dnode/mgmt/main/dndInt.c index 7b207fd496..d406b0c02e 100644 --- a/source/dnode/mgmt/main/dndInt.c +++ b/source/dnode/mgmt/main/dndInt.c @@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_REDIRECT; + terrno = TSDB_CODE_NODE_NOT_DEPLOYED; pRetWrapper = NULL; } taosRUnLockLatch(&pWrapper->latch); @@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_REDIRECT; + terrno = TSDB_CODE_NODE_NOT_DEPLOYED; code = -1; } taosRUnLockLatch(&pWrapper->latch); diff --git a/source/dnode/mgmt/main/dndTransport.c b/source/dnode/mgmt/main/dndTransport.c index 75722c8f9c..b639b79935 100644 --- a/source/dnode/mgmt/main/dndTransport.c +++ b/source/dnode/mgmt/main/dndTransport.c @@ -53,8 +53,9 @@ static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpS int32_t code = -1; SNodeMsg *pMsg = NULL; NodeMsgFp msgFp = NULL; + uint16_t msgType = pRpc->msgType; - if (pEpSet && pEpSet->numOfEps > 0 && pRpc->msgType == TDMT_MND_STATUS_RSP) { + if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) { dndUpdateMnodeEpSet(pWrapper->pDnode, pEpSet); } @@ -84,9 +85,15 @@ _OVER: } } else { dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr()); - if (pRpc->msgType & 1U) { + if (msgType & 1U) { if (terrno != 0) code = terrno; - SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; + if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) { + if (msgType > TDMT_MND_MSG && msgType < TDMT_VND_MSG) { + code = TSDB_CODE_NODE_REDIRECT; + } + } + + SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = code}; tmsgSendRsp(&rsp); } dTrace("msg:%p, is freed", pMsg); @@ -348,8 +355,7 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p } static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { - if (pRsp->code == TSDB_CODE_APP_NOT_READY || pRsp->code == TSDB_CODE_NODE_REDIRECT || - pRsp->code == TSDB_CODE_NODE_OFFLINE) { + if (pRsp->code == TSDB_CODE_NODE_REDIRECT) { dmSendRedirectRsp(pWrapper->pMgmt, pRsp); } else { rpcSendResponse(pRsp); diff --git a/tests/script/tsim/mnode/basic1.sim b/tests/script/tsim/mnode/basic1.sim index 74ec44328d..e3d27d0c13 100644 --- a/tests/script/tsim/mnode/basic1.sim +++ b/tests/script/tsim/mnode/basic1.sim @@ -75,7 +75,6 @@ if $data02 != master then return -1 endi -return print =============== create drop mnode 1 sql_error create mnode on dnode 1 sql_error drop mnode on dnode 1 From 2662a3b69d41a086ff36ce5c476646a9c7bfb82a Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sun, 10 Apr 2022 19:08:16 +0800 Subject: [PATCH 19/45] [TD-13254]: make 3.0 grant. --- CMakeLists.txt | 16 +-- cmake/bdb_CMakeLists.txt.in.bak | 4 +- cmake/cjson_CMakeLists.txt.in | 2 +- cmake/craft_CMakeLists.txt.in | 4 +- cmake/gnuregex_CMakeLists.txt.in | 2 +- cmake/gtest_CMakeLists.txt.in | 2 +- cmake/iconv_CMakeLists.txt.in | 2 +- cmake/leveldb_CMakeLists.txt.in | 2 +- cmake/libuv_CMakeLists.txt.in | 4 +- cmake/lucene_CMakeLists.txt.in | 2 +- cmake/lz4_CMakeLists.txt.in | 2 +- cmake/nuraft_CMakeLists.txt.in | 4 +- cmake/pthread_CMakeLists.txt.in | 2 +- cmake/rocksdb_CMakeLists.txt.in | 2 +- cmake/sqlite_CMakeLists.txt.in | 4 +- cmake/stub_CMakeLists.txt.in | 4 +- cmake/traft_CMakeLists.txt.in | 4 +- cmake/zlib_CMakeLists.txt.in | 2 +- contrib/CMakeLists.txt | 44 ++++---- docs/CMakeLists.txt | 2 +- docs/Doxyfile.in | 2 +- include/common/tglobal.h | 1 + include/common/tgrant.h | 51 +++++++++ include/util/taoserror.h | 102 ++++++++++++++++++ source/client/CMakeLists.txt | 2 +- source/client/test/CMakeLists.txt | 8 +- source/common/CMakeLists.txt | 6 +- source/common/src/tglobal.c | 2 +- source/common/test/CMakeLists.txt | 6 +- source/dnode/bnode/CMakeLists.txt | 2 +- source/dnode/mgmt/CMakeLists.txt | 2 +- source/dnode/mnode/impl/CMakeLists.txt | 2 +- source/dnode/mnode/sdb/CMakeLists.txt | 2 +- source/dnode/qnode/CMakeLists.txt | 2 +- source/dnode/snode/CMakeLists.txt | 2 +- source/dnode/vnode/test/CMakeLists.txt | 4 +- source/libs/cache/CMakeLists.txt | 2 +- source/libs/catalog/CMakeLists.txt | 2 +- source/libs/catalog/test/CMakeLists.txt | 4 +- source/libs/command/CMakeLists.txt | 2 +- source/libs/command/test/CMakeLists.txt | 4 +- source/libs/executor/CMakeLists.txt | 4 +- source/libs/executor/test/CMakeLists.txt | 4 +- source/libs/function/CMakeLists.txt | 18 ++-- source/libs/index/CMakeLists.txt | 8 +- source/libs/index/test/CMakeLists.txt | 10 +- source/libs/monitor/CMakeLists.txt | 2 +- source/libs/nodes/CMakeLists.txt | 2 +- source/libs/nodes/test/CMakeLists.txt | 4 +- source/libs/parser/CMakeLists.txt | 2 +- source/libs/parser/test/CMakeLists.txt | 4 +- source/libs/planner/CMakeLists.txt | 2 +- source/libs/planner/test/CMakeLists.txt | 6 +- source/libs/qcom/CMakeLists.txt | 2 +- source/libs/qcom/test/CMakeLists.txt | 4 +- source/libs/qworker/CMakeLists.txt | 2 +- source/libs/qworker/test/CMakeLists.txt | 4 +- source/libs/scalar/CMakeLists.txt | 2 +- source/libs/scalar/test/filter/CMakeLists.txt | 4 +- source/libs/scalar/test/scalar/CMakeLists.txt | 4 +- source/libs/scheduler/CMakeLists.txt | 2 +- source/libs/scheduler/test/CMakeLists.txt | 4 +- source/libs/stream/CMakeLists.txt | 2 +- source/libs/sync/CMakeLists.txt | 2 +- source/libs/sync/test/CMakeLists.txt | 80 +++++++------- source/libs/tfs/CMakeLists.txt | 2 +- source/libs/transport/CMakeLists.txt | 4 +- source/libs/transport/test/CMakeLists.txt | 12 +-- source/libs/wal/CMakeLists.txt | 2 +- source/libs/wal/test/CMakeLists.txt | 2 +- source/os/CMakeLists.txt | 10 +- source/util/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 12 +-- 73 files changed, 351 insertions(+), 193 deletions(-) create mode 100644 include/common/tgrant.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e37a14143..0603055e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,17 @@ project( DESCRIPTION "An open-source big data platform designed and optimized for the Internet of Things(IOT)" ) -set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake") -set(CMAKE_CONTRIB_DIR "${CMAKE_SOURCE_DIR}/contrib") +if (NOT DEFINED TD_SOURCE_DIR) + set( TD_SOURCE_DIR ${CMAKE_SOURCE_DIR} ) +endif() -include(${CMAKE_SUPPORT_DIR}/cmake.platform) -include(${CMAKE_SUPPORT_DIR}/cmake.define) -include(${CMAKE_SUPPORT_DIR}/cmake.options) -include(${CMAKE_SUPPORT_DIR}/cmake.version) +set(TD_SUPPORT_DIR "${TD_SOURCE_DIR}/cmake") +set(TD_CONTRIB_DIR "${TD_SOURCE_DIR}/contrib") + +include(${TD_SUPPORT_DIR}/cmake.platform) +include(${TD_SUPPORT_DIR}/cmake.define) +include(${TD_SUPPORT_DIR}/cmake.options) +include(${TD_SUPPORT_DIR}/cmake.version) # contrib add_subdirectory(contrib) diff --git a/cmake/bdb_CMakeLists.txt.in.bak b/cmake/bdb_CMakeLists.txt.in.bak index 52cef74db6..dd21020105 100644 --- a/cmake/bdb_CMakeLists.txt.in.bak +++ b/cmake/bdb_CMakeLists.txt.in.bak @@ -3,8 +3,8 @@ ExternalProject_Add(bdb GIT_REPOSITORY https://github.com/berkeleydb/libdb.git GIT_TAG v5.3.28 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/bdb" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/bdb" + SOURCE_DIR "${TD_CONTRIB_DIR}/bdb" + BINARY_DIR "${TD_CONTRIB_DIR}/bdb" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND COMMAND ./dist/configure --enable-debug BUILD_COMMAND "$(MAKE)" diff --git a/cmake/cjson_CMakeLists.txt.in b/cmake/cjson_CMakeLists.txt.in index c9ec90e809..32cea7baa1 100644 --- a/cmake/cjson_CMakeLists.txt.in +++ b/cmake/cjson_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(cjson GIT_REPOSITORY https://github.com/taosdata-contrib/cJSON.git GIT_TAG v1.7.15 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/cJson" + SOURCE_DIR "${TD_CONTRIB_DIR}/cJson" BINARY_DIR "" CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/cmake/craft_CMakeLists.txt.in b/cmake/craft_CMakeLists.txt.in index 3a951c1c99..f0ec7feaf2 100644 --- a/cmake/craft_CMakeLists.txt.in +++ b/cmake/craft_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(craft GIT_REPOSITORY https://github.com/canonical/raft.git GIT_TAG v0.11.2 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/craft" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/craft" + SOURCE_DIR "${TD_CONTRIB_DIR}/craft" + BINARY_DIR "${TD_CONTRIB_DIR}/craft" #BUILD_IN_SOURCE TRUE # https://answers.ros.org/question/333125/how-to-include-external-automakeautoconf-projects-into-ament_cmake/ CONFIGURE_COMMAND COMMAND autoreconf -i COMMAND ./configure --enable-example diff --git a/cmake/gnuregex_CMakeLists.txt.in b/cmake/gnuregex_CMakeLists.txt.in index e0c07fe3ba..817c22093a 100644 --- a/cmake/gnuregex_CMakeLists.txt.in +++ b/cmake/gnuregex_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(gnuregex URL https://launchpad.net/gnuregex/trunk/2.9/+download/libgnurx-src-2.9.zip DOWNLOAD_NAME libgnurx-src.zip - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/gnuregex" + SOURCE_DIR "${TD_CONTRIB_DIR}/gnuregex" BINARY_DIR "" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "" diff --git a/cmake/gtest_CMakeLists.txt.in b/cmake/gtest_CMakeLists.txt.in index 98701456cf..fe07f2318b 100644 --- a/cmake/gtest_CMakeLists.txt.in +++ b/cmake/gtest_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(googletest GIT_REPOSITORY https://github.com/taosdata-contrib/googletest.git GIT_TAG release-1.11.0 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/googletest" + SOURCE_DIR "${TD_CONTRIB_DIR}/googletest" BINARY_DIR "" CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/cmake/iconv_CMakeLists.txt.in b/cmake/iconv_CMakeLists.txt.in index 31dfd829fc..5eb277ce0d 100644 --- a/cmake/iconv_CMakeLists.txt.in +++ b/cmake/iconv_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(iconv GIT_REPOSITORY https://github.com/win-iconv/win-iconv.git GIT_TAG v0.0.8 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/iconv" + SOURCE_DIR "${TD_CONTRIB_DIR}/iconv" BINARY_DIR "" CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/cmake/leveldb_CMakeLists.txt.in b/cmake/leveldb_CMakeLists.txt.in index ac8a097b25..6878711bc1 100644 --- a/cmake/leveldb_CMakeLists.txt.in +++ b/cmake/leveldb_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(leveldb GIT_REPOSITORY https://github.com/taosdata-contrib/leveldb.git GIT_TAG master - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/leveldb" + SOURCE_DIR "${TD_CONTRIB_DIR}/leveldb" BINARY_DIR "" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "" diff --git a/cmake/libuv_CMakeLists.txt.in b/cmake/libuv_CMakeLists.txt.in index 6c7ab79ed2..14228b775f 100644 --- a/cmake/libuv_CMakeLists.txt.in +++ b/cmake/libuv_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(libuv GIT_REPOSITORY https://github.com/libuv/libuv.git GIT_TAG v1.42.0 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/libuv" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/libuv" + SOURCE_DIR "${TD_CONTRIB_DIR}/libuv" + BINARY_DIR "${TD_CONTRIB_DIR}/libuv" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/lucene_CMakeLists.txt.in b/cmake/lucene_CMakeLists.txt.in index d2a453df2f..9fd7471705 100644 --- a/cmake/lucene_CMakeLists.txt.in +++ b/cmake/lucene_CMakeLists.txt.in @@ -2,7 +2,7 @@ # lucene ExternalProject_Add(lucene GIT_REPOSITORY https://github.com/yihaoDeng/LucenePlusPlus.git - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/lucene" + SOURCE_DIR "${TD_CONTRIB_DIR}/lucene" BINARY_DIR "" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "" diff --git a/cmake/lz4_CMakeLists.txt.in b/cmake/lz4_CMakeLists.txt.in index 199b325b09..381f8f5c5b 100644 --- a/cmake/lz4_CMakeLists.txt.in +++ b/cmake/lz4_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(lz4 GIT_REPOSITORY https://github.com/taosdata-contrib/lz4.git GIT_TAG v1.9.3 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/lz4" + SOURCE_DIR "${TD_CONTRIB_DIR}/lz4" BINARY_DIR "" CONFIGURE_COMMAND "" BUILD_COMMAND "" diff --git a/cmake/nuraft_CMakeLists.txt.in b/cmake/nuraft_CMakeLists.txt.in index 970cb3a830..593c6fed26 100644 --- a/cmake/nuraft_CMakeLists.txt.in +++ b/cmake/nuraft_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(NuRaft GIT_REPOSITORY https://github.com/eBay/NuRaft.git GIT_TAG v1.3.0 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/nuraft" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/nuraft" + SOURCE_DIR "${TD_CONTRIB_DIR}/nuraft" + BINARY_DIR "${TD_CONTRIB_DIR}/nuraft" CONFIGURE_COMMAND "./prepare.sh" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/pthread_CMakeLists.txt.in b/cmake/pthread_CMakeLists.txt.in index ee6d069155..2553df6500 100644 --- a/cmake/pthread_CMakeLists.txt.in +++ b/cmake/pthread_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(pthread GIT_REPOSITORY https://github.com/GerHobbelt/pthread-win32 GIT_TAG v3.0.3.1 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/pthread-win32" + SOURCE_DIR "${TD_CONTRIB_DIR}/pthread-win32" BINARY_DIR "" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "" diff --git a/cmake/rocksdb_CMakeLists.txt.in b/cmake/rocksdb_CMakeLists.txt.in index e38cd876f6..58ae9a1c59 100644 --- a/cmake/rocksdb_CMakeLists.txt.in +++ b/cmake/rocksdb_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(rocksdb GIT_REPOSITORY https://github.com/taosdata-contrib/rocksdb.git GIT_TAG v6.23.3 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/rocksdb" + SOURCE_DIR "${TD_CONTRIB_DIR}/rocksdb" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/sqlite_CMakeLists.txt.in b/cmake/sqlite_CMakeLists.txt.in index 95308833db..445c49487a 100644 --- a/cmake/sqlite_CMakeLists.txt.in +++ b/cmake/sqlite_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(sqlite GIT_REPOSITORY https://github.com/sqlite/sqlite.git GIT_TAG version-3.36.0 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/sqlite" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/sqlite" + SOURCE_DIR "${TD_CONTRIB_DIR}/sqlite" + BINARY_DIR "${TD_CONTRIB_DIR}/sqlite" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "./configure" BUILD_COMMAND "$(MAKE)" diff --git a/cmake/stub_CMakeLists.txt.in b/cmake/stub_CMakeLists.txt.in index e227e820d6..cf175aab42 100644 --- a/cmake/stub_CMakeLists.txt.in +++ b/cmake/stub_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(stub GIT_REPOSITORY https://github.com/coolxv/cpp-stub.git GIT_SUBMODULES "src" - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/cpp-stub/src" + SOURCE_DIR "${TD_CONTRIB_DIR}/cpp-stub" + BINARY_DIR "${TD_CONTRIB_DIR}/cpp-stub/src" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/traft_CMakeLists.txt.in b/cmake/traft_CMakeLists.txt.in index 1dd1323603..0934e2c35c 100644 --- a/cmake/traft_CMakeLists.txt.in +++ b/cmake/traft_CMakeLists.txt.in @@ -3,8 +3,8 @@ ExternalProject_Add(traft GIT_REPOSITORY https://github.com/taosdata/traft.git GIT_TAG for_3.0 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/traft" - BINARY_DIR "${CMAKE_CONTRIB_DIR}/traft" + SOURCE_DIR "${TD_CONTRIB_DIR}/traft" + BINARY_DIR "${TD_CONTRIB_DIR}/traft" #BUILD_IN_SOURCE TRUE # https://answers.ros.org/question/333125/how-to-include-external-automakeautoconf-projects-into-ament_cmake/ CONFIGURE_COMMAND COMMAND autoreconf -i COMMAND ./configure diff --git a/cmake/zlib_CMakeLists.txt.in b/cmake/zlib_CMakeLists.txt.in index 160d3305d0..6c162eb5de 100644 --- a/cmake/zlib_CMakeLists.txt.in +++ b/cmake/zlib_CMakeLists.txt.in @@ -3,7 +3,7 @@ ExternalProject_Add(zlib GIT_REPOSITORY https://github.com/taosdata-contrib/zlib.git GIT_TAG v1.2.11 - SOURCE_DIR "${CMAKE_CONTRIB_DIR}/zlib" + SOURCE_DIR "${TD_CONTRIB_DIR}/zlib" BINARY_DIR "" #BUILD_IN_SOURCE TRUE CONFIGURE_COMMAND "" diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 377e3fbccc..1ddc765c5c 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -7,88 +7,88 @@ function(cat IN_FILE OUT_FILE) endfunction(cat IN_FILE OUT_FILE) set(CONTRIB_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in") -configure_file("${CMAKE_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +configure_file("${TD_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) # pthread if(${BUILD_PTHREAD}) - cat("${CMAKE_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/pthread_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif() # gnu regex if(${BUILD_GNUREGEX}) - cat("${CMAKE_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/gnuregex_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif() # googletest if(${BUILD_TEST}) - cat("${CMAKE_SUPPORT_DIR}/gtest_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) - cat("${CMAKE_SUPPORT_DIR}/stub_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/gtest_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/stub_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_TEST}) # lz4 -cat("${CMAKE_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +cat("${TD_SUPPORT_DIR}/lz4_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) # zlib -cat("${CMAKE_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +cat("${TD_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) # cJson -cat("${CMAKE_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +cat("${TD_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) # leveldb if(${BUILD_WITH_LEVELDB}) - cat("${CMAKE_SUPPORT_DIR}/leveldb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/leveldb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_LEVELDB}) # rocksdb if(${BUILD_WITH_ROCKSDB}) - cat("${CMAKE_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) add_definitions(-DUSE_ROCKSDB) endif(${BUILD_WITH_ROCKSDB}) # canonical-raft if(${BUILD_WITH_CRAFT}) - cat("${CMAKE_SUPPORT_DIR}/craft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/craft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) SET(BUILD_WITH_UV ON CACHE BOOL "craft need libuv" FORCE) endif(${BUILD_WITH_CRAFT}) # traft if(${BUILD_WITH_TRAFT}) - cat("${CMAKE_SUPPORT_DIR}/traft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/traft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) SET(BUILD_WITH_UV ON CACHE BOOL "traft need libuv" FORCE) endif(${BUILD_WITH_TRAFT}) #libuv if(${BUILD_WITH_UV}) - cat("${CMAKE_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/libuv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_UV}) # bdb #if(${BUILD_WITH_BDB}) - #cat("${CMAKE_SUPPORT_DIR}/bdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + #cat("${TD_SUPPORT_DIR}/bdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) #endif(${BUILD_WITH_BDB}) # sqlite if(${BUILD_WITH_SQLITE}) - cat("${CMAKE_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/sqlite_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_SQLITE}) # lucene if(${BUILD_WITH_LUCENE}) - cat("${CMAKE_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) add_definitions(-DUSE_LUCENE) endif(${BUILD_WITH_LUCENE}) # NuRaft if(${BUILD_WITH_NURAFT}) - cat("${CMAKE_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) + cat("${TD_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_NURAFT}) # download dependencies -configure_file(${CONTRIB_TMP_FILE} "${CMAKE_CONTRIB_DIR}/deps-download/CMakeLists.txt") +configure_file(${CONTRIB_TMP_FILE} "${TD_CONTRIB_DIR}/deps-download/CMakeLists.txt") execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY "${CMAKE_CONTRIB_DIR}/deps-download") + WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${CMAKE_CONTRIB_DIR}/deps-download") + WORKING_DIRECTORY "${TD_CONTRIB_DIR}/deps-download") # ================================================================================================ # Build @@ -105,7 +105,7 @@ endif(${BUILD_TEST}) # cJson # see https://stackoverflow.com/questions/37582508/silence-cmp0048-warnings-in-vendored-projects -set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_SUPPORT_DIR}/EnableCMP0048.txt.in") +set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in") option(ENABLE_CJSON_TEST "Enable building cJSON test" OFF) option(CJSON_OVERRIDE_BUILD_SHARED_LIBS "Override BUILD_SHARED_LIBS with CJSON_BUILD_SHARED_LIBS" ON) option(CJSON_BUILD_SHARED_LIBS "Overrides BUILD_SHARED_LIBS if CJSON_OVERRIDE_BUILD_SHARED_LIBS is enabled" OFF) @@ -125,7 +125,7 @@ target_include_directories( ) # zlib -set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_SUPPORT_DIR}/EnableCMP0048.txt.in") +set(CMAKE_PROJECT_INCLUDE_BEFORE "${TD_SUPPORT_DIR}/EnableCMP0048.txt.in") add_subdirectory(zlib) target_include_directories( zlibstatic diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 59552c67d7..da76b2c3fd 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -4,7 +4,7 @@ if(${BUILD_DOCS}) find_package(Doxygen) if (DOXYGEN_FOUND) # Build the doc - set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in) + set(DOXYGEN_IN ${TD_SOURCE_DIR}/docs/Doxyfile.in) set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile) configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 139300ea80..6ca240f52f 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -829,7 +829,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = @CMAKE_SOURCE_DIR@/include @CMAKE_SOURCE_DIR@/source +INPUT = @TD_SOURCE_DIR@/include @TD_SOURCE_DIR@/source # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 006d5849de..f03943e105 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -126,6 +126,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloUrl, SArray *pArgs, bool tsc); void taosCleanupCfg(); void taosCfgDynamicOptions(const char *option, const char *value); +void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary); struct SConfig *taosGetCfg(); diff --git a/include/common/tgrant.h b/include/common/tgrant.h new file mode 100644 index 0000000000..962af0ddc4 --- /dev/null +++ b/include/common/tgrant.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_GTANT_H +#define TDENGINE_GTANT_H + +#ifdef __cplusplus +"C" { +#endif + +typedef enum { + TSDB_GRANT_ALL, + TSDB_GRANT_TIME, + TSDB_GRANT_USER, + TSDB_GRANT_DB, + TSDB_GRANT_TIMESERIES, + TSDB_GRANT_DNODE, + TSDB_GRANT_ACCT, + TSDB_GRANT_STORAGE, + TSDB_GRANT_SPEED, + TSDB_GRANT_QUERY_TIME, + TSDB_GRANT_CONNS, + TSDB_GRANT_STREAMS, + TSDB_GRANT_CPU_CORES, +} EGrantType; + +int32_t grantInit(); +void grantCleanUp(); +void grantParseParameter(); +int32_t grantCheck(EGrantType grant); +void grantReset(EGrantType grant, uint64_t value); +void grantAdd(EGrantType grant, uint64_t value); +void grantRestore(EGrantType grant, uint64_t value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 93efbdb989..04baa3c09d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -428,6 +428,108 @@ int32_t* taosGetErrno(); #define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003) #define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) +// http +#define TSDB_CODE_HTTP_SERVER_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x1100) //"http server is not online" +#define TSDB_CODE_HTTP_UNSUPPORT_URL TAOS_DEF_ERROR_CODE(0, 0x1101) //"url is not support" +#define TSDB_CODE_HTTP_INVALID_URL TAOS_DEF_ERROR_CODE(0, 0x1102) //invalid url format" +#define TSDB_CODE_HTTP_NO_ENOUGH_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1103) //"no enough memory" +#define TSDB_CODE_HTTP_REQUSET_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x1104) //"request size is too big" +#define TSDB_CODE_HTTP_NO_AUTH_INFO TAOS_DEF_ERROR_CODE(0, 0x1105) //"no auth info input" +#define TSDB_CODE_HTTP_NO_MSG_INPUT TAOS_DEF_ERROR_CODE(0, 0x1106) //"request is empty" +#define TSDB_CODE_HTTP_NO_SQL_INPUT TAOS_DEF_ERROR_CODE(0, 0x1107) //"no sql input" +#define TSDB_CODE_HTTP_NO_EXEC_USEDB TAOS_DEF_ERROR_CODE(0, 0x1108) //"no need to execute use db cmd" +#define TSDB_CODE_HTTP_SESSION_FULL TAOS_DEF_ERROR_CODE(0, 0x1109) //"session list was full" +#define TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR TAOS_DEF_ERROR_CODE(0, 0x110A) //"generate taosd token error" +#define TSDB_CODE_HTTP_INVALID_MULTI_REQUEST TAOS_DEF_ERROR_CODE(0, 0x110B) //"size of multi request is 0" +#define TSDB_CODE_HTTP_CREATE_GZIP_FAILED TAOS_DEF_ERROR_CODE(0, 0x110C) //"failed to create gzip" +#define TSDB_CODE_HTTP_FINISH_GZIP_FAILED TAOS_DEF_ERROR_CODE(0, 0x110D) //"failed to finish gzip" +#define TSDB_CODE_HTTP_LOGIN_FAILED TAOS_DEF_ERROR_CODE(0, 0x110E) //"failed to login" + +#define TSDB_CODE_HTTP_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x1120) //"invalid http version" +#define TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH TAOS_DEF_ERROR_CODE(0, 0x1121) //"invalid content length" +#define TSDB_CODE_HTTP_INVALID_AUTH_TYPE TAOS_DEF_ERROR_CODE(0, 0x1122) //"invalid type of Authorization" +#define TSDB_CODE_HTTP_INVALID_AUTH_FORMAT TAOS_DEF_ERROR_CODE(0, 0x1123) //"invalid format of Authorization" +#define TSDB_CODE_HTTP_INVALID_BASIC_AUTH TAOS_DEF_ERROR_CODE(0, 0x1124) //"invalid basic Authorization" +#define TSDB_CODE_HTTP_INVALID_TAOSD_AUTH TAOS_DEF_ERROR_CODE(0, 0x1125) //"invalid taosd Authorization" +#define TSDB_CODE_HTTP_PARSE_METHOD_FAILED TAOS_DEF_ERROR_CODE(0, 0x1126) //"failed to parse method" +#define TSDB_CODE_HTTP_PARSE_TARGET_FAILED TAOS_DEF_ERROR_CODE(0, 0x1127) //"failed to parse target" +#define TSDB_CODE_HTTP_PARSE_VERSION_FAILED TAOS_DEF_ERROR_CODE(0, 0x1128) //"failed to parse http version" +#define TSDB_CODE_HTTP_PARSE_SP_FAILED TAOS_DEF_ERROR_CODE(0, 0x1129) //"failed to parse sp" +#define TSDB_CODE_HTTP_PARSE_STATUS_FAILED TAOS_DEF_ERROR_CODE(0, 0x112A) //"failed to parse status" +#define TSDB_CODE_HTTP_PARSE_PHRASE_FAILED TAOS_DEF_ERROR_CODE(0, 0x112B) //"failed to parse phrase" +#define TSDB_CODE_HTTP_PARSE_CRLF_FAILED TAOS_DEF_ERROR_CODE(0, 0x112C) //"failed to parse crlf" +#define TSDB_CODE_HTTP_PARSE_HEADER_FAILED TAOS_DEF_ERROR_CODE(0, 0x112D) //"failed to parse header" +#define TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED TAOS_DEF_ERROR_CODE(0, 0x112E) //"failed to parse header key" +#define TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED TAOS_DEF_ERROR_CODE(0, 0x112F) //"failed to parse header val" +#define TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED TAOS_DEF_ERROR_CODE(0, 0x1130) //"failed to parse chunk size" +#define TSDB_CODE_HTTP_PARSE_CHUNK_FAILED TAOS_DEF_ERROR_CODE(0, 0x1131) //"failed to parse chunk" +#define TSDB_CODE_HTTP_PARSE_END_FAILED TAOS_DEF_ERROR_CODE(0, 0x1132) //"failed to parse end section" +#define TSDB_CODE_HTTP_PARSE_INVALID_STATE TAOS_DEF_ERROR_CODE(0, 0x1134) //"invalid parse state" +#define TSDB_CODE_HTTP_PARSE_ERROR_STATE TAOS_DEF_ERROR_CODE(0, 0x1135) //"failed to parse error section" + +#define TSDB_CODE_HTTP_GC_QUERY_NULL TAOS_DEF_ERROR_CODE(0, 0x1150) //"query size is 0" +#define TSDB_CODE_HTTP_GC_QUERY_SIZE TAOS_DEF_ERROR_CODE(0, 0x1151) //"query size can not more than 100" +#define TSDB_CODE_HTTP_GC_REQ_PARSE_ERROR TAOS_DEF_ERROR_CODE(0, 0x1152) //"parse grafana json error" + +#define TSDB_CODE_HTTP_TG_DB_NOT_INPUT TAOS_DEF_ERROR_CODE(0, 0x1160) //"database name can not be null" +#define TSDB_CODE_HTTP_TG_DB_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x1161) //"database name too long" +#define TSDB_CODE_HTTP_TG_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x1162) //"invalid telegraf json fromat" +#define TSDB_CODE_HTTP_TG_METRICS_NULL TAOS_DEF_ERROR_CODE(0, 0x1163) //"metrics size is 0" +#define TSDB_CODE_HTTP_TG_METRICS_SIZE TAOS_DEF_ERROR_CODE(0, 0x1164) //"metrics size can not more than 1K" +#define TSDB_CODE_HTTP_TG_METRIC_NULL TAOS_DEF_ERROR_CODE(0, 0x1165) //"metric name not find" +#define TSDB_CODE_HTTP_TG_METRIC_TYPE TAOS_DEF_ERROR_CODE(0, 0x1166) //"metric name type should be string" +#define TSDB_CODE_HTTP_TG_METRIC_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1167) //"metric name length is 0" +#define TSDB_CODE_HTTP_TG_METRIC_NAME_LONG TAOS_DEF_ERROR_CODE(0, 0x1168) //"metric name length too long" +#define TSDB_CODE_HTTP_TG_TIMESTAMP_NULL TAOS_DEF_ERROR_CODE(0, 0x1169) //"timestamp not find" +#define TSDB_CODE_HTTP_TG_TIMESTAMP_TYPE TAOS_DEF_ERROR_CODE(0, 0x116A) //"timestamp type should be integer" +#define TSDB_CODE_HTTP_TG_TIMESTAMP_VAL_NULL TAOS_DEF_ERROR_CODE(0, 0x116B) //"timestamp value smaller than 0" +#define TSDB_CODE_HTTP_TG_TAGS_NULL TAOS_DEF_ERROR_CODE(0, 0x116C) //"tags not find" +#define TSDB_CODE_HTTP_TG_TAGS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x116D) //"tags size is 0" +#define TSDB_CODE_HTTP_TG_TAGS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x116E) //"tags size too long" +#define TSDB_CODE_HTTP_TG_TAG_NULL TAOS_DEF_ERROR_CODE(0, 0x116F) //"tag is null" +#define TSDB_CODE_HTTP_TG_TAG_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1170) //"tag name is null" +#define TSDB_CODE_HTTP_TG_TAG_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x1171) //"tag name length too long" +#define TSDB_CODE_HTTP_TG_TAG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x1172) //"tag value type should be number or string" +#define TSDB_CODE_HTTP_TG_TAG_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x1173) //"tag value is null" +#define TSDB_CODE_HTTP_TG_TABLE_NULL TAOS_DEF_ERROR_CODE(0, 0x1174) //"table is null" +#define TSDB_CODE_HTTP_TG_TABLE_SIZE TAOS_DEF_ERROR_CODE(0, 0x1175) //"table name length too long" +#define TSDB_CODE_HTTP_TG_FIELDS_NULL TAOS_DEF_ERROR_CODE(0, 0x1176) //"fields not find" +#define TSDB_CODE_HTTP_TG_FIELDS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x1177) //"fields size is 0" +#define TSDB_CODE_HTTP_TG_FIELDS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x1178) //"fields size too long" +#define TSDB_CODE_HTTP_TG_FIELD_NULL TAOS_DEF_ERROR_CODE(0, 0x1179) //"field is null" +#define TSDB_CODE_HTTP_TG_FIELD_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x117A) //"field name is null" +#define TSDB_CODE_HTTP_TG_FIELD_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x117B) //"field name length too long" +#define TSDB_CODE_HTTP_TG_FIELD_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x117C) //"field value type should be number or string" +#define TSDB_CODE_HTTP_TG_FIELD_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x117D) //"field value is null" +#define TSDB_CODE_HTTP_TG_HOST_NOT_STRING TAOS_DEF_ERROR_CODE(0, 0x117E) //"host type should be string" +#define TSDB_CODE_HTTP_TG_STABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x117F) //"stable not exist" + +#define TSDB_CODE_HTTP_OP_DB_NOT_INPUT TAOS_DEF_ERROR_CODE(0, 0x1190) //"database name can not be null" +#define TSDB_CODE_HTTP_OP_DB_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x1191) //"database name too long" +#define TSDB_CODE_HTTP_OP_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x1192) //"invalid opentsdb json fromat" +#define TSDB_CODE_HTTP_OP_METRICS_NULL TAOS_DEF_ERROR_CODE(0, 0x1193) //"metrics size is 0" +#define TSDB_CODE_HTTP_OP_METRICS_SIZE TAOS_DEF_ERROR_CODE(0, 0x1194) //"metrics size can not more than 10K" +#define TSDB_CODE_HTTP_OP_METRIC_NULL TAOS_DEF_ERROR_CODE(0, 0x1195) //"metric name not find" +#define TSDB_CODE_HTTP_OP_METRIC_TYPE TAOS_DEF_ERROR_CODE(0, 0x1196) //"metric name type should be string" +#define TSDB_CODE_HTTP_OP_METRIC_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1197) //"metric name length is 0" +#define TSDB_CODE_HTTP_OP_METRIC_NAME_LONG TAOS_DEF_ERROR_CODE(0, 0x1198) //"metric name length can not more than 22" +#define TSDB_CODE_HTTP_OP_TIMESTAMP_NULL TAOS_DEF_ERROR_CODE(0, 0x1199) //"timestamp not find" +#define TSDB_CODE_HTTP_OP_TIMESTAMP_TYPE TAOS_DEF_ERROR_CODE(0, 0x119A) //"timestamp type should be integer" +#define TSDB_CODE_HTTP_OP_TIMESTAMP_VAL_NULL TAOS_DEF_ERROR_CODE(0, 0x119B) //"timestamp value smaller than 0" +#define TSDB_CODE_HTTP_OP_TAGS_NULL TAOS_DEF_ERROR_CODE(0, 0x119C) //"tags not find" +#define TSDB_CODE_HTTP_OP_TAGS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x119D) //"tags size is 0" +#define TSDB_CODE_HTTP_OP_TAGS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x119E) //"tags size too long" +#define TSDB_CODE_HTTP_OP_TAG_NULL TAOS_DEF_ERROR_CODE(0, 0x119F) //"tag is null" +#define TSDB_CODE_HTTP_OP_TAG_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x11A0) //"tag name is null" +#define TSDB_CODE_HTTP_OP_TAG_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x11A1) //"tag name length too long" +#define TSDB_CODE_HTTP_OP_TAG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A2) //"tag value type should be boolean number or string" +#define TSDB_CODE_HTTP_OP_TAG_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A3) //"tag value is null" +#define TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x11A4) //"tag value can not more than 64" +#define TSDB_CODE_HTTP_OP_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A5) //"value not find" +#define TSDB_CODE_HTTP_OP_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A6) //"value type should be boolean number or string" + +#define TSDB_CODE_HTTP_REQUEST_JSON_ERROR TAOS_DEF_ERROR_CODE(0, 0x1F00) //"http request json error" + // tfs #define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200) #define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201) diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 8ee6c31ba1..bbceaa8fed 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src CLIENT_SRC) add_library(taos ${CLIENT_SRC}) target_include_directories( taos - PUBLIC "${CMAKE_SOURCE_DIR}/include/client" + PUBLIC "${TD_SOURCE_DIR}/include/client" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/client/test/CMakeLists.txt b/source/client/test/CMakeLists.txt index ee5109860e..73e11caa95 100644 --- a/source/client/test/CMakeLists.txt +++ b/source/client/test/CMakeLists.txt @@ -19,12 +19,12 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( clientTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/client/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/client/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/client/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/client/inc" ) TARGET_INCLUDE_DIRECTORIES( tmqTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/client/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/client/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/client/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/client/inc" ) diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index 1344b5b58c..63a04a8813 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -2,11 +2,11 @@ aux_source_directory(src COMMON_SRC) add_library(common STATIC ${COMMON_SRC}) target_include_directories( common - PUBLIC "${CMAKE_SOURCE_DIR}/include/common" + PUBLIC "${TD_SOURCE_DIR}/include/common" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" IF(${TD_WINDOWS}) - PRIVATE "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" - PRIVATE "${CMAKE_SOURCE_DIR}/contrib/gnuregex" + PRIVATE "${TD_SOURCE_DIR}/contrib/pthread-win32" + PRIVATE "${TD_SOURCE_DIR}/contrib/gnuregex" ENDIF () ) target_link_libraries( diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index b351536839..0bc1fa09f5 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -173,7 +173,7 @@ uint32_t tsMaxRange = 500; // max range uint32_t tsCurRange = 100; // range char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR -static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) { +void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t primary) { tstrncpy(tsDiskCfg[index].dir, v1, TSDB_FILENAME_LEN); tsDiskCfg[index].level = level; tsDiskCfg[index].primary = primary; diff --git a/source/common/test/CMakeLists.txt b/source/common/test/CMakeLists.txt index 58dde913f0..a0406e099c 100644 --- a/source/common/test/CMakeLists.txt +++ b/source/common/test/CMakeLists.txt @@ -13,8 +13,8 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( commonTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/common/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/common/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/common/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/common/inc" ) # tmsg test @@ -24,5 +24,5 @@ TARGET_INCLUDE_DIRECTORIES( # "tmsgTest.cpp" # "../src/tmsg.c" # ) -# target_include_directories(tmsgTest PUBLIC "${CMAKE_SOURCE_DIR}/include/common/") +# target_include_directories(tmsgTest PUBLIC "${TD_SOURCE_DIR}/include/common/") # target_link_libraries(tmsgTest PUBLIC os util gtest gtest_main) \ No newline at end of file diff --git a/source/dnode/bnode/CMakeLists.txt b/source/dnode/bnode/CMakeLists.txt index f51969f6bf..77f4d15ad2 100644 --- a/source/dnode/bnode/CMakeLists.txt +++ b/source/dnode/bnode/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src BNODE_SRC) add_library(bnode STATIC ${BNODE_SRC}) target_include_directories( bnode - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/bnode" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/bnode" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/dnode/mgmt/CMakeLists.txt b/source/dnode/mgmt/CMakeLists.txt index 0c9a3733a2..f498773462 100644 --- a/source/dnode/mgmt/CMakeLists.txt +++ b/source/dnode/mgmt/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries( ) target_include_directories( dnode - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mgmt" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/mgmt" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/dnode/mnode/impl/CMakeLists.txt b/source/dnode/mnode/impl/CMakeLists.txt index e91c851be7..341dbf6135 100644 --- a/source/dnode/mnode/impl/CMakeLists.txt +++ b/source/dnode/mnode/impl/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src MNODE_SRC) add_library(mnode STATIC ${MNODE_SRC}) target_include_directories( mnode - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/dnode/mnode/sdb/CMakeLists.txt b/source/dnode/mnode/sdb/CMakeLists.txt index 168d5063c2..823bcdeaca 100644 --- a/source/dnode/mnode/sdb/CMakeLists.txt +++ b/source/dnode/mnode/sdb/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src MNODE_SRC) add_library(sdb STATIC ${MNODE_SRC}) target_include_directories( sdb - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/mnode/sdb" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/mnode/sdb" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/dnode/qnode/CMakeLists.txt b/source/dnode/qnode/CMakeLists.txt index 32e3e85d90..5426cd55d3 100644 --- a/source/dnode/qnode/CMakeLists.txt +++ b/source/dnode/qnode/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src QNODE_SRC) add_library(qnode STATIC ${QNODE_SRC}) target_include_directories( qnode - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/qnode" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/qnode" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/dnode/snode/CMakeLists.txt b/source/dnode/snode/CMakeLists.txt index f177bda47a..6f1e7f9593 100644 --- a/source/dnode/snode/CMakeLists.txt +++ b/source/dnode/snode/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src SNODE_SRC) add_library(snode STATIC ${SNODE_SRC}) target_include_directories( snode - PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/snode" + PUBLIC "${TD_SOURCE_DIR}/include/dnode/snode" private "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/dnode/vnode/test/CMakeLists.txt b/source/dnode/vnode/test/CMakeLists.txt index 59f459462f..724eabc751 100644 --- a/source/dnode/vnode/test/CMakeLists.txt +++ b/source/dnode/vnode/test/CMakeLists.txt @@ -11,7 +11,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) # ) # target_include_directories(tqTest # PUBLIC -# "${CMAKE_SOURCE_DIR}/include/server/vnode/tq" +# "${TD_SOURCE_DIR}/include/server/vnode/tq" # "${CMAKE_CURRENT_SOURCE_DIR}/../inc" # ) @@ -33,7 +33,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) # TARGET_INCLUDE_DIRECTORIES( # tsdbSmaTest -# PUBLIC "${CMAKE_SOURCE_DIR}/include/common" +# PUBLIC "${TD_SOURCE_DIR}/include/common" # PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../src/inc" # PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../inc" # ) \ No newline at end of file diff --git a/source/libs/cache/CMakeLists.txt b/source/libs/cache/CMakeLists.txt index c99b5602ad..dc631e5bfd 100644 --- a/source/libs/cache/CMakeLists.txt +++ b/source/libs/cache/CMakeLists.txt @@ -2,6 +2,6 @@ aux_source_directory(src CACHE_SRC) add_library(cache STATIC ${CACHE_SRC}) target_include_directories( cache - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/cache" + PUBLIC "${TD_SOURCE_DIR}/include/libs/cache" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) \ No newline at end of file diff --git a/source/libs/catalog/CMakeLists.txt b/source/libs/catalog/CMakeLists.txt index 09cd252a89..632034d6b6 100644 --- a/source/libs/catalog/CMakeLists.txt +++ b/source/libs/catalog/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src CATALOG_SRC) add_library(catalog STATIC ${CATALOG_SRC}) target_include_directories( catalog - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/catalog" + PUBLIC "${TD_SOURCE_DIR}/include/libs/catalog" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/catalog/test/CMakeLists.txt b/source/libs/catalog/test/CMakeLists.txt index bfab744fa7..3ffb420b4b 100644 --- a/source/libs/catalog/test/CMakeLists.txt +++ b/source/libs/catalog/test/CMakeLists.txt @@ -13,8 +13,8 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( catalogTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/catalog/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/catalog/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/catalog/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/catalog/inc" ) # add_test( diff --git a/source/libs/command/CMakeLists.txt b/source/libs/command/CMakeLists.txt index db3766d145..51118f4a34 100644 --- a/source/libs/command/CMakeLists.txt +++ b/source/libs/command/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src COMMAND_SRC) add_library(command STATIC ${COMMAND_SRC}) target_include_directories( command - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/command" + PUBLIC "${TD_SOURCE_DIR}/include/libs/command" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/command/test/CMakeLists.txt b/source/libs/command/test/CMakeLists.txt index 6d2335d2e3..8eaa5eea68 100644 --- a/source/libs/command/test/CMakeLists.txt +++ b/source/libs/command/test/CMakeLists.txt @@ -8,8 +8,8 @@ ADD_EXECUTABLE(commandTest ${SOURCE_LIST}) TARGET_INCLUDE_DIRECTORIES( commandTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/command/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/command/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/command/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/command/inc" ) TARGET_LINK_LIBRARIES( diff --git a/source/libs/executor/CMakeLists.txt b/source/libs/executor/CMakeLists.txt index f947acf822..3dfef9b59f 100644 --- a/source/libs/executor/CMakeLists.txt +++ b/source/libs/executor/CMakeLists.txt @@ -4,7 +4,7 @@ aux_source_directory(src EXECUTOR_SRC) add_library(executor STATIC ${EXECUTOR_SRC}) #set_target_properties(executor PROPERTIES # IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libexecutor.a" -# INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/include/libs/executor" +# INTERFACE_INCLUDE_DIRECTORIES "${TD_SOURCE_DIR}/include/libs/executor" # ) target_link_libraries(executor @@ -13,7 +13,7 @@ target_link_libraries(executor target_include_directories( executor - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/executor" + PUBLIC "${TD_SOURCE_DIR}/include/libs/executor" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/executor/test/CMakeLists.txt b/source/libs/executor/test/CMakeLists.txt index c24993eb89..b07ff89d90 100644 --- a/source/libs/executor/test/CMakeLists.txt +++ b/source/libs/executor/test/CMakeLists.txt @@ -13,6 +13,6 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( executorTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/executor/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/executor/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/executor/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/executor/inc" ) diff --git a/source/libs/function/CMakeLists.txt b/source/libs/function/CMakeLists.txt index e1c7626f01..aa909361ea 100644 --- a/source/libs/function/CMakeLists.txt +++ b/source/libs/function/CMakeLists.txt @@ -4,8 +4,8 @@ add_library(function STATIC ${FUNCTION_SRC}) target_include_directories( function PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/function" - "${CMAKE_SOURCE_DIR}/contrib/libuv/include" + "${TD_SOURCE_DIR}/include/libs/function" + "${TD_SOURCE_DIR}/contrib/libuv/include" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) @@ -19,9 +19,9 @@ add_executable(runUdf test/runUdf.c) target_include_directories( runUdf PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/function" - "${CMAKE_SOURCE_DIR}/contrib/libuv/include" - "${CMAKE_SOURCE_DIR}/include/os" + "${TD_SOURCE_DIR}/include/libs/function" + "${TD_SOURCE_DIR}/contrib/libuv/include" + "${TD_SOURCE_DIR}/include/os" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( @@ -34,8 +34,8 @@ add_library(udf1 MODULE test/udf1.c) target_include_directories( udf1 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/function" - "${CMAKE_SOURCE_DIR}/include/os" + "${TD_SOURCE_DIR}/include/libs/function" + "${TD_SOURCE_DIR}/include/os" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) @@ -44,8 +44,8 @@ add_executable(udfd src/udfd.c) target_include_directories( udfd PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/function" - "${CMAKE_SOURCE_DIR}/contrib/libuv/include" + "${TD_SOURCE_DIR}/include/libs/function" + "${TD_SOURCE_DIR}/contrib/libuv/include" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/index/CMakeLists.txt b/source/libs/index/CMakeLists.txt index 047fc555a0..7dc66e4789 100644 --- a/source/libs/index/CMakeLists.txt +++ b/source/libs/index/CMakeLists.txt @@ -2,8 +2,8 @@ aux_source_directory(src INDEX_SRC) add_library(index STATIC ${INDEX_SRC}) target_include_directories( index - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/index" - PUBLIC "${CMAKE_SOURCE_DIR}/include/os" + PUBLIC "${TD_SOURCE_DIR}/include/libs/index" + PUBLIC "${TD_SOURCE_DIR}/include/os" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) @@ -17,9 +17,9 @@ target_link_libraries( if (${BUILD_WITH_LUCENE}) target_include_directories( index - PUBLIC "${CMAKE_SOURCE_DIR}/deps/lucene/include" + PUBLIC "${TD_SOURCE_DIR}/deps/lucene/include" ) - LINK_DIRECTORIES("${CMAKE_SOURCE_DIR}/deps/lucene/debug/src/core") + LINK_DIRECTORIES("${TD_SOURCE_DIR}/deps/lucene/debug/src/core") target_link_libraries( index PUBLIC lucene++ diff --git a/source/libs/index/test/CMakeLists.txt b/source/libs/index/test/CMakeLists.txt index 1ebf85368b..a5c02fb9dc 100644 --- a/source/libs/index/test/CMakeLists.txt +++ b/source/libs/index/test/CMakeLists.txt @@ -28,30 +28,30 @@ target_sources(jsonUT ) target_include_directories ( indexTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories ( fstTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories ( fstUT PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories ( UtilUT PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories (jsonUT PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/index" + "${TD_SOURCE_DIR}/include/libs/index" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_link_libraries (indexTest diff --git a/source/libs/monitor/CMakeLists.txt b/source/libs/monitor/CMakeLists.txt index 58f1c08039..30dce7aaef 100644 --- a/source/libs/monitor/CMakeLists.txt +++ b/source/libs/monitor/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src MONITOR_SRC) add_library(monitor STATIC ${MONITOR_SRC}) target_include_directories( monitor - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/monitor" + PUBLIC "${TD_SOURCE_DIR}/include/libs/monitor" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/nodes/CMakeLists.txt b/source/libs/nodes/CMakeLists.txt index e20cdc39ba..b8fdb32987 100644 --- a/source/libs/nodes/CMakeLists.txt +++ b/source/libs/nodes/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src NODES_SRC) add_library(nodes STATIC ${NODES_SRC}) target_include_directories( nodes - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/nodes" + PUBLIC "${TD_SOURCE_DIR}/include/libs/nodes" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/source/libs/nodes/test/CMakeLists.txt b/source/libs/nodes/test/CMakeLists.txt index 80725a79fb..2be8e78d06 100644 --- a/source/libs/nodes/test/CMakeLists.txt +++ b/source/libs/nodes/test/CMakeLists.txt @@ -9,8 +9,8 @@ ADD_EXECUTABLE(nodesTest ${SOURCE_LIST}) TARGET_INCLUDE_DIRECTORIES( nodesTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/nodes/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/nodes/inc" + PUBLIC "${TD_SOURCE_DIR}/include/nodes/" + PRIVATE "${TD_SOURCE_DIR}/source/nodes/inc" ) TARGET_LINK_LIBRARIES( diff --git a/source/libs/parser/CMakeLists.txt b/source/libs/parser/CMakeLists.txt index c3157480a9..860250df85 100644 --- a/source/libs/parser/CMakeLists.txt +++ b/source/libs/parser/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src PARSER_SRC) add_library(parser STATIC ${PARSER_SRC}) target_include_directories( parser - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/parser" + PUBLIC "${TD_SOURCE_DIR}/include/libs/parser" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/parser/test/CMakeLists.txt b/source/libs/parser/test/CMakeLists.txt index 84164c8c76..869232002a 100644 --- a/source/libs/parser/test/CMakeLists.txt +++ b/source/libs/parser/test/CMakeLists.txt @@ -9,8 +9,8 @@ ADD_EXECUTABLE(parserTest ${SOURCE_LIST}) TARGET_INCLUDE_DIRECTORIES( parserTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/parser/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/parser/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/parser/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/parser/inc" ) TARGET_LINK_LIBRARIES( diff --git a/source/libs/planner/CMakeLists.txt b/source/libs/planner/CMakeLists.txt index db5d31f22b..a095a6205f 100644 --- a/source/libs/planner/CMakeLists.txt +++ b/source/libs/planner/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src PLANNER_SRC) add_library(planner STATIC ${PLANNER_SRC}) target_include_directories( planner - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/planner" + PUBLIC "${TD_SOURCE_DIR}/include/libs/planner" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/planner/test/CMakeLists.txt b/source/libs/planner/test/CMakeLists.txt index cd60b503b9..e068cd8698 100644 --- a/source/libs/planner/test/CMakeLists.txt +++ b/source/libs/planner/test/CMakeLists.txt @@ -18,7 +18,7 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( plannerTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/planner/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/planner/inc" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/parser/test" + PUBLIC "${TD_SOURCE_DIR}/include/libs/planner/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/planner/inc" + PRIVATE "${TD_SOURCE_DIR}/source/libs/parser/test" ) diff --git a/source/libs/qcom/CMakeLists.txt b/source/libs/qcom/CMakeLists.txt index d50047e592..6e7b5cb610 100644 --- a/source/libs/qcom/CMakeLists.txt +++ b/source/libs/qcom/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src QUERY_SRC) add_library(qcom STATIC ${QUERY_SRC}) target_include_directories( qcom - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/qcom" + PUBLIC "${TD_SOURCE_DIR}/include/libs/qcom" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/qcom/test/CMakeLists.txt b/source/libs/qcom/test/CMakeLists.txt index e3a0e11a32..8ad38a9f50 100644 --- a/source/libs/qcom/test/CMakeLists.txt +++ b/source/libs/qcom/test/CMakeLists.txt @@ -9,8 +9,8 @@ ADD_EXECUTABLE(queryUtilTest ${SOURCE_LIST}) TARGET_INCLUDE_DIRECTORIES( queryUtilTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/qcom/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/qcom/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/qcom/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/qcom/inc" ) TARGET_LINK_LIBRARIES( diff --git a/source/libs/qworker/CMakeLists.txt b/source/libs/qworker/CMakeLists.txt index 89700e8939..306753808b 100644 --- a/source/libs/qworker/CMakeLists.txt +++ b/source/libs/qworker/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src QWORKER_SRC) add_library(qworker STATIC ${QWORKER_SRC}) target_include_directories( qworker - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/qworker" + PUBLIC "${TD_SOURCE_DIR}/include/libs/qworker" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/qworker/test/CMakeLists.txt b/source/libs/qworker/test/CMakeLists.txt index 6de71a4530..e7cc8b7c83 100644 --- a/source/libs/qworker/test/CMakeLists.txt +++ b/source/libs/qworker/test/CMakeLists.txt @@ -13,6 +13,6 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( qworkerTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/qworker/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/qworker/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/qworker/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/qworker/inc" ) diff --git a/source/libs/scalar/CMakeLists.txt b/source/libs/scalar/CMakeLists.txt index d2d02bc0dc..02d530533c 100644 --- a/source/libs/scalar/CMakeLists.txt +++ b/source/libs/scalar/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src SCALAR_SRC) add_library(scalar STATIC ${SCALAR_SRC}) target_include_directories( scalar - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/scalar" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/scalar/test/filter/CMakeLists.txt b/source/libs/scalar/test/filter/CMakeLists.txt index b738285ded..8e3aeb6f9d 100644 --- a/source/libs/scalar/test/filter/CMakeLists.txt +++ b/source/libs/scalar/test/filter/CMakeLists.txt @@ -13,6 +13,6 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( filterTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/scalar/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/scalar/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/scalar/inc" ) diff --git a/source/libs/scalar/test/scalar/CMakeLists.txt b/source/libs/scalar/test/scalar/CMakeLists.txt index 9dfbf3b5e8..6cbac1e25d 100644 --- a/source/libs/scalar/test/scalar/CMakeLists.txt +++ b/source/libs/scalar/test/scalar/CMakeLists.txt @@ -13,6 +13,6 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( scalarTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/scalar/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/scalar/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scalar/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/scalar/inc" ) diff --git a/source/libs/scheduler/CMakeLists.txt b/source/libs/scheduler/CMakeLists.txt index 1a62c7d89d..88180391dd 100644 --- a/source/libs/scheduler/CMakeLists.txt +++ b/source/libs/scheduler/CMakeLists.txt @@ -3,7 +3,7 @@ add_library(scheduler STATIC ${SCHEDULER_SRC}) target_include_directories( scheduler - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/scheduler" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scheduler" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/scheduler/test/CMakeLists.txt b/source/libs/scheduler/test/CMakeLists.txt index 00a6d08e5d..4018f73ee2 100644 --- a/source/libs/scheduler/test/CMakeLists.txt +++ b/source/libs/scheduler/test/CMakeLists.txt @@ -13,6 +13,6 @@ TARGET_LINK_LIBRARIES( TARGET_INCLUDE_DIRECTORIES( schedulerTest - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/scheduler/" - PRIVATE "${CMAKE_SOURCE_DIR}/source/libs/scheduler/inc" + PUBLIC "${TD_SOURCE_DIR}/include/libs/scheduler/" + PRIVATE "${TD_SOURCE_DIR}/source/libs/scheduler/inc" ) diff --git a/source/libs/stream/CMakeLists.txt b/source/libs/stream/CMakeLists.txt index 572c70d31b..3bab354c22 100644 --- a/source/libs/stream/CMakeLists.txt +++ b/source/libs/stream/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src STREAM_SRC) add_library(stream STATIC ${STREAM_SRC}) target_include_directories( stream - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/stream" + PUBLIC "${TD_SOURCE_DIR}/include/libs/stream" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/sync/CMakeLists.txt b/source/libs/sync/CMakeLists.txt index cb196acc02..551849c6f2 100644 --- a/source/libs/sync/CMakeLists.txt +++ b/source/libs/sync/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries( target_include_directories( sync - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/sync" + PUBLIC "${TD_SOURCE_DIR}/include/libs/sync" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 7341565b1d..58b01e4ca2 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -204,202 +204,202 @@ target_sources(syncLogStoreCheck target_include_directories(syncTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncEnvTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncPingTimerTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIOTickQTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIOTickPingTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIOSendMsgTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIOClientTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIOServerTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncRaftStoreTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncEnqTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIndexTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncInitTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncUtilTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncVotesGrantedTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncVotesRespondTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncIndexMgrTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncLogStoreTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncEntryTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncRequestVoteTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncRequestVoteReplyTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncAppendEntriesTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncAppendEntriesReplyTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncClientRequestTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncTimeoutTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncPingTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncPingReplyTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncRpcMsgTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncPingTimerTest2 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncPingSelfTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncElectTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncElectTest2 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncElectTest3 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncEncodeTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncWriteTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncReplicateTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncReplicateTest2 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncReplicateTest3 PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncReplicateLoadTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncRefTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(syncLogStoreCheck PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${TD_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) diff --git a/source/libs/tfs/CMakeLists.txt b/source/libs/tfs/CMakeLists.txt index 97e02fc8a9..ef1afa01a1 100644 --- a/source/libs/tfs/CMakeLists.txt +++ b/source/libs/tfs/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src TFS_SRC) add_library(tfs STATIC ${TFS_SRC}) target_include_directories( tfs - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tfs" + PUBLIC "${TD_SOURCE_DIR}/include/libs/tfs" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/transport/CMakeLists.txt b/source/libs/transport/CMakeLists.txt index 20dd3f7ad2..62eb1a985b 100644 --- a/source/libs/transport/CMakeLists.txt +++ b/source/libs/transport/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src TRANSPORT_SRC) add_library(transport STATIC ${TRANSPORT_SRC}) target_include_directories( transport - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/transport" + PUBLIC "${TD_SOURCE_DIR}/include/libs/transport" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) @@ -18,7 +18,7 @@ if (${BUILD_WITH_UV_TRANS}) if (${BUILD_WITH_UV}) target_include_directories( transport - PUBLIC "${CMAKE_SOURCE_DIR}/contrib/libuv/include" + PUBLIC "${TD_SOURCE_DIR}/contrib/libuv/include" ) target_link_libraries( diff --git a/source/libs/transport/test/CMakeLists.txt b/source/libs/transport/test/CMakeLists.txt index 1245121d94..02ada328fc 100644 --- a/source/libs/transport/test/CMakeLists.txt +++ b/source/libs/transport/test/CMakeLists.txt @@ -33,7 +33,7 @@ target_sources(pushServer target_include_directories(transportTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) @@ -54,7 +54,7 @@ target_link_libraries (transUT target_include_directories(client PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) @@ -67,13 +67,13 @@ target_link_libraries (client ) target_include_directories(server PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_include_directories(transUT PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) @@ -86,7 +86,7 @@ target_link_libraries (server ) target_include_directories(syncClient PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_link_libraries (syncClient @@ -99,7 +99,7 @@ target_link_libraries (syncClient target_include_directories(pushServer PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/transport" + "${TD_SOURCE_DIR}/include/libs/transport" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) target_link_libraries (pushServer diff --git a/source/libs/wal/CMakeLists.txt b/source/libs/wal/CMakeLists.txt index 4cf7cff818..d2ed4f1d16 100644 --- a/source/libs/wal/CMakeLists.txt +++ b/source/libs/wal/CMakeLists.txt @@ -2,7 +2,7 @@ aux_source_directory(src WAL_SRC) add_library(wal STATIC ${WAL_SRC}) target_include_directories( wal - PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/wal" + PUBLIC "${TD_SOURCE_DIR}/include/libs/wal" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) diff --git a/source/libs/wal/test/CMakeLists.txt b/source/libs/wal/test/CMakeLists.txt index 1c0a3a162a..84c6ed0e68 100644 --- a/source/libs/wal/test/CMakeLists.txt +++ b/source/libs/wal/test/CMakeLists.txt @@ -5,7 +5,7 @@ target_sources(walTest ) target_include_directories(walTest PUBLIC - "${CMAKE_SOURCE_DIR}/include/libs/wal" + "${TD_SOURCE_DIR}/include/libs/wal" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index c467ab5fa3..261ec312ad 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -2,11 +2,11 @@ aux_source_directory(src OS_SRC) add_library(os STATIC ${OS_SRC}) target_include_directories( os - PUBLIC "${CMAKE_SOURCE_DIR}/include/os" - PUBLIC "${CMAKE_SOURCE_DIR}/include" - PUBLIC "${CMAKE_SOURCE_DIR}/include/util" - PUBLIC "${CMAKE_SOURCE_DIR}/contrib/pthread" - PUBLIC "${CMAKE_SOURCE_DIR}/contrib/gnuregex" + PUBLIC "${TD_SOURCE_DIR}/include/os" + PUBLIC "${TD_SOURCE_DIR}/include" + PUBLIC "${TD_SOURCE_DIR}/include/util" + PUBLIC "${TD_SOURCE_DIR}/contrib/pthread" + PUBLIC "${TD_SOURCE_DIR}/contrib/gnuregex" ) # iconv find_path(IconvApiIncludes iconv.h PATHS) diff --git a/source/util/CMakeLists.txt b/source/util/CMakeLists.txt index 7a47639e75..8609c6eb21 100644 --- a/source/util/CMakeLists.txt +++ b/source/util/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src UTIL_SRC) add_library(util STATIC ${UTIL_SRC}) target_include_directories( util - PUBLIC "${CMAKE_SOURCE_DIR}/include/util" + PUBLIC "${TD_SOURCE_DIR}/include/util" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" ) target_link_libraries( diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f064833691..afd3b36f2d 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,10 +1,10 @@ IF (TD_TAOS_TOOLS) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/tools/taos_tools/deps/avro/lang/c/src) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/client) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/common) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/util) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/os) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/libs/transport) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/tools/taos_tools/deps/avro/lang/c/src) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/client) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/common) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/util) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/os) + INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/libs/transport) ADD_SUBDIRECTORY(taos-tools) ENDIF () From 03cce69b75c3b97931342d1f14968cb934195184 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Sun, 10 Apr 2022 19:10:57 +0800 Subject: [PATCH 20/45] [query]: add cast function SQL syntax TD-14242 --- source/libs/function/src/builtins.c | 14 + source/libs/parser/inc/parAst.h | 1 + source/libs/parser/inc/sql.y | 6 + source/libs/parser/src/parAstCreater.c | 20 + source/libs/parser/src/sql.c | 2533 ++++++++++++++---------- 5 files changed, 1515 insertions(+), 1059 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index c1cdcbcb0c..aa7343f610 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -382,6 +382,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = substrFunction, .finalizeFunc = NULL }, + { + .name = "cast", + .type = FUNCTION_TYPE_CAST, + .classification = FUNC_MGT_SCALAR_FUNC, + .checkFunc = stubCheckAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, { .name = "_rowts", .type = FUNCTION_TYPE_ROWTS, @@ -588,6 +598,10 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { pFunc->node.resType = (SDataType) { .bytes = paraBytes, .type = paraType }; break; } + case FUNCTION_TYPE_CAST: { + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT }; + break; + } case FUNCTION_TYPE_TBNAME: { // todo diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 2ac7dbe8e3..6e0a675a59 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -81,6 +81,7 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode); SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode); SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode); +SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList); SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 6e6a769db7..931b1a58e6 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -520,6 +520,12 @@ expression(A) ::= pseudo_column(B). expression(A) ::= column_reference(B). { A = B; } expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); } +//for CAST function CAST(expr AS type_name) +expression(A) ::= function_name(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { + SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, C)); + p = addValueNodeFromTypeToList(pCxt, D, p); + A = createRawExprNodeExt(pCxt, &B, &E, createFunctionNode(pCxt, &B, p)); + } //expression(A) ::= cast_expression(B). { A = B; } //expression(A) ::= case_expression(B). { A = B; } expression(A) ::= subquery(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 893d500641..0b3fd38641 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -249,6 +249,26 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC return (SNode*)col; } +SNodeList* addValueNodeFromTypeToList(SAstCreateContext* pCxt, SDataType dataType, SNodeList* pList) { + char buf[64] = {0}; + //add value node for type + snprintf(buf, sizeof(buf), "%u", dataType.type); + SToken token = {.type = TSDB_DATA_TYPE_TINYINT, .n = strlen(buf), .z = buf}; + SNode* pNode = createValueNode(pCxt, token.type, &token); + addNodeToList(pCxt, pList, pNode); + + //add value node for bytes + memset(buf, 0, sizeof(buf)); + snprintf(buf, sizeof(buf), "%u", dataType.bytes); + token.type = TSDB_DATA_TYPE_BIGINT; + token.n = strlen(buf); + token.z = buf; + pNode = createValueNode(pCxt, token.type, &token); + addNodeToList(pCxt, pList, pNode); + + return pList; +} + SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) { SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index b2ddd1d0bc..c82e6a86a2 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -132,17 +132,18 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 518 -#define YYNRULE 400 +#define YYNSTATE 521 +#define YYNRULE 401 +#define YYNRULE_WITH_ACTION 401 #define YYNTOKEN 202 -#define YY_MAX_SHIFT 517 -#define YY_MIN_SHIFTREDUCE 776 -#define YY_MAX_SHIFTREDUCE 1175 -#define YY_ERROR_ACTION 1176 -#define YY_ACCEPT_ACTION 1177 -#define YY_NO_ACTION 1178 -#define YY_MIN_REDUCE 1179 -#define YY_MAX_REDUCE 1578 +#define YY_MAX_SHIFT 520 +#define YY_MIN_SHIFTREDUCE 780 +#define YY_MAX_SHIFTREDUCE 1180 +#define YY_ERROR_ACTION 1181 +#define YY_ACCEPT_ACTION 1182 +#define YY_NO_ACTION 1183 +#define YY_MIN_REDUCE 1184 +#define YY_MAX_REDUCE 1584 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -209,157 +210,158 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1488) +#define YY_ACTTAB_COUNT (1496) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 255, 432, 272, 1447, 267, 52, 1218, 1380, 275, 25, - /* 10 */ 193, 304, 31, 29, 121, 1371, 1373, 1431, 96, 1431, - /* 20 */ 264, 444, 1012, 1431, 445, 1333, 1288, 1463, 367, 1427, - /* 30 */ 1433, 1427, 1433, 72, 429, 1427, 1434, 117, 1010, 1340, - /* 40 */ 352, 1251, 1557, 310, 431, 254, 1284, 11, 1418, 1293, - /* 50 */ 1338, 263, 1225, 413, 1017, 130, 813, 432, 812, 1555, - /* 60 */ 31, 29, 1118, 1381, 231, 1448, 1449, 1452, 264, 1270, - /* 70 */ 1012, 1, 12, 236, 31, 29, 814, 444, 100, 1340, - /* 80 */ 413, 444, 264, 445, 1012, 269, 1010, 343, 31, 29, - /* 90 */ 1338, 1418, 72, 1035, 514, 11, 264, 417, 1012, 358, - /* 100 */ 1010, 366, 1017, 360, 858, 100, 1011, 365, 1293, 11, - /* 110 */ 97, 98, 361, 359, 1010, 362, 1017, 1034, 1340, 1, - /* 120 */ 860, 186, 1503, 412, 276, 411, 445, 208, 1557, 1338, - /* 130 */ 1017, 476, 12, 1, 1222, 308, 1463, 116, 98, 1191, - /* 140 */ 1013, 130, 514, 429, 1032, 1555, 445, 7, 127, 1503, - /* 150 */ 1504, 1293, 1508, 478, 1011, 309, 514, 1016, 1036, 1037, - /* 160 */ 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1011, 482, - /* 170 */ 514, 1293, 475, 474, 473, 406, 472, 163, 1117, 131, - /* 180 */ 131, 355, 1011, 502, 501, 500, 499, 279, 1013, 498, - /* 190 */ 497, 496, 102, 491, 490, 489, 488, 487, 486, 485, - /* 200 */ 484, 108, 1013, 357, 6, 1016, 1036, 1037, 1062, 1063, - /* 210 */ 1064, 1065, 1066, 1067, 1068, 1069, 1013, 510, 509, 1016, - /* 220 */ 1036, 1037, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, - /* 230 */ 1038, 1036, 1037, 1016, 1036, 1037, 1062, 1063, 1064, 1065, - /* 240 */ 1066, 1067, 1068, 1069, 1142, 1271, 31, 29, 430, 32, - /* 250 */ 30, 28, 27, 26, 264, 131, 1012, 136, 407, 31, - /* 260 */ 29, 235, 303, 1032, 302, 445, 65, 264, 1180, 1012, - /* 270 */ 322, 403, 1010, 334, 315, 400, 1140, 1141, 1143, 1144, - /* 280 */ 101, 131, 335, 50, 1202, 1010, 49, 1285, 1017, 84, - /* 290 */ 1293, 343, 83, 82, 81, 80, 79, 78, 77, 76, - /* 300 */ 75, 1017, 131, 131, 329, 7, 480, 896, 468, 467, - /* 310 */ 466, 900, 465, 902, 903, 464, 905, 461, 7, 911, - /* 320 */ 458, 913, 914, 455, 452, 408, 404, 84, 514, 1418, - /* 330 */ 83, 82, 81, 80, 79, 78, 77, 76, 75, 1113, - /* 340 */ 1011, 514, 188, 32, 30, 28, 27, 26, 364, 363, - /* 350 */ 140, 139, 333, 1011, 1116, 328, 327, 326, 325, 324, - /* 360 */ 445, 321, 320, 319, 318, 314, 313, 312, 311, 316, - /* 370 */ 1172, 9, 8, 1033, 1013, 32, 30, 28, 27, 26, - /* 380 */ 32, 30, 28, 27, 26, 1293, 1201, 1013, 483, 1200, - /* 390 */ 1265, 1016, 1036, 1037, 1062, 1063, 1064, 1065, 1066, 1067, - /* 400 */ 1068, 1069, 421, 1132, 1016, 1036, 1037, 1062, 1063, 1064, - /* 410 */ 1065, 1066, 1067, 1068, 1069, 238, 1282, 31, 29, 32, - /* 420 */ 30, 28, 27, 26, 366, 264, 360, 1012, 1199, 1447, - /* 430 */ 365, 1418, 371, 97, 1418, 361, 359, 1171, 362, 471, - /* 440 */ 1050, 445, 1094, 1010, 1447, 1557, 445, 379, 1081, 268, - /* 450 */ 342, 1269, 380, 1463, 238, 1290, 1368, 114, 1556, 1017, - /* 460 */ 429, 165, 1555, 138, 374, 1295, 1293, 52, 1463, 368, - /* 470 */ 431, 1293, 164, 1418, 1418, 416, 1, 445, 1278, 417, - /* 480 */ 28, 27, 26, 1557, 1198, 431, 442, 1081, 1289, 1418, - /* 490 */ 227, 1448, 1449, 1452, 1082, 1280, 130, 480, 42, 514, - /* 500 */ 1555, 41, 1293, 1197, 1083, 69, 1448, 1449, 1452, 1496, - /* 510 */ 1557, 1011, 1086, 257, 1492, 125, 274, 495, 493, 1276, - /* 520 */ 1177, 1039, 1087, 130, 114, 215, 420, 1555, 1323, 1418, - /* 530 */ 115, 422, 1295, 1082, 1524, 221, 24, 262, 1076, 1077, - /* 540 */ 1078, 1079, 1080, 1084, 1085, 1013, 22, 219, 1418, 1196, - /* 550 */ 1195, 1086, 32, 30, 28, 27, 26, 141, 1515, 1113, - /* 560 */ 168, 1447, 1016, 1036, 1037, 1062, 1063, 1064, 1065, 1066, - /* 570 */ 1067, 1068, 1069, 280, 1447, 24, 262, 1076, 1077, 1078, - /* 580 */ 1079, 1080, 1084, 1085, 295, 1463, 388, 271, 270, 59, - /* 590 */ 1510, 445, 429, 114, 1418, 1418, 1510, 1025, 1463, 297, - /* 600 */ 443, 1296, 431, 413, 1557, 429, 1418, 1194, 1507, 445, - /* 610 */ 1286, 417, 1050, 1018, 1506, 431, 1293, 130, 207, 1418, - /* 620 */ 67, 1555, 68, 1448, 1449, 1452, 1496, 470, 100, 1017, - /* 630 */ 237, 1492, 277, 174, 1293, 70, 1448, 1449, 1452, 1496, - /* 640 */ 114, 812, 1557, 1495, 1492, 48, 47, 307, 1295, 135, - /* 650 */ 1193, 1252, 1418, 1192, 301, 130, 1407, 350, 1190, 1555, - /* 660 */ 248, 98, 244, 517, 293, 1447, 289, 285, 132, 446, - /* 670 */ 415, 126, 1503, 1504, 1189, 1508, 1188, 212, 1125, 1510, - /* 680 */ 95, 1021, 156, 163, 1034, 154, 506, 355, 211, 1463, - /* 690 */ 494, 131, 287, 1187, 298, 1418, 416, 1505, 445, 249, - /* 700 */ 1447, 247, 246, 1418, 354, 1186, 431, 278, 428, 357, - /* 710 */ 1418, 1185, 1184, 1183, 66, 1026, 106, 205, 419, 1418, - /* 720 */ 392, 1418, 1182, 1293, 1463, 1020, 69, 1448, 1449, 1452, - /* 730 */ 1496, 429, 1029, 1340, 257, 1492, 125, 1213, 1418, 401, - /* 740 */ 1340, 431, 1447, 158, 1372, 1418, 157, 441, 189, 160, - /* 750 */ 1418, 1339, 159, 1447, 396, 1523, 1418, 1418, 1418, 369, - /* 760 */ 1211, 69, 1448, 1449, 1452, 1496, 1463, 1418, 378, 257, - /* 770 */ 1492, 1569, 395, 429, 190, 170, 162, 1463, 1447, 161, - /* 780 */ 1530, 376, 372, 431, 429, 44, 424, 1418, 338, 1139, - /* 790 */ 996, 177, 167, 1023, 431, 179, 9, 8, 1418, 413, - /* 800 */ 389, 397, 1463, 69, 1448, 1449, 1452, 1496, 1334, 429, - /* 810 */ 1019, 257, 1492, 1569, 231, 1448, 1449, 1452, 1073, 431, - /* 820 */ 64, 1447, 1553, 1418, 100, 1174, 1175, 33, 387, 33, - /* 830 */ 61, 1088, 1447, 1047, 1438, 183, 349, 832, 1012, 69, - /* 840 */ 1448, 1449, 1452, 1496, 390, 1463, 1436, 257, 1492, 1569, - /* 850 */ 1526, 33, 429, 833, 1010, 979, 1463, 98, 1514, 1464, - /* 860 */ 196, 94, 431, 429, 198, 437, 1418, 128, 1503, 1504, - /* 870 */ 1017, 1508, 104, 431, 1447, 1557, 204, 1418, 1022, 414, - /* 880 */ 192, 2, 70, 1448, 1449, 1452, 1496, 1032, 130, 282, - /* 890 */ 427, 1492, 1555, 118, 1448, 1449, 1452, 286, 1463, 243, - /* 900 */ 106, 245, 1447, 44, 889, 429, 858, 884, 450, 104, - /* 910 */ 514, 988, 917, 921, 213, 431, 105, 425, 151, 1418, - /* 920 */ 927, 124, 1011, 317, 106, 1370, 1463, 348, 926, 150, - /* 930 */ 1447, 418, 1570, 429, 137, 70, 1448, 1449, 1452, 1496, - /* 940 */ 323, 104, 330, 431, 1493, 107, 331, 1418, 332, 336, - /* 950 */ 1043, 337, 1042, 339, 1463, 53, 1013, 143, 148, 1447, - /* 960 */ 340, 429, 1041, 230, 1448, 1449, 1452, 21, 341, 146, - /* 970 */ 51, 431, 1040, 1016, 351, 1418, 344, 32, 30, 28, - /* 980 */ 27, 26, 149, 1463, 1447, 383, 356, 353, 381, 74, - /* 990 */ 429, 118, 1448, 1449, 1452, 409, 253, 1283, 384, 153, - /* 1000 */ 431, 382, 391, 1279, 1418, 155, 109, 261, 1463, 110, - /* 1010 */ 1281, 1277, 147, 111, 120, 429, 144, 112, 1447, 169, - /* 1020 */ 231, 1448, 1449, 1452, 23, 431, 1179, 393, 172, 1418, - /* 1030 */ 1571, 1039, 265, 142, 32, 30, 28, 27, 26, 402, - /* 1040 */ 1527, 394, 1463, 1017, 435, 231, 1448, 1449, 1452, 429, - /* 1050 */ 93, 92, 91, 90, 89, 88, 87, 86, 85, 431, - /* 1060 */ 1537, 175, 1447, 1418, 399, 5, 178, 410, 1447, 256, - /* 1070 */ 398, 405, 1113, 4, 1038, 99, 123, 34, 1517, 224, - /* 1080 */ 1448, 1449, 1452, 1536, 185, 258, 1463, 184, 182, 1511, - /* 1090 */ 17, 426, 1463, 429, 423, 1478, 1447, 1572, 191, 429, - /* 1100 */ 1379, 433, 1554, 431, 1447, 434, 438, 1418, 439, 431, - /* 1110 */ 1378, 200, 266, 1418, 202, 214, 440, 58, 1294, 60, - /* 1120 */ 1463, 448, 1266, 229, 1448, 1449, 1452, 429, 1463, 232, - /* 1130 */ 1448, 1449, 1452, 477, 216, 429, 210, 431, 1447, 222, - /* 1140 */ 40, 1418, 513, 223, 220, 431, 1268, 1412, 218, 1418, - /* 1150 */ 1447, 1411, 281, 1408, 283, 284, 1006, 225, 1448, 1449, - /* 1160 */ 1452, 1007, 1463, 133, 1406, 233, 1448, 1449, 1452, 429, - /* 1170 */ 288, 290, 291, 292, 1463, 1405, 294, 1404, 296, 431, - /* 1180 */ 1395, 429, 134, 1418, 299, 300, 991, 990, 1389, 1388, - /* 1190 */ 1387, 431, 305, 306, 1386, 1418, 1447, 962, 1363, 226, - /* 1200 */ 1448, 1449, 1452, 1362, 208, 1361, 1360, 1359, 476, 1358, - /* 1210 */ 1357, 234, 1448, 1449, 1452, 1356, 1355, 1354, 1353, 1352, - /* 1220 */ 1463, 1447, 1351, 103, 1350, 1349, 1348, 429, 1347, 1346, - /* 1230 */ 478, 1345, 1447, 964, 1344, 1343, 1342, 431, 1341, 1224, - /* 1240 */ 1403, 1418, 1397, 1385, 1376, 1463, 1272, 145, 825, 475, - /* 1250 */ 474, 473, 429, 472, 1223, 1221, 1463, 1460, 1448, 1449, - /* 1260 */ 1452, 345, 431, 429, 347, 1210, 1418, 1209, 1447, 346, - /* 1270 */ 1206, 1274, 73, 431, 1447, 152, 494, 1418, 932, 934, - /* 1280 */ 1273, 492, 1459, 1448, 1449, 1452, 857, 856, 855, 854, - /* 1290 */ 851, 850, 1463, 1458, 1448, 1449, 1452, 1219, 1463, 429, - /* 1300 */ 250, 1214, 1447, 251, 1212, 429, 252, 370, 1205, 431, - /* 1310 */ 1447, 373, 375, 1418, 1204, 431, 377, 1402, 71, 1418, - /* 1320 */ 166, 998, 1396, 43, 113, 385, 1463, 386, 122, 241, - /* 1330 */ 1448, 1449, 1452, 429, 1463, 240, 1448, 1449, 1452, 1384, - /* 1340 */ 1383, 429, 1375, 431, 1447, 54, 37, 1418, 171, 14, - /* 1350 */ 3, 431, 1436, 33, 173, 1418, 38, 15, 176, 1138, - /* 1360 */ 119, 181, 180, 242, 1448, 1449, 1452, 19, 1463, 10, - /* 1370 */ 55, 239, 1448, 1449, 1452, 429, 56, 20, 1131, 1110, - /* 1380 */ 36, 16, 1109, 187, 1160, 431, 1159, 1165, 259, 1418, - /* 1390 */ 1164, 1163, 260, 8, 129, 1048, 13, 35, 18, 194, - /* 1400 */ 195, 1136, 1074, 197, 199, 228, 1448, 1449, 1452, 436, - /* 1410 */ 1374, 201, 45, 1435, 57, 61, 1027, 918, 206, 203, - /* 1420 */ 39, 449, 273, 915, 453, 456, 447, 451, 454, 895, - /* 1430 */ 912, 457, 910, 906, 459, 460, 462, 904, 463, 929, - /* 1440 */ 62, 46, 63, 909, 928, 923, 469, 925, 823, 479, - /* 1450 */ 481, 908, 846, 864, 845, 907, 209, 844, 843, 842, - /* 1460 */ 841, 839, 840, 859, 836, 861, 835, 834, 831, 830, - /* 1470 */ 829, 828, 1220, 503, 504, 1208, 1207, 505, 507, 508, - /* 1480 */ 1203, 511, 512, 1178, 1014, 217, 515, 516, + /* 0 */ 257, 435, 274, 1452, 269, 52, 1223, 1385, 277, 25, + /* 10 */ 194, 306, 30, 28, 122, 1376, 1378, 1436, 96, 1436, + /* 20 */ 266, 447, 1016, 1436, 448, 1338, 1293, 1469, 369, 1432, + /* 30 */ 1438, 1432, 1438, 72, 431, 1432, 1439, 118, 1014, 1345, + /* 40 */ 354, 1256, 1563, 312, 434, 256, 1289, 11, 1423, 1298, + /* 50 */ 1343, 265, 1230, 415, 1021, 131, 817, 435, 816, 1561, + /* 60 */ 30, 28, 1123, 1386, 229, 1453, 1454, 1458, 266, 1275, + /* 70 */ 1016, 1, 12, 238, 30, 28, 818, 447, 100, 1345, + /* 80 */ 415, 447, 266, 448, 1016, 271, 1014, 345, 30, 28, + /* 90 */ 1343, 1423, 72, 1039, 517, 11, 266, 419, 1016, 360, + /* 100 */ 1014, 368, 1021, 362, 862, 100, 1015, 367, 1298, 11, + /* 110 */ 97, 98, 363, 361, 1014, 364, 1021, 1038, 1345, 1, + /* 120 */ 864, 187, 1509, 414, 278, 413, 448, 209, 1563, 1343, + /* 130 */ 1021, 479, 12, 1, 1227, 310, 1469, 117, 98, 1196, + /* 140 */ 1017, 131, 517, 431, 1036, 1561, 448, 7, 128, 1509, + /* 150 */ 1510, 1298, 1514, 481, 1015, 311, 517, 1020, 1040, 1041, + /* 160 */ 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1015, 485, + /* 170 */ 517, 1298, 478, 477, 476, 408, 475, 164, 1122, 132, + /* 180 */ 132, 357, 1015, 505, 504, 503, 502, 281, 1017, 501, + /* 190 */ 500, 499, 102, 494, 493, 492, 491, 490, 489, 488, + /* 200 */ 487, 108, 1017, 359, 6, 1020, 1040, 1041, 1067, 1068, + /* 210 */ 1069, 1070, 1071, 1072, 1073, 1074, 1017, 513, 512, 1020, + /* 220 */ 1040, 1041, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, + /* 230 */ 1042, 1040, 1041, 1020, 1040, 1041, 1067, 1068, 1069, 1070, + /* 240 */ 1071, 1072, 1073, 1074, 1147, 1276, 30, 28, 433, 32, + /* 250 */ 31, 29, 27, 26, 266, 132, 1016, 137, 409, 30, + /* 260 */ 28, 237, 305, 1036, 304, 448, 65, 266, 1185, 1016, + /* 270 */ 324, 405, 1014, 336, 317, 402, 1145, 1146, 1148, 1149, + /* 280 */ 101, 132, 337, 50, 1207, 1014, 49, 1290, 1021, 84, + /* 290 */ 1298, 345, 83, 82, 81, 80, 79, 78, 77, 76, + /* 300 */ 75, 1021, 132, 132, 331, 7, 483, 900, 471, 470, + /* 310 */ 469, 904, 468, 906, 907, 467, 909, 464, 7, 915, + /* 320 */ 461, 917, 918, 458, 455, 410, 406, 84, 517, 1423, + /* 330 */ 83, 82, 81, 80, 79, 78, 77, 76, 75, 1118, + /* 340 */ 1015, 517, 189, 32, 31, 29, 27, 26, 366, 365, + /* 350 */ 141, 140, 335, 1015, 1121, 330, 329, 328, 327, 326, + /* 360 */ 448, 323, 322, 321, 320, 316, 315, 314, 313, 318, + /* 370 */ 1177, 29, 27, 26, 1017, 32, 31, 29, 27, 26, + /* 380 */ 32, 31, 29, 27, 26, 1298, 1206, 1017, 486, 1205, + /* 390 */ 1270, 1020, 1040, 1041, 1067, 1068, 1069, 1070, 1071, 1072, + /* 400 */ 1073, 1074, 423, 1137, 1020, 1040, 1041, 1067, 1068, 1069, + /* 410 */ 1070, 1071, 1072, 1073, 1074, 241, 1037, 30, 28, 32, + /* 420 */ 31, 29, 27, 26, 368, 266, 362, 1016, 1204, 1452, + /* 430 */ 367, 1423, 373, 97, 1423, 363, 361, 1176, 364, 1287, + /* 440 */ 1055, 448, 52, 1014, 1452, 1563, 448, 381, 1086, 270, + /* 450 */ 344, 1274, 382, 1469, 241, 1295, 474, 115, 1562, 1021, + /* 460 */ 431, 166, 1561, 1294, 376, 1300, 1298, 59, 1469, 370, + /* 470 */ 434, 1298, 165, 1423, 1423, 418, 1, 448, 497, 419, + /* 480 */ 1203, 1202, 300, 1563, 1201, 434, 445, 1086, 1291, 1423, + /* 490 */ 228, 1453, 1454, 1458, 1087, 114, 131, 483, 42, 517, + /* 500 */ 1561, 41, 1298, 1200, 1088, 69, 1453, 1454, 1458, 1502, + /* 510 */ 1563, 1015, 1091, 259, 1498, 126, 276, 1283, 9, 8, + /* 520 */ 1182, 1373, 1092, 131, 115, 1423, 1423, 1561, 139, 1423, + /* 530 */ 116, 424, 1300, 1087, 1530, 222, 24, 264, 1081, 1082, + /* 540 */ 1083, 1084, 1085, 1089, 1090, 1017, 22, 220, 1423, 1199, + /* 550 */ 1198, 1091, 32, 31, 29, 27, 26, 142, 498, 496, + /* 560 */ 1285, 1452, 1020, 1040, 1041, 1067, 1068, 1069, 1070, 1071, + /* 570 */ 1072, 1073, 1074, 282, 1452, 24, 264, 1081, 1082, 1083, + /* 580 */ 1084, 1085, 1089, 1090, 422, 1469, 390, 273, 272, 1099, + /* 590 */ 1516, 448, 431, 115, 1423, 1423, 1516, 1029, 1469, 1345, + /* 600 */ 446, 1301, 434, 415, 1563, 431, 1423, 1195, 1513, 448, + /* 610 */ 1377, 419, 1055, 1022, 1512, 434, 1298, 131, 208, 1423, + /* 620 */ 67, 1561, 68, 1453, 1454, 1458, 1502, 1043, 100, 1021, + /* 630 */ 240, 1498, 279, 1281, 1298, 70, 1453, 1454, 1458, 1502, + /* 640 */ 115, 816, 1563, 1501, 1498, 48, 47, 309, 1300, 136, + /* 650 */ 1194, 169, 1423, 1193, 303, 131, 1218, 352, 1192, 1561, + /* 660 */ 250, 98, 246, 520, 295, 1452, 291, 287, 133, 449, + /* 670 */ 417, 127, 1509, 1510, 432, 1514, 1516, 213, 371, 1345, + /* 680 */ 95, 1025, 1412, 164, 1521, 1118, 509, 357, 212, 1469, + /* 690 */ 1344, 132, 1191, 1190, 1511, 1423, 418, 426, 1423, 251, + /* 700 */ 1452, 249, 248, 1423, 356, 1189, 434, 1188, 430, 359, + /* 710 */ 1423, 1187, 380, 216, 66, 1030, 1328, 206, 289, 32, + /* 720 */ 31, 29, 27, 26, 1469, 378, 69, 1453, 1454, 1458, + /* 730 */ 1502, 431, 1033, 473, 259, 1498, 126, 1423, 1423, 175, + /* 740 */ 157, 434, 1452, 155, 297, 1423, 1216, 444, 190, 448, + /* 750 */ 1423, 1130, 1423, 1452, 398, 1529, 1423, 1038, 280, 299, + /* 760 */ 1197, 69, 1453, 1454, 1458, 1502, 1469, 1257, 374, 259, + /* 770 */ 1498, 1575, 397, 431, 1298, 171, 421, 1469, 1452, 159, + /* 780 */ 1536, 191, 158, 434, 431, 161, 163, 1423, 160, 162, + /* 790 */ 1000, 106, 168, 403, 434, 394, 9, 8, 1423, 415, + /* 800 */ 391, 399, 1469, 69, 1453, 1454, 1458, 1502, 340, 431, + /* 810 */ 1024, 259, 1498, 1575, 233, 1453, 1454, 1458, 1078, 434, + /* 820 */ 389, 1452, 1559, 1423, 100, 44, 178, 33, 427, 1144, + /* 830 */ 180, 1093, 1452, 33, 1179, 1180, 1023, 1051, 1016, 69, + /* 840 */ 1453, 1454, 1458, 1502, 392, 1469, 33, 259, 1498, 1575, + /* 850 */ 983, 197, 431, 1339, 1014, 199, 1469, 98, 1520, 184, + /* 860 */ 1443, 94, 434, 431, 1532, 440, 1423, 129, 1509, 1510, + /* 870 */ 1021, 1514, 1441, 434, 1452, 1563, 104, 1423, 1027, 351, + /* 880 */ 205, 416, 70, 1453, 1454, 1458, 1502, 1470, 131, 2, + /* 890 */ 429, 1498, 1561, 119, 1453, 1454, 1458, 106, 1469, 44, + /* 900 */ 193, 893, 1452, 888, 1026, 431, 1036, 453, 104, 105, + /* 910 */ 517, 921, 925, 931, 284, 434, 106, 288, 152, 1423, + /* 920 */ 930, 125, 1015, 245, 104, 836, 1469, 350, 107, 151, + /* 930 */ 1452, 420, 1576, 431, 862, 70, 1453, 1454, 1458, 1502, + /* 940 */ 64, 837, 247, 434, 1499, 992, 214, 1423, 333, 319, + /* 950 */ 61, 1375, 138, 325, 1469, 53, 1017, 332, 149, 1452, + /* 960 */ 334, 431, 338, 232, 1453, 1454, 1458, 21, 1047, 1046, + /* 970 */ 341, 434, 339, 1020, 144, 1423, 1045, 32, 31, 29, + /* 980 */ 27, 26, 343, 1469, 1452, 342, 147, 51, 346, 150, + /* 990 */ 431, 119, 1453, 1454, 1458, 411, 1044, 353, 355, 1288, + /* 1000 */ 434, 358, 74, 255, 1423, 384, 385, 263, 1469, 154, + /* 1010 */ 1284, 156, 148, 109, 121, 431, 145, 110, 1452, 386, + /* 1020 */ 233, 1453, 1454, 1458, 23, 434, 1184, 170, 1286, 1423, + /* 1030 */ 1577, 1282, 267, 143, 32, 31, 29, 27, 26, 111, + /* 1040 */ 112, 383, 1469, 173, 396, 233, 1453, 1454, 1458, 431, + /* 1050 */ 93, 92, 91, 90, 89, 88, 87, 86, 85, 434, + /* 1060 */ 393, 395, 1452, 1423, 1043, 1533, 404, 1543, 1452, 438, + /* 1070 */ 176, 1021, 179, 401, 258, 412, 407, 183, 5, 225, + /* 1080 */ 1453, 1454, 1458, 1542, 400, 1523, 1469, 4, 1118, 99, + /* 1090 */ 1042, 124, 1469, 431, 1517, 34, 1452, 186, 185, 431, + /* 1100 */ 17, 260, 428, 434, 1452, 425, 1560, 1423, 436, 434, + /* 1110 */ 1578, 1484, 1384, 1423, 437, 192, 1383, 268, 441, 442, + /* 1120 */ 1469, 443, 203, 231, 1453, 1454, 1458, 431, 1469, 234, + /* 1130 */ 1453, 1454, 1458, 201, 58, 431, 215, 434, 1452, 1299, + /* 1140 */ 451, 1423, 60, 480, 1271, 434, 1273, 217, 211, 1423, + /* 1150 */ 1452, 516, 40, 223, 224, 219, 221, 226, 1453, 1454, + /* 1160 */ 1458, 1417, 1469, 1416, 283, 235, 1453, 1454, 1458, 431, + /* 1170 */ 1413, 285, 286, 1010, 1469, 1011, 134, 290, 1411, 434, + /* 1180 */ 292, 431, 293, 1423, 294, 1410, 296, 1409, 298, 1400, + /* 1190 */ 135, 434, 301, 302, 995, 1423, 1452, 994, 1394, 227, + /* 1200 */ 1453, 1454, 1458, 1393, 209, 307, 1392, 1391, 479, 308, + /* 1210 */ 966, 236, 1453, 1454, 1458, 1368, 1367, 1366, 1365, 1364, + /* 1220 */ 1469, 1452, 1363, 1362, 1361, 1360, 1359, 431, 1358, 1357, + /* 1230 */ 481, 1356, 1452, 103, 1355, 1354, 1353, 434, 1352, 1351, + /* 1240 */ 1350, 1423, 968, 1349, 1348, 1469, 1347, 1346, 1229, 478, + /* 1250 */ 477, 476, 431, 475, 1408, 1402, 1469, 1466, 1453, 1454, + /* 1260 */ 1458, 1390, 434, 431, 1381, 1277, 1423, 1228, 1452, 829, + /* 1270 */ 146, 1226, 1215, 434, 1452, 347, 349, 1423, 348, 1214, + /* 1280 */ 1211, 1279, 1465, 1453, 1454, 1458, 1278, 153, 73, 938, + /* 1290 */ 936, 861, 1469, 243, 1453, 1454, 1458, 860, 1469, 431, + /* 1300 */ 497, 859, 1452, 1224, 858, 431, 252, 855, 854, 434, + /* 1310 */ 1452, 1219, 253, 1423, 372, 434, 1217, 495, 254, 1423, + /* 1320 */ 375, 1210, 377, 1209, 379, 71, 1469, 1407, 43, 1464, + /* 1330 */ 1453, 1454, 1458, 431, 1469, 244, 1453, 1454, 1458, 167, + /* 1340 */ 1401, 431, 1002, 434, 1452, 113, 387, 1423, 1389, 1388, + /* 1350 */ 1380, 434, 172, 3, 54, 1423, 33, 14, 15, 177, + /* 1360 */ 38, 1143, 388, 242, 1453, 1454, 1458, 1136, 1469, 120, + /* 1370 */ 123, 239, 1453, 1454, 1458, 431, 182, 37, 181, 174, + /* 1380 */ 1441, 19, 20, 55, 188, 434, 56, 1115, 35, 1423, + /* 1390 */ 1114, 1170, 1165, 36, 16, 10, 130, 1164, 261, 1169, + /* 1400 */ 1168, 262, 8, 195, 1053, 230, 1453, 1454, 1458, 1052, + /* 1410 */ 13, 1379, 18, 1079, 196, 1141, 198, 200, 45, 202, + /* 1420 */ 204, 439, 57, 1031, 452, 61, 39, 275, 456, 922, + /* 1430 */ 919, 459, 462, 465, 914, 1440, 207, 454, 450, 457, + /* 1440 */ 899, 916, 460, 933, 910, 463, 929, 908, 466, 62, + /* 1450 */ 46, 63, 927, 482, 472, 827, 868, 484, 850, 210, + /* 1460 */ 913, 912, 849, 911, 848, 847, 846, 845, 843, 844, + /* 1470 */ 865, 863, 840, 839, 838, 835, 834, 833, 832, 932, + /* 1480 */ 1225, 506, 1213, 507, 508, 1212, 510, 511, 1208, 514, + /* 1490 */ 515, 1183, 1018, 218, 518, 519, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 233, 246, 233, 205, 249, 213, 0, 252, 238, 271, @@ -399,119 +401,119 @@ static const YYCODETYPE yy_lookahead[] = { /* 340 */ 106, 94, 132, 12, 13, 14, 15, 16, 215, 216, /* 350 */ 110, 111, 109, 106, 180, 112, 113, 114, 115, 116, /* 360 */ 211, 118, 119, 120, 121, 122, 123, 124, 125, 220, - /* 370 */ 133, 1, 2, 20, 140, 12, 13, 14, 15, 16, + /* 370 */ 133, 14, 15, 16, 140, 12, 13, 14, 15, 16, /* 380 */ 12, 13, 14, 15, 16, 236, 205, 140, 217, 205, /* 390 */ 219, 157, 158, 159, 160, 161, 162, 163, 164, 165, /* 400 */ 166, 167, 68, 72, 157, 158, 159, 160, 161, 162, - /* 410 */ 163, 164, 165, 166, 167, 47, 230, 12, 13, 12, + /* 410 */ 163, 164, 165, 166, 167, 47, 20, 12, 13, 12, /* 420 */ 13, 14, 15, 16, 49, 20, 51, 22, 205, 205, - /* 430 */ 55, 250, 4, 58, 250, 60, 61, 200, 63, 82, - /* 440 */ 72, 211, 72, 38, 205, 286, 211, 19, 80, 221, - /* 450 */ 220, 0, 255, 229, 47, 220, 236, 229, 299, 54, - /* 460 */ 236, 33, 303, 243, 36, 237, 236, 213, 229, 41, - /* 470 */ 246, 236, 44, 250, 250, 236, 71, 211, 230, 255, - /* 480 */ 14, 15, 16, 286, 205, 246, 220, 80, 234, 250, - /* 490 */ 266, 267, 268, 269, 126, 230, 299, 46, 70, 94, + /* 430 */ 55, 250, 4, 58, 250, 60, 61, 200, 63, 230, + /* 440 */ 72, 211, 213, 38, 205, 286, 211, 19, 80, 221, + /* 450 */ 220, 0, 255, 229, 47, 220, 82, 229, 299, 54, + /* 460 */ 236, 33, 303, 234, 36, 237, 236, 210, 229, 41, + /* 470 */ 246, 236, 44, 250, 250, 236, 71, 211, 68, 255, + /* 480 */ 205, 205, 72, 286, 205, 246, 220, 80, 231, 250, + /* 490 */ 266, 267, 268, 269, 126, 132, 299, 46, 70, 94, /* 500 */ 303, 73, 236, 205, 126, 266, 267, 268, 269, 270, - /* 510 */ 286, 106, 144, 274, 275, 276, 221, 215, 216, 230, - /* 520 */ 202, 20, 144, 299, 229, 222, 3, 303, 225, 250, + /* 510 */ 286, 106, 144, 274, 275, 276, 221, 230, 1, 2, + /* 520 */ 202, 236, 144, 299, 229, 250, 250, 303, 243, 250, /* 530 */ 18, 197, 237, 126, 295, 23, 168, 169, 170, 171, /* 540 */ 172, 173, 174, 175, 176, 140, 168, 35, 250, 205, - /* 550 */ 205, 144, 12, 13, 14, 15, 16, 45, 177, 178, + /* 550 */ 205, 144, 12, 13, 14, 15, 16, 45, 215, 216, /* 560 */ 230, 205, 157, 158, 159, 160, 161, 162, 163, 164, /* 570 */ 165, 166, 167, 255, 205, 168, 169, 170, 171, 172, - /* 580 */ 173, 174, 175, 176, 136, 229, 258, 12, 13, 210, - /* 590 */ 264, 211, 236, 229, 250, 250, 264, 22, 229, 151, + /* 580 */ 173, 174, 175, 176, 3, 229, 258, 12, 13, 72, + /* 590 */ 264, 211, 236, 229, 250, 250, 264, 22, 229, 229, /* 600 */ 220, 237, 246, 211, 286, 236, 250, 205, 282, 211, - /* 610 */ 231, 255, 72, 38, 282, 246, 236, 299, 220, 250, - /* 620 */ 108, 303, 266, 267, 268, 269, 270, 230, 236, 54, - /* 630 */ 274, 275, 221, 132, 236, 266, 267, 268, 269, 270, + /* 610 */ 240, 255, 72, 38, 282, 246, 236, 299, 220, 250, + /* 620 */ 108, 303, 266, 267, 268, 269, 270, 20, 236, 54, + /* 630 */ 274, 275, 221, 230, 236, 266, 267, 268, 269, 270, /* 640 */ 229, 22, 286, 274, 275, 133, 134, 135, 237, 137, - /* 650 */ 205, 218, 250, 206, 142, 299, 0, 38, 205, 303, + /* 650 */ 205, 230, 250, 205, 142, 299, 0, 38, 205, 303, /* 660 */ 35, 269, 150, 19, 152, 205, 154, 155, 156, 94, - /* 670 */ 278, 279, 280, 281, 205, 283, 205, 33, 14, 264, - /* 680 */ 36, 106, 75, 58, 20, 78, 42, 62, 44, 229, - /* 690 */ 68, 179, 36, 205, 72, 250, 236, 282, 211, 74, - /* 700 */ 205, 76, 77, 250, 79, 205, 246, 220, 47, 84, - /* 710 */ 250, 205, 205, 205, 70, 140, 68, 73, 195, 250, - /* 720 */ 72, 250, 205, 236, 229, 38, 266, 267, 268, 269, - /* 730 */ 270, 236, 157, 229, 274, 275, 276, 0, 250, 297, - /* 740 */ 229, 246, 205, 75, 240, 250, 78, 103, 288, 75, - /* 750 */ 250, 240, 78, 205, 294, 295, 250, 250, 250, 22, - /* 760 */ 0, 266, 267, 268, 269, 270, 229, 250, 21, 274, - /* 770 */ 275, 276, 128, 236, 306, 131, 75, 229, 205, 78, - /* 780 */ 285, 34, 22, 246, 236, 68, 68, 250, 246, 72, - /* 790 */ 146, 68, 148, 106, 246, 72, 1, 2, 250, 211, - /* 800 */ 211, 253, 229, 266, 267, 268, 269, 270, 239, 236, + /* 670 */ 278, 279, 280, 281, 230, 283, 264, 33, 22, 229, + /* 680 */ 36, 106, 0, 58, 177, 178, 42, 62, 44, 229, + /* 690 */ 240, 179, 205, 205, 282, 250, 236, 68, 250, 74, + /* 700 */ 205, 76, 77, 250, 79, 205, 246, 205, 47, 84, + /* 710 */ 250, 205, 21, 222, 70, 140, 225, 73, 36, 12, + /* 720 */ 13, 14, 15, 16, 229, 34, 266, 267, 268, 269, + /* 730 */ 270, 236, 157, 230, 274, 275, 276, 250, 250, 132, + /* 740 */ 75, 246, 205, 78, 136, 250, 0, 103, 288, 211, + /* 750 */ 250, 14, 250, 205, 294, 295, 250, 20, 220, 151, + /* 760 */ 206, 266, 267, 268, 269, 270, 229, 218, 22, 274, + /* 770 */ 275, 276, 128, 236, 236, 131, 195, 229, 205, 75, + /* 780 */ 285, 306, 78, 246, 236, 75, 75, 250, 78, 78, + /* 790 */ 146, 68, 148, 297, 246, 72, 1, 2, 250, 211, + /* 800 */ 211, 253, 229, 266, 267, 268, 269, 270, 246, 236, /* 810 */ 38, 274, 275, 276, 266, 267, 268, 269, 157, 246, - /* 820 */ 71, 205, 285, 250, 236, 158, 159, 68, 246, 68, - /* 830 */ 81, 72, 205, 72, 71, 291, 208, 38, 22, 266, - /* 840 */ 267, 268, 269, 270, 255, 229, 83, 274, 275, 276, - /* 850 */ 265, 68, 236, 54, 38, 72, 229, 269, 285, 229, - /* 860 */ 68, 68, 246, 236, 72, 72, 250, 279, 280, 281, - /* 870 */ 54, 283, 68, 246, 205, 286, 72, 250, 106, 284, - /* 880 */ 300, 287, 266, 267, 268, 269, 270, 20, 299, 211, - /* 890 */ 274, 275, 303, 266, 267, 268, 269, 36, 229, 261, - /* 900 */ 68, 215, 205, 68, 72, 236, 38, 72, 68, 68, - /* 910 */ 94, 138, 72, 72, 256, 246, 68, 199, 33, 250, - /* 920 */ 72, 36, 106, 211, 68, 211, 229, 42, 72, 44, - /* 930 */ 205, 304, 305, 236, 117, 266, 267, 268, 269, 270, - /* 940 */ 244, 68, 242, 246, 275, 72, 126, 250, 242, 211, - /* 950 */ 20, 260, 20, 254, 229, 70, 140, 213, 73, 205, - /* 960 */ 236, 236, 20, 266, 267, 268, 269, 2, 247, 213, - /* 970 */ 213, 246, 20, 157, 207, 250, 211, 12, 13, 14, - /* 980 */ 15, 16, 213, 229, 205, 147, 215, 229, 236, 211, - /* 990 */ 236, 266, 267, 268, 269, 298, 207, 229, 259, 229, - /* 1000 */ 246, 260, 254, 229, 250, 229, 229, 253, 229, 229, - /* 1010 */ 229, 229, 127, 229, 129, 236, 131, 229, 205, 210, - /* 1020 */ 266, 267, 268, 269, 2, 246, 0, 236, 210, 250, - /* 1030 */ 305, 20, 253, 148, 12, 13, 14, 15, 16, 187, - /* 1040 */ 265, 247, 229, 54, 186, 266, 267, 268, 269, 236, + /* 820 */ 246, 205, 285, 250, 236, 68, 68, 68, 199, 72, + /* 830 */ 72, 72, 205, 68, 158, 159, 38, 72, 22, 266, + /* 840 */ 267, 268, 269, 270, 255, 229, 68, 274, 275, 276, + /* 850 */ 72, 68, 236, 239, 38, 72, 229, 269, 285, 291, + /* 860 */ 71, 68, 246, 236, 265, 72, 250, 279, 280, 281, + /* 870 */ 54, 283, 83, 246, 205, 286, 68, 250, 106, 208, + /* 880 */ 72, 284, 266, 267, 268, 269, 270, 229, 299, 287, + /* 890 */ 274, 275, 303, 266, 267, 268, 269, 68, 229, 68, + /* 900 */ 300, 72, 205, 72, 106, 236, 20, 68, 68, 68, + /* 910 */ 94, 72, 72, 72, 211, 246, 68, 36, 33, 250, + /* 920 */ 72, 36, 106, 261, 68, 38, 229, 42, 72, 44, + /* 930 */ 205, 304, 305, 236, 38, 266, 267, 268, 269, 270, + /* 940 */ 71, 54, 215, 246, 275, 138, 256, 250, 126, 211, + /* 950 */ 81, 211, 117, 244, 229, 70, 140, 242, 73, 205, + /* 960 */ 242, 236, 211, 266, 267, 268, 269, 2, 20, 20, + /* 970 */ 254, 246, 260, 157, 213, 250, 20, 12, 13, 14, + /* 980 */ 15, 16, 247, 229, 205, 236, 213, 213, 211, 213, + /* 990 */ 236, 266, 267, 268, 269, 298, 20, 207, 229, 229, + /* 1000 */ 246, 215, 211, 207, 250, 260, 147, 253, 229, 229, + /* 1010 */ 229, 229, 127, 229, 129, 236, 131, 229, 205, 259, + /* 1020 */ 266, 267, 268, 269, 2, 246, 0, 210, 229, 250, + /* 1030 */ 305, 229, 253, 148, 12, 13, 14, 15, 16, 229, + /* 1040 */ 229, 236, 229, 210, 247, 266, 267, 268, 269, 236, /* 1050 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 246, - /* 1060 */ 296, 251, 205, 250, 250, 194, 251, 193, 205, 250, - /* 1070 */ 182, 250, 178, 181, 20, 236, 290, 117, 293, 266, - /* 1080 */ 267, 268, 269, 296, 277, 201, 229, 289, 292, 264, - /* 1090 */ 71, 198, 229, 236, 196, 273, 205, 307, 301, 236, - /* 1100 */ 251, 250, 302, 246, 205, 250, 129, 250, 248, 246, - /* 1110 */ 251, 236, 250, 250, 210, 225, 247, 210, 236, 71, - /* 1120 */ 229, 232, 219, 266, 267, 268, 269, 236, 229, 266, - /* 1130 */ 267, 268, 269, 215, 211, 236, 210, 246, 205, 223, - /* 1140 */ 257, 250, 207, 223, 203, 246, 0, 0, 212, 250, - /* 1150 */ 205, 0, 61, 0, 38, 153, 38, 266, 267, 268, - /* 1160 */ 269, 38, 229, 38, 0, 266, 267, 268, 269, 236, - /* 1170 */ 153, 38, 38, 153, 229, 0, 38, 0, 38, 246, - /* 1180 */ 0, 236, 71, 250, 144, 143, 106, 140, 0, 0, - /* 1190 */ 0, 246, 50, 136, 0, 250, 205, 83, 0, 266, - /* 1200 */ 267, 268, 269, 0, 58, 0, 0, 0, 62, 0, - /* 1210 */ 0, 266, 267, 268, 269, 0, 0, 0, 0, 0, - /* 1220 */ 229, 205, 0, 117, 0, 0, 0, 236, 0, 0, - /* 1230 */ 84, 0, 205, 22, 0, 0, 0, 246, 0, 0, - /* 1240 */ 0, 250, 0, 0, 0, 229, 0, 43, 48, 103, + /* 1060 */ 254, 236, 205, 250, 20, 265, 187, 296, 205, 186, + /* 1070 */ 251, 54, 251, 250, 250, 193, 250, 292, 194, 266, + /* 1080 */ 267, 268, 269, 296, 182, 293, 229, 181, 178, 236, + /* 1090 */ 20, 290, 229, 236, 264, 117, 205, 277, 289, 236, + /* 1100 */ 71, 201, 198, 246, 205, 196, 302, 250, 250, 246, + /* 1110 */ 307, 273, 251, 250, 250, 301, 251, 250, 129, 248, + /* 1120 */ 229, 247, 210, 266, 267, 268, 269, 236, 229, 266, + /* 1130 */ 267, 268, 269, 236, 210, 236, 225, 246, 205, 236, + /* 1140 */ 232, 250, 71, 215, 219, 246, 0, 211, 210, 250, + /* 1150 */ 205, 207, 257, 223, 223, 212, 203, 266, 267, 268, + /* 1160 */ 269, 0, 229, 0, 61, 266, 267, 268, 269, 236, + /* 1170 */ 0, 38, 153, 38, 229, 38, 38, 153, 0, 246, + /* 1180 */ 38, 236, 38, 250, 153, 0, 38, 0, 38, 0, + /* 1190 */ 71, 246, 144, 143, 106, 250, 205, 140, 0, 266, + /* 1200 */ 267, 268, 269, 0, 58, 50, 0, 0, 62, 136, + /* 1210 */ 83, 266, 267, 268, 269, 0, 0, 0, 0, 0, + /* 1220 */ 229, 205, 0, 0, 0, 0, 0, 236, 0, 0, + /* 1230 */ 84, 0, 205, 117, 0, 0, 0, 246, 0, 0, + /* 1240 */ 0, 250, 22, 0, 0, 229, 0, 0, 0, 103, /* 1250 */ 104, 105, 236, 107, 0, 0, 229, 266, 267, 268, - /* 1260 */ 269, 38, 246, 236, 43, 0, 250, 0, 205, 36, - /* 1270 */ 0, 0, 80, 246, 205, 78, 68, 250, 22, 38, - /* 1280 */ 0, 68, 266, 267, 268, 269, 38, 38, 38, 38, - /* 1290 */ 38, 38, 229, 266, 267, 268, 269, 0, 229, 236, - /* 1300 */ 22, 0, 205, 22, 0, 236, 22, 39, 0, 246, - /* 1310 */ 205, 38, 22, 250, 0, 246, 22, 0, 20, 250, - /* 1320 */ 149, 38, 0, 132, 145, 22, 229, 132, 129, 266, - /* 1330 */ 267, 268, 269, 236, 229, 266, 267, 268, 269, 0, - /* 1340 */ 0, 236, 0, 246, 205, 71, 132, 250, 43, 183, - /* 1350 */ 68, 246, 83, 68, 127, 250, 68, 183, 72, 72, - /* 1360 */ 71, 68, 71, 266, 267, 268, 269, 71, 229, 183, - /* 1370 */ 71, 266, 267, 268, 269, 236, 4, 68, 72, 72, - /* 1380 */ 68, 68, 72, 83, 38, 246, 38, 72, 38, 250, - /* 1390 */ 38, 38, 38, 2, 83, 72, 71, 177, 71, 83, - /* 1400 */ 72, 72, 157, 71, 71, 266, 267, 268, 269, 130, - /* 1410 */ 0, 43, 71, 83, 71, 81, 22, 72, 83, 127, - /* 1420 */ 71, 38, 38, 72, 38, 38, 82, 71, 71, 22, - /* 1430 */ 72, 71, 96, 72, 38, 71, 38, 72, 71, 38, - /* 1440 */ 71, 71, 71, 96, 106, 22, 84, 38, 48, 47, - /* 1450 */ 69, 96, 38, 54, 38, 96, 68, 38, 38, 38, - /* 1460 */ 38, 22, 38, 38, 38, 54, 38, 38, 38, 38, - /* 1470 */ 38, 38, 0, 38, 36, 0, 0, 43, 38, 37, - /* 1480 */ 0, 22, 21, 308, 22, 22, 21, 20, 308, 308, - /* 1490 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, + /* 1260 */ 269, 0, 246, 236, 0, 0, 250, 0, 205, 48, + /* 1270 */ 43, 0, 0, 246, 205, 38, 43, 250, 36, 0, + /* 1280 */ 0, 0, 266, 267, 268, 269, 0, 78, 80, 38, + /* 1290 */ 22, 38, 229, 266, 267, 268, 269, 38, 229, 236, + /* 1300 */ 68, 38, 205, 0, 38, 236, 22, 38, 38, 246, + /* 1310 */ 205, 0, 22, 250, 39, 246, 0, 68, 22, 250, + /* 1320 */ 38, 0, 22, 0, 22, 20, 229, 0, 132, 266, + /* 1330 */ 267, 268, 269, 236, 229, 266, 267, 268, 269, 149, + /* 1340 */ 0, 236, 38, 246, 205, 145, 22, 250, 0, 0, + /* 1350 */ 0, 246, 43, 68, 71, 250, 68, 183, 183, 72, + /* 1360 */ 68, 72, 132, 266, 267, 268, 269, 72, 229, 71, + /* 1370 */ 129, 266, 267, 268, 269, 236, 68, 132, 71, 127, + /* 1380 */ 83, 71, 68, 71, 83, 246, 4, 72, 177, 250, + /* 1390 */ 72, 72, 38, 68, 68, 183, 83, 38, 38, 38, + /* 1400 */ 38, 38, 2, 83, 72, 266, 267, 268, 269, 72, + /* 1410 */ 71, 0, 71, 157, 72, 72, 71, 71, 71, 43, + /* 1420 */ 127, 130, 71, 22, 38, 81, 71, 38, 38, 72, + /* 1430 */ 72, 38, 38, 38, 96, 83, 83, 71, 82, 71, + /* 1440 */ 22, 72, 71, 38, 72, 71, 38, 72, 71, 71, + /* 1450 */ 71, 71, 22, 47, 84, 48, 54, 69, 38, 68, + /* 1460 */ 96, 96, 38, 96, 38, 38, 38, 38, 22, 38, + /* 1470 */ 54, 38, 38, 38, 38, 38, 38, 38, 38, 106, + /* 1480 */ 0, 38, 0, 36, 43, 0, 38, 37, 0, 22, + /* 1490 */ 21, 308, 22, 22, 21, 20, 308, 308, 308, 308, /* 1500 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, /* 1510 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, /* 1520 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, @@ -531,10 +533,11 @@ static const YYCODETYPE yy_lookahead[] = { /* 1660 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, /* 1670 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, /* 1680 */ 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, + /* 1690 */ 308, 308, 308, 308, 308, 308, 308, 308, }; -#define YY_SHIFT_COUNT (517) +#define YY_SHIFT_COUNT (520) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1480) +#define YY_SHIFT_MAX (1488) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 512, 0, 48, 62, 62, 62, 62, 76, 62, 62, /* 10 */ 247, 405, 1, 234, 247, 247, 247, 247, 247, 247, @@ -546,50 +549,51 @@ static const unsigned short int yy_shift_ofst[] = { /* 70 */ 407, 306, 625, 816, 375, 816, 816, 816, 816, 816, /* 80 */ 816, 816, 816, 816, 816, 816, 816, 816, 816, 816, /* 90 */ 816, 816, 816, 816, 73, 36, 245, 66, 210, 210, - /* 100 */ 210, 451, 66, 353, 97, 97, 97, 357, 115, 222, - /* 110 */ 222, 222, 222, 222, 222, 644, 268, 52, 237, 87, - /* 120 */ 73, 119, 73, 141, 619, 501, 381, 161, 381, 664, - /* 130 */ 523, 174, 867, 861, 868, 773, 867, 867, 817, 820, - /* 140 */ 820, 867, 930, 932, 41, 353, 942, 41, 41, 867, - /* 150 */ 41, 952, 97, 97, 97, 97, 97, 97, 97, 97, - /* 160 */ 97, 97, 97, 868, 867, 952, 353, 930, 838, 932, - /* 170 */ 260, 353, 942, 260, 1011, 852, 858, 989, 852, 858, - /* 180 */ 989, 989, 871, 874, 888, 892, 894, 353, 1054, 960, - /* 190 */ 884, 893, 898, 1019, 97, 858, 989, 989, 858, 989, - /* 200 */ 977, 353, 942, 260, 357, 260, 353, 1048, 868, 115, - /* 210 */ 867, 260, 952, 1488, 1488, 1488, 1488, 1488, 134, 885, - /* 220 */ 1026, 428, 69, 1146, 331, 965, 1022, 540, 363, 363, - /* 230 */ 363, 363, 363, 363, 363, 213, 240, 370, 378, 466, - /* 240 */ 466, 466, 466, 656, 448, 622, 607, 668, 674, 701, - /* 250 */ 6, 737, 760, 747, 648, 717, 723, 795, 667, 334, - /* 260 */ 718, 759, 661, 761, 763, 783, 792, 793, 804, 832, - /* 270 */ 687, 772, 835, 840, 841, 848, 856, 873, 749, 799, - /* 280 */ 1147, 1151, 1091, 1153, 1116, 1002, 1118, 1123, 1125, 1017, - /* 290 */ 1164, 1133, 1134, 1020, 1175, 1138, 1177, 1140, 1180, 1111, - /* 300 */ 1040, 1042, 1080, 1047, 1188, 1189, 1142, 1057, 1190, 1194, - /* 310 */ 1114, 1198, 1203, 1205, 1206, 1207, 1209, 1210, 1215, 1216, - /* 320 */ 1217, 1218, 1219, 1222, 1106, 1224, 1225, 1226, 1228, 1229, - /* 330 */ 1231, 1211, 1234, 1235, 1236, 1238, 1239, 1240, 1242, 1243, - /* 340 */ 1244, 1204, 1246, 1200, 1254, 1255, 1223, 1233, 1221, 1265, - /* 350 */ 1267, 1270, 1271, 1192, 1197, 1241, 1208, 1256, 1280, 1248, - /* 360 */ 1249, 1250, 1251, 1213, 1208, 1252, 1253, 1297, 1278, 1301, - /* 370 */ 1281, 1268, 1304, 1284, 1273, 1308, 1290, 1314, 1294, 1298, - /* 380 */ 1317, 1191, 1171, 1283, 1322, 1179, 1303, 1195, 1199, 1339, - /* 390 */ 1340, 1214, 1342, 1274, 1305, 1227, 1282, 1285, 1166, 1286, - /* 400 */ 1288, 1287, 1289, 1291, 1296, 1306, 1293, 1269, 1299, 1309, - /* 410 */ 1174, 1307, 1310, 1300, 1220, 1312, 1311, 1315, 1313, 1186, - /* 420 */ 1372, 1346, 1348, 1350, 1352, 1353, 1354, 1391, 1245, 1316, - /* 430 */ 1323, 1325, 1327, 1328, 1329, 1332, 1333, 1279, 1341, 1410, - /* 440 */ 1368, 1292, 1343, 1334, 1330, 1335, 1394, 1349, 1344, 1345, - /* 450 */ 1383, 1384, 1356, 1351, 1386, 1357, 1358, 1387, 1360, 1361, - /* 460 */ 1396, 1364, 1365, 1398, 1367, 1336, 1347, 1355, 1359, 1407, - /* 470 */ 1362, 1369, 1401, 1338, 1370, 1371, 1409, 1208, 1423, 1400, - /* 480 */ 1402, 1399, 1381, 1388, 1414, 1416, 1419, 1420, 1421, 1422, - /* 490 */ 1424, 1439, 1411, 1213, 1425, 1208, 1426, 1428, 1429, 1430, - /* 500 */ 1431, 1432, 1433, 1472, 1435, 1438, 1434, 1475, 1440, 1442, - /* 510 */ 1476, 1480, 1459, 1461, 1462, 1463, 1465, 1467, + /* 100 */ 210, 451, 66, 396, 97, 97, 97, 374, 115, 222, + /* 110 */ 222, 222, 222, 222, 222, 222, 644, 268, 52, 237, + /* 120 */ 87, 73, 119, 73, 141, 619, 607, 507, 161, 507, + /* 130 */ 737, 581, 174, 886, 881, 896, 807, 886, 886, 835, + /* 140 */ 822, 822, 886, 948, 949, 41, 396, 956, 41, 41, + /* 150 */ 886, 41, 976, 97, 97, 97, 97, 97, 97, 97, + /* 160 */ 97, 97, 97, 97, 896, 886, 976, 396, 948, 859, + /* 170 */ 949, 260, 396, 956, 260, 1044, 879, 883, 1017, 879, + /* 180 */ 883, 1017, 1017, 884, 882, 902, 906, 910, 396, 1070, + /* 190 */ 978, 900, 904, 909, 1029, 97, 883, 1017, 1017, 883, + /* 200 */ 1017, 989, 396, 956, 260, 374, 260, 396, 1071, 896, + /* 210 */ 115, 886, 260, 976, 1496, 1496, 1496, 1496, 1496, 134, + /* 220 */ 885, 1026, 428, 69, 1146, 331, 965, 1022, 540, 363, + /* 230 */ 707, 707, 707, 707, 707, 707, 707, 213, 240, 357, + /* 240 */ 517, 378, 357, 357, 357, 682, 608, 410, 665, 704, + /* 250 */ 710, 711, 6, 656, 746, 691, 723, 757, 758, 795, + /* 260 */ 676, 334, 629, 759, 661, 765, 789, 778, 783, 793, + /* 270 */ 808, 829, 772, 798, 831, 839, 840, 841, 848, 856, + /* 280 */ 869, 887, 1161, 1163, 1103, 1170, 1133, 1019, 1135, 1137, + /* 290 */ 1138, 1024, 1178, 1142, 1144, 1031, 1185, 1148, 1187, 1150, + /* 300 */ 1189, 1119, 1048, 1050, 1088, 1057, 1198, 1203, 1155, 1073, + /* 310 */ 1206, 1207, 1127, 1215, 1216, 1217, 1218, 1219, 1222, 1223, + /* 320 */ 1224, 1225, 1226, 1228, 1229, 1231, 1116, 1234, 1235, 1236, + /* 330 */ 1238, 1239, 1240, 1220, 1243, 1244, 1246, 1247, 1248, 1254, + /* 340 */ 1255, 1261, 1264, 1227, 1265, 1221, 1267, 1271, 1237, 1242, + /* 350 */ 1233, 1272, 1279, 1280, 1281, 1208, 1209, 1251, 1232, 1268, + /* 360 */ 1286, 1253, 1259, 1263, 1266, 1249, 1232, 1269, 1270, 1303, + /* 370 */ 1284, 1311, 1290, 1275, 1316, 1296, 1282, 1321, 1300, 1323, + /* 380 */ 1302, 1305, 1327, 1196, 1190, 1304, 1340, 1200, 1324, 1230, + /* 390 */ 1241, 1348, 1349, 1245, 1350, 1283, 1309, 1252, 1285, 1288, + /* 400 */ 1174, 1287, 1292, 1289, 1298, 1307, 1310, 1295, 1308, 1297, + /* 410 */ 1312, 1314, 1175, 1315, 1318, 1301, 1211, 1325, 1313, 1319, + /* 420 */ 1326, 1212, 1382, 1354, 1359, 1360, 1361, 1362, 1363, 1400, + /* 430 */ 1256, 1320, 1332, 1337, 1339, 1341, 1342, 1343, 1345, 1346, + /* 440 */ 1291, 1347, 1411, 1376, 1293, 1351, 1344, 1352, 1353, 1401, + /* 450 */ 1355, 1356, 1357, 1386, 1389, 1366, 1358, 1390, 1368, 1369, + /* 460 */ 1393, 1371, 1372, 1394, 1374, 1375, 1395, 1377, 1338, 1364, + /* 470 */ 1365, 1367, 1418, 1370, 1378, 1405, 1373, 1379, 1380, 1408, + /* 480 */ 1232, 1430, 1407, 1406, 1402, 1388, 1391, 1420, 1424, 1426, + /* 490 */ 1427, 1428, 1429, 1431, 1446, 1416, 1249, 1433, 1232, 1434, + /* 500 */ 1435, 1436, 1437, 1438, 1439, 1440, 1480, 1443, 1447, 1441, + /* 510 */ 1482, 1448, 1450, 1485, 1488, 1467, 1469, 1470, 1471, 1473, + /* 520 */ 1475, }; -#define YY_REDUCE_COUNT (217) +#define YY_REDUCE_COUNT (218) #define YY_REDUCE_MIN (-262) #define YY_REDUCE_MAX (1139) static const short yy_reduce_ofst[] = { @@ -599,76 +603,77 @@ static const short yy_reduce_ofst[] = { /* 30 */ 1069, 1097, 1105, 1139, 392, -131, 588, 589, -233, -231, /* 40 */ -244, -187, -128, 197, -227, -245, -230, -85, -65, 54, /* 50 */ 149, 230, 235, -208, -190, -93, 159, 228, 266, 380, - /* 60 */ -150, 398, 295, -111, 411, 487, 56, -168, -262, -262, - /* 70 */ -262, -67, -214, -159, -177, 79, 181, 184, 223, 279, - /* 80 */ 298, 344, 345, 402, 445, 453, 469, 471, 488, 500, - /* 90 */ 506, 507, 508, 517, -189, 9, 254, 133, 326, 332, - /* 100 */ 415, 379, 302, 220, 364, 504, 511, 303, 171, 186, - /* 110 */ 248, 265, 289, 330, 397, 328, 447, 433, 468, 442, - /* 120 */ 542, 569, 582, 544, 628, 585, 595, 595, 595, 630, - /* 130 */ 580, 594, 678, 638, 686, 658, 712, 714, 696, 700, - /* 140 */ 706, 738, 691, 699, 744, 724, 721, 756, 757, 765, - /* 150 */ 769, 767, 758, 768, 770, 774, 776, 777, 780, 781, - /* 160 */ 782, 784, 788, 771, 778, 789, 752, 741, 739, 748, - /* 170 */ 809, 791, 794, 818, 775, 764, 810, 814, 787, 815, - /* 180 */ 819, 821, 785, 796, 786, 798, 595, 839, 825, 807, - /* 190 */ 790, 800, 797, 822, 630, 849, 851, 855, 859, 862, - /* 200 */ 860, 875, 869, 904, 890, 907, 882, 889, 918, 903, - /* 210 */ 923, 926, 935, 883, 916, 920, 936, 941, + /* 60 */ -150, 398, 295, -111, 411, 538, 56, -168, -262, -262, + /* 70 */ -262, -67, -214, -159, -177, 79, 181, 184, 223, 275, + /* 80 */ 276, 279, 298, 344, 345, 402, 445, 448, 453, 487, + /* 90 */ 488, 500, 502, 506, -189, 9, 229, 133, 326, 332, + /* 100 */ 412, 257, 343, 285, 364, 370, 450, 491, 171, 209, + /* 110 */ 287, 330, 403, 421, 444, 503, 328, 554, 549, 475, + /* 120 */ 496, 562, 614, 574, 568, 671, 599, 597, 597, 597, + /* 130 */ 658, 600, 602, 703, 662, 727, 690, 738, 740, 709, + /* 140 */ 715, 718, 751, 712, 716, 761, 749, 735, 773, 774, + /* 150 */ 777, 776, 790, 769, 770, 780, 781, 782, 784, 788, + /* 160 */ 799, 802, 810, 811, 786, 791, 796, 805, 745, 760, + /* 170 */ 806, 817, 825, 797, 833, 800, 771, 819, 823, 787, + /* 180 */ 821, 824, 826, 792, 785, 801, 809, 597, 853, 830, + /* 190 */ 820, 803, 804, 814, 838, 658, 861, 858, 864, 865, + /* 200 */ 867, 871, 897, 874, 912, 911, 924, 903, 908, 928, + /* 210 */ 925, 936, 938, 944, 895, 930, 931, 943, 953, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 10 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 20 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 30 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 40 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 50 */ 1176, 1176, 1176, 1229, 1176, 1176, 1176, 1176, 1176, 1176, - /* 60 */ 1176, 1176, 1176, 1176, 1176, 1176, 1227, 1364, 1176, 1498, - /* 70 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 80 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 90 */ 1176, 1176, 1176, 1176, 1176, 1176, 1229, 1176, 1509, 1509, - /* 100 */ 1509, 1227, 1176, 1176, 1176, 1176, 1176, 1322, 1176, 1176, - /* 110 */ 1176, 1176, 1176, 1176, 1176, 1398, 1176, 1176, 1573, 1176, - /* 120 */ 1176, 1275, 1176, 1533, 1176, 1525, 1501, 1515, 1502, 1176, - /* 130 */ 1558, 1518, 1176, 1176, 1176, 1390, 1176, 1176, 1369, 1366, - /* 140 */ 1366, 1176, 1176, 1176, 1229, 1176, 1176, 1229, 1229, 1176, - /* 150 */ 1229, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 160 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1400, 1176, - /* 170 */ 1227, 1176, 1176, 1227, 1176, 1540, 1538, 1176, 1540, 1538, - /* 180 */ 1176, 1176, 1552, 1548, 1531, 1529, 1515, 1176, 1176, 1176, - /* 190 */ 1576, 1564, 1560, 1176, 1176, 1538, 1176, 1176, 1538, 1176, - /* 200 */ 1377, 1176, 1176, 1227, 1176, 1227, 1176, 1291, 1176, 1176, - /* 210 */ 1176, 1227, 1176, 1392, 1325, 1325, 1230, 1181, 1176, 1176, - /* 220 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1462, 1551, - /* 230 */ 1550, 1461, 1475, 1474, 1473, 1176, 1176, 1176, 1176, 1456, - /* 240 */ 1457, 1455, 1454, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 250 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1499, 1176, 1561, - /* 260 */ 1565, 1176, 1176, 1176, 1437, 1176, 1176, 1176, 1176, 1176, - /* 270 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 280 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 290 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 300 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 310 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 320 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 330 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 340 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 350 */ 1176, 1176, 1176, 1176, 1176, 1176, 1336, 1176, 1176, 1176, - /* 360 */ 1176, 1176, 1176, 1256, 1255, 1176, 1176, 1176, 1176, 1176, - /* 370 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 380 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 390 */ 1176, 1176, 1176, 1176, 1176, 1176, 1522, 1532, 1176, 1176, - /* 400 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1437, 1176, 1549, - /* 410 */ 1176, 1508, 1504, 1176, 1176, 1500, 1176, 1176, 1559, 1176, - /* 420 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1494, 1176, 1176, - /* 430 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 440 */ 1176, 1176, 1176, 1176, 1436, 1176, 1176, 1176, 1176, 1176, - /* 450 */ 1176, 1176, 1319, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 460 */ 1176, 1176, 1176, 1176, 1176, 1304, 1302, 1301, 1300, 1176, - /* 470 */ 1297, 1176, 1176, 1176, 1176, 1176, 1176, 1327, 1176, 1176, - /* 480 */ 1176, 1176, 1176, 1250, 1176, 1176, 1176, 1176, 1176, 1176, - /* 490 */ 1176, 1176, 1176, 1241, 1176, 1240, 1176, 1176, 1176, 1176, - /* 500 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, - /* 510 */ 1176, 1176, 1176, 1176, 1176, 1176, 1176, 1176, + /* 0 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 10 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 20 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 30 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 40 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 50 */ 1181, 1181, 1181, 1234, 1181, 1181, 1181, 1181, 1181, 1181, + /* 60 */ 1181, 1181, 1181, 1181, 1181, 1181, 1232, 1369, 1181, 1504, + /* 70 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 80 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 90 */ 1181, 1181, 1181, 1181, 1181, 1181, 1234, 1181, 1515, 1515, + /* 100 */ 1515, 1232, 1181, 1181, 1181, 1181, 1181, 1327, 1181, 1181, + /* 110 */ 1181, 1181, 1181, 1181, 1181, 1181, 1403, 1181, 1181, 1579, + /* 120 */ 1181, 1181, 1280, 1181, 1539, 1181, 1531, 1507, 1521, 1508, + /* 130 */ 1181, 1564, 1524, 1181, 1181, 1181, 1395, 1181, 1181, 1374, + /* 140 */ 1371, 1371, 1181, 1181, 1181, 1234, 1181, 1181, 1234, 1234, + /* 150 */ 1181, 1234, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 160 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1405, + /* 170 */ 1181, 1232, 1181, 1181, 1232, 1181, 1546, 1544, 1181, 1546, + /* 180 */ 1544, 1181, 1181, 1558, 1554, 1537, 1535, 1521, 1181, 1181, + /* 190 */ 1181, 1582, 1570, 1566, 1181, 1181, 1544, 1181, 1181, 1544, + /* 200 */ 1181, 1382, 1181, 1181, 1232, 1181, 1232, 1181, 1296, 1181, + /* 210 */ 1181, 1181, 1232, 1181, 1397, 1330, 1330, 1235, 1186, 1181, + /* 220 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1467, + /* 230 */ 1468, 1557, 1556, 1467, 1481, 1480, 1479, 1181, 1181, 1462, + /* 240 */ 1181, 1181, 1463, 1461, 1460, 1181, 1181, 1181, 1181, 1181, + /* 250 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1505, + /* 260 */ 1181, 1567, 1571, 1181, 1181, 1181, 1442, 1181, 1181, 1181, + /* 270 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 280 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 290 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 300 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 310 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 320 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 330 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 340 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 350 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1341, 1181, + /* 360 */ 1181, 1181, 1181, 1181, 1181, 1261, 1260, 1181, 1181, 1181, + /* 370 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 380 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 390 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1528, 1538, + /* 400 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1442, + /* 410 */ 1181, 1555, 1181, 1514, 1510, 1181, 1181, 1506, 1181, 1181, + /* 420 */ 1565, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1500, + /* 430 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 440 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1441, 1181, 1181, + /* 450 */ 1181, 1181, 1181, 1181, 1181, 1324, 1181, 1181, 1181, 1181, + /* 460 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1309, 1307, + /* 470 */ 1306, 1305, 1181, 1302, 1181, 1181, 1181, 1181, 1181, 1181, + /* 480 */ 1332, 1181, 1181, 1181, 1181, 1181, 1255, 1181, 1181, 1181, + /* 490 */ 1181, 1181, 1181, 1181, 1181, 1181, 1246, 1181, 1245, 1181, + /* 500 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 510 */ 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, + /* 520 */ 1181, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1363,133 +1368,134 @@ static const char *const yyRuleName[] = { /* 270 */ "expression ::= column_reference", /* 271 */ "expression ::= function_name NK_LP expression_list NK_RP", /* 272 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 273 */ "expression ::= subquery", - /* 274 */ "expression ::= NK_LP expression NK_RP", - /* 275 */ "expression ::= NK_PLUS expression", - /* 276 */ "expression ::= NK_MINUS expression", - /* 277 */ "expression ::= expression NK_PLUS expression", - /* 278 */ "expression ::= expression NK_MINUS expression", - /* 279 */ "expression ::= expression NK_STAR expression", - /* 280 */ "expression ::= expression NK_SLASH expression", - /* 281 */ "expression ::= expression NK_REM expression", - /* 282 */ "expression_list ::= expression", - /* 283 */ "expression_list ::= expression_list NK_COMMA expression", - /* 284 */ "column_reference ::= column_name", - /* 285 */ "column_reference ::= table_name NK_DOT column_name", - /* 286 */ "pseudo_column ::= NOW", - /* 287 */ "pseudo_column ::= ROWTS", - /* 288 */ "pseudo_column ::= TBNAME", - /* 289 */ "pseudo_column ::= QSTARTTS", - /* 290 */ "pseudo_column ::= QENDTS", - /* 291 */ "pseudo_column ::= WSTARTTS", - /* 292 */ "pseudo_column ::= WENDTS", - /* 293 */ "pseudo_column ::= WDURATION", - /* 294 */ "predicate ::= expression compare_op expression", - /* 295 */ "predicate ::= expression BETWEEN expression AND expression", - /* 296 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 297 */ "predicate ::= expression IS NULL", - /* 298 */ "predicate ::= expression IS NOT NULL", - /* 299 */ "predicate ::= expression in_op in_predicate_value", - /* 300 */ "compare_op ::= NK_LT", - /* 301 */ "compare_op ::= NK_GT", - /* 302 */ "compare_op ::= NK_LE", - /* 303 */ "compare_op ::= NK_GE", - /* 304 */ "compare_op ::= NK_NE", - /* 305 */ "compare_op ::= NK_EQ", - /* 306 */ "compare_op ::= LIKE", - /* 307 */ "compare_op ::= NOT LIKE", - /* 308 */ "compare_op ::= MATCH", - /* 309 */ "compare_op ::= NMATCH", - /* 310 */ "in_op ::= IN", - /* 311 */ "in_op ::= NOT IN", - /* 312 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 313 */ "boolean_value_expression ::= boolean_primary", - /* 314 */ "boolean_value_expression ::= NOT boolean_primary", - /* 315 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 316 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 317 */ "boolean_primary ::= predicate", - /* 318 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 319 */ "common_expression ::= expression", - /* 320 */ "common_expression ::= boolean_value_expression", - /* 321 */ "from_clause ::= FROM table_reference_list", - /* 322 */ "table_reference_list ::= table_reference", - /* 323 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 324 */ "table_reference ::= table_primary", - /* 325 */ "table_reference ::= joined_table", - /* 326 */ "table_primary ::= table_name alias_opt", - /* 327 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 328 */ "table_primary ::= subquery alias_opt", - /* 329 */ "table_primary ::= parenthesized_joined_table", - /* 330 */ "alias_opt ::=", - /* 331 */ "alias_opt ::= table_alias", - /* 332 */ "alias_opt ::= AS table_alias", - /* 333 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 334 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 335 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 336 */ "join_type ::=", - /* 337 */ "join_type ::= INNER", - /* 338 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 339 */ "set_quantifier_opt ::=", - /* 340 */ "set_quantifier_opt ::= DISTINCT", - /* 341 */ "set_quantifier_opt ::= ALL", - /* 342 */ "select_list ::= NK_STAR", - /* 343 */ "select_list ::= select_sublist", - /* 344 */ "select_sublist ::= select_item", - /* 345 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 346 */ "select_item ::= common_expression", - /* 347 */ "select_item ::= common_expression column_alias", - /* 348 */ "select_item ::= common_expression AS column_alias", - /* 349 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 350 */ "where_clause_opt ::=", - /* 351 */ "where_clause_opt ::= WHERE search_condition", - /* 352 */ "partition_by_clause_opt ::=", - /* 353 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 354 */ "twindow_clause_opt ::=", - /* 355 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 356 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 357 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 358 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 359 */ "sliding_opt ::=", - /* 360 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 361 */ "fill_opt ::=", - /* 362 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 363 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 364 */ "fill_mode ::= NONE", - /* 365 */ "fill_mode ::= PREV", - /* 366 */ "fill_mode ::= NULL", - /* 367 */ "fill_mode ::= LINEAR", - /* 368 */ "fill_mode ::= NEXT", - /* 369 */ "group_by_clause_opt ::=", - /* 370 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 371 */ "group_by_list ::= expression", - /* 372 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 373 */ "having_clause_opt ::=", - /* 374 */ "having_clause_opt ::= HAVING search_condition", - /* 375 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 376 */ "query_expression_body ::= query_primary", - /* 377 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 378 */ "query_primary ::= query_specification", - /* 379 */ "order_by_clause_opt ::=", - /* 380 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 381 */ "slimit_clause_opt ::=", - /* 382 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 383 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 384 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 385 */ "limit_clause_opt ::=", - /* 386 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 387 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 388 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 389 */ "subquery ::= NK_LP query_expression NK_RP", - /* 390 */ "search_condition ::= common_expression", - /* 391 */ "sort_specification_list ::= sort_specification", - /* 392 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 393 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 394 */ "ordering_specification_opt ::=", - /* 395 */ "ordering_specification_opt ::= ASC", - /* 396 */ "ordering_specification_opt ::= DESC", - /* 397 */ "null_ordering_opt ::=", - /* 398 */ "null_ordering_opt ::= NULLS FIRST", - /* 399 */ "null_ordering_opt ::= NULLS LAST", + /* 273 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", + /* 274 */ "expression ::= subquery", + /* 275 */ "expression ::= NK_LP expression NK_RP", + /* 276 */ "expression ::= NK_PLUS expression", + /* 277 */ "expression ::= NK_MINUS expression", + /* 278 */ "expression ::= expression NK_PLUS expression", + /* 279 */ "expression ::= expression NK_MINUS expression", + /* 280 */ "expression ::= expression NK_STAR expression", + /* 281 */ "expression ::= expression NK_SLASH expression", + /* 282 */ "expression ::= expression NK_REM expression", + /* 283 */ "expression_list ::= expression", + /* 284 */ "expression_list ::= expression_list NK_COMMA expression", + /* 285 */ "column_reference ::= column_name", + /* 286 */ "column_reference ::= table_name NK_DOT column_name", + /* 287 */ "pseudo_column ::= NOW", + /* 288 */ "pseudo_column ::= ROWTS", + /* 289 */ "pseudo_column ::= TBNAME", + /* 290 */ "pseudo_column ::= QSTARTTS", + /* 291 */ "pseudo_column ::= QENDTS", + /* 292 */ "pseudo_column ::= WSTARTTS", + /* 293 */ "pseudo_column ::= WENDTS", + /* 294 */ "pseudo_column ::= WDURATION", + /* 295 */ "predicate ::= expression compare_op expression", + /* 296 */ "predicate ::= expression BETWEEN expression AND expression", + /* 297 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 298 */ "predicate ::= expression IS NULL", + /* 299 */ "predicate ::= expression IS NOT NULL", + /* 300 */ "predicate ::= expression in_op in_predicate_value", + /* 301 */ "compare_op ::= NK_LT", + /* 302 */ "compare_op ::= NK_GT", + /* 303 */ "compare_op ::= NK_LE", + /* 304 */ "compare_op ::= NK_GE", + /* 305 */ "compare_op ::= NK_NE", + /* 306 */ "compare_op ::= NK_EQ", + /* 307 */ "compare_op ::= LIKE", + /* 308 */ "compare_op ::= NOT LIKE", + /* 309 */ "compare_op ::= MATCH", + /* 310 */ "compare_op ::= NMATCH", + /* 311 */ "in_op ::= IN", + /* 312 */ "in_op ::= NOT IN", + /* 313 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 314 */ "boolean_value_expression ::= boolean_primary", + /* 315 */ "boolean_value_expression ::= NOT boolean_primary", + /* 316 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 317 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 318 */ "boolean_primary ::= predicate", + /* 319 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 320 */ "common_expression ::= expression", + /* 321 */ "common_expression ::= boolean_value_expression", + /* 322 */ "from_clause ::= FROM table_reference_list", + /* 323 */ "table_reference_list ::= table_reference", + /* 324 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 325 */ "table_reference ::= table_primary", + /* 326 */ "table_reference ::= joined_table", + /* 327 */ "table_primary ::= table_name alias_opt", + /* 328 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 329 */ "table_primary ::= subquery alias_opt", + /* 330 */ "table_primary ::= parenthesized_joined_table", + /* 331 */ "alias_opt ::=", + /* 332 */ "alias_opt ::= table_alias", + /* 333 */ "alias_opt ::= AS table_alias", + /* 334 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 335 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 336 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 337 */ "join_type ::=", + /* 338 */ "join_type ::= INNER", + /* 339 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 340 */ "set_quantifier_opt ::=", + /* 341 */ "set_quantifier_opt ::= DISTINCT", + /* 342 */ "set_quantifier_opt ::= ALL", + /* 343 */ "select_list ::= NK_STAR", + /* 344 */ "select_list ::= select_sublist", + /* 345 */ "select_sublist ::= select_item", + /* 346 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 347 */ "select_item ::= common_expression", + /* 348 */ "select_item ::= common_expression column_alias", + /* 349 */ "select_item ::= common_expression AS column_alias", + /* 350 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 351 */ "where_clause_opt ::=", + /* 352 */ "where_clause_opt ::= WHERE search_condition", + /* 353 */ "partition_by_clause_opt ::=", + /* 354 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 355 */ "twindow_clause_opt ::=", + /* 356 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 357 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 358 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 359 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 360 */ "sliding_opt ::=", + /* 361 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 362 */ "fill_opt ::=", + /* 363 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 364 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 365 */ "fill_mode ::= NONE", + /* 366 */ "fill_mode ::= PREV", + /* 367 */ "fill_mode ::= NULL", + /* 368 */ "fill_mode ::= LINEAR", + /* 369 */ "fill_mode ::= NEXT", + /* 370 */ "group_by_clause_opt ::=", + /* 371 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 372 */ "group_by_list ::= expression", + /* 373 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 374 */ "having_clause_opt ::=", + /* 375 */ "having_clause_opt ::= HAVING search_condition", + /* 376 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 377 */ "query_expression_body ::= query_primary", + /* 378 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 379 */ "query_primary ::= query_specification", + /* 380 */ "order_by_clause_opt ::=", + /* 381 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 382 */ "slimit_clause_opt ::=", + /* 383 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 384 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 385 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 386 */ "limit_clause_opt ::=", + /* 387 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 388 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 389 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 390 */ "subquery ::= NK_LP query_expression NK_RP", + /* 391 */ "search_condition ::= common_expression", + /* 392 */ "sort_specification_list ::= sort_specification", + /* 393 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 394 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 395 */ "ordering_specification_opt ::=", + /* 396 */ "ordering_specification_opt ::= ASC", + /* 397 */ "ordering_specification_opt ::= DESC", + /* 398 */ "null_ordering_opt ::=", + /* 399 */ "null_ordering_opt ::= NULLS FIRST", + /* 400 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1893,15 +1899,18 @@ static YYACTIONTYPE yy_find_shift_action( do{ i = yy_shift_ofst[stateno]; assert( i>=0 ); - /* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */ + assert( i<=YY_ACTTAB_COUNT ); + assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - if( i>=YY_NLOOKAHEAD || yy_lookahead[i]!=iLookAhead ){ + assert( i<(int)YY_NLOOKAHEAD ); + if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead %s\n", @@ -1916,16 +1925,8 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j0 - ){ + assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); + if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1939,6 +1940,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ + assert( i>=0 && iyytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfo[yyruleno].nrhs; + yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno); + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2684,7 +3092,7 @@ static YYACTIONTYPE yy_reduce( case 50: /* exists_opt ::= */ yytestcase(yyruleno==50); case 211: /* analyze_opt ::= */ yytestcase(yyruleno==211); case 219: /* agg_func_opt ::= */ yytestcase(yyruleno==219); - case 339: /* set_quantifier_opt ::= */ yytestcase(yyruleno==339); + case 340: /* set_quantifier_opt ::= */ yytestcase(yyruleno==340); { yymsp[1].minor.yy537 = false; } break; case 49: /* exists_opt ::= IF EXISTS */ @@ -2825,8 +3233,8 @@ static YYACTIONTYPE yy_reduce( case 192: /* func_name_list ::= func_name */ yytestcase(yyruleno==192); case 201: /* func_list ::= func */ yytestcase(yyruleno==201); case 254: /* literal_list ::= signed_literal */ yytestcase(yyruleno==254); - case 344: /* select_sublist ::= select_item */ yytestcase(yyruleno==344); - case 391: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==391); + case 345: /* select_sublist ::= select_item */ yytestcase(yyruleno==345); + case 392: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==392); { yylhsminor.yy376 = createNodeList(pCxt, yymsp[0].minor.yy168); } yymsp[0].minor.yy376 = yylhsminor.yy376; break; @@ -2836,8 +3244,8 @@ static YYACTIONTYPE yy_reduce( case 193: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==193); case 202: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==202); case 255: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==255); - case 345: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==345); - case 392: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==392); + case 346: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==346); + case 393: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==393); { yylhsminor.yy376 = addNodeToList(pCxt, yymsp[-2].minor.yy376, yymsp[0].minor.yy168); } yymsp[-2].minor.yy376 = yylhsminor.yy376; break; @@ -2918,9 +3326,9 @@ static YYACTIONTYPE yy_reduce( break; case 112: /* specific_tags_opt ::= */ case 143: /* tags_def_opt ::= */ yytestcase(yyruleno==143); - case 352: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==352); - case 369: /* group_by_clause_opt ::= */ yytestcase(yyruleno==369); - case 379: /* order_by_clause_opt ::= */ yytestcase(yyruleno==379); + case 353: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==353); + case 370: /* group_by_clause_opt ::= */ yytestcase(yyruleno==370); + case 380: /* order_by_clause_opt ::= */ yytestcase(yyruleno==380); { yymsp[1].minor.yy376 = NULL; } break; case 113: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ @@ -3010,7 +3418,7 @@ static YYACTIONTYPE yy_reduce( { yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 144: /* tags_def_opt ::= tags_def */ - case 343: /* select_list ::= select_sublist */ yytestcase(yyruleno==343); + case 344: /* select_list ::= select_sublist */ yytestcase(yyruleno==344); { yylhsminor.yy376 = yymsp[0].minor.yy376; } yymsp[0].minor.yy376 = yylhsminor.yy376; break; @@ -3148,13 +3556,13 @@ static YYACTIONTYPE yy_reduce( break; case 187: /* like_pattern_opt ::= */ case 198: /* index_options ::= */ yytestcase(yyruleno==198); - case 350: /* where_clause_opt ::= */ yytestcase(yyruleno==350); - case 354: /* twindow_clause_opt ::= */ yytestcase(yyruleno==354); - case 359: /* sliding_opt ::= */ yytestcase(yyruleno==359); - case 361: /* fill_opt ::= */ yytestcase(yyruleno==361); - case 373: /* having_clause_opt ::= */ yytestcase(yyruleno==373); - case 381: /* slimit_clause_opt ::= */ yytestcase(yyruleno==381); - case 385: /* limit_clause_opt ::= */ yytestcase(yyruleno==385); + case 351: /* where_clause_opt ::= */ yytestcase(yyruleno==351); + case 355: /* twindow_clause_opt ::= */ yytestcase(yyruleno==355); + case 360: /* sliding_opt ::= */ yytestcase(yyruleno==360); + case 362: /* fill_opt ::= */ yytestcase(yyruleno==362); + case 374: /* having_clause_opt ::= */ yytestcase(yyruleno==374); + case 382: /* slimit_clause_opt ::= */ yytestcase(yyruleno==382); + case 386: /* limit_clause_opt ::= */ yytestcase(yyruleno==386); { yymsp[1].minor.yy168 = NULL; } break; case 188: /* like_pattern_opt ::= LIKE NK_STRING */ @@ -3211,7 +3619,7 @@ static YYACTIONTYPE yy_reduce( break; case 212: /* analyze_opt ::= ANALYZE */ case 220: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==220); - case 340: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==340); + case 341: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==341); { yymsp[0].minor.yy537 = true; } break; case 213: /* explain_options ::= */ @@ -3292,17 +3700,17 @@ static YYACTIONTYPE yy_reduce( case 268: /* expression ::= literal */ yytestcase(yyruleno==268); case 269: /* expression ::= pseudo_column */ yytestcase(yyruleno==269); case 270: /* expression ::= column_reference */ yytestcase(yyruleno==270); - case 273: /* expression ::= subquery */ yytestcase(yyruleno==273); - case 313: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==313); - case 317: /* boolean_primary ::= predicate */ yytestcase(yyruleno==317); - case 319: /* common_expression ::= expression */ yytestcase(yyruleno==319); - case 320: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==320); - case 322: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==322); - case 324: /* table_reference ::= table_primary */ yytestcase(yyruleno==324); - case 325: /* table_reference ::= joined_table */ yytestcase(yyruleno==325); - case 329: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==329); - case 376: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==376); - case 378: /* query_primary ::= query_specification */ yytestcase(yyruleno==378); + case 274: /* expression ::= subquery */ yytestcase(yyruleno==274); + case 314: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==314); + case 318: /* boolean_primary ::= predicate */ yytestcase(yyruleno==318); + case 320: /* common_expression ::= expression */ yytestcase(yyruleno==320); + case 321: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==321); + case 323: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==323); + case 325: /* table_reference ::= table_primary */ yytestcase(yyruleno==325); + case 326: /* table_reference ::= joined_table */ yytestcase(yyruleno==326); + case 330: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==330); + case 377: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==377); + case 379: /* query_primary ::= query_specification */ yytestcase(yyruleno==379); { yylhsminor.yy168 = yymsp[0].minor.yy168; } yymsp[0].minor.yy168 = yylhsminor.yy168; break; @@ -3356,7 +3764,7 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy168 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 252: /* signed_literal ::= duration_literal */ - case 390: /* search_condition ::= common_expression */ yytestcase(yyruleno==390); + case 391: /* search_condition ::= common_expression */ yytestcase(yyruleno==391); { yylhsminor.yy168 = releaseRawExprNode(pCxt, yymsp[0].minor.yy168); } yymsp[0].minor.yy168 = yylhsminor.yy168; break; @@ -3371,26 +3779,34 @@ static YYACTIONTYPE yy_reduce( { yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy393, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy393, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 274: /* expression ::= NK_LP expression NK_RP */ - case 318: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==318); + case 273: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ +{ + SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168)); + p = addValueNodeFromTypeToList(pCxt, yymsp[-1].minor.yy224, p); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy393, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-5].minor.yy393, p)); + } + yymsp[-5].minor.yy168 = yylhsminor.yy168; + break; + case 275: /* expression ::= NK_LP expression NK_RP */ + case 319: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==319); { yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 275: /* expression ::= NK_PLUS expression */ + case 276: /* expression ::= NK_PLUS expression */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 276: /* expression ::= NK_MINUS expression */ + case 277: /* expression ::= NK_MINUS expression */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 277: /* expression ::= expression NK_PLUS expression */ + case 278: /* expression ::= expression NK_PLUS expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3398,7 +3814,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 278: /* expression ::= expression NK_MINUS expression */ + case 279: /* expression ::= expression NK_MINUS expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3406,7 +3822,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 279: /* expression ::= expression NK_STAR expression */ + case 280: /* expression ::= expression NK_STAR expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3414,7 +3830,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 280: /* expression ::= expression NK_SLASH expression */ + case 281: /* expression ::= expression NK_SLASH expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3422,7 +3838,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 281: /* expression ::= expression NK_REM expression */ + case 282: /* expression ::= expression NK_REM expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3430,35 +3846,35 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 282: /* expression_list ::= expression */ + case 283: /* expression_list ::= expression */ { yylhsminor.yy376 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } yymsp[0].minor.yy376 = yylhsminor.yy376; break; - case 283: /* expression_list ::= expression_list NK_COMMA expression */ + case 284: /* expression_list ::= expression_list NK_COMMA expression */ { yylhsminor.yy376 = addNodeToList(pCxt, yymsp[-2].minor.yy376, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } yymsp[-2].minor.yy376 = yylhsminor.yy376; break; - case 284: /* column_reference ::= column_name */ + case 285: /* column_reference ::= column_name */ { yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy393, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy393)); } yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 285: /* column_reference ::= table_name NK_DOT column_name */ + case 286: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy393, &yymsp[0].minor.yy393, createColumnNode(pCxt, &yymsp[-2].minor.yy393, &yymsp[0].minor.yy393)); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 286: /* pseudo_column ::= NOW */ - case 287: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==287); - case 288: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==288); - case 289: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==289); - case 290: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==290); - case 291: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==291); - case 292: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==292); - case 293: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==293); + case 287: /* pseudo_column ::= NOW */ + case 288: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==288); + case 289: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==289); + case 290: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==290); + case 291: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==291); + case 292: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==292); + case 293: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==293); + case 294: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==294); { yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 294: /* predicate ::= expression compare_op expression */ - case 299: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==299); + case 295: /* predicate ::= expression compare_op expression */ + case 300: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==300); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3466,7 +3882,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 295: /* predicate ::= expression BETWEEN expression AND expression */ + case 296: /* predicate ::= expression BETWEEN expression AND expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3474,7 +3890,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 296: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 297: /* predicate ::= expression NOT BETWEEN expression AND expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3482,68 +3898,68 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy168 = yylhsminor.yy168; break; - case 297: /* predicate ::= expression IS NULL */ + case 298: /* predicate ::= expression IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), NULL)); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 298: /* predicate ::= expression IS NOT NULL */ + case 299: /* predicate ::= expression IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy168); yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL)); } yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 300: /* compare_op ::= NK_LT */ + case 301: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy436 = OP_TYPE_LOWER_THAN; } break; - case 301: /* compare_op ::= NK_GT */ + case 302: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy436 = OP_TYPE_GREATER_THAN; } break; - case 302: /* compare_op ::= NK_LE */ + case 303: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy436 = OP_TYPE_LOWER_EQUAL; } break; - case 303: /* compare_op ::= NK_GE */ + case 304: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy436 = OP_TYPE_GREATER_EQUAL; } break; - case 304: /* compare_op ::= NK_NE */ + case 305: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy436 = OP_TYPE_NOT_EQUAL; } break; - case 305: /* compare_op ::= NK_EQ */ + case 306: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy436 = OP_TYPE_EQUAL; } break; - case 306: /* compare_op ::= LIKE */ + case 307: /* compare_op ::= LIKE */ { yymsp[0].minor.yy436 = OP_TYPE_LIKE; } break; - case 307: /* compare_op ::= NOT LIKE */ + case 308: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy436 = OP_TYPE_NOT_LIKE; } break; - case 308: /* compare_op ::= MATCH */ + case 309: /* compare_op ::= MATCH */ { yymsp[0].minor.yy436 = OP_TYPE_MATCH; } break; - case 309: /* compare_op ::= NMATCH */ + case 310: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy436 = OP_TYPE_NMATCH; } break; - case 310: /* in_op ::= IN */ + case 311: /* in_op ::= IN */ { yymsp[0].minor.yy436 = OP_TYPE_IN; } break; - case 311: /* in_op ::= NOT IN */ + case 312: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy436 = OP_TYPE_NOT_IN; } break; - case 312: /* in_predicate_value ::= NK_LP expression_list NK_RP */ + case 313: /* in_predicate_value ::= NK_LP expression_list NK_RP */ { yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy376)); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 314: /* boolean_value_expression ::= NOT boolean_primary */ + case 315: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 315: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 316: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3551,7 +3967,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 316: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 317: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); @@ -3559,52 +3975,52 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 321: /* from_clause ::= FROM table_reference_list */ - case 351: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==351); - case 374: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==374); + case 322: /* from_clause ::= FROM table_reference_list */ + case 352: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==352); + case 375: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==375); { yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; } break; - case 323: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 324: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 326: /* table_primary ::= table_name alias_opt */ + case 327: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy393, &yymsp[0].minor.yy393); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 327: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 328: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy393, &yymsp[-1].minor.yy393, &yymsp[0].minor.yy393); } yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 328: /* table_primary ::= subquery alias_opt */ + case 329: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy168 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy393); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 330: /* alias_opt ::= */ + case 331: /* alias_opt ::= */ { yymsp[1].minor.yy393 = nil_token; } break; - case 331: /* alias_opt ::= table_alias */ + case 332: /* alias_opt ::= table_alias */ { yylhsminor.yy393 = yymsp[0].minor.yy393; } yymsp[0].minor.yy393 = yylhsminor.yy393; break; - case 332: /* alias_opt ::= AS table_alias */ + case 333: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy393 = yymsp[0].minor.yy393; } break; - case 333: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 334: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==334); + case 334: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 335: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==335); { yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; } break; - case 335: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 336: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy596, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } yymsp[-5].minor.yy168 = yylhsminor.yy168; break; - case 336: /* join_type ::= */ + case 337: /* join_type ::= */ { yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } break; - case 337: /* join_type ::= INNER */ + case 338: /* join_type ::= INNER */ { yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } break; - case 338: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 339: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy537, yymsp[-6].minor.yy376, yymsp[-5].minor.yy168); yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168); @@ -3614,81 +4030,81 @@ static YYACTIONTYPE yy_reduce( yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168); } break; - case 341: /* set_quantifier_opt ::= ALL */ + case 342: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy537 = false; } break; - case 342: /* select_list ::= NK_STAR */ + case 343: /* select_list ::= NK_STAR */ { yymsp[0].minor.yy376 = NULL; } break; - case 346: /* select_item ::= common_expression */ + case 347: /* select_item ::= common_expression */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), &t); } yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 347: /* select_item ::= common_expression column_alias */ + case 348: /* select_item ::= common_expression column_alias */ { yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy393); } yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 348: /* select_item ::= common_expression AS column_alias */ + case 349: /* select_item ::= common_expression AS column_alias */ { yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), &yymsp[0].minor.yy393); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 349: /* select_item ::= table_name NK_DOT NK_STAR */ + case 350: /* select_item ::= table_name NK_DOT NK_STAR */ { yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy393, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 353: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 370: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==370); - case 380: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==380); + case 354: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 371: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==371); + case 381: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==381); { yymsp[-2].minor.yy376 = yymsp[0].minor.yy376; } break; - case 355: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 356: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy168 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } break; - case 356: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + case 357: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ { yymsp[-3].minor.yy168 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } break; - case 357: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 358: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } break; - case 358: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 359: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } break; - case 360: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 361: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ { yymsp[-3].minor.yy168 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy168); } break; - case 362: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 363: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy168 = createFillNode(pCxt, yymsp[-1].minor.yy382, NULL); } break; - case 363: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 364: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy168 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy376)); } break; - case 364: /* fill_mode ::= NONE */ + case 365: /* fill_mode ::= NONE */ { yymsp[0].minor.yy382 = FILL_MODE_NONE; } break; - case 365: /* fill_mode ::= PREV */ + case 366: /* fill_mode ::= PREV */ { yymsp[0].minor.yy382 = FILL_MODE_PREV; } break; - case 366: /* fill_mode ::= NULL */ + case 367: /* fill_mode ::= NULL */ { yymsp[0].minor.yy382 = FILL_MODE_NULL; } break; - case 367: /* fill_mode ::= LINEAR */ + case 368: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy382 = FILL_MODE_LINEAR; } break; - case 368: /* fill_mode ::= NEXT */ + case 369: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy382 = FILL_MODE_NEXT; } break; - case 371: /* group_by_list ::= expression */ + case 372: /* group_by_list ::= expression */ { yylhsminor.yy376 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } yymsp[0].minor.yy376 = yylhsminor.yy376; break; - case 372: /* group_by_list ::= group_by_list NK_COMMA expression */ + case 373: /* group_by_list ::= group_by_list NK_COMMA expression */ { yylhsminor.yy376 = addNodeToList(pCxt, yymsp[-2].minor.yy376, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } yymsp[-2].minor.yy376 = yylhsminor.yy376; break; - case 375: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 376: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy376); yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168); @@ -3696,55 +4112,55 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 377: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + case 378: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ { yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); } yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 382: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 386: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==386); + case 383: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 387: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==387); { yymsp[-1].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 383: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 387: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==387); + case 384: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 388: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==388); { yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 384: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 388: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==388); + case 385: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 389: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==389); { yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 389: /* subquery ::= NK_LP query_expression NK_RP */ + case 390: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy168); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 393: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + case 394: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ { yylhsminor.yy168 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[-1].minor.yy554, yymsp[0].minor.yy81); } yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 394: /* ordering_specification_opt ::= */ + case 395: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy554 = ORDER_ASC; } break; - case 395: /* ordering_specification_opt ::= ASC */ + case 396: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy554 = ORDER_ASC; } break; - case 396: /* ordering_specification_opt ::= DESC */ + case 397: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy554 = ORDER_DESC; } break; - case 397: /* null_ordering_opt ::= */ + case 398: /* null_ordering_opt ::= */ { yymsp[1].minor.yy81 = NULL_ORDER_DEFAULT; } break; - case 398: /* null_ordering_opt ::= NULLS FIRST */ + case 399: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy81 = NULL_ORDER_FIRST; } break; - case 399: /* null_ordering_opt ::= NULLS LAST */ + case 400: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy81 = NULL_ORDER_LAST; } break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyruleno Date: Sun, 10 Apr 2022 22:34:18 +0800 Subject: [PATCH 21/45] fix[cluster]: manage mnode in multi-process mode --- source/dnode/mgmt/main/dndTransport.c | 3 ++- source/dnode/mgmt/mm/mmHandle.c | 2 +- source/dnode/mgmt/mm/mmInt.c | 3 +++ source/dnode/mgmt/test/mnode/dmnode.cpp | 2 +- tests/script/jenkins/basic.txt | 10 ++++++++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/dnode/mgmt/main/dndTransport.c b/source/dnode/mgmt/main/dndTransport.c index b639b79935..bcebd521b6 100644 --- a/source/dnode/mgmt/main/dndTransport.c +++ b/source/dnode/mgmt/main/dndTransport.c @@ -448,7 +448,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, ProcFuncType ftype) { pMsg->pCont = pCont; - dTrace("msg:%p, get from parent queue, ftype:%d handle:%p, app:%p", pMsg, ftype, pMsg->handle, pMsg->ahandle); + dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle, + pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle); switch (ftype) { case PROC_REGIST: diff --git a/source/dnode/mgmt/mm/mmHandle.c b/source/dnode/mgmt/mm/mmHandle.c index eeae9da8b7..6ad0b8c0ed 100644 --- a/source/dnode/mgmt/mm/mmHandle.c +++ b/source/dnode/mgmt/mm/mmHandle.c @@ -96,7 +96,7 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { if (alterReq.dnodeId != pDnode->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; - dError("failed to alter mnode since %s", terrstr()); + dError("failed to alter mnode since %s, dnodeId:%d input:%d", terrstr(), pDnode->dnodeId, alterReq.dnodeId); return -1; } else { return mmAlter(pMgmt, &alterReq); diff --git a/source/dnode/mgmt/mm/mmInt.c b/source/dnode/mgmt/mm/mmInt.c index 64daf09bf9..49886621ec 100644 --- a/source/dnode/mgmt/mm/mmInt.c +++ b/source/dnode/mgmt/mm/mmInt.c @@ -112,6 +112,9 @@ static int32_t mmOpenImp(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq) { if (!deployed) { dInfo("mnode start to deploy"); + if (pMgmt->pWrapper->procType == PROC_CHILD) { + pMgmt->pDnode->dnodeId = 1; + } mmBuildOptionForDeploy(pMgmt, &option); } else { dInfo("mnode start to open"); diff --git a/source/dnode/mgmt/test/mnode/dmnode.cpp b/source/dnode/mgmt/test/mnode/dmnode.cpp index 348eb50c8f..e92e51fa39 100644 --- a/source/dnode/mgmt/test/mnode/dmnode.cpp +++ b/source/dnode/mgmt/test/mnode/dmnode.cpp @@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_REDIRECT); + ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); } { diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2d18167337..761a8921d5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -43,7 +43,7 @@ ./test.sh -f tsim/bnode/basic1.sim # ---- mnode -./test.sh -f tsim/bnode/basic1.sim +./test.sh -f tsim/mnode/basic1.sim # ---- show ./test.sh -f tsim/show/basic.sim @@ -69,7 +69,13 @@ # --- for multi process mode ./test.sh -f tsim/user/basic1.sim -m -./test.sh -f tsim/stable/vnode3.sim -m +./test.sh -f tsim/db/basic3.sim -m +./test.sh -f tsim/insert/backquote.sim +./test.sh -f tsim/parser/fourArithmetic-basic.sim -m +./test.sh -f tsim/query/interval-offset.sim -m ./test.sh -f tsim/tmq/basic.sim -m +./test.sh -f tsim/stable/vnode3.sim -m +./test.sh -f tsim/qnode/basic1.sim -m +./test.sh -f tsim/mnode/basic1.sim -m #======================b1-end=============== From ca5d5ca7bb6f4ee3ebce6d67beab74dfc81e9d0a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 10:44:37 +0800 Subject: [PATCH 22/45] test[query]:update the script. --- source/libs/executor/inc/executorimpl.h | 3 - tests/script/tsim/query/session.sim | 114 ++++++++++++------------ 2 files changed, 57 insertions(+), 60 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index b1f15482a9..9a75830ec4 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -717,9 +717,6 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* #if 0 SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); -SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, - SExprInfo* pExpr, int32_t numOfOutput); - SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index c1d3437e4a..3a57581668 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -98,15 +98,15 @@ if $data01 != 2 then return -1 endi - -print ====> select count(*) from (select * from dev_001) session(ts,5a) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a) -if $rows != 15 then - return -1 -endi -if $data01 != 2 then - return -1 -endi +# +#print ====> select count(*) from (select * from dev_001) session(ts,5a) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a) +#if $rows != 15 then +# return -1 +#endi +#if $data01 != 2 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1s) sql select _wstartts, count(*) from dev_001 session(ts,1s) @@ -117,14 +117,14 @@ if $data01 != 5 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1s) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s) -if $rows != 12 then - return -1 -endi -if $data01 != 5 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1s) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s) +#if $rows != 12 then +# return -1 +#endi +#if $data01 != 5 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1000a) sql select _wstartts, count(*) from dev_001 session(ts,1000a) @@ -135,14 +135,14 @@ if $data01 != 5 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1000a) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a) -if $rows != 12 then - return -1 -endi -if $data01 != 5 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1000a) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a) +#if $rows != 12 then +# return -1 +#endi +#if $data01 != 5 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1m) sql select _wstartts, count(*) from dev_001 session(ts,1m) @@ -153,14 +153,14 @@ if $data01 != 8 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1m) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m) -if $rows != 9 then - return -1 -endi -if $data01 != 8 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1m) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m) +#if $rows != 9 then +# return -1 +#endi +#if $data01 != 8 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1h) sql select _wstartts, count(*) from dev_001 session(ts,1h) @@ -171,14 +171,14 @@ if $data01 != 11 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1h) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h) -if $rows != 6 then - return -1 -endi -if $data01 != 11 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1h) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h) +#if $rows != 6 then +# return -1 +#endi +#if $data01 != 11 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1d) sql select _wstartts, count(*) from dev_001 session(ts,1d) @@ -189,14 +189,14 @@ if $data01 != 13 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1d) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d) -if $rows != 4 then - return -1 -endi -if $data01 != 13 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1d) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d) +#if $rows != 4 then +# return -1 +#endi +#if $data01 != 13 then +# return -1 +#endi print ====> select count(*) from dev_001 session(ts,1w) sql select _wstartts, count(*) from dev_001 session(ts,1w) @@ -207,14 +207,14 @@ if $data01 != 15 then return -1 endi -print ====> select count(*) from (select * from dev_001) session(ts,1w) -sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w) -if $rows != 2 then - return -1 -endi -if $data01 != 15 then - return -1 -endi +#print ====> select count(*) from (select * from dev_001) session(ts,1w) +#sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w) +#if $rows != 2 then +# return -1 +#endi +#if $data01 != 15 then +# return -1 +#endi print ====> leastsquares not supported yet. From 984a508774a155dbfbdfe7703dbd03de34abf280 Mon Sep 17 00:00:00 2001 From: cpwu Date: Mon, 11 Apr 2022 11:51:03 +0800 Subject: [PATCH 23/45] add group by case --- tests/script/tsim/query/complex_group.sim | 278 ++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 tests/script/tsim/query/complex_group.sim diff --git a/tests/script/tsim/query/complex_group.sim b/tests/script/tsim/query/complex_group.sim new file mode 100644 index 0000000000..5372f9bd9b --- /dev/null +++ b/tests/script/tsim/query/complex_group.sim @@ -0,0 +1,278 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 2 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct2 (d) +sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a ) +sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a ) + +print =============== insert data into child table ct3 (n) +sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== + + +print ================ query 1 group by filter +sql select count(*) from ct3 group by c1 +print ====> sql : select count(*) from ct3 group by c1 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c2 +print ====> sql : select count(*) from ct3 group by c2 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c3 +print ====> sql : select count(*) from ct3 group by c3 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c4 +print ====> sql : select count(*) from ct3 group by c4 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c5 +print ====> sql : select count(*) from ct3 group by c5 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c6 +print ====> sql : select count(*) from ct3 group by c6 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c7 +print ====> sql : select count(*) from ct3 group by c7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select count(*) from ct3 group by c8 +print ====> sql : select count(*) from ct3 group by c8 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c9 +print ====> sql : select count(*) from ct3 group by c9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c10 +print ====> sql : select count(*) from ct3 group by c10 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +#================================================= +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +print ================ query 1 group by filter +sql select count(*) from ct3 group by c1 +print ====> sql : select count(*) from ct3 group by c1 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c2 +print ====> sql : select count(*) from ct3 group by c2 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c3 +print ====> sql : select count(*) from ct3 group by c3 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c4 +print ====> sql : select count(*) from ct3 group by c4 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c5 +print ====> sql : select count(*) from ct3 group by c5 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c6 +print ====> sql : select count(*) from ct3 group by c6 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c7 +print ====> sql : select count(*) from ct3 group by c7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select count(*) from ct3 group by c8 +print ====> sql : select count(*) from ct3 group by c8 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c9 +print ====> sql : select count(*) from ct3 group by c9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select count(*) from ct3 group by c10 +print ====> sql : select count(*) from ct3 group by c10 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From f17bead78e1e83624a22ab9e73f81ff153573f1a Mon Sep 17 00:00:00 2001 From: cpwu Date: Mon, 11 Apr 2022 12:48:09 +0800 Subject: [PATCH 24/45] add complex case --- tests/script/tsim/query/complex_group.sim | 198 +++++++ tests/script/tsim/query/complex_limit.sim | 535 +++++++++++++++++ tests/script/tsim/query/complex_where.sim | 691 ++++++++++++++++++++++ 3 files changed, 1424 insertions(+) create mode 100644 tests/script/tsim/query/complex_limit.sim create mode 100644 tests/script/tsim/query/complex_where.sim diff --git a/tests/script/tsim/query/complex_group.sim b/tests/script/tsim/query/complex_group.sim index 5372f9bd9b..3a1ec523fe 100644 --- a/tests/script/tsim/query/complex_group.sim +++ b/tests/script/tsim/query/complex_group.sim @@ -164,6 +164,105 @@ if $rows != 8 then return -1 endi +print ================ query 2 complex with group by +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + print =================== count all rows sql select count(c1) from stb1 @@ -275,4 +374,103 @@ if $rows != 8 then return -1 endi +print ================ query 2 complex with group by +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + #system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/complex_limit.sim b/tests/script/tsim/query/complex_limit.sim new file mode 100644 index 0000000000..ac25135685 --- /dev/null +++ b/tests/script/tsim/query/complex_limit.sim @@ -0,0 +1,535 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 2 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct2 (d) +sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a ) +sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a ) + +print =============== insert data into child table ct3 (n) +sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== +print ================ query 1 limit/offset +sql select * from ct1 limit 1 +print ====> sql : select * from ct1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi + +sql select * from ct1 limit 9 +print ====> sql : select * from ct1 limit 9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct1 limit 1 offset 2 +print ====> sql : select * from ct1 limit 1 offset 2 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql select * from ct1 limit 2 offset 1 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from ct1 limit 2 offset 7 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select * from ct1 limit 2 offset 10 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + +sql select c1 from stb1 limit 1 +print ====> sql : select c1 from stb1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 50 +print ====> sql : select c1 from stb1 limit 50 +print ====> rows: $rows +if $rows != 33 then + return -1 +endi + +sql select c1 from stb1 limit 1 offset 2 +print ====> sql : select c1 from stb1 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 1 +print ====> sql : select c1 from stb1 limit 2 offset 1 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 32 +print ====> sql : select c1 from stb1 limit 2 offset 32 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 40 +print ====> sql : select c1 from stb1 limit 2 offset 40 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + + +print ================ query 2 complex with limit +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +#================================================= +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +print ================ query 1 limit/offset +sql select * from ct1 limit 1 +print ====> sql : select * from ct1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi + +sql select * from ct1 limit 9 +print ====> sql : select * from ct1 limit 9 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct1 limit 1 offset 2 +print ====> sql : select * from ct1 limit 1 offset 2 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi + +sql select * from ct1 limit 2 offset 1 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi +if $data01 != 8 then + return -1 +endi + +sql select * from ct1 limit 2 offset 7 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data11 != 3 then + return -1 +endi + +sql select * from ct1 limit 2 offset 10 +print ====> sql : select * from ct1 limit 2 offset 7 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + +sql select c1 from stb1 limit 1 +print ====> sql : select c1 from stb1 limit 1 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 50 +print ====> sql : select c1 from stb1 limit 50 +print ====> rows: $rows +if $rows != 33 then + return -1 +endi + +sql select c1 from stb1 limit 1 offset 2 +print ====> sql : select c1 from stb1 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 1 +print ====> sql : select c1 from stb1 limit 2 offset 1 +print ====> rows: $rows +if $rows != 2 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 32 +print ====> sql : select c1 from stb1 limit 2 offset 32 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select c1 from stb1 limit 2 offset 40 +print ====> sql : select c1 from stb1 limit 2 offset 40 +print ====> rows: $rows +if $rows != 0 then + return -1 +endi + + +print ================ query 2 complex with limit +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/tsim/query/complex_where.sim b/tests/script/tsim/query/complex_where.sim new file mode 100644 index 0000000000..7a5de85a3c --- /dev/null +++ b/tests/script/tsim/query/complex_where.sim @@ -0,0 +1,691 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +print =============== create database +sql create database db +sql show databases +if $rows != 2 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 +if $rows != 1 then + return -1 +endi + +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct2 (d) +sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a ) +sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a ) + +print =============== insert data into child table ct3 (n) +sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== +print ================ query 1 where condition +sql select * from ct3 where c1 < 5 +print ====> sql : select * from ct3 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 > 5 and c1 <= 6 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 8 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> sql : select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from ct3 where ts != 0 +sql select * from ct3 where ts <> 0 +print ====> sql : select * from ct3 where ts <> 0 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c1 between 1 and 3 +print ====> sql : select * from ct3 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql_error select * from ct3 where c7 between false and true + +sql select * from ct3 where c1 in (1,2,3) +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql select * from ct3 where c1 in (‘true','false') +print ====> sql : select * from ct3 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c9 like "_char_" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c8 like "bi%" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select c1 from stb1 where c1 < 5 +print ====> sql : select c1 from stb1 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 16 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where stb1 > 5 and c1 <= 6 +print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : sselect c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 32 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> sql : select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 17 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from stb1 where ts != 0 +sql select c1 from stb1 where ts <> 0 +print ====> sql : select c1 from stb1 where ts <> 0 +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c1 between 1 and 3 +print ====> sql : select c1 from stb1 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql_error select c1 from stb1 where c7 between false and true + +sql select c1 from stb1 where c1 in (1,2,3) +print ====> sql : select c1 from stb1 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql select c1 from stb1 where c1 in (‘true','false') +print ====> sql : select c1 from stb1 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c9 like "_char_" +print ====> sql : select c1 from stb1 where c9 like "_char_" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c8 like "bi%" +print ====> sql : select c1 from stb1 where c8 like "bi%" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + + +print ================ query 2 complex with where +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +#================================================= +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =================== count all rows +sql select count(c1) from stb1 +print ====> sql : select count(c1) from stb1 +print ====> rows: $data00 +if $data00 != 33 then + return -1 +endi + +print ================ query 1 where condition +sql select * from ct3 where c1 < 5 +print ====> sql : select * from ct3 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 > 5 and c1 <= 6 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 1 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 8 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> sql : select * from ct3 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09 +if $rows != 4 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from ct3 where ts != 0 +sql select * from ct3 where ts <> 0 +print ====> sql : select * from ct3 where ts <> 0 +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c1 between 1 and 3 +print ====> sql : select * from ct3 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql_error select * from ct3 where c7 between false and true + +sql select * from ct3 where c1 in (1,2,3) +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 3 then + return -1 +endi + +sql select * from ct3 where c1 in (‘true','false') +print ====> sql : select * from ct3 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c9 like "_char_" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select * from ct3 where c8 like "bi%" +print ====> sql : select * from ct3 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 8 then + return -1 +endi + +sql select c1 from stb1 where c1 < 5 +print ====> sql : select c1 from stb1 where c1 < 5 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 16 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where stb1 > 5 and c1 <= 6 +print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 4 then + return -1 +endi +if $data01 != 6 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> sql : sselect c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2 +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 32 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> sql : select c1 from stb1 where c1 >= 5 and c1 is not NULL +print ====> rows: $rows +print ====> rows0: $data00 +if $rows != 17 then + return -1 +endi +if $data01 != 5 then + return -1 +endi + +sql_error select ts from stb1 where ts != 0 +sql select c1 from stb1 where ts <> 0 +print ====> sql : select c1 from stb1 where ts <> 0 +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c1 between 1 and 3 +print ====> sql : select c1 from stb1 where c1 between 1 and 3 +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql_error select c1 from stb1 where c7 between false and true + +sql select c1 from stb1 where c1 in (1,2,3) +print ====> sql : select c1 from stb1 where c1 in (1,2,3) +print ====> rows: $rows +if $rows != 12 then + return -1 +endi + +sql select c1 from stb1 where c1 in (‘true','false') +print ====> sql : select c1 from stb1 where c1 in (‘true','false') +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c9 like "_char_" +print ====> sql : select c1 from stb1 where c9 like "_char_" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + +sql select c1 from stb1 where c8 like "bi%" +print ====> sql : select c1 from stb1 where c8 like "bi%" +print ====> rows: $rows +if $rows != 32 then + return -1 +endi + + +print ================ query 2 complex with where +sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1 +print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2 +print ====> rows: $rows +if $rows != 1 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 9a543fb331eb5babe931c458ca2ef45fe7f47c1b Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Apr 2022 14:09:47 +0800 Subject: [PATCH 25/45] feat:fix error in result row --- source/libs/executor/src/executorimpl.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index c57079cf4b..947e705c39 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -302,10 +302,6 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) { } taosArrayPush(pBlock->pDataBlock, &idata); - - if (IS_VAR_DATA_TYPE(idata.info.type)) { - pBlock->info.hasVarCol = true; - } } return pBlock; @@ -365,7 +361,7 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, jmp_buf env) pResultRowInfo->pPosition = taosMemoryRealloc(pResultRowInfo->pPosition, newCapacity * sizeof(SResultRowPosition)); int32_t inc = (int32_t)newCapacity - pResultRowInfo->capacity; - memset(&pResultRowInfo->pPosition[pResultRowInfo->capacity], 0, sizeof(SResultRowPosition)); + memset(&pResultRowInfo->pPosition[pResultRowInfo->capacity], 0, sizeof(SResultRowPosition) * inc); pResultRowInfo->capacity = (int32_t)newCapacity; } @@ -500,7 +496,7 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, pData = getBufPage(pResultBuf, getPageId(pi)); pageId = getPageId(pi); - if (pData->num + interBufSize + sizeof(SResultRow) > getBufPageSize(pResultBuf)) { + if (pData->num + interBufSize > getBufPageSize(pResultBuf)) { // release current page first, and prepare the next one releaseBufPageInfo(pResultBuf, pi); @@ -520,7 +516,7 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, pResultRow->pageId = pageId; pResultRow->offset = (int32_t)pData->num; - pData->num += interBufSize + sizeof(SResultRow); + pData->num += interBufSize; return pResultRow; } @@ -588,7 +584,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; - taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, POINTER_BYTES); + taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, sizeof(SResultRowPosition)); SResultRowCell cell = {.groupId = tableGroupId, .pos = pos}; taosArrayPush(pSup->pResultRowArrayList, &cell); } else { From 6f12bc1093f24e49ca0662451845c23fc81fab1f Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 11 Apr 2022 14:15:09 +0800 Subject: [PATCH 26/45] feature/qnode --- include/libs/command/command.h | 2 +- source/client/inc/clientInt.h | 8 +++---- source/client/src/clientEnv.c | 6 ++--- source/client/src/clientHb.c | 16 ++++--------- source/client/src/clientImpl.c | 6 ++--- source/libs/command/inc/commandInt.h | 14 +++++++---- source/libs/command/src/explain.c | 30 +++++++++++++++++++++--- source/libs/parser/src/parAstCreater.c | 9 ++++--- tests/script/general/explain/explain.sim | 2 +- 9 files changed, 60 insertions(+), 33 deletions(-) diff --git a/include/libs/command/command.h b/include/libs/command/command.h index fa229d7265..0cd566ee46 100644 --- a/include/libs/command/command.h +++ b/include/libs/command/command.h @@ -22,7 +22,7 @@ typedef struct SExplainCtx SExplainCtx; int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp); int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp); -int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int32_t startTs); +int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs); int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp); int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp); void qExplainFreeCtx(SExplainCtx *pCtx); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index ae1b34a3bd..96d7cead68 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -84,10 +84,10 @@ typedef struct { } SClientHbMgr; typedef struct SQueryExecMetric { - int64_t start; // start timestamp - int64_t parsed; // start to parse - int64_t send; // start to send to server - int64_t rsp; // receive response from server + int64_t start; // start timestamp, us + int64_t parsed; // start to parse, us + int64_t send; // start to send to server, us + int64_t rsp; // receive response from server, us } SQueryExecMetric; typedef struct SInstanceSummary { diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 769870ada8..359649884f 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -65,10 +65,10 @@ static void deregisterRequest(SRequestObj *pRequest) { int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); - int64_t duration = taosGetTimestampMs() - pRequest->metric.start; + int64_t duration = taosGetTimestampUs() - pRequest->metric.start; tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64 " ms, current:%d, app current:%d", - pRequest->self, pTscObj->id, pRequest->requestId, duration, num, currentInst); + pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst); taosReleaseRef(clientConnRefPool, pTscObj->id); } @@ -151,7 +151,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty pRequest->pDb = getDbOfConnection(pObj); pRequest->requestId = generateRequestId(); - pRequest->metric.start = taosGetTimestampMs(); + pRequest->metric.start = taosGetTimestampUs(); pRequest->type = type; pRequest->pTscObj = pObj; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index abb6e7fbd1..d389fc34c6 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -435,11 +435,11 @@ static int32_t hbCreateThread() { taosThreadAttrInit(&thAttr); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); -// if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) { -// terrno = TAOS_SYSTEM_ERROR(errno); -// return -1; -// } -// taosThreadAttrDestroy(&thAttr); + if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + taosThreadAttrDestroy(&thAttr); return 0; } @@ -500,8 +500,6 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { } void appHbMgrCleanup(void) { - taosThreadMutexLock(&clientHbMgr.lock); - int sz = taosArrayGetSize(clientHbMgr.appHbMgrs); for (int i = 0; i < sz; i++) { SAppHbMgr *pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, i); @@ -510,8 +508,6 @@ void appHbMgrCleanup(void) { taosHashCleanup(pTarget->connInfo); pTarget->connInfo = NULL; } - - taosThreadMutexUnlock(&clientHbMgr.lock); } int hbMgrInit() { @@ -532,7 +528,6 @@ int hbMgrInit() { } void hbMgrCleanUp() { -#if 0 hbStopThread(); // destroy all appHbMgr @@ -545,7 +540,6 @@ void hbMgrCleanUp() { taosThreadMutexUnlock(&clientHbMgr.lock); clientHbMgr.appHbMgrs = NULL; -#endif } int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *info) { diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 9938a2e1b9..b311060ea9 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -520,7 +520,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId); assert(pRequest->self == pSendInfo->requestObjRefId); - pRequest->metric.rsp = taosGetTimestampMs(); + pRequest->metric.rsp = taosGetTimestampUs(); STscObj* pTscObj = pRequest->pTscObj; if (pEpSet) { @@ -536,10 +536,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start; if (pMsg->code == TSDB_CODE_SUCCESS) { tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self, - TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed, pRequest->requestId); + TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed/1000, pRequest->requestId); } else { tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self, - TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed, pRequest->requestId); + TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed/1000, pRequest->requestId); } taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId); diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h index 23e4f2b24f..452804ac91 100644 --- a/source/libs/command/inc/commandInt.h +++ b/source/libs/command/inc/commandInt.h @@ -44,6 +44,9 @@ extern "C" { #define EXPLAIN_OUTPUT_FORMAT "Output: " #define EXPLAIN_TIME_WINDOWS_FORMAT "Time Window: interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c" #define EXPLAIN_WINDOW_FORMAT "Window: gap=%" PRId64 +#define EXPLAIN_RATIO_TIME_FORMAT "Ratio: %f" +#define EXPLAIN_PLANNING_TIME_FORMAT "Planning Time: %.3f ms" +#define EXPLAIN_EXEC_TIME_FORMAT "Execution Time: %.3f ms" //append area #define EXPLAIN_LEFT_PARENTHESIS_FORMAT " (" @@ -108,16 +111,19 @@ typedef struct SExplainCtx { #define EXPLAIN_ROW_NEW(level, ...) \ do { \ if (isVerboseLine) { \ - tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, "%*s", (level) * 2 + 3, ""); \ } else { \ - tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, "%*s%s", (level) * 2, "", "-> "); \ } \ - tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \ + tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE - tlen, __VA_ARGS__); \ } while (0) -#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__) +#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE - tlen, __VA_ARGS__) #define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0) +#define EXPLAIN_SUM_ROW_NEW(...) tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, __VA_ARGS__) +#define EXPLAIN_SUM_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; } while (0) + #ifdef __cplusplus } #endif diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 155da8de49..7a6264709f 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -894,9 +894,33 @@ _return: QRY_RET(code); } +int32_t qExplainAppendPlanRows(SExplainCtx *pCtx) { + if (EXPLAIN_MODE_ANALYZE != pCtx->mode) { + return TSDB_CODE_SUCCESS; + } + + int32_t tlen = 0; + char *tbuf = pCtx->tbuf; + + EXPLAIN_SUM_ROW_NEW(EXPLAIN_RATIO_TIME_FORMAT, pCtx->ratio); + EXPLAIN_SUM_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0)); + + EXPLAIN_SUM_ROW_NEW(EXPLAIN_PLANNING_TIME_FORMAT, (double)(pCtx->jobStartTs - pCtx->reqStartTs) / 1000.0); + EXPLAIN_SUM_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0)); + + EXPLAIN_SUM_ROW_NEW(EXPLAIN_EXEC_TIME_FORMAT, (double)(pCtx->jobDoneTs - pCtx->jobStartTs) / 1000.0); + EXPLAIN_SUM_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0)); + + return TSDB_CODE_SUCCESS; +} int32_t qExplainGenerateRsp(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) { QRY_ERR_RET(qExplainAppendGroupResRows(pCtx, pCtx->rootGroupId, 0)); + + QRY_ERR_RET(qExplainAppendPlanRows(pCtx)); QRY_ERR_RET(qExplainGetRspFromCtx(pCtx, pRsp)); @@ -977,18 +1001,18 @@ _return: QRY_RET(code); } -int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int32_t startTs) { +int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs) { QRY_ERR_RET(qExplainPrepareCtx(pDag, pCtx)); (*pCtx)->reqStartTs = startTs; - (*pCtx)->jobStartTs = taosGetTimestampMs(); + (*pCtx)->jobStartTs = taosGetTimestampUs(); return TSDB_CODE_SUCCESS; } int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) { int32_t code = 0; - pCtx->jobDoneTs = taosGetTimestampMs(); + pCtx->jobDoneTs = taosGetTimestampUs(); atomic_store_8((int8_t *)&pCtx->execDone, true); diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4908748f0d..cf05d87d4d 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -207,7 +207,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { CHECK_RAW_EXPR_NODE(pNode); SRawExprNode* pRawExpr = (SRawExprNode*)pNode; SNode* pExpr = pRawExpr->pNode; - strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n); + if (nodesIsExprNode(pExpr)) { + strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n); + } taosMemoryFreeClear(pNode); return pExpr; } @@ -498,8 +500,9 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p if (NULL == pNode || !pCxt->valid) { return pNode; } - uint32_t maxLen = sizeof(((SExprNode*)pNode)->aliasName); - strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, pAlias->n > maxLen ? maxLen : pAlias->n); + int32_t len = TMIN(sizeof(((SExprNode*)pNode)->aliasName) - 1, pAlias->n); + strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, len); + ((SExprNode*)pNode)->aliasName[len] = '\0'; return pNode; } diff --git a/tests/script/general/explain/explain.sim b/tests/script/general/explain/explain.sim index 666e4040b7..3358b24e83 100644 --- a/tests/script/general/explain/explain.sim +++ b/tests/script/general/explain/explain.sim @@ -99,4 +99,4 @@ sql explain analyze verbose true select * from (select min(f1),count(*) a from s #sql explain analyze verbose true select sum(a+b) from (select _rowts, min(f1) b,count(*) a from st1 where f1 > 0 interval(1a)) where a < 0 interval(1s); -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT From cd75d1121a44edd21de121267ec41c3073294f68 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 11 Apr 2022 14:48:07 +0800 Subject: [PATCH 27/45] constant calc bugfix --- source/libs/function/src/builtins.c | 94 +++++++++++++-------------- source/libs/parser/src/parCalcConst.c | 3 +- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index aa7343f610..7acb0e5463 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -19,14 +19,14 @@ #include "taoserror.h" #include "tdatablock.h" -int32_t stubCheckAndGetResultType(SFunctionNode* pFunc); +int32_t checkAndGetResultType(SFunctionNode* pFunc); const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "count", .type = FUNCTION_TYPE_COUNT, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getCountFuncEnv, .initFunc = functionSetup, .processFunc = countFunction, @@ -36,7 +36,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sum", .type = FUNCTION_TYPE_SUM, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getSumFuncEnv, .initFunc = functionSetup, .processFunc = sumFunction, @@ -46,7 +46,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "min", .type = FUNCTION_TYPE_MIN, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minFunctionSetup, .processFunc = minFunction, @@ -56,7 +56,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "max", .type = FUNCTION_TYPE_MAX, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -66,7 +66,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "stddev", .type = FUNCTION_TYPE_STDDEV, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getStddevFuncEnv, .initFunc = stddevFunctionSetup, .processFunc = stddevFunction, @@ -76,7 +76,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "percentile", .type = FUNCTION_TYPE_PERCENTILE, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getPercentileFuncEnv, .initFunc = percentileFunctionSetup, .processFunc = percentileFunction, @@ -86,7 +86,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "apercentile", .type = FUNCTION_TYPE_APERCENTILE, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -96,7 +96,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "top", .type = FUNCTION_TYPE_TOP, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -106,7 +106,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "bottom", .type = FUNCTION_TYPE_BOTTOM, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -116,7 +116,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "spread", .type = FUNCTION_TYPE_SPREAD, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -126,7 +126,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getMinmaxFuncEnv, .initFunc = maxFunctionSetup, .processFunc = maxFunction, @@ -136,7 +136,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "first", .type = FUNCTION_TYPE_FIRST, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, .processFunc = firstFunction, @@ -146,7 +146,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "last", .type = FUNCTION_TYPE_LAST, .classification = FUNC_MGT_AGG_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getFirstLastFuncEnv, .initFunc = functionSetup, .processFunc = lastFunction, @@ -156,7 +156,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "diff", .type = FUNCTION_TYPE_DIFF, .classification = FUNC_MGT_NONSTANDARD_SQL_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getDiffFuncEnv, .initFunc = diffFunctionSetup, .processFunc = diffFunction, @@ -166,7 +166,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "abs", .type = FUNCTION_TYPE_ABS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = absFunction, @@ -176,7 +176,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "log", .type = FUNCTION_TYPE_LOG, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = logFunction, @@ -186,7 +186,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "pow", .type = FUNCTION_TYPE_POW, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = powFunction, @@ -196,7 +196,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sqrt", .type = FUNCTION_TYPE_SQRT, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = sqrtFunction, @@ -206,7 +206,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "ceil", .type = FUNCTION_TYPE_CEIL, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = ceilFunction, @@ -216,7 +216,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "floor", .type = FUNCTION_TYPE_FLOOR, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = floorFunction, @@ -226,7 +226,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "round", .type = FUNCTION_TYPE_ROUND, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = roundFunction, @@ -236,7 +236,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "sin", .type = FUNCTION_TYPE_SIN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = sinFunction, @@ -246,7 +246,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "cos", .type = FUNCTION_TYPE_COS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = cosFunction, @@ -256,7 +256,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "tan", .type = FUNCTION_TYPE_TAN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = tanFunction, @@ -266,7 +266,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "asin", .type = FUNCTION_TYPE_ASIN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = asinFunction, @@ -276,7 +276,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "acos", .type = FUNCTION_TYPE_ACOS, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = acosFunction, @@ -286,7 +286,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "atan", .type = FUNCTION_TYPE_ATAN, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = atanFunction, @@ -296,7 +296,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "length", .type = FUNCTION_TYPE_LENGTH, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = lengthFunction, @@ -306,7 +306,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "char_length", .type = FUNCTION_TYPE_CHAR_LENGTH, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = charLengthFunction, @@ -316,7 +316,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "concat", .type = FUNCTION_TYPE_CONCAT, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = concatFunction, @@ -326,7 +326,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "concat_ws", .type = FUNCTION_TYPE_CONCAT_WS, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = concatWsFunction, @@ -336,7 +336,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "lower", .type = FUNCTION_TYPE_LOWER, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = lowerFunction, @@ -346,7 +346,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "upper", .type = FUNCTION_TYPE_UPPER, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = upperFunction, @@ -356,7 +356,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "ltrim", .type = FUNCTION_TYPE_LTRIM, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = ltrimFunction, @@ -366,7 +366,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "rtrim", .type = FUNCTION_TYPE_RTRIM, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = rtrimFunction, @@ -376,7 +376,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "substr", .type = FUNCTION_TYPE_SUBSTR, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = substrFunction, @@ -386,7 +386,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "cast", .type = FUNCTION_TYPE_CAST, .classification = FUNC_MGT_SCALAR_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = NULL, @@ -396,7 +396,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_rowts", .type = FUNCTION_TYPE_ROWTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = NULL, @@ -406,7 +406,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "tbname", .type = FUNCTION_TYPE_TBNAME, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = NULL, .initFunc = NULL, .sprocessFunc = NULL, @@ -416,7 +416,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_qstartts", .type = FUNCTION_TYPE_QSTARTTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = qStartTsFunction, @@ -426,7 +426,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_qendts", .type = FUNCTION_TYPE_QENDTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = qEndTsFunction, @@ -436,7 +436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wstartts", .type = FUNCTION_TYPE_WSTARTTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winStartTsFunction, @@ -446,7 +446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wendts", .type = FUNCTION_TYPE_QENDTS, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winEndTsFunction, @@ -456,7 +456,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "_wduration", .type = FUNCTION_TYPE_WDURATION, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winDurFunction, @@ -466,7 +466,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "now", .type = FUNCTION_TYPE_NOW, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .checkFunc = stubCheckAndGetResultType, + .checkFunc = checkAndGetResultType, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, .sprocessFunc = winDurFunction, @@ -476,7 +476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition)); -int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { +int32_t checkAndGetResultType(SFunctionNode* pFunc) { switch(pFunc->funcType) { case FUNCTION_TYPE_WDURATION: case FUNCTION_TYPE_COUNT: { diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 048830b80b..c31ec92bde 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -45,7 +45,7 @@ static EDealRes calcConstOperator(SOperatorNode** pNode, void* pContext) { static EDealRes calcConstFunction(SFunctionNode** pNode, void* pContext) { SFunctionNode* pFunc = *pNode; - if (fmIsPseudoColumnFunc(pFunc->funcId)) { + if (!fmIsScalarFunc(pFunc->funcId)) { return DEAL_RES_CONTINUE; } SNode* pParam = NULL; @@ -61,6 +61,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext) SLogicConditionNode* pCond = *pNode; SNode* pParam = NULL; FOREACH(pParam, pCond->pParameterList) { + // todo calc "true and c1 > 10" if (QUERY_NODE_VALUE != nodeType(pParam)) { return DEAL_RES_CONTINUE; } From b223010bdd69e917c0dd5db9f0c14305a2fb1dc4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 14:54:16 +0800 Subject: [PATCH 28/45] fix[query]:fix memory invalid write in group by nchar data. --- source/libs/executor/inc/executorimpl.h | 2 +- source/libs/executor/src/executorimpl.c | 45 ++++++++++++++---------- source/libs/executor/src/groupoperator.c | 17 ++++++--- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 9a75830ec4..f6f863c82d 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -671,7 +671,7 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); void operatorDummyCloseFn(void* param, int32_t numOfCols); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, - int32_t numOfRows, SSDataBlock* pResultBlock, const char* pkey); + int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey); void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset); void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset); void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 1bc84f85d7..1c9ca87563 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1687,12 +1687,13 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) { if (IS_VAR_DATA_TYPE(type)) { - if (pResultRow->key == NULL) { - pResultRow->key = taosMemoryMalloc(varDataTLen(pData)); - varDataCopy(pResultRow->key, pData); - } else { - assert(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0); - } + // todo disable this +// if (pResultRow->key == NULL) { +// pResultRow->key = taosMemoryMalloc(varDataTLen(pData)); +// varDataCopy(pResultRow->key, pData); +// } else { +// ASSERT(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0); +// } } else { int64_t v = -1; GET_TYPED_DATA(v, int64_t, type, pData); @@ -4467,7 +4468,7 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) { return pResBlock; } -static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, const char* pKey); +static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey); static void cleanupAggSup(SAggSupporter* pAggSup); static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) { @@ -4826,7 +4827,8 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t goto _error; } - int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, num, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, num, keyBufSize, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -5890,11 +5892,11 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { taosMemoryFreeClear(pOperator); } -int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, const char* pKey) { +int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, const char* pKey) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); - pAggSup->keyBuf = taosMemoryCalloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); + pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); @@ -5921,12 +5923,12 @@ static void cleanupAggSup(SAggSupporter* pAggSup) { } int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, - int32_t numOfRows, SSDataBlock* pResultBlock, const char* pkey) { + int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey) { pBasicInfo->pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pBasicInfo->rowCellInfoOffset); pBasicInfo->pRes = pResultBlock; pBasicInfo->capacity = numOfRows; - doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, pkey); + doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, keyBufSize, pkey); return TSDB_CODE_SUCCESS; } @@ -5965,7 +5967,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); int32_t numOfRows = 1; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, keyBufSize, pTaskInfo->id.str); pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { goto _error; @@ -6081,8 +6084,9 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); int32_t numOfRows = 1; + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; int32_t code = - initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); + initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str); pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { goto _error; @@ -6142,7 +6146,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p int32_t numOfCols = num; int32_t numOfRows = 4096; - initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str); setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo); pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pInfo->binfo.pCtx, numOfCols); @@ -6190,7 +6195,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pInfo->primaryTsIndex = primaryTsSlot; int32_t numOfRows = 4096; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str); initExecTimeWindowInfo(&pInfo->timeWindowData, &pInfo->win); // pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); @@ -6266,8 +6272,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf } pInfo->colIndex = -1; - - initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExpr, numOfCols, 4096, pResBlock, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExpr, numOfCols, 4096, pResBlock, keyBufSize, pTaskInfo->id.str); initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); pOperator->name = "StateWindowOperator"; @@ -6299,7 +6305,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo } int32_t numOfRows = 4096; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, keyBufSize, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 3eb8ff1b72..9410d1384d 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -46,7 +46,7 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** int32_t numOfGroupCols = taosArrayGetSize(pGroupColList); for (int32_t i = 0; i < numOfGroupCols; ++i) { SColumn* pCol = taosArrayGet(pGroupColList, i); - (*keyLen) += pCol->bytes; + (*keyLen) += pCol->bytes; // actual data + null_flag SGroupKeys key = {0}; key.bytes = pCol->bytes; @@ -61,8 +61,9 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** } int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols; + (*keyLen) += nullFlagSize; - (*keyBuf) = taosMemoryCalloc(1, (*keyLen) + nullFlagSize); + (*keyBuf) = taosMemoryCalloc(1, (*keyLen)); if ((*keyBuf) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -169,11 +170,16 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[i]); SColumnInfoData* pColInfoData = pCtx[i].input.pData[0]; + // todo OPT all/all not NULL if (!colDataIsNull(pColInfoData, totalRows, rowIndex, NULL)) { char* dest = GET_ROWCELL_INTERBUF(pEntryInfo); char* data = colDataGetData(pColInfoData, rowIndex); - memcpy(dest, data, pColInfoData->info.bytes); + if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { + varDataCopy(dest, data); + } else { + memcpy(dest, data, pColInfoData->info.bytes); + } } else { // it is a NULL value pEntryInfo->isNullRes = 1; } @@ -326,14 +332,15 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pInfo->pGroupCols = pGroupColList; pInfo->pCondition = pCondition; - initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, 4096, pResultBlock, pTaskInfo->id.str); - initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList); if (code != TSDB_CODE_SUCCESS) { goto _error; } + initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, 4096, pResultBlock, pInfo->groupKeyLen, pTaskInfo->id.str); + initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); + pOperator->name = "GroupbyAggOperator"; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; From 86a39034d3209ee4dbb7638f4135d9547572e0d6 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 11 Apr 2022 15:13:53 +0800 Subject: [PATCH 29/45] add explain case --- tests/script/{general/explain => tsim/query}/explain.sim | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/script/{general/explain => tsim/query}/explain.sim (100%) diff --git a/tests/script/general/explain/explain.sim b/tests/script/tsim/query/explain.sim similarity index 100% rename from tests/script/general/explain/explain.sim rename to tests/script/tsim/query/explain.sim From e158dbeed99f6c0685d71092b943488c17f095c8 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 11 Apr 2022 15:21:55 +0800 Subject: [PATCH 30/45] add case to CI --- tests/script/jenkins/basic.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 2d18167337..d3ae58a524 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -32,6 +32,7 @@ ./test.sh -f tsim/query/interval-offset.sim ./test.sh -f tsim/query/scalarFunction.sim ./test.sh -f tsim/query/charScalarFunction.sim +./test.sh -f tsim/query/explain.sim # ---- qnode ./test.sh -f tsim/qnode/basic1.sim From 6b681d79d4de328f3b4d110e39433a2aec5f5df4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 15:25:19 +0800 Subject: [PATCH 31/45] fix[query]:enable sum function to be applied to bool data type. --- source/libs/function/src/builtins.c | 2 +- source/libs/function/src/builtinsimpl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index c1cdcbcb0c..0d0afd4011 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -479,7 +479,7 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { int32_t paraType = pParam->node.resType.type; int32_t resType = 0; - if (IS_SIGNED_NUMERIC_TYPE(paraType)) { + if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) { resType = TSDB_DATA_TYPE_BIGINT; } else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) { resType = TSDB_DATA_TYPE_UBIGINT; diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index bad40422c8..53b15a82af 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -138,8 +138,8 @@ int32_t sumFunction(SqlFunctionCtx *pCtx) { int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; - if (IS_SIGNED_NUMERIC_TYPE(type)) { - if (type == TSDB_DATA_TYPE_TINYINT) { + if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { + if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) { LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int8_t, numOfElem); } else if (type == TSDB_DATA_TYPE_SMALLINT) { LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int16_t, numOfElem); From e4d53ef3c77245311a65b54d5de0a70b9830c28c Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Mon, 11 Apr 2022 15:57:34 +0800 Subject: [PATCH 32/45] fix hb bug --- source/common/src/tmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 5973a70b59..0edfcb3314 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1960,7 +1960,7 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR int32_t numOfBatch = taosArrayGetSize(pRsp->pArray); if (tDecodeI32(&decoder, &numOfBatch) < 0) return -1; - pRsp->pArray = taosArrayInit(numOfBatch, sizeof(SUseDbBatchRsp)); + pRsp->pArray = taosArrayInit(numOfBatch, sizeof(SUseDbRsp)); if (pRsp->pArray == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; From 3ff5d91d31c7fee71280ea19eca93cac48387171 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Mon, 11 Apr 2022 16:12:34 +0800 Subject: [PATCH 33/45] test:add session windows cases --- tests/script/tsim/query/session.sim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 3a57581668..2f85cc7723 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -77,6 +77,8 @@ sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.51', 7) $loop_test = 0 loop_test_pos: +sql use $dbNamme + # session(ts,5a) print ====> select count(*) from dev_001 session(ts,5a) sql select _wstartts, count(*) from dev_001 session(ts,5a) @@ -301,12 +303,17 @@ sql create table dev_001 (ts timestamp ,i timestamp ,j int) sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) print ====> select count(*) from dev_001 session(ts,1u) sql select _wstartts, count(*) from dev_001 session(ts,1u) -if $rows != 2 then +print rows: $rows +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +if $rows != 4 then print expect 2, actual: $rows return -1 endi -if $data01 != 3 then +if $data01 != 1 then return -1 endi From e30d114c7b9bdcfa3289ac171ee198050d85815b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 11 Apr 2022 16:27:42 +0800 Subject: [PATCH 34/45] set datablock desc timestamp precision --- include/libs/nodes/plannodes.h | 7 +-- source/libs/command/src/explain.c | 2 +- source/libs/executor/src/executorimpl.c | 2 +- source/libs/nodes/src/nodesCodeFuncs.c | 18 +++---- source/libs/nodes/src/nodesUtilFuncs.c | 2 +- source/libs/planner/src/planPhysiCreater.c | 55 +++++++++++++--------- source/libs/planner/src/planSpliter.c | 1 + 7 files changed, 49 insertions(+), 38 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 7cb96104bd..3931be7da5 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -84,6 +84,7 @@ typedef struct SVnodeModifLogicNode { typedef struct SExchangeLogicNode { SLogicNode node; int32_t srcGroupId; + uint8_t precision; } SExchangeLogicNode; typedef enum EWindowType { @@ -163,7 +164,7 @@ typedef struct SDataBlockDescNode { SNodeList* pSlots; int32_t totalRowSize; int32_t outputRowSize; - int16_t precision; + uint8_t precision; } SDataBlockDescNode; typedef struct SPhysiNode { @@ -253,11 +254,11 @@ typedef struct SWinodwPhysiNode { SPhysiNode node; SNodeList* pExprs; // these are expression list of parameter expression of function SNodeList* pFuncs; + SNode* pTspk; // timestamp primary key } SWinodwPhysiNode; typedef struct SIntervalPhysiNode { SWinodwPhysiNode window; - SNode* pTspk; // timestamp primary key int64_t interval; int64_t offset; int64_t sliding; @@ -274,7 +275,7 @@ typedef struct SMultiTableIntervalPhysiNode { typedef struct SSessionWinodwPhysiNode { SWinodwPhysiNode window; - int64_t gap; + int64_t gap; } SSessionWinodwPhysiNode; typedef struct SStateWinodwPhysiNode { diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 605d8f41da..064dde3ee9 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -641,7 +641,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; - EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->pTspk)); + EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk)); EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); if (pResNode->pExecInfo) { QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 1bc84f85d7..74544cc202 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6916,7 +6916,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo .precision = pIntervalPhyNode->precision }; - int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->pTspk)->slotId; + int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId; return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) { SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 7f91aeb16f..13093d63ac 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -65,7 +65,7 @@ const char* nodesNodeName(ENodeType type) { case QUERY_NODE_TARGET: return "Target"; case QUERY_NODE_DATABLOCK_DESC: - return "TupleDesc"; + return "DataBlockDesc"; case QUERY_NODE_SLOT_DESC: return "SlotDesc"; case QUERY_NODE_COLUMN_DEF: @@ -1060,6 +1060,7 @@ static int32_t jsonToPhysiSortNode(const SJson* pJson, void* pObj) { static const char* jkWindowPhysiPlanExprs = "Exprs"; static const char* jkWindowPhysiPlanFuncs = "Funcs"; +static const char* jkWindowPhysiPlanTsPk = "TsPk"; static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj; @@ -1071,6 +1072,9 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkWindowPhysiPlanFuncs, pNode->pFuncs); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkWindowPhysiPlanTsPk, nodeToJson, pNode->pTspk); + } return code; } @@ -1085,6 +1089,9 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeList(pJson, jkWindowPhysiPlanFuncs, &pNode->pFuncs); } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsPk, (SNode**)&pNode->pTspk); + } return code; } @@ -1095,7 +1102,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding"; static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit"; static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit"; static const char* jkIntervalPhysiPlanFill = "Fill"; -static const char* jkIntervalPhysiPlanTsPk = "TsPk"; static const char* jkIntervalPhysiPlanPrecision = "Precision"; static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { @@ -1120,9 +1126,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill); } - if (TSDB_CODE_SUCCESS == code) { - code = tjsonAddObject(pJson, jkIntervalPhysiPlanTsPk, nodeToJson, pNode->pTspk); - } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision); } @@ -1152,9 +1155,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill); } - if (TSDB_CODE_SUCCESS == code) { - code = jsonToNodeObject(pJson, jkIntervalPhysiPlanTsPk, (SNode**)&pNode->pTspk); - } if (TSDB_CODE_SUCCESS == code) { code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision); } @@ -2291,7 +2291,7 @@ static int32_t jsonToDataBlockDescNode(const SJson* pJson, void* pObj) { code = jsonToNodeList(pJson, jkDataBlockDescSlots, &pNode->pSlots); } if (TSDB_CODE_SUCCESS == code) { - code = tjsonGetSmallIntValue(pJson, jkDataBlockPrecision, &pNode->precision); + code = tjsonGetUTinyIntValue(pJson, jkDataBlockPrecision, &pNode->precision); } return code; diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index d21eec0a41..9f81b34274 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -252,6 +252,7 @@ static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) { destroyPhysiNode((SPhysiNode*)pNode); nodesDestroyList(pNode->pExprs); nodesDestroyList(pNode->pFuncs); + nodesDestroyNode(pNode->pTspk); } static void destroyScanPhysiNode(SScanPhysiNode* pNode) { @@ -593,7 +594,6 @@ void nodesDestroyNode(SNodeptr pNode) { SIntervalPhysiNode* pPhyNode = (SIntervalPhysiNode*)pNode; destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode); nodesDestroyNode(pPhyNode->pFill); - nodesDestroyNode(pPhyNode->pTspk); break; } case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 0c2cffa399..3b255bf276 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -316,7 +316,18 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i return TSDB_CODE_SUCCESS; } -static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, ENodeType type) { +static uint8_t getPrecision(SNodeList* pChildren) { + if (1 == LIST_LENGTH(pChildren)) { + return (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision; + } else if (2 == LIST_LENGTH(pChildren)) { + uint8_t lp = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision; + uint8_t rp = (((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc)->precision; + return (lp > rp ? rp : lp); + } + return 0; +} + +static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, uint8_t precision, SLogicNode* pLogicNode, ENodeType type) { SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type); if (NULL == pPhysiNode) { return NULL; @@ -327,6 +338,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode nodesDestroyNode(pPhysiNode); return NULL; } + pPhysiNode->pOutputDataBlockDesc->precision = precision; return pPhysiNode; } @@ -405,7 +417,7 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd } static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { - STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN); + STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN); if (NULL == pTagScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -413,7 +425,7 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* p } static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { - STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); + STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); if (NULL == pTableScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -430,7 +442,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp } static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { - SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN); + SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN); if (NULL == pScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -451,7 +463,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* } static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { - SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); + SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); if (NULL == pScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -515,7 +527,7 @@ static int32_t createJoinOutputCols(SPhysiPlanContext* pCxt, SDataBlockDescNode* } static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) { - SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN); + SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN); if (NULL == pJoin) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -656,7 +668,7 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi } static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode, SPhysiNode** pPhyNode) { - SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG); + SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG); if (NULL == pAgg) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -710,7 +722,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, } static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) { - SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT); + SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT); if (NULL == pProject) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -738,18 +750,18 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild } static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) { - SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); + SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } - + pExchange->srcGroupId = pExchangeLogicNode->srcGroupId; *pPhyNode = (SPhysiNode*)pExchange; return TSDB_CODE_SUCCESS; } static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) { - SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); + SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); if (NULL == pScan) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -803,6 +815,10 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* } } + if (TSDB_CODE_SUCCESS == code) { + code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pWindowLogicNode->pTspk, &pWindow->pTspk); + } + if (TSDB_CODE_SUCCESS == code && NULL != pFuncs) { code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFuncs, &pWindow->pFuncs); if (TSDB_CODE_SUCCESS == code) { @@ -820,7 +836,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* } static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { - SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL); + SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL); if (NULL == pInterval) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -838,18 +854,11 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil return TSDB_CODE_OUT_OF_MEMORY; } - SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc); - int32_t code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pWindowLogicNode->pTspk, &pInterval->pTspk); - if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pInterval); - return code; - } - return createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode, pPhyNode); } static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { - SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW); + SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW); if (NULL == pSession) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -860,7 +869,7 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* } static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { - SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW); + SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW); if (NULL == pState) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -908,7 +917,7 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr } static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode, SPhysiNode** pPhyNode) { - SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT); + SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT); if (NULL == pSort) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -947,7 +956,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren } static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { - SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION); + SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION); if (NULL == pPart) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 3ce225abab..aadbaf6fd8 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -103,6 +103,7 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla return TSDB_CODE_OUT_OF_MEMORY; } pExchange->srcGroupId = pCxt->groupId; + pExchange->precision = pScan->pMeta->tableInfo.precision; pExchange->node.pTargets = nodesCloneList(pScan->node.pTargets); if (NULL == pExchange->node.pTargets) { return TSDB_CODE_OUT_OF_MEMORY; From 0f83fd7c5903b7358c48511847c2e7bec1f296f8 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Mon, 11 Apr 2022 16:32:44 +0800 Subject: [PATCH 35/45] test: add session cases into CI --- tests/script/jenkins/basic.txt | 1 + tests/script/tsim/query/session.sim | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 761a8921d5..c6a69f7e06 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -32,6 +32,7 @@ ./test.sh -f tsim/query/interval-offset.sim ./test.sh -f tsim/query/scalarFunction.sim ./test.sh -f tsim/query/charScalarFunction.sim +./test.sh -f tsim/query/session.sim # ---- qnode ./test.sh -f tsim/qnode/basic1.sim diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 2f85cc7723..282d83bc27 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -219,8 +219,8 @@ endi #endi -print ====> leastsquares not supported yet. -print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d) +#print ====> leastsquares not supported yet. +#print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d) #sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d) #if $rows != 2 then # return -1 @@ -287,14 +287,14 @@ print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtyp #endi print ================> syntax error check not active ================> reactive -#sql_error select * from dev_001 session(ts,1w) -#sql_error select count(*) from st session(ts,1w) -#sql_error select count(*) from dev_001 group by tagtype session(ts,1w) -#sql_error select count(*) from dev_001 session(ts,1n) -#sql_error select count(*) from dev_001 session(ts,1y) -#sql_error select count(*) from dev_001 session(ts,0s) -#sql_error select count(*) from dev_001 session(i,1y) -#sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0' +sql_error select * from dev_001 session(ts,1w) +sql select count(*) from st session(ts,1w) +sql_error select count(*) from dev_001 group by tagtype session(ts,1w) +sql select count(*) from dev_001 session(ts,1n) +sql select count(*) from dev_001 session(ts,1y) +sql select count(*) from dev_001 session(ts,0s) +sql_error select count(*) from dev_001 session(i,1y) +sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0' print ====> create database d1 precision 'us' sql create database d1 precision 'us' @@ -318,7 +318,7 @@ if $data01 != 1 then endi #sql_error select count(*) from dev_001 session(i,1s) -#sql create table secondts(ts timestamp,t2 timestamp,i int) +sql create table secondts(ts timestamp,t2 timestamp,i int) #sql_error select count(*) from secondts session(t2,2s) if $loop_test == 0 then From 8240efda4c98304918ad42993f3122fa09dd25e5 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 17:03:41 +0800 Subject: [PATCH 36/45] fix[query]: enable filter on nchar type. --- source/libs/scalar/src/filter.c | 29 +++++++++--------- source/libs/scalar/src/scalar.c | 1 - source/libs/scalar/src/sclvector.c | 48 ++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 2e47e19023..191143de12 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1748,7 +1748,6 @@ int32_t fltInitValFieldData(SFilterInfo *info) { SFilterField* fi = right; SValueNode* var = (SValueNode *)fi->desc; - if (var == NULL) { assert(fi->data != NULL); continue; @@ -1767,13 +1766,18 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } SDataType *dType = &var->node.resType; + size_t bytes = 0; if (type == TSDB_DATA_TYPE_BINARY) { size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; - fi->data = taosMemoryCalloc(1, len + 1 + VARSTR_HEADER_SIZE); + bytes = len + 1 + VARSTR_HEADER_SIZE; + + fi->data = taosMemoryCalloc(1, bytes); } else if (type == TSDB_DATA_TYPE_NCHAR) { - size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; - fi->data = taosMemoryCalloc(1, (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; + bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; + + fi->data = taosMemoryCalloc(1, bytes); } else if (type != TSDB_DATA_TYPE_JSON){ if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE /* @@ -1797,8 +1801,11 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } else { SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; out.columnData->info.type = type; - out.columnData->info.bytes = tDataTypes[type].bytes; - ASSERT(!IS_VAR_DATA_TYPE(type)); + if (IS_VAR_DATA_TYPE(type)) { + out.columnData->info.bytes = bytes; + } else { + out.columnData->info.bytes = tDataTypes[type].bytes; + } // todo refactor the convert int32_t code = doConvertDataType(var, &out); @@ -2985,13 +2992,13 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); - if (colData == NULL || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)) { + if (colData == NULL || colDataIsNull_s((SColumnInfoData *)info->cunits[uidx].colData, i)) { (*p)[i] = 0; all = false; continue; } - // match/nmatch for nchar type need convert from ucs4 to mbs + // match/nmatch for nchar type need convert from ucs4 to mbs if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)){ char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); @@ -3222,19 +3229,13 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) { info->unitFlags = taosMemoryMalloc(info->unitNum * sizeof(*info->unitFlags)); filterDumpInfoToString(info, "Final", 0); - return code; _return: - qInfo("init from node failed, code:%d", code); - return code; } - - - bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows) { if (FILTER_EMPTY_RES(info)) { return false; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index f97e5a2d2a..116dfdd5d5 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -46,7 +46,6 @@ int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) { colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); colInfoDataEnsureCapacity(out->columnData, 1); - int32_t code = vectorConvertImpl(&in, out); sclFreeParam(&in); diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 4bce8f33f2..ff677d2f7b 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -177,10 +177,25 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowInd colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v); } +static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex) { + int32_t len = 0; + int32_t inputLen = varDataLen(buf); + + char* t = taosMemoryCalloc(1,(inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + /*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), pOut->columnData->info.bytes, &len); + varDataSetLen(t, len); + + colDataAppend(pOut->columnData, rowIndex, t, false); + taosMemoryFree(t); +} + +//TODO opt performance int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { int32_t bufSize = pIn->columnData->info.bytes; char *tmp = taosMemoryMalloc(bufSize); + bool vton = false; + _bufConverteFunc func = NULL; if (TSDB_DATA_TYPE_BOOL == outType) { func = varToBool; @@ -190,6 +205,9 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in func = varToUnsigned; } else if (IS_FLOAT_TYPE(outType)) { func = varToFloat; + } else if (outType == TSDB_DATA_TYPE_NCHAR) { + func = varToNchar; + vton = true; } else { sclError("invalid convert outType:%d", outType); return TSDB_CODE_QRY_APP_ERROR; @@ -197,26 +215,30 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in pOut->numOfRows = pIn->numOfRows; for (int32_t i = 0; i < pIn->numOfRows; ++i) { - if (colDataIsNull(pIn->columnData, pIn->numOfRows, i, NULL)) { + if (colDataIsNull_s(pIn->columnData, i)) { colDataAppendNULL(pOut->columnData, i); continue; } char* data = colDataGetData(pIn->columnData, i); - if (TSDB_DATA_TYPE_BINARY == inType) { - memcpy(tmp, varDataVal(data), varDataLen(data)); - tmp[varDataLen(data)] = 0; + if (vton) { + memcpy(tmp, data, varDataTLen(data)); } else { - ASSERT (varDataLen(data) <= bufSize); - - int len = taosUcs4ToMbs((TdUcs4*)varDataVal(data), varDataLen(data), tmp); - if (len < 0){ - sclError("castConvert taosUcs4ToMbs error 1"); - taosMemoryFreeClear(tmp); - return TSDB_CODE_QRY_APP_ERROR; + if (TSDB_DATA_TYPE_VARCHAR == inType) { + memcpy(tmp, varDataVal(data), varDataLen(data)); + tmp[varDataLen(data)] = 0; + } else { + ASSERT(varDataLen(data) <= bufSize); + + int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); + if (len < 0) { + sclError("castConvert taosUcs4ToMbs error 1"); + taosMemoryFreeClear(tmp); + return TSDB_CODE_QRY_APP_ERROR; + } + + tmp[len] = 0; } - - tmp[len] = 0; } (*func)(tmp, pOut, i); From 72e39b2bf521424065ebd740d5cb7e6089b83e34 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 11 Apr 2022 17:05:24 +0800 Subject: [PATCH 37/45] adaption for update function --- include/common/taosdef.h | 2 ++ include/common/tdataformat.h | 2 +- include/common/trow.h | 2 +- include/common/ttypes.h | 1 + source/common/src/tdataformat.c | 1 + source/common/src/trow.c | 26 +++++++------- source/dnode/vnode/src/tsdb/tsdbCommit.c | 40 +++++++++++++++++++++- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 2 +- source/dnode/vnode/src/tsdb/tsdbRead.c | 8 +++++ source/dnode/vnode/src/tsdb/tsdbReadImpl.c | 7 ++-- 10 files changed, 72 insertions(+), 19 deletions(-) diff --git a/include/common/taosdef.h b/include/common/taosdef.h index 5001a99c2a..6e344dfdb4 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -57,6 +57,8 @@ typedef enum { TD_ROW_PARTIAL_UPDATE = 2, } TDUpdateConfig; +#define TD_SUPPORT_UPDATE(u) ((u) > 0) + typedef enum { TSDB_STATIS_OK = 0, // statis part exist and load successfully TSDB_STATIS_NONE = 1, // statis part not exist diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index 8e07d4e669..8a87a1bd2e 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -482,7 +482,7 @@ void tdResetDataCols(SDataCols *pCols); int32_t tdInitDataCols(SDataCols *pCols, STSchema *pSchema); SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData); SDataCols *tdFreeDataCols(SDataCols *pCols); -int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToMerge, int32_t *pOffset, bool forceSetNull); +int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToMerge, int32_t *pOffset, bool forceSetNull, TDRowVerT maxVer); // ----------------- K-V data row structure /* |<-------------------------------------- len -------------------------------------------->| diff --git a/include/common/trow.h b/include/common/trow.h index b7ffcd14c6..539bda078d 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -230,7 +230,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset, col_id_t colId); -int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull); +int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols); /** * @brief diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 37d688a0ef..5f1cfc030a 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -27,6 +27,7 @@ extern "C" { typedef int32_t VarDataOffsetT; typedef uint32_t TDRowLenT; typedef uint8_t TDRowValT; +typedef uint64_t TDRowVerT; typedef int16_t col_id_t; typedef int8_t col_type_t; typedef int32_t col_bytes_t; diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index f6614633fb..f2a5a98d96 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -411,6 +411,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) { #endif pCols->numOfRows = 0; + pCols->bitmapMode = 0; pCols->numOfCols = schemaNCols(pSchema); for (i = 0; i < schemaNCols(pSchema); ++i) { diff --git a/source/common/src/trow.c b/source/common/src/trow.c index d9c48bfe76..7392b0bf8b 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -385,7 +385,6 @@ int tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int pCol->len += pCol->bytes; } #ifdef TD_SUPPORT_BITMAP - tdSetBitmapValType(pCol->pBitmap, numOfRows, valType, bitmapMode); #endif return 0; @@ -486,7 +485,7 @@ static int32_t tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols * @param pCols * @param forceSetNull */ -int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull) { +int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols) { if (TD_IS_TP_ROW(pRow)) { return tdAppendTpRowToDataCol(pRow, pSchema, pCols); } else if (TD_IS_KV_ROW(pRow)) { @@ -497,7 +496,7 @@ int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCol return TSDB_CODE_SUCCESS; } -int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull) { +int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull, TDRowVerT maxVer) { ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows); ASSERT(target->numOfCols == source->numOfCols); int offset = 0; @@ -510,6 +509,7 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int * if ((target->numOfRows == 0) || (dataColsKeyLast(target) < dataColsKeyAtRow(source, *pOffset))) { // No overlap ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints); + // TODO: filter the maxVer for (int i = 0; i < rowsToMerge; i++) { for (int j = 0; j < source->numOfCols; j++) { if (source->cols[j].len > 0 || target->cols[j].len > 0) { @@ -555,9 +555,9 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i // TKEY tkey2 = (*iter2 >= limit2) ? TKEY_NULL : dataColsTKeyAt(src2, *iter2); ASSERT(tkey1 == TKEY_NULL || (!TKEY_IS_DELETED(tkey1))); - + // TODO: filter the maxVer if (key1 < key2) { - for (int i = 0; i < src1->numOfCols; i++) { + for (int i = 0; i < src1->numOfCols; ++i) { ASSERT(target->cols[i].type == src1->cols[i].type); if (src1->cols[i].len > 0 || target->cols[i].len > 0) { SCellVal sVal = {0}; @@ -568,12 +568,12 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i } } - target->numOfRows++; - (*iter1)++; + ++target->numOfRows; + ++(*iter1); } else if (key1 >= key2) { - // if ((key1 > key2) || (key1 == key2 && !TKEY_IS_DELETED(tkey2))) { - if ((key1 > key2) || (key1 == key2)) { - for (int i = 0; i < src2->numOfCols; i++) { + // TODO: filter the maxVer + if ((key1 > key2) || ((key1 == key2) && !TKEY_IS_DELETED(key2))) { + for (int i = 0; i < src2->numOfCols; ++i) { SCellVal sVal = {0}; ASSERT(target->cols[i].type == src2->cols[i].type); if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2, src2->bitmapMode) < 0) { @@ -590,11 +590,11 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i dataColSetNullAt(&target->cols[i], target->numOfRows, true, target->bitmapMode); } } - target->numOfRows++; + ++target->numOfRows; } - (*iter2)++; - if (key1 == key2) (*iter1)++; + ++(*iter2); + if (key1 == key2) ++(*iter1); } ASSERT(target->numOfRows <= target->maxPoints); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 21ad1ec076..67c7973206 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -1678,10 +1678,11 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt ASSERT(pSchema != NULL); } - tdAppendSTSRowToDataCol(row, pSchema, pTarget, true); + tdAppendSTSRowToDataCol(row, pSchema, pTarget); tSkipListIterNext(pCommitIter->pIter); } else { +#if 0 if (update != TD_ROW_OVERWRITE_UPDATE) { // copy disk data for (int i = 0; i < pDataCols->numOfCols; ++i) { @@ -1706,6 +1707,43 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt } ++(*iter); tSkipListIterNext(pCommitIter->pIter); +#endif + // copy disk data + for (int i = 0; i < pDataCols->numOfCols; ++i) { + SCellVal sVal = {0}; + if (tdGetColDataOfRow(&sVal, pDataCols->cols + i, *iter, pDataCols->bitmapMode) < 0) { + TASSERT(0); + } + // TODO: tdAppendValToDataCol may fail + tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, + pTarget->bitmapMode); + } + + if (TD_SUPPORT_UPDATE(update)) { + // copy mem data(Multi-Version) + if (pSchema == NULL || schemaVersion(pSchema) != TD_ROW_SVER(row)) { + pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, TD_ROW_SVER(row)); + ASSERT(pSchema != NULL); + } + + // TODO: merge with Multi-Version + STSRow *curRow = row; + + ++(*iter); + tSkipListIterNext(pCommitIter->pIter); + STSRow *nextRow = tsdbNextIterRow(pCommitIter->pIter); + + if (key2 < TD_ROW_KEY(nextRow)) { + tdAppendSTSRowToDataCol(row, pSchema, pTarget); + } else { + tdAppendSTSRowToDataCol(row, pSchema, pTarget); + } + // TODO: merge with Multi-Version + } else { + ++pTarget->numOfRows; + ++(*iter); + tSkipListIterNext(pCommitIter->pIter); + } } if (pTarget->numOfRows >= maxRows) break; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index c657b2e947..54115003cf 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -475,7 +475,7 @@ static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema * } } - tdAppendSTSRowToDataCol(row, *ppSchema, pCols, true); + tdAppendSTSRowToDataCol(row, *ppSchema, pCols); } return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 5677bb0615..e308c9c2b9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -761,6 +761,7 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order, TSKEY r2 = TD_ROW_KEY(rimem); if (r1 == r2) { +#if 0 if(update == TD_ROW_DISCARD_UPDATE){ pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; tSkipListIterNext(pCheckInfo->iter); @@ -771,6 +772,13 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order, } else { pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH; } +#endif + if (TD_SUPPORT_UPDATE(update)) { + pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH; + } else { + pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; + tSkipListIterNext(pCheckInfo->iter); + } return r1; } else if (r1 < r2 && ASCENDING_TRAVERSE(order)) { pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index 87459593b5..e31ede09cc 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -263,8 +263,9 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) { for (int i = 1; i < pBlock->numOfSubBlocks; i++) { iBlock++; if (tsdbLoadBlockDataImpl(pReadh, iBlock, pReadh->pDCols[1]) < 0) return -1; + // TODO: use the real maxVersion to replace the UINT64_MAX to support Multi-Version if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL, - update != TD_ROW_PARTIAL_UPDATE) < 0) + update != TD_ROW_PARTIAL_UPDATE, UINT64_MAX) < 0) return -1; } @@ -293,8 +294,9 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, for (int i = 1; i < pBlock->numOfSubBlocks; i++) { iBlock++; if (tsdbLoadBlockDataColsImpl(pReadh, iBlock, pReadh->pDCols[1], colIds, numOfColsIds) < 0) return -1; + // TODO: use the real maxVersion to replace the UINT64_MAX to support Multi-Version if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL, - update != TD_ROW_PARTIAL_UPDATE) < 0) + update != TD_ROW_PARTIAL_UPDATE, UINT64_MAX) < 0) return -1; } @@ -304,6 +306,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, if (pDataCol->bitmap) { ASSERT(pDataCol->colId != PRIMARYKEY_TIMESTAMP_COL_ID); tdMergeBitmap(pDataCol->pBitmap, TD_BITMAP_BYTES(pReadh->pDCols[0]->numOfRows), pDataCol->pBitmap); + tdDataColsSetBitmapI(pReadh->pDCols[0]); } } } From 4961b6ab8ee7cb58d51e204f73422c1ccc630b39 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Apr 2022 17:08:13 +0800 Subject: [PATCH 38/45] feat: optimize encode/decode resultRow --- source/libs/executor/inc/executorimpl.h | 9 +- source/libs/executor/src/executorimpl.c | 134 ++++++++++------------- source/libs/executor/src/groupoperator.c | 6 +- 3 files changed, 68 insertions(+), 81 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 9a75830ec4..526f43cb64 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -232,9 +232,11 @@ typedef struct STaskAttr { } STaskAttr; struct SOperatorInfo; +struct SAggSupporter; +struct SOptrBasicInfo; -typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, char **result, int32_t *length); -typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, char *result, int32_t length); +typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char **result, int32_t *length); +typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char *result, int32_t length); typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr); typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup); @@ -753,6 +755,9 @@ void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model); int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo **pRes, int32_t *capacity, int32_t *resNum); +bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char* result, int32_t length); +void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char **result, int32_t *length); + #ifdef __cplusplus } #endif diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index d344b93485..8addd53479 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4974,15 +4974,19 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); doAggregateImpl(pOperator, 0, pInfo->pCtx); - char *result = NULL; - int32_t length = 0; - pOperator->encodeResultRow(pOperator, &result, &length); - SAggSupporter *pSup = &pAggInfo->aggSup; - taosHashClear(pSup->pResultRowHashTable); - pOperator->decodeResultRow(pOperator, result, length); - if(result){ - taosMemoryFree(result); + if(pOperator->encodeResultRow){ + char *result = NULL; + int32_t length = 0; + SAggSupporter *pSup = &pAggInfo->aggSup; + pOperator->encodeResultRow(pOperator, pSup, pInfo, &result, &length); + taosHashClear(pSup->pResultRowHashTable); + pInfo->resultRowInfo.size = 0; + pOperator->decodeResultRow(pOperator, pSup, pInfo, result, length); + if(result){ + taosMemoryFree(result); + } } + } finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput); @@ -5011,43 +5015,33 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator, bool* newgroup) return (blockDataGetNumOfRows(pInfo->pRes) != 0) ? pInfo->pRes : NULL; } -static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t *length) { - SAggSupporter *pSup = NULL; - switch(pOperator->operatorType){ - case QUERY_NODE_PHYSICAL_PLAN_AGG:{ - SAggOperatorInfo *pAggInfo = pOperator->info; - pSup = &pAggInfo->aggSup; - break; - } - case QUERY_NODE_PHYSICAL_PLAN_GROUPBY:{ - SGroupbyOperatorInfo *pAggInfo = pOperator->info; - pSup = &pAggInfo->aggSup; - break; - } - case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ - STableIntervalOperatorInfo *pAggInfo = pOperator->info; - pSup = &pAggInfo->aggSup; - break; - } - default:{ - qDebug("invalid operatorType: %d", pOperator->operatorType); - } - } - +void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char **result, int32_t *length) { int32_t size = taosHashGetSize(pSup->pResultRowHashTable); - size_t keyLen = POINTER_BYTES; // estimate the key length + size_t keyLen = sizeof(uint64_t) * 2; // estimate the key length int32_t totalSize = sizeof(int32_t) + size * (sizeof(int32_t) + keyLen + sizeof(int32_t) + pSup->resultRowSize); *result = taosMemoryCalloc(1, totalSize); if (*result == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return; + longjmp(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } *(int32_t*)(*result) = size; int32_t offset = sizeof(int32_t); + + // prepare memory + SResultRowPosition* pos = &pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.curPos]; + void* pPage = getBufPage(pSup->pResultBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); + setBufPageDirty(pPage, true); + releaseBufPage(pSup->pResultBuf, pPage); + void* pIter = taosHashIterate(pSup->pResultRowHashTable, NULL); while (pIter) { void* key = taosHashGetKey(pIter, &keyLen); - SResultRow** p1 = (SResultRow**)pIter; + SResultRowPosition** p1 = (SResultRowPosition**)pIter; + + pPage = (SFilePage*) getBufPage(pSup->pResultBuf, (*p1)->pageId); + pRow = (SResultRow*)((char*)pPage + (*p1)->offset); + setBufPageDirty(pPage, true); + releaseBufPage(pSup->pResultBuf, pPage); // recalculate the result size int32_t realTotalSize = offset + sizeof(int32_t) + keyLen + sizeof(int32_t) + pSup->resultRowSize; @@ -5057,7 +5051,7 @@ static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(*result); *result = NULL; - return; + longjmp(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } else { *result = tmp; } @@ -5071,7 +5065,7 @@ static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t // save value *(int32_t*)(*result + offset) = pSup->resultRowSize; offset += sizeof(int32_t); - memcpy(*result + offset, *p1, pSup->resultRowSize); + memcpy(*result + offset, pRow, pSup->resultRowSize); offset += pSup->resultRowSize; pIter = taosHashIterate(pSup->pResultRowHashTable, pIter); @@ -5083,34 +5077,11 @@ static void aggEncodeResultRow(SOperatorInfo* pOperator, char **result, int32_t return; } -static bool aggDecodeResultRow(SOperatorInfo* pOperator, char* result, int32_t length) { +bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char* result, int32_t length) { if (!result || length <= 0) { return false; } - SAggSupporter *pSup = NULL; - switch(pOperator->operatorType){ - case QUERY_NODE_PHYSICAL_PLAN_AGG:{ - SAggOperatorInfo *pAggInfo = pOperator->info; - //SOptrBasicInfo *pInfo = &pAggInfo->binfo; - pSup = &pAggInfo->aggSup; - break; - } - case QUERY_NODE_PHYSICAL_PLAN_GROUPBY:{ - SGroupbyOperatorInfo *pAggInfo = pOperator->info; - pSup = &pAggInfo->aggSup; - break; - } - case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ - STableIntervalOperatorInfo *pAggInfo = pOperator->info; - pSup = &pAggInfo->aggSup; - break; - } - default:{ - qDebug("invalid operatorType: %d", pOperator->operatorType); - } - } - // int32_t size = taosHashGetSize(pSup->pResultRowHashTable); int32_t count = *(int32_t*)(result); @@ -5122,17 +5093,16 @@ static bool aggDecodeResultRow(SOperatorInfo* pOperator, char* result, int32_t l uint64_t tableGroupId = *(uint64_t*)(result + offset); SResultRow* resultRow = getNewResultRow_rv(pSup->pResultBuf, tableGroupId, pSup->resultRowSize); if (!resultRow) { - terrno = TSDB_CODE_TSC_INVALID_INPUT; - return false; + longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_INVALID_INPUT); } // add a new result set for a new group - taosHashPut(pSup->pResultRowHashTable, result + offset, keyLen, &resultRow, POINTER_BYTES); + SResultRowPosition pos = {.pageId = resultRow->pageId, .offset = resultRow->offset}; + taosHashPut(pSup->pResultRowHashTable, result + offset, keyLen, &pos, sizeof(SResultRowPosition)); offset += keyLen; int32_t valueLen = *(int32_t*)(result + offset); if (valueLen != pSup->resultRowSize) { - terrno = TSDB_CODE_TSC_INVALID_INPUT; - return false; + longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_INVALID_INPUT); } offset += sizeof(int32_t); int32_t pageId = resultRow->pageId; @@ -5143,12 +5113,13 @@ static bool aggDecodeResultRow(SOperatorInfo* pOperator, char* result, int32_t l offset += valueLen; initResultRow(resultRow); - //pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; + prepareResultListBuffer(&pInfo->resultRowInfo, pOperator->pTaskInfo->env); + pInfo->resultRowInfo.curPos = pInfo->resultRowInfo.size; + pInfo->resultRowInfo.pPosition[pInfo->resultRowInfo.size++] = (SResultRowPosition) {.pageId = resultRow->pageId, .offset = resultRow->offset}; } if (offset != length) { - terrno = TSDB_CODE_TSC_INVALID_INPUT; - return false; + longjmp(pOperator->pTaskInfo->env, TSDB_CODE_TSC_INVALID_INPUT); } return true; } @@ -5375,16 +5346,21 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); - char *result = NULL; - int32_t length = 0; - pOperator->encodeResultRow(pOperator, &result, &length); - SAggSupporter *pSup = &pInfo->aggSup; - taosHashClear(pSup->pResultRowHashTable); - pOperator->decodeResultRow(pOperator, result, length); - if(result){ - taosMemoryFree(result); +#if 0 + if(pOperator->encodeResultRow){ + char *result = NULL; + int32_t length = 0; + SAggSupporter *pSup = &pInfo->aggSup; + pOperator->encodeResultRow(pOperator, pSup, &pInfo->binfo, &result, &length); + taosHashClear(pSup->pResultRowHashTable); + pInfo->binfo.resultRowInfo.size = 0; + pOperator->decodeResultRow(pOperator, pSup, &pInfo->binfo, result, length); + if(result){ + taosMemoryFree(result); + } } } +#endif closeAllResultRows(&pInfo->binfo.resultRowInfo); finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, @@ -6335,6 +6311,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf pOperator->info = pInfo; pOperator->getNextFn = doStateWindowAgg; pOperator->closeFn = destroyStateWindowOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; + pOperator->decodeResultRow = aggDecodeResultRow; int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -6374,6 +6352,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo pOperator->info = pInfo; pOperator->getNextFn = doSessionWindowAgg; pOperator->closeFn = destroySWindowOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; + pOperator->decodeResultRow = aggDecodeResultRow; pOperator->pTaskInfo = pTaskInfo; code = appendDownstream(pOperator, &downstream, 1); diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 3eb8ff1b72..1de33466e3 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -165,7 +165,7 @@ static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) { // assign the group keys or user input constant values if required static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t totalRows, int32_t rowIndex) { for (int32_t i = 0; i < numOfOutput; ++i) { - if (pCtx[i].functionId == -1) { + if (pCtx[i].functionId == -1) { // select count(*),key from t group by key. SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[i]); SColumnInfoData* pColInfoData = pCtx[i].input.pData[0]; @@ -337,7 +337,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pOperator->name = "GroupbyAggOperator"; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; - // pOperator->operatorType = OP_Groupby; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUPBY; pOperator->pExpr = pExprInfo; pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; @@ -345,6 +345,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pOperator->_openFn = operatorDummyOpenFn; pOperator->getNextFn = hashGroupbyAggregate; pOperator->closeFn = destroyGroupOperatorInfo; + pOperator->encodeResultRow = aggEncodeResultRow; + pOperator->decodeResultRow = aggDecodeResultRow; code = appendDownstream(pOperator, &downstream, 1); return pOperator; From 91f966155035d476370f7a27eee4285a5c3163d0 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Mon, 11 Apr 2022 17:29:14 +0800 Subject: [PATCH 39/45] bug fix for bitmap compress --- source/dnode/vnode/src/tsdb/tsdbCommit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 67c7973206..eb32663387 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -1298,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF int32_t tBitmaps = 0; int32_t tBitmapsLen = 0; if ((ncol != 0) && !TD_COL_ROWS_NORM(pBlockCol)) { - tBitmaps = sBitmaps; + tBitmaps = isSuper ? sBitmaps : nBitmaps; } #endif From 78fd2d3a3eabeb6d608c217bb96d04bb18776021 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Apr 2022 17:30:27 +0800 Subject: [PATCH 40/45] feat: optimize encode/decode resultRow --- source/libs/executor/src/executorimpl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 8addd53479..eff5555dd2 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4974,6 +4974,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); doAggregateImpl(pOperator, 0, pInfo->pCtx); +#if 0 // test for encode/decode result info if(pOperator->encodeResultRow){ char *result = NULL; int32_t length = 0; @@ -4986,7 +4987,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { taosMemoryFree(result); } } - +#endif } finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput); @@ -5036,10 +5037,10 @@ void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasi void* pIter = taosHashIterate(pSup->pResultRowHashTable, NULL); while (pIter) { void* key = taosHashGetKey(pIter, &keyLen); - SResultRowPosition** p1 = (SResultRowPosition**)pIter; + SResultRowPosition* p1 = (SResultRowPosition*)pIter; - pPage = (SFilePage*) getBufPage(pSup->pResultBuf, (*p1)->pageId); - pRow = (SResultRow*)((char*)pPage + (*p1)->offset); + pPage = (SFilePage*) getBufPage(pSup->pResultBuf, p1->pageId); + pRow = (SResultRow*)((char*)pPage + p1->offset); setBufPageDirty(pPage, true); releaseBufPage(pSup->pResultBuf, pPage); @@ -5346,7 +5347,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, order); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); -#if 0 +#if 0 // test for encode/decode result info if(pOperator->encodeResultRow){ char *result = NULL; int32_t length = 0; From 45b766cd358f0eaeb7df335e6adbcebf507bbee8 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Apr 2022 17:35:17 +0800 Subject: [PATCH 41/45] feat: optimize encode/decode resultRow --- include/libs/nodes/nodes.h | 3 +-- source/libs/executor/src/groupoperator.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 68056eff47..c91779ba8b 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -184,8 +184,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_DISPATCH, QUERY_NODE_PHYSICAL_PLAN_INSERT, QUERY_NODE_PHYSICAL_SUBPLAN, - QUERY_NODE_PHYSICAL_PLAN, - QUERY_NODE_PHYSICAL_PLAN_GROUPBY + QUERY_NODE_PHYSICAL_PLAN } ENodeType; /** diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 1de33466e3..8d780fc70c 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -337,7 +337,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx pOperator->name = "GroupbyAggOperator"; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; - pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUPBY; + // pOperator->operatorType = OP_Groupby; pOperator->pExpr = pExprInfo; pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; From 2624fa2711ea5a73c20c07975516497576dbdc3b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 17:36:10 +0800 Subject: [PATCH 42/45] fix[query]: invalid write. --- source/libs/scalar/src/sclvector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index ff677d2f7b..05456790a5 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -189,10 +189,10 @@ static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIn taosMemoryFree(t); } -//TODO opt performance +//TODO opt performance, tmp is not needed. int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { int32_t bufSize = pIn->columnData->info.bytes; - char *tmp = taosMemoryMalloc(bufSize); + char *tmp = taosMemoryMalloc(bufSize + VARSTR_HEADER_SIZE); bool vton = false; From 983e4aa010b1bc481d75b52771c28890f3eca56e Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 11 Apr 2022 17:42:05 +0800 Subject: [PATCH 43/45] set datablock desc timestamp precision --- include/libs/nodes/querynodes.h | 1 + source/libs/function/inc/builtins.h | 20 +++++++------ source/libs/nodes/src/nodesTraverseFuncs.c | 27 +++++++++++++---- source/libs/parser/src/parAstCreater.c | 35 +++++----------------- source/libs/planner/src/planLogicCreater.c | 12 ++++++++ source/libs/planner/src/planPhysiCreater.c | 1 + 6 files changed, 53 insertions(+), 43 deletions(-) diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index f052c9daa7..3e78da63de 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -190,6 +190,7 @@ typedef struct SLimitNode { typedef struct SStateWindowNode { ENodeType type; // QUERY_NODE_STATE_WINDOW + SNode* pCol; // timestamp primary key SNode* pExpr; } SStateWindowNode; diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 2c0148e04f..f0349c55b9 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -26,15 +26,17 @@ extern "C" { #define FUNC_MGT_FUNC_CLASSIFICATION_MASK(n) (1 << n) -#define FUNC_MGT_AGG_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(0) -#define FUNC_MGT_SCALAR_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(1) -#define FUNC_MGT_NONSTANDARD_SQL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(2) -#define FUNC_MGT_STRING_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(3) -#define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4) -#define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5) -#define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) -#define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7) -#define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) +#define FUNC_MGT_AGG_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(0) +#define FUNC_MGT_SCALAR_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(1) +#define FUNC_MGT_NONSTANDARD_SQL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(2) +#define FUNC_MGT_STRING_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(3) +#define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4) +#define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5) +#define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) +#define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7) +#define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) +#define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9) +#define FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED FUNC_MGT_FUNC_CLASSIFICATION_MASK(10) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 3c10287992..4a782cce08 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -77,9 +77,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker case QUERY_NODE_ORDER_BY_EXPR: res = walkNode(((SOrderByExprNode*)pNode)->pExpr, order, walker, pContext); break; - case QUERY_NODE_STATE_WINDOW: - res = walkNode(((SStateWindowNode*)pNode)->pExpr, order, walker, pContext); + case QUERY_NODE_STATE_WINDOW: { + SStateWindowNode* pState = (SStateWindowNode*)pNode; + res = walkNode(pState->pExpr, order, walker, pContext); + if (DEAL_RES_ERROR != res) { + res = walkNode(pState->pCol, order, walker, pContext); + } break; + } case QUERY_NODE_SESSION_WINDOW: { SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; res = walkNode(pSession->pCol, order, walker, pContext); @@ -211,12 +216,22 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit case QUERY_NODE_ORDER_BY_EXPR: res = rewriteNode(&(((SOrderByExprNode*)pNode)->pExpr), order, rewriter, pContext); break; - case QUERY_NODE_STATE_WINDOW: - res = rewriteNode(&(((SStateWindowNode*)pNode)->pExpr), order, rewriter, pContext); + case QUERY_NODE_STATE_WINDOW: { + SStateWindowNode* pState = (SStateWindowNode*)pNode; + res = rewriteNode(&pState->pExpr, order, rewriter, pContext); + if (DEAL_RES_ERROR != res) { + res = rewriteNode(&pState->pCol, order, rewriter, pContext); + } break; - case QUERY_NODE_SESSION_WINDOW: - res = rewriteNode(&(((SSessionWindowNode*)pNode)->pCol), order, rewriter, pContext); + } + case QUERY_NODE_SESSION_WINDOW: { + SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; + res = rewriteNode(&pSession->pCol, order, rewriter, pContext); + if (DEAL_RES_ERROR != res) { + res = rewriteNode(&pSession->pGap, order, rewriter, pContext); + } break; + } case QUERY_NODE_INTERVAL_WINDOW: { SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; res = rewriteNode(&(pInterval->pInterval), order, rewriter, pContext); diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4908748f0d..01531f89ab 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -456,6 +456,13 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW); CHECK_OUT_OF_MEM(state); + state->pCol = nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == state->pCol) { + nodesDestroyNode(state); + CHECK_OUT_OF_MEM(state->pCol); + } + ((SColumnNode*)state->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + strcpy(((SColumnNode*)state->pCol)->colName, PK_TS_COL_INTERNAL_NAME); state->pExpr = pExpr; return (SNode*)state; } @@ -584,34 +591,6 @@ SNode* createDatabaseOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } -static bool checkAndSetKeepOption(SAstCreateContext* pCxt, SNodeList* pKeep, int32_t* pKeep0, int32_t* pKeep1, int32_t* pKeep2) { - int32_t numOfKeep = LIST_LENGTH(pKeep); - if (numOfKeep > 3 || numOfKeep < 1) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid number of keep options"); - return false; - } - - int32_t daysToKeep0 = strtol(((SValueNode*)nodesListGetNode(pKeep, 0))->literal, NULL, 10); - int32_t daysToKeep1 = numOfKeep > 1 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 1))->literal, NULL, 10) : daysToKeep0; - int32_t daysToKeep2 = numOfKeep > 2 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 2))->literal, NULL, 10) : daysToKeep1; - if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP || - daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, - "invalid option keep: %d, %d, %d valid range: [%d, %d]", daysToKeep0, daysToKeep1, daysToKeep2, TSDB_MIN_KEEP, TSDB_MAX_KEEP); - return false; - } - - if (!((daysToKeep0 <= daysToKeep1) && (daysToKeep1 <= daysToKeep2))) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid keep value, should be keep0 <= keep1 <= keep2"); - return false; - } - - *pKeep0 = daysToKeep0; - *pKeep1 = daysToKeep1; - *pKeep2 = daysToKeep2; - return true; -} - SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { switch (pAlterOption->type) { case DB_OPTION_BLOCKS: diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 596bb64bac..bd5ce0f494 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -488,6 +488,12 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo pWindow->winType = WINDOW_TYPE_STATE; pWindow->pStateExpr = nodesCloneNode(pState->pExpr); + pWindow->pTspk = nodesCloneNode(pState->pCol); + if (NULL == pWindow->pTspk) { + nodesDestroyNode(pWindow); + return TSDB_CODE_OUT_OF_MEMORY; + } + return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); } @@ -500,6 +506,12 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW pWindow->winType = WINDOW_TYPE_SESSION; pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i; + pWindow->pTspk = nodesCloneNode(pSession->pCol); + if (NULL == pWindow->pTspk) { + nodesDestroyNode(pWindow); + return TSDB_CODE_OUT_OF_MEMORY; + } + return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 3b255bf276..f34452f84a 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1238,6 +1238,7 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) { SExplainStmt* pStmt = (SExplainStmt*)pCxt->pAstRoot; pPlan->explainInfo.mode = pStmt->analyze ? EXPLAIN_MODE_ANALYZE : EXPLAIN_MODE_STATIC; pPlan->explainInfo.verbose = pStmt->pOptions->verbose; + pPlan->explainInfo.ratio = pStmt->pOptions->ratio; } else { pPlan->explainInfo.mode = EXPLAIN_MODE_DISABLE; } From bc4e73a3ddc3b1f6eff98b3dbe225bdd8a063a0a Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 11 Apr 2022 17:55:53 +0800 Subject: [PATCH 44/45] feat: optimize encode/decode resultRow --- source/libs/executor/src/executorimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index eff5555dd2..63cd6b77b4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -5360,8 +5360,8 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { taosMemoryFree(result); } } - } #endif + } closeAllResultRows(&pInfo->binfo.resultRowInfo); finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, From 8c27b944bac52f3356a80f991c43e5e8e40b9527 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 11 Apr 2022 18:54:31 +0800 Subject: [PATCH 45/45] fix[query]: disable the auto convert of ucs4 for taos_fetch_raw_block api. --- source/client/inc/clientInt.h | 4 +- source/client/src/clientImpl.c | 81 +++++++++++++++------------- source/client/src/clientMain.c | 6 +-- source/client/src/clientMsgHandler.c | 4 +- 4 files changed, 52 insertions(+), 43 deletions(-) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index ae1b34a3bd..562a1ce696 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -238,9 +238,9 @@ void initMsgHandleFp(); TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, uint16_t port); -void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr); +void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); -int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows); +int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4); int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 9938a2e1b9..2949d6eda6 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -13,7 +13,7 @@ static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet); static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest); static void destroySendMsgInfo(SMsgSendInfo* pMsgBody); -static int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp); +static int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4); static bool stringLengthCheck(const char* str, size_t maxsize) { if (str == NULL) { @@ -176,7 +176,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { SRetrieveTableRsp* pRsp = NULL; int32_t code = qExecCommand(pQuery->pRoot, &pRsp); if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { - code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp); + code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false); } return code; } @@ -616,7 +616,7 @@ static void doSetOneRowPtr(SReqResultInfo* pResultInfo) { } } -void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { +void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) { assert(pRequest != NULL); SReqResultInfo* pResultInfo = &pRequest->body.resInfo; @@ -637,7 +637,7 @@ void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { return NULL; } - pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData); + pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData, convertUcs4); if (pRequest->code != TSDB_CODE_SUCCESS) { pResultInfo->numOfRows = 0; return NULL; @@ -735,7 +735,42 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { return TSDB_CODE_SUCCESS; } -int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) { +static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) { + for (int32_t i = 0; i < numOfCols; ++i) { + int32_t type = pResultInfo->fields[i].type; + int32_t bytes = pResultInfo->fields[i].bytes; + + if (type == TSDB_DATA_TYPE_NCHAR) { + char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pResultInfo->convertBuf[i] = p; + + SResultColumn* pCol = &pResultInfo->pCol[i]; + for (int32_t j = 0; j < numOfRows; ++j) { + if (pCol->offset[j] != -1) { + char* pStart = pCol->offset[j] + pCol->pData; + + int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p)); + ASSERT(len <= bytes); + + varDataSetLen(p, len); + pCol->offset[j] = (p - pResultInfo->convertBuf[i]); + p += (len + VARSTR_HEADER_SIZE); + } + } + + pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i]; + pResultInfo->row[i] = pResultInfo->pCol[i].pData; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4) { assert(numOfCols > 0 && pFields != NULL && pResultInfo != NULL); if (numOfRows == 0) { return TSDB_CODE_SUCCESS; @@ -767,37 +802,11 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 } // convert UCS4-LE encoded character to native multi-bytes character in current data block. - for (int32_t i = 0; i < numOfCols; ++i) { - int32_t type = pResultInfo->fields[i].type; - int32_t bytes = pResultInfo->fields[i].bytes; - - if (type == TSDB_DATA_TYPE_NCHAR) { - char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]); - if (p == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pResultInfo->convertBuf[i] = p; - - SResultColumn* pCol = &pResultInfo->pCol[i]; - for (int32_t j = 0; j < numOfRows; ++j) { - if (pCol->offset[j] != -1) { - pStart = pCol->offset[j] + pCol->pData; - - int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p)); - ASSERT(len <= bytes); - - varDataSetLen(p, len); - pCol->offset[j] = (p - pResultInfo->convertBuf[i]); - p += (len + VARSTR_HEADER_SIZE); - } - } - - pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i]; - pResultInfo->row[i] = pResultInfo->pCol[i].pData; - } + if (convertUcs4) { + code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength); } - return TSDB_CODE_SUCCESS; + return code; } char* getDbOfConnection(STscObj* pObj) { @@ -829,7 +838,7 @@ void resetConnectDB(STscObj* pTscObj) { taosThreadMutexUnlock(&pTscObj->mutex); } -int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp) { +int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4) { assert(pResultInfo != NULL && pRsp != NULL); pResultInfo->pRspMsg = (const char*)pRsp; @@ -842,5 +851,5 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR // TODO handle the compressed case pResultInfo->totalRows += pResultInfo->numOfRows; - return setResultDataPtr(pResultInfo, pResultInfo->fields, pResultInfo->numOfCols, pResultInfo->numOfRows); + return setResultDataPtr(pResultInfo, pResultInfo->fields, pResultInfo->numOfCols, pResultInfo->numOfRows, convertUcs4); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e10cf5179e..51629510d0 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -168,7 +168,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { return NULL; } - return doFetchRow(pRequest, true); + return doFetchRow(pRequest, true, true); } int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) { @@ -404,7 +404,7 @@ int taos_fetch_block_s(TAOS_RES *res, int* numOfRows, TAOS_ROW *rows) { return 0; } - doFetchRow(pRequest, false); + doFetchRow(pRequest, false, true); // TODO refactor SReqResultInfo *pResultInfo = &pRequest->body.resInfo; @@ -426,7 +426,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int* numOfRows, void** pData) { return 0; } - doFetchRow(pRequest, false); + doFetchRow(pRequest, false, false); SReqResultInfo *pResultInfo = &pRequest->body.resInfo; diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 4314391743..99c6e81551 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -191,7 +191,7 @@ int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) pResInfo->completed = pRetrieve->completed; pResInfo->current = 0; - setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); +// setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pRetrieve->numOfRows, pRetrieve->completed, pRequest->body.showInfo.execId); @@ -225,7 +225,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) { pResInfo->pData = pFetchRsp->data; pResInfo->current = 0; - setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); +// setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pFetchRsp->numOfRows, pFetchRsp->completed, pRequest->body.showInfo.execId);