From e34da43e38220d01d70faf09c4db0490fe4e8be5 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Mon, 23 Oct 2023 19:32:44 +0800 Subject: [PATCH 01/45] feat: support pipelining of snap replication --- include/util/tdef.h | 2 + source/libs/sync/inc/syncInt.h | 4 +- source/libs/sync/inc/syncSnapshot.h | 19 ++- source/libs/sync/src/syncSnapshot.c | 251 +++++++++++++++++++++------- 4 files changed, 215 insertions(+), 61 deletions(-) diff --git a/include/util/tdef.h b/include/util/tdef.h index 7f8fe22340..9ea6240b1f 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -294,6 +294,8 @@ typedef enum ELogicConditionType { #define TSDB_SYNC_APPLYQ_SIZE_LIMIT 512 #define TSDB_SYNC_NEGOTIATION_WIN 512 +#define TSDB_SYNC_SNAP_BUFFER_SIZE 2048 + #define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index cec1a12024..637c18e97d 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -249,8 +249,8 @@ int32_t syncNodeOnRequestVote(SSyncNode* pNode, const SRpcMsg* pMsg); int32_t syncNodeOnRequestVoteReply(SSyncNode* pNode, const SRpcMsg* pMsg); int32_t syncNodeOnAppendEntries(SSyncNode* pNode, const SRpcMsg* pMsg); int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pMsg); -int32_t syncNodeOnSnapshot(SSyncNode* ths, const SRpcMsg* pMsg); -int32_t syncNodeOnSnapshotRsp(SSyncNode* ths, const SRpcMsg* pMsg); +int32_t syncNodeOnSnapshot(SSyncNode* ths, SRpcMsg* pMsg); +int32_t syncNodeOnSnapshotRsp(SSyncNode* ths, SRpcMsg* pMsg); int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pMsg); int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pMsg); int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pMsg); diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 95382132b5..0332204769 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -30,6 +30,15 @@ extern "C" { #define SYNC_SNAPSHOT_RETRY_MS 5000 +typedef struct SSyncSnapBuffer { + void *entries[TSDB_SYNC_SNAP_BUFFER_SIZE]; + int64_t start; + int64_t cursor; + int64_t end; + int64_t size; + TdThreadMutex mutex; +} SSyncSnapBuffer; + typedef struct SSyncSnapshotSender { int8_t start; int32_t seq; @@ -47,6 +56,9 @@ typedef struct SSyncSnapshotSender { int64_t lastSendTime; bool finish; + // buffer + SSyncSnapBuffer *pSndBuf; + // init when create SSyncNode *pSyncNode; int32_t replicaIndex; @@ -72,6 +84,9 @@ typedef struct SSyncSnapshotReceiver { SSnapshotParam snapshotParam; SSnapshot snapshot; + // buffer + SSyncSnapBuffer *pRcvBuf; + // init when create SSyncNode *pSyncNode; } SSyncSnapshotReceiver; @@ -83,8 +98,8 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver); bool snapshotReceiverIsStart(SSyncSnapshotReceiver *pReceiver); // on message -int32_t syncNodeOnSnapshot(SSyncNode *ths, const SRpcMsg *pMsg); -int32_t syncNodeOnSnapshotRsp(SSyncNode *ths, const SRpcMsg *pMsg); +// int32_t syncNodeOnSnapshot(SSyncNode *ths, const SRpcMsg *pMsg); +// int32_t syncNodeOnSnapshotRsp(SSyncNode *ths, const SRpcMsg *pMsg); SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode *pSyncNode, SyncIndex snapshotLastApplyIndex); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 924813eb98..43726307e6 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -23,6 +23,42 @@ #include "syncReplication.h" #include "syncUtil.h" +static void syncSnapBufferReset(SSyncSnapBuffer *pBuf) { + taosThreadMutexLock(&pBuf->mutex); + for (int64_t i = pBuf->start; i < pBuf->end; ++i) { + rpcFreeCont(pBuf->entries[i % pBuf->size]); + pBuf->entries[i % pBuf->size] = NULL; + } + pBuf->start = 1; + pBuf->end = 1; + pBuf->cursor = 0; + taosThreadMutexUnlock(&pBuf->mutex); +} + +static void syncSnapBufferDestroy(SSyncSnapBuffer **ppBuf) { + if (ppBuf == NULL || ppBuf[0] == NULL) return; + SSyncSnapBuffer *pBuf = ppBuf[0]; + + syncSnapBufferReset(pBuf); + + taosThreadMutexDestroy(&pBuf->mutex); + taosMemoryFree(ppBuf[0]); + ppBuf[0] = NULL; + return; +} + +static SSyncSnapBuffer *syncSnapBufferCreate() { + SSyncSnapBuffer *pBuf = taosMemoryCalloc(1, sizeof(SSyncSnapBuffer)); + if (pBuf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + pBuf->size = sizeof(pBuf->entries) / sizeof(void *); + ASSERT(pBuf->size == TSDB_SYNC_SNAP_BUFFER_SIZE); + taosThreadMutexInit(&pBuf->mutex, NULL); + return pBuf; +} + SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex) { bool condition = (pSyncNode->pFsm->FpSnapshotStartRead != NULL) && (pSyncNode->pFsm->FpSnapshotStopRead != NULL) && (pSyncNode->pFsm->FpSnapshotDoRead != NULL); @@ -49,6 +85,14 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; + pSender->pSndBuf = syncSnapBufferCreate(); + if (pSender->pSndBuf == NULL) { + taosMemoryFree(pSender); + pSender = NULL; + return NULL; + } + syncSnapBufferReset(pSender->pSndBuf); + return pSender; } @@ -67,6 +111,10 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { pSender->pReader = NULL; } + // free snap buffer + if (pSender->pSndBuf) { + syncSnapBufferDestroy(&pSender->pSndBuf); + } // free sender taosMemoryFree(pSender); } @@ -181,6 +229,8 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { pSender->pCurrentBlock = NULL; pSender->blockLen = 0; } + + syncSnapBufferReset(pSender->pSndBuf); } // when sender receive ack, call this function to send msg from seq @@ -193,6 +243,8 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { pSender->blockLen = 0; } + pSender->seq++; + // read data int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, &pSender->pCurrentBlock, &pSender->blockLen); @@ -362,6 +414,14 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->snapshot.lastApplyTerm = 0; pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; + pReceiver->pRcvBuf = syncSnapBufferCreate(); + if (pReceiver->pRcvBuf == NULL) { + taosMemoryFree(pReceiver); + pReceiver = NULL; + return NULL; + } + + syncSnapBufferReset(pReceiver->pRcvBuf); return pReceiver; } @@ -389,6 +449,11 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { pReceiver->snapshot.data = NULL; } + // free snap buf + if (pReceiver->pRcvBuf) { + syncSnapBufferDestroy(&pReceiver->pRcvBuf); + } + // free receiver taosMemoryFree(pReceiver); } @@ -472,6 +537,8 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { } else { sRInfo(pReceiver, "snapshot receiver stop, writer is null"); } + + syncSnapBufferReset(pReceiver->pRcvBuf); } // when recv last snapshot block, apply data into snapshot @@ -765,29 +832,8 @@ _SEND_REPLY: return code; } -static int32_t syncNodeOnSnapshotReceive(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { - // condition 4 - // transfering - SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; - int64_t timeNow = taosGetTimestampMs(); - int32_t code = 0; - - if (snapshotReceiverSignatureCmp(pReceiver, pMsg) != 0) { - terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; - sRError(pReceiver, "failed to receive snapshot data since %s.", terrstr()); - code = terrno; - goto _SEND_REPLY; - } - - if (snapshotReceiverGotData(pReceiver, pMsg) != 0) { - code = terrno; - if (code >= SYNC_SNAPSHOT_SEQ_INVALID) { - code = TSDB_CODE_SYN_INTERNAL_ERROR; - } - } - -_SEND_REPLY:; - +static int32_t syncSnapSendRsp(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pMsg, int32_t code) { + SSyncNode *pSyncNode = pReceiver->pSyncNode; // build msg SRpcMsg rpcMsg = {0}; if (syncBuildSnapshotSendRsp(&rpcMsg, 0, pSyncNode->vgId)) { @@ -811,10 +857,76 @@ _SEND_REPLY:; sRError(pReceiver, "failed to send snapshot receiver resp since %s", terrstr()); return -1; } + return 0; +} +static int32_t syncSnapBufferRecv(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend **ppMsg) { + int32_t code = 0; + SSyncSnapBuffer *pRcvBuf = pReceiver->pRcvBuf; + SyncSnapshotSend *pMsg = ppMsg[0]; + terrno = TSDB_CODE_SUCCESS; + + taosThreadMutexLock(&pRcvBuf->mutex); + + if (pMsg->seq - pRcvBuf->start >= pRcvBuf->size) { + terrno = TSDB_CODE_SYN_BUFFER_FULL; + code = terrno; + goto _out; + } + + ASSERT(pRcvBuf->start <= pRcvBuf->cursor + 1 && pRcvBuf->cursor < pRcvBuf->end); + + if (pMsg->seq > pRcvBuf->cursor) { + pRcvBuf->entries[pMsg->seq % pRcvBuf->size] = pMsg; + ppMsg[0] = NULL; + pRcvBuf->end = TMAX(pMsg->seq + 1, pRcvBuf->end); + } + + for (int64_t seq = pRcvBuf->cursor + 1; seq < pRcvBuf->end; ++seq) { + if (pRcvBuf->entries[seq]) { + pRcvBuf->cursor = seq; + } else { + break; + } + } + + for (int64_t seq = pRcvBuf->start; seq <= pRcvBuf->cursor; ++seq) { + if (snapshotReceiverGotData(pReceiver, pRcvBuf->entries[seq % pRcvBuf->size]) != 0) { + code = terrno; + if (code >= SYNC_SNAPSHOT_SEQ_INVALID) { + code = TSDB_CODE_SYN_INTERNAL_ERROR; + } + } + pRcvBuf->start = seq + 1; + syncSnapSendRsp(pReceiver, pRcvBuf->entries[seq % pRcvBuf->size], code); + rpcFreeCont(pRcvBuf->entries[seq % pRcvBuf->size]); + pRcvBuf->entries[seq % pRcvBuf->size] = NULL; + if (code) goto _out; + } + +_out: + taosThreadMutexUnlock(&pRcvBuf->mutex); return code; } +static int32_t syncNodeOnSnapshotReceive(SSyncNode *pSyncNode, SyncSnapshotSend **ppMsg) { + // condition 4 + // transfering + SyncSnapshotSend *pMsg = ppMsg[0]; + ASSERT(pMsg); + SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; + int64_t timeNow = taosGetTimestampMs(); + int32_t code = 0; + + if (snapshotReceiverSignatureCmp(pReceiver, pMsg) != 0) { + terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; + sRError(pReceiver, "failed to receive snapshot data since %s.", terrstr()); + return syncSnapSendRsp(pReceiver, pMsg, terrno); + } + + return syncSnapBufferRecv(pReceiver, ppMsg); +} + static int32_t syncNodeOnSnapshotEnd(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) { // condition 2 // end, finish FSM @@ -885,8 +997,10 @@ _SEND_REPLY:; // // condition 5, got data, update ack // -int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { - SyncSnapshotSend *pMsg = pRpcMsg->pCont; +int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { + SyncSnapshotSend **ppMsg = (SyncSnapshotSend **)&pRpcMsg->pCont; + SyncSnapshotSend *pMsg = ppMsg[0]; + ASSERT(pMsg); SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; // if already drop replica, do not process @@ -935,9 +1049,9 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { // force close, no response syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process force stop"); snapshotReceiverStop(pReceiver); - } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { + } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq <= SYNC_SNAPSHOT_SEQ_END) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq data"); - code = syncNodeOnSnapshotReceive(pSyncNode, pMsg); + code = syncNodeOnSnapshotReceive(pSyncNode, ppMsg); } else { // error log sRError(pReceiver, "snapshot receiver recv error seq:%d, my ack:%d", pMsg->seq, pReceiver->ack); @@ -1038,14 +1152,62 @@ static int32_t snapshotSenderSignatureCmp(SSyncSnapshotSender *pSender, SyncSnap return 0; } +static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp **ppMsg) { + int32_t code = 0; + SSyncSnapBuffer *pSndBuf = pSender->pSndBuf; + SyncSnapshotRsp *pMsg = ppMsg[0]; + + taosThreadMutexLock(&pSndBuf->mutex); + + if (pMsg->ack - pSndBuf->start >= pSndBuf->size) { + terrno = TSDB_CODE_SYN_BUFFER_FULL; + code = terrno; + goto _out; + } + + ASSERT(pSndBuf->start <= pSndBuf->cursor + 1 && pSndBuf->cursor < pSndBuf->end); + + if (pMsg->ack > pSndBuf->cursor && pSndBuf->entries[pMsg->ack % pSndBuf->size] == NULL) { + pSndBuf->entries[pMsg->ack % pSndBuf->size] = pMsg; + ppMsg[0] = NULL; + pSndBuf->end = TMAX(pMsg->ack + 1, pSndBuf->end); + } + + for (int64_t ack = pSndBuf->cursor + 1; ack < pSndBuf->end; ++ack) { + if (pSndBuf->entries[ack % pSndBuf->size]) { + pSndBuf->cursor = ack; + } else { + break; + } + } + + for (int64_t ack = pSndBuf->start; ack < pSndBuf->cursor; ++ack) { + rpcFreeCont(pSndBuf->entries[ack % pSndBuf->size]); + pSndBuf->entries[ack % pSndBuf->size] = NULL; + pSndBuf->start = ack + 1; + } + + while (pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) { + if (snapshotSend(pSender) != 0) { + code = terrno; + goto _out; + } + } + +_out: + taosThreadMutexUnlock(&pSndBuf->mutex); + return code; +} + // sender on message // // condition 1 sender receives SYNC_SNAPSHOT_SEQ_END, close sender // condition 2 sender receives ack, set seq = ack + 1, send msg from seq // condition 3 sender receives error msg, just print error log // -int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { - SyncSnapshotRsp *pMsg = pRpcMsg->pCont; +int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { + SyncSnapshotRsp **ppMsg = (SyncSnapshotRsp **)&pRpcMsg->pCont; + SyncSnapshotRsp *pMsg = ppMsg[0]; // if already drop replica, do not process if (!syncNodeInRaftGroup(pSyncNode, &pMsg->srcId)) { @@ -1123,12 +1285,8 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq begin"); - if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { - return -1; - } - if (snapshotSend(pSender) != 0) { - return -1; + goto _ERROR; } return 0; } @@ -1142,30 +1300,9 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { } // send next msg - if (pMsg->ack == pSender->seq) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq data"); - // update sender ack - if (snapshotSenderUpdateProgress(pSender, pMsg) != 0) { - return -1; - } - if (snapshotSend(pSender) != 0) { - return -1; - } - } else if (pMsg->ack == pSender->seq - 1) { - // maybe resend - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq and resend"); - if (snapshotReSend(pSender) != 0) { - return -1; - } - } else { - // error log - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error ack"); - sSError(pSender, "snapshot sender receive error ack:%d, my seq:%d", pMsg->ack, pSender->seq); - snapshotSenderStop(pSender, true); - syncNodeReplicateReset(pSyncNode, &pMsg->srcId); - return -1; + if (syncSnapBufferSend(pSender, ppMsg) != 0) { + goto _ERROR; } - return 0; _ERROR: From f299a2810944c47d71188ec7f27fe89de841018c Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Thu, 19 Oct 2023 11:34:04 +0800 Subject: [PATCH 02/45] feat: support to_timestamp/to_char --- docs/en/12-taos-sql/10-function.md | 83 ++ docs/zh/12-taos-sql/10-function.md | 83 ++ include/common/ttime.h | 21 + include/libs/function/functionMgt.h | 2 + include/libs/scalar/scalar.h | 2 + include/util/taoserror.h | 1 + include/util/tdef.h | 9 + source/common/src/ttime.c | 877 +++++++++++++++++- source/common/test/commonTests.cpp | 225 ++++- source/libs/function/src/builtins.c | 48 + source/libs/scalar/src/sclfunc.c | 56 ++ source/util/src/terror.c | 1 + tests/parallel_test/cases.task | 4 + .../2-query/func_to_char_timestamp.py | 160 ++++ 14 files changed, 1566 insertions(+), 6 deletions(-) create mode 100644 tests/system-test/2-query/func_to_char_timestamp.py diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 340a3e917b..266cdb4958 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -483,6 +483,89 @@ return_timestamp: { - The precision of the returned timestamp is same as the precision set for the current data base in use - return_timestamp indicates whether the returned value type is TIMESTAMP or not. If this parameter set to 1, function will return TIMESTAMP type. Otherwise function will return BIGINT type. If parameter is omitted, default return value type is BIGINT. +#### TO_CHAR + +```sql +TO_CHAR(ts, str_literal) +``` + +**Description**: Convert a ts column to string as the format specified + +**Return value type**: VARCHAR + +**Applicable column types**: TIMESTAMP + +**Nested query**: It can be used in both the outer query and inner query in a nested query. + +**Applicable table types**: standard tables and supertables + +**Supported Formats** + +| **Format** | **Comment**| **example** | +| --- | --- | --- | +|AM,am,PM,pm| Meridiem indicator(without periods) | 07:00:00am| +|A.M.,a.m.,P.M.,p.m.| Meridiem indicator(with periods)| 07:00:00a.m.| +|YYYY,yyyy|year, 4 or more digits| 2023-10-10| +|YYY,yyy| year, last 3 digits| 023-10-10| +|YY,yy| year, last 2 digits| 23-10-10| +|Y,y| year, last digit| 3-10-10| +|MONTH|full uppercase of month| 2023-JANUARY-01| +|Month|full capitalized month| 2023-January-01| +|month|full lowercase of month| 2023-january-01| +|MON| abbreviated uppercase of month(3 char)| JAN, SEP| +|Mon| abbreviated capitalized month| Jan, Sep| +|mon|abbreviated lowercase of month| jan, sep| +|MM,mm|month number 01-12|2023-01-01| +|DD,dd|month day, 01-31|| +|DAY|full uppercase of week day|MONDAY| +|Day|full capitalized week day|Monday| +|day|full lowercase of week day|monday| +|DY|abbreviated uppercase of week day|MON| +|Dy|abbreviated capitalized week day|Mon| +|dy|abbreviated lowercase of week day|mon| +|DDD|year day, 001-366|| +|D,d|week day number, 1-7, Sunday(1) to Saturday(7)|| +|HH24,hh24|hour of day, 00-23|2023-01-30 23:59:59| +|hh12,HH12, hh, HH| hour of day, 01-12|2023-01-30 12:59:59PM| +|MI,mi|minute, 00-59|| +|SS,ss|second, 00-59|| +|MS,ms|milli second, 000-999|| +|US,us|micro second, 000000-999999|| +|NS,ns|nano second, 000000000-999999999|| +|TZH,tzh|time zone hour|2023-01-30 11:59:59PM +08| + +**More explanations**: +- The output format of `Month`, `Day` are left aligined, like`2023-OCTOBER -01`, `2023-SEPTEMBER-01`, `September` is the longest, no paddings. Week days are slimilar. +- When `ms`,`us`,`ns` are used in `to_char`, like `to_char(ts, 'yyyy-mm-dd hh:mi:ss.ms.us.ns')`, The time of `ms`,`us`,`ns` corresponds to the same fraction seconds. When ts is `1697182085123`, the output of `ms` is `123`, `us` is `123000`, `ns` is `123000000`. +- If we want to output some characters of format without converting, surround it with double quotes. `to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. If want to output double quotes, add a back slash before double quote, like `to_char(ts, '\"yyyy-mm-dd\"')` will output `"2023-10-10"`. +- For formats that output digits, the uppercase and lowercase formats are the same. + +#### TO_TIMESTAMP + +```sql +TO_TIMESTAMP(str_literal, str_literal) +``` + +**Description**: Convert a formated timestamp string to a timestamp + +**Return value type**: TIMESTAMP + +**Applicable column types**: VARCHAR + +**Nested query**: It can be used in both the outer query and inner query in a nested query. + +**Applicable table types**: standard tables and supertables + +**Supported Formats**: The same as `TO_CHAR`. + +**More explanations**: +- When `ms`, `us`, `ns` are used in `to_timestamp`, if multi of them are specified, the results are accumulated. For example, `to_timestamp('2023-10-10 10:10:10.123.000456.000000789', 'yyyy-mm-dd hh:mi:ss.ms.us.ns')` will output the timestamp of `2023-10-10 10:10:10.123456789`. +- The uppercase or lowercase of `MONTH`, `MON`, `DAY`, `DY` and formtas that output digits have same effect when used in `to_timestamp`, like `to_timestamp('2023-JANUARY-01', 'YYYY-month-dd')`, `month` can be replaced by `MONTH`, or `month`. The cases are ignored. +- If multi times are specified for one component, the previous will be overwritten. Like `to_timestamp('2023-22-10-10', 'yyyy-yy-MM-dd')`, the output year will be `2022`. +- The default timetsamp if some components are not specified will be: `1970-01-01 00:00:00` with your local timezone. +- If `AM` or `PM` is specified in formats, the Hour must between `1-12`. +- In some cases, `to_timestamp` can convert correctly even the format and the timestamp string are not totally matched. Like `to_timetamp('200101/2', 'yyyyMM1/dd')`, the digit `1` in format string are ignored, and the output timestsamp is `2001-01-02 00:00:00`. Spaces and tabs in formats and tiemstamp string are also ignored automatically. + ### Time and Date Functions diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 8b87a18e54..806ff3c6a8 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -483,6 +483,89 @@ return_timestamp: { - 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 - return_timestamp 指定函数返回值是否为时间戳类型,设置为1时返回 TIMESTAMP 类型,设置为0时返回 BIGINT 类型。如不指定缺省返回 BIGINT 类型。 +#### TO_CHAR + +```sql +TO_CHAR(ts, str_literal) +``` + +**功能说明**: 将timestamp类型按照指定格式转换为字符串 + +**返回结果数据类型**: VARCHAR + +**应用字段**: TIMESTAMP + +**嵌套子查询支持**: 适用于内层查询和外层查询 + +**适用于**: 表和超级表 + +**支持的格式** + +| **格式** | **说明**| **例子** | +| --- | --- | --- | +|AM,am,PM,pm| 无点分隔的上午下午 | 07:00:00am| +|A.M.,a.m.,P.M.,p.m.| 有点分割的上午下午| 07:00:00a.m.| +|YYYY,yyyy|年, 4个及以上数字| 2023-10-10| +|YYY,yyy| 年, 最后3位数字| 023-10-10| +|YY,yy| 年, 最后2位数字| 23-10-10| +|Y,y|年, 最后一位数字| 3-10-10| +|MONTH|月, 全大写| 2023-JANUARY-01| +|Month|月, 首字母大写| 2023-January-01| +|month|月, 全小写| 2023-january-01| +|MON| 月, 缩写, 全大写(三个字符)| JAN, SEP| +|Mon| 月, 缩写, 首字母大写| Jan, Sep| +|mon|月, 缩写, 全小写| jan, sep| +|MM,mm|月, 数字 01-12|2023-01-01| +|DD,dd|月日, 01-31|| +|DAY|周日, 全大写|MONDAY| +|Day|周日, 首字符大写|Monday| +|day|周日, 全小写|monday| +|DY|周日, 缩写, 全大写|MON| +|Dy|周日, 缩写, 首字符大写|Mon| +|dy|周日, 缩写, 全小写|mon| +|DDD|年日, 001-366|| +|D,d|周日, 数字, 1-7, Sunday(1) to Saturday(7)|| +|HH24,hh24|小时, 00-23|2023-01-30 23:59:59| +|hh12,HH12, hh, HH| 小时, 01-12|2023-01-30 12:59:59PM| +|MI,mi|分钟, 00-59|| +|SS,ss|秒, 00-59|| +|MS,ms|毫秒, 000-999|| +|US,us|微秒, 000000-999999|| +|NS,ns|纳秒, 000000000-999999999|| +|TZH,tzh|时区小时|2023-01-30 11:59:59PM +08| + +**使用说明**: +- `Month`, `Day`等的输出格式是左对齐的, 右侧添加空格, 如`2023-OCTOBER -01`, `2023-SEPTEMBER-01`, 9月是月份中英文字母数最长的, 因此9月没有空格. 星期类似. +- 使用`ms`, `us`, `ns`时, 以上三种格式的输出只在精度上不同, 比如ts为 `1697182085123`, `ms` 的输出为 `123`, `us` 的输出为 `123000`, `ns` 的输出为 `123000000`. +- 如果想要在格式串中指定某些部分不做转换, 可以使用双引号, 如`to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. 如果想要输出双引号, 那么在双引号之前加一个反斜杠, 如 `to_char(ts, '\"yyyy-mm-dd\"')` 将会输出 `"2023-10-10"`. +- 那些输出是数字的格式, 如`YYYY`, `DD`, 大写与小写意义相同, 即`yyyy` 和 `YYYY` 可以互换. + +#### TO_TIMESTAMP + +```sql +TO_TIMESTAMP(str_literal, str_literal) +``` + +**功能说明**: 将字符串按照指定格式转化为时间戳. + +**返回结果数据类型**: TIMESTAMP + +**应用字段**: VARCHAR + +**嵌套子查询支持**: 适用于内层查询和外层查询 + +**适用于**: 表和超级表 + +**支持的格式**: 与`to_char`相同 + +**使用说明**: +- 若`ms`, `us`, `ns`同时指定, 那么结果时间戳包含上述三个字段的和. 如 `to_timestamp('2023-10-10 10:10:10.123.000456.000000789', 'yyyy-mm-dd hh:mi:ss.ms.us.ns')` 输出是 `2023-10-10 10:10:10.123456789`. +- `MONTH`, `MON`, `DAY`, `DY` 以及其他输出为数字的格式的大小写意义相同, 如 `to_timestamp('2023-JANUARY-01', 'YYYY-month-dd')`, `month`可以被替换为`MONTH` 或者`Month`. +- 如果同一字段被指定了多次, 那么前面的指定将会被覆盖. 如 `to_timestamp('2023-22-10-10', 'yyyy-yy-MM-dd')`, 输出年份是`2022`. +- 如果某些部分没有指定 那么默认时间为本地时区的 `1970-01-01 00:00:00`, 未指定部分为对应默认值. +- 如果格式串中有`AM`, `PM`等, 那么小时必须是12小时制, 范围必须是01-12. +- `to_timestamp`转换具有一定的容错机制, 在格式串和时间戳串不完全对应时, 有时也可转换, 如: `to_timestamp('200101/2', 'yyyyMM1/dd')`, 格式串中多出来的1会被丢弃. 格式串与时间戳串中多余的空格字符(空格, tab等)也会被 自动忽略. 如`to_timestamp(' 23 年 - 1 月 - 01 日 ', 'yy 年-MM月-dd日')` 可以被成功转换. 虽然`MM`等字段需要两个数字对应(只有一位时前面补0), 在`to_timestamp`时, 一个数字也可以成功转换. + ### 时间和日期函数 diff --git a/include/common/ttime.h b/include/common/ttime.h index 37e3045817..75bbcddd0e 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -90,6 +90,27 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision); +struct STm { + struct tm tm; + int64_t fsec; // in NANOSECOND +}; + +int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm); +int32_t taosTm2Ts(struct STm* tm, int64_t* ts, int32_t precision); + +/// @brief convert a timestamp to a formatted string +/// @param format the timestamp format, must null terminated +void taosTs2Char(const char* format, int64_t ts, int32_t precision, char* out); +/// @brief convert a formatted timestamp string to a timestamp +/// @param format must null terminated +/// @param tsStr must null terminated +/// @retval 0 for success, otherwise error occured +int32_t taosChar2Ts(const char* format, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, + int32_t errMsgLen); + +void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out); +int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr); + #ifdef __cplusplus } #endif diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 48c2210f46..865f1b2295 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -94,6 +94,8 @@ typedef enum EFunctionType { FUNCTION_TYPE_TO_ISO8601, FUNCTION_TYPE_TO_UNIXTIMESTAMP, FUNCTION_TYPE_TO_JSON, + FUNCTION_TYPE_TO_TIMESTAMP, + FUNCTION_TYPE_TO_CHAR, // date and time function FUNCTION_TYPE_NOW = 2500, diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 2e6652f860..789ba554e2 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -80,6 +80,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t toTimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t toCharFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 39ae3fb97a..10784bdb0c 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -739,6 +739,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_FUNC_FUNTION_PARA_VALUE TAOS_DEF_ERROR_CODE(0, 0x2803) #define TSDB_CODE_FUNC_NOT_BUILTIN_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2804) #define TSDB_CODE_FUNC_DUP_TIMESTAMP TAOS_DEF_ERROR_CODE(0, 0x2805) +#define TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED TAOS_DEF_ERROR_CODE(0, 0x2806) //udf #define TSDB_CODE_UDF_STOPPING TAOS_DEF_ERROR_CODE(0, 0x2901) diff --git a/include/util/tdef.h b/include/util/tdef.h index 287617970c..14c507b9a2 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -109,6 +109,15 @@ extern const int32_t TYPE_BYTES[21]; #define TSDB_INS_USER_STABLES_DBNAME_COLID 2 +static const int64_t TICK_PER_SECOND[] = { + 1000LL, // MILLISECOND + 1000000LL, // MICROSECOND + 1000000000LL, // NANOSECOND + 0LL, // HOUR + 0LL, // MINUTE + 1LL // SECOND +}; + #define TSDB_TICK_PER_SECOND(precision) \ ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI \ ? 1000LL \ diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 425218f0e1..3450e32f4a 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -25,7 +25,6 @@ #include "tlog.h" - // ==== mktime() kernel code =================// static int64_t m_deltaUtc = 0; @@ -679,7 +678,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) { } // The following code handles the y/n time duration - int64_t numOfMonth = (unit == 'y')? duration*12:duration; + int64_t numOfMonth = (unit == 'y') ? duration * 12 : duration; int64_t fraction = t % TSDB_TICK_PER_SECOND(precision); struct tm tm; @@ -722,7 +721,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) { * Total num of windows is ret + 1(the first window) */ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision, - int32_t order) { + int32_t order) { if (ekey < skey) { int64_t tmp = ekey; ekey = skey; @@ -765,7 +764,6 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) { int32_t precision = pInterval->precision; if (IS_CALENDAR_TIME_DURATION(pInterval->slidingUnit)) { - start /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); struct tm tm; time_t tt = (time_t)start; @@ -796,7 +794,7 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) { int64_t newe = taosTimeAdd(news, pInterval->interval, pInterval->intervalUnit, precision) - 1; if (newe < ts) { // move towards the greater endpoint - while(newe < ts && news < ts) { + while (newe < ts && news < ts) { news += pInterval->sliding; newe = taosTimeAdd(news, pInterval->interval, pInterval->intervalUnit, precision) - 1; } @@ -975,3 +973,872 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) tstrncpy(buf, ts, bufLen); } + +int32_t taosTs2Tm(int64_t ts, int32_t precision, struct STm* tm) { + tm->fsec = ts % TICK_PER_SECOND[precision] * (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]); + time_t t = ts / TICK_PER_SECOND[precision]; + taosLocalTime(&t, &tm->tm, NULL); + return TSDB_CODE_SUCCESS; +} + +int32_t taosTm2Ts(struct STm* tm, int64_t* ts, int32_t precision) { + *ts = taosMktime(&tm->tm); + *ts *= TICK_PER_SECOND[precision]; + *ts += tm->fsec / (TICK_PER_SECOND[TSDB_TIME_PRECISION_NANO] / TICK_PER_SECOND[precision]); + return TSDB_CODE_SUCCESS; +} + +typedef struct { + const char* name; + int len; + int id; + bool isDigit; +} TSFormatKeyWord; + +typedef enum { + // TSFKW_AD, // BC AD + // TSFKW_A_D, // A.D. B.C. + TSFKW_AM, // AM, PM + TSFKW_A_M, // A.M., P.M. + // TSFKW_BC, // BC AD + // TSFKW_B_C, // B.C. A.D. + TSFKW_DAY, // MONDAY, TUESDAY ... + TSFKW_DDD, // Day of year 001-366 + TSFKW_DD, // Day of month 01-31 + TSFKW_Day, // Sunday, Monday + TSFKW_DY, // MON, TUE + TSFKW_Dy, // Mon, Tue + TSFKW_dy, // mon, tue + TSFKW_D, // 1-7 -> Sunday(1) -> Saturday(7) + TSFKW_HH24, + TSFKW_HH12, + TSFKW_HH, + TSFKW_MI, // minute + TSFKW_MM, + TSFKW_MONTH, // JANUARY, FEBRUARY + TSFKW_MON, + TSFKW_Month, + TSFKW_Mon, + TSFKW_MS, + TSFKW_NS, + TSFKW_OF, + TSFKW_PM, + TSFKW_P_M, + TSFKW_SS, + // TSFKW_TZM, + TSFKW_TZH, + // TSFKW_TZ, + TSFKW_US, + TSFKW_YYYY, + TSFKW_YYY, + TSFKW_YY, + TSFKW_Y, + // TSFKW_a_d, + // TSFKW_ad, + TSFKW_am, + TSFKW_a_m, + // TSFKW_b_c, + // TSFKW_bc, + TSFKW_d, + TSFKW_day, + TSFKW_ddd, + TSFKW_dd, + TSFKW_hh24, + TSFKW_hh12, + TSFKW_hh, + TSFKW_mm, + TSFKW_month, + TSFKW_mon, + TSFKW_ms, + TSFKW_ns, + TSFKW_pm, + TSFKW_p_m, + TSFKW_ss, + TSFKW_tzh, + // TSFKW_tzm, + // TSFKW_tz, + TSFKW_us, + TSFKW_yyyy, + TSFKW_yyy, + TSFKW_yy, + TSFKW_y, + TSFKW_last_ +} TSFormatKeywordId; + +// clang-format off +static const TSFormatKeyWord formatKeyWords[] = { + //{"A.D.", 4, TSFKW_A_D}, + {"A.M.", 4, TSFKW_A_M, false}, + //{"AD", 2, TSFKW_AD, false}, + {"AM", 2, TSFKW_AM, false}, + //{"B.C.", 4, TSFKW_B_C, false}, + //{"BC", 2, TSFKW_BC, false}, + {"DAY", 3, TSFKW_DAY, false}, + {"DDD", 3, TSFKW_DDD, true}, + {"DD", 2, TSFKW_DD, true}, + {"DY", 2, TSFKW_DY, false}, + {"Day", 3, TSFKW_Day, false}, + {"Dy", 2, TSFKW_Dy, false}, + {"D", 1, TSFKW_D, true}, + {"HH24", 4, TSFKW_HH24, true}, + {"HH12", 4, TSFKW_HH12, true}, + {"HH", 2, TSFKW_HH, true}, + {"MI", 2, TSFKW_MI, true}, + {"MM", 2, TSFKW_MM, true}, + {"MONTH", 5, TSFKW_MONTH, false}, + {"MON", 3, TSFKW_MON, false}, + {"MS", 2, TSFKW_MS, true}, + {"Month", 5, TSFKW_Month, false}, + {"Mon", 3, TSFKW_Mon, false}, + {"NS", 2, TSFKW_NS, true}, + //{"OF", 2, TSFKW_OF, false}, + {"P.M.", 4, TSFKW_P_M, false}, + {"PM", 2, TSFKW_PM, false}, + {"SS", 2, TSFKW_SS, true}, + {"TZH", 3, TSFKW_TZH, false}, + //{"TZM", 3, TSFKW_TZM}, + //{"TZ", 2, TSFKW_TZ}, + {"US", 2, TSFKW_US, true}, + {"YYYY", 4, TSFKW_YYYY, true}, + {"YYY", 3, TSFKW_YYY, true}, + {"YY", 2, TSFKW_YY, true}, + {"Y", 1, TSFKW_Y, true}, + //{"a.d.", 4, TSFKW_a_d, false}, + {"a.m.", 4, TSFKW_a_m, false}, + //{"ad", 2, TSFKW_ad, false}, + {"am", 2, TSFKW_am, false}, + //{"b.c.", 4, TSFKW_b_c, false}, + //{"bc", 2, TSFKW_bc, false}, + {"day", 3, TSFKW_day, false}, + {"ddd", 3, TSFKW_DDD, true}, + {"dd", 2, TSFKW_DD, true}, + {"dy", 2, TSFKW_dy, false}, + {"d", 1, TSFKW_D, true}, + {"hh24", 4, TSFKW_HH24, true}, + {"hh12", 4, TSFKW_HH12, true}, + {"hh", 2, TSFKW_HH, true}, + {"mi", 2, TSFKW_MI, true}, + {"mm", 2, TSFKW_MM, true}, + {"month", 5, TSFKW_month, false}, + {"mon", 3, TSFKW_mon, false}, + {"ms", 2, TSFKW_MS, true}, + {"ns", 2, TSFKW_NS, true}, + //{"of", 2, TSFKW_OF, false}, + {"p.m.", 4, TSFKW_p_m, false}, + {"pm", 2, TSFKW_pm, false}, + {"ss", 2, TSFKW_SS, true}, + {"tzh", 3, TSFKW_TZH, false}, + //{"tzm", 3, TSFKW_TZM}, + //{"tz", 2, TSFKW_tz}, + {"us", 2, TSFKW_US, true}, + {"yyyy", 4, TSFKW_YYYY, true}, + {"yyy", 3, TSFKW_YYY, true}, + {"yy", 2, TSFKW_YY, true}, + {"y", 1, TSFKW_Y, true}, + {NULL, 0, 0} +}; +// clang-format on + +typedef struct { + uint8_t type; + char c[2]; + const TSFormatKeyWord* key; +} TSFormatNode; + +static const char* const weekDays[] = {"Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", "NULL"}; +static const char* const shortWeekDays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "NULL"}; +static const char* const fullMonths[] = {"January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December", NULL}; +static const char* const months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", + "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; +#define A_M_STR "A.M." +#define a_m_str "a.m." +#define AM_STR "AM" +#define am_str "am" +#define P_M_STR "P.M." +#define p_m_str "p.m." +#define PM_STR "PM" +#define pm_str "pm" +static const char* const apms[] = {AM_STR, PM_STR, am_str, pm_str, NULL}; +static const char* const long_apms[] = {A_M_STR, P_M_STR, a_m_str, p_m_str, NULL}; + +#define TS_FORMAT_NODE_TYPE_KEYWORD 1 +#define TS_FORMAT_NODE_TYPE_SEPARATOR 2 +#define TS_FORMAT_NODE_TYPE_CHAR 3 + +static const TSFormatKeyWord* keywordSearch(const char* str) { + if (*str < 'A' || *str > 'z' || (*str > 'Z' && *str < 'a')) return NULL; + int32_t idx = 0; + const TSFormatKeyWord* key = &formatKeyWords[idx++]; + while (key->name) { + if (0 == strncmp(key->name, str, key->len)) { + return key; + } + key = &formatKeyWords[idx++]; + } + return NULL; +} + +static bool isSeperatorChar(char c) { + return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9')); +} + +static void parseTsFormat(const char* format_str, SArray* formats) { + while (*format_str) { + const TSFormatKeyWord* key = keywordSearch(format_str); + if (key) { + TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD}; + taosArrayPush(formats, &format); + format_str += key->len; + } else { + if (*format_str == '"') { + // for double quoted string + format_str++; + while (*format_str) { + if (*format_str == '"') { + format_str++; + break; + } + if (*format_str == '\\' && *(format_str + 1)) format_str++; + TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL}; + format.c[0] = *format_str; + format.c[1] = '\0'; + taosArrayPush(formats, &format); + format_str++; + } + } else { + // for other strings + if (*format_str == '\\' && *(format_str + 1)) format_str++; + TSFormatNode format = { + .type = isSeperatorChar(*format_str) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR, + .key = NULL}; + format.c[0] = *format_str; + format.c[1] = '\0'; + taosArrayPush(formats, &format); + format_str++; + } + } + } +} + +static void tm2char(const SArray* formats, const struct STm* tm, char* s) { + int32_t size = taosArrayGetSize(formats); + for (int32_t i = 0; i < size; ++i) { + TSFormatNode* format = taosArrayGet(formats, i); + if (format->type != TS_FORMAT_NODE_TYPE_KEYWORD) { + strcpy(s, format->c); + s += strlen(s); + continue; + } + + switch (format->key->id) { + case TSFKW_AM: + case TSFKW_PM: + sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "PM" : "AM"); + s += strlen(s); + break; + case TSFKW_A_M: + case TSFKW_P_M: + sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "P.M." : "A.M."); + s += strlen(s); + break; + case TSFKW_am: + case TSFKW_pm: + sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "pm" : "am"); + s += strlen(s); + break; + case TSFKW_a_m: + case TSFKW_p_m: + sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "p.m." : "a.m."); + s += strlen(s); + break; + case TSFKW_DDD: + sprintf(s, "%d", tm->tm.tm_yday); + s += strlen(s); + break; + case TSFKW_DD: + sprintf(s, "%02d", tm->tm.tm_mday); + s += strlen(s); + break; + case TSFKW_D: + sprintf(s, "%d", tm->tm.tm_wday + 1); + s += strlen(s); + break; + case TSFKW_DAY: { + // MONDAY, TUESDAY... + const char* wd = weekDays[tm->tm.tm_wday]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = toupper(wd[i]); + sprintf(s, "%-9s", buf); + s += strlen(s); + break; + } + case TSFKW_Day: + // Monday, TuesDay... + sprintf(s, "%-9s", weekDays[tm->tm.tm_wday]); + s += strlen(s); + break; + case TSFKW_day: { + const char* wd = weekDays[tm->tm.tm_wday]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = tolower(wd[i]); + sprintf(s, "%-9s", buf); + s += strlen(s); + break; + } + case TSFKW_DY: { + // MON, TUE + const char* wd = shortWeekDays[tm->tm.tm_wday]; + char buf[8] = {0}; + for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = toupper(wd[i]); + sprintf(s, "%3s", buf); + s += strlen(s); + break; + } + case TSFKW_Dy: + // Mon, Tue + sprintf(s, "%3s", shortWeekDays[tm->tm.tm_wday]); + s += strlen(s); + break; + case TSFKW_dy: { + // mon, tue + const char* wd = shortWeekDays[tm->tm.tm_wday]; + char buf[8] = {0}; + for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = tolower(wd[i]); + sprintf(s, "%3s", buf); + s += strlen(s); + break; + } + case TSFKW_HH24: + sprintf(s, "%02d", tm->tm.tm_hour); + s += strlen(s); + break; + case TSFKW_HH: + case TSFKW_HH12: + // 0 or 12 o'clock in 24H coresponds to 12 o'clock (AM/PM) in 12H + sprintf(s, "%02d", tm->tm.tm_hour % 12 == 0 ? 12 : tm->tm.tm_hour % 12); + s += strlen(s); + break; + case TSFKW_MI: + sprintf(s, "%02d", tm->tm.tm_min); + s += strlen(s); + break; + case TSFKW_MM: + sprintf(s, "%02d", tm->tm.tm_mon + 1); + s += strlen(s); + break; + case TSFKW_MONTH: { + const char* mon = fullMonths[tm->tm.tm_mon]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = toupper(mon[i]); + sprintf(s, "%-9s", buf); + s += strlen(s); + break; + } + case TSFKW_MON: { + const char* mon = months[tm->tm.tm_mon]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = toupper(mon[i]); + sprintf(s, "%s", buf); + s += strlen(s); + break; + } + case TSFKW_Month: + sprintf(s, "%-9s", fullMonths[tm->tm.tm_mon]); + s += strlen(s); + break; + case TSFKW_month: { + const char* mon = fullMonths[tm->tm.tm_mon]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = tolower(mon[i]); + sprintf(s, "%-9s", buf); + s += strlen(s); + break; + } + case TSFKW_Mon: + sprintf(s, "%s", months[tm->tm.tm_mon]); + s += strlen(s); + break; + case TSFKW_mon: { + const char* mon = months[tm->tm.tm_mon]; + char buf[10] = {0}; + for (int32_t i = 0; i < strlen(mon); ++i) buf[i] = tolower(mon[i]); + sprintf(s, "%s", buf); + s += strlen(s); + break; + } + case TSFKW_SS: + sprintf(s, "%02d", tm->tm.tm_sec); + s += strlen(s); + break; + case TSFKW_MS: + sprintf(s, "%03" PRId64, tm->fsec / 1000000L); + s += strlen(s); + break; + case TSFKW_US: + sprintf(s, "%06" PRId64, tm->fsec / 1000L); + s += strlen(s); + break; + case TSFKW_NS: + sprintf(s, "%09" PRId64, tm->fsec); + s += strlen(s); + break; + case TSFKW_TZH: + sprintf(s, "%s%02d", tsTimezone < 0 ? "-" : "+", tsTimezone); + s += strlen(s); + break; + case TSFKW_YYYY: + sprintf(s, "%04d", tm->tm.tm_year + 1900); + s += strlen(s); + break; + case TSFKW_YYY: + sprintf(s, "%03d", (tm->tm.tm_year + 1900) % 1000); + s += strlen(s); + break; + case TSFKW_YY: + sprintf(s, "%02d", (tm->tm.tm_year + 1900) % 100); + s += strlen(s); + break; + case TSFKW_Y: + sprintf(s, "%01d", (tm->tm.tm_year + 1900) % 10); + s += strlen(s); + break; + default: + break; + } + } +} + +/// @brief find s in arr case insensitively +/// @retval the index in arr if found, -1 if not found +static int32_t strArrayCaseSearch(const char* const* arr, const char* s) { + if (!*s) return -1; + const char* const* fmt = arr; + for (; *fmt; ++fmt) { + const char *l, *r; + for (l = fmt[0], r = s;; l++, r++) { + if (*l == '\0') return fmt - arr; + if (*r == '\0' || tolower(*l) != tolower(*r)) break; + } + } + return -1; +} + +static const char* tsFormatStr2Int32(int32_t* dest, const char* str, int32_t len, bool needMoreDigit) { + char* last; + int64_t res; + const char* s = str; + if (len <= 0) { + res = taosStr2Int64(s, &last, 10); + s = last; + } else { + char buf[16] = {0}; + strncpy(buf, s, len); + int32_t copiedLen = strlen(buf); + if (copiedLen < len) { + if (!needMoreDigit) { + // digits not enough, that's ok, cause we do not need more digits + // '2023-1' 'YYYY-MM' + // '202a' 'YYYY' -> 202 + res = taosStr2Int64(s, &last, 10); + s += copiedLen; + } else { + // bytes not enough, and there are other digit formats to match + // '2023-1' 'YYYY-MMDD' + return NULL; + } + } else { + if (needMoreDigit) { + res = taosStr2Int64(buf, &last, 10); + // bytes enough, but digits not enough, like '202a12' 'YYYYMM', YYYY needs four digits + if (last - buf < len) return NULL; + s += last - buf; + } else { + res = taosStr2Int64(s, &last, 10); + s = last; + } + } + } + if (s == str) { + // no integers found + return NULL; + } + if (errno == ERANGE || res > INT32_MAX || res < INT32_MIN) { + // out of range + return NULL; + } + *dest = res; + return s; +} + +static int32_t adjustYearTo2020(int32_t year) { + if (year < 70) return year + 2000; // 2000 - 2069 + if (year < 100) return year + 1900; // 1970 - 1999 + if (year < 520) return year + 2000; // 2100 - 2519 + if (year < 1000) return year + 1000; // 1520 - 1999 + return year; +} + +static bool checkTm(const struct tm* tm) { + if (tm->tm_mon < 0 || tm->tm_mon > 11) return false; + if (tm->tm_wday < 0 || tm->tm_wday > 6) return false; + if (tm->tm_yday < 0 || tm->tm_yday > 365) return false; + if (tm->tm_mday < 0 || tm->tm_mday > 31) return false; + if (tm->tm_hour < 0 || tm->tm_hour > 23) return false; + if (tm->tm_min < 0 || tm->tm_min > 59) return false; + if (tm->tm_sec < 0 || tm->tm_sec > 60) return false; + return true; +} + +static bool needMoreDigits(SArray* formats, int32_t curIdx) { + if (curIdx == taosArrayGetSize(formats) - 1) return false; + TSFormatNode* pNextNode = taosArrayGet(formats, curIdx + 1); + if (pNextNode->type == TS_FORMAT_NODE_TYPE_SEPARATOR) { + return false; + } else if (pNextNode->type == TS_FORMAT_NODE_TYPE_KEYWORD) { + return pNextNode->key->isDigit; + } else { + return isdigit(pNextNode->c[0]); + } +} + +/// @brief convert a formatted time str to timestamp +/// @param[in] s the formatted timestamp str +/// @param[in] formats array of TSFormatNode, output of parseTsFormat +/// @param[out] ts output timestamp +/// @param precision the timestamp precision to convert to, sec/milli/micro/nano +/// @param[out] sErrPos if not NULL, when err occured, points to the failed position of s, only set when ret is -1 +/// @param[out] fErrIdx if not NULL, when err occured, the idx of the failed format idx, only set when ret is -1 +/// @retval 0 for success +/// @retval -1 for format and s mismatch error +/// @retval -2 if datetime err, like 2023-13-32 25:61:69 +static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t precision, const char** sErrPos, + int32_t* fErrIdx) { + int32_t size = taosArrayGetSize(formats); + int32_t pm = 0; // default am + int32_t hour12 = 0; // default HH24 + int32_t year = 0, mon = 0, yd = 0, md = 1, wd = 0; + int32_t hour = 0, min = 0, sec = 0, us = 0, ms = 0, ns = 0; + int32_t tzSign = 1, tz = tsTimezone; + int32_t err = 0; + + for (int32_t i = 0; i < size; ++i) { + while (isspace(*s)) { + s++; + } + TSFormatNode* node = taosArrayGet(formats, i); + if (node->type == TS_FORMAT_NODE_TYPE_SEPARATOR) { + // separator matches any character + if (isSeperatorChar(s[0])) s += strlen(node->c); + continue; + } + if (node->type == TS_FORMAT_NODE_TYPE_CHAR) { + if (!isspace(node->c[0])) s += strlen(node->c); + continue; + } + assert(node->type == TS_FORMAT_NODE_TYPE_KEYWORD); + switch (node->key->id) { + case TSFKW_A_M: + case TSFKW_P_M: + case TSFKW_a_m: + case TSFKW_p_m: { + int32_t idx = strArrayCaseSearch(long_apms, s); + if (idx >= 0) { + s += strlen(long_apms[idx]); + pm = idx % 2; + hour12 = 1; + } else { + err = -1; + } + } break; + case TSFKW_AM: + case TSFKW_PM: + case TSFKW_am: + case TSFKW_pm: { + int32_t idx = strArrayCaseSearch(apms, s); + if (idx >= 0) { + s += strlen(apms[idx]); + pm = idx % 2; + hour12 = 1; + } else { + err = -1; + } + } break; + case TSFKW_HH: + case TSFKW_HH12: { + const char* newPos = tsFormatStr2Int32(&hour, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos || hour > 12 || hour <= 0) { + err = -1; + } else { + hour12 = 1; + s = newPos; + } + } break; + case TSFKW_HH24: { + const char* newPos = tsFormatStr2Int32(&hour, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + hour12 = 0; + s = newPos; + } + } break; + case TSFKW_MI: { + const char* newPos = tsFormatStr2Int32(&min, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + } + } break; + case TSFKW_SS: { + const char* newPos = tsFormatStr2Int32(&sec, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) + err = -1; + else + s = newPos; + } break; + case TSFKW_MS: { + const char* newPos = tsFormatStr2Int32(&ms, s, 3, needMoreDigits(formats, i)); + if (NULL == newPos) + err = -1; + else { + int32_t len = newPos - s; + ms *= len == 1 ? 100 : len == 2 ? 10 : 1; + s = newPos; + } + } break; + case TSFKW_US: { + const char* newPos = tsFormatStr2Int32(&us, s, 6, needMoreDigits(formats, i)); + if (NULL == newPos) + err = -1; + else { + int32_t len = newPos - s; + us *= len == 1 ? 100000 : len == 2 ? 10000 : len == 3 ? 1000 : len == 4 ? 100 : len == 5 ? 10 : 1; + s = newPos; + } + } break; + case TSFKW_NS: { + const char* newPos = tsFormatStr2Int32(&ns, s, 9, needMoreDigits(formats, i)); + if (NULL == newPos) + err = -1; + else { + int32_t len = newPos - s; + ns *= len == 1 ? 100000000 + : len == 2 ? 10000000 + : len == 3 ? 1000000 + : len == 4 ? 100000 + : len == 5 ? 10000 + : len == 6 ? 1000 + : len == 7 ? 100 + : len == 8 ? 10 + : 1; + s = newPos; + } + } break; + case TSFKW_TZH: { + tzSign = *s == '-' ? -1 : 1; + const char* newPos = tsFormatStr2Int32(&tz, s, -1, needMoreDigits(formats, i)); + if (NULL == newPos) + err = -1; + else { + s = newPos; + } + } break; + case TSFKW_MONTH: + case TSFKW_Month: + case TSFKW_month: { + int32_t idx = strArrayCaseSearch(fullMonths, s); + if (idx >= 0) { + s += strlen(fullMonths[idx]); + mon = idx; + } else { + err = -1; + } + } break; + case TSFKW_MON: + case TSFKW_Mon: + case TSFKW_mon: { + int32_t idx = strArrayCaseSearch(months, s); + if (idx >= 0) { + s += strlen(months[idx]); + mon = idx; + } else { + err = -1; + } + } break; + case TSFKW_MM: { + const char* newPos = tsFormatStr2Int32(&mon, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + mon -= 1; + } + } break; + case TSFKW_DAY: + case TSFKW_Day: + case TSFKW_day: { + int32_t idx = strArrayCaseSearch(weekDays, s); + if (idx >= 0) { + s += strlen(weekDays[idx]); + wd = idx; + } else { + err = -1; + } + } break; + case TSFKW_DY: + case TSFKW_Dy: + case TSFKW_dy: { + int32_t idx = strArrayCaseSearch(shortWeekDays, s); + if (idx >= 0) { + s += strlen(shortWeekDays[idx]); + wd = idx; + } else { + err = -1; + } + } break; + case TSFKW_DDD: { + const char* newPos = tsFormatStr2Int32(&yd, s, 3, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + } + } break; + case TSFKW_DD: { + const char* newPos = tsFormatStr2Int32(&md, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + } + } break; + case TSFKW_D: { + const char* newPos = tsFormatStr2Int32(&wd, s, 1, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + } + } break; + case TSFKW_YYYY: { + const char* newPos = tsFormatStr2Int32(&year, s, 4, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + s = newPos; + } + } break; + case TSFKW_YYY: { + const char* newPos = tsFormatStr2Int32(&year, s, 3, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + year = adjustYearTo2020(year); + s = newPos; + } + } break; + case TSFKW_YY: { + const char* newPos = tsFormatStr2Int32(&year, s, 2, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + year = adjustYearTo2020(year); + s = newPos; + } + } break; + case TSFKW_Y: { + const char* newPos = tsFormatStr2Int32(&year, s, 1, needMoreDigits(formats, i)); + if (NULL == newPos) { + err = -1; + } else { + year = adjustYearTo2020(year); + s = newPos; + } + } break; + default: + break; + } + if (err) { + if (sErrPos) *sErrPos = s; + if (fErrIdx) *fErrIdx = i; + return err; + } + } + struct STm tm = {0}; + tm.tm.tm_year = year - 1900; + tm.tm.tm_mon = mon; + tm.tm.tm_yday = yd; + tm.tm.tm_mday = md; + tm.tm.tm_wday = wd; + if (hour12) { + if (pm && hour < 12) + tm.tm.tm_hour = hour + 12; + else if (!pm && hour == 12) + tm.tm.tm_hour = 0; + else + tm.tm.tm_hour = hour; + } else { + tm.tm.tm_hour = hour; + } + tm.tm.tm_min = min; + tm.tm.tm_sec = sec; + if (!checkTm(&tm.tm)) return -2; + if (tz < -12 || tz > 12) return -2; + tm.fsec = ms * 1000000 + us * 1000 + ns; + int32_t ret = taosTm2Ts(&tm, ts, precision); + *ts += 60 * 60 * (tsTimezone - tz) * TICK_PER_SECOND[precision]; + return ret; +} + +void taosTs2Char(const char* format, int64_t ts, int32_t precision, char* out) { + SArray* formats = taosArrayInit(8, sizeof(TSFormatNode)); + parseTsFormat(format, formats); + struct STm tm; + taosTs2Tm(ts, precision, &tm); + tm2char(formats, &tm, out); + taosArrayDestroy(formats); +} + +int32_t taosChar2Ts(const char* format, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, + int32_t errMsgLen) { + const char* sErrPos; + int32_t fErrIdx; + SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); + parseTsFormat(format, formats); + int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx); + if (code == -1) { + TSFormatNode* fNode = (taosArrayGet(formats, fErrIdx)); + snprintf(errMsg, errMsgLen, "mismatch format for: %s and %s", sErrPos, + fErrIdx < taosArrayGetSize(formats) ? ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name : ""); + } else if (code == -2) { + snprintf(errMsg, errMsgLen, "timestamp format error: %s -> %s", tsStr, format); + } + taosArrayDestroy(formats); + return code; +} + +void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out) { + SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); + parseTsFormat(format, formats); + struct STm tm; + taosTs2Tm(ts, precision, &tm); + tm2char(formats, &tm, out); + taosArrayDestroy(formats); +} + +int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr) { + const char* sErrPos; + int32_t fErrIdx; + SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); + parseTsFormat(format, formats); + int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx); + if (code == -1) { + printf("failed position: %s\n", sErrPos); + printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name); + } + taosArrayDestroy(formats); + return code; +} diff --git a/source/common/test/commonTests.cpp b/source/common/test/commonTests.cpp index 8a77087d23..49a16351ca 100644 --- a/source/common/test/commonTests.cpp +++ b/source/common/test/commonTests.cpp @@ -13,6 +13,7 @@ #include "tdatablock.h" #include "tdef.h" #include "tvariant.h" +#include "ttime.h" namespace { // @@ -260,4 +261,226 @@ TEST(testCase, var_dataBlock_split_test) { } } -#pragma GCC diagnostic pop \ No newline at end of file +void check_tm(const STm* tm, int32_t y, int32_t mon, int32_t d, int32_t h, int32_t m, int32_t s, int64_t fsec) { + ASSERT_EQ(tm->tm.tm_year, y); + ASSERT_EQ(tm->tm.tm_mon, mon); + ASSERT_EQ(tm->tm.tm_mday, d); + ASSERT_EQ(tm->tm.tm_hour, h); + ASSERT_EQ(tm->tm.tm_min, m); + ASSERT_EQ(tm->tm.tm_sec, s); + ASSERT_EQ(tm->fsec, fsec); +} + +void test_timestamp_tm_conversion(int64_t ts, int32_t precision, int32_t y, int32_t mon, int32_t d, int32_t h, int32_t m, int32_t s, int64_t fsec) { + int64_t ts_tmp; + char buf[128] = {0}; + struct STm tm; + taosFormatUtcTime(buf, 128, ts, precision); + printf("formated ts of %ld, precision: %d is: %s\n", ts, precision, buf); + taosTs2Tm(ts, precision, &tm); + check_tm(&tm, y, mon, d, h, m, s, fsec); + taosTm2Ts(&tm, &ts_tmp, precision); + ASSERT_EQ(ts, ts_tmp); +} + +TEST(timeTest, timestamp2tm) { + const char* ts_str_ns = "2023-10-12T11:29:00.775726171+0800"; + const char* ts_str_us = "2023-10-12T11:29:00.775726+0800"; + const char* ts_str_ms = "2023-10-12T11:29:00.775+0800"; + int64_t ts, tmp_ts = 0; + struct STm tm; + + ASSERT_EQ(TSDB_CODE_SUCCESS, taosParseTime(ts_str_ns, &ts, strlen(ts_str_ns), TSDB_TIME_PRECISION_NANO, 0)); + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_NANO, 2023 - 1900, 9 /* mon start from 0*/, 12, 11, 29, 0, + 775726171L); + + ASSERT_EQ(TSDB_CODE_SUCCESS, taosParseTime(ts_str_us, &ts, strlen(ts_str_us), TSDB_TIME_PRECISION_MICRO, 0)); + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_MICRO, 2023 - 1900, 9 /* mon start from 0*/, 12, 11, 29, 0, + 775726000L); + + ASSERT_EQ(TSDB_CODE_SUCCESS, taosParseTime(ts_str_ms, &ts, strlen(ts_str_ms), TSDB_TIME_PRECISION_MILLI, 0)); + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_MILLI, 2023 - 1900, 9 /* mon start from 0*/, 12, 11, 29, 0, + 775000000L); + + ts = -5364687943000; // milliseconds since epoch, Wednesday, January 1, 1800 1:00:00 AM GMT+08:06 + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_MILLI, 1800 - 1900, 0 /* mon start from 0*/, 1, 1, 0, 0, + 000000000L); + + ts = 0; + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_MILLI, 1970 - 1900, 0 /* mon start from 0*/, 1, 8, 0, 0, + 000000000L); + + ts = -62198784343000; // milliseconds before epoch, Friday, January 1, -0001 12:00:00 AM GMT+08:06 + test_timestamp_tm_conversion(ts, TSDB_TIME_PRECISION_MILLI, -1 - 1900, 0 /* mon start from 0*/, 1, + 0 /* hour start from 0*/, 0, 0, 000000000L); +} + +void test_ts2char(int64_t ts, const char* format, int32_t precison, const char* expected) { + char buf[128] = {0}; + TEST_ts2char(format, ts, precison, buf); + printf("ts: %ld format: %s res: [%s], expected: [%s]\n", ts, format, buf, expected); + ASSERT_STREQ(expected, buf); +} + +TEST(timeTest, ts2char) { + osDefaultInit(); + if (tsTimezone != TdEastZone8) GTEST_SKIP(); + int64_t ts; + const char* format = "YYYY-MM-DD"; + ts = 0; + test_ts2char(ts, format, TSDB_TIME_PRECISION_MILLI, "1970-01-01"); + test_ts2char(ts, format, TSDB_TIME_PRECISION_MICRO, "1970-01-01"); + test_ts2char(ts, format, TSDB_TIME_PRECISION_NANO, "1970-01-01"); + test_ts2char(ts, format, TSDB_TIME_PRECISION_SECONDS, "1970-01-01"); + + ts = 1697163517; + test_ts2char(ts, "YYYY-MM-DD", TSDB_TIME_PRECISION_SECONDS, "2023-10-13"); + ts = 1697163517000; + test_ts2char(ts, "YYYY-MM-DD-Day-DAY", TSDB_TIME_PRECISION_MILLI, "2023-10-13-Friday -FRIDAY "); +#ifndef WINDOWS + // double quoted: year, month, day are not parsed + test_ts2char(ts, + "YYYY-YYY-YY-Y-yyyy-yyy-yy-y-\"年\"-MONTH-MON-Month-Mon-month-mon-\"月\"-DDD-DD-D-ddd-dd-d-DAY-Day-" + "day-\"日\"", + TSDB_TIME_PRECISION_MILLI, + "2023-023-23-3-2023-023-23-3-年-OCTOBER -OCT-October -Oct-october " + "-oct-月-285-13-6-285-13-6-FRIDAY -Friday -friday -日"); +#endif + ts = 1697182085123L; // Friday, October 13, 2023 3:28:05.123 PM GMT+08:00 + test_ts2char(ts, "HH24:hh24:HH12:hh12:HH:hh:MI:mi:SS:ss:MS:ms:US:us:NS:ns:PM:AM:pm:am", TSDB_TIME_PRECISION_MILLI, + "15:15:03:03:03:03:28:28:05:05:123:123:123000:123000:123000000:123000000:PM:PM:pm:pm"); + + // double quotes normal output + test_ts2char(ts, "\\\"HH24:hh24:HH12:hh12:HH:hh:MI:mi:SS:ss:MS:ms:US:us:NS:ns:PM:AM:pm:am\\\"", TSDB_TIME_PRECISION_MILLI, + "\"15:15:03:03:03:03:28:28:05:05:123:123:123000:123000:123000000:123000000:PM:PM:pm:pm\""); + test_ts2char(ts, "\\\"HH24:hh24:HH12:hh12:HH:hh:MI:mi:SS:ss:MS:ms:US:us:NS:ns:PM:AM:pm:am", TSDB_TIME_PRECISION_MILLI, + "\"15:15:03:03:03:03:28:28:05:05:123:123:123000:123000:123000000:123000000:PM:PM:pm:pm"); + // double quoted strings recognized as literal string, parsing skipped + test_ts2char(ts, "\"HH24:hh24:HH12:hh12:HH:hh:MI:mi:SS:ss:MS:ms:US:us:NS:ns:PM:AM:pm:am", TSDB_TIME_PRECISION_MILLI, + "HH24:hh24:HH12:hh12:HH:hh:MI:mi:SS:ss:MS:ms:US:us:NS:ns:PM:AM:pm:am"); + test_ts2char(ts, "yyyy-mm-dd hh24:mi:ss.nsamaaa", TSDB_TIME_PRECISION_MILLI, "2023-10-13 15:28:05.123000000pmaaa"); + test_ts2char(ts, "aaa--yyyy-mm-dd hh24:mi:ss.nsamaaa", TSDB_TIME_PRECISION_MILLI, "aaa--2023-10-13 15:28:05.123000000pmaaa"); + test_ts2char(ts, "add--yyyy-mm-dd hh24:mi:ss.nsamaaa", TSDB_TIME_PRECISION_MILLI, "a13--2023-10-13 15:28:05.123000000pmaaa"); + + ts = 1693946405000; + test_ts2char(ts, "Day, Month dd, YYYY hh24:mi:ss AM TZH:tzh", TSDB_TIME_PRECISION_MILLI, "Wednesday, September 06, 2023 04:40:05 AM +08:+08"); + + ts = -62198784343000; // milliseconds before epoch, Friday, January 1, -0001 12:00:00 AM GMT+08:06 + test_ts2char(ts, "Day, Month dd, YYYY hh12:mi:ss AM", TSDB_TIME_PRECISION_MILLI, "Friday , January 01, -001 12:00:00 AM"); +} + +TEST(timeTest, char2ts) { + osDefaultInit(); + if (tsTimezone != TdEastZone8) GTEST_SKIP(); + int64_t ts; + int32_t code = + TEST_char2ts("YYYY-DD-MM HH12:MI:SS:MSPM", &ts, TSDB_TIME_PRECISION_MILLI, "2023-10-10 12:00:00.000AM"); + ASSERT_EQ(code, 0); + ASSERT_EQ(ts, 1696867200000LL); + + // 2009-1-1 00:00:00 + ASSERT_EQ(0, TEST_char2ts("YYYY-YYY-YY-Y", &ts, TSDB_TIME_PRECISION_MILLI, "2023-123-23-9")); + ASSERT_EQ(1230739200000LL, ts); + // 2023-1-1 + ASSERT_EQ(0, TEST_char2ts("YYYY-YYY-YY", &ts, TSDB_TIME_PRECISION_MILLI, "2023-123-23-9")); + ASSERT_EQ(ts, 1672502400000LL); + + // 2123-1-1, the second year(123) is used, which converted to 2123 + ASSERT_EQ(0, TEST_char2ts("YYYY-YYY", &ts, TSDB_TIME_PRECISION_MILLI, "2023-123-23-9")); + ASSERT_EQ(ts, 4828176000000LL); + // 2023-1-1 12:10:10am + ASSERT_EQ(0, TEST_char2ts("yyyy-mm-dd HH12:MI:SSAM", &ts, TSDB_TIME_PRECISION_MILLI, "2023-1-1 12:10:10am")); + ASSERT_EQ(ts, 1672503010000LL); + + // 2023-1-1 21:10:10.123 + ASSERT_EQ(0, TEST_char2ts("yy-MM-dd HH12:MI:ss.msa.m.", &ts, TSDB_TIME_PRECISION_MILLI, "23-1-01 9:10:10.123p.m.")); + ASSERT_EQ(ts, 1672578610123LL); + + // 2023-1-1 21:10:10.123456789 + ASSERT_EQ(0, TEST_char2ts("yy-MM-dd HH:MI:ss.ms.us.nsa.m.", &ts, TSDB_TIME_PRECISION_NANO, + "23-1-01 9:10:10.123.000456.000000789p.m.")); + ASSERT_EQ(ts, 1672578610123456789LL); + + // 2023-1-1 21:10:10.120450780 + ASSERT_EQ(0, TEST_char2ts("yy-MM-dd HH24:MI:SS.ms.us.ns", &ts, TSDB_TIME_PRECISION_NANO, + " 23 - 1 - 01 \t 21:10:10 . 12 . \t 00045 . 00000078 \t")); + ASSERT_EQ(ts, 1672578610120450780LL); + +#ifndef WINDOWS + // 2023-1-1 21:10:10.120450780 + ASSERT_EQ(0, TEST_char2ts("yy \"年\"-MM 月-dd \"日\" HH24:MI:ss.ms.us.ns TZH", &ts, TSDB_TIME_PRECISION_NANO, + " 23 年 - 1 月 - 01 日 \t 21:10:10 . 12 . \t 00045 . 00000078 \t+08")); + ASSERT_EQ(ts, 1672578610120450780LL); +#endif + + // 2023-1-1 19:10:10.123456789+06 -> 2023-1-1 21:10:10.123456789+08 + ASSERT_EQ(0, TEST_char2ts("yy-MM-dd HH:MI:ss.ms.us.nsa.m.TZH", &ts, TSDB_TIME_PRECISION_NANO, + "23-1-01 7:10:10.123.000456.000000789p.m.6")); + ASSERT_EQ(ts, 1672578610123456789LL); + + // 2023-1-1 12:10:10.123456789-01 -> 2023-1-1 21:10:10.123456789+08 + ASSERT_EQ(0, TEST_char2ts("yy-MM-dd HH24:MI:ss.ms.us.nsTZH", &ts, TSDB_TIME_PRECISION_NANO, + "23-1-01 12:10:10.123.000456.000000789-1")); + ASSERT_EQ(ts, 1672578610123456789LL); + + // 2100-01-01 11:10:10.124456+08 + ASSERT_EQ( + 0, TEST_char2ts("yyyy-MM-dd HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, "2100-01-01 11:10:10.124456+08")); + ASSERT_EQ(ts, 4102456210124456LL); + + // 2100-01-01 11:10:10.124456+08 Firday + ASSERT_EQ(0, TEST_char2ts("yyyy/MONTH/dd DAY HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/january/01 friday 11:10:10.124456+08")); + ASSERT_EQ(ts, 4102456210124456LL); + + ASSERT_EQ(0, TEST_char2ts("yyyy/Month/dd Day HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/january/01 FRIDAY 11:10:10.124456+08")); + ASSERT_EQ(ts, 4102456210124456LL); + ASSERT_EQ(0, TEST_char2ts("yyyy/Month/dd Dy HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/january/01 Fri 11:10:10.124456+08")); + ASSERT_EQ(ts, 4102456210124456LL); + + ASSERT_EQ(0, TEST_char2ts("yyyy/month/dd day HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/january/01 Friday 11:10:10.124456+08")); + ASSERT_EQ(ts, 4102456210124456LL); + + // 2100-02-01 11:10:10.124456+08 Firday + ASSERT_EQ(0, TEST_char2ts("yyyy/mon/dd DY HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/Feb/01 Mon 11:10:10.124456+08")); + ASSERT_EQ(ts, 4105134610124456LL); + + // 2100-02-01 11:10:10.124456+08 Firday + ASSERT_EQ(0, TEST_char2ts("yyyy/mon/dd DY DDD-DD-D HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, + "2100/Feb/01 Mon 100-1-01 11:10:10.124456+08")); + ASSERT_EQ(ts, 4105134610124456LL); + + ASSERT_EQ(0, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "21000101")); + + // What is Fe? + ASSERT_EQ(-1, TEST_char2ts("yyyy/mon/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "2100/Fe/01")); + // '/' cannot convert to MM + ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "2100/2/1")); + // nothing to be converted to dd + ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "210012")); + ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "21001")); + ASSERT_EQ(-1, TEST_char2ts("yyyyMM-dd ", &ts, TSDB_TIME_PRECISION_MICRO, "23a1-1")); + + // 2100-1-2 + ASSERT_EQ(0, TEST_char2ts("yyyyMM/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "21001/2")); + ASSERT_EQ(ts, 4102502400000000LL); + + // default to 1970-1-1 00:00:00+08 -> 1969-12-31 16:00:00+00 + ASSERT_EQ(0, TEST_char2ts("YYYY", &ts, TSDB_TIME_PRECISION_SECONDS, "1970")); + ASSERT_EQ(ts, -1 * tsTimezone * 60 * 60); + + ASSERT_EQ(0, TEST_char2ts("yyyyMM1/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "210001/2")); + ASSERT_EQ(ts, 4102502400000000LL); + + ASSERT_EQ(-2, TEST_char2ts("yyyyMM/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "210013/2")); + ASSERT_EQ(-2, TEST_char2ts("yyyyMM/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "210011/32")); + ASSERT_EQ(-1, TEST_char2ts("HH12:MI:SS", &ts, TSDB_TIME_PRECISION_MICRO, "21:12:12")); + ASSERT_EQ(-1, TEST_char2ts("yyyy/MM1/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "2100111111111/11/2")); + ASSERT_EQ(-2, TEST_char2ts("yyyy/MM1/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "23/11/2-13")); +} + +#pragma GCC diagnostic pop diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 68a83fa662..628a609715 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2083,6 +2083,34 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int return TSDB_CODE_SUCCESS; } +static int32_t translateToTimestamp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (LIST_LENGTH(pFunc->pParameterList) != 2) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + if (!IS_STR_DATA_TYPE(para1Type) || !IS_STR_DATA_TYPE(para2Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = + (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateToChar(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (LIST_LENGTH(pFunc->pParameterList) != 2) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; + // currently only support to_char(timestamp, str) + if (!IS_STR_DATA_TYPE(para2Type) || !IS_TIMESTAMP_TYPE(para1Type)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_VARCHAR].bytes, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); if (2 != numOfParams && 3 != numOfParams) { @@ -3284,6 +3312,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = castFunction, .finalizeFunc = NULL }, + { + .name = "to_timestamp", + .type = FUNCTION_TYPE_TO_TIMESTAMP, + .classification = FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateToTimestamp, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = toTimestampFunction, + .finalizeFunc = NULL + }, + { + .name = "to_char", + .type = FUNCTION_TYPE_TO_CHAR, + .classification = FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateToChar, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = toCharFunction, + .finalizeFunc = NULL + }, { .name = "to_iso8601", .type = FUNCTION_TYPE_TO_ISO8601, diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 4df7454df8..ee2ba47ce8 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1197,6 +1197,62 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu return TSDB_CODE_SUCCESS; } +#define TS_FORMAT_MAX_LEN 4096 +int32_t toTimestampFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput) { + int64_t ts; + char * tsStr = taosMemoryMalloc(TS_FORMAT_MAX_LEN); + char * format = taosMemoryMalloc(TS_FORMAT_MAX_LEN); + int32_t len, code = TSDB_CODE_SUCCESS; + for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { + if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) + colDataSetNULL(pOutput->columnData, i); + + char *tsData = colDataGetData(pInput[0].columnData, i); + char *formatData = colDataGetData(pInput[1].columnData, pInput[1].numOfRows > 1 ? i : 0); + len = TMIN(TS_FORMAT_MAX_LEN - 1, varDataLen(tsData)); + strncpy(tsStr, varDataVal(tsData), len); + tsStr[len] = '\0'; + len = TMIN(TS_FORMAT_MAX_LEN - 1, varDataLen(formatData)); + strncpy(format, varDataVal(formatData), len); + format[len] = '\0'; + int32_t precision = pOutput->columnData->info.precision; + char errMsg[128] = {0}; + code = taosChar2Ts(format, tsStr, &ts, precision, errMsg, 128); + if (code) { + qError("func to_timestamp failed %s", errMsg); + code = TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED; + break; + } + colDataSetVal(pOutput->columnData, i, (char *)&ts, false); + } + taosMemoryFree(tsStr); + taosMemoryFree(format); + return code; +} + +int32_t toCharFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput) { + char * format = taosMemoryMalloc(TS_FORMAT_MAX_LEN); + char * out = taosMemoryMalloc(TS_FORMAT_MAX_LEN * 2); + int32_t len; + for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { + if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) + colDataSetNULL(pOutput->columnData, i); + + char *ts = colDataGetData(pInput[0].columnData, i); + char *formatData = colDataGetData(pInput[1].columnData, pInput[1].numOfRows > 1 ? i : 0); + len = TMIN(TS_FORMAT_MAX_LEN - 1, varDataLen(formatData)); + strncpy(format, varDataVal(formatData), len); + format[len] = '\0'; + int32_t precision = pInput[0].columnData->info.precision; + taosTs2Char(format, *(int64_t *)ts, precision, varDataVal(out)); + varDataSetLen(out, strlen(varDataVal(out))); + colDataSetVal(pOutput->columnData, i, out, false); + } + taosMemoryFree(format); + taosMemoryFree(out); + return TSDB_CODE_SUCCESS; +} + /** Time functions **/ static int64_t offsetFromTz(char *timezone, int64_t factor) { char *minStr = &timezone[3]; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 383e4e9d8a..9e5a50ce85 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -601,6 +601,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_TYPE, "Invalid function par TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_FUNTION_PARA_VALUE, "Invalid function para value") TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_NOT_BUILTIN_FUNTION, "Not buildin function") TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_DUP_TIMESTAMP, "Duplicate timestamps not allowed in function") +TAOS_DEFINE_ERROR(TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED, "Func to_timestamp failed, check log for detail") //udf TAOS_DEFINE_ERROR(TSDB_CODE_UDF_STOPPING, "udf is stopping") diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 8b0451604c..bd20a2745f 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -61,6 +61,10 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interval_limit_opt_2.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interval_limit_opt_2.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interval_limit_opt_2.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/func_to_char_timestamp.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/func_to_char_timestamp.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/func_to_char_timestamp.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/func_to_char_timestamp.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py diff --git a/tests/system-test/2-query/func_to_char_timestamp.py b/tests/system-test/2-query/func_to_char_timestamp.py new file mode 100644 index 0000000000..3d3435d9c7 --- /dev/null +++ b/tests/system-test/2-query/func_to_char_timestamp.py @@ -0,0 +1,160 @@ +import taos +import sys +import time +import socket +import os +import threading +import math + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +# from tmqCommon import * + +class TDTestCase: + def __init__(self): + self.vgroups = 4 + self.ctbNum = 10 + self.rowsPerTbl = 10000 + self.duraion = '1h' + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + + def create_database(self,tsql, dbName,dropFlag=1,vgroups=2,replica=1, duration:str='1d'): + if dropFlag == 1: + tsql.execute("drop database if exists %s"%(dbName)) + + tsql.execute("create database if not exists %s vgroups %d replica %d duration %s"%(dbName, vgroups, replica, duration)) + tdLog.debug("complete to create database %s"%(dbName)) + return + + def create_stable(self,tsql, paraDict): + colString = tdCom.gen_column_type_str(colname_prefix=paraDict["colPrefix"], column_elm_list=paraDict["colSchema"]) + tagString = tdCom.gen_tag_type_str(tagname_prefix=paraDict["tagPrefix"], tag_elm_list=paraDict["tagSchema"]) + sqlString = f"create table if not exists %s.%s (%s) tags (%s)"%(paraDict["dbName"], paraDict["stbName"], colString, tagString) + tdLog.debug("%s"%(sqlString)) + tsql.execute(sqlString) + return + + def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1,ctbStartIdx=0): + for i in range(ctbNum): + sqlString = "create table %s.%s%d using %s.%s tags(%d, 'tb%d', 'tb%d', %d, %d, %d)" % \ + (dbName,ctbPrefix,i+ctbStartIdx,dbName,stbName,(i+ctbStartIdx) % 5,i+ctbStartIdx,i+ctbStartIdx,i+ctbStartIdx,i+ctbStartIdx,i+ctbStartIdx) + tsql.execute(sqlString) + + tdLog.debug("complete to create %d child tables by %s.%s" %(ctbNum, dbName, stbName)) + return + + def insert_data(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs,tsStep): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + for i in range(ctbNum): + rowsBatched = 0 + sql += " %s%d values "%(ctbPrefix,i) + for j in range(rowsPerTbl): + if (i < ctbNum/2): + sql += "(%d, %d, %d, %d,%d,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10, j%10, j%10) + else: + sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10) + rowsBatched += 1 + if ((rowsBatched == batchNum) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + rowsBatched = 0 + if j < rowsPerTbl - 1: + sql = "insert into %s%d values " %(ctbPrefix,i) + else: + sql = "insert into " + if sql != pre_insert: + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def prepareTestEnv(self): + tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ") + paraDict = {'dbName': 'test', + 'dropFlag': 1, + 'vgroups': 2, + 'stbName': 'meters', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'FLOAT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'smallint', 'count':1},{'type': 'tinyint', 'count':1},{'type': 'bool', 'count':1},{'type': 'binary', 'len':10, 'count':1},{'type': 'nchar', 'len':10, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'nchar', 'len':20, 'count':1},{'type': 'binary', 'len':20, 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'smallint', 'count':1},{'type': 'DOUBLE', 'count':1}], + 'ctbPrefix': 't', + 'ctbStartIdx': 0, + 'ctbNum': 100, + 'rowsPerTbl': 10000, + 'batchNum': 3000, + 'startTs': 1537146000000, + 'tsStep': 600000} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tdLog.info("create database") + self.create_database(tsql=tdSql, dbName=paraDict["dbName"], dropFlag=paraDict["dropFlag"], vgroups=paraDict["vgroups"], replica=self.replicaVar, duration=self.duraion) + + tdLog.info("create stb") + self.create_stable(tsql=tdSql, paraDict=paraDict) + + tdLog.info("create child tables") + self.create_ctable(tsql=tdSql, dbName=paraDict["dbName"], \ + stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"],\ + ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict["ctbStartIdx"]) + self.insert_data(tsql=tdSql, dbName=paraDict["dbName"],\ + ctbPrefix=paraDict["ctbPrefix"],ctbNum=paraDict["ctbNum"],\ + rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],\ + startTs=paraDict["startTs"],tsStep=paraDict["tsStep"]) + return + + def convert_ts_and_check(self, ts_str: str, ts_format: str, expect_ts_char: str, expect_ts: str): + tdSql.query("select to_timestamp('%s', '%s')" % (ts_str, ts_format), queryTimes=1) + tdSql.checkData(0, 0, expect_ts) + tdSql.query("select to_char(to_timestamp('%s', '%s'), '%s')" % (ts_str, ts_format, ts_format), queryTimes=1) + tdSql.checkData(0, 0, expect_ts_char) + + def test_to_timestamp(self): + self.convert_ts_and_check('2023-10-10 12:13:14.123', 'YYYY-MM-DD HH:MI:SS.MS', '2023-10-10 12:13:14.123', '2023-10-10 00:13:14.123000') + self.convert_ts_and_check('2023-10-10 12:00:00.000AM', 'YYYY-DD-MM HH12:MI:SS.MSPM', '2023-10-10 12:00:00.000AM', '2023-10-10 00:00:00.000000') + self.convert_ts_and_check('2023-01-01 12:10:10am', 'yyyy-mm-dd HH12:MI:SSAM', '2023-01-01 12:10:10AM', '2023-1-1 00:10:10.000000') + self.convert_ts_and_check('23-1-01 9:10:10.123p.m.', 'yy-MM-dd HH12:MI:ss.msa.m.', '23-01-01 09:10:10.123p.m.', '2023-1-1 21:10:10.123000') + self.convert_ts_and_check('23-1-01 9:10:10.123.000456.000000789p.m.', 'yy-MM-dd HH12:MI:ss.ms.us.nsa.m.', '23-01-01 09:10:10.123.123000.123000000p.m.', '2023-1-1 21:10:10.123000') + self.convert_ts_and_check(' 23 -1 - 01 \t 21:10:10 . 12 . \t 00045 . 00000078 \t', 'yy-MM-dd HH24:MI:SS.ms.us.ns', '23-01-01 21:10:10.120.120000.120000000', '2023-1-1 21:10:10.120000') + self.convert_ts_and_check(' 23 年 -1 月 - 01 日 \t 21:10:10 . 12 . \t 00045 . 00000078 \t+08', 'yy\"年\"-MM月-dd日 HH24:MI:SS.ms.us.ns TZH', '23年-01月-01日 21:10:10.120.120000.120000000 +08', '2023-1-1 21:10:10.120000') + self.convert_ts_and_check('23-1-01 7:10:10.123p.m.6', 'yy-MM-dd HH:MI:ss.msa.m.TZH', '23-01-01 09:10:10.123p.m.+08', '2023-1-1 21:10:10.123000') + + self.convert_ts_and_check('2023-OCTober-19 10:10:10AM Thu', 'yyyy-month-dd hh24:mi:ssam dy', '2023-october -19 10:10:10am thu', '2023-10-19 10:10:10') + + tdSql.error("select to_timestamp('210013/2', 'yyyyMM/dd')") + tdSql.error("select to_timestamp('2100111111111/13/2', 'yyyyMM/dd')") + + tdSql.error("select to_timestamp('210a12/2', 'yyyyMM/dd')") + + tdSql.query("select to_timestamp(to_char(ts, 'yy-mon-dd hh24:mi:ss dy'), 'yy-mon-dd hh24:mi:ss dy') == ts from meters limit 10") + tdSql.checkData(0, 0, 1) + tdSql.checkData(1, 0, 1) + tdSql.checkRows(10) + + tdSql.query("select to_char(ts, 'yy-mon-dd hh24:mi:ss.msa.m.TZH Day') from meters where to_timestamp(to_char(ts, 'yy-mon-dd hh24:mi:ss dy'), 'yy-mon-dd hh24:mi:ss dy') != ts") + tdSql.checkRows(0) + + def run(self): + self.prepareTestEnv() + self.test_to_timestamp() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) From f444cd7a6d7b813c09bfc3f6a910189479457e08 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 10:15:39 +0800 Subject: [PATCH 03/45] enh: log signature of snap sender/receiver while started or stopped --- source/libs/sync/src/syncSnapshot.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 43726307e6..3017f4e33c 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -175,7 +175,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { SyncSnapshotSend *pMsg = rpcMsg.pCont; pMsg->srcId = pSender->pSyncNode->myRaftId; pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - pMsg->term = raftStoreGetTerm(pSender->pSyncNode); + pMsg->term = pSender->term; pMsg->beginIndex = pSender->snapshotParam.start; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; pMsg->lastTerm = pSender->snapshot.lastApplyTerm; @@ -189,15 +189,15 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { memcpy(pMsg->data, snapInfo.data, dataLen); } - // event log - syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender start"); - // send msg if (syncNodeSendMsgById(&pMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { sSError(pSender, "snapshot sender send msg failed since %s", terrstr()); goto _out; } + sSInfo(pSender, "snapshot sender started. signature:(%" PRId64 ", %" PRId64 "), to dnode:%d", pSender->term, + pSender->startTime, DID(&pMsg->destId)); + code = 0; _out: if (snapInfo.data) { @@ -231,6 +231,10 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { } syncSnapBufferReset(pSender->pSndBuf); + + SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; + sSInfo(pSender, "snapshot sender stopped. signature:(%" PRId64 ", %" PRId64 "), to dnode:%d", pSender->term, + pSender->startTime, DID(&destId)); } // when sender receive ack, call this function to send msg from seq @@ -515,14 +519,14 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p pReceiver->startTime = pPreMsg->startTime; ASSERT(pReceiver->startTime); - // event log - sRInfo(pReceiver, "snapshot receiver is start"); + sRInfo(pReceiver, "snapshot receiver started. signature:(%" PRId64 ", %" PRId64 "), from dnode:%d", pReceiver->term, + pReceiver->startTime, DID(&pReceiver->fromId)); } // just set start = false // FpSnapshotStopWrite should not be called void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { - sRInfo(pReceiver, "snapshot receiver stop, not apply, writer:%p", pReceiver->pWriter); + sRDebug(pReceiver, "snapshot receiver stop, not apply, writer:%p", pReceiver->pWriter); int8_t stopped = !atomic_val_compare_exchange_8(&pReceiver->start, true, false); if (stopped) return; @@ -539,6 +543,9 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { } syncSnapBufferReset(pReceiver->pRcvBuf); + + sRInfo(pReceiver, "snapshot receiver stopped. signature:(%" PRId64 ", %" PRId64 "), from dnode:%d", pReceiver->term, + pReceiver->startTime, DID(&pReceiver->fromId)); } // when recv last snapshot block, apply data into snapshot From 1c60e67a8380813bb78f1cde4f86dce03d101de8 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 14:16:46 +0800 Subject: [PATCH 04/45] enh: send the END snap msg at last --- source/libs/sync/src/syncSnapshot.c | 52 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 3017f4e33c..7e556b28f5 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -247,25 +247,28 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { pSender->blockLen = 0; } - pSender->seq++; + if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) { + pSender->seq++; - // read data - int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, - &pSender->pCurrentBlock, &pSender->blockLen); - if (ret != 0) { - sSError(pSender, "snapshot sender read failed since %s", terrstr()); - return -1; - } + // read data + int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, + &pSender->pCurrentBlock, &pSender->blockLen); + if (ret != 0) { + sSError(pSender, "snapshot sender read failed since %s", terrstr()); + return -1; + } - if (pSender->blockLen > 0) { - // has read data - sSDebug(pSender, "vgId:%d, snapshot sender continue to read, blockLen:%d seq:%d", pSender->pSyncNode->vgId, - pSender->blockLen, pSender->seq); - } else { - // read finish, update seq to end - pSender->seq = SYNC_SNAPSHOT_SEQ_END; - sSInfo(pSender, "vgId:%d, snapshot sender read to the end, blockLen:%d seq:%d", pSender->pSyncNode->vgId, - pSender->blockLen, pSender->seq); + if (pSender->blockLen > 0) { + // has read data + sSDebug(pSender, "vgId:%d, snapshot sender continue to read, blockLen:%d seq:%d", pSender->pSyncNode->vgId, + pSender->blockLen, pSender->seq); + } else { + // read finish, update seq to end + pSender->seq = SYNC_SNAPSHOT_SEQ_END; + sSInfo(pSender, "vgId:%d, snapshot sender read to the end, blockLen:%d seq:%d", pSender->pSyncNode->vgId, + pSender->blockLen, pSender->seq); + return 0; + } } // build msg @@ -1188,19 +1191,28 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp } } - for (int64_t ack = pSndBuf->start; ack < pSndBuf->cursor; ++ack) { + for (int64_t ack = pSndBuf->start; ack <= pSndBuf->cursor; ++ack) { rpcFreeCont(pSndBuf->entries[ack % pSndBuf->size]); pSndBuf->entries[ack % pSndBuf->size] = NULL; pSndBuf->start = ack + 1; } - while (pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) { + while (pSender->seq != SYNC_SNAPSHOT_SEQ_END && pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) { + if (snapshotSend(pSender) != 0) { + code = terrno; + goto _out; + } + if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) { + pSndBuf->end = TMAX(pSender->seq + 1, pSndBuf->end); + } + } + + if (pSender->seq == SYNC_SNAPSHOT_SEQ_END && pSndBuf->end <= pSndBuf->start) { if (snapshotSend(pSender) != 0) { code = terrno; goto _out; } } - _out: taosThreadMutexUnlock(&pSndBuf->mutex); return code; From 811f1bbbea25bbbd2fc470f7cd80919b71fb8dc2 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 15:47:47 +0800 Subject: [PATCH 05/45] enh: tidy up logging msg in syncNodeOnSnapshotRsp --- source/libs/sync/src/syncSnapshot.c | 30 +++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 7e556b28f5..195354ac79 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -195,8 +195,8 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { goto _out; } - sSInfo(pSender, "snapshot sender started. signature:(%" PRId64 ", %" PRId64 "), to dnode:%d", pSender->term, - pSender->startTime, DID(&pMsg->destId)); + sSInfo(pSender, "snapshot sender start to dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", DID(&pMsg->destId), + pSender->term, pSender->startTime); code = 0; _out: @@ -233,8 +233,8 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { syncSnapBufferReset(pSender->pSndBuf); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - sSInfo(pSender, "snapshot sender stopped. signature:(%" PRId64 ", %" PRId64 "), to dnode:%d", pSender->term, - pSender->startTime, DID(&destId)); + sSInfo(pSender, "snapshot sender stop to dnode:%d. signature:(%" PRId64 ", %" PRId64 "), finish:%d", DID(&destId), + pSender->term, pSender->startTime, finish); } // when sender receive ack, call this function to send msg from seq @@ -522,8 +522,8 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p pReceiver->startTime = pPreMsg->startTime; ASSERT(pReceiver->startTime); - sRInfo(pReceiver, "snapshot receiver started. signature:(%" PRId64 ", %" PRId64 "), from dnode:%d", pReceiver->term, - pReceiver->startTime, DID(&pReceiver->fromId)); + sRInfo(pReceiver, "snapshot receiver start from dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", + DID(&pReceiver->fromId), pReceiver->term, pReceiver->startTime); } // just set start = false @@ -547,8 +547,8 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { syncSnapBufferReset(pReceiver->pRcvBuf); - sRInfo(pReceiver, "snapshot receiver stopped. signature:(%" PRId64 ", %" PRId64 "), from dnode:%d", pReceiver->term, - pReceiver->startTime, DID(&pReceiver->fromId)); + sRInfo(pReceiver, "snapshot receiver stop from dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", + DID(&pReceiver->fromId), pReceiver->term, pReceiver->startTime); } // when recv last snapshot block, apply data into snapshot @@ -1266,7 +1266,6 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // state, term, seq/ack if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender not leader"); sSError(pSender, "snapshot sender not leader"); terrno = TSDB_CODE_SYN_NOT_LEADER; goto _ERROR; @@ -1274,15 +1273,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { SyncTerm currentTerm = raftStoreGetTerm(pSyncNode); if (pMsg->term != currentTerm) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender and receiver term not match"); - sSError(pSender, "snapshot sender term not equal, msg term:%" PRId64 " currentTerm:%" PRId64, pMsg->term, + sSError(pSender, "snapshot sender term mismatch, msg term:%" PRId64 " currentTerm:%" PRId64, pMsg->term, currentTerm); terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; goto _ERROR; } if (pMsg->code != 0) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error code"); sSError(pSender, "snapshot sender receive error:%s 0x%x and stop sender", tstrerror(pMsg->code), pMsg->code); terrno = pMsg->code; goto _ERROR; @@ -1290,12 +1287,10 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // prepare , send begin msg if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq pre-snapshot"); return syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg); } if (pSender->pReader == NULL || pSender->finish) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "snapshot sender invalid"); sSError(pSender, "snapshot sender invalid error:%s 0x%x, pReader:%p finish:%d", tstrerror(pMsg->code), pMsg->code, pSender->pReader, pSender->finish); terrno = pMsg->code; @@ -1303,7 +1298,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { } if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq begin"); + sSInfo(pSender, "process seq begin"); if (snapshotSend(pSender) != 0) { goto _ERROR; } @@ -1312,7 +1307,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // receive ack is finish, close sender if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { - syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq end"); + sSInfo(pSender, "process seq end"); snapshotSenderStop(pSender, true); syncNodeReplicateReset(pSyncNode, &pMsg->srcId); return 0; @@ -1320,12 +1315,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // send next msg if (syncSnapBufferSend(pSender, ppMsg) != 0) { + sSError(pSender, "failed to send snapshot msg since %s. seq:%d", terrstr(), pSender->seq); goto _ERROR; } return 0; _ERROR: - snapshotSenderStop(pSender, true); + snapshotSenderStop(pSender, false); syncNodeReplicateReset(pSyncNode, &pMsg->srcId); return -1; } From 4d61e87c0f66fddd0ae3946b553772b8530fc044 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 17:11:32 +0800 Subject: [PATCH 06/45] enh: add signature info in logging msgs of snap replication --- source/libs/sync/src/syncSnapshot.c | 56 +++++++++++++---------------- source/libs/sync/src/syncUtil.c | 51 +++++++++++++------------- 2 files changed, 49 insertions(+), 58 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 195354ac79..ad782bd51d 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -195,8 +195,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { goto _out; } - sSInfo(pSender, "snapshot sender start to dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", DID(&pMsg->destId), - pSender->term, pSender->startTime); + sSInfo(pSender, "snapshot sender start, to dnode:%d.", DID(&pMsg->destId)); code = 0; _out: @@ -233,8 +232,7 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { syncSnapBufferReset(pSender->pSndBuf); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - sSInfo(pSender, "snapshot sender stop to dnode:%d. signature:(%" PRId64 ", %" PRId64 "), finish:%d", DID(&destId), - pSender->term, pSender->startTime, finish); + sSInfo(pSender, "snapshot sender stop, to dnode:%d, finish:%d", DID(&destId), finish); } // when sender receive ack, call this function to send msg from seq @@ -522,8 +520,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p pReceiver->startTime = pPreMsg->startTime; ASSERT(pReceiver->startTime); - sRInfo(pReceiver, "snapshot receiver start from dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", - DID(&pReceiver->fromId), pReceiver->term, pReceiver->startTime); + sRInfo(pReceiver, "snapshot receiver start, from dnode:%d.", DID(&pReceiver->fromId)); } // just set start = false @@ -547,8 +544,7 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { syncSnapBufferReset(pReceiver->pRcvBuf); - sRInfo(pReceiver, "snapshot receiver stop from dnode:%d. signature:(%" PRId64 ", %" PRId64 ")", - DID(&pReceiver->fromId), pReceiver->term, pReceiver->startTime); + sRInfo(pReceiver, "snapshot receiver stop, from dnode:%d.", DID(&pReceiver->fromId)); } // when recv last snapshot block, apply data into snapshot @@ -676,22 +672,22 @@ static int32_t syncNodeOnSnapshotPrep(SSyncNode *pSyncNode, SyncSnapshotSend *pM int32_t order = 0; if ((order = snapshotReceiverSignatureCmp(pReceiver, pMsg)) < 0) { sRInfo(pReceiver, - "received a new snapshot preparation. restart receiver" - "receiver signature: (%" PRId64 ", %" PRId64 "), msg signature:(%" PRId64 ", %" PRId64 ")", - pReceiver->term, pReceiver->startTime, pMsg->term, pMsg->startTime); + "received a new snapshot preparation. restart receiver." + " msg signature:(%" PRId64 ", %" PRId64 ")", + pMsg->term, pMsg->startTime); goto _START_RECEIVER; } else if (order == 0) { sRInfo(pReceiver, - "received a duplicate snapshot preparation. send reply" - "receiver signature: (%" PRId64 ", %" PRId64 "), msg signature:(%" PRId64 ", %" PRId64 ")", - pReceiver->term, pReceiver->startTime, pMsg->term, pMsg->startTime); + "received a duplicate snapshot preparation. send reply." + " msg signature:(%" PRId64 ", %" PRId64 ")", + pMsg->term, pMsg->startTime); goto _SEND_REPLY; } else { // ignore sRError(pReceiver, - "received a stale snapshot preparation. ignore" - "receiver signature: (%" PRId64 ", %" PRId64 "), msg signature:(%" PRId64 ", %" PRId64 ")", - pReceiver->term, pReceiver->startTime, pMsg->term, pMsg->startTime); + "received a stale snapshot preparation. ignore." + " msg signature:(%" PRId64 ", %" PRId64 ")", + pMsg->term, pMsg->startTime); terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; code = terrno; goto _SEND_REPLY; @@ -809,6 +805,8 @@ static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *p goto _SEND_REPLY; } + sRInfo(pReceiver, "snapshot begin"); + code = 0; _SEND_REPLY: if (code != 0 && terrno != 0) { @@ -1009,8 +1007,7 @@ _SEND_REPLY:; // int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { SyncSnapshotSend **ppMsg = (SyncSnapshotSend **)&pRpcMsg->pCont; - SyncSnapshotSend *pMsg = ppMsg[0]; - ASSERT(pMsg); + SyncSnapshotSend *pMsg = ppMsg[0]; SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; // if already drop replica, do not process @@ -1040,16 +1037,16 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER || pSyncNode->state == TAOS_SYNC_STATE_LEARNER) { if (pMsg->term == raftStoreGetTerm(pSyncNode)) { if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { - sInfo("vgId:%d, receive pre-snapshot msg of snapshot replication. signature:(%" PRId64 ", %" PRId64 ")", + sInfo("vgId:%d, receive prepare msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, pMsg->startTime); code = syncNodeOnSnapshotPrep(pSyncNode, pMsg); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { - sInfo("vgId:%d, receive begin msg of snapshot replication. signature:(%" PRId64 ", %" PRId64 ")", + sInfo("vgId:%d, receive begin msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, pMsg->startTime); code = syncNodeOnSnapshotBegin(pSyncNode, pMsg); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { - sInfo("vgId:%d, receive end msg of snapshot replication. signature: (%" PRId64 ", %" PRId64 ")", - pSyncNode->vgId, pMsg->term, pMsg->startTime); + sInfo("vgId:%d, receive end msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, + pMsg->term, pMsg->startTime); code = syncNodeOnSnapshotEnd(pSyncNode, pMsg); if (syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode) != 0) { sRError(pReceiver, "failed to reinit log buffer since %s", terrstr()); @@ -1059,7 +1056,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // force close, no response syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process force stop"); snapshotReceiverStop(pReceiver); - } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq <= SYNC_SNAPSHOT_SEQ_END) { + } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq data"); code = syncNodeOnSnapshotReceive(pSyncNode, ppMsg); } else { @@ -1139,10 +1136,7 @@ static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSend pSendMsg->startTime = pSender->startTime; pSendMsg->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - ASSERT(pSendMsg->startTime); - - sSInfo(pSender, "begin snapshot replication to dnode %d. startTime:%" PRId64, DID(&pSendMsg->destId), - pSendMsg->startTime); + sSInfo(pSender, "begin snapshot replication to dnode %d." PRId64, DID(&pSendMsg->destId)); // send msg syncLogSendSyncSnapshotSend(pSyncNode, pSendMsg, "snapshot sender reply pre"); @@ -1252,10 +1246,8 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // check signature int32_t order = 0; if ((order = snapshotSenderSignatureCmp(pSender, pMsg)) > 0) { - sSError(pSender, - "received a stale snapshot rsp. ignore it" - "sender signature: (%" PRId64 ", %" PRId64 "), msg signature:(%" PRId64 ", %" PRId64 ")", - pSender->term, pSender->startTime, pMsg->term, pMsg->startTime); + sSError(pSender, "received a stale snapshot rsp, msg signature:(%" PRId64 ", %" PRId64 "), ignore it.", pMsg->term, + pMsg->startTime); terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; return -1; } else if (order < 0) { diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 9acc17e130..dc16b0e958 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -266,22 +266,21 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer); va_end(argpointer); - taosPrintLog(flags, level, dflag, - "vgId:%d, %s, sync:%s, snap-sender:{%p start:%" PRId64 " end:%" PRId64 " last-index:%" PRId64 - " last-term:%" PRIu64 " last-cfg:%" PRId64 - ", seq:%d ack:%d finish:%d, as:%d dnode:%d}" - ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 - ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64 - "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 - ", chging:%d, restore:%d, quorum:%d, lc-timer:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s", - pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->snapshotParam.start, - pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, pSender->snapshot.lastApplyTerm, - pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, pSender->replicaIndex, - DID(&pNode->replicasId[pSender->replicaIndex]), raftStoreGetTerm(pNode), pNode->commitIndex, - logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, - pNode->changing, pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, - pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); + taosPrintLog( + flags, level, dflag, + "vgId:%d, %s, sync:%s, snap-sender:%p signature:(%" PRId64 ", %" PRId64 "), {start:%" PRId64 " end:%" PRId64 + " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 + ", seq:%d ack:%d finish:%d, as:%d, to-dnode:%d}" + ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64 + ", snap:{last-index:%" PRId64 ", term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, peer:%s, cfg:%s", + pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->term, pSender->startTime, + pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, + pSender->replicaIndex, DID(&pNode->replicasId[pSender->replicaIndex]), raftStoreGetTerm(pNode), + pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, + snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, + pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, pNode->quorum, peerStr, cfgStr); } void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver, @@ -316,19 +315,19 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df taosPrintLog( flags, level, dflag, "vgId:%d, %s, sync:%s," - " snap-receiver:{%p started:%d acked:%d term:%" PRIu64 " start-time:%" PRId64 " from-dnode:%d, start:%" PRId64 - " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 + " snap-receiver:%p signature:(%" PRId64 ", %" PRId64 "), {start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 + " from-dnode:%d, start:%" PRId64 " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 "}" ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", last-term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 - ", chging:%d, restore:%d, quorum:%d, lc-timers:{elect:%" PRId64 ", hb:%" PRId64 "}, peer:%s, cfg:%s", - pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->start, pReceiver->ack, pReceiver->term, - pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, - pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex, - raftStoreGetTerm(pNode), pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, - snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, - pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, - syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr); + ", chging:%d, restore:%d, quorum:%d, peer:%s, cfg:%s", + pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->term, pReceiver->startTime, pReceiver->start, + pReceiver->ack, pReceiver->term, pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, + pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, + pReceiver->snapshot.lastConfigIndex, raftStoreGetTerm(pNode), pNode->commitIndex, logBeginIndex, logLastIndex, + pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, + pNode->raftCfg.batchSize, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, + pNode->restoreFinish, pNode->quorum, peerStr, cfgStr); } void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s) { From 95188ab8c387d10ad54c7a58a8c4264dc3274864 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 17:42:17 +0800 Subject: [PATCH 07/45] enh: adjust some logging msgs for sync log replication mgr --- source/libs/sync/src/syncPipeline.c | 34 ++++++++++++++--------------- source/libs/sync/src/syncSnapshot.c | 8 +++---- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index a7ee37cc3b..f2386797c1 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -797,7 +797,7 @@ _out: pMgr->retryBackoff = syncLogReplGetNextRetryBackoff(pMgr); SSyncLogBuffer* pBuf = pNode->pLogBuf; sInfo("vgId:%d, resend %d sync log entries. dest:%" PRIx64 ", indexes:%" PRId64 " ..., terms: ... %" PRId64 - ", retryWaitMs:%" PRId64 ", mgr: [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 + ", retryWaitMs:%" PRId64 ", repl-mgr:[%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, count, pDestId->addr, firstIndex, term, retryWaitMs, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); @@ -815,9 +815,9 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn ASSERT(pMgr->matchIndex == 0); if (pMsg->matchIndex < 0) { pMgr->restored = true; - sInfo("vgId:%d, sync log repl restored. peer: dnode:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 - ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, DID(&destId), destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + sInfo("vgId:%d, sync log repl restored. peer: dnode:%d (%" PRIx64 "), repl-mgr:[%" PRId64 " %" PRId64 ", %" PRId64 + "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, DID(&destId), destId.addr, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } @@ -832,9 +832,9 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn if (pMsg->success && pMsg->matchIndex == pMsg->lastSendIndex) { pMgr->matchIndex = pMsg->matchIndex; pMgr->restored = true; - sInfo("vgId:%d, sync log repl restored. peer: dnode:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 - ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, DID(&destId), destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + sInfo("vgId:%d, sync log repl restored. peer: dnode:%d (%" PRIx64 "), repl-mgr:[%" PRId64 " %" PRId64 ", %" PRId64 + "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, DID(&destId), destId.addr, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } @@ -958,10 +958,10 @@ int32_t syncLogReplProbe(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex inde pMgr->endIndex = index + 1; SSyncLogBuffer* pBuf = pNode->pLogBuf; - sTrace("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term:%" PRId64 ". mgr (rs:%d): [%" PRId64 - " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, pDestId->addr, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, - pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + sTrace("vgId:%d, probe peer:%" PRIx64 " with msg of index:%" PRId64 " term:%" PRId64 ". repl-mgr:[%" PRId64 + " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, pDestId->addr, index, term, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, pBuf->startIndex, + pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } @@ -1002,9 +1002,9 @@ int32_t syncLogReplAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { pMgr->endIndex = index + 1; if (barrier) { - sInfo("vgId:%d, replicated sync barrier to dnode:%d. index:%" PRId64 ", term:%" PRId64 - ", repl mgr: rs(%d) [%" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, DID(pDestId), index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex); + sInfo("vgId:%d, replicated sync barrier to dnode:%d. index:%" PRId64 ", term:%" PRId64 ", repl-mgr:[%" PRId64 + " %" PRId64 ", %" PRId64 ")", + pNode->vgId, DID(pDestId), index, term, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex); break; } } @@ -1013,10 +1013,10 @@ int32_t syncLogReplAttempt(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { SSyncLogBuffer* pBuf = pNode->pLogBuf; sTrace("vgId:%d, replicated %d msgs to peer:%" PRIx64 ". indexes:%" PRId64 "..., terms: ...%" PRId64 - ", mgr: (rs:%d) [%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 + ", repl-mgr:[%" PRId64 " %" PRId64 ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", - pNode->vgId, count, pDestId->addr, firstIndex, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, - pMgr->endIndex, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + pNode->vgId, count, pDestId->addr, firstIndex, term, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); return 0; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index ad782bd51d..7e431111f2 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -258,13 +258,11 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { if (pSender->blockLen > 0) { // has read data - sSDebug(pSender, "vgId:%d, snapshot sender continue to read, blockLen:%d seq:%d", pSender->pSyncNode->vgId, - pSender->blockLen, pSender->seq); + sSDebug(pSender, "snapshot sender continue to read, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); } else { // read finish, update seq to end pSender->seq = SYNC_SNAPSHOT_SEQ_END; - sSInfo(pSender, "vgId:%d, snapshot sender read to the end, blockLen:%d seq:%d", pSender->pSyncNode->vgId, - pSender->blockLen, pSender->seq); + sSInfo(pSender, "snapshot sender read to the end, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); return 0; } } @@ -1136,7 +1134,7 @@ static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSend pSendMsg->startTime = pSender->startTime; pSendMsg->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - sSInfo(pSender, "begin snapshot replication to dnode %d." PRId64, DID(&pSendMsg->destId)); + sSInfo(pSender, "begin snapshot replication to dnode %d.", DID(&pSendMsg->destId)); // send msg syncLogSendSyncSnapshotSend(pSyncNode, pSendMsg, "snapshot sender reply pre"); From 374217cefffefcedae3c68a2a52d9a4eeed47b86 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 19:20:53 +0800 Subject: [PATCH 08/45] fixup: adjust a logging msg in syncNodeStartSnapshot --- source/libs/sync/src/syncSnapshot.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 7e431111f2..c2ba30a6bb 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -383,8 +383,6 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) { return 0; } - sSInfo(pSender, "snapshot sender start"); - int32_t code = snapshotSenderStart(pSender); if (code != 0) { sSError(pSender, "snapshot sender start error since %s", terrstr()); @@ -803,8 +801,6 @@ static int32_t syncNodeOnSnapshotBegin(SSyncNode *pSyncNode, SyncSnapshotSend *p goto _SEND_REPLY; } - sRInfo(pReceiver, "snapshot begin"); - code = 0; _SEND_REPLY: if (code != 0 && terrno != 0) { From 4e3a8b893df4c6ee66eb887758f0da0126e617bc Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 24 Oct 2023 20:03:48 +0800 Subject: [PATCH 09/45] enh: restore wal log from snapshot after finish --- source/libs/sync/src/syncSnapshot.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index c2ba30a6bb..8a83891735 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -539,8 +539,6 @@ void snapshotReceiverStop(SSyncSnapshotReceiver *pReceiver) { } syncSnapBufferReset(pReceiver->pRcvBuf); - - sRInfo(pReceiver, "snapshot receiver stop, from dnode:%d.", DID(&pReceiver->fromId)); } // when recv last snapshot block, apply data into snapshot @@ -548,7 +546,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap int32_t code = 0; if (pReceiver->pWriter != NULL) { // write data - sRInfo(pReceiver, "snapshot receiver write finish, blockLen:%d seq:%d", pMsg->dataLen, pMsg->seq); + sRInfo(pReceiver, "snapshot receiver write about to finish, blockLen:%d seq:%d", pMsg->dataLen, pMsg->seq); if (pMsg->dataLen > 0) { code = pReceiver->pSyncNode->pFsm->FpSnapshotDoWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, pMsg->data, pMsg->dataLen); @@ -558,15 +556,6 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap } } - // reset wal - sRInfo(pReceiver, "snapshot receiver log restore"); - code = - pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); - if (code != 0) { - sRError(pReceiver, "failed to snapshot receiver log restore since %s", terrstr()); - return -1; - } - // update commit index if (pReceiver->snapshot.lastApplyIndex > pReceiver->pSyncNode->commitIndex) { pReceiver->pSyncNode->commitIndex = pReceiver->snapshot.lastApplyIndex; @@ -578,7 +567,6 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap } // stop writer, apply data - sRInfo(pReceiver, "snapshot receiver apply write"); code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true, &pReceiver->snapshot); if (code != 0) { @@ -586,10 +574,21 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap return -1; } pReceiver->pWriter = NULL; + sRInfo(pReceiver, "snapshot receiver write stopped"); // update progress pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; + // reset wal + code = + pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); + if (code != 0) { + sRError(pReceiver, "failed to snapshot receiver log restore since %s", terrstr()); + return -1; + } + sRInfo(pReceiver, "wal log restored from snapshot"); + + // get fsmState SSnapshot snapshot = {0}; pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); pReceiver->pSyncNode->fsmState = snapshot.state; @@ -599,8 +598,6 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap return -1; } - // event log - sRInfo(pReceiver, "snapshot receiver got last data and apply snapshot finished"); return 0; } From 8b2d57504c50de10130808abc3ada23153790c84 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Wed, 25 Oct 2023 13:54:45 +0800 Subject: [PATCH 10/45] enhance: bi mode default tag scan --- source/libs/parser/src/parAstCreater.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 06c098af92..7ad61f4324 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -978,6 +978,9 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr SNodeList* pHint) { CHECK_PARSER_STATUS(pCxt); SNode* select = createSelectStmtImpl(isDistinct, pProjectionList, pTable, pHint); + if (pCxt->pQueryCxt->biMode) { + setSelectStmtTagMode(pCxt, select, true); + } CHECK_OUT_OF_MEM(select); return select; } From 7d9d1c6877a8fee601822d4199c210eac297cb22 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 25 Oct 2023 14:50:53 +0800 Subject: [PATCH 11/45] enh: terminate snap replication on timeout --- include/libs/sync/sync.h | 1 + source/libs/sync/src/syncTimeout.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index ad525a2aa7..e3b5f3611c 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -46,6 +46,7 @@ extern "C" { #define SYNC_HEARTBEAT_SLOW_MS 1500 #define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500 #define SYNC_SNAP_RESEND_MS 1000 * 60 +#define SYNC_SNAP_TIMEOUT_MS 1000 * 180 #define SYNC_VND_COMMIT_MIN_MS 3000 diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 37166805ce..91c7494fa4 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -78,11 +78,9 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) { SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(ths->peersId[i])); if (pSender != NULL) { if (ths->isStart && ths->state == TAOS_SYNC_STATE_LEADER && pSender->start && - timeNow - pSender->lastSendTime > SYNC_SNAP_RESEND_MS) { - snapshotReSend(pSender); - } else { - sTrace("vgId:%d, do not resend: nstart%d, now:%" PRId64 ", lstsend:%" PRId64 ", diff:%" PRId64, ths->vgId, - ths->isStart, timeNow, pSender->lastSendTime, timeNow - pSender->lastSendTime); + timeNow - pSender->lastSendTime > SYNC_SNAP_TIMEOUT_MS) { + sSError(pSender, "snapshot timeout, terminate. lastSendTime:%d", pSender->lastSendTime); + snapshotSenderStop(pSender, false); } } } From ec5b1f2ec175b33c5aa8f6b40ce98e006787d2fa Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 25 Oct 2023 15:04:14 +0800 Subject: [PATCH 12/45] enh: logging buf info for snapshot reader and sender --- source/libs/sync/inc/syncSnapshot.h | 2 +- source/libs/sync/src/syncSnapshot.c | 16 ++-------- source/libs/sync/src/syncUtil.c | 49 ++++++++++++++++------------- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 0332204769..93c62544f2 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -56,7 +56,7 @@ typedef struct SSyncSnapshotSender { int64_t lastSendTime; bool finish; - // buffer + // ring buffer for ack SSyncSnapBuffer *pSndBuf; // init when create diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 8a83891735..751f777b18 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -345,20 +345,6 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { return 0; } -static int32_t snapshotSenderUpdateProgress(SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { - if (pMsg->ack != pSender->seq) { - sSError(pSender, "snapshot sender update seq failed, ack:%d seq:%d", pMsg->ack, pSender->seq); - terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; - return -1; - } - - pSender->ack = pMsg->ack; - pSender->seq++; - - sSDebug(pSender, "snapshot sender update seq:%d", pSender->seq); - return 0; -} - // return 0, start ok // return 1, last snapshot finish ok // return -1, error @@ -1182,6 +1168,8 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp pSndBuf->start = ack + 1; } + pSender->ack = pSndBuf->start - 1; + while (pSender->seq != SYNC_SNAPSHOT_SEQ_END && pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) { if (snapshotSend(pSender) != 0) { code = terrno; diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index dc16b0e958..9e6ea94e78 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -266,21 +266,24 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer); va_end(argpointer); - taosPrintLog( - flags, level, dflag, - "vgId:%d, %s, sync:%s, snap-sender:%p signature:(%" PRId64 ", %" PRId64 "), {start:%" PRId64 " end:%" PRId64 - " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 - ", seq:%d ack:%d finish:%d, as:%d, to-dnode:%d}" - ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64 - ", snap:{last-index:%" PRId64 ", term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 - ", chging:%d, restore:%d, quorum:%d, peer:%s, cfg:%s", - pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->term, pSender->startTime, - pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, - pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, pSender->finish, - pSender->replicaIndex, DID(&pNode->replicasId[pSender->replicaIndex]), raftStoreGetTerm(pNode), - pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, - snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, - pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, pNode->quorum, peerStr, cfgStr); + taosPrintLog(flags, level, dflag, + "vgId:%d, %s, sync:%s, snap-sender:%p signature:(%" PRId64 ", %" PRId64 "), {start:%" PRId64 + " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 + ", seq:%d, ack:%d, " + " buf:[%" PRId64 " %" PRId64 ", %" PRId64 + "), finish:%d, as:%d, to-dnode:%d}" + ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 + ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", term:%" PRIu64 + "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, peer:%s, cfg:%s", + pNode->vgId, eventLog, syncStr(pNode->state), pSender, pSender->term, pSender->startTime, + pSender->snapshotParam.start, pSender->snapshotParam.end, pSender->snapshot.lastApplyIndex, + pSender->snapshot.lastApplyTerm, pSender->snapshot.lastConfigIndex, pSender->seq, pSender->ack, + pSender->pSndBuf->start, pSender->pSndBuf->cursor, pSender->pSndBuf->end, pSender->finish, + pSender->replicaIndex, DID(&pNode->replicasId[pSender->replicaIndex]), raftStoreGetTerm(pNode), + pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, + snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, pNode->replicaNum, + pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, pNode->quorum, peerStr, cfgStr); } void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotReceiver* pReceiver, @@ -315,19 +318,21 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df taosPrintLog( flags, level, dflag, "vgId:%d, %s, sync:%s," - " snap-receiver:%p signature:(%" PRId64 ", %" PRId64 "), {start:%d ack:%d term:%" PRIu64 " start-time:%" PRId64 + " snap-receiver:%p signature:(%" PRId64 ", %" PRId64 "), {start:%d ack:%d buf:[%" PRId64 " %" PRId64 ", %" PRId64 + ")" " from-dnode:%d, start:%" PRId64 " end:%" PRId64 " last-index:%" PRId64 " last-term:%" PRIu64 " last-cfg:%" PRId64 "}" ", term:%" PRIu64 ", commit-index:%" PRId64 ", firstver:%" PRId64 ", lastver:%" PRId64 ", min-match:%" PRId64 ", snap:{last-index:%" PRId64 ", last-term:%" PRIu64 "}, standby:%d, batch-sz:%d, replicas:%d, last-cfg:%" PRId64 ", chging:%d, restore:%d, quorum:%d, peer:%s, cfg:%s", pNode->vgId, eventLog, syncStr(pNode->state), pReceiver, pReceiver->term, pReceiver->startTime, pReceiver->start, - pReceiver->ack, pReceiver->term, pReceiver->startTime, DID(&pReceiver->fromId), pReceiver->snapshotParam.start, - pReceiver->snapshotParam.end, pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, - pReceiver->snapshot.lastConfigIndex, raftStoreGetTerm(pNode), pNode->commitIndex, logBeginIndex, logLastIndex, - pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, - pNode->raftCfg.batchSize, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, - pNode->restoreFinish, pNode->quorum, peerStr, cfgStr); + pReceiver->ack, pReceiver->pRcvBuf->start, pReceiver->pRcvBuf->cursor, pReceiver->pRcvBuf->end, + DID(&pReceiver->fromId), pReceiver->snapshotParam.start, pReceiver->snapshotParam.end, + pReceiver->snapshot.lastApplyIndex, pReceiver->snapshot.lastApplyTerm, pReceiver->snapshot.lastConfigIndex, + raftStoreGetTerm(pNode), pNode->commitIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, + snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->raftCfg.isStandBy, pNode->raftCfg.batchSize, + pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, pNode->quorum, peerStr, + cfgStr); } void syncLogRecvTimer(SSyncNode* pSyncNode, const SyncTimeout* pMsg, const char* s) { From 25aade13336149bcbcd3bd5384b554d3b9d368b0 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 Oct 2023 19:44:21 +0800 Subject: [PATCH 13/45] feat: alloc disk acorrding to avail disk space --- source/libs/tfs/src/tfsTier.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/libs/tfs/src/tfsTier.c b/source/libs/tfs/src/tfsTier.c index 1c47182e2a..d4f228a537 100644 --- a/source/libs/tfs/src/tfsTier.c +++ b/source/libs/tfs/src/tfsTier.c @@ -110,7 +110,9 @@ int32_t tfsAllocDiskOnTier(STfsTier *pTier) { } int32_t retId = -1; + int64_t avail = 0; for (int32_t id = 0; id < TFS_MAX_DISKS_PER_TIER; ++id) { +#if 0 // round-robin int32_t diskId = (pTier->nextid + id) % pTier->ndisk; STfsDisk *pDisk = pTier->disks[diskId]; @@ -126,6 +128,18 @@ int32_t tfsAllocDiskOnTier(STfsTier *pTier) { terrno = 0; pTier->nextid = (diskId + 1) % pTier->ndisk; break; +#else // select the disk with the most available space + STfsDisk *pDisk = pTier->disks[id]; + if (pDisk == NULL) continue; + + if (pDisk->size.avail < tsMinDiskFreeSize) continue; + + if (pDisk->size.avail > avail) { + avail = pDisk->size.avail; + retId = id; + terrno = 0; + } +#endif } tfsUnLockTier(pTier); From fe553352b85812fc4c24934f50fd440e6007f44e Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Wed, 25 Oct 2023 20:25:57 +0800 Subject: [PATCH 14/45] enh: cache snap blocks sent in snapshotSend for resending --- source/libs/sync/inc/syncSnapshot.h | 13 ++++ source/libs/sync/src/syncSnapshot.c | 108 +++++++++++++++++----------- 2 files changed, 81 insertions(+), 40 deletions(-) diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 93c62544f2..e68702568a 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -37,8 +37,21 @@ typedef struct SSyncSnapBuffer { int64_t end; int64_t size; TdThreadMutex mutex; + void (*entryDeleteCb)(void *ptr); } SSyncSnapBuffer; +typedef struct SyncSnapBlock { + int32_t seq; + int8_t acked; + int64_t sendTimeMs; + + int16_t blockType; + void *pBlock; + int32_t blockLen; +} SyncSnapBlock; + +void syncSnapBlockDestroy(void *ptr); + typedef struct SSyncSnapshotSender { int8_t start; int32_t seq; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 751f777b18..eee0ab2cc9 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -26,7 +26,9 @@ static void syncSnapBufferReset(SSyncSnapBuffer *pBuf) { taosThreadMutexLock(&pBuf->mutex); for (int64_t i = pBuf->start; i < pBuf->end; ++i) { - rpcFreeCont(pBuf->entries[i % pBuf->size]); + if (pBuf->entryDeleteCb) { + pBuf->entryDeleteCb(pBuf->entries[i % pBuf->size]); + } pBuf->entries[i % pBuf->size] = NULL; } pBuf->start = 1; @@ -85,17 +87,29 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; - pSender->pSndBuf = syncSnapBufferCreate(); - if (pSender->pSndBuf == NULL) { + SSyncSnapBuffer *pSndBuf = syncSnapBufferCreate(); + if (pSndBuf == NULL) { taosMemoryFree(pSender); pSender = NULL; return NULL; } - syncSnapBufferReset(pSender->pSndBuf); + pSndBuf->entryDeleteCb = syncSnapBlockDestroy; + pSender->pSndBuf = pSndBuf; + syncSnapBufferReset(pSender->pSndBuf); return pSender; } +void syncSnapBlockDestroy(void *ptr) { + SyncSnapBlock *pBlk = ptr; + if (pBlk->pBlock != NULL) { + taosMemoryFree(pBlk->pBlock); + pBlk->pBlock = NULL; + pBlk->blockLen = 0; + } + taosMemoryFree(pBlk); +} + void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender == NULL) return; @@ -238,23 +252,26 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { // when sender receive ack, call this function to send msg from seq // seq = ack + 1, already updated static int32_t snapshotSend(SSyncSnapshotSender *pSender) { - // free memory last time (current seq - 1) - if (pSender->pCurrentBlock != NULL) { - taosMemoryFree(pSender->pCurrentBlock); - pSender->pCurrentBlock = NULL; - pSender->blockLen = 0; - } + int32_t code = -1; + SyncSnapBlock *pBlk = NULL; if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) { pSender->seq++; + pBlk = taosMemoryCalloc(1, sizeof(SyncSnapBlock)); + if (pBlk == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OUT; + } + // read data - int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, - &pSender->pCurrentBlock, &pSender->blockLen); + int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, &pBlk->pBlock, + &pBlk->blockLen); if (ret != 0) { sSError(pSender, "snapshot sender read failed since %s", terrstr()); - return -1; + goto _OUT; } + pBlk->seq = pSender->seq; if (pSender->blockLen > 0) { // has read data @@ -263,7 +280,8 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { // read finish, update seq to end pSender->seq = SYNC_SNAPSHOT_SEQ_END; sSInfo(pSender, "snapshot sender read to the end, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); - return 0; + code = 0; + goto _OUT; } } @@ -271,7 +289,7 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { SRpcMsg rpcMsg = {0}; if (syncBuildSnapshotSend(&rpcMsg, pSender->blockLen, pSender->pSyncNode->vgId) != 0) { sSError(pSender, "vgId:%d, snapshot sender build msg failed since %s", pSender->pSyncNode->vgId, terrstr()); - return -1; + goto _OUT; } SyncSnapshotSend *pMsg = rpcMsg.pCont; @@ -286,25 +304,35 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { pMsg->startTime = pSender->startTime; pMsg->seq = pSender->seq; - if (pSender->pCurrentBlock != NULL) { - memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); - } - - // event log - if (pSender->seq == SYNC_SNAPSHOT_SEQ_END) { - syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender finish"); - } else { - syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender sending"); + if (pBlk != NULL && pBlk->pBlock != NULL) { + memcpy(pMsg->data, pBlk->pBlock, pBlk->blockLen); } // send msg if (syncNodeSendMsgById(&pMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { sSError(pSender, "snapshot sender send msg failed since %s", terrstr()); - return -1; + goto _OUT; } - pSender->lastSendTime = taosGetTimestampMs(); - return 0; + // put in buffer + int64_t nowMs = taosGetTimestampMs(); + if (pBlk) { + ASSERT(pBlk->seq != SYNC_SNAPSHOT_SEQ_END); + pBlk->sendTimeMs = nowMs; + pSender->pSndBuf->entries[pSender->seq % pSender->pSndBuf->size] = pBlk; + pBlk = NULL; + pSender->pSndBuf->end = pSender->seq + 1; + } + + pSender->lastSendTime = nowMs; + code = 0; + +_OUT:; + if (pBlk != NULL) { + syncSnapBlockDestroy(pBlk); + pBlk = NULL; + } + return code; } // send snapshot data from cache @@ -319,7 +347,7 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { SyncSnapshotSend *pMsg = rpcMsg.pCont; pMsg->srcId = pSender->pSyncNode->myRaftId; pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - pMsg->term = raftStoreGetTerm(pSender->pSyncNode); + pMsg->term = pSender->term; pMsg->beginIndex = pSender->snapshotParam.start; pMsg->lastIndex = pSender->snapshot.lastApplyIndex; pMsg->lastTerm = pSender->snapshot.lastApplyTerm; @@ -332,9 +360,6 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); } - // event log - syncLogSendSyncSnapshotSend(pSender->pSyncNode, pMsg, "snapshot sender resend"); - // send msg if (syncNodeSendMsgById(&pMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { sSError(pSender, "snapshot sender resend msg failed since %s", terrstr()); @@ -401,12 +426,14 @@ SSyncSnapshotReceiver *snapshotReceiverCreate(SSyncNode *pSyncNode, SRaftId from pReceiver->snapshot.lastApplyTerm = 0; pReceiver->snapshot.lastConfigIndex = SYNC_INDEX_INVALID; - pReceiver->pRcvBuf = syncSnapBufferCreate(); - if (pReceiver->pRcvBuf == NULL) { + SSyncSnapBuffer *pRcvBuf = syncSnapBufferCreate(); + if (pRcvBuf == NULL) { taosMemoryFree(pReceiver); pReceiver = NULL; return NULL; } + pRcvBuf->entryDeleteCb = rpcFreeCont; + pReceiver->pRcvBuf = pRcvBuf; syncSnapBufferReset(pReceiver->pRcvBuf); return pReceiver; @@ -884,7 +911,7 @@ static int32_t syncSnapBufferRecv(SSyncSnapshotReceiver *pReceiver, SyncSnapshot } pRcvBuf->start = seq + 1; syncSnapSendRsp(pReceiver, pRcvBuf->entries[seq % pRcvBuf->size], code); - rpcFreeCont(pRcvBuf->entries[seq % pRcvBuf->size]); + pRcvBuf->entryDeleteCb(pRcvBuf->entries[seq % pRcvBuf->size]); pRcvBuf->entries[seq % pRcvBuf->size] = NULL; if (code) goto _out; } @@ -1148,14 +1175,15 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp ASSERT(pSndBuf->start <= pSndBuf->cursor + 1 && pSndBuf->cursor < pSndBuf->end); - if (pMsg->ack > pSndBuf->cursor && pSndBuf->entries[pMsg->ack % pSndBuf->size] == NULL) { - pSndBuf->entries[pMsg->ack % pSndBuf->size] = pMsg; - ppMsg[0] = NULL; - pSndBuf->end = TMAX(pMsg->ack + 1, pSndBuf->end); + if (pMsg->ack > pSndBuf->cursor && pMsg->ack < pSndBuf->end) { + SyncSnapBlock *pBlk = pSndBuf->entries[pMsg->ack % pSndBuf->size]; + ASSERT(pBlk); + pBlk->acked = 1; } for (int64_t ack = pSndBuf->cursor + 1; ack < pSndBuf->end; ++ack) { - if (pSndBuf->entries[ack % pSndBuf->size]) { + SyncSnapBlock *pBlk = pSndBuf->entries[ack % pSndBuf->size]; + if (pBlk->acked) { pSndBuf->cursor = ack; } else { break; @@ -1163,7 +1191,7 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp } for (int64_t ack = pSndBuf->start; ack <= pSndBuf->cursor; ++ack) { - rpcFreeCont(pSndBuf->entries[ack % pSndBuf->size]); + pSndBuf->entryDeleteCb(pSndBuf->entries[ack % pSndBuf->size]); pSndBuf->entries[ack % pSndBuf->size] = NULL; pSndBuf->start = ack + 1; } From dc03d8cd1a7638b2b5d9b2e99bb12979f98767c6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 26 Oct 2023 20:07:38 +0800 Subject: [PATCH 15/45] disable tfs unit test --- source/libs/tfs/test/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/tfs/test/CMakeLists.txt b/source/libs/tfs/test/CMakeLists.txt index ee28dcf723..2fd0836a1d 100644 --- a/source/libs/tfs/test/CMakeLists.txt +++ b/source/libs/tfs/test/CMakeLists.txt @@ -8,7 +8,7 @@ target_link_libraries( PUBLIC gtest_main ) -add_test( - NAME tfs_test - COMMAND tfs_test -) +# add_test( +# NAME tfs_test +# COMMAND tfs_test +# ) From 70850697a48445e103badb6519e2642ff059e0f8 Mon Sep 17 00:00:00 2001 From: wangjiaming0909 <604227650@qq.com> Date: Wed, 25 Oct 2023 20:01:22 +0800 Subject: [PATCH 16/45] feat: support to_timestamp/to_char fix comments --- docs/en/12-taos-sql/10-function.md | 5 +- docs/zh/12-taos-sql/10-function.md | 9 +- include/common/ttime.h | 13 +- source/common/src/ttime.c | 229 ++++++++++++------ source/common/test/commonTests.cpp | 20 +- source/libs/function/src/builtins.c | 2 +- source/libs/scalar/src/sclfunc.c | 39 ++- .../2-query/func_to_char_timestamp.py | 25 +- 8 files changed, 236 insertions(+), 106 deletions(-) diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 266cdb4958..c986a98e46 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -486,7 +486,7 @@ return_timestamp: { #### TO_CHAR ```sql -TO_CHAR(ts, str_literal) +TO_CHAR(ts, format_str_literal) ``` **Description**: Convert a ts column to string as the format specified @@ -539,11 +539,12 @@ TO_CHAR(ts, str_literal) - When `ms`,`us`,`ns` are used in `to_char`, like `to_char(ts, 'yyyy-mm-dd hh:mi:ss.ms.us.ns')`, The time of `ms`,`us`,`ns` corresponds to the same fraction seconds. When ts is `1697182085123`, the output of `ms` is `123`, `us` is `123000`, `ns` is `123000000`. - If we want to output some characters of format without converting, surround it with double quotes. `to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. If want to output double quotes, add a back slash before double quote, like `to_char(ts, '\"yyyy-mm-dd\"')` will output `"2023-10-10"`. - For formats that output digits, the uppercase and lowercase formats are the same. +- The local time zone will be used to convert the timestamp. #### TO_TIMESTAMP ```sql -TO_TIMESTAMP(str_literal, str_literal) +TO_TIMESTAMP(ts_str_literal, format_str_literal) ``` **Description**: Convert a formated timestamp string to a timestamp diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 806ff3c6a8..44ab3d5091 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -486,7 +486,7 @@ return_timestamp: { #### TO_CHAR ```sql -TO_CHAR(ts, str_literal) +TO_CHAR(ts, format_str_literal) ``` **功能说明**: 将timestamp类型按照指定格式转换为字符串 @@ -504,7 +504,7 @@ TO_CHAR(ts, str_literal) | **格式** | **说明**| **例子** | | --- | --- | --- | |AM,am,PM,pm| 无点分隔的上午下午 | 07:00:00am| -|A.M.,a.m.,P.M.,p.m.| 有点分割的上午下午| 07:00:00a.m.| +|A.M.,a.m.,P.M.,p.m.| 有点分隔的上午下午| 07:00:00a.m.| |YYYY,yyyy|年, 4个及以上数字| 2023-10-10| |YYY,yyy| 年, 最后3位数字| 023-10-10| |YY,yy| 年, 最后2位数字| 23-10-10| @@ -537,13 +537,14 @@ TO_CHAR(ts, str_literal) **使用说明**: - `Month`, `Day`等的输出格式是左对齐的, 右侧添加空格, 如`2023-OCTOBER -01`, `2023-SEPTEMBER-01`, 9月是月份中英文字母数最长的, 因此9月没有空格. 星期类似. - 使用`ms`, `us`, `ns`时, 以上三种格式的输出只在精度上不同, 比如ts为 `1697182085123`, `ms` 的输出为 `123`, `us` 的输出为 `123000`, `ns` 的输出为 `123000000`. -- 如果想要在格式串中指定某些部分不做转换, 可以使用双引号, 如`to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. 如果想要输出双引号, 那么在双引号之前加一个反斜杠, 如 `to_char(ts, '\"yyyy-mm-dd\"')` 将会输出 `"2023-10-10"`. +- 时间格式中无法匹配规则的内容会直接输出. 如果想要在格式串中指定某些能够匹配规则的部分不做转换, 可以使用双引号, 如`to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. 如果想要输出双引号, 那么在双引号之前加一个反斜杠, 如 `to_char(ts, '\"yyyy-mm-dd\"')` 将会输出 `"2023-10-10"`. - 那些输出是数字的格式, 如`YYYY`, `DD`, 大写与小写意义相同, 即`yyyy` 和 `YYYY` 可以互换. +- 默认输出的时间为本地时区的时间. #### TO_TIMESTAMP ```sql -TO_TIMESTAMP(str_literal, str_literal) +TO_TIMESTAMP(ts_str_literal, format_str_literal) ``` **功能说明**: 将字符串按照指定格式转化为时间戳. diff --git a/include/common/ttime.h b/include/common/ttime.h index 75bbcddd0e..306b5105d0 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -100,15 +100,22 @@ int32_t taosTm2Ts(struct STm* tm, int64_t* ts, int32_t precision); /// @brief convert a timestamp to a formatted string /// @param format the timestamp format, must null terminated -void taosTs2Char(const char* format, int64_t ts, int32_t precision, char* out); +/// @param [in,out] formats the formats array pointer generated. Shouldn't be NULL. +/// If (*formats == NULL), [format] will be used and [formats] will be updated to the new generated +/// formats array; If not NULL, [formats] will be used instead of [format] to skip parse formats again. +/// @param out output buffer, should be initialized by memset +/// @notes remember to free the generated formats +void taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t precision, char* out, int32_t outLen); /// @brief convert a formatted timestamp string to a timestamp /// @param format must null terminated +/// @param [in, out] formats, see taosTs2Char /// @param tsStr must null terminated /// @retval 0 for success, otherwise error occured -int32_t taosChar2Ts(const char* format, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, +/// @notes remember to free the generated formats even when error occured +int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, int32_t errMsgLen); -void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out); +void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen); int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr); #ifdef __cplusplus diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 3450e32f4a..aad844da88 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -1008,7 +1008,6 @@ typedef enum { TSFKW_Day, // Sunday, Monday TSFKW_DY, // MON, TUE TSFKW_Dy, // Mon, Tue - TSFKW_dy, // mon, tue TSFKW_D, // 1-7 -> Sunday(1) -> Saturday(7) TSFKW_HH24, TSFKW_HH12, @@ -1021,12 +1020,12 @@ typedef enum { TSFKW_Mon, TSFKW_MS, TSFKW_NS, - TSFKW_OF, + //TSFKW_OF, TSFKW_PM, TSFKW_P_M, TSFKW_SS, - // TSFKW_TZM, TSFKW_TZH, + // TSFKW_TZM, // TSFKW_TZ, TSFKW_US, TSFKW_YYYY, @@ -1039,13 +1038,15 @@ typedef enum { TSFKW_a_m, // TSFKW_b_c, // TSFKW_bc, - TSFKW_d, TSFKW_day, TSFKW_ddd, TSFKW_dd, + TSFKW_dy, // mon, tue + TSFKW_d, TSFKW_hh24, TSFKW_hh12, TSFKW_hh, + TSFKW_mi, TSFKW_mm, TSFKW_month, TSFKW_mon, @@ -1067,17 +1068,17 @@ typedef enum { // clang-format off static const TSFormatKeyWord formatKeyWords[] = { - //{"A.D.", 4, TSFKW_A_D}, - {"A.M.", 4, TSFKW_A_M, false}, //{"AD", 2, TSFKW_AD, false}, + //{"A.D.", 4, TSFKW_A_D}, {"AM", 2, TSFKW_AM, false}, - //{"B.C.", 4, TSFKW_B_C, false}, + {"A.M.", 4, TSFKW_A_M, false}, //{"BC", 2, TSFKW_BC, false}, + //{"B.C.", 4, TSFKW_B_C, false}, {"DAY", 3, TSFKW_DAY, false}, {"DDD", 3, TSFKW_DDD, true}, {"DD", 2, TSFKW_DD, true}, - {"DY", 2, TSFKW_DY, false}, {"Day", 3, TSFKW_Day, false}, + {"DY", 2, TSFKW_DY, false}, {"Dy", 2, TSFKW_Dy, false}, {"D", 1, TSFKW_D, true}, {"HH24", 4, TSFKW_HH24, true}, @@ -1087,13 +1088,13 @@ static const TSFormatKeyWord formatKeyWords[] = { {"MM", 2, TSFKW_MM, true}, {"MONTH", 5, TSFKW_MONTH, false}, {"MON", 3, TSFKW_MON, false}, - {"MS", 2, TSFKW_MS, true}, {"Month", 5, TSFKW_Month, false}, {"Mon", 3, TSFKW_Mon, false}, + {"MS", 2, TSFKW_MS, true}, {"NS", 2, TSFKW_NS, true}, //{"OF", 2, TSFKW_OF, false}, - {"P.M.", 4, TSFKW_P_M, false}, {"PM", 2, TSFKW_PM, false}, + {"P.M.", 4, TSFKW_P_M, false}, {"SS", 2, TSFKW_SS, true}, {"TZH", 3, TSFKW_TZH, false}, //{"TZM", 3, TSFKW_TZM}, @@ -1104,9 +1105,9 @@ static const TSFormatKeyWord formatKeyWords[] = { {"YY", 2, TSFKW_YY, true}, {"Y", 1, TSFKW_Y, true}, //{"a.d.", 4, TSFKW_a_d, false}, - {"a.m.", 4, TSFKW_a_m, false}, //{"ad", 2, TSFKW_ad, false}, {"am", 2, TSFKW_am, false}, + {"a.m.", 4, TSFKW_a_m, false}, //{"b.c.", 4, TSFKW_b_c, false}, //{"bc", 2, TSFKW_bc, false}, {"day", 3, TSFKW_day, false}, @@ -1124,8 +1125,8 @@ static const TSFormatKeyWord formatKeyWords[] = { {"ms", 2, TSFKW_MS, true}, {"ns", 2, TSFKW_NS, true}, //{"of", 2, TSFKW_OF, false}, - {"p.m.", 4, TSFKW_p_m, false}, {"pm", 2, TSFKW_pm, false}, + {"p.m.", 4, TSFKW_p_m, false}, {"ss", 2, TSFKW_SS, true}, {"tzh", 3, TSFKW_TZH, false}, //{"tzm", 3, TSFKW_TZM}, @@ -1139,9 +1140,34 @@ static const TSFormatKeyWord formatKeyWords[] = { }; // clang-format on +#define TS_FROMAT_KEYWORD_INDEX_SIZE ('z' - 'A' + 1) +static const int TSFormatKeywordIndex[TS_FROMAT_KEYWORD_INDEX_SIZE] = { + /*A*/ TSFKW_AM, -1, -1, + /*D*/ TSFKW_DAY, -1, -1, -1, + /*H*/ TSFKW_HH24, -1, -1, -1, -1, + /*M*/ TSFKW_MI, + /*N*/ TSFKW_NS, -1, + /*P*/ TSFKW_PM, -1, -1, + /*S*/ TSFKW_SS, + /*T*/ TSFKW_TZH, + /*U*/ TSFKW_US, -1, -1, -1, + /*Y*/ TSFKW_YYYY, -1, + /*[ \ ] ^ _ `*/ -1, -1, -1, -1, -1, -1, + /*a*/ TSFKW_am, -1, -1, + /*d*/ TSFKW_day, -1, -1, -1, + /*h*/ TSFKW_hh24, -1, -1, -1, -1, + /*m*/ TSFKW_mi, + /*n*/ TSFKW_ns, -1, + /*p*/ TSFKW_pm, -1, -1, + /*s*/ TSFKW_ss, + /*t*/ TSFKW_tzh, + /*u*/ TSFKW_us, -1, -1, -1, + /*y*/ TSFKW_yyyy, -1}; + typedef struct { uint8_t type; - char c[2]; + const char* c; + int32_t len; const TSFormatKeyWord* key; } TSFormatNode; @@ -1169,9 +1195,10 @@ static const char* const long_apms[] = {A_M_STR, P_M_STR, a_m_str, p_m_str, NULL static const TSFormatKeyWord* keywordSearch(const char* str) { if (*str < 'A' || *str > 'z' || (*str > 'Z' && *str < 'a')) return NULL; - int32_t idx = 0; + int32_t idx = TSFormatKeywordIndex[str[0] - 'A']; + if (idx < 0) return NULL; const TSFormatKeyWord* key = &formatKeyWords[idx++]; - while (key->name) { + while (key->name && str[0] == key->name[0]) { if (0 == strncmp(key->name, str, key->len)) { return key; } @@ -1184,74 +1211,110 @@ static bool isSeperatorChar(char c) { return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9')); } -static void parseTsFormat(const char* format_str, SArray* formats) { - while (*format_str) { - const TSFormatKeyWord* key = keywordSearch(format_str); +static void parseTsFormat(const char* formatStr, SArray* formats) { + TSFormatNode* lastOtherFormat = NULL; + while (*formatStr) { + const TSFormatKeyWord* key = keywordSearch(formatStr); if (key) { TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD}; taosArrayPush(formats, &format); - format_str += key->len; + formatStr += key->len; + lastOtherFormat = NULL; } else { - if (*format_str == '"') { + if (*formatStr == '"') { + lastOtherFormat = NULL; // for double quoted string - format_str++; - while (*format_str) { - if (*format_str == '"') { - format_str++; + formatStr++; + TSFormatNode* last = NULL; + while (*formatStr) { + if (*formatStr == '"') { + formatStr++; break; } - if (*format_str == '\\' && *(format_str + 1)) format_str++; - TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL}; - format.c[0] = *format_str; - format.c[1] = '\0'; - taosArrayPush(formats, &format); - format_str++; + if (*formatStr == '\\' && *(formatStr + 1)) { + formatStr++; + last = NULL; // stop expanding last format, create new format + } + if (last) { + // expand + assert(last->type == TS_FORMAT_NODE_TYPE_CHAR); + last->len++; + formatStr++; + } else { + // create new + TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL}; + format.c = formatStr; + format.len = 1; + taosArrayPush(formats, &format); + formatStr++; + last = taosArrayGetLast(formats); + } } } else { // for other strings - if (*format_str == '\\' && *(format_str + 1)) format_str++; - TSFormatNode format = { - .type = isSeperatorChar(*format_str) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR, + if (*formatStr == '\\' && *(formatStr + 1)) { + formatStr++; + lastOtherFormat = NULL; // stop expanding + } else { + if (lastOtherFormat && !isSeperatorChar(*formatStr)) { + // expanding + } else { + // create new + lastOtherFormat = NULL; + } + } + if (lastOtherFormat) { + assert(lastOtherFormat->type == TS_FORMAT_NODE_TYPE_CHAR); + lastOtherFormat->len++; + formatStr++; + } else { + TSFormatNode format = { + .type = isSeperatorChar(*formatStr) ? TS_FORMAT_NODE_TYPE_SEPARATOR : TS_FORMAT_NODE_TYPE_CHAR, .key = NULL}; - format.c[0] = *format_str; - format.c[1] = '\0'; - taosArrayPush(formats, &format); - format_str++; + format.c = formatStr; + format.len = 1; + taosArrayPush(formats, &format); + formatStr++; + if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats); + } } } } } -static void tm2char(const SArray* formats, const struct STm* tm, char* s) { +static void tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) { int32_t size = taosArrayGetSize(formats); + const char* start = s; for (int32_t i = 0; i < size; ++i) { TSFormatNode* format = taosArrayGet(formats, i); if (format->type != TS_FORMAT_NODE_TYPE_KEYWORD) { - strcpy(s, format->c); - s += strlen(s); + if (s - start + format->len + 1 > outLen) break; + strncpy(s, format->c, format->len); + s += format->len; continue; } + if (s - start + 16 > outLen) break; switch (format->key->id) { case TSFKW_AM: case TSFKW_PM: sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "PM" : "AM"); - s += strlen(s); + s += 2; break; case TSFKW_A_M: case TSFKW_P_M: sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "P.M." : "A.M."); - s += strlen(s); + s += 4; break; case TSFKW_am: case TSFKW_pm: sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "pm" : "am"); - s += strlen(s); + s += 2; break; case TSFKW_a_m: case TSFKW_p_m: sprintf(s, tm->tm.tm_hour % 24 >= 12 ? "p.m." : "a.m."); - s += strlen(s); + s += 4; break; case TSFKW_DDD: sprintf(s, "%d", tm->tm.tm_yday); @@ -1259,11 +1322,11 @@ static void tm2char(const SArray* formats, const struct STm* tm, char* s) { break; case TSFKW_DD: sprintf(s, "%02d", tm->tm.tm_mday); - s += strlen(s); + s += 2; break; case TSFKW_D: sprintf(s, "%d", tm->tm.tm_wday + 1); - s += strlen(s); + s += 1; break; case TSFKW_DAY: { // MONDAY, TUESDAY... @@ -1293,13 +1356,13 @@ static void tm2char(const SArray* formats, const struct STm* tm, char* s) { char buf[8] = {0}; for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = toupper(wd[i]); sprintf(s, "%3s", buf); - s += strlen(s); + s += 3; break; } case TSFKW_Dy: // Mon, Tue sprintf(s, "%3s", shortWeekDays[tm->tm.tm_wday]); - s += strlen(s); + s += 3; break; case TSFKW_dy: { // mon, tue @@ -1307,26 +1370,26 @@ static void tm2char(const SArray* formats, const struct STm* tm, char* s) { char buf[8] = {0}; for (int32_t i = 0; i < strlen(wd); ++i) buf[i] = tolower(wd[i]); sprintf(s, "%3s", buf); - s += strlen(s); + s += 3; break; } case TSFKW_HH24: sprintf(s, "%02d", tm->tm.tm_hour); - s += strlen(s); + s += 2; break; case TSFKW_HH: case TSFKW_HH12: // 0 or 12 o'clock in 24H coresponds to 12 o'clock (AM/PM) in 12H sprintf(s, "%02d", tm->tm.tm_hour % 12 == 0 ? 12 : tm->tm.tm_hour % 12); - s += strlen(s); + s += 2; break; case TSFKW_MI: sprintf(s, "%02d", tm->tm.tm_min); - s += strlen(s); + s += 2; break; case TSFKW_MM: sprintf(s, "%02d", tm->tm.tm_mon + 1); - s += strlen(s); + s += 2; break; case TSFKW_MONTH: { const char* mon = fullMonths[tm->tm.tm_mon]; @@ -1370,19 +1433,19 @@ static void tm2char(const SArray* formats, const struct STm* tm, char* s) { } case TSFKW_SS: sprintf(s, "%02d", tm->tm.tm_sec); - s += strlen(s); + s += 2; break; case TSFKW_MS: sprintf(s, "%03" PRId64, tm->fsec / 1000000L); - s += strlen(s); + s += 3; break; case TSFKW_US: sprintf(s, "%06" PRId64, tm->fsec / 1000L); - s += strlen(s); + s += 6; break; case TSFKW_NS: sprintf(s, "%09" PRId64, tm->fsec); - s += strlen(s); + s += 9; break; case TSFKW_TZH: sprintf(s, "%s%02d", tsTimezone < 0 ? "-" : "+", tsTimezone); @@ -1429,6 +1492,7 @@ static const char* tsFormatStr2Int32(int32_t* dest, const char* str, int32_t len char* last; int64_t res; const char* s = str; + if ('\0' == str[0]) return NULL; if (len <= 0) { res = taosStr2Int64(s, &last, 10); s = last; @@ -1523,18 +1587,27 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec int32_t tzSign = 1, tz = tsTimezone; int32_t err = 0; - for (int32_t i = 0; i < size; ++i) { - while (isspace(*s)) { + for (int32_t i = 0; i < size && *s != '\0'; ++i) { + while (isspace(*s) && *s != '\0') { s++; } + if (!s) break; TSFormatNode* node = taosArrayGet(formats, i); if (node->type == TS_FORMAT_NODE_TYPE_SEPARATOR) { // separator matches any character - if (isSeperatorChar(s[0])) s += strlen(node->c); + if (isSeperatorChar(s[0])) s += node->len; continue; } if (node->type == TS_FORMAT_NODE_TYPE_CHAR) { - if (!isspace(node->c[0])) s += strlen(node->c); + int32_t pos = 0; + // skip leading spaces + while (isspace(node->c[pos]) && node->len > 0) pos++; + while (pos < node->len && *s != '\0') { + if (!isspace(node->c[pos++])) { + while (isspace(*s) && *s != '\0') s++; + if (*s != '\0') s++; // forward together + } + } continue; } assert(node->type == TS_FORMAT_NODE_TYPE_KEYWORD); @@ -1545,7 +1618,7 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec case TSFKW_p_m: { int32_t idx = strArrayCaseSearch(long_apms, s); if (idx >= 0) { - s += strlen(long_apms[idx]); + s += 4; pm = idx % 2; hour12 = 1; } else { @@ -1558,7 +1631,7 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec case TSFKW_pm: { int32_t idx = strArrayCaseSearch(apms, s); if (idx >= 0) { - s += strlen(apms[idx]); + s += 2; pm = idx % 2; hour12 = 1; } else { @@ -1793,39 +1866,41 @@ static int32_t char2ts(const char* s, SArray* formats, int64_t* ts, int32_t prec return ret; } -void taosTs2Char(const char* format, int64_t ts, int32_t precision, char* out) { - SArray* formats = taosArrayInit(8, sizeof(TSFormatNode)); - parseTsFormat(format, formats); +void taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t precision, char* out, int32_t outLen) { + if (!*formats) { + *formats = taosArrayInit(8, sizeof(TSFormatNode)); + parseTsFormat(format, *formats); + } struct STm tm; taosTs2Tm(ts, precision, &tm); - tm2char(formats, &tm, out); - taosArrayDestroy(formats); + tm2char(*formats, &tm, out, outLen); } -int32_t taosChar2Ts(const char* format, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, +int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg, int32_t errMsgLen) { const char* sErrPos; int32_t fErrIdx; - SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); - parseTsFormat(format, formats); - int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx); + if (!*formats) { + *formats = taosArrayInit(4, sizeof(TSFormatNode)); + parseTsFormat(format, *formats); + } + int32_t code = char2ts(tsStr, *formats, ts, precision, &sErrPos, &fErrIdx); if (code == -1) { - TSFormatNode* fNode = (taosArrayGet(formats, fErrIdx)); + TSFormatNode* fNode = (taosArrayGet(*formats, fErrIdx)); snprintf(errMsg, errMsgLen, "mismatch format for: %s and %s", sErrPos, - fErrIdx < taosArrayGetSize(formats) ? ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name : ""); + fErrIdx < taosArrayGetSize(*formats) ? ((TSFormatNode*)taosArrayGet(*formats, fErrIdx))->key->name : ""); } else if (code == -2) { snprintf(errMsg, errMsgLen, "timestamp format error: %s -> %s", tsStr, format); } - taosArrayDestroy(formats); return code; } -void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out) { +void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen) { SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); parseTsFormat(format, formats); struct STm tm; taosTs2Tm(ts, precision, &tm); - tm2char(formats, &tm, out); + tm2char(formats, &tm, out, outLen); taosArrayDestroy(formats); } diff --git a/source/common/test/commonTests.cpp b/source/common/test/commonTests.cpp index 49a16351ca..dc320ebcb2 100644 --- a/source/common/test/commonTests.cpp +++ b/source/common/test/commonTests.cpp @@ -316,8 +316,8 @@ TEST(timeTest, timestamp2tm) { } void test_ts2char(int64_t ts, const char* format, int32_t precison, const char* expected) { - char buf[128] = {0}; - TEST_ts2char(format, ts, precison, buf); + char buf[256] = {0}; + TEST_ts2char(format, ts, precison, buf, 256); printf("ts: %ld format: %s res: [%s], expected: [%s]\n", ts, format, buf, expected); ASSERT_STREQ(expected, buf); } @@ -408,8 +408,8 @@ TEST(timeTest, char2ts) { #ifndef WINDOWS // 2023-1-1 21:10:10.120450780 - ASSERT_EQ(0, TEST_char2ts("yy \"年\"-MM 月-dd \"日\" HH24:MI:ss.ms.us.ns TZH", &ts, TSDB_TIME_PRECISION_NANO, - " 23 年 - 1 月 - 01 日 \t 21:10:10 . 12 . \t 00045 . 00000078 \t+08")); + ASSERT_EQ(0, TEST_char2ts("yy \"年\"-MM 月-dd \"日 子\" HH24:MI:ss.ms.us.ns TZH", &ts, TSDB_TIME_PRECISION_NANO, + " 23 年 - 1 月 - 01 日 子 \t 21:10:10 . 12 . \t 00045 . 00000078 \t+08")); ASSERT_EQ(ts, 1672578610120450780LL); #endif @@ -437,7 +437,7 @@ TEST(timeTest, char2ts) { "2100/january/01 FRIDAY 11:10:10.124456+08")); ASSERT_EQ(ts, 4102456210124456LL); ASSERT_EQ(0, TEST_char2ts("yyyy/Month/dd Dy HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, - "2100/january/01 Fri 11:10:10.124456+08")); + "2100/january/01 Fri 11:10:10.124456+08:00")); ASSERT_EQ(ts, 4102456210124456LL); ASSERT_EQ(0, TEST_char2ts("yyyy/month/dd day HH24:MI:ss.usTZH", &ts, TSDB_TIME_PRECISION_MICRO, @@ -461,7 +461,8 @@ TEST(timeTest, char2ts) { // '/' cannot convert to MM ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "2100/2/1")); // nothing to be converted to dd - ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "210012")); + ASSERT_EQ(0, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "210012")); + ASSERT_EQ(ts, 4131273600000000LL); // 2100-12-1 ASSERT_EQ(-1, TEST_char2ts("yyyyMMdd ", &ts, TSDB_TIME_PRECISION_MICRO, "21001")); ASSERT_EQ(-1, TEST_char2ts("yyyyMM-dd ", &ts, TSDB_TIME_PRECISION_MICRO, "23a1-1")); @@ -481,6 +482,13 @@ TEST(timeTest, char2ts) { ASSERT_EQ(-1, TEST_char2ts("HH12:MI:SS", &ts, TSDB_TIME_PRECISION_MICRO, "21:12:12")); ASSERT_EQ(-1, TEST_char2ts("yyyy/MM1/dd ", &ts, TSDB_TIME_PRECISION_MICRO, "2100111111111/11/2")); ASSERT_EQ(-2, TEST_char2ts("yyyy/MM1/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "23/11/2-13")); + ASSERT_EQ(0, TEST_char2ts("yyyy年 MM/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "1970年1/1+0")); + ASSERT_EQ(ts, 0); + ASSERT_EQ(-1, TEST_char2ts("yyyy年a MM/dd", &ts, TSDB_TIME_PRECISION_MICRO, "2023年1/2")); + ASSERT_EQ(0, TEST_char2ts("yyyy年 MM/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "1970年 1/1+0")); + ASSERT_EQ(ts, 0); + ASSERT_EQ(0, TEST_char2ts("yyyy年 a a a MM/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "1970年 a a a 1/1+0")); + ASSERT_EQ(0, TEST_char2ts("yyyy年 a a a a a a a a a a a a a a a MM/ddTZH", &ts, TSDB_TIME_PRECISION_MICRO, "1970年 a ")); } #pragma GCC diagnostic pop diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 628a609715..84aff9fa88 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2107,7 +2107,7 @@ static int32_t translateToChar(SFunctionNode* pFunc, char* pErrBuf, int32_t len) if (!IS_STR_DATA_TYPE(para2Type) || !IS_TIMESTAMP_TYPE(para1Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_VARCHAR].bytes, .type = TSDB_DATA_TYPE_VARCHAR}; + pFunc->node.resType = (SDataType){.bytes = 4096, .type = TSDB_DATA_TYPE_VARCHAR}; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index ee2ba47ce8..48886b1eec 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1203,9 +1203,13 @@ int32_t toTimestampFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam char * tsStr = taosMemoryMalloc(TS_FORMAT_MAX_LEN); char * format = taosMemoryMalloc(TS_FORMAT_MAX_LEN); int32_t len, code = TSDB_CODE_SUCCESS; + SArray *formats = NULL; + for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { - if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) + if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) { colDataSetNULL(pOutput->columnData, i); + continue; + } char *tsData = colDataGetData(pInput[0].columnData, i); char *formatData = colDataGetData(pInput[1].columnData, pInput[1].numOfRows > 1 ? i : 0); @@ -1213,11 +1217,17 @@ int32_t toTimestampFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam strncpy(tsStr, varDataVal(tsData), len); tsStr[len] = '\0'; len = TMIN(TS_FORMAT_MAX_LEN - 1, varDataLen(formatData)); - strncpy(format, varDataVal(formatData), len); - format[len] = '\0'; + if (pInput[1].numOfRows > 1 || i == 0) { + strncpy(format, varDataVal(formatData), len); + format[len] = '\0'; + if (formats) { + taosArrayDestroy(formats); + formats = NULL; + } + } int32_t precision = pOutput->columnData->info.precision; char errMsg[128] = {0}; - code = taosChar2Ts(format, tsStr, &ts, precision, errMsg, 128); + code = taosChar2Ts(format, &formats, tsStr, &ts, precision, errMsg, 128); if (code) { qError("func to_timestamp failed %s", errMsg); code = TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED; @@ -1225,6 +1235,7 @@ int32_t toTimestampFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam } colDataSetVal(pOutput->columnData, i, (char *)&ts, false); } + if (formats) taosArrayDestroy(formats); taosMemoryFree(tsStr); taosMemoryFree(format); return code; @@ -1232,22 +1243,32 @@ int32_t toTimestampFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam int32_t toCharFunction(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput) { char * format = taosMemoryMalloc(TS_FORMAT_MAX_LEN); - char * out = taosMemoryMalloc(TS_FORMAT_MAX_LEN * 2); + char * out = taosMemoryCalloc(1, TS_FORMAT_MAX_LEN + VARSTR_HEADER_SIZE); int32_t len; + SArray *formats = NULL; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { - if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) + if (colDataIsNull_s(pInput[1].columnData, i) || colDataIsNull_s(pInput[0].columnData, i)) { colDataSetNULL(pOutput->columnData, i); + continue; + } char *ts = colDataGetData(pInput[0].columnData, i); char *formatData = colDataGetData(pInput[1].columnData, pInput[1].numOfRows > 1 ? i : 0); len = TMIN(TS_FORMAT_MAX_LEN - 1, varDataLen(formatData)); - strncpy(format, varDataVal(formatData), len); - format[len] = '\0'; + if (pInput[1].numOfRows > 1 || i == 0) { + strncpy(format, varDataVal(formatData), len); + format[len] = '\0'; + if (formats) { + taosArrayDestroy(formats); + formats = NULL; + } + } int32_t precision = pInput[0].columnData->info.precision; - taosTs2Char(format, *(int64_t *)ts, precision, varDataVal(out)); + taosTs2Char(format, &formats, *(int64_t *)ts, precision, varDataVal(out), TS_FORMAT_MAX_LEN); varDataSetLen(out, strlen(varDataVal(out))); colDataSetVal(pOutput->columnData, i, out, false); } + if (formats) taosArrayDestroy(formats); taosMemoryFree(format); taosMemoryFree(out); return TSDB_CODE_SUCCESS; diff --git a/tests/system-test/2-query/func_to_char_timestamp.py b/tests/system-test/2-query/func_to_char_timestamp.py index 3d3435d9c7..639811d275 100644 --- a/tests/system-test/2-query/func_to_char_timestamp.py +++ b/tests/system-test/2-query/func_to_char_timestamp.py @@ -60,10 +60,15 @@ class TDTestCase: rowsBatched = 0 sql += " %s%d values "%(ctbPrefix,i) for j in range(rowsPerTbl): - if (i < ctbNum/2): - sql += "(%d, %d, %d, %d,%d,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10, j%10, j%10) + if i % 3 == 0: + ts_format = 'NULL' else: - sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10) + ts_format = "'yyyy-mm-dd hh24:mi:ss'" + + if (i < ctbNum/2): + sql += "(%d, %d, %d, %d,%d,%d,%d,true,'2023-11-01 10:10:%d', %s, 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10, j%10, ts_format, j%10) + else: + sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,NULL , %s, 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, ts_format, j%10) rowsBatched += 1 if ((rowsBatched == batchNum) or (j == rowsPerTbl - 1)): tsql.execute(sql) @@ -85,7 +90,7 @@ class TDTestCase: 'stbName': 'meters', 'colPrefix': 'c', 'tagPrefix': 't', - 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'FLOAT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'smallint', 'count':1},{'type': 'tinyint', 'count':1},{'type': 'bool', 'count':1},{'type': 'binary', 'len':10, 'count':1},{'type': 'nchar', 'len':10, 'count':1}], + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'FLOAT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'smallint', 'count':1},{'type': 'tinyint', 'count':1},{'type': 'bool', 'count':1},{'type': 'varchar', 'len':1024, 'count':2},{'type': 'nchar', 'len':10, 'count':1}], 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'nchar', 'len':20, 'count':1},{'type': 'binary', 'len':20, 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'smallint', 'count':1},{'type': 'DOUBLE', 'count':1}], 'ctbPrefix': 't', 'ctbStartIdx': 0, @@ -146,6 +151,18 @@ class TDTestCase: tdSql.query("select to_char(ts, 'yy-mon-dd hh24:mi:ss.msa.m.TZH Day') from meters where to_timestamp(to_char(ts, 'yy-mon-dd hh24:mi:ss dy'), 'yy-mon-dd hh24:mi:ss dy') != ts") tdSql.checkRows(0) + tdSql.query("select to_timestamp(c8, 'YYYY-MM-DD hh24:mi:ss') from meters") + tdSql.query("select to_timestamp(c8, c9) from meters") + + format = "YYYY-MM-DD HH:MI:SS" + for i in range(500): + format = format + "1234567890" + tdSql.query("select to_char(ts, '%s') from meters" % (format), queryTimes=1) + time_str = '2023-11-11 10:10:10' + for i in range(500): + time_str = time_str + "1234567890" + tdSql.query("select to_timestamp('%s', '%s')" % (time_str, format)) + def run(self): self.prepareTestEnv() self.test_to_timestamp() From 418602808312b7ae6d71563c0e715ff2b876decb Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 27 Oct 2023 11:09:18 +0800 Subject: [PATCH 17/45] fix: interval more than 1000 years --- include/util/taoserror.h | 1 + source/libs/parser/src/parTranslater.c | 3 ++ source/libs/parser/src/parUtil.c | 2 + source/os/src/osTime.c | 69 +++++++++++--------------- source/util/src/terror.c | 1 + 5 files changed, 37 insertions(+), 39 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 6fbe4422ac..671d390638 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -657,6 +657,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618) #define TSDB_CODE_PAR_INVALID_DB_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619) #define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A) +#define TSDB_CODE_PAR_INTER_VALUE_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x261B) #define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624) #define TSDB_CODE_PAR_AGG_FUNC_NESTING TAOS_DEF_ERROR_CODE(0, 0x2627) #define TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2628) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 72293e2f8c..bff0b46b61 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3512,6 +3512,7 @@ static void convertVarDuration(SValueNode* pOffset, uint8_t precision) { pOffset->unit = units[precision]; } +static const int64_t maxKeepMS = (int64_t)3600 * 1000 * 24 * (365 * 1000 + 250); static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision; @@ -3520,6 +3521,8 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* if (pInter->datum.i <= 0 || (!valInter && pInter->datum.i < tsMinIntervalTime)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime, getPrecisionStr(precision)); + } else if (pInter->datum.i > maxKeepMS) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_BIG, 1000, "years"); } if (NULL != pInterval->pOffset) { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 0ab8927bd0..825e02f9aa 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -65,6 +65,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "This statement is no longer supported"; case TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL: return "Interval cannot be less than %d %s"; + case TSDB_CODE_PAR_INTER_VALUE_TOO_BIG: + return "Interval cannot be more than %d %s"; case TSDB_CODE_PAR_DB_NOT_SPECIFIED: return "Database not specified"; case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME: diff --git a/source/os/src/osTime.c b/source/os/src/osTime.c index 05233065fa..e506ee603b 100644 --- a/source/os/src/osTime.c +++ b/source/os/src/osTime.c @@ -477,47 +477,38 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) { return res; } #ifdef WINDOWS - if (*timep < 0) { - if (*timep < -2208988800LL) { - if (buf != NULL) { - sprintf(buf, "NaN"); - } - return NULL; - } - - SYSTEMTIME s; - FILETIME f; - LARGE_INTEGER offset; - struct tm tm1; - time_t tt = 0; - if (localtime_s(&tm1, &tt) != 0 ) { - if (buf != NULL) { - sprintf(buf, "NaN"); - } - return NULL; - } - offset.QuadPart = TIMEEPOCH1900; - offset.QuadPart += *timep * 10000000; - f.dwLowDateTime = offset.QuadPart & 0xffffffff; - f.dwHighDateTime = (offset.QuadPart >> 32) & 0xffffffff; - FileTimeToSystemTime(&f, &s); - result->tm_sec = s.wSecond; - result->tm_min = s.wMinute; - result->tm_hour = s.wHour; - result->tm_mday = s.wDay; - result->tm_mon = s.wMonth - 1; - result->tm_year = s.wYear - 1900; - result->tm_wday = s.wDayOfWeek; - result->tm_yday = 0; - result->tm_isdst = 0; - } else { - if (localtime_s(result, timep) != 0) { - if (buf != NULL) { - sprintf(buf, "NaN"); - } - return NULL; + if (*timep < -2208988800LL) { + if (buf != NULL) { + sprintf(buf, "NaN"); } + return NULL; } + + SYSTEMTIME s; + FILETIME f; + LARGE_INTEGER offset; + struct tm tm1; + time_t tt = 0; + if (localtime_s(&tm1, &tt) != 0) { + if (buf != NULL) { + sprintf(buf, "NaN"); + } + return NULL; + } + offset.QuadPart = TIMEEPOCH1900; + offset.QuadPart += *timep * 10000000; + f.dwLowDateTime = offset.QuadPart & 0xffffffff; + f.dwHighDateTime = (offset.QuadPart >> 32) & 0xffffffff; + FileTimeToSystemTime(&f, &s); + result->tm_sec = s.wSecond; + result->tm_min = s.wMinute; + result->tm_hour = s.wHour; + result->tm_mday = s.wDay; + result->tm_mon = s.wMonth - 1; + result->tm_year = s.wYear - 1900; + result->tm_wday = s.wDayOfWeek; + result->tm_yday = 0; + result->tm_isdst = 0; #else res = localtime_r(timep, result); if (res == NULL && buf != NULL) { diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 4cc86d51b7..83b0ec7a82 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -518,6 +518,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_PORT, "Port should be an in TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_ENDPOINT, "Endpoint should be in the format of 'fqdn:port'") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_EXPRIE_STATEMENT, "This statement is no longer supported") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, "Interval too small") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INTER_VALUE_TOO_BIG, "Interval too big") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_DB_NOT_SPECIFIED, "Database not specified") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, "Invalid identifier name") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR, "Corresponding super table not in this db") From b422c29d4e94dfe2a7c6550ea305b596160d83df Mon Sep 17 00:00:00 2001 From: xsren <285808407@qq.com> Date: Fri, 27 Oct 2023 15:16:03 +0800 Subject: [PATCH 18/45] fix interval limit on us/ns db --- source/libs/parser/src/parTranslater.c | 16 +++++++++++++++- source/os/test/osTimeTests.cpp | 4 ---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index bff0b46b61..d65f97dce7 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3499,6 +3499,20 @@ static const char* getPrecisionStr(uint8_t precision) { return "unknown"; } +static int64_t getPrecisionMultiple(uint8_t precision) { + switch (precision) { + case TSDB_TIME_PRECISION_MILLI: + return 1; + case TSDB_TIME_PRECISION_MICRO: + return 1000; + case TSDB_TIME_PRECISION_NANO: + return 1000000; + default: + break; + } + return 1; +} + static void convertVarDuration(SValueNode* pOffset, uint8_t precision) { const int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; const int8_t units[3] = {TIME_UNIT_MILLISECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_NANOSECOND}; @@ -3521,7 +3535,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* if (pInter->datum.i <= 0 || (!valInter && pInter->datum.i < tsMinIntervalTime)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime, getPrecisionStr(precision)); - } else if (pInter->datum.i > maxKeepMS) { + } else if (pInter->datum.i / getPrecisionMultiple(precision) > maxKeepMS) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_BIG, 1000, "years"); } diff --git a/source/os/test/osTimeTests.cpp b/source/os/test/osTimeTests.cpp index 5dd15db4ab..90c089e310 100644 --- a/source/os/test/osTimeTests.cpp +++ b/source/os/test/osTimeTests.cpp @@ -114,10 +114,6 @@ TEST(osTimeTests, taosLocalTime) { ASSERT_EQ(local_time->tm_min, 0); ASSERT_EQ(local_time->tm_sec, 0); - time_t over_timep = 6406301441633558; - local_time = taosLocalTime(&over_timep, &result, NULL); - ASSERT_EQ(local_time, nullptr); - time_t neg_timep3 = -78115158887; local_time = taosLocalTime(&neg_timep3, &result, NULL); ASSERT_EQ(local_time, nullptr); From 43e6dec6c218fcc6b3993c247d18ed90d021bf79 Mon Sep 17 00:00:00 2001 From: dmchen Date: Fri, 27 Oct 2023 09:30:30 +0000 Subject: [PATCH 19/45] TD-26971 --- source/dnode/vnode/src/vnd/vnodeSvr.c | 72 +++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index c46ea15111..040ae96972 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -20,6 +20,7 @@ #include "vnode.h" #include "vnodeInt.h" #include "audit.h" +#include "tstrbuild.h" static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessAlterStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); @@ -886,6 +887,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, char tbName[TSDB_TABLE_FNAME_LEN]; STbUidStore *pStore = NULL; SArray *tbUids = NULL; + SArray *tbNames = NULL; pRsp->msgType = TDMT_VND_CREATE_TABLE_RSP; pRsp->code = TSDB_CODE_SUCCESS; @@ -902,7 +904,8 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, rsp.pArray = taosArrayInit(req.nReqs, sizeof(cRsp)); tbUids = taosArrayInit(req.nReqs, sizeof(int64_t)); - if (rsp.pArray == NULL || tbUids == NULL) { + tbNames = taosArrayInit(req.nReqs, sizeof(char*)); + if (rsp.pArray == NULL || tbUids == NULL || tbNames == NULL) { rcode = -1; terrno = TSDB_CODE_OUT_OF_MEMORY; goto _exit; @@ -947,14 +950,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, taosArrayPush(rsp.pArray, &cRsp); - if(tsEnableAuditCreateTable){ - int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; - - SName name = {0}; - tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); - - auditRecord(NULL, clusterId, "createTable", name.dbname, "", pCreateReq->name, strlen(pCreateReq->name)); - } + char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); + strcpy(str, pCreateReq->name); + taosArrayPush(tbNames, str); } vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); @@ -976,6 +974,29 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); tEncodeSVCreateTbBatchRsp(&encoder, &rsp); + if(tsEnableAuditCreateTable){ + int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; + + SName name = {0}; + tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + + SStringBuilder sb = {0}; + for(int32_t iReq = 0; iReq < req.nReqs; iReq++){ + char* key = taosArrayGet(tbNames, iReq); + taosStringBuilderAppendStringLen(&sb, key, strlen(key)); + if(iReq < req.nReqs - 1){ + taosStringBuilderAppendChar(&sb, ','); + } + } + + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + + auditRecord(NULL, clusterId, "createTable", name.dbname, "", keyJoined, len); + + taosStringBuilderDestroy(&sb); + } + _exit: for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; @@ -987,6 +1008,7 @@ _exit: taosArrayDestroy(tbUids); tDecoderClear(&decoder); tEncoderClear(&encoder); + taosArrayDestroy(tbNames); return rcode; } @@ -1120,6 +1142,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in int32_t ret; SArray *tbUids = NULL; STbUidStore *pStore = NULL; + SArray *tbNames = NULL; pRsp->msgType = TDMT_VND_DROP_TABLE_RSP; pRsp->pCont = NULL; @@ -1138,7 +1161,8 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in // process req tbUids = taosArrayInit(req.nReqs, sizeof(int64_t)); rsp.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbRsp)); - if (tbUids == NULL || rsp.pArray == NULL) goto _exit; + tbNames = taosArrayInit(req.nReqs, sizeof(char*)); + if (tbUids == NULL || rsp.pArray == NULL || tbNames == NULL) goto _exit; for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { SVDropTbReq *pDropTbReq = req.pReqs + iReq; @@ -1159,11 +1183,38 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in } taosArrayPush(rsp.pArray, &dropTbRsp); + + char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); + strcpy(str, pDropTbReq->name); + taosArrayPush(tbNames, str); } tqUpdateTbUidList(pVnode->pTq, tbUids, false); tdUpdateTbUidList(pVnode->pSma, pStore, false); + if(tsEnableAuditCreateTable){ + int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; + + SName name = {0}; + tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + + SStringBuilder sb = {0}; + for(int32_t iReq = 0; iReq < req.nReqs; iReq++){ + char* key = taosArrayGet(tbNames, iReq); + taosStringBuilderAppendStringLen(&sb, key, strlen(key)); + if(iReq < req.nReqs - 1){ + taosStringBuilderAppendChar(&sb, ','); + } + } + + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + + auditRecord(NULL, clusterId, "createTable", name.dbname, "", keyJoined, len); + + taosStringBuilderDestroy(&sb); + } + _exit: taosArrayDestroy(tbUids); tdUidStoreFree(pStore); @@ -1174,6 +1225,7 @@ _exit: tEncodeSVDropTbBatchRsp(&encoder, &rsp); tEncoderClear(&encoder); taosArrayDestroy(rsp.pArray); + taosArrayDestroy(tbNames); return 0; } From cdb1d8296ddd322d8f0de91656ed9a153017d71f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 27 Oct 2023 17:48:19 +0800 Subject: [PATCH 20/45] feat: concurrency on fileset --- source/dnode/vnode/src/inc/tsdb.h | 18 +- source/dnode/vnode/src/sma/smaRollup.c | 2 - source/dnode/vnode/src/tsdb/tsdbCommit.c | 20 +- source/dnode/vnode/src/tsdb/tsdbCommit2.c | 25 +- source/dnode/vnode/src/tsdb/tsdbFS2.c | 319 ++++++++++---------- source/dnode/vnode/src/tsdb/tsdbFS2.h | 50 +-- source/dnode/vnode/src/tsdb/tsdbFSet2.c | 33 +- source/dnode/vnode/src/tsdb/tsdbFSet2.h | 44 ++- source/dnode/vnode/src/tsdb/tsdbMerge.c | 117 ++++--- source/dnode/vnode/src/tsdb/tsdbOpen.c | 9 +- source/dnode/vnode/src/tsdb/tsdbRead2.c | 66 ++-- source/dnode/vnode/src/tsdb/tsdbRetention.c | 264 +++++++++------- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 18 +- 13 files changed, 542 insertions(+), 443 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 79112babc3..1efcd9417d 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -309,7 +309,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader *pReader, _query_reseek_func_t reseek, STs void tsdbUntakeReadSnap2(STsdbReader *pReader, STsdbReadSnap *pSnap, bool proactive); // tsdbMerge.c ============================================================================================== -int32_t tsdbMerge(void *arg); +int32_t tsdbSchedMerge(STsdb *tsdb, int32_t fid); // tsdbDiskData ============================================================================================== int32_t tDiskDataBuilderCreate(SDiskDataBuilder **ppBuilder); @@ -371,7 +371,7 @@ struct STsdb { char *path; SVnode *pVnode; STsdbKeepCfg keepCfg; - TdThreadRwlock rwLock; + TdThreadMutex mutex; SMemTable *mem; SMemTable *imem; STsdbFS fs; // old @@ -668,8 +668,8 @@ struct SDelFWriter { }; #include "tarray2.h" -//#include "tsdbFS2.h" -// struct STFileSet; +// #include "tsdbFS2.h" +// struct STFileSet; typedef struct STFileSet STFileSet; typedef TARRAY2(STFileSet *) TFileSetArray; @@ -677,9 +677,9 @@ typedef struct STSnapRange STSnapRange; typedef TARRAY2(STSnapRange *) TSnapRangeArray; // disjoint snap ranges // util -int32_t tSerializeSnapRangeArray(void *buf, int32_t bufLen, TSnapRangeArray *pSnapR); -int32_t tDeserializeSnapRangeArray(void *buf, int32_t bufLen, TSnapRangeArray *pSnapR); -void tsdbSnapRangeArrayDestroy(TSnapRangeArray **ppSnap); +int32_t tSerializeSnapRangeArray(void *buf, int32_t bufLen, TSnapRangeArray *pSnapR); +int32_t tDeserializeSnapRangeArray(void *buf, int32_t bufLen, TSnapRangeArray *pSnapR); +void tsdbSnapRangeArrayDestroy(TSnapRangeArray **ppSnap); SHashObj *tsdbGetSnapRangeHash(TSnapRangeArray *pRanges); // snap partition list @@ -873,8 +873,8 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf); void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter); bool tMergeTreeNext(SMergeTree *pMTree); -void tMergeTreePinSttBlock(SMergeTree* pMTree); -void tMergeTreeUnpinSttBlock(SMergeTree* pMTree); +void tMergeTreePinSttBlock(SMergeTree *pMTree); +void tMergeTreeUnpinSttBlock(SMergeTree *pMTree); bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree); void tMergeTreeClose(SMergeTree *pMTree); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 8da2fff5a6..14c5baa402 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -31,8 +31,6 @@ SSmaMgmt smaMgmt = { typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem; -extern int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now); - static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid); static void tdUidStoreDestory(STbUidStore *pStore); static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids, bool isAdd); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index b4c2c0a979..55ae25aee4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -131,7 +131,7 @@ int32_t tsdbBegin(STsdb *pTsdb) { TSDB_CHECK_CODE(code, lino, _exit); // lock - if ((code = taosThreadRwlockWrlock(&pTsdb->rwLock))) { + if ((code = taosThreadMutexLock(&pTsdb->mutex))) { code = TAOS_SYSTEM_ERROR(code); TSDB_CHECK_CODE(code, lino, _exit); } @@ -139,7 +139,7 @@ int32_t tsdbBegin(STsdb *pTsdb) { pTsdb->mem = pMemTable; // unlock - if ((code = taosThreadRwlockUnlock(&pTsdb->rwLock))) { + if ((code = taosThreadMutexUnlock(&pTsdb->mutex))) { code = TAOS_SYSTEM_ERROR(code); TSDB_CHECK_CODE(code, lino, _exit); } @@ -152,11 +152,11 @@ _exit: } int32_t tsdbPrepareCommit(STsdb *pTsdb) { - taosThreadRwlockWrlock(&pTsdb->rwLock); + taosThreadMutexLock(&pTsdb->mutex); ASSERT(pTsdb->imem == NULL); pTsdb->imem = pTsdb->mem; pTsdb->mem = NULL; - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); return 0; } @@ -171,9 +171,9 @@ int32_t tsdbCommit(STsdb *pTsdb, SCommitInfo *pInfo) { // check if (pMemTable->nRow == 0 && pMemTable->nDel == 0) { - taosThreadRwlockWrlock(&pTsdb->rwLock); + taosThreadMutexLock(&pTsdb->mutex); pTsdb->imem = NULL; - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); tsdbUnrefMemTable(pMemTable, NULL, true); goto _exit; @@ -501,6 +501,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) { int32_t lino = 0; STsdb *pTsdb = pCommitter->pTsdb; SDFileSet *pRSet = NULL; + // memory pCommitter->commitFid = tsdbKeyFid(pCommitter->nextKey, pCommitter->minutes, pCommitter->precision); pCommitter->expLevel = tsdbFidLevel(pCommitter->commitFid, &pCommitter->pTsdb->keepCfg, taosGetTimestampSec()); @@ -798,6 +799,7 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) { int32_t lino = 0; STsdb *pTsdb = pCommitter->pTsdb; SMemTable *pMemTable = pTsdb->imem; + // commit file data start code = tsdbCommitFileDataStart(pCommitter); TSDB_CHECK_CODE(code, lino, _exit); @@ -1650,18 +1652,18 @@ int32_t tsdbFinishCommit(STsdb *pTsdb) { SMemTable *pMemTable = pTsdb->imem; // lock - taosThreadRwlockWrlock(&pTsdb->rwLock); + taosThreadMutexLock(&pTsdb->mutex); code = tsdbFSCommit(pTsdb); if (code) { - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } pTsdb->imem = NULL; // unlock - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); if (pMemTable) { tsdbUnrefMemTable(pMemTable, NULL, true); } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 6dc492f420..79ecdab15c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -367,7 +367,12 @@ static int32_t tsdbCommitFileSetBegin(SCommitter2 *committer) { int32_t lino = 0; STsdb *tsdb = committer->tsdb; - committer->ctx->fid = tsdbKeyFid(committer->ctx->nextKey, committer->minutes, committer->precision); + int32_t fid = tsdbKeyFid(committer->ctx->nextKey, committer->minutes, committer->precision); + + // check if can commit + tsdbFSCheckCommit(tsdb, fid); + + committer->ctx->fid = fid; committer->ctx->expLevel = tsdbFidLevel(committer->ctx->fid, &tsdb->keepCfg, committer->ctx->now); tsdbFidKeyRange(committer->ctx->fid, committer->minutes, committer->precision, &committer->ctx->minKey, &committer->ctx->maxKey); @@ -549,11 +554,11 @@ _exit: } int32_t tsdbPreCommit(STsdb *tsdb) { - taosThreadRwlockWrlock(&tsdb->rwLock); + taosThreadMutexLock(&tsdb->mutex); ASSERT(tsdb->imem == NULL); tsdb->imem = tsdb->mem; tsdb->mem = NULL; - taosThreadRwlockUnlock(&tsdb->rwLock); + taosThreadMutexUnlock(&tsdb->mutex); return 0; } @@ -568,15 +573,13 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) { int64_t nDel = imem->nDel; if (nRow == 0 && nDel == 0) { - taosThreadRwlockWrlock(&tsdb->rwLock); + taosThreadMutexLock(&tsdb->mutex); tsdb->imem = NULL; - taosThreadRwlockUnlock(&tsdb->rwLock); + taosThreadMutexUnlock(&tsdb->mutex); tsdbUnrefMemTable(imem, NULL, true); } else { SCommitter2 committer[1]; - tsdbFSCheckCommit(tsdb->pFS); - code = tsdbOpenCommitter(tsdb, info, committer); TSDB_CHECK_CODE(code, lino, _exit); @@ -605,14 +608,14 @@ int32_t tsdbCommitCommit(STsdb *tsdb) { if (tsdb->imem == NULL) goto _exit; SMemTable *pMemTable = tsdb->imem; - taosThreadRwlockWrlock(&tsdb->rwLock); + taosThreadMutexLock(&tsdb->mutex); code = tsdbFSEditCommit(tsdb->pFS); if (code) { - taosThreadRwlockUnlock(&tsdb->rwLock); + taosThreadMutexUnlock(&tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } tsdb->imem = NULL; - taosThreadRwlockUnlock(&tsdb->rwLock); + taosThreadMutexUnlock(&tsdb->mutex); tsdbUnrefMemTable(pMemTable, NULL, true); _exit: @@ -640,4 +643,4 @@ _exit: tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); } return code; -} +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 93a16b5502..38d221d978 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -55,25 +55,11 @@ static int32_t create_fs(STsdb *pTsdb, STFileSystem **fs) { TARRAY2_INIT(fs[0]->fSetArr); TARRAY2_INIT(fs[0]->fSetArrTmp); - // background task queue - taosThreadMutexInit(fs[0]->mutex, NULL); - fs[0]->bgTaskQueue->next = fs[0]->bgTaskQueue; - fs[0]->bgTaskQueue->prev = fs[0]->bgTaskQueue; - - taosThreadMutexInit(&fs[0]->commitMutex, NULL); - taosThreadCondInit(&fs[0]->canCommit, NULL); - fs[0]->blockCommit = false; - return 0; } static int32_t destroy_fs(STFileSystem **fs) { if (fs[0] == NULL) return 0; - taosThreadMutexDestroy(&fs[0]->commitMutex); - taosThreadCondDestroy(&fs[0]->canCommit); - taosThreadMutexDestroy(fs[0]->mutex); - - ASSERT(fs[0]->bgTaskNum == 0); TARRAY2_DESTROY(fs[0]->fSetArr, NULL); TARRAY2_DESTROY(fs[0]->fSetArrTmp, NULL); @@ -264,10 +250,11 @@ static int32_t apply_commit(STFileSystem *fs) { if (fset1 && fset2) { if (fset1->fid < fset2->fid) { // delete fset1 - TARRAY2_REMOVE(fsetArray1, i1, tsdbTFileSetRemove); + tsdbTFileSetRemove(fset1); + i1++; } else if (fset1->fid > fset2->fid) { // create new file set with fid of fset2->fid - code = tsdbTFileSetInitDup(fs->tsdb, fset2, &fset1); + code = tsdbTFileSetInitCopy(fs->tsdb, fset2, &fset1); if (code) return code; code = TARRAY2_SORT_INSERT(fsetArray1, fset1, tsdbTFileSetCmprFn); if (code) return code; @@ -282,10 +269,11 @@ static int32_t apply_commit(STFileSystem *fs) { } } else if (fset1) { // delete fset1 - TARRAY2_REMOVE(fsetArray1, i1, tsdbTFileSetRemove); + tsdbTFileSetRemove(fset1); + i1++; } else { // create new file set with fid of fset2->fid - code = tsdbTFileSetInitDup(fs->tsdb, fset2, &fset1); + code = tsdbTFileSetInitCopy(fs->tsdb, fset2, &fset1); if (code) return code; code = TARRAY2_SORT_INSERT(fsetArray1, fset1, tsdbTFileSetCmprFn); if (code) return code; @@ -512,7 +500,8 @@ static int32_t tsdbFSDoSanAndFix(STFileSystem *fs) { TARRAY2_FOREACH(lvl->fobjArr, fobj) { code = tsdbFSDoScanAndFixFile(fs, fobj); if (code) { - fset->maxVerValid = (fobj->f->minVer <= fobj->f->maxVer) ? TMIN(fset->maxVerValid, fobj->f->minVer - 1) : -1; + fset->maxVerValid = + (fobj->f->minVer <= fobj->f->maxVer) ? TMIN(fset->maxVerValid, fobj->f->minVer - 1) : -1; corrupt = true; } } @@ -592,7 +581,7 @@ static int32_t tsdbFSDupState(STFileSystem *fs) { const STFileSet *fset1; TARRAY2_FOREACH(src, fset1) { STFileSet *fset2; - code = tsdbTFileSetInitDup(fs->tsdb, fset1, &fset2); + code = tsdbTFileSetInitCopy(fs->tsdb, fset1, &fset2); if (code) return code; code = TARRAY2_APPEND(dst, fset2); if (code) return code; @@ -665,12 +654,6 @@ static int32_t close_file_system(STFileSystem *fs) { return 0; } -static int32_t apply_edit(STFileSystem *pFS) { - int32_t code = 0; - ASSERTS(0, "TODO: Not implemented yet"); - return code; -} - static int32_t fset_cmpr_fn(const struct STFileSet *pSet1, const struct STFileSet *pSet2) { if (pSet1->fid < pSet2->fid) { return -1; @@ -710,10 +693,23 @@ static int32_t edit_fs(STFileSystem *fs, const TFileOpArray *opArray) { TSDB_CHECK_CODE(code, lino, _exit); } - // remove empty file set + // remove empty empty stt level and empty file set int32_t i = 0; while (i < TARRAY2_SIZE(fsetArray)) { fset = TARRAY2_GET(fsetArray, i); + + SSttLvl *lvl; + int32_t j = 0; + while (j < TARRAY2_SIZE(fset->lvlArr)) { + lvl = TARRAY2_GET(fset->lvlArr, j); + + if (TARRAY2_SIZE(lvl->fobjArr) == 0) { + TARRAY2_REMOVE(fset->lvlArr, j, tsdbSttLvlClear); + } else { + j++; + } + } + if (tsdbTFileSetIsEmpty(fset)) { TARRAY2_REMOVE(fsetArray, i, tsdbTFileSetClear); } else { @@ -753,13 +749,13 @@ _exit: static void tsdbDoWaitBgTask(STFileSystem *fs, STFSBgTask *task) { task->numWait++; - taosThreadCondWait(task->done, fs->mutex); + taosThreadCondWait(task->done, &fs->tsdb->mutex); task->numWait--; if (task->numWait == 0) { taosThreadCondDestroy(task->done); - if (task->free) { - task->free(task->arg); + if (task->destroy) { + task->destroy(task->arg); } taosMemoryFree(task); } @@ -770,8 +766,8 @@ static void tsdbDoDoneBgTask(STFileSystem *fs, STFSBgTask *task) { taosThreadCondBroadcast(task->done); } else { taosThreadCondDestroy(task->done); - if (task->free) { - task->free(task->arg); + if (task->destroy) { + task->destroy(task->arg); } taosMemoryFree(task); } @@ -780,23 +776,16 @@ static void tsdbDoDoneBgTask(STFileSystem *fs, STFSBgTask *task) { int32_t tsdbCloseFS(STFileSystem **fs) { if (fs[0] == NULL) return 0; - taosThreadMutexLock(fs[0]->mutex); - fs[0]->stop = true; - - if (fs[0]->bgTaskRunning) { - tsdbDoWaitBgTask(fs[0], fs[0]->bgTaskRunning); - } - taosThreadMutexUnlock(fs[0]->mutex); - + tsdbFSDisableBgTask(fs[0]); close_file_system(fs[0]); destroy_fs(fs); return 0; } int64_t tsdbFSAllocEid(STFileSystem *fs) { - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); int64_t cid = ++fs->neid; - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); return cid; } @@ -837,27 +826,34 @@ _exit: return code; } -static int32_t tsdbFSSetBlockCommit(STFileSystem *fs, bool block) { - taosThreadMutexLock(&fs->commitMutex); +static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) { if (block) { - fs->blockCommit = true; + fset->blockCommit = true; } else { - fs->blockCommit = false; - taosThreadCondSignal(&fs->canCommit); + fset->blockCommit = false; + if (fset->numWaitCommit > 0) { + taosThreadCondSignal(&fset->canCommit); + } } - taosThreadMutexUnlock(&fs->commitMutex); return 0; } -int32_t tsdbFSCheckCommit(STFileSystem *fs) { - taosThreadMutexLock(&fs->commitMutex); - while (fs->blockCommit) { - taosThreadCondWait(&fs->canCommit, &fs->commitMutex); +int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) { + taosThreadMutexLock(&tsdb->mutex); + STFileSet *fset; + tsdbFSGetFSet(tsdb->pFS, fid, &fset); + if (fset) { + while (fset->blockCommit) { + fset->numWaitCommit++; + taosThreadCondWait(&fset->canCommit, &tsdb->mutex); + fset->numWaitCommit--; + } } - taosThreadMutexUnlock(&fs->commitMutex); + taosThreadMutexUnlock(&tsdb->mutex); return 0; } +// IMPORTANT: the caller must hold fs->tsdb->mutex int32_t tsdbFSEditCommit(STFileSystem *fs) { int32_t code = 0; int32_t lino = 0; @@ -867,36 +863,57 @@ int32_t tsdbFSEditCommit(STFileSystem *fs) { TSDB_CHECK_CODE(code, lino, _exit); // schedule merge - if (fs->tsdb->pVnode->config.sttTrigger > 1) { + int32_t sttTrigger = fs->tsdb->pVnode->config.sttTrigger; + if (sttTrigger > 1) { STFileSet *fset; - int32_t sttTrigger = fs->tsdb->pVnode->config.sttTrigger; - bool schedMerge = false; - bool blockCommit = false; - TARRAY2_FOREACH_REVERSE(fs->fSetArr, fset) { - if (TARRAY2_SIZE(fset->lvlArr) == 0) continue; + if (TARRAY2_SIZE(fset->lvlArr) == 0) { + tsdbFSSetBlockCommit(fset, false); + continue; + } SSttLvl *lvl = TARRAY2_FIRST(fset->lvlArr); - if (lvl->level != 0) continue; + if (lvl->level != 0) { + tsdbFSSetBlockCommit(fset, false); + continue; + } int32_t numFile = TARRAY2_SIZE(lvl->fobjArr); if (numFile >= sttTrigger) { - schedMerge = true; + // launch merge + code = tsdbSchedMerge(fs->tsdb, fset->fid); + TSDB_CHECK_CODE(code, lino, _exit); } if (numFile >= sttTrigger * BLOCK_COMMIT_FACTOR) { - blockCommit = true; + tsdbFSSetBlockCommit(fset, true); + } else { + tsdbFSSetBlockCommit(fset, false); } + } + } - if (schedMerge && blockCommit) break; + // clear empty level and fset + int32_t i = 0; + while (i < TARRAY2_SIZE(fs->fSetArr)) { + STFileSet *fset = TARRAY2_GET(fs->fSetArr, i); + + int32_t j = 0; + while (j < TARRAY2_SIZE(fset->lvlArr)) { + SSttLvl *lvl = TARRAY2_GET(fset->lvlArr, j); + + if (TARRAY2_SIZE(lvl->fobjArr) == 0) { + TARRAY2_REMOVE(fset->lvlArr, j, tsdbSttLvlClear); + } else { + j++; + } } - if (schedMerge) { - code = tsdbFSScheduleBgTask(fs, TSDB_BG_TASK_MERGER, tsdbMerge, NULL, fs->tsdb, NULL); - TSDB_CHECK_CODE(code, lino, _exit); + if (tsdbTFileSetIsEmpty(fset) && fset->bgTaskRunning == NULL) { + TARRAY2_REMOVE(fs->fSetArr, i, tsdbTFileSetClear); + } else { + i++; } - - tsdbFSSetBlockCommit(fs, blockCommit); } _exit: @@ -933,15 +950,15 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { TARRAY2_INIT(fsetArr[0]); - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { - code = tsdbTFileSetInitDup(fs->tsdb, fset, &fset1); + code = tsdbTFileSetInitCopy(fs->tsdb, fset, &fset1); if (code) break; code = TARRAY2_APPEND(fsetArr[0], fset1); if (code) break; } - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear); @@ -961,9 +978,9 @@ int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) { } int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); int32_t code = tsdbFSCreateRefSnapshotWithoutLock(fs, fsetArr); - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); return code; } @@ -1017,7 +1034,7 @@ int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TSnapRangeArray *pRange } } - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { int64_t ever = VERSION_MAX; if (pHash) { @@ -1034,7 +1051,7 @@ int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TSnapRangeArray *pRange code = TARRAY2_APPEND(fsetArr[0], fset1); if (code) break; } - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); _out: if (code) { @@ -1089,7 +1106,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev } } - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { int64_t sver1 = sver; int64_t ever1 = ever; @@ -1118,7 +1135,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev fsr1 = NULL; } - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { tsdbTSnapRangeClear(&fsr1); @@ -1137,59 +1154,69 @@ _out: const char *gFSBgTaskName[] = {NULL, "MERGE", "RETENTION", "COMPACT"}; static int32_t tsdbFSRunBgTask(void *arg) { - STFileSystem *fs = (STFileSystem *)arg; + STFSBgTask *task = (STFSBgTask *)arg; + STFileSystem *fs = task->fs; + STFileSet *fset; - ASSERT(fs->bgTaskRunning != NULL); + tsdbFSGetFSet(fs, task->fid, &fset); - fs->bgTaskRunning->launchTime = taosGetTimestampMs(); - fs->bgTaskRunning->run(fs->bgTaskRunning->arg); - fs->bgTaskRunning->finishTime = taosGetTimestampMs(); + ASSERT(fset != NULL && fset->bgTaskRunning == task); + + task->launchTime = taosGetTimestampMs(); + task->run(task->arg); + task->finishTime = taosGetTimestampMs(); tsdbDebug("vgId:%d bg task:%s task id:%" PRId64 " finished, schedule time:%" PRId64 " launch time:%" PRId64 " finish time:%" PRId64, - TD_VID(fs->tsdb->pVnode), gFSBgTaskName[fs->bgTaskRunning->type], fs->bgTaskRunning->taskid, - fs->bgTaskRunning->scheduleTime, fs->bgTaskRunning->launchTime, fs->bgTaskRunning->finishTime); + TD_VID(fs->tsdb->pVnode), gFSBgTaskName[task->type], task->taskid, task->scheduleTime, task->launchTime, + task->finishTime); - taosThreadMutexLock(fs->mutex); + taosThreadMutexLock(&fs->tsdb->mutex); // free last - tsdbDoDoneBgTask(fs, fs->bgTaskRunning); - fs->bgTaskRunning = NULL; + tsdbDoDoneBgTask(fs, task); + fset->bgTaskRunning = NULL; // schedule next - if (fs->bgTaskNum > 0) { + if (fset->bgTaskNum > 0) { if (fs->stop) { - while (fs->bgTaskNum > 0) { - STFSBgTask *task = fs->bgTaskQueue->next; - task->prev->next = task->next; - task->next->prev = task->prev; - fs->bgTaskNum--; - tsdbDoDoneBgTask(fs, task); + while (fset->bgTaskNum > 0) { + STFSBgTask *nextTask = fset->bgTaskQueue->next; + nextTask->prev->next = nextTask->next; + nextTask->next->prev = nextTask->prev; + fset->bgTaskNum--; + tsdbDoDoneBgTask(fs, nextTask); } } else { // pop task from head - fs->bgTaskRunning = fs->bgTaskQueue->next; - fs->bgTaskRunning->prev->next = fs->bgTaskRunning->next; - fs->bgTaskRunning->next->prev = fs->bgTaskRunning->prev; - fs->bgTaskNum--; - vnodeScheduleTaskEx(1, tsdbFSRunBgTask, arg); + fset->bgTaskRunning = fset->bgTaskQueue->next; + fset->bgTaskRunning->prev->next = fset->bgTaskRunning->next; + fset->bgTaskRunning->next->prev = fset->bgTaskRunning->prev; + fset->bgTaskNum--; + vnodeScheduleTaskEx(1, tsdbFSRunBgTask, fset->bgTaskRunning); } } - taosThreadMutexUnlock(fs->mutex); + taosThreadMutexUnlock(&fs->tsdb->mutex); return 0; } -static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *), - void (*destroy)(void *), void *arg, int64_t *taskid) { +// IMPORTANT: the caller must hold the fs->tsdb->mutex +int32_t tsdbFSScheduleBgTask(STFileSystem *fs, int32_t fid, EFSBgTaskT type, int32_t (*run)(void *), + void (*destroy)(void *), void *arg, int64_t *taskid) { if (fs->stop) { if (destroy) { destroy(arg); } - return 0; // TODO: use a better error code + return 0; } - for (STFSBgTask *task = fs->bgTaskQueue->next; task != fs->bgTaskQueue; task = task->next) { + STFileSet *fset; + tsdbFSGetFSet(fs, fid, &fset); + + ASSERT(fset != NULL); + + for (STFSBgTask *task = fset->bgTaskQueue->next; task != fset->bgTaskQueue; task = task->next) { if (task->type == type) { if (destroy) { destroy(arg); @@ -1203,22 +1230,24 @@ static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int if (task == NULL) return TSDB_CODE_OUT_OF_MEMORY; taosThreadCondInit(task->done, NULL); + task->fs = fs; + task->fid = fid; task->type = type; task->run = run; - task->free = destroy; + task->destroy = destroy; task->arg = arg; task->scheduleTime = taosGetTimestampMs(); task->taskid = ++fs->taskid; - if (fs->bgTaskRunning == NULL && fs->bgTaskNum == 0) { + if (fset->bgTaskRunning == NULL && fset->bgTaskNum == 0) { // launch task directly - fs->bgTaskRunning = task; - vnodeScheduleTaskEx(1, tsdbFSRunBgTask, fs); + fset->bgTaskRunning = task; + vnodeScheduleTaskEx(1, tsdbFSRunBgTask, task); } else { // add to the queue tail - fs->bgTaskNum++; - task->next = fs->bgTaskQueue; - task->prev = fs->bgTaskQueue->prev; + fset->bgTaskNum++; + task->next = fset->bgTaskQueue; + task->prev = fset->bgTaskQueue->prev; task->prev->next = task; task->next->prev = task; } @@ -1227,68 +1256,30 @@ static int32_t tsdbFSScheduleBgTaskImpl(STFileSystem *fs, EFSBgTaskT type, int return 0; } -int32_t tsdbFSScheduleBgTask(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *), void (*free)(void *), void *arg, - int64_t *taskid) { - taosThreadMutexLock(fs->mutex); - int32_t code = tsdbFSScheduleBgTaskImpl(fs, type, run, free, arg, taskid); - taosThreadMutexUnlock(fs->mutex); - return code; -} +int32_t tsdbFSDisableBgTask(STFileSystem *fs) { + taosThreadMutexLock(&fs->tsdb->mutex); + for (;;) { + fs->stop = true; + bool done = true; -int32_t tsdbFSWaitBgTask(STFileSystem *fs, int64_t taskid) { - STFSBgTask *task = NULL; - - taosThreadMutexLock(fs->mutex); - - if (fs->bgTaskRunning && fs->bgTaskRunning->taskid == taskid) { - task = fs->bgTaskRunning; - } else { - for (STFSBgTask *taskt = fs->bgTaskQueue->next; taskt != fs->bgTaskQueue; taskt = taskt->next) { - if (taskt->taskid == taskid) { - task = taskt; + STFileSet *fset; + TARRAY2_FOREACH(fs->fSetArr, fset) { + if (fset->bgTaskRunning) { + tsdbDoWaitBgTask(fs, fset->bgTaskRunning); + done = false; break; } } - } - if (task) { - tsdbDoWaitBgTask(fs, task); + if (done) break; } - - taosThreadMutexUnlock(fs->mutex); + taosThreadMutexUnlock(&fs->tsdb->mutex); return 0; } -int32_t tsdbFSWaitAllBgTask(STFileSystem *fs) { - taosThreadMutexLock(fs->mutex); - - while (fs->bgTaskRunning) { - taosThreadCondWait(fs->bgTaskRunning->done, fs->mutex); - } - - taosThreadMutexUnlock(fs->mutex); - return 0; -} - -static int32_t tsdbFSDoDisableBgTask(STFileSystem *fs) { - fs->stop = true; - - if (fs->bgTaskRunning) { - tsdbDoWaitBgTask(fs, fs->bgTaskRunning); - } - return 0; -} - -int32_t tsdbFSDisableBgTask(STFileSystem *fs) { - taosThreadMutexLock(fs->mutex); - int32_t code = tsdbFSDoDisableBgTask(fs); - taosThreadMutexUnlock(fs->mutex); - return code; -} - int32_t tsdbFSEnableBgTask(STFileSystem *fs) { - taosThreadMutexLock(fs->mutex); + taosThreadMutexLock(&fs->tsdb->mutex); fs->stop = false; - taosThreadMutexUnlock(fs->mutex); + taosThreadMutexUnlock(&fs->tsdb->mutex); return 0; -} +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.h b/source/dnode/vnode/src/tsdb/tsdbFS2.h index 31b98e5656..a3a8e2f575 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.h @@ -22,22 +22,11 @@ extern "C" { #endif -/* Exposed Handle */ -typedef struct STFileSystem STFileSystem; -typedef struct STFSBgTask STFSBgTask; -// typedef TARRAY2(STFileSet *) TFileSetArray; - typedef enum { TSDB_FEDIT_COMMIT = 1, // TSDB_FEDIT_MERGE } EFEditT; -typedef enum { - TSDB_BG_TASK_MERGER = 1, - TSDB_BG_TASK_RETENTION, - TSDB_BG_TASK_COMPACT, -} EFSBgTaskT; - typedef enum { TSDB_FCURRENT = 1, TSDB_FCURRENT_C, // for commit @@ -67,37 +56,17 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e int32_t tsdbFSEditCommit(STFileSystem *fs); int32_t tsdbFSEditAbort(STFileSystem *fs); // background task -int32_t tsdbFSScheduleBgTask(STFileSystem *fs, EFSBgTaskT type, int32_t (*run)(void *), void (*free)(void *), void *arg, - int64_t *taskid); -int32_t tsdbFSWaitBgTask(STFileSystem *fs, int64_t taskid); -int32_t tsdbFSWaitAllBgTask(STFileSystem *fs); +int32_t tsdbFSScheduleBgTask(STFileSystem *fs, int32_t fid, EFSBgTaskT type, int32_t (*run)(void *), + void (*destroy)(void *), void *arg, int64_t *taskid); int32_t tsdbFSDisableBgTask(STFileSystem *fs); int32_t tsdbFSEnableBgTask(STFileSystem *fs); // other int32_t tsdbFSGetFSet(STFileSystem *fs, int32_t fid, STFileSet **fset); -int32_t tsdbFSCheckCommit(STFileSystem *fs); +int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid); // utils int32_t save_fs(const TFileSetArray *arr, const char *fname); int32_t current_fname(STsdb *pTsdb, char *fname, EFCurrentT ftype); -struct STFSBgTask { - EFSBgTaskT type; - int32_t (*run)(void *arg); - void (*free)(void *arg); - void *arg; - - TdThreadCond done[1]; - int32_t numWait; - - int64_t taskid; - int64_t scheduleTime; - int64_t launchTime; - int64_t finishTime; - - struct STFSBgTask *prev; - struct STFSBgTask *next; -}; - /* Exposed Structs */ struct STFileSystem { STsdb *tsdb; @@ -109,17 +78,8 @@ struct STFileSystem { TFileSetArray fSetArrTmp[1]; // background task queue - TdThreadMutex mutex[1]; - bool stop; - int64_t taskid; - int32_t bgTaskNum; - STFSBgTask bgTaskQueue[1]; - STFSBgTask *bgTaskRunning; - - // block commit variables - TdThreadMutex commitMutex; - TdThreadCond canCommit; - bool blockCommit; + bool stop; + int64_t taskid; }; #ifdef __cplusplus diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 620fcb3a47..642d555366 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -342,11 +342,6 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) { int32_t idx = TARRAY2_SEARCH_IDX(lvl->fobjArr, &tfobjp, tsdbTFileObjCmpr, TD_EQ); ASSERT(idx >= 0); TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj); - - if (TARRAY2_SIZE(lvl->fobjArr) == 0) { - // TODO: remove the stt level if no file exists anymore - // TARRAY2_REMOVE(&fset->lvlArr, lvl - fset->lvlArr.data, tsdbSttLvlClear); - } } else { ASSERT(tsdbIsSameTFile(&op->of, fset->farr[op->of.type]->f)); tsdbTFileObjUnref(fset->farr[op->of.type]); @@ -454,10 +449,22 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset) { fset[0]->fid = fid; fset[0]->maxVerValid = VERSION_MAX; TARRAY2_INIT(fset[0]->lvlArr); + + // background task queue + fset[0]->bgTaskNum = 0; + fset[0]->bgTaskQueue->next = fset[0]->bgTaskQueue; + fset[0]->bgTaskQueue->prev = fset[0]->bgTaskQueue; + fset[0]->bgTaskRunning = NULL; + + // block commit variables + taosThreadCondInit(&fset[0]->canCommit, NULL); + fset[0]->numWaitCommit = 0; + fset[0]->blockCommit = false; + return 0; } -int32_t tsdbTFileSetInitDup(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset) { +int32_t tsdbTFileSetInitCopy(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset) { int32_t code = tsdbTFileSetInit(fset1->fid, fset); if (code) return code; @@ -588,21 +595,23 @@ int32_t tsdbTFileSetClear(STFileSet **fset) { TARRAY2_DESTROY(fset[0]->lvlArr, tsdbSttLvlClear); + taosThreadCondDestroy(&fset[0]->canCommit); taosMemoryFree(fset[0]); fset[0] = NULL; return 0; } -int32_t tsdbTFileSetRemove(STFileSet **fset) { +int32_t tsdbTFileSetRemove(STFileSet *fset) { + if (fset == NULL) return 0; + for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { - if (fset[0]->farr[ftype] == NULL) continue; - tsdbTFileObjRemove(fset[0]->farr[ftype]); + if (fset->farr[ftype] == NULL) continue; + tsdbTFileObjRemove(fset->farr[ftype]); } - TARRAY2_DESTROY(fset[0]->lvlArr, tsdbSttLvlRemove); - taosMemoryFree(fset[0]); - fset[0] = NULL; + TARRAY2_DESTROY(fset->lvlArr, tsdbSttLvlRemove); + return 0; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.h b/source/dnode/vnode/src/tsdb/tsdbFSet2.h index ea0f99f68e..34f174ade7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.h +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.h @@ -28,6 +28,8 @@ typedef struct SSttLvl SSttLvl; typedef TARRAY2(STFileObj *) TFileObjArray; typedef TARRAY2(SSttLvl *) TSttLvlArray; typedef TARRAY2(STFileOp) TFileOpArray; +typedef struct STFileSystem STFileSystem; +typedef struct STFSBgTask STFSBgTask; typedef enum { TSDB_FOP_NONE = 0, @@ -41,10 +43,10 @@ typedef enum { // init/clear int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset); -int32_t tsdbTFileSetInitDup(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset); +int32_t tsdbTFileSetInitCopy(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset); int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset); int32_t tsdbTFileSetClear(STFileSet **fset); -int32_t tsdbTFileSetRemove(STFileSet **fset); +int32_t tsdbTFileSetRemove(STFileSet *fset); int32_t tsdbTFileSetFilteredInitDup(STsdb *pTsdb, const STFileSet *fset1, int64_t ever, STFileSet **fset, TFileOpArray *fopArr); @@ -58,6 +60,7 @@ int32_t tsdbJsonToTFileSet(STsdb *pTsdb, const cJSON *json, STFileSet **fset); // cmpr int32_t tsdbTFileSetCmprFn(const STFileSet **fset1, const STFileSet **fset2); // edit +int32_t tsdbSttLvlClear(SSttLvl **lvl); int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op); int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *fset); // max commit id @@ -70,6 +73,33 @@ bool tsdbTFileSetIsEmpty(const STFileSet *fset); int32_t tsdbSttLvlInit(int32_t level, SSttLvl **lvl); int32_t tsdbSttLvlClear(SSttLvl **lvl); +typedef enum { + TSDB_BG_TASK_MERGER = 1, + TSDB_BG_TASK_RETENTION, + TSDB_BG_TASK_COMPACT, +} EFSBgTaskT; + +struct STFSBgTask { + STFileSystem *fs; + int32_t fid; + + EFSBgTaskT type; + int32_t (*run)(void *arg); + void (*destroy)(void *arg); + void *arg; + + TdThreadCond done[1]; + int32_t numWait; + + int64_t taskid; + int64_t scheduleTime; + int64_t launchTime; + int64_t finishTime; + + struct STFSBgTask *prev; + struct STFSBgTask *next; +}; + struct STFileOp { tsdb_fop_t optype; int32_t fid; @@ -87,6 +117,16 @@ struct STFileSet { int64_t maxVerValid; STFileObj *farr[TSDB_FTYPE_MAX]; // file array TSttLvlArray lvlArr[1]; // level array + + // background task queue + int32_t bgTaskNum; + STFSBgTask bgTaskQueue[1]; + STFSBgTask *bgTaskRunning; + + // block commit variables + TdThreadCond canCommit; + int32_t numWaitCommit; + bool blockCommit; }; struct STSnapRange { diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index e659cedba3..0c20a342d3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -15,11 +15,17 @@ #include "tsdbMerge.h" -#define TSDB_MAX_LEVEL 6 // means max level is 7 +#define TSDB_MAX_LEVEL 2 // means max level is 3 typedef struct { - STsdb *tsdb; - TFileSetArray *fsetArr; + STsdb *tsdb; + int32_t fid; +} SMergeArg; + +typedef struct { + STsdb *tsdb; + int32_t fid; + STFileSet *fset; int32_t sttTrigger; int32_t maxRow; @@ -313,7 +319,6 @@ static int32_t tsdbMergeFileSetBeginOpenWriter(SMerger *merger) { if (merger->ctx->fset->farr[ftype]) { config.files[ftype].exist = true; config.files[ftype].file = merger->ctx->fset->farr[ftype]->f[0]; - } else { config.files[ftype].exist = false; } @@ -397,13 +402,13 @@ static int32_t tsdbMergeFileSetEnd(SMerger *merger) { code = tsdbFSEditBegin(merger->tsdb->pFS, merger->fopArr, TSDB_FEDIT_MERGE); TSDB_CHECK_CODE(code, lino, _exit); - taosThreadRwlockWrlock(&merger->tsdb->rwLock); + taosThreadMutexLock(&merger->tsdb->mutex); code = tsdbFSEditCommit(merger->tsdb->pFS); if (code) { - taosThreadRwlockUnlock(&merger->tsdb->rwLock); + taosThreadMutexUnlock(&merger->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } - taosThreadRwlockUnlock(&merger->tsdb->rwLock); + taosThreadMutexUnlock(&merger->tsdb->mutex); _exit: if (code) { @@ -478,30 +483,21 @@ _exit: } static int32_t tsdbDoMerge(SMerger *merger) { - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + SSttLvl *lvl = TARRAY2_FIRST(merger->fset->lvlArr); - STFileSet *fset; - TARRAY2_FOREACH(merger->fsetArr, fset) { - if (TARRAY2_SIZE(fset->lvlArr) == 0) continue; + if (TARRAY2_SIZE(merger->fset->lvlArr) == 0) return 0; + if (lvl->level != 0 || TARRAY2_SIZE(lvl->fobjArr) < merger->sttTrigger) return 0; - SSttLvl *lvl = TARRAY2_FIRST(fset->lvlArr); + code = tsdbMergerOpen(merger); + TSDB_CHECK_CODE(code, lino, _exit); - if (lvl->level != 0 || TARRAY2_SIZE(lvl->fobjArr) < merger->sttTrigger) continue; + code = tsdbMergeFileSet(merger, merger->fset); + TSDB_CHECK_CODE(code, lino, _exit); - if (!merger->ctx->opened) { - code = tsdbMergerOpen(merger); - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = tsdbMergeFileSet(merger, fset); - TSDB_CHECK_CODE(code, lino, _exit); - } - - if (merger->ctx->opened) { - code = tsdbMergerClose(merger); - TSDB_CHECK_CODE(code, lino, _exit); - } + code = tsdbMergerClose(merger); + TSDB_CHECK_CODE(code, lino, _exit); _exit: if (code) { @@ -512,36 +508,73 @@ _exit: return code; } -int32_t tsdbMerge(void *arg) { - int32_t code = 0; - int32_t lino = 0; - STsdb *tsdb = (STsdb *)arg; +static int32_t tsdbMergeGetFSet(SMerger *merger) { + STFileSet *fset; - SMerger merger[1] = {{ - .tsdb = tsdb, - .sttTrigger = tsdb->pVnode->config.sttTrigger, - }}; - - if (merger->sttTrigger <= 1) { + taosThreadMutexLock(&merger->tsdb->mutex); + tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset); + if (fset == NULL) { + taosThreadMutexUnlock(&merger->tsdb->mutex); return 0; } - code = tsdbFSCreateCopySnapshot(tsdb->pFS, &merger->fsetArr); + int32_t code = tsdbTFileSetInitCopy(merger->tsdb, fset, &merger->fset); + if (code) { + taosThreadMutexUnlock(&merger->tsdb->mutex); + return code; + } + taosThreadMutexUnlock(&merger->tsdb->mutex); + return 0; +} + +static int32_t tsdbMerge(void *arg) { + int32_t code = 0; + int32_t lino = 0; + SMergeArg *mergeArg = (SMergeArg *)arg; + STsdb *tsdb = mergeArg->tsdb; + + SMerger merger[1] = {{ + .tsdb = tsdb, + .fid = mergeArg->fid, + .sttTrigger = tsdb->pVnode->config.sttTrigger, + }}; + + if (merger->sttTrigger <= 1) return 0; + + // copy snapshot + code = tsdbMergeGetFSet(merger); TSDB_CHECK_CODE(code, lino, _exit); + if (merger->fset == NULL) return 0; + + // do merge + tsdbDebug("vgId:%d merge begin, fid:%d", TD_VID(tsdb->pVnode), merger->fid); code = tsdbDoMerge(merger); + tsdbDebug("vgId:%d merge done, fid:%d", TD_VID(tsdb->pVnode), mergeArg->fid); TSDB_CHECK_CODE(code, lino, _exit); - tsdbFSDestroyCopySnapshot(&merger->fsetArr); - _exit: if (code) { TSDB_ERROR_LOG(TD_VID(tsdb->pVnode), lino, code); tsdbFatal("vgId:%d, failed to merge stt files since %s. code:%d", TD_VID(tsdb->pVnode), terrstr(), code); taosMsleep(100); exit(EXIT_FAILURE); - } else if (merger->ctx->opened) { - tsdbDebug("vgId:%d %s done", TD_VID(tsdb->pVnode), __func__); } + tsdbTFileSetClear(&merger->fset); return code; } + +int32_t tsdbSchedMerge(STsdb *tsdb, int32_t fid) { + SMergeArg *arg = taosMemoryMalloc(sizeof(*arg)); + if (arg == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + arg->tsdb = tsdb; + arg->fid = fid; + + int32_t code = tsdbFSScheduleBgTask(tsdb->pFS, fid, TSDB_BG_TASK_MERGER, tsdbMerge, taosMemoryFree, arg, NULL); + if (code) taosMemoryFree(arg); + + return code; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 6dd66c7a40..c32b2eedd7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -53,7 +53,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); // taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; - taosThreadRwlockInit(&pTsdb->rwLock, NULL); + taosThreadMutexInit(&pTsdb->mutex, NULL); if (!pKeepCfg) { tsdbSetKeepCfg(pTsdb, &pVnode->config.tsdbCfg); } else { @@ -99,15 +99,14 @@ int tsdbClose(STsdb **pTsdb) { tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path, pdb->keepCfg.days, pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2, pdb->keepCfg.keepTimeOffset); - taosThreadRwlockWrlock(&(*pTsdb)->rwLock); + taosThreadMutexLock(&(*pTsdb)->mutex); tsdbMemTableDestroy((*pTsdb)->mem, true); (*pTsdb)->mem = NULL; - taosThreadRwlockUnlock(&(*pTsdb)->rwLock); - - taosThreadRwlockDestroy(&(*pTsdb)->rwLock); + taosThreadMutexUnlock(&(*pTsdb)->mutex); tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); + taosThreadMutexDestroy(&(*pTsdb)->mutex); taosMemoryFreeClear(*pTsdb); } return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 65cebf0ca0..41e0bd373e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -1105,8 +1105,9 @@ static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* p (pVerRange->maxVer < pBlock->record.maxVer && pVerRange->maxVer >= pBlock->record.minVer); } -static bool getNeighborBlockOfSameTable(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pTableBlockScanInfo, - int32_t* nextIndex, int32_t order, SBrinRecord* pRecord) { +static bool getNeighborBlockOfSameTable(SDataBlockIter* pBlockIter, SFileDataBlockInfo* pBlockInfo, + STableBlockScanInfo* pTableBlockScanInfo, int32_t* nextIndex, int32_t order, + SBrinRecord* pRecord) { bool asc = ASCENDING_TRAVERSE(order); if (asc && pBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockIdxList) - 1) { return false; @@ -1119,7 +1120,8 @@ static bool getNeighborBlockOfSameTable(SDataBlockIter* pBlockIter, SFileDataBlo int32_t step = asc ? 1 : -1; // *nextIndex = pBlockInfo->tbBlockIdx + step; // *pBlockIndex = *(SBlockIndex*)taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex); - STableDataBlockIdx* pTableDataBlockIdx = taosArrayGet(pTableBlockScanInfo->pBlockIdxList, pBlockInfo->tbBlockIdx + step); + STableDataBlockIdx* pTableDataBlockIdx = + taosArrayGet(pTableBlockScanInfo->pBlockIdxList, pBlockInfo->tbBlockIdx + step); SFileDataBlockInfo* p = taosArrayGet(pBlockIter->blockList, pTableDataBlockIdx->globalIndex); memcpy(pRecord, &p->record, sizeof(SBrinRecord)); @@ -1145,7 +1147,8 @@ static int32_t findFileBlockInfoIndex(SDataBlockIter* pBlockIter, SFileDataBlock return -1; } -static int32_t setFileBlockActiveInBlockIter(STsdbReader* pReader, SDataBlockIter* pBlockIter, int32_t index, int32_t step) { +static int32_t setFileBlockActiveInBlockIter(STsdbReader* pReader, SDataBlockIter* pBlockIter, int32_t index, + int32_t step) { if (index < 0 || index >= pBlockIter->numOfBlocks) { return -1; } @@ -1153,12 +1156,13 @@ static int32_t setFileBlockActiveInBlockIter(STsdbReader* pReader, SDataBlockIte SFileDataBlockInfo fblock = *(SFileDataBlockInfo*)taosArrayGet(pBlockIter->blockList, index); pBlockIter->index += step; - if (index != pBlockIter->index) { + if (index != pBlockIter->index) { if (index > pBlockIter->index) { for (int32_t i = index - 1; i >= pBlockIter->index; --i) { SFileDataBlockInfo* pBlockInfo = taosArrayGet(pBlockIter->blockList, i); - STableBlockScanInfo* pBlockScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); + STableBlockScanInfo* pBlockScanInfo = + getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); STableDataBlockIdx* pTableDataBlockIdx = taosArrayGet(pBlockScanInfo->pBlockIdxList, pBlockInfo->tbBlockIdx); pTableDataBlockIdx->globalIndex = i + 1; @@ -1168,13 +1172,13 @@ static int32_t setFileBlockActiveInBlockIter(STsdbReader* pReader, SDataBlockIte for (int32_t i = index + 1; i <= pBlockIter->index; ++i) { SFileDataBlockInfo* pBlockInfo = taosArrayGet(pBlockIter->blockList, i); - STableBlockScanInfo* pBlockScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); + STableBlockScanInfo* pBlockScanInfo = + getTableBlockScanInfo(pReader->status.pTableMap, pBlockInfo->uid, pReader->idStr); STableDataBlockIdx* pTableDataBlockIdx = taosArrayGet(pBlockScanInfo->pBlockIdxList, pBlockInfo->tbBlockIdx); pTableDataBlockIdx->globalIndex = i - 1; taosArraySet(pBlockIter->blockList, i - 1, pBlockInfo); } - } taosArraySet(pBlockIter->blockList, pBlockIter->index, &fblock); @@ -1286,7 +1290,8 @@ static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* int32_t neighborIndex = 0; SBrinRecord rec = {0}; - bool hasNeighbor = getNeighborBlockOfSameTable(&pReader->status.blockIter, pBlockInfo, pScanInfo, &neighborIndex, pReader->info.order, &rec); + bool hasNeighbor = getNeighborBlockOfSameTable(&pReader->status.blockIter, pBlockInfo, pScanInfo, &neighborIndex, + pReader->info.order, &rec); // overlap with neighbor if (hasNeighbor) { @@ -1420,9 +1425,7 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc } } -static void doPinSttBlock(SLastBlockReader* pLastBlockReader) { - tMergeTreePinSttBlock(&pLastBlockReader->mergeTree); -} +static void doPinSttBlock(SLastBlockReader* pLastBlockReader) { tMergeTreePinSttBlock(&pLastBlockReader->mergeTree); } static void doUnpinSttBlock(SLastBlockReader* pLastBlockReader) { tMergeTreeUnpinSttBlock(&pLastBlockReader->mergeTree); @@ -1568,7 +1571,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW* fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); - int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); + int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1618,7 +1621,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == tsLast) { TSDBROW* fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree); - int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); + int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1826,8 +1829,8 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* int64_t key = hasDataInFileBlock(pBlockData, pDumpInfo) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN; - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + TSDBKEY k = TSDBROW_KEY(pRow); + TSDBKEY ik = TSDBROW_KEY(piRow); STSchema* pSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { @@ -2219,8 +2222,9 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; TSDBROW *pRow = NULL, *piRow = NULL; - int64_t key = (pBlockData->nRow > 0 && (!pDumpInfo->allDumped)) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : - (ASCENDING_TRAVERSE(pReader->info.order) ? INT64_MAX : INT64_MIN); + int64_t key = (pBlockData->nRow > 0 && (!pDumpInfo->allDumped)) + ? pBlockData->aTSKEY[pDumpInfo->rowIndex] + : (ASCENDING_TRAVERSE(pReader->info.order) ? INT64_MAX : INT64_MIN); if (pBlockScanInfo->iter.hasVal) { pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); } @@ -2257,7 +2261,8 @@ static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlock *loadNeighbor = false; SBrinRecord rec = {0}; - bool hasNeighbor = getNeighborBlockOfSameTable(&pReader->status.blockIter, pBlockInfo, pBlockScanInfo, &nextIndex, pReader->info.order, &rec); + bool hasNeighbor = getNeighborBlockOfSameTable(&pReader->status.blockIter, pBlockInfo, pBlockScanInfo, &nextIndex, + pReader->info.order, &rec); if (!hasNeighbor) { // do nothing return code; } @@ -2268,7 +2273,7 @@ static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlock // 1. find the next neighbor block in the scan block list STableDataBlockIdx* tableDataBlockIdx = taosArrayGet(pBlockScanInfo->pBlockIdxList, nextIndex); - int32_t neighborIndex = tableDataBlockIdx->globalIndex; + int32_t neighborIndex = tableDataBlockIdx->globalIndex; // 2. remove it from the scan block list setFileBlockActiveInBlockIter(pReader, pBlockIter, neighborIndex, step); @@ -2704,7 +2709,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { (ASCENDING_TRAVERSE(pReader->info.order)) ? pBlockInfo->record.firstKey : pBlockInfo->record.lastKey; code = buildDataBlockFromBuf(pReader, pScanInfo, endKey); } else { - bool bHasDataInLastBlock = hasDataInLastBlock(pLastBlockReader); + bool bHasDataInLastBlock = hasDataInLastBlock(pLastBlockReader); int64_t tsLast = bHasDataInLastBlock ? getCurrentKeyInLastBlock(pLastBlockReader) : INT64_MIN; if (!bHasDataInLastBlock || ((asc && pBlockInfo->record.lastKey < tsLast) || (!asc && pBlockInfo->record.firstKey > tsLast))) { @@ -3479,7 +3484,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, // start to merge duplicated rows STSchema* pTSchema = NULL; - if (current.type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory + if (current.type == TSDBROW_ROW_FMT) { // get the correct schema for row-wise data in memory pTSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(¤t), pReader, uid); if (pTSchema == NULL) { return terrno; @@ -3525,8 +3530,8 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p SRow** pTSRow) { SRowMerger* pMerger = &pReader->status.merger; - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + TSDBKEY k = TSDBROW_KEY(pRow); + TSDBKEY ik = TSDBROW_KEY(piRow); STSchema* pSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { @@ -4907,12 +4912,12 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs SVersionRange* pRange = &pReader->info.verRange; // lock - taosThreadRwlockRdlock(&pTsdb->rwLock); + taosThreadMutexLock(&pTsdb->mutex); // alloc STsdbReadSnap* pSnap = (STsdbReadSnap*)taosMemoryCalloc(1, sizeof(STsdbReadSnap)); if (pSnap == NULL) { - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } @@ -4922,7 +4927,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs pSnap->pMem = pTsdb->mem; pSnap->pNode = taosMemoryMalloc(sizeof(*pSnap->pNode)); if (pSnap->pNode == NULL) { - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } @@ -4937,7 +4942,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs pSnap->pIMem = pTsdb->imem; pSnap->pINode = taosMemoryMalloc(sizeof(*pSnap->pINode)); if (pSnap->pINode == NULL) { - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } @@ -4952,7 +4957,7 @@ int32_t tsdbTakeReadSnap2(STsdbReader* pReader, _query_reseek_func_t reseek, STs code = tsdbFSCreateRefSnapshotWithoutLock(pTsdb->pFS, &pSnap->pfSetArray); // unlock - taosThreadRwlockUnlock(&pTsdb->rwLock); + taosThreadMutexUnlock(&pTsdb->mutex); if (code == TSDB_CODE_SUCCESS) { tsdbTrace("vgId:%d, take read snapshot", TD_VID(pTsdb->pVnode)); @@ -5005,4 +5010,5 @@ void tsdbReaderSetId2(STsdbReader* pReader, const char* idstr) { pReader->status.fileIter.pLastBlockReader->mergeTree.idStr = pReader->idStr; } -void tsdbReaderSetCloseFlag(STsdbReader* pReader) { /*pReader->code = TSDB_CODE_TSC_QUERY_CANCELLED;*/ } +void tsdbReaderSetCloseFlag(STsdbReader* pReader) { /*pReader->code = TSDB_CODE_TSC_QUERY_CANCELLED;*/ +} diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index f2665dcf26..6c41b46c73 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -25,11 +25,6 @@ typedef struct { TFileSetArray *fsetArr; TFileOpArray fopArr[1]; - - struct { - int32_t fsetArrIdx; - STFileSet *fset; - } ctx[1]; } SRTNer; static int32_t tsdbDoRemoveFileObject(SRTNer *rtner, const STFileObj *fobj) { @@ -227,8 +222,8 @@ _exit: typedef struct { STsdb *tsdb; - int32_t sync; int64_t now; + int32_t fid; } SRtnArg; static int32_t tsdbDoRetentionBegin(SRtnArg *arg, SRTNer *rtner) { @@ -263,15 +258,15 @@ static int32_t tsdbDoRetentionEnd(SRTNer *rtner) { code = tsdbFSEditBegin(rtner->tsdb->pFS, rtner->fopArr, TSDB_FEDIT_MERGE); TSDB_CHECK_CODE(code, lino, _exit); - taosThreadRwlockWrlock(&rtner->tsdb->rwLock); + taosThreadMutexLock(&rtner->tsdb->mutex); code = tsdbFSEditCommit(rtner->tsdb->pFS); if (code) { - taosThreadRwlockUnlock(&rtner->tsdb->rwLock); + taosThreadMutexUnlock(&rtner->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } - taosThreadRwlockUnlock(&rtner->tsdb->rwLock); + taosThreadMutexUnlock(&rtner->tsdb->mutex); TARRAY2_DESTROY(rtner->fopArr, NULL); @@ -285,95 +280,83 @@ _exit: return code; } -static int32_t tsdbDoRetention2(void *arg) { - int32_t code = 0; - int32_t lino = 0; - SRTNer rtner[1] = {0}; +static int32_t tsdbDoRetentionOnFileSet(SRTNer *rtner, STFileSet *fset) { + int32_t code = 0; + int32_t lino = 0; + STFileObj *fobj = NULL; + int32_t expLevel = tsdbFidLevel(fset->fid, &rtner->tsdb->keepCfg, rtner->now); - code = tsdbDoRetentionBegin(arg, rtner); - TSDB_CHECK_CODE(code, lino, _exit); + if (expLevel < 0) { // remove the fileset + for (int32_t ftype = 0; (ftype < TSDB_FTYPE_MAX) && (fobj = fset->farr[ftype], 1); ++ftype) { + if (fobj == NULL) continue; - for (rtner->ctx->fsetArrIdx = 0; rtner->ctx->fsetArrIdx < TARRAY2_SIZE(rtner->fsetArr); rtner->ctx->fsetArrIdx++) { - rtner->ctx->fset = TARRAY2_GET(rtner->fsetArr, rtner->ctx->fsetArrIdx); - - STFileObj *fobj; - int32_t expLevel = tsdbFidLevel(rtner->ctx->fset->fid, &rtner->tsdb->keepCfg, rtner->now); - - if (expLevel < 0) { // remove the file set - for (int32_t ftype = 0; (ftype < TSDB_FTYPE_MAX) && (fobj = rtner->ctx->fset->farr[ftype], 1); ++ftype) { - if (fobj == NULL) continue; - - int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs); - if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && fobj->f->did.level == nlevel - 1) { - code = tsdbRemoveFileObjectS3(rtner, fobj); - TSDB_CHECK_CODE(code, lino, _exit); - } else { - code = tsdbDoRemoveFileObject(rtner, fobj); - TSDB_CHECK_CODE(code, lino, _exit); - } - } - - SSttLvl *lvl; - TARRAY2_FOREACH(rtner->ctx->fset->lvlArr, lvl) { - TARRAY2_FOREACH(lvl->fobjArr, fobj) { - code = tsdbDoRemoveFileObject(rtner, fobj); - TSDB_CHECK_CODE(code, lino, _exit); - } - } - } else if (expLevel == 0) { - continue; - } else { - SDiskID did; - - if (tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did) < 0) { - code = terrno; + int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs); + if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && fobj->f->did.level == nlevel - 1) { + code = tsdbRemoveFileObjectS3(rtner, fobj); + TSDB_CHECK_CODE(code, lino, _exit); + } else { + code = tsdbDoRemoveFileObject(rtner, fobj); TSDB_CHECK_CODE(code, lino, _exit); } - tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); + } - // data - for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = rtner->ctx->fset->farr[ftype], 1); ++ftype) { - if (fobj == NULL) continue; + SSttLvl *lvl; + TARRAY2_FOREACH(fset->lvlArr, lvl) { + TARRAY2_FOREACH(lvl->fobjArr, fobj) { + code = tsdbDoRemoveFileObject(rtner, fobj); + TSDB_CHECK_CODE(code, lino, _exit); + } + } + } else if (expLevel == 0) { // only migrate to upper level + return 0; + } else { // migrate + SDiskID did; + if (tfsAllocDisk(rtner->tsdb->pVnode->pTfs, expLevel, &did) < 0) { + code = terrno; + TSDB_CHECK_CODE(code, lino, _exit); + } + tfsMkdirRecurAt(rtner->tsdb->pVnode->pTfs, rtner->tsdb->path, did); + + // data + for (int32_t ftype = 0; ftype < TSDB_FTYPE_MAX && (fobj = fset->farr[ftype], 1); ++ftype) { + if (fobj == NULL) continue; + + if (fobj->f->did.level == did.level) continue; + + int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs); + if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && did.level == nlevel - 1) { + code = tsdbMigrateDataFileS3(rtner, fobj, &did); + TSDB_CHECK_CODE(code, lino, _exit); + } else { + if (tsS3Enabled) { + int64_t fsize = 0; + if (taosStatFile(fobj->fname, &fsize, NULL, NULL) < 0) { + code = TAOS_SYSTEM_ERROR(terrno); + tsdbError("vgId:%d %s failed since file:%s stat failed, reason:%s", TD_VID(rtner->tsdb->pVnode), __func__, + fobj->fname, tstrerror(code)); + TSDB_CHECK_CODE(code, lino, _exit); + } + s3EvictCache(fobj->fname, fsize * 2); + } + + code = tsdbDoMigrateFileObj(rtner, fobj, &did); + TSDB_CHECK_CODE(code, lino, _exit); + } + } + + // stt + SSttLvl *lvl; + TARRAY2_FOREACH(fset->lvlArr, lvl) { + TARRAY2_FOREACH(lvl->fobjArr, fobj) { if (fobj->f->did.level == did.level) continue; - int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs); - if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && did.level == nlevel - 1) { - code = tsdbMigrateDataFileS3(rtner, fobj, &did); - TSDB_CHECK_CODE(code, lino, _exit); - } else { - if (tsS3Enabled) { - int64_t fsize = 0; - if (taosStatFile(fobj->fname, &fsize, NULL, NULL) < 0) { - code = TAOS_SYSTEM_ERROR(terrno); - tsdbError("vgId:%d %s failed since file:%s stat failed, reason:%s", TD_VID(rtner->tsdb->pVnode), __func__, - fobj->fname, tstrerror(code)); - TSDB_CHECK_CODE(code, lino, _exit); - } - s3EvictCache(fobj->fname, fsize * 2); - } - - code = tsdbDoMigrateFileObj(rtner, fobj, &did); - TSDB_CHECK_CODE(code, lino, _exit); - } - } - - // stt - SSttLvl *lvl; - TARRAY2_FOREACH(rtner->ctx->fset->lvlArr, lvl) { - TARRAY2_FOREACH(lvl->fobjArr, fobj) { - if (fobj->f->did.level == did.level) continue; - - code = tsdbDoMigrateFileObj(rtner, fobj, &did); - TSDB_CHECK_CODE(code, lino, _exit); - } + code = tsdbDoMigrateFileObj(rtner, fobj, &did); + TSDB_CHECK_CODE(code, lino, _exit); } } } - code = tsdbDoRetentionEnd(rtner); - TSDB_CHECK_CODE(code, lino, _exit); - _exit: if (code) { if (TARRAY2_DATA(rtner->fopArr)) { @@ -389,30 +372,105 @@ _exit: return code; } -static void tsdbFreeRtnArg(void *arg) { - SRtnArg *rArg = (SRtnArg *)arg; - if (rArg->sync) { - tsem_post(&rArg->tsdb->pVnode->canCommit); +static int32_t tsdbDoRetentionSync(void *arg) { + int32_t code = 0; + int32_t lino = 0; + SRTNer rtner[1] = {0}; + + code = tsdbDoRetentionBegin(arg, rtner); + TSDB_CHECK_CODE(code, lino, _exit); + + STFileSet *fset; + TARRAY2_FOREACH(rtner->fsetArr, fset) { + code = tsdbDoRetentionOnFileSet(rtner, fset); + TSDB_CHECK_CODE(code, lino, _exit); } - taosMemoryFree(arg); + + code = tsdbDoRetentionEnd(rtner); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: + if (code) { + TSDB_ERROR_LOG(TD_VID(rtner->tsdb->pVnode), lino, code); + } + tsem_post(&((SRtnArg *)arg)->tsdb->pVnode->canCommit); + return code; } -int32_t tsdbRetention(STsdb *tsdb, int64_t now, int32_t sync) { - SRtnArg *arg = taosMemoryMalloc(sizeof(*arg)); - if (arg == NULL) return TSDB_CODE_OUT_OF_MEMORY; - arg->tsdb = tsdb; - arg->sync = sync; - arg->now = now; +static int32_t tsdbDoRetentionAsync(void *arg) { + int32_t code = 0; + int32_t lino = 0; + SRTNer rtner[1] = {0}; - if (sync) { - tsem_wait(&tsdb->pVnode->canCommit); + code = tsdbDoRetentionBegin(arg, rtner); + TSDB_CHECK_CODE(code, lino, _exit); + + STFileSet *fset; + TARRAY2_FOREACH(rtner->fsetArr, fset) { + if (fset->fid != ((SRtnArg *)arg)->fid) continue; + + code = tsdbDoRetentionOnFileSet(rtner, fset); + TSDB_CHECK_CODE(code, lino, _exit); } - int64_t taskid; - int32_t code = - tsdbFSScheduleBgTask(tsdb->pFS, TSDB_BG_TASK_RETENTION, tsdbDoRetention2, tsdbFreeRtnArg, arg, &taskid); + code = tsdbDoRetentionEnd(rtner); + TSDB_CHECK_CODE(code, lino, _exit); + +_exit: if (code) { - tsdbFreeRtnArg(arg); + TSDB_ERROR_LOG(TD_VID(rtner->tsdb->pVnode), lino, code); } return code; } + +static void tsdbFreeRtnArg(void *arg) { taosMemoryFree(arg); } + +int32_t tsdbRetention(STsdb *tsdb, int64_t now, int32_t sync) { + int32_t code = 0; + + if (sync) { // sync retention + SRtnArg *arg = taosMemoryMalloc(sizeof(*arg)); + if (arg == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + arg->tsdb = tsdb; + arg->now = now; + arg->fid = INT32_MAX; + + tsem_wait(&tsdb->pVnode->canCommit); + code = vnodeScheduleTask(tsdbDoRetentionSync, arg); + if (code) { + tsem_post(&tsdb->pVnode->canCommit); + taosMemoryFree(arg); + return code; + } + } else { // async retention + taosThreadMutexLock(&tsdb->mutex); + + STFileSet *fset; + TARRAY2_FOREACH(tsdb->pFS->fSetArr, fset) { + SRtnArg *arg = taosMemoryMalloc(sizeof(*arg)); + if (arg == NULL) { + taosThreadMutexUnlock(&tsdb->mutex); + return TSDB_CODE_OUT_OF_MEMORY; + } + + arg->tsdb = tsdb; + arg->now = now; + arg->fid = fset->fid; + + code = tsdbFSScheduleBgTask(tsdb->pFS, fset->fid, TSDB_BG_TASK_RETENTION, tsdbDoRetentionAsync, tsdbFreeRtnArg, + arg, NULL); + if (code) { + tsdbFreeRtnArg(arg); + taosThreadMutexUnlock(&tsdb->mutex); + return code; + } + } + + taosThreadMutexUnlock(&tsdb->mutex); + } + + return code; +} diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index 3b4827a6be..df7154b775 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -38,8 +38,8 @@ struct STsdbSnapReader { struct { int32_t fsrArrIdx; STSnapRange* fsr; - bool isDataDone; - bool isTombDone; + bool isDataDone; + bool isTombDone; } ctx[1]; // reader @@ -1095,17 +1095,17 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) { code = tsdbFSEditAbort(writer[0]->tsdb->pFS); TSDB_CHECK_CODE(code, lino, _exit); } else { - taosThreadRwlockWrlock(&writer[0]->tsdb->rwLock); + taosThreadMutexLock(&writer[0]->tsdb->mutex); code = tsdbFSEditCommit(writer[0]->tsdb->pFS); if (code) { - taosThreadRwlockUnlock(&writer[0]->tsdb->rwLock); + taosThreadMutexUnlock(&writer[0]->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } writer[0]->tsdb->pFS->fsstate = TSDB_FS_STATE_NORMAL; - taosThreadRwlockUnlock(&writer[0]->tsdb->rwLock); + taosThreadMutexUnlock(&writer[0]->tsdb->mutex); } tsdbFSEnableBgTask(tsdb->pFS); @@ -1236,7 +1236,7 @@ static int32_t tsdbTFileSetToSnapPart(STFileSet* fset, STsdbSnapPartition** ppSP if (fset->farr[ftype] == NULL) continue; typ = tsdbFTypeToSRangeTyp(ftype); ASSERT(typ < TSDB_SNAP_RANGE_TYP_MAX); - STFile* f = fset->farr[ftype]->f; + STFile* f = fset->farr[ftype]->f; if (f->maxVer > fset->maxVerValid) { corrupt = true; tsdbError("skip incomplete data file: fid:%d, maxVerValid:%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 @@ -1255,7 +1255,7 @@ static int32_t tsdbTFileSetToSnapPart(STFileSet* fset, STsdbSnapPartition** ppSP TARRAY2_FOREACH(fset->lvlArr, lvl) { STFileObj* fobj; TARRAY2_FOREACH(lvl->fobjArr, fobj) { - STFile* f = fobj->f; + STFile* f = fobj->f; if (f->maxVer > fset->maxVerValid) { corrupt = true; tsdbError("skip incomplete stt file.fid:%d, maxVerValid:%" PRId64 ", minVer:%" PRId64 ", maxVer:%" PRId64 @@ -1299,7 +1299,7 @@ static STsdbSnapPartList* tsdbGetSnapPartList(STFileSystem* fs) { } int32_t code = 0; - taosThreadRwlockRdlock(&fs->tsdb->rwLock); + taosThreadMutexLock(&fs->tsdb->mutex); STFileSet* fset; TARRAY2_FOREACH(fs->fSetArr, fset) { STsdbSnapPartition* pItem = NULL; @@ -1311,7 +1311,7 @@ static STsdbSnapPartList* tsdbGetSnapPartList(STFileSystem* fs) { code = TARRAY2_SORT_INSERT(pList, pItem, tsdbSnapPartCmprFn); ASSERT(code == 0); } - taosThreadRwlockUnlock(&fs->tsdb->rwLock); + taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { TARRAY2_DESTROY(pList, tsdbSnapPartitionClear); From 4163a3be7c8233d9ca32de6d570b766ba8e5c00e Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Fri, 27 Oct 2023 15:21:55 +0800 Subject: [PATCH 21/45] feat: resend snap replication of data on timeout --- source/dnode/vnode/src/vnd/vnodeSnapshot.c | 1 + source/dnode/vnode/src/vnd/vnodeSync.c | 5 +- source/libs/sync/inc/syncSnapshot.h | 6 +- source/libs/sync/src/syncMain.c | 3 +- source/libs/sync/src/syncSnapshot.c | 265 +++++++++------------ source/libs/sync/src/syncTimeout.c | 5 +- 6 files changed, 126 insertions(+), 159 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 87b407efcb..91244e321f 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -584,6 +584,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * // commit json if (!rollback) { + ASSERT(pVnode->config.vgId == pWriter->info.config.vgId); pWriter->info.state.committed = pWriter->ever; pVnode->config = pWriter->info.config; pVnode->state = (SVState){.committed = pWriter->info.state.committed, diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 6c03ed68e9..c9e805d80b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -516,7 +516,10 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool pVnode->config.vgId, isApply, pSnapshot->lastApplyIndex, pSnapshot->lastApplyTerm, pSnapshot->lastConfigIndex); int32_t code = vnodeSnapWriterClose(pWriter, !isApply, pSnapshot); - vInfo("vgId:%d, apply vnode snapshot finished, code:0x%x", pVnode->config.vgId, code); + if (code != 0) { + vError("vgId:%d, failed to finish applying vnode snapshot since %s, code:0x%x", pVnode->config.vgId, terrstr(), + code); + } return code; } diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index e68702568a..f8ee99e8a0 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -22,9 +22,9 @@ extern "C" { #include "syncInt.h" -#define SYNC_SNAPSHOT_SEQ_INVALID -2 #define SYNC_SNAPSHOT_SEQ_FORCE_CLOSE -3 -#define SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT -1 +#define SYNC_SNAPSHOT_SEQ_INVALID -2 +#define SYNC_SNAPSHOT_SEQ_PREP -1 #define SYNC_SNAPSHOT_SEQ_BEGIN 0 #define SYNC_SNAPSHOT_SEQ_END 0x7FFFFFFF @@ -57,8 +57,6 @@ typedef struct SSyncSnapshotSender { int32_t seq; int32_t ack; void *pReader; - void *pCurrentBlock; - int32_t blockLen; SSnapshotParam snapshotParam; SSnapshot snapshot; SSyncCfg lastConfig; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index f9dc10da02..199c7a1445 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -818,7 +818,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { if (!taosCheckExistFile(pSyncNode->configPath)) { // create a new raft config file - sInfo("vgId:%d, create a new raft config file", pSyncNode->vgId); + sInfo("vgId:%d, create a new raft config file", pSyncInfo->vgId); + pSyncNode->vgId = pSyncInfo->vgId; pSyncNode->raftCfg.isStandBy = pSyncInfo->isStandBy; pSyncNode->raftCfg.snapshotStrategy = pSyncInfo->snapshotStrategy; pSyncNode->raftCfg.lastConfigIndex = pSyncInfo->syncCfg.lastIndex; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index eee0ab2cc9..92d9571906 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -31,9 +31,9 @@ static void syncSnapBufferReset(SSyncSnapBuffer *pBuf) { } pBuf->entries[i % pBuf->size] = NULL; } - pBuf->start = 1; - pBuf->end = 1; - pBuf->cursor = 0; + pBuf->start = SYNC_SNAPSHOT_SEQ_BEGIN + 1; + pBuf->end = pBuf->start; + pBuf->cursor = pBuf->start - 1; taosThreadMutexUnlock(&pBuf->mutex); } @@ -76,8 +76,6 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI pSender->seq = SYNC_SNAPSHOT_SEQ_INVALID; pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; pSender->pReader = NULL; - pSender->pCurrentBlock = NULL; - pSender->blockLen = 0; pSender->sendingMS = SYNC_SNAPSHOT_RETRY_MS; pSender->pSyncNode = pSyncNode; pSender->replicaIndex = replicaIndex; @@ -113,12 +111,6 @@ void syncSnapBlockDestroy(void *ptr) { void snapshotSenderDestroy(SSyncSnapshotSender *pSender) { if (pSender == NULL) return; - // free current block - if (pSender->pCurrentBlock != NULL) { - taosMemoryFree(pSender->pCurrentBlock); - pSender->pCurrentBlock = NULL; - } - // close reader if (pSender->pReader != NULL) { pSender->pSyncNode->pFsm->FpSnapshotStopRead(pSender->pSyncNode->pFsm, pSender->pReader); @@ -141,11 +133,9 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { int8_t started = atomic_val_compare_exchange_8(&pSender->start, false, true); if (started) return 0; - pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; + pSender->seq = SYNC_SNAPSHOT_SEQ_PREP; pSender->ack = SYNC_SNAPSHOT_SEQ_INVALID; pSender->pReader = NULL; - pSender->pCurrentBlock = NULL; - pSender->blockLen = 0; pSender->snapshotParam.start = SYNC_INDEX_INVALID; pSender->snapshotParam.end = SYNC_INDEX_INVALID; pSender->snapshot.data = NULL; @@ -196,7 +186,7 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender) { pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; pMsg->lastConfig = pSender->lastConfig; pMsg->startTime = pSender->startTime; - pMsg->seq = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT; + pMsg->seq = pSender->seq; if (dataLen > 0) { pMsg->payloadType = snapInfo.type; @@ -236,13 +226,6 @@ void snapshotSenderStop(SSyncSnapshotSender *pSender, bool finish) { pSender->pReader = NULL; } - // free current block - if (pSender->pCurrentBlock != NULL) { - taosMemoryFree(pSender->pCurrentBlock); - pSender->pCurrentBlock = NULL; - pSender->blockLen = 0; - } - syncSnapBufferReset(pSender->pSndBuf); SRaftId destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; @@ -255,39 +238,45 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { int32_t code = -1; SyncSnapBlock *pBlk = NULL; - if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) { + if (pSender->seq < SYNC_SNAPSHOT_SEQ_END) { pSender->seq++; - pBlk = taosMemoryCalloc(1, sizeof(SyncSnapBlock)); - if (pBlk == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto _OUT; - } + if (pSender->seq > SYNC_SNAPSHOT_SEQ_BEGIN) { + pBlk = taosMemoryCalloc(1, sizeof(SyncSnapBlock)); + if (pBlk == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OUT; + } - // read data - int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, &pBlk->pBlock, - &pBlk->blockLen); - if (ret != 0) { - sSError(pSender, "snapshot sender read failed since %s", terrstr()); - goto _OUT; - } - pBlk->seq = pSender->seq; + pBlk->seq = pSender->seq; - if (pSender->blockLen > 0) { - // has read data - sSDebug(pSender, "snapshot sender continue to read, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); - } else { - // read finish, update seq to end - pSender->seq = SYNC_SNAPSHOT_SEQ_END; - sSInfo(pSender, "snapshot sender read to the end, blockLen:%d seq:%d", pSender->blockLen, pSender->seq); - code = 0; - goto _OUT; + // read data + int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotDoRead(pSender->pSyncNode->pFsm, pSender->pReader, + &pBlk->pBlock, &pBlk->blockLen); + if (ret != 0) { + sSError(pSender, "snapshot sender read failed since %s", terrstr()); + goto _OUT; + } + + if (pBlk->blockLen > 0) { + // has read data + sSDebug(pSender, "snapshot sender continue to read, blockLen:%d seq:%d", pBlk->blockLen, pBlk->seq); + } else { + // read finish, update seq to end + pSender->seq = SYNC_SNAPSHOT_SEQ_END; + sSInfo(pSender, "snapshot sender read to the end"); + code = 0; + goto _OUT; + } } } + ASSERT(pSender->seq >= SYNC_SNAPSHOT_SEQ_BEGIN && pSender->seq <= SYNC_SNAPSHOT_SEQ_END); + + int32_t blockLen = (pBlk != NULL) ? pBlk->blockLen : 0; // build msg SRpcMsg rpcMsg = {0}; - if (syncBuildSnapshotSend(&rpcMsg, pSender->blockLen, pSender->pSyncNode->vgId) != 0) { + if (syncBuildSnapshotSend(&rpcMsg, blockLen, pSender->pSyncNode->vgId) != 0) { sSError(pSender, "vgId:%d, snapshot sender build msg failed since %s", pSender->pSyncNode->vgId, terrstr()); goto _OUT; } @@ -304,7 +293,7 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { pMsg->startTime = pSender->startTime; pMsg->seq = pSender->seq; - if (pBlk != NULL && pBlk->pBlock != NULL) { + if (pBlk != NULL && pBlk->pBlock != NULL && pBlk->blockLen > 0) { memcpy(pMsg->data, pBlk->pBlock, pBlk->blockLen); } @@ -317,13 +306,12 @@ static int32_t snapshotSend(SSyncSnapshotSender *pSender) { // put in buffer int64_t nowMs = taosGetTimestampMs(); if (pBlk) { - ASSERT(pBlk->seq != SYNC_SNAPSHOT_SEQ_END); + ASSERT(pBlk->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pBlk->seq < SYNC_SNAPSHOT_SEQ_END); pBlk->sendTimeMs = nowMs; pSender->pSndBuf->entries[pSender->seq % pSender->pSndBuf->size] = pBlk; pBlk = NULL; - pSender->pSndBuf->end = pSender->seq + 1; + pSender->pSndBuf->end = TMAX(pSender->seq + 1, pSender->pSndBuf->end); } - pSender->lastSendTime = nowMs; code = 0; @@ -337,36 +325,52 @@ _OUT:; // send snapshot data from cache int32_t snapshotReSend(SSyncSnapshotSender *pSender) { - // build msg - SRpcMsg rpcMsg = {0}; - if (syncBuildSnapshotSend(&rpcMsg, pSender->blockLen, pSender->pSyncNode->vgId) != 0) { - sSError(pSender, "snapshot sender build msg failed since %s", terrstr()); - return -1; + SSyncSnapBuffer *pSndBuf = pSender->pSndBuf; + int32_t code = -1; + + taosThreadMutexLock(&pSndBuf->mutex); + + for (int32_t seq = pSndBuf->cursor + 1; seq < pSndBuf->end; ++seq) { + SyncSnapBlock *pBlk = pSndBuf->entries[seq % pSndBuf->size]; + ASSERT(pBlk && !pBlk->acked); + int64_t nowMs = taosGetTimestampMs(); + if (nowMs < pBlk->sendTimeMs + SYNC_SNAP_RESEND_MS) { + continue; + } + // build msg + SRpcMsg rpcMsg = {0}; + if (syncBuildSnapshotSend(&rpcMsg, pBlk->blockLen, pSender->pSyncNode->vgId) != 0) { + sSError(pSender, "snapshot sender build msg failed since %s", terrstr()); + goto _out; + } + + SyncSnapshotSend *pMsg = rpcMsg.pCont; + pMsg->srcId = pSender->pSyncNode->myRaftId; + pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; + pMsg->term = pSender->term; + pMsg->beginIndex = pSender->snapshotParam.start; + pMsg->lastIndex = pSender->snapshot.lastApplyIndex; + pMsg->lastTerm = pSender->snapshot.lastApplyTerm; + pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; + pMsg->lastConfig = pSender->lastConfig; + pMsg->startTime = pSender->startTime; + pMsg->seq = pBlk->seq; + + if (pBlk->pBlock != NULL && pBlk->blockLen > 0) { + memcpy(pMsg->data, pBlk->pBlock, pBlk->blockLen); + } + + // send msg + if (syncNodeSendMsgById(&pMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { + sSError(pSender, "snapshot sender resend msg failed since %s", terrstr()); + goto _out; + } + pBlk->sendTimeMs = nowMs; + pSender->lastSendTime = nowMs; } - - SyncSnapshotSend *pMsg = rpcMsg.pCont; - pMsg->srcId = pSender->pSyncNode->myRaftId; - pMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - pMsg->term = pSender->term; - pMsg->beginIndex = pSender->snapshotParam.start; - pMsg->lastIndex = pSender->snapshot.lastApplyIndex; - pMsg->lastTerm = pSender->snapshot.lastApplyTerm; - pMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; - pMsg->lastConfig = pSender->lastConfig; - pMsg->startTime = pSender->startTime; - pMsg->seq = pSender->seq; - - if (pSender->pCurrentBlock != NULL && pSender->blockLen > 0) { - memcpy(pMsg->data, pSender->pCurrentBlock, pSender->blockLen); - } - - // send msg - if (syncNodeSendMsgById(&pMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { - sSError(pSender, "snapshot sender resend msg failed since %s", terrstr()); - return -1; - } - - pSender->lastSendTime = taosGetTimestampMs(); + code = 0; +_out:; + taosThreadMutexUnlock(&pSndBuf->mutex); return 0; } @@ -523,7 +527,7 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *p int8_t started = atomic_val_compare_exchange_8(&pReceiver->start, false, true); if (started) return; - pReceiver->ack = SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT; + pReceiver->ack = SYNC_SNAPSHOT_SEQ_PREP; pReceiver->term = pPreMsg->term; pReceiver->fromId = pPreMsg->srcId; pReceiver->startTime = pPreMsg->startTime; @@ -592,6 +596,11 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap // update progress pReceiver->ack = SYNC_SNAPSHOT_SEQ_END; + // get fsmState + SSnapshot snapshot = {0}; + pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + pReceiver->pSyncNode->fsmState = snapshot.state; + // reset wal code = pReceiver->pSyncNode->pLogStore->syncLogRestoreFromSnapshot(pReceiver->pSyncNode->pLogStore, pMsg->lastIndex); @@ -600,12 +609,6 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap return -1; } sRInfo(pReceiver, "wal log restored from snapshot"); - - // get fsmState - SSnapshot snapshot = {0}; - pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); - pReceiver->pSyncNode->fsmState = snapshot.state; - } else { sRError(pReceiver, "snapshot receiver finish error since writer is null"); return -1; @@ -892,6 +895,9 @@ static int32_t syncSnapBufferRecv(SSyncSnapshotReceiver *pReceiver, SyncSnapshot pRcvBuf->entries[pMsg->seq % pRcvBuf->size] = pMsg; ppMsg[0] = NULL; pRcvBuf->end = TMAX(pMsg->seq + 1, pRcvBuf->end); + } else { + syncSnapSendRsp(pReceiver, pMsg, code); + goto _out; } for (int64_t seq = pRcvBuf->cursor + 1; seq < pRcvBuf->end; ++seq) { @@ -991,7 +997,7 @@ _SEND_REPLY:; // receiver on message // -// condition 1, recv SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT +// condition 1, recv SYNC_SNAPSHOT_SEQ_PREP // if receiver already start // if sender.start-time > receiver.start-time, restart receiver(reply snapshot start) // if sender.start-time = receiver.start-time, maybe duplicate msg @@ -1040,7 +1046,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { int32_t code = 0; if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER || pSyncNode->state == TAOS_SYNC_STATE_LEARNER) { if (pMsg->term == raftStoreGetTerm(pSyncNode)) { - if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { + if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP) { sInfo("vgId:%d, receive prepare msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, pMsg->startTime); code = syncNodeOnSnapshotPrep(pSyncNode, pMsg); @@ -1052,16 +1058,14 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { sInfo("vgId:%d, receive end msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, pMsg->startTime); code = syncNodeOnSnapshotEnd(pSyncNode, pMsg); - if (syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode) != 0) { + if (code != 0) { + sRError(pReceiver, "failed to end snapshot."); + code = -1; + } else if (syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode) != 0) { sRError(pReceiver, "failed to reinit log buffer since %s", terrstr()); code = -1; } - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { - // force close, no response - syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process force stop"); - snapshotReceiverStop(pReceiver); } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { - syncLogRecvSyncSnapshotSend(pSyncNode, pMsg, "process seq data"); code = syncNodeOnSnapshotReceive(pSyncNode, ppMsg); } else { // error log @@ -1118,38 +1122,7 @@ static int32_t syncNodeOnSnapshotPrepRsp(SSyncNode *pSyncNode, SSyncSnapshotSend // update next index syncIndexMgrSetIndex(pSyncNode->pNextIndex, &pMsg->srcId, snapshot.lastApplyIndex + 1); - // update seq - pSender->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - - // build begin msg - SRpcMsg rpcMsg = {0}; - if (syncBuildSnapshotSend(&rpcMsg, 0, pSender->pSyncNode->vgId) != 0) { - sSError(pSender, "prepare snapshot failed since build msg error"); - return -1; - } - - SyncSnapshotSend *pSendMsg = rpcMsg.pCont; - pSendMsg->srcId = pSender->pSyncNode->myRaftId; - pSendMsg->destId = pSender->pSyncNode->replicasId[pSender->replicaIndex]; - pSendMsg->term = raftStoreGetTerm(pSender->pSyncNode); - pSendMsg->beginIndex = pSender->snapshotParam.start; - pSendMsg->lastIndex = pSender->snapshot.lastApplyIndex; - pSendMsg->lastTerm = pSender->snapshot.lastApplyTerm; - pSendMsg->lastConfigIndex = pSender->snapshot.lastConfigIndex; - pSendMsg->lastConfig = pSender->lastConfig; - pSendMsg->startTime = pSender->startTime; - pSendMsg->seq = SYNC_SNAPSHOT_SEQ_BEGIN; - - sSInfo(pSender, "begin snapshot replication to dnode %d.", DID(&pSendMsg->destId)); - - // send msg - syncLogSendSyncSnapshotSend(pSyncNode, pSendMsg, "snapshot sender reply pre"); - if (syncNodeSendMsgById(&pSendMsg->destId, pSender->pSyncNode, &rpcMsg) != 0) { - sSError(pSender, "prepare snapshot failed since send msg error"); - return -1; - } - - return 0; + return snapshotSend(pSender); } static int32_t snapshotSenderSignatureCmp(SSyncSnapshotSender *pSender, SyncSnapshotRsp *pMsg) { @@ -1166,10 +1139,18 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp SyncSnapshotRsp *pMsg = ppMsg[0]; taosThreadMutexLock(&pSndBuf->mutex); + if (snapshotSenderSignatureCmp(pSender, pMsg) != 0) { + code = terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; + goto _out; + } + + if (pSender->pReader == NULL || pSender->finish) { + code = terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + goto _out; + } if (pMsg->ack - pSndBuf->start >= pSndBuf->size) { - terrno = TSDB_CODE_SYN_BUFFER_FULL; - code = terrno; + code = terrno = TSDB_CODE_SYN_BUFFER_FULL; goto _out; } @@ -1196,16 +1177,11 @@ static int32_t syncSnapBufferSend(SSyncSnapshotSender *pSender, SyncSnapshotRsp pSndBuf->start = ack + 1; } - pSender->ack = pSndBuf->start - 1; - while (pSender->seq != SYNC_SNAPSHOT_SEQ_END && pSender->seq - pSndBuf->start < (pSndBuf->size >> 2)) { if (snapshotSend(pSender) != 0) { code = terrno; goto _out; } - if (pSender->seq != SYNC_SNAPSHOT_SEQ_END) { - pSndBuf->end = TMAX(pSender->seq + 1, pSndBuf->end); - } } if (pSender->seq == SYNC_SNAPSHOT_SEQ_END && pSndBuf->end <= pSndBuf->start) { @@ -1285,23 +1261,17 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { } // prepare , send begin msg - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP_SNAPSHOT) { + if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP) { return syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg); } - if (pSender->pReader == NULL || pSender->finish) { - sSError(pSender, "snapshot sender invalid error:%s 0x%x, pReader:%p finish:%d", tstrerror(pMsg->code), pMsg->code, - pSender->pReader, pSender->finish); - terrno = pMsg->code; - goto _ERROR; - } - - if (pMsg->ack == SYNC_SNAPSHOT_SEQ_BEGIN) { - sSInfo(pSender, "process seq begin"); - if (snapshotSend(pSender) != 0) { + // send next msg + if (pMsg->ack >= SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->ack < SYNC_SNAPSHOT_SEQ_END) { + if (syncSnapBufferSend(pSender, ppMsg) != 0) { + sSError(pSender, "failed to replicate snap since %s. seq:%d, pReader:%p, finish:%d", terrstr(), pSender->seq, + pSender->pReader, pSender->finish); goto _ERROR; } - return 0; } // receive ack is finish, close sender @@ -1312,11 +1282,6 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { return 0; } - // send next msg - if (syncSnapBufferSend(pSender, ppMsg) != 0) { - sSError(pSender, "failed to send snapshot msg since %s. seq:%d", terrstr(), pSender->seq); - goto _ERROR; - } return 0; _ERROR: diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 91c7494fa4..5837308e59 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -78,9 +78,8 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) { SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(ths->peersId[i])); if (pSender != NULL) { if (ths->isStart && ths->state == TAOS_SYNC_STATE_LEADER && pSender->start && - timeNow - pSender->lastSendTime > SYNC_SNAP_TIMEOUT_MS) { - sSError(pSender, "snapshot timeout, terminate. lastSendTime:%d", pSender->lastSendTime); - snapshotSenderStop(pSender, false); + timeNow - pSender->lastSendTime > SYNC_SNAP_RESEND_MS) { + snapshotReSend(pSender); } } } From a7f3041ff3e28179d7916a103e45967608fad1db Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 27 Oct 2023 17:59:27 +0800 Subject: [PATCH 22/45] more fix --- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index ee3abf7559..cc77474e79 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -191,7 +191,7 @@ int32_t tsdbDeleteTableData(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid pMemTable->nDel++; pMemTable->minVer = TMIN(pMemTable->minVer, version); - pMemTable->maxVer = TMIN(pMemTable->maxVer, version); + pMemTable->maxVer = TMAX(pMemTable->maxVer, version); /* if (TSDB_CACHE_LAST_ROW(pMemTable->pTsdb->pVnode->config) && tsdbKeyCmprFn(&lastKey, &pTbData->maxKey) >= 0) { tsdbCacheDeleteLastrow(pTsdb->lruCache, pTbData->uid, eKey); From c3f9cae36bfa9fa8ce7df630834259999b14e3f6 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Fri, 27 Oct 2023 18:55:30 +0800 Subject: [PATCH 23/45] refact: improve code of syncNodeOnSnapshot --- source/libs/sync/src/syncSnapshot.c | 106 +++++++++++++++------------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 92d9571906..56735d479e 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -1019,6 +1019,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { SyncSnapshotSend **ppMsg = (SyncSnapshotSend **)&pRpcMsg->pCont; SyncSnapshotSend *pMsg = ppMsg[0]; SSyncSnapshotReceiver *pReceiver = pSyncNode->pNewNodeReceiver; + int32_t code = 0; // if already drop replica, do not process if (!syncNodeInRaftGroup(pSyncNode, &pMsg->srcId)) { @@ -1042,47 +1043,56 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { syncNodeUpdateTermWithoutStepDown(pSyncNode, pMsg->term); } - // state, term, seq/ack - int32_t code = 0; - if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER || pSyncNode->state == TAOS_SYNC_STATE_LEARNER) { - if (pMsg->term == raftStoreGetTerm(pSyncNode)) { - if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP) { - sInfo("vgId:%d, receive prepare msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", - pSyncNode->vgId, pMsg->term, pMsg->startTime); - code = syncNodeOnSnapshotPrep(pSyncNode, pMsg); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { - sInfo("vgId:%d, receive begin msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", - pSyncNode->vgId, pMsg->term, pMsg->startTime); - code = syncNodeOnSnapshotBegin(pSyncNode, pMsg); - } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { - sInfo("vgId:%d, receive end msg of snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, - pMsg->term, pMsg->startTime); - code = syncNodeOnSnapshotEnd(pSyncNode, pMsg); - if (code != 0) { - sRError(pReceiver, "failed to end snapshot."); - code = -1; - } else if (syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode) != 0) { - sRError(pReceiver, "failed to reinit log buffer since %s", terrstr()); - code = -1; - } - } else if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { - code = syncNodeOnSnapshotReceive(pSyncNode, ppMsg); - } else { - // error log - sRError(pReceiver, "snapshot receiver recv error seq:%d, my ack:%d", pMsg->seq, pReceiver->ack); - code = -1; - } - } else { - // error log - sRError(pReceiver, "snapshot receiver term not equal"); - code = -1; - } - } else { - // error log - sRError(pReceiver, "snapshot receiver not follower"); - code = -1; + if (pSyncNode->state != TAOS_SYNC_STATE_FOLLOWER && pSyncNode->state != TAOS_SYNC_STATE_LEARNER) { + sRError(pReceiver, "snapshot receiver not a follower or learner"); + return -1; } + if (pMsg->seq < SYNC_SNAPSHOT_SEQ_PREP || pMsg->seq > SYNC_SNAPSHOT_SEQ_END) { + sRError(pReceiver, "snap replication msg with invalid seq:%d", pMsg->seq); + return -1; + } + + // prepare + if (pMsg->seq == SYNC_SNAPSHOT_SEQ_PREP) { + sInfo("vgId:%d, prepare snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, + pMsg->startTime); + code = syncNodeOnSnapshotPrep(pSyncNode, pMsg); + goto _out; + } + + // begin + if (pMsg->seq == SYNC_SNAPSHOT_SEQ_BEGIN) { + sInfo("vgId:%d, begin snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, + pMsg->startTime); + code = syncNodeOnSnapshotBegin(pSyncNode, pMsg); + goto _out; + } + + // data + if (pMsg->seq > SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->seq < SYNC_SNAPSHOT_SEQ_END) { + code = syncNodeOnSnapshotReceive(pSyncNode, ppMsg); + goto _out; + } + + // end + if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { + sInfo("vgId:%d, end snap replication. msg signature:(%" PRId64 ", %" PRId64 ")", pSyncNode->vgId, pMsg->term, + pMsg->startTime); + code = syncNodeOnSnapshotEnd(pSyncNode, pMsg); + if (code != 0) { + sRError(pReceiver, "failed to end snapshot."); + goto _out; + } + + code = syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode); + if (code != 0) { + sRError(pReceiver, "failed to reinit log buffer since %s", terrstr()); + } + goto _out; + } + +_out:; syncNodeResetElectTimer(pSyncNode); return code; } @@ -1229,8 +1239,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { // check signature int32_t order = 0; if ((order = snapshotSenderSignatureCmp(pSender, pMsg)) > 0) { - sSError(pSender, "received a stale snapshot rsp, msg signature:(%" PRId64 ", %" PRId64 "), ignore it.", pMsg->term, - pMsg->startTime); + sSWarn(pSender, "ignore a stale snap rsp, msg signature:(%" PRId64 ", %" PRId64 ").", pMsg->term, pMsg->startTime); terrno = TSDB_CODE_SYN_MISMATCHED_SIGNATURE; return -1; } else if (order < 0) { @@ -1239,7 +1248,6 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { goto _ERROR; } - // state, term, seq/ack if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { sSError(pSender, "snapshot sender not leader"); terrno = TSDB_CODE_SYN_NOT_LEADER; @@ -1260,12 +1268,15 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { goto _ERROR; } - // prepare , send begin msg + // send begin if (pMsg->ack == SYNC_SNAPSHOT_SEQ_PREP) { - return syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg); + sSInfo(pSender, "process prepare rsp"); + if (syncNodeOnSnapshotPrepRsp(pSyncNode, pSender, pMsg) != 0) { + goto _ERROR; + } } - // send next msg + // send msg of data or end if (pMsg->ack >= SYNC_SNAPSHOT_SEQ_BEGIN && pMsg->ack < SYNC_SNAPSHOT_SEQ_END) { if (syncSnapBufferSend(pSender, ppMsg) != 0) { sSError(pSender, "failed to replicate snap since %s. seq:%d, pReader:%p, finish:%d", terrstr(), pSender->seq, @@ -1274,12 +1285,11 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { } } - // receive ack is finish, close sender + // end if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { - sSInfo(pSender, "process seq end"); + sSInfo(pSender, "process end rsp"); snapshotSenderStop(pSender, true); syncNodeReplicateReset(pSyncNode, &pMsg->srcId); - return 0; } return 0; From 55f6d2b7a96e50e364c286c0bdd813ba35ff5717 Mon Sep 17 00:00:00 2001 From: facetosea <285808407@qq.com> Date: Mon, 30 Oct 2023 09:30:35 +0800 Subject: [PATCH 24/45] use TSDB_MAX_KEEP --- source/libs/parser/src/parTranslater.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d65f97dce7..5c7a6180c0 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3526,7 +3526,7 @@ static void convertVarDuration(SValueNode* pOffset, uint8_t precision) { pOffset->unit = units[precision]; } -static const int64_t maxKeepMS = (int64_t)3600 * 1000 * 24 * (365 * 1000 + 250); +static const int64_t tsdbMaxKeepMS = (int64_t)60 * 1000 * TSDB_MAX_KEEP; static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision; @@ -3535,7 +3535,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* if (pInter->datum.i <= 0 || (!valInter && pInter->datum.i < tsMinIntervalTime)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL, tsMinIntervalTime, getPrecisionStr(precision)); - } else if (pInter->datum.i / getPrecisionMultiple(precision) > maxKeepMS) { + } else if (pInter->datum.i / getPrecisionMultiple(precision) > tsdbMaxKeepMS) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_VALUE_TOO_BIG, 1000, "years"); } From 4b6f927e6a719e763cc1b34f44fcd669cfa2f3be Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 30 Oct 2023 10:11:57 +0800 Subject: [PATCH 25/45] fix: add test case for bi tag scan --- source/libs/parser/src/parAstCreater.c | 7 +++--- tests/parallel_test/cases.task | 1 + tests/script/tsim/query/bi_tag_scan.sim | 31 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 tests/script/tsim/query/bi_tag_scan.sim diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 8196a9b329..de7ffce2d3 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1024,15 +1024,14 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr SNodeList* pHint) { CHECK_PARSER_STATUS(pCxt); SNode* select = createSelectStmtImpl(isDistinct, pProjectionList, pTable, pHint); - if (pCxt->pQueryCxt->biMode) { - setSelectStmtTagMode(pCxt, select, true); - } CHECK_OUT_OF_MEM(select); return select; } SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { - if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + if (pCxt->pQueryCxt->biMode) { + ((SSelectStmt*)pStmt)->tagScan = true; + } else if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->tagScan = bSelectTags; } return pStmt; diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 6915f802c3..1206e11c75 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -1044,6 +1044,7 @@ e ,,y,script,./test.sh -f tsim/query/tableCount.sim ,,y,script,./test.sh -f tsim/query/show_db_table_kind.sim ,,y,script,./test.sh -f tsim/query/bi_star_table.sim +,,y,script,./test.sh -f tsim/query/bi_tag_scan.sim ,,y,script,./test.sh -f tsim/query/tag_scan.sim ,,y,script,./test.sh -f tsim/query/nullColSma.sim ,,y,script,./test.sh -f tsim/query/bug3398.sim diff --git a/tests/script/tsim/query/bi_tag_scan.sim b/tests/script/tsim/query/bi_tag_scan.sim new file mode 100644 index 0000000000..5b8af68b5a --- /dev/null +++ b/tests/script/tsim/query/bi_tag_scan.sim @@ -0,0 +1,31 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 3; +sql create database db1; +sql use db1; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql insert into tba1 values(now, 1, "1")(now+3s, 3, "3")(now+5s, 5, "5"); +sql insert into tba2 values(now + 1s, 2, "2")(now+2s, 2, "2")(now+4s, 4, "4"); +sql create table tbn1 (ts timestamp, f1 int); + +set_bi_mode 1 +sql select t1,t2,t3 from db1.sta order by t1; +print $rows $data00 $data10 +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT From 70e261f66217e2d1ff8f1c6edd5374db7ed921b6 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Fri, 27 Oct 2023 19:21:54 +0800 Subject: [PATCH 26/45] enh: terminate snap replication on timeout --- include/libs/sync/sync.h | 2 +- source/libs/sync/src/syncSnapshot.c | 4 +--- source/libs/sync/src/syncTimeout.c | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index e3b5f3611c..a19b249bc7 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -46,7 +46,7 @@ extern "C" { #define SYNC_HEARTBEAT_SLOW_MS 1500 #define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500 #define SYNC_SNAP_RESEND_MS 1000 * 60 -#define SYNC_SNAP_TIMEOUT_MS 1000 * 180 +#define SYNC_SNAP_TIMEOUT_MS 1000 * 600 #define SYNC_VND_COMMIT_MIN_MS 3000 diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 56735d479e..0b94d377f1 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -327,7 +327,6 @@ _OUT:; int32_t snapshotReSend(SSyncSnapshotSender *pSender) { SSyncSnapBuffer *pSndBuf = pSender->pSndBuf; int32_t code = -1; - taosThreadMutexLock(&pSndBuf->mutex); for (int32_t seq = pSndBuf->cursor + 1; seq < pSndBuf->end; ++seq) { @@ -366,12 +365,11 @@ int32_t snapshotReSend(SSyncSnapshotSender *pSender) { goto _out; } pBlk->sendTimeMs = nowMs; - pSender->lastSendTime = nowMs; } code = 0; _out:; taosThreadMutexUnlock(&pSndBuf->mutex); - return 0; + return code; } // return 0, start ok diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 5837308e59..a57dfbee53 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -77,9 +77,19 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) { for (int i = 0; i < ths->peersNum; ++i) { SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(ths->peersId[i])); if (pSender != NULL) { - if (ths->isStart && ths->state == TAOS_SYNC_STATE_LEADER && pSender->start && - timeNow - pSender->lastSendTime > SYNC_SNAP_RESEND_MS) { - snapshotReSend(pSender); + if (ths->isStart && ths->state == TAOS_SYNC_STATE_LEADER && pSender->start) { + int64_t elapsedMs = timeNow - pSender->lastSendTime; + if (elapsedMs < SYNC_SNAP_RESEND_MS) { + continue; + } + + if (elapsedMs > SYNC_SNAP_TIMEOUT_MS) { + sSError(pSender, "snap replication timeout, terminate."); + snapshotSenderStop(pSender, false); + } else { + sSWarn(pSender, "snap replication resend."); + snapshotReSend(pSender); + } } } } From 78cce0003767bb44b4b876a1e8e4954a9bc2a8bc Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Mon, 30 Oct 2023 10:46:17 +0800 Subject: [PATCH 27/45] test: pause 1s after creating stream in testcase sliding.sim --- tests/script/tsim/stream/sliding.sim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/script/tsim/stream/sliding.sim b/tests/script/tsim/stream/sliding.sim index 18893245fa..a92da7f472 100644 --- a/tests/script/tsim/stream/sliding.sim +++ b/tests/script/tsim/stream/sliding.sim @@ -21,6 +21,7 @@ sql create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 in sql create stream streams2 trigger at_once watermark 1d IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s) sliding (5s); sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamtST as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); sql create stream stream_t2 trigger at_once watermark 1d IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamtST2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s) sliding (5s); +sleep 1000 sql insert into t1 values(1648791210000,1,2,3,1.0); sql insert into t1 values(1648791216000,2,2,3,1.1); @@ -311,6 +312,7 @@ sql create table t2 using st tags(2,2,2); sql create stream streams11 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s, 5s); sql create stream streams12 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt2 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s, 5s); +sleep 1000 sql insert into t1 values(1648791213000,1,2,3,1.0); sql insert into t1 values(1648791223001,2,2,3,1.1); @@ -444,6 +446,7 @@ sql create table t2 using st tags(2,2,2); sql create stream streams21 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt21 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from t1 interval(10s, 5s); sql create stream streams22 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt22 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s, 5s); +sleep 1000 sql insert into t1 values(1648791213000,1,1,1,1.0); sql insert into t1 values(1648791223001,2,2,2,1.1); @@ -582,6 +585,7 @@ sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); sql create stream streams23 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt23 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(20s) sliding(10s); +sleep 1000 sql insert into t1 values(1648791213000,1,1,1,1.0); sql insert into t1 values(1648791223001,2,2,2,1.1); @@ -706,6 +710,7 @@ sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); sql create stream streams4 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt4 as select _wstart as ts, count(*),min(a) c1 from st interval(10s) sliding(5s); +sleep 1000 sql insert into t1 values(1648791213000,1,1,1,1.0); sql insert into t1 values(1648791243000,2,1,1,1.0); @@ -818,4 +823,4 @@ print ============loop_all=$loop_all #=goto looptest -system sh/stop_dnodes.sh \ No newline at end of file +system sh/stop_dnodes.sh From 58e61e21a5064ee9be6aeffe1e7bf77a9251d2d1 Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:36:10 +0800 Subject: [PATCH 28/45] Update 10-function.md --- docs/zh/12-taos-sql/10-function.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 44ab3d5091..6840147112 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -539,7 +539,7 @@ TO_CHAR(ts, format_str_literal) - 使用`ms`, `us`, `ns`时, 以上三种格式的输出只在精度上不同, 比如ts为 `1697182085123`, `ms` 的输出为 `123`, `us` 的输出为 `123000`, `ns` 的输出为 `123000000`. - 时间格式中无法匹配规则的内容会直接输出. 如果想要在格式串中指定某些能够匹配规则的部分不做转换, 可以使用双引号, 如`to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. 如果想要输出双引号, 那么在双引号之前加一个反斜杠, 如 `to_char(ts, '\"yyyy-mm-dd\"')` 将会输出 `"2023-10-10"`. - 那些输出是数字的格式, 如`YYYY`, `DD`, 大写与小写意义相同, 即`yyyy` 和 `YYYY` 可以互换. -- 默认输出的时间为本地时区的时间. +- 推荐在时间格式中带时区信息,如果不带则默认输出的时区为服务端或客户端所配置的时区. #### TO_TIMESTAMP From af1fed4f04f36a05975963c85dc44ff59b1a6997 Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:41:28 +0800 Subject: [PATCH 29/45] Update 10-function.md --- docs/en/12-taos-sql/10-function.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index c986a98e46..5ff02b0f9d 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -539,7 +539,7 @@ TO_CHAR(ts, format_str_literal) - When `ms`,`us`,`ns` are used in `to_char`, like `to_char(ts, 'yyyy-mm-dd hh:mi:ss.ms.us.ns')`, The time of `ms`,`us`,`ns` corresponds to the same fraction seconds. When ts is `1697182085123`, the output of `ms` is `123`, `us` is `123000`, `ns` is `123000000`. - If we want to output some characters of format without converting, surround it with double quotes. `to_char(ts, 'yyyy-mm-dd "is formated by yyyy-mm-dd"')`. If want to output double quotes, add a back slash before double quote, like `to_char(ts, '\"yyyy-mm-dd\"')` will output `"2023-10-10"`. - For formats that output digits, the uppercase and lowercase formats are the same. -- The local time zone will be used to convert the timestamp. +- It's recommended to put time zone in the format, if not, the default time zone zone will be that in server or client. #### TO_TIMESTAMP From 46826ea600a1c7b8d5a8c0fd7f12f44b61b45b9e Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:51:08 +0800 Subject: [PATCH 30/45] Update 10-function.md --- docs/zh/12-taos-sql/10-function.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 6840147112..4371124623 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -563,7 +563,8 @@ TO_TIMESTAMP(ts_str_literal, format_str_literal) - 若`ms`, `us`, `ns`同时指定, 那么结果时间戳包含上述三个字段的和. 如 `to_timestamp('2023-10-10 10:10:10.123.000456.000000789', 'yyyy-mm-dd hh:mi:ss.ms.us.ns')` 输出是 `2023-10-10 10:10:10.123456789`. - `MONTH`, `MON`, `DAY`, `DY` 以及其他输出为数字的格式的大小写意义相同, 如 `to_timestamp('2023-JANUARY-01', 'YYYY-month-dd')`, `month`可以被替换为`MONTH` 或者`Month`. - 如果同一字段被指定了多次, 那么前面的指定将会被覆盖. 如 `to_timestamp('2023-22-10-10', 'yyyy-yy-MM-dd')`, 输出年份是`2022`. -- 如果某些部分没有指定 那么默认时间为本地时区的 `1970-01-01 00:00:00`, 未指定部分为对应默认值. +- 为避免转换时使用了非预期的时区,推荐在时间中携带时区信息,例如'2023-10-10 10:10:10+08',如果未指定时区则默认时区为服务端或客户端指定的时区。 +- 如果没有指定完整的时间,那么默认时间值为指定或默认时区的 `1970-01-01 00:00:00`, 未指定部分使用该默认值中的对应部分. - 如果格式串中有`AM`, `PM`等, 那么小时必须是12小时制, 范围必须是01-12. - `to_timestamp`转换具有一定的容错机制, 在格式串和时间戳串不完全对应时, 有时也可转换, 如: `to_timestamp('200101/2', 'yyyyMM1/dd')`, 格式串中多出来的1会被丢弃. 格式串与时间戳串中多余的空格字符(空格, tab等)也会被 自动忽略. 如`to_timestamp(' 23 年 - 1 月 - 01 日 ', 'yy 年-MM月-dd日')` 可以被成功转换. 虽然`MM`等字段需要两个数字对应(只有一位时前面补0), 在`to_timestamp`时, 一个数字也可以成功转换. From d73968a6595c863f6991c8fc4bd254f86d1fd63f Mon Sep 17 00:00:00 2001 From: dapan1121 <72057773+dapan1121@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:56:20 +0800 Subject: [PATCH 31/45] Update 10-function.md --- docs/en/12-taos-sql/10-function.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index 5ff02b0f9d..18c7ffc345 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -563,7 +563,8 @@ TO_TIMESTAMP(ts_str_literal, format_str_literal) - When `ms`, `us`, `ns` are used in `to_timestamp`, if multi of them are specified, the results are accumulated. For example, `to_timestamp('2023-10-10 10:10:10.123.000456.000000789', 'yyyy-mm-dd hh:mi:ss.ms.us.ns')` will output the timestamp of `2023-10-10 10:10:10.123456789`. - The uppercase or lowercase of `MONTH`, `MON`, `DAY`, `DY` and formtas that output digits have same effect when used in `to_timestamp`, like `to_timestamp('2023-JANUARY-01', 'YYYY-month-dd')`, `month` can be replaced by `MONTH`, or `month`. The cases are ignored. - If multi times are specified for one component, the previous will be overwritten. Like `to_timestamp('2023-22-10-10', 'yyyy-yy-MM-dd')`, the output year will be `2022`. -- The default timetsamp if some components are not specified will be: `1970-01-01 00:00:00` with your local timezone. +- To avoid unexpected time zone used during the convertion, it's recommended to put time zone in the ts string, e.g. '2023-10-10 10:10:10+08'. If time zone not specified, default will be that in server or client. +- The default timestamp if some components are not specified will be: `1970-01-01 00:00:00` with specified or default local timezone. - If `AM` or `PM` is specified in formats, the Hour must between `1-12`. - In some cases, `to_timestamp` can convert correctly even the format and the timestamp string are not totally matched. Like `to_timetamp('200101/2', 'yyyyMM1/dd')`, the digit `1` in format string are ignored, and the output timestsamp is `2001-01-02 00:00:00`. Spaces and tabs in formats and tiemstamp string are also ignored automatically. From c77153cb8137b25f4c38ae59079ce5b53e6d1817 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 14:02:31 +0800 Subject: [PATCH 32/45] enh: use placeholder '-' for interval of 1st retention level --- include/common/tmsg.h | 2 +- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 2 +- source/dnode/vnode/src/sma/smaOpen.c | 31 +- source/dnode/vnode/src/vnd/vnodeCfg.c | 2 +- source/libs/command/src/command.c | 37 +- source/libs/parser/inc/sql.y | 1 + source/libs/parser/src/parTranslater.c | 14 +- source/libs/parser/src/sql.c | 6404 +++++++---------- .../script/tsim/sma/rsmaCreateInsertQuery.sim | 2 +- .../tsim/sma/rsmaPersistenceRecovery.sim | 2 +- .../tsim/sync/vnodesnapshot-rsma-test.sim | 2 +- tests/system-test/1-insert/block_wise.py | 4 +- .../system-test/1-insert/create_retentions.py | 82 +- tests/system-test/1-insert/time_range_wise.py | 4 +- 14 files changed, 2687 insertions(+), 3902 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index fa123b11f8..331188c264 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -451,7 +451,7 @@ typedef struct SRetention { int8_t keepUnit; } SRetention; -#define RETENTION_VALID(r) (((r)->freq > 0) && ((r)->keep > 0)) +#define RETENTION_VALID(l, r) ((((l) == 0 && (r)->freq >= 0) || ((r)->freq > 0)) && ((r)->keep > 0)) #pragma pack(push, 1) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index cc542f51ce..c4d525a871 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -137,7 +137,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { SRetention *pRetention = &pCfg->tsdbCfg.retentions[i]; memcpy(pRetention, taosArrayGet(pCreate->pRetensions, i), sizeof(SRetention)); if (i == 0) { - if ((pRetention->freq > 0 && pRetention->keep > 0)) pCfg->isRsma = 1; + if ((pRetention->freq >= 0 && pRetention->keep > 0)) pCfg->isRsma = 1; } } diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index 49f25c0b0a..f0e329dfd7 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -31,21 +31,21 @@ static int32_t rsmaRestore(SSma *pSma); } while (0) #define SMA_OPEN_RSMA_IMPL(v, l, force) \ - do { \ - SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \ - if (!RETENTION_VALID(r)) { \ - if (l == 0) { \ - code = TSDB_CODE_INVALID_PARA; \ - TSDB_CHECK_CODE(code, lino, _exit); \ - } \ - break; \ - } \ - code = smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ - TSDB_CHECK_CODE(code, lino, _exit); \ + do { \ + SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \ + if (!RETENTION_VALID(l, r)) { \ + if (l == 0) { \ + code = TSDB_CODE_INVALID_PARA; \ + TSDB_CHECK_CODE(code, lino, _exit); \ + } \ + break; \ + } \ + code = smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \ + TSDB_CHECK_CODE(code, lino, _exit); \ if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg, rollback, force) < 0) { \ - code = terrno; \ - TSDB_CHECK_CODE(code, lino, _exit); \ - } \ + code = terrno; \ + TSDB_CHECK_CODE(code, lino, _exit); \ + } \ } while (0) /** @@ -79,7 +79,7 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); - int32_t nFreqTimes = (r + level)->freq / (r + TSDB_RETENTION_L0)->freq; + int32_t nFreqTimes = (r + level)->freq / (10 * 1000); // use 10s for freq of 1st level days *= (nFreqTimes > 1 ? nFreqTimes : 1); if (days > keepDuration) { @@ -157,6 +157,7 @@ int32_t smaOpen(SVnode *pVnode, int8_t rollback, bool force) { _exit: if (code) { smaError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); + terrno = code; } return code; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index bbd67611cb..07bfa6c719 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -106,7 +106,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keepTimeOffset", pCfg->tsdbCfg.keepTimeOffset) < 0) return -1; - if (pCfg->tsdbCfg.retentions[0].freq > 0) { + if (pCfg->tsdbCfg.retentions[0].keep > 0) { int32_t nRetention = 1; if (pCfg->tsdbCfg.retentions[1].freq > 0) { ++nRetention; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index f204f239b4..3d7a88ac03 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -215,37 +215,28 @@ int64_t getValOfDiffPrecision(int8_t unit, int64_t val) { return v; } -char* buildRetension(SArray* pRetension) { +static char* buildRetension(SArray* pRetension) { size_t size = taosArrayGetSize(pRetension); if (size == 0) { return NULL; } - char* p1 = taosMemoryCalloc(1, 100); - SRetention* p = taosArrayGet(pRetension, 0); - + char* p1 = taosMemoryCalloc(1, 100); int32_t len = 0; - int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + for (int32_t i = 0; i < size; ++i) { + SRetention* p = TARRAY_GET_ELEM(pRetension, i); + int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq); + int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep); + if (i == 0) { + len += sprintf(p1 + len, "-:%" PRId64 "%c", v2, p->keepUnit); + } else { + len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + } - if (size > 1) { - len += sprintf(p1 + len, ","); - p = taosArrayGet(pRetension, 1); - - v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); - } - - if (size > 2) { - len += sprintf(p1 + len, ","); - p = taosArrayGet(pRetension, 2); - - v1 = getValOfDiffPrecision(p->freqUnit, p->freq); - v2 = getValOfDiffPrecision(p->keepUnit, p->keep); - len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + if (i < size - 1) { + len += sprintf(p1 + len, ","); + } } return p1; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 149306b23c..a7b490c0dc 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -304,6 +304,7 @@ retention_list(A) ::= retention(B). retention_list(A) ::= retention_list(B) NK_COMMA retention(C). { A = addNodeToList(pCxt, B, C); } retention(A) ::= NK_VARIABLE(B) NK_COLON NK_VARIABLE(C). { A = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &B), createDurationValueNode(pCxt, &C)); } +retention(A) ::= NK_MINUS(B) NK_COLON NK_VARIABLE(C). { A = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &B), createDurationValueNode(pCxt, &C)); } %type speed_opt { int32_t } %destructor speed_opt { } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index ece2c82748..487abd6613 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4588,10 +4588,22 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete SValueNode* pPrevFreq = NULL; SValueNode* pPrevKeep = NULL; SNode* pRetention = NULL; + bool firstFreq = true; FOREACH(pRetention, pRetentions) { SNode* pNode = NULL; FOREACH(pNode, ((SNodeListNode*)pRetention)->pNodeList) { SValueNode* pVal = (SValueNode*)pNode; + if (firstFreq) { + firstFreq = false; + if (pVal->literal[0] != '-' || strlen(pVal->literal) != 1) { + return generateSyntaxErrMsgExt( + &pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, + "Invalid option retentions(freq): %s, the interval of 1st retention level should be '-'", pVal->literal); + } + pVal->unit = TIME_UNIT_SECOND; // assign minimum unit + pVal->datum.i = 0; // assign minimum value + continue; + } if (DEAL_RES_ERROR == translateValue(pCxt, pVal)) { return pCxt->errCode; } @@ -4616,7 +4628,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete } // check value range - if (pFreq->datum.i <= 0) { + if (pPrevFreq != NULL && pFreq->datum.i <= 0) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option retentions(freq): %s should larger than 0", pFreq->literal); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 43382c08b1..a4958c3e80 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -24,8 +24,9 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +#include +#include /************ Begin %include sections from the grammar ************************/ -#line 11 "sql.y" #include #include @@ -42,357 +43,12 @@ #include "parAst.h" #define YYSTACKDEPTH 0 -#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols. -***************** Begin token definitions *************************************/ -#ifndef TK_OR -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_NK_COMMA 33 -#define TK_HOST 34 -#define TK_USER 35 -#define TK_ENABLE 36 -#define TK_NK_INTEGER 37 -#define TK_SYSINFO 38 -#define TK_ADD 39 -#define TK_DROP 40 -#define TK_GRANT 41 -#define TK_ON 42 -#define TK_TO 43 -#define TK_REVOKE 44 -#define TK_FROM 45 -#define TK_SUBSCRIBE 46 -#define TK_READ 47 -#define TK_WRITE 48 -#define TK_NK_DOT 49 -#define TK_WITH 50 -#define TK_DNODE 51 -#define TK_PORT 52 -#define TK_DNODES 53 -#define TK_RESTORE 54 -#define TK_NK_IPTOKEN 55 -#define TK_FORCE 56 -#define TK_UNSAFE 57 -#define TK_LOCAL 58 -#define TK_QNODE 59 -#define TK_BNODE 60 -#define TK_SNODE 61 -#define TK_MNODE 62 -#define TK_VNODE 63 -#define TK_DATABASE 64 -#define TK_USE 65 -#define TK_FLUSH 66 -#define TK_TRIM 67 -#define TK_COMPACT 68 -#define TK_IF 69 -#define TK_NOT 70 -#define TK_EXISTS 71 -#define TK_BUFFER 72 -#define TK_CACHEMODEL 73 -#define TK_CACHESIZE 74 -#define TK_COMP 75 -#define TK_DURATION 76 -#define TK_NK_VARIABLE 77 -#define TK_MAXROWS 78 -#define TK_MINROWS 79 -#define TK_KEEP 80 -#define TK_PAGES 81 -#define TK_PAGESIZE 82 -#define TK_TSDB_PAGESIZE 83 -#define TK_PRECISION 84 -#define TK_REPLICA 85 -#define TK_VGROUPS 86 -#define TK_SINGLE_STABLE 87 -#define TK_RETENTIONS 88 -#define TK_SCHEMALESS 89 -#define TK_WAL_LEVEL 90 -#define TK_WAL_FSYNC_PERIOD 91 -#define TK_WAL_RETENTION_PERIOD 92 -#define TK_WAL_RETENTION_SIZE 93 -#define TK_WAL_ROLL_PERIOD 94 -#define TK_WAL_SEGMENT_SIZE 95 -#define TK_STT_TRIGGER 96 -#define TK_TABLE_PREFIX 97 -#define TK_TABLE_SUFFIX 98 -#define TK_KEEP_TIME_OFFSET 99 -#define TK_NK_COLON 100 -#define TK_BWLIMIT 101 -#define TK_START 102 -#define TK_TIMESTAMP 103 -#define TK_END 104 -#define TK_TABLE 105 -#define TK_NK_LP 106 -#define TK_NK_RP 107 -#define TK_STABLE 108 -#define TK_COLUMN 109 -#define TK_MODIFY 110 -#define TK_RENAME 111 -#define TK_TAG 112 -#define TK_SET 113 -#define TK_NK_EQ 114 -#define TK_USING 115 -#define TK_TAGS 116 -#define TK_BOOL 117 -#define TK_TINYINT 118 -#define TK_SMALLINT 119 -#define TK_INT 120 -#define TK_INTEGER 121 -#define TK_BIGINT 122 -#define TK_FLOAT 123 -#define TK_DOUBLE 124 -#define TK_BINARY 125 -#define TK_NCHAR 126 -#define TK_UNSIGNED 127 -#define TK_JSON 128 -#define TK_VARCHAR 129 -#define TK_MEDIUMBLOB 130 -#define TK_BLOB 131 -#define TK_VARBINARY 132 -#define TK_GEOMETRY 133 -#define TK_DECIMAL 134 -#define TK_COMMENT 135 -#define TK_MAX_DELAY 136 -#define TK_WATERMARK 137 -#define TK_ROLLUP 138 -#define TK_TTL 139 -#define TK_SMA 140 -#define TK_DELETE_MARK 141 -#define TK_FIRST 142 -#define TK_LAST 143 -#define TK_SHOW 144 -#define TK_PRIVILEGES 145 -#define TK_DATABASES 146 -#define TK_TABLES 147 -#define TK_STABLES 148 -#define TK_MNODES 149 -#define TK_QNODES 150 -#define TK_FUNCTIONS 151 -#define TK_INDEXES 152 -#define TK_ACCOUNTS 153 -#define TK_APPS 154 -#define TK_CONNECTIONS 155 -#define TK_LICENCES 156 -#define TK_GRANTS 157 -#define TK_QUERIES 158 -#define TK_SCORES 159 -#define TK_TOPICS 160 -#define TK_VARIABLES 161 -#define TK_CLUSTER 162 -#define TK_BNODES 163 -#define TK_SNODES 164 -#define TK_TRANSACTIONS 165 -#define TK_DISTRIBUTED 166 -#define TK_CONSUMERS 167 -#define TK_SUBSCRIPTIONS 168 -#define TK_VNODES 169 -#define TK_ALIVE 170 -#define TK_NORMAL 171 -#define TK_CHILD 172 -#define TK_LIKE 173 -#define TK_TBNAME 174 -#define TK_QTAGS 175 -#define TK_AS 176 -#define TK_SYSTEM 177 -#define TK_INDEX 178 -#define TK_FUNCTION 179 -#define TK_INTERVAL 180 -#define TK_COUNT 181 -#define TK_LAST_ROW 182 -#define TK_META 183 -#define TK_ONLY 184 -#define TK_TOPIC 185 -#define TK_CONSUMER 186 -#define TK_GROUP 187 -#define TK_DESC 188 -#define TK_DESCRIBE 189 -#define TK_RESET 190 -#define TK_QUERY 191 -#define TK_CACHE 192 -#define TK_EXPLAIN 193 -#define TK_ANALYZE 194 -#define TK_VERBOSE 195 -#define TK_NK_BOOL 196 -#define TK_RATIO 197 -#define TK_NK_FLOAT 198 -#define TK_OUTPUTTYPE 199 -#define TK_AGGREGATE 200 -#define TK_BUFSIZE 201 -#define TK_LANGUAGE 202 -#define TK_REPLACE 203 -#define TK_STREAM 204 -#define TK_INTO 205 -#define TK_PAUSE 206 -#define TK_RESUME 207 -#define TK_TRIGGER 208 -#define TK_AT_ONCE 209 -#define TK_WINDOW_CLOSE 210 -#define TK_IGNORE 211 -#define TK_EXPIRED 212 -#define TK_FILL_HISTORY 213 -#define TK_UPDATE 214 -#define TK_SUBTABLE 215 -#define TK_UNTREATED 216 -#define TK_KILL 217 -#define TK_CONNECTION 218 -#define TK_TRANSACTION 219 -#define TK_BALANCE 220 -#define TK_VGROUP 221 -#define TK_LEADER 222 -#define TK_MERGE 223 -#define TK_REDISTRIBUTE 224 -#define TK_SPLIT 225 -#define TK_DELETE 226 -#define TK_INSERT 227 -#define TK_NULL 228 -#define TK_NK_QUESTION 229 -#define TK_NK_ALIAS 230 -#define TK_NK_ARROW 231 -#define TK_ROWTS 232 -#define TK_QSTART 233 -#define TK_QEND 234 -#define TK_QDURATION 235 -#define TK_WSTART 236 -#define TK_WEND 237 -#define TK_WDURATION 238 -#define TK_IROWTS 239 -#define TK_ISFILLED 240 -#define TK_CAST 241 -#define TK_NOW 242 -#define TK_TODAY 243 -#define TK_TIMEZONE 244 -#define TK_CLIENT_VERSION 245 -#define TK_SERVER_VERSION 246 -#define TK_SERVER_STATUS 247 -#define TK_CURRENT_USER 248 -#define TK_CASE 249 -#define TK_WHEN 250 -#define TK_THEN 251 -#define TK_ELSE 252 -#define TK_BETWEEN 253 -#define TK_IS 254 -#define TK_NK_LT 255 -#define TK_NK_GT 256 -#define TK_NK_LE 257 -#define TK_NK_GE 258 -#define TK_NK_NE 259 -#define TK_MATCH 260 -#define TK_NMATCH 261 -#define TK_CONTAINS 262 -#define TK_IN 263 -#define TK_JOIN 264 -#define TK_INNER 265 -#define TK_SELECT 266 -#define TK_NK_HINT 267 -#define TK_DISTINCT 268 -#define TK_WHERE 269 -#define TK_PARTITION 270 -#define TK_BY 271 -#define TK_SESSION 272 -#define TK_STATE_WINDOW 273 -#define TK_EVENT_WINDOW 274 -#define TK_SLIDING 275 -#define TK_FILL 276 -#define TK_VALUE 277 -#define TK_VALUE_F 278 -#define TK_NONE 279 -#define TK_PREV 280 -#define TK_NULL_F 281 -#define TK_LINEAR 282 -#define TK_NEXT 283 -#define TK_HAVING 284 -#define TK_RANGE 285 -#define TK_EVERY 286 -#define TK_ORDER 287 -#define TK_SLIMIT 288 -#define TK_SOFFSET 289 -#define TK_LIMIT 290 -#define TK_OFFSET 291 -#define TK_ASC 292 -#define TK_NULLS 293 -#define TK_ABORT 294 -#define TK_AFTER 295 -#define TK_ATTACH 296 -#define TK_BEFORE 297 -#define TK_BEGIN 298 -#define TK_BITAND 299 -#define TK_BITNOT 300 -#define TK_BITOR 301 -#define TK_BLOCKS 302 -#define TK_CHANGE 303 -#define TK_COMMA 304 -#define TK_CONCAT 305 -#define TK_CONFLICT 306 -#define TK_COPY 307 -#define TK_DEFERRED 308 -#define TK_DELIMITERS 309 -#define TK_DETACH 310 -#define TK_DIVIDE 311 -#define TK_DOT 312 -#define TK_EACH 313 -#define TK_FAIL 314 -#define TK_FILE 315 -#define TK_FOR 316 -#define TK_GLOB 317 -#define TK_ID 318 -#define TK_IMMEDIATE 319 -#define TK_IMPORT 320 -#define TK_INITIALLY 321 -#define TK_INSTEAD 322 -#define TK_ISNULL 323 -#define TK_KEY 324 -#define TK_MODULES 325 -#define TK_NK_BITNOT 326 -#define TK_NK_SEMI 327 -#define TK_NOTNULL 328 -#define TK_OF 329 -#define TK_PLUS 330 -#define TK_PRIVILEGE 331 -#define TK_RAISE 332 -#define TK_RESTRICT 333 -#define TK_ROW 334 -#define TK_SEMI 335 -#define TK_STAR 336 -#define TK_STATEMENT 337 -#define TK_STRICT 338 -#define TK_STRING 339 -#define TK_TIMES 340 -#define TK_VALUES 341 -#define TK_VARIABLE 342 -#define TK_VIEW 343 -#define TK_WAL 344 -#endif -/**************** End token definitions ***************************************/ +/* These constants specify the various numeric values for terminal symbols +** in a format understandable to "makeheaders". This section is blank unless +** "lemon" is run with the "-m" command-line option. +***************** Begin makeheaders token definitions *************************/ +/**************** End makeheaders token definitions ***************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -488,18 +144,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 820 -#define YYNRULE 630 -#define YYNRULE_WITH_ACTION 630 +#define YYNSTATE 822 +#define YYNRULE 631 +#define YYNRULE_WITH_ACTION 631 #define YYNTOKEN 345 -#define YY_MAX_SHIFT 819 -#define YY_MIN_SHIFTREDUCE 1217 -#define YY_MAX_SHIFTREDUCE 1846 -#define YY_ERROR_ACTION 1847 -#define YY_ACCEPT_ACTION 1848 -#define YY_NO_ACTION 1849 -#define YY_MIN_REDUCE 1850 -#define YY_MAX_REDUCE 2479 +#define YY_MAX_SHIFT 821 +#define YY_MIN_SHIFTREDUCE 1220 +#define YY_MAX_SHIFTREDUCE 1850 +#define YY_ERROR_ACTION 1851 +#define YY_ACCEPT_ACTION 1852 +#define YY_NO_ACTION 1853 +#define YY_MIN_REDUCE 1854 +#define YY_MAX_REDUCE 2484 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -568,370 +224,370 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (3640) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2089, 707, 2036, 674, 2025, 2455, 2450, 548, 2450, 2021, - /* 10 */ 549, 1893, 48, 46, 1770, 693, 2455, 668, 412, 2450, - /* 20 */ 409, 133, 1612, 1851, 673, 198, 164, 2454, 590, 2451, - /* 30 */ 675, 2451, 2453, 391, 2038, 1696, 1933, 1610, 2454, 38, - /* 40 */ 313, 2087, 2451, 2452, 123, 2299, 2281, 122, 121, 120, - /* 50 */ 119, 118, 117, 116, 115, 114, 686, 142, 1637, 689, - /* 60 */ 1639, 41, 40, 154, 1691, 47, 45, 44, 43, 42, - /* 70 */ 19, 707, 2036, 1848, 170, 123, 1862, 1618, 122, 121, - /* 80 */ 120, 119, 118, 117, 116, 115, 114, 2299, 41, 40, - /* 90 */ 67, 133, 47, 45, 44, 43, 42, 1873, 595, 2248, - /* 100 */ 1640, 723, 706, 816, 667, 706, 15, 319, 791, 790, - /* 110 */ 789, 788, 421, 1637, 787, 786, 146, 781, 780, 779, - /* 120 */ 778, 777, 776, 775, 158, 771, 770, 769, 420, 419, - /* 130 */ 766, 765, 764, 179, 178, 763, 556, 55, 2280, 549, - /* 140 */ 1893, 2318, 1698, 1699, 110, 2282, 727, 2284, 2285, 722, - /* 150 */ 2248, 717, 424, 686, 142, 634, 181, 423, 2371, 180, - /* 160 */ 1812, 2167, 405, 2367, 293, 2379, 685, 2455, 134, 684, - /* 170 */ 169, 2450, 463, 706, 1671, 1681, 402, 200, 1976, 2164, - /* 180 */ 694, 1697, 1700, 2148, 1639, 2401, 2089, 625, 51, 673, - /* 190 */ 198, 51, 62, 390, 2451, 675, 1613, 669, 1611, 62, - /* 200 */ 649, 2087, 623, 2450, 621, 262, 261, 41, 40, 62, - /* 210 */ 62, 47, 45, 44, 43, 42, 295, 515, 513, 1361, - /* 220 */ 361, 2456, 198, 266, 211, 1774, 2451, 675, 1616, 1617, - /* 230 */ 1668, 1637, 1670, 1673, 1674, 1675, 1676, 1677, 1678, 1679, - /* 240 */ 1680, 719, 715, 1689, 1690, 1692, 1693, 1694, 1695, 2, - /* 250 */ 48, 46, 1850, 686, 142, 360, 194, 1635, 409, 1363, - /* 260 */ 1612, 197, 2379, 2380, 500, 140, 2384, 518, 553, 369, - /* 270 */ 217, 1836, 517, 1696, 550, 1610, 132, 131, 130, 129, - /* 280 */ 128, 127, 126, 125, 124, 609, 608, 607, 483, 563, - /* 290 */ 519, 1257, 599, 139, 603, 485, 1581, 1582, 602, 454, - /* 300 */ 12, 453, 1691, 601, 606, 385, 384, 2013, 19, 600, - /* 310 */ 1641, 88, 596, 1725, 87, 1618, 47, 45, 44, 43, - /* 320 */ 42, 41, 40, 2281, 75, 47, 45, 44, 43, 42, - /* 330 */ 2211, 452, 52, 1259, 1262, 1263, 724, 664, 1902, 231, - /* 340 */ 295, 816, 378, 551, 15, 1900, 418, 417, 297, 2167, - /* 350 */ 41, 40, 297, 471, 47, 45, 44, 43, 42, 297, - /* 360 */ 688, 196, 2379, 2380, 2299, 140, 2384, 2165, 694, 297, - /* 370 */ 297, 1619, 1726, 233, 86, 30, 2248, 551, 723, 1900, - /* 380 */ 1698, 1699, 267, 2154, 2133, 1672, 507, 506, 505, 504, + /* 0 */ 2094, 707, 2041, 674, 2030, 2460, 2455, 548, 2455, 2026, + /* 10 */ 549, 1897, 48, 46, 1774, 693, 2460, 668, 412, 2455, + /* 20 */ 409, 133, 1616, 1855, 673, 198, 164, 2459, 590, 2456, + /* 30 */ 675, 2456, 2458, 391, 2043, 1700, 1937, 1614, 2459, 38, + /* 40 */ 314, 2092, 2456, 2457, 123, 2304, 2286, 122, 121, 120, + /* 50 */ 119, 118, 117, 116, 115, 114, 686, 142, 1641, 689, + /* 60 */ 1643, 41, 40, 155, 1695, 47, 45, 44, 43, 42, + /* 70 */ 19, 707, 2041, 1852, 170, 123, 1866, 1622, 122, 121, + /* 80 */ 120, 119, 118, 117, 116, 115, 114, 2304, 41, 40, + /* 90 */ 67, 133, 47, 45, 44, 43, 42, 1877, 595, 2253, + /* 100 */ 1644, 723, 706, 818, 667, 706, 15, 319, 793, 792, + /* 110 */ 791, 790, 421, 1641, 789, 788, 147, 783, 782, 781, + /* 120 */ 780, 779, 778, 777, 146, 771, 770, 769, 420, 419, + /* 130 */ 766, 765, 764, 179, 178, 763, 556, 55, 2285, 549, + /* 140 */ 1897, 2323, 1702, 1703, 110, 2287, 727, 2289, 2290, 722, + /* 150 */ 2253, 717, 424, 686, 142, 706, 181, 423, 2376, 180, + /* 160 */ 1816, 2172, 405, 2372, 294, 2384, 685, 2460, 134, 684, + /* 170 */ 169, 2455, 463, 563, 1675, 1685, 402, 200, 1980, 2169, + /* 180 */ 694, 1701, 1704, 2153, 1643, 2406, 2094, 625, 51, 673, + /* 190 */ 198, 51, 62, 390, 2456, 675, 1617, 669, 1615, 62, + /* 200 */ 649, 2092, 623, 2455, 621, 263, 262, 41, 40, 62, + /* 210 */ 62, 47, 45, 44, 43, 42, 296, 515, 513, 1364, + /* 220 */ 361, 2461, 198, 267, 212, 1778, 2456, 675, 1620, 1621, + /* 230 */ 1672, 1641, 1674, 1677, 1678, 1679, 1680, 1681, 1682, 1683, + /* 240 */ 1684, 719, 715, 1693, 1694, 1696, 1697, 1698, 1699, 2, + /* 250 */ 48, 46, 1854, 686, 142, 360, 194, 1639, 409, 1366, + /* 260 */ 1616, 197, 2384, 2385, 500, 140, 2389, 518, 553, 369, + /* 270 */ 218, 1840, 517, 1700, 550, 1614, 132, 131, 130, 129, + /* 280 */ 128, 127, 126, 125, 124, 609, 608, 607, 483, 567, + /* 290 */ 519, 1260, 599, 139, 603, 485, 1585, 1586, 602, 454, + /* 300 */ 634, 453, 1695, 601, 606, 385, 384, 2018, 19, 600, + /* 310 */ 1645, 88, 596, 1729, 87, 1622, 47, 45, 44, 43, + /* 320 */ 42, 41, 40, 2286, 75, 47, 45, 44, 43, 42, + /* 330 */ 2216, 452, 52, 1262, 1265, 1266, 724, 664, 1906, 232, + /* 340 */ 296, 818, 378, 551, 15, 1904, 418, 417, 298, 2172, + /* 350 */ 41, 40, 298, 471, 47, 45, 44, 43, 42, 298, + /* 360 */ 688, 196, 2384, 2385, 2304, 140, 2389, 2170, 694, 298, + /* 370 */ 298, 1623, 1730, 234, 86, 30, 2253, 551, 723, 1904, + /* 380 */ 1702, 1703, 268, 2159, 2138, 1676, 507, 506, 505, 504, /* 390 */ 499, 498, 497, 496, 495, 491, 490, 489, 488, 359, - /* 400 */ 480, 479, 478, 1640, 473, 472, 376, 1668, 1504, 1505, - /* 410 */ 1265, 1706, 1671, 1681, 1523, 2280, 1636, 1637, 2318, 1697, - /* 420 */ 1700, 110, 2282, 727, 2284, 2285, 722, 1637, 717, 670, - /* 430 */ 665, 658, 567, 2470, 1613, 2371, 1611, 383, 382, 405, - /* 440 */ 2367, 1669, 760, 156, 155, 757, 756, 755, 153, 1813, - /* 450 */ 2281, 1638, 37, 407, 1720, 1721, 1722, 1723, 1724, 1728, - /* 460 */ 1729, 1730, 1731, 724, 762, 1872, 1616, 1617, 1668, 2241, - /* 470 */ 1670, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 719, - /* 480 */ 715, 1689, 1690, 1692, 1693, 1694, 1695, 2, 12, 48, - /* 490 */ 46, 2299, 297, 92, 1638, 192, 1282, 409, 1281, 1612, - /* 500 */ 1282, 1843, 1281, 2248, 92, 723, 1871, 2076, 381, 380, - /* 510 */ 379, 592, 1696, 138, 1610, 34, 597, 649, 2248, 2031, - /* 520 */ 2450, 41, 40, 2281, 1727, 47, 45, 44, 43, 42, - /* 530 */ 2032, 1283, 1622, 594, 1640, 1283, 689, 593, 2456, 198, - /* 540 */ 1358, 1691, 2280, 2451, 675, 2318, 564, 19, 110, 2282, - /* 550 */ 727, 2284, 2285, 722, 1618, 717, 3, 1801, 145, 2248, - /* 560 */ 151, 2342, 2371, 1618, 2299, 2012, 405, 2367, 54, 509, - /* 570 */ 1417, 1672, 144, 1452, 1453, 2342, 2248, 1870, 723, 1869, - /* 580 */ 816, 1516, 1517, 15, 1408, 752, 751, 750, 1412, 749, - /* 590 */ 1414, 1415, 748, 745, 1868, 1423, 742, 1425, 1426, 739, - /* 600 */ 736, 733, 565, 2160, 35, 1842, 661, 660, 1799, 1800, - /* 610 */ 1802, 1803, 1804, 1641, 1732, 2280, 1536, 1537, 2318, 1698, - /* 620 */ 1699, 110, 2282, 727, 2284, 2285, 722, 1669, 717, 2023, - /* 630 */ 2248, 221, 2248, 181, 762, 2371, 753, 41, 40, 405, - /* 640 */ 2367, 47, 45, 44, 43, 42, 414, 2248, 180, 2082, - /* 650 */ 2084, 1671, 1681, 508, 36, 1535, 1538, 598, 1697, 1700, - /* 660 */ 41, 40, 2402, 2089, 47, 45, 44, 43, 42, 248, - /* 670 */ 377, 773, 2147, 1613, 1936, 1611, 1372, 2089, 702, 707, - /* 680 */ 2036, 1356, 707, 2036, 375, 174, 686, 142, 1867, 545, - /* 690 */ 189, 1371, 2087, 584, 580, 576, 572, 543, 247, 202, - /* 700 */ 539, 535, 56, 1866, 265, 1616, 1617, 1668, 264, 1670, - /* 710 */ 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 719, 715, - /* 720 */ 1689, 1690, 1692, 1693, 1694, 1695, 2, 48, 46, 1701, - /* 730 */ 2281, 707, 2036, 102, 1612, 409, 1786, 1612, 1865, 93, - /* 740 */ 1864, 2248, 245, 724, 1641, 2409, 609, 608, 607, 1610, - /* 750 */ 1696, 460, 1610, 599, 139, 603, 2248, 520, 2029, 602, - /* 760 */ 674, 2281, 2089, 2450, 601, 606, 385, 384, 2014, 399, - /* 770 */ 600, 2299, 95, 596, 724, 364, 2422, 2087, 389, 1691, - /* 780 */ 627, 673, 198, 2248, 1861, 723, 2451, 675, 12, 1618, - /* 790 */ 10, 2248, 1618, 2248, 199, 2379, 2380, 1860, 140, 2384, - /* 800 */ 456, 147, 2299, 41, 40, 455, 2019, 47, 45, 44, - /* 810 */ 43, 42, 244, 237, 2248, 816, 723, 2040, 816, 242, - /* 820 */ 561, 49, 2280, 707, 2036, 2318, 2281, 1859, 110, 2282, - /* 830 */ 727, 2284, 2285, 722, 1376, 717, 403, 2248, 235, 721, - /* 840 */ 2470, 2258, 2371, 461, 167, 275, 405, 2367, 649, 1375, - /* 850 */ 2248, 2450, 2038, 2280, 1640, 2027, 2318, 1698, 1699, 110, - /* 860 */ 2282, 727, 2284, 2285, 722, 2262, 717, 2299, 412, 2456, - /* 870 */ 198, 2470, 154, 2371, 2451, 675, 167, 405, 2367, 2248, - /* 880 */ 2248, 723, 1637, 2386, 2038, 1858, 648, 41, 40, 1671, - /* 890 */ 1681, 47, 45, 44, 43, 42, 1697, 1700, 2011, 760, - /* 900 */ 156, 155, 757, 756, 755, 153, 272, 2264, 1613, 2383, - /* 910 */ 1611, 1613, 718, 1611, 709, 522, 2343, 717, 2280, 707, - /* 920 */ 2036, 2318, 707, 2036, 350, 2282, 727, 2284, 2285, 722, - /* 930 */ 720, 717, 708, 2336, 2454, 469, 2143, 2120, 2248, 477, - /* 940 */ 1616, 1617, 492, 1616, 1617, 1668, 1576, 1670, 1673, 1674, - /* 950 */ 1675, 1676, 1677, 1678, 1679, 1680, 719, 715, 1689, 1690, - /* 960 */ 1692, 1693, 1694, 1695, 2, 48, 46, 1793, 2281, 707, - /* 970 */ 2036, 614, 2089, 409, 1863, 1612, 2242, 415, 632, 404, - /* 980 */ 2089, 724, 1794, 656, 213, 167, 626, 2087, 1696, 493, - /* 990 */ 1610, 1857, 2089, 2038, 108, 2088, 707, 2036, 1637, 413, - /* 1000 */ 475, 2143, 263, 304, 305, 502, 2143, 2087, 303, 2299, - /* 1010 */ 193, 143, 60, 444, 2083, 2084, 566, 1691, 617, 2028, - /* 1020 */ 646, 2248, 1792, 723, 649, 611, 649, 2450, 594, 2450, - /* 1030 */ 1618, 260, 593, 760, 156, 155, 757, 756, 755, 153, - /* 1040 */ 446, 442, 9, 690, 2248, 2456, 198, 2456, 198, 215, - /* 1050 */ 2451, 675, 2451, 675, 220, 166, 816, 707, 2036, 49, - /* 1060 */ 2280, 2281, 1856, 2318, 1641, 2258, 110, 2282, 727, 2284, - /* 1070 */ 2285, 722, 71, 717, 724, 70, 2443, 2033, 2470, 2266, - /* 1080 */ 2371, 707, 2036, 1855, 405, 2367, 707, 2036, 711, 2262, - /* 1090 */ 2343, 649, 1669, 1854, 2450, 1698, 1699, 167, 487, 605, - /* 1100 */ 604, 268, 2299, 707, 2036, 2039, 276, 486, 754, 707, - /* 1110 */ 2036, 2080, 2456, 198, 2248, 2248, 723, 2451, 675, 1853, - /* 1120 */ 707, 2036, 1767, 692, 2229, 707, 2036, 1671, 1681, 308, - /* 1130 */ 758, 2264, 406, 2080, 1697, 1700, 2248, 707, 2036, 2386, - /* 1140 */ 704, 717, 14, 13, 2258, 705, 2248, 707, 2036, 1613, - /* 1150 */ 678, 1611, 1672, 2280, 785, 783, 2318, 314, 2267, 110, - /* 1160 */ 2282, 727, 2284, 2285, 722, 2382, 717, 416, 2262, 1285, - /* 1170 */ 1286, 2470, 2248, 2371, 44, 43, 42, 405, 2367, 586, - /* 1180 */ 585, 1616, 1617, 1668, 1621, 1670, 1673, 1674, 1675, 1676, - /* 1190 */ 1677, 1678, 1679, 1680, 719, 715, 1689, 1690, 1692, 1693, - /* 1200 */ 1694, 1695, 2, 48, 46, 2232, 2281, 2386, 1669, 759, - /* 1210 */ 2264, 409, 2080, 1612, 588, 587, 1878, 811, 677, 724, - /* 1220 */ 717, 2390, 328, 277, 774, 2066, 1696, 1998, 1610, 1262, - /* 1230 */ 1263, 2130, 135, 2381, 2391, 1759, 253, 255, 257, 251, - /* 1240 */ 254, 256, 259, 154, 85, 258, 681, 2299, 1739, 1920, - /* 1250 */ 1911, 629, 50, 628, 50, 1691, 431, 1909, 182, 2248, - /* 1260 */ 714, 723, 1845, 1846, 2269, 1759, 1977, 96, 1618, 154, - /* 1270 */ 1316, 610, 612, 467, 50, 302, 72, 152, 1903, 615, - /* 1280 */ 2415, 154, 107, 14, 13, 65, 50, 50, 731, 152, - /* 1290 */ 767, 104, 290, 154, 816, 136, 152, 15, 2280, 2281, - /* 1300 */ 768, 2318, 1620, 137, 110, 2282, 727, 2284, 2285, 722, - /* 1310 */ 1317, 717, 724, 284, 1335, 662, 2470, 1579, 2371, 418, - /* 1320 */ 417, 2271, 405, 2367, 1333, 2300, 1798, 1974, 1797, 1626, - /* 1330 */ 809, 1973, 282, 1698, 1699, 2152, 2405, 659, 392, 422, - /* 1340 */ 2299, 395, 1696, 691, 1619, 1624, 204, 666, 1533, 306, - /* 1350 */ 699, 310, 2248, 696, 723, 1402, 2153, 1894, 1899, 1733, - /* 1360 */ 1682, 327, 1430, 1434, 2077, 1671, 1681, 1441, 687, 1439, - /* 1370 */ 157, 1691, 1697, 1700, 2406, 2416, 292, 289, 296, 5, - /* 1380 */ 425, 430, 373, 438, 1618, 439, 1766, 1613, 1644, 1611, - /* 1390 */ 448, 2280, 447, 206, 2318, 208, 205, 110, 2282, 727, - /* 1400 */ 2284, 2285, 722, 450, 717, 1557, 679, 322, 464, 2346, - /* 1410 */ 713, 2371, 1635, 1636, 468, 405, 2367, 219, 1717, 1616, - /* 1420 */ 1617, 1668, 470, 1670, 1673, 1674, 1675, 1676, 1677, 1678, - /* 1430 */ 1679, 1680, 719, 715, 1689, 1690, 1692, 1693, 1694, 1695, - /* 1440 */ 2, 474, 168, 476, 511, 481, 494, 335, 501, 2145, - /* 1450 */ 503, 510, 512, 523, 524, 521, 223, 224, 526, 527, - /* 1460 */ 226, 529, 531, 1623, 332, 74, 1642, 546, 73, 4, - /* 1470 */ 557, 1638, 547, 555, 554, 234, 558, 236, 357, 1643, - /* 1480 */ 1645, 559, 560, 1646, 2281, 562, 2161, 589, 591, 229, - /* 1490 */ 530, 528, 525, 2026, 239, 241, 250, 724, 568, 90, - /* 1500 */ 91, 246, 618, 1627, 682, 1622, 112, 619, 354, 631, - /* 1510 */ 2220, 2022, 2217, 2216, 633, 94, 269, 323, 148, 637, - /* 1520 */ 636, 273, 1564, 638, 252, 2299, 160, 271, 161, 2024, - /* 1530 */ 62, 2020, 162, 163, 642, 1630, 1632, 2248, 644, 723, - /* 1540 */ 663, 2421, 697, 2420, 283, 8, 672, 2393, 641, 715, - /* 1550 */ 1689, 1690, 1692, 1693, 1694, 1695, 654, 175, 653, 285, - /* 1560 */ 652, 651, 396, 683, 2449, 2473, 286, 680, 63, 279, - /* 1570 */ 1759, 281, 287, 643, 291, 141, 2280, 1639, 288, 2318, - /* 1580 */ 1764, 1762, 110, 2282, 727, 2284, 2285, 722, 185, 717, - /* 1590 */ 298, 149, 324, 695, 2344, 2175, 2371, 2174, 2173, 325, - /* 1600 */ 405, 2367, 401, 2387, 700, 150, 101, 326, 701, 61, - /* 1610 */ 103, 729, 83, 82, 459, 1241, 1999, 210, 2081, 2037, - /* 1620 */ 810, 353, 813, 53, 365, 2240, 2352, 815, 329, 366, - /* 1630 */ 451, 449, 333, 317, 159, 2239, 2238, 80, 201, 1, - /* 1640 */ 2233, 358, 338, 2281, 440, 427, 1603, 437, 433, 429, - /* 1650 */ 426, 452, 331, 428, 1604, 203, 724, 432, 2231, 352, - /* 1660 */ 434, 435, 436, 1602, 342, 2230, 374, 2228, 441, 2281, - /* 1670 */ 2227, 443, 2226, 1592, 445, 2207, 207, 2206, 209, 1560, - /* 1680 */ 81, 2188, 724, 1559, 2299, 2187, 2186, 457, 458, 2185, - /* 1690 */ 297, 2184, 2135, 2129, 462, 1503, 2248, 465, 723, 466, - /* 1700 */ 2126, 212, 2125, 2124, 84, 2123, 2128, 2127, 2122, 2121, - /* 1710 */ 2299, 214, 2119, 2118, 2117, 216, 482, 2116, 2132, 484, - /* 1720 */ 2115, 2114, 2248, 2113, 723, 2112, 2111, 2110, 2109, 2108, - /* 1730 */ 2107, 2106, 2105, 2104, 2103, 2280, 2281, 218, 2318, 2102, - /* 1740 */ 2101, 110, 2282, 727, 2284, 2285, 722, 2100, 717, 724, - /* 1750 */ 2099, 2098, 2097, 710, 2131, 2371, 2096, 2095, 1509, 405, - /* 1760 */ 2367, 2280, 2094, 222, 2318, 2281, 2093, 111, 2282, 727, - /* 1770 */ 2284, 2285, 722, 514, 717, 2092, 2091, 2299, 724, 516, - /* 1780 */ 89, 2371, 2090, 1373, 1939, 2370, 2367, 1377, 362, 2248, - /* 1790 */ 1369, 723, 363, 1938, 1937, 1935, 1932, 532, 1931, 533, - /* 1800 */ 534, 536, 1924, 1913, 1889, 225, 2299, 227, 228, 538, - /* 1810 */ 537, 540, 542, 230, 541, 544, 190, 1888, 2248, 77, - /* 1820 */ 723, 2268, 191, 1264, 232, 2205, 2195, 78, 2280, 552, - /* 1830 */ 2183, 2318, 238, 2281, 111, 2282, 727, 2284, 2285, 722, - /* 1840 */ 240, 717, 2182, 2159, 2015, 1934, 724, 1930, 2371, 243, - /* 1850 */ 1309, 569, 712, 2367, 571, 635, 570, 725, 1928, 573, - /* 1860 */ 2318, 574, 575, 111, 2282, 727, 2284, 2285, 722, 1926, - /* 1870 */ 717, 579, 577, 819, 2299, 578, 1923, 2371, 581, 582, - /* 1880 */ 583, 368, 2367, 1908, 1906, 1907, 2248, 1905, 723, 321, - /* 1890 */ 1885, 2017, 1446, 1445, 2016, 782, 1360, 1359, 2281, 249, - /* 1900 */ 64, 1357, 1355, 1354, 1353, 188, 784, 1352, 1346, 1351, - /* 1910 */ 1921, 724, 1348, 807, 803, 799, 795, 2281, 318, 1347, - /* 1920 */ 386, 1912, 387, 1910, 388, 2280, 1345, 613, 2318, 616, - /* 1930 */ 724, 171, 2282, 727, 2284, 2285, 722, 1884, 717, 2299, - /* 1940 */ 620, 1881, 622, 1880, 624, 113, 1586, 1590, 1588, 1585, - /* 1950 */ 2204, 2248, 1883, 723, 1882, 29, 68, 1566, 2299, 109, - /* 1960 */ 1568, 2194, 311, 2181, 57, 640, 639, 2180, 165, 2455, - /* 1970 */ 2248, 66, 723, 650, 2412, 1545, 274, 6, 20, 7, - /* 1980 */ 21, 17, 1544, 31, 645, 1815, 278, 23, 280, 22, - /* 1990 */ 2280, 647, 2281, 2318, 703, 1570, 172, 2282, 727, 2284, - /* 2000 */ 2285, 722, 1796, 717, 1785, 724, 184, 173, 655, 2280, - /* 2010 */ 657, 195, 2318, 183, 2269, 111, 2282, 727, 2284, 2285, - /* 2020 */ 722, 32, 717, 79, 33, 24, 1835, 1830, 294, 2371, - /* 2030 */ 1829, 1836, 300, 2299, 2368, 397, 1834, 1833, 398, 299, - /* 2040 */ 1756, 1755, 18, 59, 176, 2248, 98, 723, 2179, 2158, - /* 2050 */ 676, 2471, 97, 2157, 25, 58, 301, 186, 270, 2281, - /* 2060 */ 1791, 307, 99, 69, 100, 312, 26, 11, 698, 13, - /* 2070 */ 2321, 309, 724, 1708, 104, 1707, 1628, 1686, 716, 1718, - /* 2080 */ 177, 1684, 39, 16, 2280, 2281, 27, 2318, 1683, 187, - /* 2090 */ 171, 2282, 727, 2284, 2285, 722, 1653, 717, 724, 1661, - /* 2100 */ 2299, 728, 28, 730, 1431, 393, 411, 734, 732, 735, - /* 2110 */ 726, 737, 2248, 1428, 723, 1427, 1424, 738, 740, 741, - /* 2120 */ 743, 1418, 1416, 744, 746, 747, 2299, 105, 315, 106, - /* 2130 */ 1440, 394, 1422, 2413, 1421, 76, 1436, 1342, 2248, 1420, - /* 2140 */ 723, 1339, 1307, 1338, 1337, 1419, 761, 1336, 1334, 1332, - /* 2150 */ 1331, 2280, 1330, 316, 2318, 2281, 1367, 351, 2282, 727, - /* 2160 */ 2284, 2285, 722, 772, 717, 1328, 1327, 1326, 724, 1325, - /* 2170 */ 1324, 1323, 1322, 1364, 1362, 1319, 1313, 2280, 1318, 1315, - /* 2180 */ 2318, 1314, 2281, 351, 2282, 727, 2284, 2285, 722, 1312, - /* 2190 */ 717, 1929, 792, 794, 793, 724, 2299, 1927, 796, 797, - /* 2200 */ 798, 1925, 800, 1922, 801, 802, 804, 1904, 2248, 806, - /* 2210 */ 723, 805, 808, 1254, 1879, 1242, 812, 320, 1614, 814, - /* 2220 */ 818, 330, 1849, 2299, 1849, 817, 1849, 1849, 1849, 1849, - /* 2230 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 2240 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, - /* 2250 */ 2318, 1849, 1849, 344, 2282, 727, 2284, 2285, 722, 1849, - /* 2260 */ 717, 1849, 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, - /* 2270 */ 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, 724, - /* 2280 */ 172, 2282, 727, 2284, 2285, 722, 1849, 717, 2281, 1849, - /* 2290 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 671, - /* 2300 */ 1849, 721, 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, - /* 2310 */ 1849, 1849, 400, 1849, 1849, 1849, 1849, 1849, 1849, 2248, - /* 2320 */ 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2299, - /* 2330 */ 1849, 1849, 1849, 1849, 1849, 2472, 1849, 1849, 1849, 1849, - /* 2340 */ 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2350 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, - /* 2360 */ 1849, 2318, 1849, 1849, 351, 2282, 727, 2284, 2285, 722, - /* 2370 */ 1849, 717, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2380 */ 2280, 1849, 1849, 2318, 1849, 1849, 350, 2282, 727, 2284, - /* 2390 */ 2285, 722, 1849, 717, 2281, 2337, 1849, 1849, 1849, 1849, - /* 2400 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 724, 1849, 1849, - /* 2410 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2420 */ 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2430 */ 1849, 1849, 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, - /* 2440 */ 408, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2450 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2460 */ 1849, 1849, 2299, 1849, 1849, 1849, 1849, 410, 1849, 1849, - /* 2470 */ 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, - /* 2480 */ 1849, 1849, 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, - /* 2490 */ 1849, 1849, 351, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2500 */ 724, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, - /* 2510 */ 1849, 1849, 1849, 2280, 1849, 1849, 2318, 724, 1849, 351, - /* 2520 */ 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, - /* 2530 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2540 */ 2248, 1849, 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, - /* 2550 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2560 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2570 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 630, - /* 2580 */ 1849, 1849, 2318, 1849, 2281, 346, 2282, 727, 2284, 2285, - /* 2590 */ 722, 1849, 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, - /* 2600 */ 1849, 1849, 336, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2610 */ 1849, 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, - /* 2620 */ 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, - /* 2630 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 2640 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2650 */ 2281, 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, - /* 2660 */ 1849, 1849, 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, - /* 2670 */ 723, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, - /* 2680 */ 1849, 1849, 334, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 2690 */ 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2700 */ 1849, 1849, 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, - /* 2710 */ 2318, 1849, 1849, 337, 2282, 727, 2284, 2285, 722, 1849, - /* 2720 */ 717, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2730 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2740 */ 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, 343, 2282, - /* 2750 */ 727, 2284, 2285, 722, 1849, 717, 724, 1849, 1849, 1849, - /* 2760 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2770 */ 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2780 */ 1849, 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, - /* 2790 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2800 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2810 */ 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2820 */ 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, - /* 2830 */ 1849, 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, - /* 2840 */ 1849, 347, 2282, 727, 2284, 2285, 722, 1849, 717, 724, - /* 2850 */ 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2860 */ 1849, 1849, 2280, 1849, 1849, 2318, 724, 1849, 339, 2282, - /* 2870 */ 727, 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, - /* 2880 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, - /* 2890 */ 1849, 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, - /* 2900 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2910 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 2920 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, - /* 2930 */ 1849, 2318, 1849, 2281, 348, 2282, 727, 2284, 2285, 722, - /* 2940 */ 1849, 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, 1849, - /* 2950 */ 1849, 340, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 2960 */ 1849, 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, - /* 2970 */ 1849, 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, 1849, - /* 2980 */ 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 2990 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, - /* 3000 */ 1849, 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, 1849, - /* 3010 */ 1849, 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 3020 */ 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, - /* 3030 */ 1849, 349, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 3040 */ 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3050 */ 1849, 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, 2318, - /* 3060 */ 1849, 1849, 341, 2282, 727, 2284, 2285, 722, 1849, 717, - /* 3070 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3080 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3090 */ 1849, 2280, 2281, 1849, 2318, 1849, 1849, 355, 2282, 727, - /* 3100 */ 2284, 2285, 722, 1849, 717, 724, 1849, 1849, 1849, 1849, - /* 3110 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, - /* 3120 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3130 */ 1849, 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3140 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3150 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3160 */ 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3170 */ 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, - /* 3180 */ 1849, 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, - /* 3190 */ 356, 2282, 727, 2284, 2285, 722, 1849, 717, 724, 1849, - /* 3200 */ 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3210 */ 1849, 2280, 1849, 1849, 2318, 724, 1849, 2293, 2282, 727, - /* 3220 */ 2284, 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, 1849, - /* 3230 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, - /* 3240 */ 723, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3250 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3260 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3270 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, - /* 3280 */ 2318, 1849, 2281, 2292, 2282, 727, 2284, 2285, 722, 1849, - /* 3290 */ 717, 1849, 1849, 1849, 2280, 724, 1849, 2318, 1849, 1849, - /* 3300 */ 2291, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 1849, - /* 3310 */ 1849, 1849, 1849, 2281, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3320 */ 1849, 1849, 1849, 2299, 1849, 1849, 724, 1849, 1849, 1849, - /* 3330 */ 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, - /* 3340 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, 1849, - /* 3350 */ 1849, 1849, 1849, 1849, 2299, 1849, 1849, 1849, 1849, 1849, - /* 3360 */ 1849, 724, 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, - /* 3370 */ 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, 1849, 1849, - /* 3380 */ 370, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, 2299, - /* 3390 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3400 */ 1849, 2248, 1849, 723, 1849, 2280, 1849, 1849, 2318, 1849, - /* 3410 */ 1849, 371, 2282, 727, 2284, 2285, 722, 1849, 717, 1849, - /* 3420 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3430 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3440 */ 2280, 2281, 1849, 2318, 1849, 1849, 367, 2282, 727, 2284, - /* 3450 */ 2285, 722, 1849, 717, 724, 1849, 1849, 1849, 1849, 1849, - /* 3460 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2281, 1849, - /* 3470 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3480 */ 1849, 724, 2299, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3490 */ 1849, 1849, 1849, 1849, 2248, 1849, 723, 1849, 1849, 1849, - /* 3500 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2299, - /* 3510 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3520 */ 1849, 2248, 1849, 723, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3530 */ 1849, 1849, 1849, 2280, 2281, 1849, 2318, 1849, 1849, 372, - /* 3540 */ 2282, 727, 2284, 2285, 722, 1849, 717, 724, 1849, 1849, - /* 3550 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3560 */ 725, 1849, 1849, 2318, 1849, 1849, 346, 2282, 727, 2284, - /* 3570 */ 2285, 722, 1849, 717, 1849, 2299, 1849, 1849, 1849, 1849, - /* 3580 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 2248, 1849, 723, - /* 3590 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3600 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3610 */ 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, 1849, - /* 3620 */ 1849, 1849, 1849, 1849, 1849, 1849, 2280, 1849, 1849, 2318, - /* 3630 */ 1849, 1849, 345, 2282, 727, 2284, 2285, 722, 1849, 717, + /* 400 */ 480, 479, 478, 1644, 473, 472, 376, 1672, 1508, 1509, + /* 410 */ 1268, 1710, 1675, 1685, 1527, 2285, 1640, 1641, 2323, 1701, + /* 420 */ 1704, 110, 2287, 727, 2289, 2290, 722, 1641, 717, 670, + /* 430 */ 665, 658, 762, 2475, 1617, 2376, 1615, 383, 382, 405, + /* 440 */ 2372, 1673, 760, 157, 156, 757, 756, 755, 154, 1817, + /* 450 */ 2286, 1642, 37, 407, 1724, 1725, 1726, 1727, 1728, 1732, + /* 460 */ 1733, 1734, 1735, 724, 12, 1876, 1620, 1621, 1672, 2246, + /* 470 */ 1674, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 719, + /* 480 */ 715, 1693, 1694, 1696, 1697, 1698, 1699, 2, 12, 48, + /* 490 */ 46, 2304, 298, 92, 1642, 192, 1285, 409, 1284, 1616, + /* 500 */ 1285, 1847, 1284, 2253, 773, 723, 1875, 2081, 381, 380, + /* 510 */ 379, 592, 1700, 138, 1614, 34, 597, 649, 2253, 2036, + /* 520 */ 2455, 41, 40, 2286, 1731, 47, 45, 44, 43, 42, + /* 530 */ 92, 1286, 1626, 594, 1644, 1286, 689, 593, 2461, 198, + /* 540 */ 1361, 1695, 2285, 2456, 675, 2323, 564, 19, 110, 2287, + /* 550 */ 727, 2289, 2290, 722, 1622, 717, 2037, 1805, 145, 2253, + /* 560 */ 152, 2347, 2376, 1622, 2304, 2017, 405, 2372, 775, 509, + /* 570 */ 1421, 1676, 776, 1456, 1457, 2002, 2253, 1874, 723, 1873, + /* 580 */ 818, 1520, 1521, 15, 1412, 752, 751, 750, 1416, 749, + /* 590 */ 1418, 1419, 748, 745, 1872, 1427, 742, 1429, 1430, 739, + /* 600 */ 736, 733, 565, 2165, 35, 1846, 661, 660, 1803, 1804, + /* 610 */ 1806, 1807, 1808, 1645, 1736, 2285, 1540, 1541, 2323, 1702, + /* 620 */ 1703, 110, 2287, 727, 2289, 2290, 722, 1673, 717, 2028, + /* 630 */ 2253, 222, 2253, 181, 762, 2376, 753, 41, 40, 405, + /* 640 */ 2372, 47, 45, 44, 43, 42, 414, 2253, 180, 2087, + /* 650 */ 2089, 1675, 1685, 508, 36, 1539, 1542, 598, 1701, 1704, + /* 660 */ 41, 40, 2407, 2094, 47, 45, 44, 43, 42, 249, + /* 670 */ 377, 2024, 2152, 1617, 1940, 1615, 1376, 2094, 702, 707, + /* 680 */ 2041, 1359, 707, 2041, 375, 174, 686, 142, 1871, 545, + /* 690 */ 189, 1375, 2092, 584, 580, 576, 572, 543, 248, 203, + /* 700 */ 539, 535, 56, 1870, 266, 1620, 1621, 1672, 265, 1674, + /* 710 */ 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 719, 715, + /* 720 */ 1693, 1694, 1696, 1697, 1698, 1699, 2, 48, 46, 1705, + /* 730 */ 2286, 707, 2041, 102, 1616, 409, 1790, 1616, 1869, 93, + /* 740 */ 1868, 2253, 246, 724, 1645, 2414, 609, 608, 607, 1614, + /* 750 */ 1700, 460, 1614, 599, 139, 603, 2253, 520, 2034, 602, + /* 760 */ 674, 2286, 2094, 2455, 601, 606, 385, 384, 2019, 399, + /* 770 */ 600, 2304, 95, 596, 724, 364, 2427, 2092, 389, 1695, + /* 780 */ 627, 673, 198, 2253, 1865, 723, 2456, 675, 12, 1622, + /* 790 */ 10, 2253, 1622, 2253, 199, 2384, 2385, 1864, 140, 2389, + /* 800 */ 456, 148, 2304, 41, 40, 455, 2045, 47, 45, 44, + /* 810 */ 43, 42, 245, 238, 2253, 818, 723, 273, 818, 243, + /* 820 */ 561, 49, 2285, 707, 2041, 2323, 2286, 1863, 110, 2287, + /* 830 */ 727, 2289, 2290, 722, 1380, 717, 403, 2253, 236, 721, + /* 840 */ 2475, 2263, 2376, 461, 167, 276, 405, 2372, 649, 1379, + /* 850 */ 2253, 2455, 2043, 2285, 1644, 2032, 2323, 1702, 1703, 110, + /* 860 */ 2287, 727, 2289, 2290, 722, 2267, 717, 2304, 412, 2461, + /* 870 */ 198, 2475, 155, 2376, 2456, 675, 167, 405, 2372, 2253, + /* 880 */ 2253, 723, 1641, 2391, 2043, 1862, 648, 41, 40, 1675, + /* 890 */ 1685, 47, 45, 44, 43, 42, 1701, 1704, 2016, 760, + /* 900 */ 157, 156, 757, 756, 755, 154, 718, 2269, 1617, 2388, + /* 910 */ 1615, 1617, 1981, 1615, 709, 522, 2348, 717, 2285, 707, + /* 920 */ 2041, 2323, 707, 2041, 350, 2287, 727, 2289, 2290, 722, + /* 930 */ 720, 717, 708, 2341, 2459, 469, 2148, 2125, 2253, 477, + /* 940 */ 1620, 1621, 492, 1620, 1621, 1672, 1580, 1674, 1677, 1678, + /* 950 */ 1679, 1680, 1681, 1682, 1683, 1684, 719, 715, 1693, 1694, + /* 960 */ 1696, 1697, 1698, 1699, 2, 48, 46, 1797, 2286, 707, + /* 970 */ 2041, 614, 2094, 409, 1867, 1616, 2247, 415, 632, 404, + /* 980 */ 2094, 724, 1798, 656, 214, 167, 626, 2092, 1700, 493, + /* 990 */ 1614, 1861, 2094, 2043, 108, 2093, 707, 2041, 1641, 413, + /* 1000 */ 475, 2148, 264, 305, 306, 502, 2148, 2092, 304, 2304, + /* 1010 */ 193, 143, 60, 444, 2088, 2089, 566, 1695, 617, 2033, + /* 1020 */ 646, 2253, 1796, 723, 649, 611, 649, 2455, 594, 2455, + /* 1030 */ 1622, 261, 593, 760, 157, 156, 757, 756, 755, 154, + /* 1040 */ 446, 442, 9, 690, 2253, 2461, 198, 2461, 198, 216, + /* 1050 */ 2456, 675, 2456, 675, 221, 166, 818, 707, 2041, 49, + /* 1060 */ 2285, 2286, 1860, 2323, 1645, 2263, 110, 2287, 727, 2289, + /* 1070 */ 2290, 722, 71, 717, 724, 70, 2448, 2038, 2475, 2271, + /* 1080 */ 2376, 707, 2041, 1859, 405, 2372, 707, 2041, 711, 2267, + /* 1090 */ 2348, 649, 1673, 1858, 2455, 1702, 1703, 1771, 487, 605, + /* 1100 */ 604, 269, 2304, 707, 2041, 144, 277, 486, 2347, 707, + /* 1110 */ 2041, 678, 2461, 198, 2253, 2253, 723, 2456, 675, 1857, + /* 1120 */ 707, 2041, 167, 692, 2234, 707, 2041, 1675, 1685, 309, + /* 1130 */ 2044, 2269, 406, 2237, 1701, 1704, 2253, 707, 2041, 2391, + /* 1140 */ 704, 717, 14, 13, 2263, 705, 2253, 707, 2041, 1617, + /* 1150 */ 681, 1615, 1676, 2285, 787, 785, 2323, 315, 2272, 110, + /* 1160 */ 2287, 727, 2289, 2290, 722, 2387, 717, 416, 2267, 1288, + /* 1170 */ 1289, 2475, 2253, 2376, 44, 43, 42, 405, 2372, 586, + /* 1180 */ 585, 1620, 1621, 1672, 431, 1674, 1677, 1678, 1679, 1680, + /* 1190 */ 1681, 1682, 1683, 1684, 719, 715, 1693, 1694, 1696, 1697, + /* 1200 */ 1698, 1699, 2, 48, 46, 155, 2286, 2391, 1673, 754, + /* 1210 */ 2269, 409, 2085, 1616, 588, 587, 1882, 813, 677, 724, + /* 1220 */ 717, 2395, 758, 1924, 759, 2085, 1700, 2085, 1614, 328, + /* 1230 */ 1265, 1266, 2071, 2386, 2396, 1763, 2135, 3, 135, 254, + /* 1240 */ 256, 258, 252, 255, 257, 610, 278, 2304, 1743, 54, + /* 1250 */ 85, 260, 1915, 1913, 259, 1695, 629, 50, 628, 2253, + /* 1260 */ 714, 723, 50, 182, 155, 1763, 2420, 50, 1622, 1849, + /* 1270 */ 1850, 303, 1907, 72, 612, 615, 153, 155, 467, 1583, + /* 1280 */ 14, 13, 65, 50, 50, 1625, 2274, 291, 731, 153, + /* 1290 */ 96, 107, 662, 767, 818, 155, 136, 15, 2285, 2286, + /* 1300 */ 104, 2323, 153, 768, 110, 2287, 727, 2289, 2290, 722, + /* 1310 */ 137, 717, 724, 1624, 285, 1319, 2475, 1338, 2376, 418, + /* 1320 */ 417, 2305, 405, 2372, 811, 1978, 1977, 1336, 2157, 1630, + /* 1330 */ 2410, 1802, 659, 1702, 1703, 395, 1801, 283, 691, 422, + /* 1340 */ 2304, 1537, 1700, 2276, 1623, 307, 205, 699, 392, 666, + /* 1350 */ 311, 1406, 2253, 696, 723, 1320, 1737, 1686, 327, 1903, + /* 1360 */ 1898, 1770, 1434, 1438, 2158, 1675, 1685, 679, 2082, 1445, + /* 1370 */ 1443, 1695, 1701, 1704, 2411, 2421, 158, 687, 293, 290, + /* 1380 */ 5, 297, 2003, 425, 1622, 430, 373, 1617, 438, 1615, + /* 1390 */ 1648, 2285, 447, 439, 2323, 206, 448, 110, 2287, 727, + /* 1400 */ 2289, 2290, 722, 207, 717, 450, 209, 1561, 682, 2351, + /* 1410 */ 713, 2376, 322, 1639, 464, 405, 2372, 1640, 1721, 1620, + /* 1420 */ 1621, 1672, 468, 1674, 1677, 1678, 1679, 1680, 1681, 1682, + /* 1430 */ 1683, 1684, 719, 715, 1693, 1694, 1696, 1697, 1698, 1699, + /* 1440 */ 2, 220, 168, 470, 474, 476, 1628, 335, 511, 481, + /* 1450 */ 494, 503, 501, 510, 2150, 512, 523, 524, 521, 224, + /* 1460 */ 225, 526, 227, 527, 332, 74, 529, 531, 73, 1646, + /* 1470 */ 4, 546, 547, 554, 1627, 1642, 555, 557, 357, 235, + /* 1480 */ 558, 237, 1647, 559, 2286, 1649, 560, 1650, 562, 230, + /* 1490 */ 530, 528, 525, 2166, 240, 633, 589, 724, 242, 568, + /* 1500 */ 354, 618, 2225, 1631, 90, 1626, 91, 247, 112, 619, + /* 1510 */ 2222, 591, 2031, 631, 94, 2221, 149, 251, 637, 323, + /* 1520 */ 636, 270, 638, 2027, 274, 2304, 1568, 272, 642, 253, + /* 1530 */ 62, 644, 2426, 160, 161, 1634, 1636, 2253, 2029, 723, + /* 1540 */ 2025, 162, 163, 663, 8, 697, 2425, 175, 2398, 715, + /* 1550 */ 1693, 1694, 1696, 1697, 1698, 1699, 672, 653, 641, 284, + /* 1560 */ 654, 286, 652, 287, 651, 2454, 288, 292, 63, 2478, + /* 1570 */ 1763, 643, 683, 680, 396, 141, 2285, 1643, 280, 2323, + /* 1580 */ 282, 1, 110, 2287, 727, 2289, 2290, 722, 289, 717, + /* 1590 */ 1768, 1766, 201, 299, 2349, 185, 2376, 324, 695, 150, + /* 1600 */ 405, 2372, 2180, 2179, 2178, 325, 700, 2392, 401, 701, + /* 1610 */ 326, 61, 83, 82, 459, 103, 2086, 211, 1244, 2042, + /* 1620 */ 729, 151, 812, 815, 101, 329, 317, 2357, 53, 365, + /* 1630 */ 451, 449, 366, 353, 331, 333, 2245, 159, 2244, 817, + /* 1640 */ 2243, 358, 80, 2286, 440, 2238, 427, 437, 433, 429, + /* 1650 */ 426, 452, 428, 1607, 338, 1608, 724, 204, 432, 2236, + /* 1660 */ 434, 435, 436, 1606, 2235, 374, 2233, 352, 441, 2286, + /* 1670 */ 342, 2232, 443, 2231, 445, 1596, 2212, 208, 2211, 210, + /* 1680 */ 1564, 81, 724, 1563, 2304, 2193, 2192, 2191, 457, 458, + /* 1690 */ 298, 2190, 2189, 2140, 2134, 462, 2253, 1507, 723, 465, + /* 1700 */ 466, 2131, 213, 2130, 2129, 84, 2128, 2133, 2132, 2127, + /* 1710 */ 2304, 482, 215, 2126, 2124, 2123, 2122, 217, 2121, 484, + /* 1720 */ 2137, 2120, 2253, 2119, 723, 2118, 2117, 2116, 2115, 2114, + /* 1730 */ 2113, 2112, 2111, 2110, 2109, 2285, 2286, 219, 2323, 2108, + /* 1740 */ 2107, 110, 2287, 727, 2289, 2290, 722, 2106, 717, 724, + /* 1750 */ 2105, 2104, 2103, 710, 2102, 2376, 2136, 89, 2101, 405, + /* 1760 */ 2372, 2285, 2100, 1513, 2323, 2286, 2099, 111, 2287, 727, + /* 1770 */ 2289, 2290, 722, 2098, 717, 223, 514, 2304, 724, 2097, + /* 1780 */ 516, 2376, 2096, 2095, 1943, 2375, 2372, 1377, 362, 2253, + /* 1790 */ 1381, 723, 363, 1942, 1373, 1941, 1939, 1936, 532, 226, + /* 1800 */ 228, 534, 1935, 1928, 533, 538, 2304, 229, 536, 540, + /* 1810 */ 1917, 537, 542, 544, 1893, 541, 2273, 77, 2253, 231, + /* 1820 */ 723, 190, 1267, 1892, 233, 2210, 191, 552, 2285, 78, + /* 1830 */ 2200, 2323, 2188, 2286, 111, 2287, 727, 2289, 2290, 722, + /* 1840 */ 239, 717, 241, 2187, 2164, 2020, 724, 1938, 2376, 244, + /* 1850 */ 1934, 1312, 712, 2372, 569, 635, 570, 725, 571, 1932, + /* 1860 */ 2323, 573, 574, 111, 2287, 727, 2289, 2290, 722, 575, + /* 1870 */ 717, 1930, 577, 821, 2304, 579, 1927, 2376, 581, 578, + /* 1880 */ 582, 368, 2372, 1912, 583, 1910, 2253, 1911, 723, 321, + /* 1890 */ 1909, 1889, 2022, 1450, 1449, 2021, 1349, 1363, 2286, 64, + /* 1900 */ 1362, 250, 1360, 1358, 1357, 188, 1356, 1355, 784, 1925, + /* 1910 */ 1354, 724, 786, 809, 805, 801, 797, 2286, 318, 1351, + /* 1920 */ 386, 1350, 1916, 1348, 387, 2285, 1914, 388, 2323, 1888, + /* 1930 */ 724, 171, 2287, 727, 2289, 2290, 722, 616, 717, 2304, + /* 1940 */ 620, 613, 1887, 1886, 1885, 622, 1884, 624, 113, 1590, + /* 1950 */ 1592, 2253, 1589, 723, 2209, 1594, 1570, 29, 2304, 109, + /* 1960 */ 1572, 68, 312, 2199, 2186, 2185, 57, 639, 165, 2460, + /* 1970 */ 2253, 275, 723, 650, 2417, 640, 17, 1549, 66, 195, + /* 1980 */ 20, 6, 1548, 31, 7, 1819, 279, 645, 281, 1574, + /* 1990 */ 2285, 657, 2286, 2323, 703, 647, 172, 2287, 727, 2289, + /* 2000 */ 2290, 722, 21, 717, 22, 724, 1800, 173, 655, 2285, + /* 2010 */ 184, 2274, 2323, 183, 33, 111, 2287, 727, 2289, 2290, + /* 2020 */ 722, 1789, 717, 32, 24, 1834, 79, 1833, 1839, 2376, + /* 2030 */ 1840, 397, 301, 2304, 2373, 1838, 1837, 398, 295, 300, + /* 2040 */ 1760, 59, 1759, 2184, 176, 2253, 98, 723, 2163, 2162, + /* 2050 */ 676, 2476, 99, 26, 97, 25, 104, 302, 271, 2286, + /* 2060 */ 1795, 186, 23, 308, 69, 18, 100, 313, 13, 11, + /* 2070 */ 177, 310, 724, 58, 698, 1632, 1712, 1711, 187, 1665, + /* 2080 */ 1722, 1690, 2326, 728, 2285, 2286, 716, 2323, 726, 1688, + /* 2090 */ 171, 2287, 727, 2289, 2290, 722, 730, 717, 724, 39, + /* 2100 */ 2304, 411, 734, 1687, 1657, 393, 737, 16, 27, 28, + /* 2110 */ 1426, 732, 2253, 1435, 723, 740, 1432, 735, 743, 1431, + /* 2120 */ 738, 746, 1428, 741, 316, 744, 2304, 1444, 1440, 1422, + /* 2130 */ 1420, 394, 747, 2418, 1425, 1345, 105, 106, 2253, 76, + /* 2140 */ 723, 1310, 761, 1424, 1342, 1341, 1340, 1339, 1337, 1335, + /* 2150 */ 1334, 2285, 1423, 1333, 2323, 2286, 1371, 351, 2287, 727, + /* 2160 */ 2289, 2290, 722, 772, 717, 1370, 202, 774, 724, 1331, + /* 2170 */ 1328, 1330, 1329, 1327, 1326, 1325, 1367, 2285, 1365, 1322, + /* 2180 */ 2323, 1321, 2286, 351, 2287, 727, 2289, 2290, 722, 1318, + /* 2190 */ 717, 1317, 1316, 1933, 1315, 724, 2304, 794, 795, 1931, + /* 2200 */ 796, 798, 799, 800, 1929, 802, 803, 804, 2253, 1926, + /* 2210 */ 723, 806, 1908, 807, 808, 810, 1257, 1883, 1245, 814, + /* 2220 */ 320, 816, 819, 2304, 1618, 330, 820, 1853, 1853, 1853, + /* 2230 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, + /* 2240 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, + /* 2250 */ 2323, 1853, 1853, 344, 2287, 727, 2289, 2290, 722, 1853, + /* 2260 */ 717, 1853, 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, + /* 2270 */ 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, 724, + /* 2280 */ 172, 2287, 727, 2289, 2290, 722, 1853, 717, 2286, 1853, + /* 2290 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 671, + /* 2300 */ 1853, 721, 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, + /* 2310 */ 1853, 1853, 400, 1853, 1853, 1853, 1853, 1853, 1853, 2253, + /* 2320 */ 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2304, + /* 2330 */ 1853, 1853, 1853, 1853, 1853, 2477, 1853, 1853, 1853, 1853, + /* 2340 */ 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2350 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, + /* 2360 */ 1853, 2323, 1853, 1853, 351, 2287, 727, 2289, 2290, 722, + /* 2370 */ 1853, 717, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2380 */ 2285, 1853, 1853, 2323, 1853, 1853, 350, 2287, 727, 2289, + /* 2390 */ 2290, 722, 1853, 717, 2286, 2342, 1853, 1853, 1853, 1853, + /* 2400 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 724, 1853, 1853, + /* 2410 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2420 */ 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2430 */ 1853, 1853, 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, + /* 2440 */ 408, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, + /* 2450 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2460 */ 1853, 1853, 2304, 1853, 1853, 1853, 1853, 410, 1853, 1853, + /* 2470 */ 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, + /* 2480 */ 1853, 1853, 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, + /* 2490 */ 1853, 1853, 351, 2287, 727, 2289, 2290, 722, 1853, 717, + /* 2500 */ 724, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, + /* 2510 */ 1853, 1853, 1853, 2285, 1853, 1853, 2323, 724, 1853, 351, + /* 2520 */ 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, + /* 2530 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2540 */ 2253, 1853, 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, + /* 2550 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, + /* 2560 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2570 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 630, + /* 2580 */ 1853, 1853, 2323, 1853, 2286, 346, 2287, 727, 2289, 2290, + /* 2590 */ 722, 1853, 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, + /* 2600 */ 1853, 1853, 336, 2287, 727, 2289, 2290, 722, 1853, 717, + /* 2610 */ 1853, 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, + /* 2620 */ 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, + /* 2630 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, + /* 2640 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2650 */ 2286, 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, + /* 2660 */ 1853, 1853, 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, + /* 2670 */ 723, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, + /* 2680 */ 1853, 1853, 334, 2287, 727, 2289, 2290, 722, 1853, 717, + /* 2690 */ 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2700 */ 1853, 1853, 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, + /* 2710 */ 2323, 1853, 1853, 337, 2287, 727, 2289, 2290, 722, 1853, + /* 2720 */ 717, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2730 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2740 */ 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, 343, 2287, + /* 2750 */ 727, 2289, 2290, 722, 1853, 717, 724, 1853, 1853, 1853, + /* 2760 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2770 */ 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2780 */ 1853, 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, + /* 2790 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, + /* 2800 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2810 */ 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2820 */ 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, + /* 2830 */ 1853, 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, + /* 2840 */ 1853, 347, 2287, 727, 2289, 2290, 722, 1853, 717, 724, + /* 2850 */ 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2860 */ 1853, 1853, 2285, 1853, 1853, 2323, 724, 1853, 339, 2287, + /* 2870 */ 727, 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, + /* 2880 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, + /* 2890 */ 1853, 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, + /* 2900 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, + /* 2910 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 2920 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, + /* 2930 */ 1853, 2323, 1853, 2286, 348, 2287, 727, 2289, 2290, 722, + /* 2940 */ 1853, 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, 1853, + /* 2950 */ 1853, 340, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, + /* 2960 */ 1853, 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, + /* 2970 */ 1853, 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, 1853, + /* 2980 */ 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, + /* 2990 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, + /* 3000 */ 1853, 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, 1853, + /* 3010 */ 1853, 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, 723, + /* 3020 */ 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, + /* 3030 */ 1853, 349, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, + /* 3040 */ 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3050 */ 1853, 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, 2323, + /* 3060 */ 1853, 1853, 341, 2287, 727, 2289, 2290, 722, 1853, 717, + /* 3070 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3080 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3090 */ 1853, 2285, 2286, 1853, 2323, 1853, 1853, 355, 2287, 727, + /* 3100 */ 2289, 2290, 722, 1853, 717, 724, 1853, 1853, 1853, 1853, + /* 3110 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, + /* 3120 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3130 */ 1853, 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3140 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, + /* 3150 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3160 */ 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3170 */ 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, + /* 3180 */ 1853, 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, + /* 3190 */ 356, 2287, 727, 2289, 2290, 722, 1853, 717, 724, 1853, + /* 3200 */ 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3210 */ 1853, 2285, 1853, 1853, 2323, 724, 1853, 2298, 2287, 727, + /* 3220 */ 2289, 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, 1853, + /* 3230 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, + /* 3240 */ 723, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3250 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, + /* 3260 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3270 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, + /* 3280 */ 2323, 1853, 2286, 2297, 2287, 727, 2289, 2290, 722, 1853, + /* 3290 */ 717, 1853, 1853, 1853, 2285, 724, 1853, 2323, 1853, 1853, + /* 3300 */ 2296, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 1853, + /* 3310 */ 1853, 1853, 1853, 2286, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3320 */ 1853, 1853, 1853, 2304, 1853, 1853, 724, 1853, 1853, 1853, + /* 3330 */ 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, + /* 3340 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, 1853, + /* 3350 */ 1853, 1853, 1853, 1853, 2304, 1853, 1853, 1853, 1853, 1853, + /* 3360 */ 1853, 724, 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, + /* 3370 */ 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, 1853, 1853, + /* 3380 */ 370, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, 2304, + /* 3390 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3400 */ 1853, 2253, 1853, 723, 1853, 2285, 1853, 1853, 2323, 1853, + /* 3410 */ 1853, 371, 2287, 727, 2289, 2290, 722, 1853, 717, 1853, + /* 3420 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3430 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3440 */ 2285, 2286, 1853, 2323, 1853, 1853, 367, 2287, 727, 2289, + /* 3450 */ 2290, 722, 1853, 717, 724, 1853, 1853, 1853, 1853, 1853, + /* 3460 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2286, 1853, + /* 3470 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3480 */ 1853, 724, 2304, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3490 */ 1853, 1853, 1853, 1853, 2253, 1853, 723, 1853, 1853, 1853, + /* 3500 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2304, + /* 3510 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3520 */ 1853, 2253, 1853, 723, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3530 */ 1853, 1853, 1853, 2285, 2286, 1853, 2323, 1853, 1853, 372, + /* 3540 */ 2287, 727, 2289, 2290, 722, 1853, 717, 724, 1853, 1853, + /* 3550 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3560 */ 725, 1853, 1853, 2323, 1853, 1853, 346, 2287, 727, 2289, + /* 3570 */ 2290, 722, 1853, 717, 1853, 2304, 1853, 1853, 1853, 1853, + /* 3580 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 2253, 1853, 723, + /* 3590 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3600 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3610 */ 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, 1853, + /* 3620 */ 1853, 1853, 1853, 1853, 1853, 1853, 2285, 1853, 1853, 2323, + /* 3630 */ 1853, 1853, 345, 2287, 727, 2289, 2290, 722, 1853, 717, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 389, 360, 361, 472, 390, 472, 475, 355, 475, 390, @@ -949,7 +605,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, /* 130 */ 94, 95, 96, 97, 98, 99, 355, 107, 440, 358, /* 140 */ 359, 443, 142, 143, 446, 447, 448, 449, 450, 451, - /* 150 */ 401, 453, 424, 360, 361, 116, 458, 429, 460, 389, + /* 150 */ 401, 453, 424, 360, 361, 20, 458, 429, 460, 389, /* 160 */ 107, 403, 464, 465, 468, 469, 470, 3, 472, 473, /* 170 */ 370, 475, 360, 20, 174, 175, 418, 479, 378, 421, /* 180 */ 422, 181, 182, 413, 20, 487, 389, 21, 106, 493, @@ -962,9 +618,9 @@ static const YYCODETYPE yy_lookahead[] = { /* 250 */ 12, 13, 0, 360, 361, 18, 176, 20, 20, 77, /* 260 */ 22, 468, 469, 470, 27, 472, 473, 30, 14, 70, /* 270 */ 64, 107, 35, 35, 20, 37, 24, 25, 26, 27, - /* 280 */ 28, 29, 30, 31, 32, 72, 73, 74, 51, 20, + /* 280 */ 28, 29, 30, 31, 32, 72, 73, 74, 51, 69, /* 290 */ 53, 4, 79, 80, 81, 58, 209, 210, 85, 195, - /* 300 */ 250, 197, 64, 90, 91, 92, 93, 0, 70, 96, + /* 300 */ 116, 197, 64, 90, 91, 92, 93, 0, 70, 96, /* 310 */ 230, 105, 99, 114, 108, 77, 12, 13, 14, 15, /* 320 */ 16, 8, 9, 348, 116, 12, 13, 14, 15, 16, /* 330 */ 385, 227, 106, 46, 47, 48, 361, 180, 363, 356, @@ -980,18 +636,18 @@ static const YYCODETYPE yy_lookahead[] = { /* 430 */ 273, 274, 69, 458, 196, 460, 198, 39, 40, 464, /* 440 */ 465, 230, 135, 136, 137, 138, 139, 140, 141, 107, /* 450 */ 348, 20, 253, 254, 255, 256, 257, 258, 259, 260, - /* 460 */ 261, 262, 263, 361, 69, 348, 228, 229, 230, 424, + /* 460 */ 261, 262, 263, 361, 250, 348, 228, 229, 230, 424, /* 470 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, /* 480 */ 242, 243, 244, 245, 246, 247, 248, 249, 250, 12, /* 490 */ 13, 389, 266, 369, 20, 388, 20, 20, 22, 22, - /* 500 */ 20, 188, 22, 401, 369, 403, 348, 400, 110, 111, + /* 500 */ 20, 188, 22, 401, 13, 403, 348, 400, 110, 111, /* 510 */ 386, 113, 35, 37, 37, 2, 13, 472, 401, 395, /* 520 */ 475, 8, 9, 348, 173, 12, 13, 14, 15, 16, - /* 530 */ 395, 55, 198, 135, 20, 55, 361, 139, 493, 494, + /* 530 */ 369, 55, 198, 135, 20, 55, 361, 139, 493, 494, /* 540 */ 37, 64, 440, 498, 499, 443, 360, 70, 446, 447, - /* 550 */ 448, 449, 450, 451, 77, 453, 33, 228, 456, 401, - /* 560 */ 458, 459, 460, 77, 389, 0, 464, 465, 45, 86, - /* 570 */ 103, 174, 456, 142, 143, 459, 401, 348, 403, 348, + /* 550 */ 448, 449, 450, 451, 77, 453, 395, 228, 456, 401, + /* 560 */ 458, 459, 460, 77, 389, 0, 464, 465, 77, 86, + /* 570 */ 103, 174, 376, 142, 143, 379, 401, 348, 403, 348, /* 580 */ 103, 174, 175, 106, 117, 118, 119, 120, 121, 122, /* 590 */ 123, 124, 125, 126, 348, 128, 129, 130, 131, 132, /* 600 */ 133, 134, 416, 417, 253, 292, 277, 278, 279, 280, @@ -1001,7 +657,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 640 */ 465, 12, 13, 14, 15, 16, 399, 401, 389, 402, /* 650 */ 403, 174, 175, 170, 2, 181, 182, 13, 181, 182, /* 660 */ 8, 9, 487, 389, 12, 13, 14, 15, 16, 35, - /* 670 */ 411, 77, 413, 196, 0, 198, 22, 389, 404, 360, + /* 670 */ 411, 390, 413, 196, 0, 198, 22, 389, 404, 360, /* 680 */ 361, 37, 360, 361, 396, 51, 360, 361, 348, 51, /* 690 */ 176, 37, 404, 59, 60, 61, 62, 59, 64, 380, /* 700 */ 62, 63, 380, 348, 137, 228, 229, 230, 141, 232, @@ -1025,7 +681,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 880 */ 401, 403, 20, 445, 397, 348, 50, 8, 9, 174, /* 890 */ 175, 12, 13, 14, 15, 16, 181, 182, 0, 135, /* 900 */ 136, 137, 138, 139, 140, 141, 390, 443, 196, 471, - /* 910 */ 198, 196, 390, 198, 457, 103, 459, 453, 440, 360, + /* 910 */ 198, 196, 378, 198, 457, 103, 459, 453, 440, 360, /* 920 */ 361, 443, 360, 361, 446, 447, 448, 449, 450, 451, /* 930 */ 452, 453, 454, 455, 3, 360, 361, 0, 401, 380, /* 940 */ 228, 229, 380, 228, 229, 230, 107, 232, 233, 234, @@ -1043,120 +699,120 @@ static const YYCODETYPE yy_lookahead[] = { /* 1060 */ 440, 348, 348, 443, 230, 377, 446, 447, 448, 449, /* 1070 */ 450, 451, 105, 453, 361, 108, 363, 380, 458, 391, /* 1080 */ 460, 360, 361, 348, 464, 465, 360, 361, 457, 401, - /* 1090 */ 459, 472, 230, 348, 475, 142, 143, 389, 161, 374, - /* 1100 */ 375, 380, 389, 360, 361, 397, 380, 170, 398, 360, - /* 1110 */ 361, 401, 493, 494, 401, 401, 403, 498, 499, 348, - /* 1120 */ 360, 361, 4, 380, 0, 360, 361, 174, 175, 380, - /* 1130 */ 398, 443, 444, 401, 181, 182, 401, 360, 361, 445, + /* 1090 */ 459, 472, 230, 348, 475, 142, 143, 4, 161, 374, + /* 1100 */ 375, 380, 389, 360, 361, 456, 380, 170, 459, 360, + /* 1110 */ 361, 33, 493, 494, 401, 401, 403, 498, 499, 348, + /* 1120 */ 360, 361, 389, 380, 0, 360, 361, 174, 175, 380, + /* 1130 */ 397, 443, 444, 0, 181, 182, 401, 360, 361, 445, /* 1140 */ 380, 453, 1, 2, 377, 380, 401, 360, 361, 196, /* 1150 */ 33, 198, 174, 440, 374, 375, 443, 380, 391, 446, /* 1160 */ 447, 448, 449, 450, 451, 471, 453, 380, 401, 56, /* 1170 */ 57, 458, 401, 460, 14, 15, 16, 464, 465, 365, - /* 1180 */ 366, 228, 229, 230, 37, 232, 233, 234, 235, 236, + /* 1180 */ 366, 228, 229, 230, 51, 232, 233, 234, 235, 236, /* 1190 */ 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, - /* 1200 */ 247, 248, 249, 12, 13, 0, 348, 445, 230, 398, + /* 1200 */ 247, 248, 249, 12, 13, 33, 348, 445, 230, 398, /* 1210 */ 443, 20, 401, 22, 365, 366, 351, 352, 287, 361, - /* 1220 */ 453, 363, 382, 64, 376, 385, 35, 379, 37, 47, - /* 1230 */ 48, 0, 33, 471, 264, 265, 109, 109, 109, 112, - /* 1240 */ 112, 112, 109, 33, 45, 112, 33, 389, 107, 0, - /* 1250 */ 0, 212, 33, 214, 33, 64, 51, 0, 33, 401, - /* 1260 */ 70, 403, 142, 143, 49, 265, 378, 108, 77, 33, - /* 1270 */ 37, 22, 22, 42, 33, 33, 33, 33, 0, 22, - /* 1280 */ 414, 33, 106, 1, 2, 33, 33, 33, 33, 33, - /* 1290 */ 13, 115, 502, 33, 103, 33, 33, 106, 440, 348, - /* 1300 */ 13, 443, 37, 364, 446, 447, 448, 449, 450, 451, - /* 1310 */ 77, 453, 361, 484, 37, 491, 458, 107, 460, 12, - /* 1320 */ 13, 106, 464, 465, 37, 389, 107, 377, 107, 22, - /* 1330 */ 52, 377, 107, 142, 143, 414, 414, 490, 423, 364, - /* 1340 */ 389, 490, 35, 107, 37, 198, 222, 490, 107, 107, - /* 1350 */ 107, 107, 401, 490, 403, 107, 414, 359, 361, 107, - /* 1360 */ 107, 107, 107, 107, 400, 174, 175, 107, 474, 107, - /* 1370 */ 107, 64, 181, 182, 414, 414, 495, 466, 477, 269, - /* 1380 */ 425, 51, 442, 42, 77, 441, 268, 196, 20, 198, - /* 1390 */ 434, 440, 211, 369, 443, 369, 439, 446, 447, 448, - /* 1400 */ 449, 450, 451, 434, 453, 194, 289, 427, 360, 458, - /* 1410 */ 103, 460, 20, 20, 361, 464, 465, 45, 228, 228, - /* 1420 */ 229, 230, 410, 232, 233, 234, 235, 236, 237, 238, + /* 1220 */ 453, 363, 398, 0, 398, 401, 35, 401, 37, 382, + /* 1230 */ 47, 48, 385, 471, 264, 265, 0, 33, 33, 109, + /* 1240 */ 109, 109, 112, 112, 112, 22, 64, 389, 107, 45, + /* 1250 */ 45, 109, 0, 0, 112, 64, 212, 33, 214, 401, + /* 1260 */ 70, 403, 33, 33, 33, 265, 414, 33, 77, 142, + /* 1270 */ 143, 33, 0, 33, 22, 22, 33, 33, 42, 107, + /* 1280 */ 1, 2, 33, 33, 33, 37, 49, 502, 33, 33, + /* 1290 */ 108, 106, 491, 13, 103, 33, 33, 106, 440, 348, + /* 1300 */ 115, 443, 33, 13, 446, 447, 448, 449, 450, 451, + /* 1310 */ 364, 453, 361, 37, 484, 37, 458, 37, 460, 12, + /* 1320 */ 13, 389, 464, 465, 52, 377, 377, 37, 414, 22, + /* 1330 */ 414, 107, 490, 142, 143, 490, 107, 107, 107, 364, + /* 1340 */ 389, 107, 35, 106, 37, 107, 222, 107, 423, 490, + /* 1350 */ 107, 107, 401, 490, 403, 77, 107, 107, 107, 361, + /* 1360 */ 359, 268, 107, 107, 414, 174, 175, 289, 400, 107, + /* 1370 */ 107, 64, 181, 182, 414, 414, 107, 474, 495, 466, + /* 1380 */ 269, 477, 379, 425, 77, 51, 442, 196, 42, 198, + /* 1390 */ 20, 440, 211, 441, 443, 439, 434, 446, 447, 448, + /* 1400 */ 449, 450, 451, 369, 453, 434, 369, 194, 291, 458, + /* 1410 */ 103, 460, 427, 20, 360, 464, 465, 20, 228, 228, + /* 1420 */ 229, 230, 361, 232, 233, 234, 235, 236, 237, 238, /* 1430 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1440 */ 249, 361, 18, 410, 173, 407, 360, 23, 361, 360, - /* 1450 */ 410, 407, 407, 104, 373, 102, 372, 360, 101, 371, - /* 1460 */ 360, 360, 360, 198, 40, 41, 20, 353, 44, 50, - /* 1470 */ 434, 20, 357, 357, 353, 369, 403, 369, 54, 20, - /* 1480 */ 20, 362, 426, 20, 348, 362, 417, 353, 389, 65, - /* 1490 */ 66, 67, 68, 389, 369, 369, 389, 361, 360, 369, - /* 1500 */ 369, 369, 351, 196, 291, 198, 360, 351, 353, 215, - /* 1510 */ 401, 389, 401, 401, 438, 106, 367, 434, 436, 202, - /* 1520 */ 201, 367, 200, 433, 389, 389, 389, 432, 389, 389, - /* 1530 */ 106, 389, 389, 389, 431, 228, 229, 401, 360, 403, - /* 1540 */ 276, 483, 275, 483, 485, 284, 187, 486, 403, 242, - /* 1550 */ 243, 244, 245, 246, 247, 248, 286, 483, 401, 482, - /* 1560 */ 285, 270, 293, 290, 497, 503, 481, 288, 144, 419, - /* 1570 */ 265, 419, 480, 425, 496, 361, 440, 20, 425, 443, - /* 1580 */ 116, 267, 446, 447, 448, 449, 450, 451, 362, 453, - /* 1590 */ 367, 367, 419, 401, 458, 401, 460, 401, 401, 419, - /* 1600 */ 464, 465, 401, 445, 179, 367, 367, 385, 415, 106, - /* 1610 */ 106, 393, 188, 189, 190, 22, 379, 193, 401, 361, - /* 1620 */ 38, 435, 350, 428, 420, 0, 463, 353, 360, 420, - /* 1630 */ 206, 207, 346, 367, 354, 0, 0, 45, 476, 478, - /* 1640 */ 0, 217, 383, 348, 220, 37, 37, 223, 224, 225, - /* 1650 */ 226, 227, 368, 221, 37, 37, 361, 221, 0, 383, - /* 1660 */ 37, 37, 221, 37, 383, 0, 221, 0, 37, 348, - /* 1670 */ 0, 22, 0, 216, 37, 0, 204, 0, 204, 198, - /* 1680 */ 205, 0, 361, 196, 389, 0, 0, 192, 191, 0, - /* 1690 */ 266, 0, 147, 0, 49, 49, 401, 37, 403, 51, - /* 1700 */ 0, 49, 0, 0, 45, 0, 0, 0, 0, 0, - /* 1710 */ 389, 49, 0, 0, 0, 161, 37, 0, 0, 161, + /* 1440 */ 249, 45, 18, 410, 361, 410, 198, 23, 173, 407, + /* 1450 */ 360, 410, 361, 407, 360, 407, 104, 373, 102, 372, + /* 1460 */ 360, 101, 360, 371, 40, 41, 360, 360, 44, 20, + /* 1470 */ 50, 353, 357, 353, 198, 20, 357, 434, 54, 369, + /* 1480 */ 403, 369, 20, 362, 348, 20, 426, 20, 362, 65, + /* 1490 */ 66, 67, 68, 417, 369, 438, 353, 361, 369, 360, + /* 1500 */ 353, 351, 401, 196, 369, 198, 369, 369, 360, 351, + /* 1510 */ 401, 389, 389, 215, 106, 401, 436, 389, 202, 434, + /* 1520 */ 201, 367, 433, 389, 367, 389, 200, 432, 431, 389, + /* 1530 */ 106, 360, 483, 389, 389, 228, 229, 401, 389, 403, + /* 1540 */ 389, 389, 389, 276, 284, 275, 483, 483, 486, 242, + /* 1550 */ 243, 244, 245, 246, 247, 248, 187, 401, 403, 485, + /* 1560 */ 286, 482, 285, 481, 270, 497, 480, 496, 144, 503, + /* 1570 */ 265, 425, 290, 288, 293, 361, 440, 20, 419, 443, + /* 1580 */ 419, 478, 446, 447, 448, 449, 450, 451, 425, 453, + /* 1590 */ 116, 267, 476, 367, 458, 362, 460, 419, 401, 367, + /* 1600 */ 464, 465, 401, 401, 401, 419, 179, 445, 401, 415, + /* 1610 */ 385, 106, 188, 189, 190, 106, 401, 193, 22, 361, + /* 1620 */ 393, 367, 38, 350, 367, 360, 367, 463, 428, 420, + /* 1630 */ 206, 207, 420, 435, 368, 346, 0, 354, 0, 353, + /* 1640 */ 0, 217, 45, 348, 220, 0, 37, 223, 224, 225, + /* 1650 */ 226, 227, 221, 37, 383, 37, 361, 37, 221, 0, + /* 1660 */ 37, 37, 221, 37, 0, 221, 0, 383, 37, 348, + /* 1670 */ 383, 0, 22, 0, 37, 216, 0, 204, 0, 204, + /* 1680 */ 198, 205, 361, 196, 389, 0, 0, 0, 192, 191, + /* 1690 */ 266, 0, 0, 147, 0, 49, 401, 49, 403, 37, + /* 1700 */ 51, 0, 49, 0, 0, 45, 0, 0, 0, 0, + /* 1710 */ 389, 37, 49, 0, 0, 0, 0, 161, 0, 161, /* 1720 */ 0, 0, 401, 0, 403, 0, 0, 0, 0, 0, /* 1730 */ 0, 0, 0, 0, 0, 440, 348, 49, 443, 0, /* 1740 */ 0, 446, 447, 448, 449, 450, 451, 0, 453, 361, - /* 1750 */ 0, 0, 0, 458, 0, 460, 0, 0, 22, 464, - /* 1760 */ 465, 440, 0, 147, 443, 348, 0, 446, 447, 448, - /* 1770 */ 449, 450, 451, 146, 453, 0, 0, 389, 361, 145, - /* 1780 */ 45, 460, 0, 22, 0, 464, 465, 22, 50, 401, - /* 1790 */ 37, 403, 50, 0, 0, 0, 0, 37, 0, 51, - /* 1800 */ 42, 37, 0, 0, 0, 64, 389, 64, 64, 42, - /* 1810 */ 51, 37, 42, 45, 51, 37, 33, 0, 401, 42, - /* 1820 */ 403, 49, 49, 14, 43, 0, 0, 42, 440, 49, - /* 1830 */ 0, 443, 42, 348, 446, 447, 448, 449, 450, 451, - /* 1840 */ 187, 453, 0, 0, 0, 0, 361, 0, 460, 49, - /* 1850 */ 71, 37, 464, 465, 42, 1, 51, 440, 0, 37, - /* 1860 */ 443, 51, 42, 446, 447, 448, 449, 450, 451, 0, - /* 1870 */ 453, 42, 37, 19, 389, 51, 0, 460, 37, 51, - /* 1880 */ 42, 464, 465, 0, 0, 0, 401, 0, 403, 35, - /* 1890 */ 0, 0, 37, 22, 0, 33, 37, 37, 348, 112, - /* 1900 */ 114, 37, 37, 37, 37, 51, 33, 37, 22, 37, - /* 1910 */ 0, 361, 37, 59, 60, 61, 62, 348, 64, 37, - /* 1920 */ 22, 0, 22, 0, 22, 440, 37, 53, 443, 37, - /* 1930 */ 361, 446, 447, 448, 449, 450, 451, 0, 453, 389, - /* 1940 */ 37, 0, 37, 0, 22, 20, 37, 107, 37, 37, - /* 1950 */ 0, 401, 0, 403, 0, 106, 106, 37, 389, 105, - /* 1960 */ 22, 0, 108, 0, 176, 176, 22, 0, 199, 3, - /* 1970 */ 401, 3, 403, 488, 489, 176, 179, 50, 33, 50, - /* 1980 */ 33, 271, 176, 106, 183, 107, 106, 271, 107, 33, - /* 1990 */ 440, 183, 348, 443, 140, 203, 446, 447, 448, 449, - /* 2000 */ 450, 451, 107, 453, 107, 361, 33, 106, 104, 440, - /* 2010 */ 102, 49, 443, 106, 49, 446, 447, 448, 449, 450, - /* 2020 */ 451, 106, 453, 106, 33, 33, 107, 37, 49, 460, - /* 2030 */ 37, 107, 178, 389, 465, 37, 37, 37, 37, 185, - /* 2040 */ 107, 107, 271, 33, 49, 401, 42, 403, 0, 0, - /* 2050 */ 500, 501, 106, 0, 106, 264, 107, 106, 204, 348, - /* 2060 */ 107, 106, 42, 106, 106, 49, 33, 251, 180, 2, - /* 2070 */ 106, 178, 361, 104, 115, 104, 22, 107, 106, 228, - /* 2080 */ 49, 107, 106, 106, 440, 348, 106, 443, 107, 49, - /* 2090 */ 446, 447, 448, 449, 450, 451, 107, 453, 361, 22, - /* 2100 */ 389, 116, 106, 37, 107, 394, 37, 37, 106, 106, - /* 2110 */ 231, 37, 401, 107, 403, 107, 107, 106, 37, 106, - /* 2120 */ 37, 107, 107, 106, 37, 106, 389, 106, 33, 106, - /* 2130 */ 37, 394, 127, 489, 127, 106, 22, 37, 401, 127, - /* 2140 */ 403, 37, 71, 37, 37, 127, 70, 37, 37, 37, - /* 2150 */ 37, 440, 37, 33, 443, 348, 77, 446, 447, 448, - /* 2160 */ 449, 450, 451, 100, 453, 37, 37, 37, 361, 22, - /* 2170 */ 37, 37, 37, 77, 37, 37, 22, 440, 37, 37, + /* 1750 */ 0, 0, 0, 458, 0, 460, 0, 45, 0, 464, + /* 1760 */ 465, 440, 0, 22, 443, 348, 0, 446, 447, 448, + /* 1770 */ 449, 450, 451, 0, 453, 147, 146, 389, 361, 0, + /* 1780 */ 145, 460, 0, 0, 0, 464, 465, 22, 50, 401, + /* 1790 */ 22, 403, 50, 0, 37, 0, 0, 0, 37, 64, + /* 1800 */ 64, 42, 0, 0, 51, 42, 389, 64, 37, 37, + /* 1810 */ 0, 51, 42, 37, 0, 51, 49, 42, 401, 45, + /* 1820 */ 403, 33, 14, 0, 43, 0, 49, 49, 440, 42, + /* 1830 */ 0, 443, 0, 348, 446, 447, 448, 449, 450, 451, + /* 1840 */ 42, 453, 187, 0, 0, 0, 361, 0, 460, 49, + /* 1850 */ 0, 71, 464, 465, 37, 1, 51, 440, 42, 0, + /* 1860 */ 443, 37, 51, 446, 447, 448, 449, 450, 451, 42, + /* 1870 */ 453, 0, 37, 19, 389, 42, 0, 460, 37, 51, + /* 1880 */ 51, 464, 465, 0, 42, 0, 401, 0, 403, 35, + /* 1890 */ 0, 0, 0, 37, 22, 0, 22, 37, 348, 114, + /* 1900 */ 37, 112, 37, 37, 37, 51, 37, 37, 33, 0, + /* 1910 */ 37, 361, 33, 59, 60, 61, 62, 348, 64, 37, + /* 1920 */ 22, 37, 0, 37, 22, 440, 0, 22, 443, 0, + /* 1930 */ 361, 446, 447, 448, 449, 450, 451, 37, 453, 389, + /* 1940 */ 37, 53, 0, 0, 0, 37, 0, 22, 20, 37, + /* 1950 */ 37, 401, 37, 403, 0, 107, 37, 106, 389, 105, + /* 1960 */ 22, 106, 108, 0, 0, 0, 176, 22, 199, 3, + /* 1970 */ 401, 179, 403, 488, 489, 176, 271, 176, 3, 49, + /* 1980 */ 33, 50, 176, 106, 50, 107, 106, 183, 107, 203, + /* 1990 */ 440, 102, 348, 443, 140, 183, 446, 447, 448, 449, + /* 2000 */ 450, 451, 33, 453, 33, 361, 107, 106, 104, 440, + /* 2010 */ 33, 49, 443, 106, 33, 446, 447, 448, 449, 450, + /* 2020 */ 451, 107, 453, 106, 33, 37, 106, 37, 107, 460, + /* 2030 */ 107, 37, 178, 389, 465, 37, 37, 37, 49, 185, + /* 2040 */ 107, 33, 107, 0, 49, 401, 42, 403, 0, 0, + /* 2050 */ 500, 501, 42, 33, 106, 106, 115, 107, 204, 348, + /* 2060 */ 107, 106, 271, 106, 106, 271, 106, 49, 2, 251, + /* 2070 */ 49, 178, 361, 264, 180, 22, 104, 104, 49, 22, + /* 2080 */ 228, 107, 106, 116, 440, 348, 106, 443, 231, 107, + /* 2090 */ 446, 447, 448, 449, 450, 451, 37, 453, 361, 106, + /* 2100 */ 389, 37, 37, 107, 107, 394, 37, 106, 106, 106, + /* 2110 */ 127, 106, 401, 107, 403, 37, 107, 106, 37, 107, + /* 2120 */ 106, 37, 107, 106, 33, 106, 389, 37, 22, 107, + /* 2130 */ 107, 394, 106, 489, 127, 37, 106, 106, 401, 106, + /* 2140 */ 403, 71, 70, 127, 37, 37, 37, 37, 37, 37, + /* 2150 */ 37, 440, 127, 37, 443, 348, 77, 446, 447, 448, + /* 2160 */ 449, 450, 451, 100, 453, 77, 33, 100, 361, 37, + /* 2170 */ 22, 37, 37, 37, 37, 37, 77, 440, 37, 37, /* 2180 */ 443, 37, 348, 446, 447, 448, 449, 450, 451, 37, - /* 2190 */ 453, 0, 37, 42, 51, 361, 389, 0, 37, 51, - /* 2200 */ 42, 0, 37, 0, 51, 42, 37, 0, 401, 42, - /* 2210 */ 403, 51, 37, 37, 0, 22, 33, 22, 22, 21, - /* 2220 */ 20, 22, 504, 389, 504, 21, 504, 504, 504, 504, + /* 2190 */ 453, 37, 22, 0, 37, 361, 389, 37, 51, 0, + /* 2200 */ 42, 37, 51, 42, 0, 37, 51, 42, 401, 0, + /* 2210 */ 403, 37, 0, 51, 42, 37, 37, 0, 22, 33, + /* 2220 */ 22, 21, 21, 389, 22, 22, 20, 504, 504, 504, /* 2230 */ 504, 504, 504, 504, 504, 401, 504, 403, 504, 504, /* 2240 */ 504, 504, 504, 504, 504, 504, 504, 440, 504, 504, /* 2250 */ 443, 504, 504, 446, 447, 448, 449, 450, 451, 504, @@ -1334,9 +990,9 @@ static const YYCODETYPE yy_lookahead[] = { /* 3970 */ 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, /* 3980 */ 345, 345, 345, 345, 345, }; -#define YY_SHIFT_COUNT (819) +#define YY_SHIFT_COUNT (821) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2214) +#define YY_SHIFT_MAX (2217) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1424, 0, 238, 0, 477, 477, 477, 477, 477, 477, /* 10 */ 477, 477, 477, 477, 477, 477, 715, 953, 953, 1191, @@ -1345,81 +1001,82 @@ static const unsigned short int yy_shift_ofst[] = { /* 40 */ 953, 953, 953, 953, 953, 953, 953, 953, 953, 953, /* 50 */ 953, 82, 93, 104, 85, 103, 226, 103, 85, 85, /* 60 */ 103, 1307, 103, 237, 1307, 1307, 86, 103, 38, 474, - /* 70 */ 153, 153, 474, 287, 287, 407, 431, 254, 254, 177, - /* 80 */ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - /* 90 */ 269, 153, 153, 363, 38, 153, 153, 38, 153, 153, - /* 100 */ 38, 153, 153, 38, 153, 38, 38, 38, 153, 395, + /* 70 */ 135, 135, 474, 287, 287, 407, 431, 254, 254, 177, + /* 80 */ 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, + /* 90 */ 153, 135, 135, 220, 38, 135, 135, 38, 135, 135, + /* 100 */ 38, 135, 135, 38, 135, 38, 38, 38, 135, 363, /* 110 */ 199, 199, 213, 54, 712, 712, 712, 712, 712, 712, /* 120 */ 712, 712, 712, 712, 712, 712, 712, 712, 712, 712, /* 130 */ 712, 712, 712, 398, 164, 407, 431, 1113, 1113, 182, - /* 140 */ 40, 40, 40, 565, 538, 538, 182, 363, 39, 38, - /* 150 */ 38, 50, 38, 486, 38, 486, 486, 520, 594, 73, + /* 140 */ 40, 40, 40, 565, 538, 538, 491, 182, 220, 184, + /* 150 */ 38, 38, 214, 38, 486, 38, 486, 486, 520, 73, /* 160 */ 467, 467, 467, 467, 467, 467, 467, 467, 1854, 674, /* 170 */ 23, 80, 313, 329, 476, 157, 211, 397, 334, 334, /* 180 */ 514, 834, 945, 945, 945, 836, 945, 978, 480, 383, - /* 190 */ 1182, 396, 893, 383, 383, 862, 970, 1000, 931, 970, - /* 200 */ 523, 1118, 1110, 1330, 1341, 1368, 1181, 363, 1368, 363, - /* 210 */ 1211, 1392, 1393, 1372, 1393, 1372, 1271, 1392, 1393, 1392, - /* 220 */ 1372, 1271, 1271, 1349, 1353, 1392, 1357, 1392, 1392, 1392, - /* 230 */ 1446, 1419, 1446, 1419, 1368, 363, 1451, 363, 1459, 1460, - /* 240 */ 363, 1459, 363, 1463, 363, 363, 1392, 363, 1446, 38, + /* 190 */ 1183, 396, 893, 383, 383, 862, 970, 1000, 931, 970, + /* 200 */ 1204, 1093, 491, 1111, 1334, 1346, 1370, 1181, 220, 1370, + /* 210 */ 220, 1213, 1393, 1397, 1396, 1397, 1396, 1275, 1393, 1397, + /* 220 */ 1393, 1396, 1275, 1275, 1352, 1356, 1393, 1360, 1393, 1393, + /* 230 */ 1393, 1449, 1420, 1449, 1420, 1370, 220, 1455, 220, 1462, + /* 240 */ 1465, 220, 1462, 220, 1467, 220, 220, 1393, 220, 1449, /* 250 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - /* 260 */ 1392, 73, 73, 1446, 486, 486, 486, 1294, 1409, 1368, - /* 270 */ 395, 1317, 1319, 1451, 395, 1322, 1110, 1392, 486, 1264, - /* 280 */ 1267, 1264, 1267, 1261, 1359, 1264, 1270, 1275, 1291, 1110, - /* 290 */ 1269, 1273, 1279, 1305, 1393, 1557, 1464, 1314, 1459, 395, - /* 300 */ 395, 1267, 486, 486, 486, 486, 1267, 486, 1425, 395, - /* 310 */ 520, 395, 1393, 1503, 1504, 486, 594, 1392, 395, 1593, - /* 320 */ 1582, 1446, 3640, 3640, 3640, 3640, 3640, 3640, 3640, 3640, + /* 260 */ 38, 1393, 73, 73, 1449, 486, 486, 486, 1298, 1408, + /* 270 */ 1370, 363, 1316, 1319, 1455, 363, 1326, 1111, 1393, 486, + /* 280 */ 1267, 1270, 1267, 1270, 1260, 1369, 1267, 1274, 1277, 1294, + /* 290 */ 1111, 1281, 1282, 1285, 1305, 1397, 1557, 1474, 1324, 1462, + /* 300 */ 363, 363, 1270, 486, 486, 486, 486, 1270, 486, 1427, + /* 310 */ 363, 520, 363, 1397, 1505, 1509, 486, 1393, 363, 1596, + /* 320 */ 1584, 1449, 3640, 3640, 3640, 3640, 3640, 3640, 3640, 3640, /* 330 */ 3640, 36, 634, 252, 342, 967, 53, 629, 307, 513, /* 340 */ 652, 879, 898, 795, 795, 795, 795, 795, 795, 795, /* 350 */ 795, 795, 764, 567, 166, 304, 304, 638, 822, 937, /* 360 */ 206, 483, 654, 812, 87, 867, 867, 1160, 1141, 351, - /* 370 */ 1160, 1160, 1160, 1205, 1124, 30, 1231, 1199, 208, 768, - /* 380 */ 1127, 1128, 1129, 1133, 503, 644, 1249, 1250, 1257, 1039, - /* 390 */ 839, 1210, 1159, 1219, 1221, 1225, 1120, 1117, 1213, 1236, - /* 400 */ 1241, 1242, 1243, 1244, 1248, 1282, 1252, 1190, 1253, 1215, - /* 410 */ 1254, 1255, 1256, 1260, 1262, 1263, 1176, 1147, 1265, 1277, - /* 420 */ 1287, 1233, 1278, 1625, 1635, 1636, 1592, 1640, 1608, 1432, - /* 430 */ 1609, 1617, 1618, 1436, 1658, 1623, 1624, 1441, 1626, 1665, - /* 440 */ 1445, 1667, 1631, 1670, 1649, 1672, 1637, 1457, 1675, 1472, - /* 450 */ 1677, 1474, 1475, 1481, 1487, 1681, 1685, 1686, 1495, 1497, - /* 460 */ 1689, 1691, 1545, 1645, 1646, 1693, 1660, 1648, 1700, 1652, - /* 470 */ 1702, 1659, 1703, 1705, 1706, 1662, 1707, 1708, 1709, 1712, - /* 480 */ 1713, 1714, 1554, 1679, 1717, 1558, 1718, 1720, 1721, 1723, - /* 490 */ 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, - /* 500 */ 1739, 1740, 1688, 1747, 1735, 1750, 1751, 1752, 1754, 1756, - /* 510 */ 1757, 1736, 1762, 1616, 1766, 1627, 1775, 1634, 1776, 1782, - /* 520 */ 1761, 1738, 1765, 1742, 1784, 1741, 1753, 1793, 1743, 1794, - /* 530 */ 1744, 1795, 1796, 1760, 1748, 1758, 1798, 1764, 1759, 1767, - /* 540 */ 1802, 1774, 1763, 1770, 1803, 1778, 1804, 1768, 1777, 1783, - /* 550 */ 1772, 1773, 1809, 1780, 1817, 1781, 1785, 1825, 1826, 1830, - /* 560 */ 1790, 1653, 1842, 1772, 1800, 1843, 1844, 1779, 1845, 1847, - /* 570 */ 1814, 1805, 1812, 1858, 1822, 1810, 1820, 1869, 1835, 1824, - /* 580 */ 1829, 1876, 1841, 1828, 1838, 1883, 1884, 1885, 1887, 1890, - /* 590 */ 1891, 1786, 1787, 1855, 1871, 1894, 1859, 1860, 1864, 1865, - /* 600 */ 1866, 1867, 1870, 1872, 1862, 1873, 1875, 1882, 1886, 1889, - /* 610 */ 1910, 1898, 1921, 1900, 1874, 1923, 1902, 1892, 1937, 1952, - /* 620 */ 1954, 1903, 1941, 1905, 1943, 1922, 1925, 1909, 1911, 1912, - /* 630 */ 1840, 1849, 1950, 1788, 1850, 1792, 1920, 1938, 1961, 1769, - /* 640 */ 1944, 1789, 1797, 1963, 1967, 1799, 1801, 1806, 1808, 1966, - /* 650 */ 1945, 1710, 1877, 1878, 1880, 1927, 1904, 1929, 1908, 1881, - /* 660 */ 1947, 1956, 1895, 1901, 1907, 1915, 1897, 1973, 1962, 1965, - /* 670 */ 1917, 1991, 1716, 1919, 1924, 1968, 1992, 1771, 1990, 1993, - /* 680 */ 1998, 1999, 2000, 2001, 1933, 1934, 1979, 1791, 2010, 1995, - /* 690 */ 2048, 2049, 1946, 2004, 1948, 1949, 1953, 1951, 1955, 1888, - /* 700 */ 1957, 2053, 2020, 1893, 1958, 1959, 1772, 2016, 2033, 1969, - /* 710 */ 1816, 1971, 2067, 2054, 1851, 1964, 1970, 1972, 1974, 1976, - /* 720 */ 1981, 2031, 1977, 1980, 2040, 1989, 2077, 1879, 1996, 1985, - /* 730 */ 1997, 2066, 2069, 2002, 2006, 2070, 2003, 2008, 2074, 2011, - /* 740 */ 2009, 2081, 2013, 2014, 2083, 2017, 2015, 2087, 2019, 2005, - /* 750 */ 2007, 2012, 2018, 2021, 2095, 2023, 2093, 2029, 2095, 2095, - /* 760 */ 2114, 2071, 2076, 2100, 2104, 2106, 2107, 2110, 2111, 2112, - /* 770 */ 2113, 2115, 2079, 2063, 2120, 2128, 2129, 2130, 2147, 2133, - /* 780 */ 2134, 2135, 2096, 1862, 2137, 1873, 2138, 2141, 2142, 2144, - /* 790 */ 2154, 2152, 2191, 2155, 2143, 2151, 2197, 2161, 2148, 2158, - /* 800 */ 2201, 2165, 2153, 2163, 2203, 2169, 2160, 2167, 2207, 2175, - /* 810 */ 2176, 2214, 2193, 2183, 2195, 2198, 2196, 2199, 2204, 2200, + /* 370 */ 1160, 1160, 1160, 1133, 1124, 30, 1236, 1205, 208, 768, + /* 380 */ 1130, 1131, 1132, 1142, 503, 644, 1223, 1252, 1253, 1044, + /* 390 */ 839, 1172, 1182, 1224, 1229, 1230, 1127, 1078, 1117, 1231, + /* 400 */ 1234, 1238, 1240, 1243, 1244, 1279, 1249, 1190, 1250, 1237, + /* 410 */ 1251, 1255, 1256, 1262, 1263, 1269, 1185, 1248, 1276, 1280, + /* 420 */ 1290, 1278, 1272, 1636, 1638, 1640, 1597, 1645, 1609, 1431, + /* 430 */ 1616, 1618, 1620, 1437, 1659, 1623, 1624, 1441, 1626, 1664, + /* 440 */ 1444, 1666, 1631, 1671, 1650, 1673, 1637, 1459, 1676, 1473, + /* 450 */ 1678, 1475, 1476, 1482, 1487, 1685, 1686, 1687, 1496, 1498, + /* 460 */ 1691, 1692, 1546, 1646, 1648, 1694, 1662, 1649, 1701, 1653, + /* 470 */ 1703, 1660, 1704, 1706, 1707, 1663, 1708, 1709, 1713, 1714, + /* 480 */ 1715, 1716, 1556, 1674, 1718, 1558, 1720, 1721, 1723, 1725, + /* 490 */ 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1739, + /* 500 */ 1740, 1747, 1688, 1750, 1712, 1751, 1752, 1754, 1756, 1758, + /* 510 */ 1762, 1741, 1766, 1628, 1773, 1630, 1779, 1635, 1782, 1783, + /* 520 */ 1765, 1738, 1768, 1742, 1784, 1735, 1757, 1793, 1736, 1795, + /* 530 */ 1743, 1796, 1797, 1761, 1753, 1759, 1802, 1771, 1760, 1763, + /* 540 */ 1803, 1772, 1764, 1770, 1810, 1776, 1814, 1774, 1775, 1788, + /* 550 */ 1767, 1777, 1808, 1778, 1823, 1781, 1787, 1825, 1830, 1832, + /* 560 */ 1798, 1655, 1843, 1767, 1800, 1844, 1845, 1780, 1847, 1850, + /* 570 */ 1817, 1805, 1816, 1859, 1824, 1811, 1827, 1871, 1835, 1828, + /* 580 */ 1833, 1876, 1841, 1829, 1842, 1883, 1885, 1887, 1890, 1891, + /* 590 */ 1892, 1785, 1789, 1856, 1872, 1895, 1860, 1863, 1865, 1866, + /* 600 */ 1867, 1869, 1870, 1873, 1875, 1879, 1882, 1884, 1874, 1886, + /* 610 */ 1909, 1898, 1922, 1902, 1888, 1926, 1905, 1900, 1929, 1942, + /* 620 */ 1943, 1903, 1944, 1908, 1946, 1925, 1928, 1912, 1913, 1915, + /* 630 */ 1848, 1851, 1954, 1790, 1855, 1786, 1919, 1938, 1963, 1769, + /* 640 */ 1945, 1799, 1792, 1964, 1965, 1801, 1804, 1806, 1812, 1966, + /* 650 */ 1947, 1705, 1877, 1878, 1880, 1931, 1904, 1934, 1889, 1881, + /* 660 */ 1969, 1971, 1899, 1901, 1907, 1917, 1914, 1977, 1930, 1962, + /* 670 */ 1920, 1981, 1791, 1921, 1923, 1975, 1991, 1794, 1988, 1990, + /* 680 */ 1994, 1998, 1999, 2000, 1933, 1935, 1989, 1809, 2008, 1995, + /* 690 */ 2043, 2048, 1948, 2004, 1949, 1950, 1953, 1955, 1957, 1894, + /* 700 */ 1958, 2049, 2010, 1893, 1960, 1941, 1767, 2018, 2020, 1972, + /* 710 */ 1818, 1973, 2066, 2053, 1852, 1976, 1974, 1980, 1982, 1993, + /* 720 */ 1996, 2021, 2001, 2002, 2029, 1997, 2057, 1857, 2003, 1967, + /* 730 */ 2006, 2059, 2064, 2005, 2009, 2065, 2011, 2012, 2069, 2014, + /* 740 */ 2015, 2078, 2017, 2022, 2081, 2019, 2023, 2084, 2026, 1983, + /* 750 */ 2007, 2016, 2025, 2030, 2091, 2031, 2090, 2033, 2091, 2091, + /* 760 */ 2106, 2070, 2072, 2098, 2107, 2108, 2109, 2110, 2111, 2112, + /* 770 */ 2113, 2116, 2079, 2063, 2088, 2067, 2133, 2132, 2134, 2135, + /* 780 */ 2148, 2136, 2137, 2138, 2099, 1875, 2141, 1879, 2142, 2144, + /* 790 */ 2152, 2154, 2170, 2157, 2193, 2160, 2147, 2158, 2199, 2164, + /* 800 */ 2151, 2161, 2204, 2168, 2155, 2165, 2209, 2174, 2162, 2172, + /* 810 */ 2212, 2178, 2179, 2217, 2196, 2186, 2198, 2200, 2202, 2203, + /* 820 */ 2201, 2206, }; #define YY_REDUCE_COUNT (330) #define YY_REDUCE_MIN (-469) @@ -1439,110 +1096,111 @@ static const short yy_reduce_ofst[] = { /* 110 */ -422, -422, -200, -273, -251, 117, 158, 229, 231, 246, /* 120 */ 340, 355, 390, 392, 436, 449, 479, 537, 643, 714, /* 130 */ 735, 745, 771, 107, 438, -230, 612, 814, 849, 725, - /* 140 */ 438, 694, 762, 366, 457, 631, 780, 135, -55, -389, - /* 150 */ 274, 116, 708, 710, 591, 732, 811, 840, 848, 865, - /* 160 */ -386, -381, 239, 416, 427, 516, 522, 427, 415, 888, - /* 170 */ 625, 866, 790, 824, 939, 829, 936, 936, 950, 954, - /* 180 */ 921, 922, 847, 851, 857, 915, 863, 936, 975, 942, - /* 190 */ 998, 997, 964, 960, 961, 936, 894, 894, 881, 894, - /* 200 */ 911, 901, 955, 940, 944, 956, 957, 1024, 969, 1026, - /* 210 */ 980, 1048, 1053, 1012, 1080, 1033, 1038, 1086, 1087, 1089, - /* 220 */ 1040, 1044, 1045, 1081, 1084, 1097, 1088, 1100, 1101, 1102, - /* 230 */ 1114, 1115, 1121, 1116, 1036, 1106, 1073, 1108, 1119, 1056, - /* 240 */ 1125, 1123, 1126, 1069, 1130, 1131, 1138, 1132, 1134, 1099, - /* 250 */ 1104, 1107, 1122, 1135, 1137, 1139, 1140, 1142, 1143, 1144, - /* 260 */ 1146, 1151, 1156, 1155, 1109, 1111, 1112, 1076, 1082, 1083, - /* 270 */ 1149, 1090, 1095, 1145, 1154, 1103, 1148, 1178, 1157, 1058, - /* 280 */ 1150, 1060, 1152, 1061, 1059, 1074, 1077, 1085, 1092, 1153, - /* 290 */ 1062, 1067, 1078, 894, 1214, 1158, 1161, 1162, 1226, 1223, - /* 300 */ 1224, 1173, 1192, 1194, 1196, 1197, 1180, 1201, 1193, 1238, - /* 310 */ 1222, 1239, 1258, 1163, 1218, 1217, 1237, 1268, 1266, 1272, - /* 320 */ 1280, 1274, 1195, 1186, 1204, 1209, 1259, 1276, 1281, 1284, - /* 330 */ 1286, + /* 140 */ 438, 694, 762, 366, 457, 631, 196, 780, 161, -55, + /* 150 */ -389, 274, 649, 733, 811, 591, 824, 826, 847, 865, + /* 160 */ -386, -381, 239, 281, 416, 427, 516, 416, 415, 534, + /* 170 */ 625, 852, 785, 801, 946, 830, 932, 932, 948, 949, + /* 180 */ 914, 916, 842, 845, 859, 925, 863, 932, 975, 950, + /* 190 */ 1001, 998, 968, 960, 961, 932, 903, 903, 883, 903, + /* 200 */ 913, 904, 1003, 958, 944, 952, 962, 956, 1034, 971, + /* 210 */ 1037, 985, 1054, 1061, 1033, 1083, 1035, 1042, 1090, 1091, + /* 220 */ 1094, 1041, 1046, 1048, 1084, 1087, 1100, 1092, 1102, 1106, + /* 230 */ 1107, 1118, 1115, 1120, 1119, 1043, 1110, 1077, 1112, 1121, + /* 240 */ 1060, 1125, 1126, 1129, 1076, 1135, 1137, 1139, 1138, 1143, + /* 250 */ 1122, 1123, 1128, 1134, 1140, 1144, 1145, 1149, 1151, 1152, + /* 260 */ 1153, 1148, 1150, 1158, 1147, 1101, 1109, 1114, 1057, 1080, + /* 270 */ 1085, 1154, 1089, 1095, 1155, 1157, 1097, 1146, 1171, 1156, + /* 280 */ 1049, 1159, 1063, 1161, 1062, 1074, 1064, 1079, 1082, 1086, + /* 290 */ 1163, 1066, 1068, 1071, 903, 1214, 1162, 1103, 1116, 1233, + /* 300 */ 1226, 1232, 1178, 1197, 1201, 1202, 1203, 1186, 1207, 1194, + /* 310 */ 1254, 1225, 1257, 1258, 1164, 1227, 1215, 1265, 1259, 1273, + /* 320 */ 1283, 1286, 1200, 1198, 1209, 1212, 1271, 1284, 1287, 1266, + /* 330 */ 1289, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 10 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 20 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 30 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 40 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 50 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 60 */ 2176, 1847, 1847, 2139, 1847, 1847, 1847, 1847, 1847, 1847, - /* 70 */ 1847, 1847, 1847, 1847, 1847, 2146, 1847, 1847, 1847, 1847, - /* 80 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 90 */ 1847, 1847, 1847, 1943, 1847, 1847, 1847, 1847, 1847, 1847, - /* 100 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1941, - /* 110 */ 2373, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 120 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 130 */ 1847, 1847, 1847, 1847, 2385, 1847, 1847, 1917, 1917, 1847, - /* 140 */ 2385, 2385, 2385, 1941, 2345, 2345, 1847, 1943, 2210, 1847, - /* 150 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2065, 1847, 1877, - /* 160 */ 1847, 1847, 1847, 1847, 2089, 1847, 1847, 1847, 2202, 1847, - /* 170 */ 1847, 2414, 2474, 1847, 1847, 2417, 1847, 1847, 1847, 1847, - /* 180 */ 2151, 2404, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 190 */ 1847, 1847, 2018, 1847, 1847, 1847, 2377, 2391, 2458, 2378, - /* 200 */ 2375, 2398, 2408, 1847, 2234, 1847, 2224, 1943, 1847, 1943, - /* 210 */ 2189, 2134, 1847, 2144, 1847, 2144, 2141, 1847, 1847, 1847, - /* 220 */ 2144, 2141, 2141, 2007, 2003, 1847, 2001, 1847, 1847, 1847, - /* 230 */ 1847, 1901, 1847, 1901, 1847, 1943, 1847, 1943, 1847, 1847, - /* 240 */ 1943, 1847, 1943, 1847, 1943, 1943, 1847, 1943, 1847, 1847, - /* 250 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 260 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2222, 2208, 1847, - /* 270 */ 1941, 2200, 2198, 1847, 1941, 2196, 2408, 1847, 1847, 2428, - /* 280 */ 2423, 2428, 2423, 2442, 2438, 2428, 2447, 2444, 2410, 2408, - /* 290 */ 2477, 2464, 2460, 2391, 1847, 1847, 2396, 2394, 1847, 1941, - /* 300 */ 1941, 2423, 1847, 1847, 1847, 1847, 2423, 1847, 1847, 1941, - /* 310 */ 1847, 1941, 1847, 1847, 2034, 1847, 1847, 1847, 1941, 1847, - /* 320 */ 1886, 1847, 2191, 2213, 2172, 2172, 2068, 2068, 2068, 1944, - /* 330 */ 1852, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 340 */ 1847, 1847, 1847, 2441, 2440, 2298, 1847, 2349, 2348, 2347, - /* 350 */ 2338, 2297, 2030, 1847, 1847, 2296, 2295, 1847, 1847, 1847, - /* 360 */ 1847, 1847, 1847, 1847, 1847, 2163, 2162, 2289, 1847, 1847, - /* 370 */ 2290, 2288, 2287, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 380 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 390 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2461, 2465, 1847, - /* 400 */ 1847, 1847, 1847, 1847, 1847, 2374, 1847, 1847, 1847, 2270, - /* 410 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 420 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 430 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 440 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 450 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 460 */ 1847, 1847, 2140, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 470 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 480 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 490 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 500 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 510 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2155, 1847, 1847, - /* 520 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 530 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 540 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1891, - /* 550 */ 2276, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 560 */ 1847, 1847, 1847, 2279, 1847, 1847, 1847, 1847, 1847, 1847, - /* 570 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 580 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 590 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 600 */ 1847, 1847, 1847, 1847, 1983, 1982, 1847, 1847, 1847, 1847, - /* 610 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 620 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 630 */ 2280, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 640 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2457, - /* 650 */ 2411, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 660 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2270, - /* 670 */ 1847, 2439, 1847, 1847, 2455, 1847, 2459, 1847, 1847, 1847, - /* 680 */ 1847, 1847, 1847, 1847, 2384, 2380, 1847, 1847, 2376, 1847, - /* 690 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 700 */ 1847, 1847, 1847, 1847, 1847, 1847, 2269, 1847, 2335, 1847, - /* 710 */ 1847, 1847, 2369, 1847, 1847, 2320, 1847, 1847, 1847, 1847, - /* 720 */ 1847, 1847, 1847, 1847, 1847, 2280, 1847, 2283, 1847, 1847, - /* 730 */ 1847, 1847, 1847, 2062, 1847, 1847, 1847, 1847, 1847, 1847, - /* 740 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 2046, - /* 750 */ 2044, 2043, 2042, 1847, 2075, 1847, 1847, 1847, 2071, 2070, - /* 760 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 770 */ 1847, 1847, 1847, 1847, 1962, 1847, 1847, 1847, 1847, 1847, - /* 780 */ 1847, 1847, 1847, 1954, 1847, 1953, 1847, 1847, 1847, 1847, - /* 790 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 800 */ 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, 1847, - /* 810 */ 1847, 1847, 1847, 1876, 1847, 1847, 1847, 1847, 1847, 1847, + /* 0 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 10 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 20 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 30 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 40 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 50 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 60 */ 2181, 1851, 1851, 2144, 1851, 1851, 1851, 1851, 1851, 1851, + /* 70 */ 1851, 1851, 1851, 1851, 1851, 2151, 1851, 1851, 1851, 1851, + /* 80 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 90 */ 1851, 1851, 1851, 1947, 1851, 1851, 1851, 1851, 1851, 1851, + /* 100 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1945, + /* 110 */ 2378, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 120 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 130 */ 1851, 1851, 1851, 1851, 2390, 1851, 1851, 1921, 1921, 1851, + /* 140 */ 2390, 2390, 2390, 1945, 2350, 2350, 1851, 1851, 1947, 2215, + /* 150 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2070, 1881, + /* 160 */ 1851, 1851, 1851, 1851, 2094, 1851, 1851, 1851, 2207, 1851, + /* 170 */ 1851, 2419, 2479, 1851, 1851, 2422, 1851, 1851, 1851, 1851, + /* 180 */ 2156, 2409, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 190 */ 1851, 1851, 2023, 1851, 1851, 1851, 2382, 2396, 2463, 2383, + /* 200 */ 2380, 2403, 1851, 2413, 1851, 2239, 1851, 2229, 1947, 1851, + /* 210 */ 1947, 2194, 2139, 1851, 2149, 1851, 2149, 2146, 1851, 1851, + /* 220 */ 1851, 2149, 2146, 2146, 2012, 2008, 1851, 2006, 1851, 1851, + /* 230 */ 1851, 1851, 1905, 1851, 1905, 1851, 1947, 1851, 1947, 1851, + /* 240 */ 1851, 1947, 1851, 1947, 1851, 1947, 1947, 1851, 1947, 1851, + /* 250 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 260 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2227, 2213, + /* 270 */ 1851, 1945, 2205, 2203, 1851, 1945, 2201, 2413, 1851, 1851, + /* 280 */ 2433, 2428, 2433, 2428, 2447, 2443, 2433, 2452, 2449, 2415, + /* 290 */ 2413, 2482, 2469, 2465, 2396, 1851, 1851, 2401, 2399, 1851, + /* 300 */ 1945, 1945, 2428, 1851, 1851, 1851, 1851, 2428, 1851, 1851, + /* 310 */ 1945, 1851, 1945, 1851, 1851, 2039, 1851, 1851, 1945, 1851, + /* 320 */ 1890, 1851, 2196, 2218, 2177, 2177, 2073, 2073, 2073, 1948, + /* 330 */ 1856, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 340 */ 1851, 1851, 1851, 2446, 2445, 2303, 1851, 2354, 2353, 2352, + /* 350 */ 2343, 2302, 2035, 1851, 1851, 2301, 2300, 1851, 1851, 1851, + /* 360 */ 1851, 1851, 1851, 1851, 1851, 2168, 2167, 2294, 1851, 1851, + /* 370 */ 2295, 2293, 2292, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 380 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 390 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2466, 2470, 1851, + /* 400 */ 1851, 1851, 1851, 1851, 1851, 2379, 1851, 1851, 1851, 2275, + /* 410 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 420 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 430 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 440 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 450 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 460 */ 1851, 1851, 2145, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 470 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 480 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 490 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 500 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 510 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2160, 1851, 1851, + /* 520 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 530 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 540 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1895, + /* 550 */ 2281, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 560 */ 1851, 1851, 1851, 2284, 1851, 1851, 1851, 1851, 1851, 1851, + /* 570 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 580 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 590 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 600 */ 1851, 1851, 1851, 1851, 1987, 1986, 1851, 1851, 1851, 1851, + /* 610 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 620 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 630 */ 2285, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 640 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2462, + /* 650 */ 2416, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 660 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2275, + /* 670 */ 1851, 2444, 1851, 1851, 2460, 1851, 2464, 1851, 1851, 1851, + /* 680 */ 1851, 1851, 1851, 1851, 2389, 2385, 1851, 1851, 2381, 1851, + /* 690 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 700 */ 1851, 1851, 1851, 1851, 1851, 1851, 2274, 1851, 2340, 1851, + /* 710 */ 1851, 1851, 2374, 1851, 1851, 2325, 1851, 1851, 1851, 1851, + /* 720 */ 1851, 1851, 1851, 1851, 1851, 2285, 1851, 2288, 1851, 1851, + /* 730 */ 1851, 1851, 1851, 2067, 1851, 1851, 1851, 1851, 1851, 1851, + /* 740 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 2051, + /* 750 */ 2049, 2048, 2047, 1851, 2080, 1851, 1851, 1851, 2076, 2075, + /* 760 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 770 */ 1851, 1851, 1851, 1851, 1851, 1851, 1966, 1851, 1851, 1851, + /* 780 */ 1851, 1851, 1851, 1851, 1851, 1958, 1851, 1957, 1851, 1851, + /* 790 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 800 */ 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, + /* 810 */ 1851, 1851, 1851, 1851, 1851, 1880, 1851, 1851, 1851, 1851, + /* 820 */ 1851, 1851, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1960,7 +1618,6 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include -#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -2657,485 +2314,486 @@ static const char *const yyRuleName[] = { /* 148 */ "retention_list ::= retention", /* 149 */ "retention_list ::= retention_list NK_COMMA retention", /* 150 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 151 */ "speed_opt ::=", - /* 152 */ "speed_opt ::= BWLIMIT NK_INTEGER", - /* 153 */ "start_opt ::=", - /* 154 */ "start_opt ::= START WITH NK_INTEGER", - /* 155 */ "start_opt ::= START WITH NK_STRING", - /* 156 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", - /* 157 */ "end_opt ::=", - /* 158 */ "end_opt ::= END WITH NK_INTEGER", - /* 159 */ "end_opt ::= END WITH NK_STRING", - /* 160 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", - /* 161 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 162 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 163 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 164 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 165 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 166 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 167 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 168 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 169 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 170 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 171 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 172 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 173 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 174 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 175 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 176 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 177 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 178 */ "multi_create_clause ::= create_subtable_clause", - /* 179 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 180 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 181 */ "multi_drop_clause ::= drop_table_clause", - /* 182 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", - /* 183 */ "drop_table_clause ::= exists_opt full_table_name", - /* 184 */ "specific_cols_opt ::=", - /* 185 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 186 */ "full_table_name ::= table_name", - /* 187 */ "full_table_name ::= db_name NK_DOT table_name", - /* 188 */ "column_def_list ::= column_def", - /* 189 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 190 */ "column_def ::= column_name type_name", - /* 191 */ "type_name ::= BOOL", - /* 192 */ "type_name ::= TINYINT", - /* 193 */ "type_name ::= SMALLINT", - /* 194 */ "type_name ::= INT", - /* 195 */ "type_name ::= INTEGER", - /* 196 */ "type_name ::= BIGINT", - /* 197 */ "type_name ::= FLOAT", - /* 198 */ "type_name ::= DOUBLE", - /* 199 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 200 */ "type_name ::= TIMESTAMP", - /* 201 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 202 */ "type_name ::= TINYINT UNSIGNED", - /* 203 */ "type_name ::= SMALLINT UNSIGNED", - /* 204 */ "type_name ::= INT UNSIGNED", - /* 205 */ "type_name ::= BIGINT UNSIGNED", - /* 206 */ "type_name ::= JSON", - /* 207 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 208 */ "type_name ::= MEDIUMBLOB", - /* 209 */ "type_name ::= BLOB", - /* 210 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 211 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", - /* 212 */ "type_name ::= DECIMAL", - /* 213 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 214 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 215 */ "tags_def_opt ::=", - /* 216 */ "tags_def_opt ::= tags_def", - /* 217 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 218 */ "table_options ::=", - /* 219 */ "table_options ::= table_options COMMENT NK_STRING", - /* 220 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 221 */ "table_options ::= table_options WATERMARK duration_list", - /* 222 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 223 */ "table_options ::= table_options TTL NK_INTEGER", - /* 224 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 225 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 226 */ "alter_table_options ::= alter_table_option", - /* 227 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 228 */ "alter_table_option ::= COMMENT NK_STRING", - /* 229 */ "alter_table_option ::= TTL NK_INTEGER", - /* 230 */ "duration_list ::= duration_literal", - /* 231 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 232 */ "rollup_func_list ::= rollup_func_name", - /* 233 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 234 */ "rollup_func_name ::= function_name", - /* 235 */ "rollup_func_name ::= FIRST", - /* 236 */ "rollup_func_name ::= LAST", - /* 237 */ "col_name_list ::= col_name", - /* 238 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 239 */ "col_name ::= column_name", - /* 240 */ "cmd ::= SHOW DNODES", - /* 241 */ "cmd ::= SHOW USERS", - /* 242 */ "cmd ::= SHOW USER PRIVILEGES", - /* 243 */ "cmd ::= SHOW db_kind_opt DATABASES", - /* 244 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", - /* 245 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 246 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 247 */ "cmd ::= SHOW MNODES", - /* 248 */ "cmd ::= SHOW QNODES", - /* 249 */ "cmd ::= SHOW FUNCTIONS", - /* 250 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 251 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", - /* 252 */ "cmd ::= SHOW STREAMS", - /* 253 */ "cmd ::= SHOW ACCOUNTS", - /* 254 */ "cmd ::= SHOW APPS", - /* 255 */ "cmd ::= SHOW CONNECTIONS", - /* 256 */ "cmd ::= SHOW LICENCES", - /* 257 */ "cmd ::= SHOW GRANTS", - /* 258 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 259 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 260 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 261 */ "cmd ::= SHOW QUERIES", - /* 262 */ "cmd ::= SHOW SCORES", - /* 263 */ "cmd ::= SHOW TOPICS", - /* 264 */ "cmd ::= SHOW VARIABLES", - /* 265 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 266 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 267 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 268 */ "cmd ::= SHOW BNODES", - /* 269 */ "cmd ::= SHOW SNODES", - /* 270 */ "cmd ::= SHOW CLUSTER", - /* 271 */ "cmd ::= SHOW TRANSACTIONS", - /* 272 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 273 */ "cmd ::= SHOW CONSUMERS", - /* 274 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 275 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 276 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", - /* 277 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 278 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", - /* 279 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", - /* 280 */ "cmd ::= SHOW VNODES", - /* 281 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 282 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 283 */ "table_kind_db_name_cond_opt ::=", - /* 284 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 285 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 286 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 287 */ "table_kind ::= NORMAL", - /* 288 */ "table_kind ::= CHILD", - /* 289 */ "db_name_cond_opt ::=", - /* 290 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 291 */ "like_pattern_opt ::=", - /* 292 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 293 */ "table_name_cond ::= table_name", - /* 294 */ "from_db_opt ::=", - /* 295 */ "from_db_opt ::= FROM db_name", - /* 296 */ "tag_list_opt ::=", - /* 297 */ "tag_list_opt ::= tag_item", - /* 298 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 299 */ "tag_item ::= TBNAME", - /* 300 */ "tag_item ::= QTAGS", - /* 301 */ "tag_item ::= column_name", - /* 302 */ "tag_item ::= column_name column_alias", - /* 303 */ "tag_item ::= column_name AS column_alias", - /* 304 */ "db_kind_opt ::=", - /* 305 */ "db_kind_opt ::= USER", - /* 306 */ "db_kind_opt ::= SYSTEM", - /* 307 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 308 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 309 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 310 */ "full_index_name ::= index_name", - /* 311 */ "full_index_name ::= db_name NK_DOT index_name", - /* 312 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 313 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 314 */ "func_list ::= func", - /* 315 */ "func_list ::= func_list NK_COMMA func", - /* 316 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 317 */ "sma_func_name ::= function_name", - /* 318 */ "sma_func_name ::= COUNT", - /* 319 */ "sma_func_name ::= FIRST", - /* 320 */ "sma_func_name ::= LAST", - /* 321 */ "sma_func_name ::= LAST_ROW", - /* 322 */ "sma_stream_opt ::=", - /* 323 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 324 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 325 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 326 */ "with_meta ::= AS", - /* 327 */ "with_meta ::= WITH META AS", - /* 328 */ "with_meta ::= ONLY META AS", - /* 329 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 330 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 331 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 332 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 333 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 334 */ "cmd ::= DESC full_table_name", - /* 335 */ "cmd ::= DESCRIBE full_table_name", - /* 336 */ "cmd ::= RESET QUERY CACHE", - /* 337 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 338 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 339 */ "analyze_opt ::=", - /* 340 */ "analyze_opt ::= ANALYZE", - /* 341 */ "explain_options ::=", - /* 342 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 343 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 344 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 345 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 346 */ "agg_func_opt ::=", - /* 347 */ "agg_func_opt ::= AGGREGATE", - /* 348 */ "bufsize_opt ::=", - /* 349 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 350 */ "language_opt ::=", - /* 351 */ "language_opt ::= LANGUAGE NK_STRING", - /* 352 */ "or_replace_opt ::=", - /* 353 */ "or_replace_opt ::= OR REPLACE", - /* 354 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 355 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 356 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 357 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 358 */ "col_list_opt ::=", - /* 359 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 360 */ "tag_def_or_ref_opt ::=", - /* 361 */ "tag_def_or_ref_opt ::= tags_def", - /* 362 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 363 */ "stream_options ::=", - /* 364 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 365 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 366 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 367 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 368 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 369 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 370 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 371 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 372 */ "subtable_opt ::=", - /* 373 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 374 */ "ignore_opt ::=", - /* 375 */ "ignore_opt ::= IGNORE UNTREATED", - /* 376 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 377 */ "cmd ::= KILL QUERY NK_STRING", - /* 378 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 379 */ "cmd ::= BALANCE VGROUP", - /* 380 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 381 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 382 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 383 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 384 */ "on_vgroup_id ::=", - /* 385 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 386 */ "dnode_list ::= DNODE NK_INTEGER", - /* 387 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 388 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 389 */ "cmd ::= query_or_subquery", - /* 390 */ "cmd ::= insert_query", - /* 391 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 392 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 393 */ "literal ::= NK_INTEGER", - /* 394 */ "literal ::= NK_FLOAT", - /* 395 */ "literal ::= NK_STRING", - /* 396 */ "literal ::= NK_BOOL", - /* 397 */ "literal ::= TIMESTAMP NK_STRING", - /* 398 */ "literal ::= duration_literal", - /* 399 */ "literal ::= NULL", - /* 400 */ "literal ::= NK_QUESTION", - /* 401 */ "duration_literal ::= NK_VARIABLE", - /* 402 */ "signed ::= NK_INTEGER", - /* 403 */ "signed ::= NK_PLUS NK_INTEGER", - /* 404 */ "signed ::= NK_MINUS NK_INTEGER", - /* 405 */ "signed ::= NK_FLOAT", - /* 406 */ "signed ::= NK_PLUS NK_FLOAT", - /* 407 */ "signed ::= NK_MINUS NK_FLOAT", - /* 408 */ "signed_literal ::= signed", - /* 409 */ "signed_literal ::= NK_STRING", - /* 410 */ "signed_literal ::= NK_BOOL", - /* 411 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 412 */ "signed_literal ::= duration_literal", - /* 413 */ "signed_literal ::= NULL", - /* 414 */ "signed_literal ::= literal_func", - /* 415 */ "signed_literal ::= NK_QUESTION", - /* 416 */ "literal_list ::= signed_literal", - /* 417 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 418 */ "db_name ::= NK_ID", - /* 419 */ "table_name ::= NK_ID", - /* 420 */ "column_name ::= NK_ID", - /* 421 */ "function_name ::= NK_ID", - /* 422 */ "table_alias ::= NK_ID", - /* 423 */ "column_alias ::= NK_ID", - /* 424 */ "column_alias ::= NK_ALIAS", - /* 425 */ "user_name ::= NK_ID", - /* 426 */ "topic_name ::= NK_ID", - /* 427 */ "stream_name ::= NK_ID", - /* 428 */ "cgroup_name ::= NK_ID", - /* 429 */ "index_name ::= NK_ID", - /* 430 */ "expr_or_subquery ::= expression", - /* 431 */ "expression ::= literal", - /* 432 */ "expression ::= pseudo_column", - /* 433 */ "expression ::= column_reference", - /* 434 */ "expression ::= function_expression", - /* 435 */ "expression ::= case_when_expression", - /* 436 */ "expression ::= NK_LP expression NK_RP", - /* 437 */ "expression ::= NK_PLUS expr_or_subquery", - /* 438 */ "expression ::= NK_MINUS expr_or_subquery", - /* 439 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 440 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 441 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 442 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 443 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 444 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 445 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 446 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 447 */ "expression_list ::= expr_or_subquery", - /* 448 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 449 */ "column_reference ::= column_name", - /* 450 */ "column_reference ::= table_name NK_DOT column_name", - /* 451 */ "column_reference ::= NK_ALIAS", - /* 452 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 453 */ "pseudo_column ::= ROWTS", - /* 454 */ "pseudo_column ::= TBNAME", - /* 455 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 456 */ "pseudo_column ::= QSTART", - /* 457 */ "pseudo_column ::= QEND", - /* 458 */ "pseudo_column ::= QDURATION", - /* 459 */ "pseudo_column ::= WSTART", - /* 460 */ "pseudo_column ::= WEND", - /* 461 */ "pseudo_column ::= WDURATION", - /* 462 */ "pseudo_column ::= IROWTS", - /* 463 */ "pseudo_column ::= ISFILLED", - /* 464 */ "pseudo_column ::= QTAGS", - /* 465 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 466 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 467 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 468 */ "function_expression ::= literal_func", - /* 469 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 470 */ "literal_func ::= NOW", - /* 471 */ "noarg_func ::= NOW", - /* 472 */ "noarg_func ::= TODAY", - /* 473 */ "noarg_func ::= TIMEZONE", - /* 474 */ "noarg_func ::= DATABASE", - /* 475 */ "noarg_func ::= CLIENT_VERSION", - /* 476 */ "noarg_func ::= SERVER_VERSION", - /* 477 */ "noarg_func ::= SERVER_STATUS", - /* 478 */ "noarg_func ::= CURRENT_USER", - /* 479 */ "noarg_func ::= USER", - /* 480 */ "star_func ::= COUNT", - /* 481 */ "star_func ::= FIRST", - /* 482 */ "star_func ::= LAST", - /* 483 */ "star_func ::= LAST_ROW", - /* 484 */ "star_func_para_list ::= NK_STAR", - /* 485 */ "star_func_para_list ::= other_para_list", - /* 486 */ "other_para_list ::= star_func_para", - /* 487 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 488 */ "star_func_para ::= expr_or_subquery", - /* 489 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 490 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 491 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 492 */ "when_then_list ::= when_then_expr", - /* 493 */ "when_then_list ::= when_then_list when_then_expr", - /* 494 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 495 */ "case_when_else_opt ::=", - /* 496 */ "case_when_else_opt ::= ELSE common_expression", - /* 497 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 498 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 499 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 500 */ "predicate ::= expr_or_subquery IS NULL", - /* 501 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 502 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 503 */ "compare_op ::= NK_LT", - /* 504 */ "compare_op ::= NK_GT", - /* 505 */ "compare_op ::= NK_LE", - /* 506 */ "compare_op ::= NK_GE", - /* 507 */ "compare_op ::= NK_NE", - /* 508 */ "compare_op ::= NK_EQ", - /* 509 */ "compare_op ::= LIKE", - /* 510 */ "compare_op ::= NOT LIKE", - /* 511 */ "compare_op ::= MATCH", - /* 512 */ "compare_op ::= NMATCH", - /* 513 */ "compare_op ::= CONTAINS", - /* 514 */ "in_op ::= IN", - /* 515 */ "in_op ::= NOT IN", - /* 516 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 517 */ "boolean_value_expression ::= boolean_primary", - /* 518 */ "boolean_value_expression ::= NOT boolean_primary", - /* 519 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 520 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 521 */ "boolean_primary ::= predicate", - /* 522 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 523 */ "common_expression ::= expr_or_subquery", - /* 524 */ "common_expression ::= boolean_value_expression", - /* 525 */ "from_clause_opt ::=", - /* 526 */ "from_clause_opt ::= FROM table_reference_list", - /* 527 */ "table_reference_list ::= table_reference", - /* 528 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 529 */ "table_reference ::= table_primary", - /* 530 */ "table_reference ::= joined_table", - /* 531 */ "table_primary ::= table_name alias_opt", - /* 532 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 533 */ "table_primary ::= subquery alias_opt", - /* 534 */ "table_primary ::= parenthesized_joined_table", - /* 535 */ "alias_opt ::=", - /* 536 */ "alias_opt ::= table_alias", - /* 537 */ "alias_opt ::= AS table_alias", - /* 538 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 539 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 540 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 541 */ "join_type ::=", - /* 542 */ "join_type ::= INNER", - /* 543 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 544 */ "hint_list ::=", - /* 545 */ "hint_list ::= NK_HINT", - /* 546 */ "tag_mode_opt ::=", - /* 547 */ "tag_mode_opt ::= TAGS", - /* 548 */ "set_quantifier_opt ::=", - /* 549 */ "set_quantifier_opt ::= DISTINCT", - /* 550 */ "set_quantifier_opt ::= ALL", - /* 551 */ "select_list ::= select_item", - /* 552 */ "select_list ::= select_list NK_COMMA select_item", - /* 553 */ "select_item ::= NK_STAR", - /* 554 */ "select_item ::= common_expression", - /* 555 */ "select_item ::= common_expression column_alias", - /* 556 */ "select_item ::= common_expression AS column_alias", - /* 557 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 558 */ "where_clause_opt ::=", - /* 559 */ "where_clause_opt ::= WHERE search_condition", - /* 560 */ "partition_by_clause_opt ::=", - /* 561 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 562 */ "partition_list ::= partition_item", - /* 563 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 564 */ "partition_item ::= expr_or_subquery", - /* 565 */ "partition_item ::= expr_or_subquery column_alias", - /* 566 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 567 */ "twindow_clause_opt ::=", - /* 568 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 569 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 570 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 571 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 572 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 573 */ "sliding_opt ::=", - /* 574 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 575 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 576 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 577 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 578 */ "fill_opt ::=", - /* 579 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 580 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 581 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 582 */ "fill_mode ::= NONE", - /* 583 */ "fill_mode ::= PREV", - /* 584 */ "fill_mode ::= NULL", - /* 585 */ "fill_mode ::= NULL_F", - /* 586 */ "fill_mode ::= LINEAR", - /* 587 */ "fill_mode ::= NEXT", - /* 588 */ "group_by_clause_opt ::=", - /* 589 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 590 */ "group_by_list ::= expr_or_subquery", - /* 591 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 592 */ "having_clause_opt ::=", - /* 593 */ "having_clause_opt ::= HAVING search_condition", - /* 594 */ "range_opt ::=", - /* 595 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 596 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 597 */ "every_opt ::=", - /* 598 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 599 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 600 */ "query_simple ::= query_specification", - /* 601 */ "query_simple ::= union_query_expression", - /* 602 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 603 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 604 */ "query_simple_or_subquery ::= query_simple", - /* 605 */ "query_simple_or_subquery ::= subquery", - /* 606 */ "query_or_subquery ::= query_expression", - /* 607 */ "query_or_subquery ::= subquery", - /* 608 */ "order_by_clause_opt ::=", - /* 609 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 610 */ "slimit_clause_opt ::=", - /* 611 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 612 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 613 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 614 */ "limit_clause_opt ::=", - /* 615 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 616 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 617 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 618 */ "subquery ::= NK_LP query_expression NK_RP", - /* 619 */ "subquery ::= NK_LP subquery NK_RP", - /* 620 */ "search_condition ::= common_expression", - /* 621 */ "sort_specification_list ::= sort_specification", - /* 622 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 623 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 624 */ "ordering_specification_opt ::=", - /* 625 */ "ordering_specification_opt ::= ASC", - /* 626 */ "ordering_specification_opt ::= DESC", - /* 627 */ "null_ordering_opt ::=", - /* 628 */ "null_ordering_opt ::= NULLS FIRST", - /* 629 */ "null_ordering_opt ::= NULLS LAST", + /* 151 */ "retention ::= NK_MINUS NK_COLON NK_VARIABLE", + /* 152 */ "speed_opt ::=", + /* 153 */ "speed_opt ::= BWLIMIT NK_INTEGER", + /* 154 */ "start_opt ::=", + /* 155 */ "start_opt ::= START WITH NK_INTEGER", + /* 156 */ "start_opt ::= START WITH NK_STRING", + /* 157 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", + /* 158 */ "end_opt ::=", + /* 159 */ "end_opt ::= END WITH NK_INTEGER", + /* 160 */ "end_opt ::= END WITH NK_STRING", + /* 161 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", + /* 162 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 163 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 164 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 165 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 166 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 167 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 168 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 169 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 170 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 171 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 172 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 173 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 174 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 175 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 176 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 177 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 178 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 179 */ "multi_create_clause ::= create_subtable_clause", + /* 180 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 181 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 182 */ "multi_drop_clause ::= drop_table_clause", + /* 183 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", + /* 184 */ "drop_table_clause ::= exists_opt full_table_name", + /* 185 */ "specific_cols_opt ::=", + /* 186 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 187 */ "full_table_name ::= table_name", + /* 188 */ "full_table_name ::= db_name NK_DOT table_name", + /* 189 */ "column_def_list ::= column_def", + /* 190 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 191 */ "column_def ::= column_name type_name", + /* 192 */ "type_name ::= BOOL", + /* 193 */ "type_name ::= TINYINT", + /* 194 */ "type_name ::= SMALLINT", + /* 195 */ "type_name ::= INT", + /* 196 */ "type_name ::= INTEGER", + /* 197 */ "type_name ::= BIGINT", + /* 198 */ "type_name ::= FLOAT", + /* 199 */ "type_name ::= DOUBLE", + /* 200 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 201 */ "type_name ::= TIMESTAMP", + /* 202 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 203 */ "type_name ::= TINYINT UNSIGNED", + /* 204 */ "type_name ::= SMALLINT UNSIGNED", + /* 205 */ "type_name ::= INT UNSIGNED", + /* 206 */ "type_name ::= BIGINT UNSIGNED", + /* 207 */ "type_name ::= JSON", + /* 208 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 209 */ "type_name ::= MEDIUMBLOB", + /* 210 */ "type_name ::= BLOB", + /* 211 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 212 */ "type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP", + /* 213 */ "type_name ::= DECIMAL", + /* 214 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 215 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 216 */ "tags_def_opt ::=", + /* 217 */ "tags_def_opt ::= tags_def", + /* 218 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 219 */ "table_options ::=", + /* 220 */ "table_options ::= table_options COMMENT NK_STRING", + /* 221 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 222 */ "table_options ::= table_options WATERMARK duration_list", + /* 223 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 224 */ "table_options ::= table_options TTL NK_INTEGER", + /* 225 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 226 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 227 */ "alter_table_options ::= alter_table_option", + /* 228 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 229 */ "alter_table_option ::= COMMENT NK_STRING", + /* 230 */ "alter_table_option ::= TTL NK_INTEGER", + /* 231 */ "duration_list ::= duration_literal", + /* 232 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 233 */ "rollup_func_list ::= rollup_func_name", + /* 234 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 235 */ "rollup_func_name ::= function_name", + /* 236 */ "rollup_func_name ::= FIRST", + /* 237 */ "rollup_func_name ::= LAST", + /* 238 */ "col_name_list ::= col_name", + /* 239 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 240 */ "col_name ::= column_name", + /* 241 */ "cmd ::= SHOW DNODES", + /* 242 */ "cmd ::= SHOW USERS", + /* 243 */ "cmd ::= SHOW USER PRIVILEGES", + /* 244 */ "cmd ::= SHOW db_kind_opt DATABASES", + /* 245 */ "cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt", + /* 246 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 247 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 248 */ "cmd ::= SHOW MNODES", + /* 249 */ "cmd ::= SHOW QNODES", + /* 250 */ "cmd ::= SHOW FUNCTIONS", + /* 251 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 252 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", + /* 253 */ "cmd ::= SHOW STREAMS", + /* 254 */ "cmd ::= SHOW ACCOUNTS", + /* 255 */ "cmd ::= SHOW APPS", + /* 256 */ "cmd ::= SHOW CONNECTIONS", + /* 257 */ "cmd ::= SHOW LICENCES", + /* 258 */ "cmd ::= SHOW GRANTS", + /* 259 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 260 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 261 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 262 */ "cmd ::= SHOW QUERIES", + /* 263 */ "cmd ::= SHOW SCORES", + /* 264 */ "cmd ::= SHOW TOPICS", + /* 265 */ "cmd ::= SHOW VARIABLES", + /* 266 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 267 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 268 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 269 */ "cmd ::= SHOW BNODES", + /* 270 */ "cmd ::= SHOW SNODES", + /* 271 */ "cmd ::= SHOW CLUSTER", + /* 272 */ "cmd ::= SHOW TRANSACTIONS", + /* 273 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 274 */ "cmd ::= SHOW CONSUMERS", + /* 275 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 276 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 277 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", + /* 278 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 279 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", + /* 280 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", + /* 281 */ "cmd ::= SHOW VNODES", + /* 282 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 283 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 284 */ "table_kind_db_name_cond_opt ::=", + /* 285 */ "table_kind_db_name_cond_opt ::= table_kind", + /* 286 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", + /* 287 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", + /* 288 */ "table_kind ::= NORMAL", + /* 289 */ "table_kind ::= CHILD", + /* 290 */ "db_name_cond_opt ::=", + /* 291 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 292 */ "like_pattern_opt ::=", + /* 293 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 294 */ "table_name_cond ::= table_name", + /* 295 */ "from_db_opt ::=", + /* 296 */ "from_db_opt ::= FROM db_name", + /* 297 */ "tag_list_opt ::=", + /* 298 */ "tag_list_opt ::= tag_item", + /* 299 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 300 */ "tag_item ::= TBNAME", + /* 301 */ "tag_item ::= QTAGS", + /* 302 */ "tag_item ::= column_name", + /* 303 */ "tag_item ::= column_name column_alias", + /* 304 */ "tag_item ::= column_name AS column_alias", + /* 305 */ "db_kind_opt ::=", + /* 306 */ "db_kind_opt ::= USER", + /* 307 */ "db_kind_opt ::= SYSTEM", + /* 308 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 309 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 310 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 311 */ "full_index_name ::= index_name", + /* 312 */ "full_index_name ::= db_name NK_DOT index_name", + /* 313 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 314 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 315 */ "func_list ::= func", + /* 316 */ "func_list ::= func_list NK_COMMA func", + /* 317 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 318 */ "sma_func_name ::= function_name", + /* 319 */ "sma_func_name ::= COUNT", + /* 320 */ "sma_func_name ::= FIRST", + /* 321 */ "sma_func_name ::= LAST", + /* 322 */ "sma_func_name ::= LAST_ROW", + /* 323 */ "sma_stream_opt ::=", + /* 324 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 325 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 326 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 327 */ "with_meta ::= AS", + /* 328 */ "with_meta ::= WITH META AS", + /* 329 */ "with_meta ::= ONLY META AS", + /* 330 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 331 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 332 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 333 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 334 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 335 */ "cmd ::= DESC full_table_name", + /* 336 */ "cmd ::= DESCRIBE full_table_name", + /* 337 */ "cmd ::= RESET QUERY CACHE", + /* 338 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 339 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 340 */ "analyze_opt ::=", + /* 341 */ "analyze_opt ::= ANALYZE", + /* 342 */ "explain_options ::=", + /* 343 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 344 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 345 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 346 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 347 */ "agg_func_opt ::=", + /* 348 */ "agg_func_opt ::= AGGREGATE", + /* 349 */ "bufsize_opt ::=", + /* 350 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 351 */ "language_opt ::=", + /* 352 */ "language_opt ::= LANGUAGE NK_STRING", + /* 353 */ "or_replace_opt ::=", + /* 354 */ "or_replace_opt ::= OR REPLACE", + /* 355 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 356 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 357 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 358 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 359 */ "col_list_opt ::=", + /* 360 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 361 */ "tag_def_or_ref_opt ::=", + /* 362 */ "tag_def_or_ref_opt ::= tags_def", + /* 363 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", + /* 364 */ "stream_options ::=", + /* 365 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 366 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 367 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 368 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 369 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 370 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 371 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 372 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 373 */ "subtable_opt ::=", + /* 374 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 375 */ "ignore_opt ::=", + /* 376 */ "ignore_opt ::= IGNORE UNTREATED", + /* 377 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 378 */ "cmd ::= KILL QUERY NK_STRING", + /* 379 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 380 */ "cmd ::= BALANCE VGROUP", + /* 381 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 382 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 383 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 384 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 385 */ "on_vgroup_id ::=", + /* 386 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 387 */ "dnode_list ::= DNODE NK_INTEGER", + /* 388 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 389 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 390 */ "cmd ::= query_or_subquery", + /* 391 */ "cmd ::= insert_query", + /* 392 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 393 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 394 */ "literal ::= NK_INTEGER", + /* 395 */ "literal ::= NK_FLOAT", + /* 396 */ "literal ::= NK_STRING", + /* 397 */ "literal ::= NK_BOOL", + /* 398 */ "literal ::= TIMESTAMP NK_STRING", + /* 399 */ "literal ::= duration_literal", + /* 400 */ "literal ::= NULL", + /* 401 */ "literal ::= NK_QUESTION", + /* 402 */ "duration_literal ::= NK_VARIABLE", + /* 403 */ "signed ::= NK_INTEGER", + /* 404 */ "signed ::= NK_PLUS NK_INTEGER", + /* 405 */ "signed ::= NK_MINUS NK_INTEGER", + /* 406 */ "signed ::= NK_FLOAT", + /* 407 */ "signed ::= NK_PLUS NK_FLOAT", + /* 408 */ "signed ::= NK_MINUS NK_FLOAT", + /* 409 */ "signed_literal ::= signed", + /* 410 */ "signed_literal ::= NK_STRING", + /* 411 */ "signed_literal ::= NK_BOOL", + /* 412 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 413 */ "signed_literal ::= duration_literal", + /* 414 */ "signed_literal ::= NULL", + /* 415 */ "signed_literal ::= literal_func", + /* 416 */ "signed_literal ::= NK_QUESTION", + /* 417 */ "literal_list ::= signed_literal", + /* 418 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 419 */ "db_name ::= NK_ID", + /* 420 */ "table_name ::= NK_ID", + /* 421 */ "column_name ::= NK_ID", + /* 422 */ "function_name ::= NK_ID", + /* 423 */ "table_alias ::= NK_ID", + /* 424 */ "column_alias ::= NK_ID", + /* 425 */ "column_alias ::= NK_ALIAS", + /* 426 */ "user_name ::= NK_ID", + /* 427 */ "topic_name ::= NK_ID", + /* 428 */ "stream_name ::= NK_ID", + /* 429 */ "cgroup_name ::= NK_ID", + /* 430 */ "index_name ::= NK_ID", + /* 431 */ "expr_or_subquery ::= expression", + /* 432 */ "expression ::= literal", + /* 433 */ "expression ::= pseudo_column", + /* 434 */ "expression ::= column_reference", + /* 435 */ "expression ::= function_expression", + /* 436 */ "expression ::= case_when_expression", + /* 437 */ "expression ::= NK_LP expression NK_RP", + /* 438 */ "expression ::= NK_PLUS expr_or_subquery", + /* 439 */ "expression ::= NK_MINUS expr_or_subquery", + /* 440 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 441 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 442 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 443 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 444 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 445 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 446 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 447 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 448 */ "expression_list ::= expr_or_subquery", + /* 449 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 450 */ "column_reference ::= column_name", + /* 451 */ "column_reference ::= table_name NK_DOT column_name", + /* 452 */ "column_reference ::= NK_ALIAS", + /* 453 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 454 */ "pseudo_column ::= ROWTS", + /* 455 */ "pseudo_column ::= TBNAME", + /* 456 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 457 */ "pseudo_column ::= QSTART", + /* 458 */ "pseudo_column ::= QEND", + /* 459 */ "pseudo_column ::= QDURATION", + /* 460 */ "pseudo_column ::= WSTART", + /* 461 */ "pseudo_column ::= WEND", + /* 462 */ "pseudo_column ::= WDURATION", + /* 463 */ "pseudo_column ::= IROWTS", + /* 464 */ "pseudo_column ::= ISFILLED", + /* 465 */ "pseudo_column ::= QTAGS", + /* 466 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 467 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 468 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 469 */ "function_expression ::= literal_func", + /* 470 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 471 */ "literal_func ::= NOW", + /* 472 */ "noarg_func ::= NOW", + /* 473 */ "noarg_func ::= TODAY", + /* 474 */ "noarg_func ::= TIMEZONE", + /* 475 */ "noarg_func ::= DATABASE", + /* 476 */ "noarg_func ::= CLIENT_VERSION", + /* 477 */ "noarg_func ::= SERVER_VERSION", + /* 478 */ "noarg_func ::= SERVER_STATUS", + /* 479 */ "noarg_func ::= CURRENT_USER", + /* 480 */ "noarg_func ::= USER", + /* 481 */ "star_func ::= COUNT", + /* 482 */ "star_func ::= FIRST", + /* 483 */ "star_func ::= LAST", + /* 484 */ "star_func ::= LAST_ROW", + /* 485 */ "star_func_para_list ::= NK_STAR", + /* 486 */ "star_func_para_list ::= other_para_list", + /* 487 */ "other_para_list ::= star_func_para", + /* 488 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 489 */ "star_func_para ::= expr_or_subquery", + /* 490 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 491 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 492 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 493 */ "when_then_list ::= when_then_expr", + /* 494 */ "when_then_list ::= when_then_list when_then_expr", + /* 495 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 496 */ "case_when_else_opt ::=", + /* 497 */ "case_when_else_opt ::= ELSE common_expression", + /* 498 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 499 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 500 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 501 */ "predicate ::= expr_or_subquery IS NULL", + /* 502 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 503 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 504 */ "compare_op ::= NK_LT", + /* 505 */ "compare_op ::= NK_GT", + /* 506 */ "compare_op ::= NK_LE", + /* 507 */ "compare_op ::= NK_GE", + /* 508 */ "compare_op ::= NK_NE", + /* 509 */ "compare_op ::= NK_EQ", + /* 510 */ "compare_op ::= LIKE", + /* 511 */ "compare_op ::= NOT LIKE", + /* 512 */ "compare_op ::= MATCH", + /* 513 */ "compare_op ::= NMATCH", + /* 514 */ "compare_op ::= CONTAINS", + /* 515 */ "in_op ::= IN", + /* 516 */ "in_op ::= NOT IN", + /* 517 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 518 */ "boolean_value_expression ::= boolean_primary", + /* 519 */ "boolean_value_expression ::= NOT boolean_primary", + /* 520 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 521 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 522 */ "boolean_primary ::= predicate", + /* 523 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 524 */ "common_expression ::= expr_or_subquery", + /* 525 */ "common_expression ::= boolean_value_expression", + /* 526 */ "from_clause_opt ::=", + /* 527 */ "from_clause_opt ::= FROM table_reference_list", + /* 528 */ "table_reference_list ::= table_reference", + /* 529 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 530 */ "table_reference ::= table_primary", + /* 531 */ "table_reference ::= joined_table", + /* 532 */ "table_primary ::= table_name alias_opt", + /* 533 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 534 */ "table_primary ::= subquery alias_opt", + /* 535 */ "table_primary ::= parenthesized_joined_table", + /* 536 */ "alias_opt ::=", + /* 537 */ "alias_opt ::= table_alias", + /* 538 */ "alias_opt ::= AS table_alias", + /* 539 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 540 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 541 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 542 */ "join_type ::=", + /* 543 */ "join_type ::= INNER", + /* 544 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 545 */ "hint_list ::=", + /* 546 */ "hint_list ::= NK_HINT", + /* 547 */ "tag_mode_opt ::=", + /* 548 */ "tag_mode_opt ::= TAGS", + /* 549 */ "set_quantifier_opt ::=", + /* 550 */ "set_quantifier_opt ::= DISTINCT", + /* 551 */ "set_quantifier_opt ::= ALL", + /* 552 */ "select_list ::= select_item", + /* 553 */ "select_list ::= select_list NK_COMMA select_item", + /* 554 */ "select_item ::= NK_STAR", + /* 555 */ "select_item ::= common_expression", + /* 556 */ "select_item ::= common_expression column_alias", + /* 557 */ "select_item ::= common_expression AS column_alias", + /* 558 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 559 */ "where_clause_opt ::=", + /* 560 */ "where_clause_opt ::= WHERE search_condition", + /* 561 */ "partition_by_clause_opt ::=", + /* 562 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 563 */ "partition_list ::= partition_item", + /* 564 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 565 */ "partition_item ::= expr_or_subquery", + /* 566 */ "partition_item ::= expr_or_subquery column_alias", + /* 567 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 568 */ "twindow_clause_opt ::=", + /* 569 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 570 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 571 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 572 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 573 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 574 */ "sliding_opt ::=", + /* 575 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 576 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 577 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 578 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 579 */ "fill_opt ::=", + /* 580 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 581 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 582 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 583 */ "fill_mode ::= NONE", + /* 584 */ "fill_mode ::= PREV", + /* 585 */ "fill_mode ::= NULL", + /* 586 */ "fill_mode ::= NULL_F", + /* 587 */ "fill_mode ::= LINEAR", + /* 588 */ "fill_mode ::= NEXT", + /* 589 */ "group_by_clause_opt ::=", + /* 590 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 591 */ "group_by_list ::= expr_or_subquery", + /* 592 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 593 */ "having_clause_opt ::=", + /* 594 */ "having_clause_opt ::= HAVING search_condition", + /* 595 */ "range_opt ::=", + /* 596 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 597 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 598 */ "every_opt ::=", + /* 599 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 600 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 601 */ "query_simple ::= query_specification", + /* 602 */ "query_simple ::= union_query_expression", + /* 603 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 604 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 605 */ "query_simple_or_subquery ::= query_simple", + /* 606 */ "query_simple_or_subquery ::= subquery", + /* 607 */ "query_or_subquery ::= query_expression", + /* 608 */ "query_or_subquery ::= subquery", + /* 609 */ "order_by_clause_opt ::=", + /* 610 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 611 */ "slimit_clause_opt ::=", + /* 612 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 613 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 614 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 615 */ "limit_clause_opt ::=", + /* 616 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 617 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 618 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 619 */ "subquery ::= NK_LP query_expression NK_RP", + /* 620 */ "subquery ::= NK_LP subquery NK_RP", + /* 621 */ "search_condition ::= common_expression", + /* 622 */ "sort_specification_list ::= sort_specification", + /* 623 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 624 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 625 */ "ordering_specification_opt ::=", + /* 626 */ "ordering_specification_opt ::= ASC", + /* 627 */ "ordering_specification_opt ::= DESC", + /* 628 */ "null_ordering_opt ::=", + /* 629 */ "null_ordering_opt ::= NULLS FIRST", + /* 630 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3338,9 +2996,7 @@ static void yy_destructor( case 499: /* query_simple_or_subquery */ case 501: /* sort_specification */ { -#line 7 "sql.y" nodesDestroyNode((yypminor->yy56)); -#line 3343 "sql.c" } break; case 346: /* account_options */ @@ -3350,9 +3006,7 @@ static void yy_destructor( case 423: /* with_meta */ case 432: /* bufsize_opt */ { -#line 54 "sql.y" -#line 3355 "sql.c" } break; case 350: /* ip_range_list */ @@ -3389,9 +3043,7 @@ static void yy_destructor( case 495: /* order_by_clause_opt */ case 500: /* sort_specification_list */ { -#line 85 "sql.y" nodesDestroyList((yypminor->yy712)); -#line 3394 "sql.c" } break; case 353: /* user_name */ @@ -3413,32 +3065,24 @@ static void yy_destructor( case 453: /* noarg_func */ case 471: /* alias_opt */ { -#line 793 "sql.y" -#line 3418 "sql.c" } break; case 354: /* sysinfo_opt */ { -#line 112 "sql.y" -#line 3425 "sql.c" } break; case 355: /* privileges */ case 358: /* priv_type_list */ case 359: /* priv_type */ { -#line 121 "sql.y" -#line 3434 "sql.c" } break; case 356: /* priv_level */ { -#line 137 "sql.y" -#line 3441 "sql.c" } break; case 365: /* force_opt */ @@ -3452,75 +3096,55 @@ static void yy_destructor( case 477: /* set_quantifier_opt */ case 478: /* tag_mode_opt */ { -#line 166 "sql.y" -#line 3457 "sql.c" } break; case 378: /* alter_db_option */ case 400: /* alter_table_option */ { -#line 264 "sql.y" -#line 3465 "sql.c" } break; case 390: /* type_name */ { -#line 386 "sql.y" -#line 3472 "sql.c" } break; case 405: /* db_kind_opt */ case 412: /* table_kind */ { -#line 547 "sql.y" -#line 3480 "sql.c" } break; case 406: /* table_kind_db_name_cond_opt */ { -#line 512 "sql.y" -#line 3487 "sql.c" } break; case 461: /* compare_op */ case 462: /* in_op */ { -#line 983 "sql.y" -#line 3495 "sql.c" } break; case 474: /* join_type */ { -#line 1059 "sql.y" -#line 3502 "sql.c" } break; case 491: /* fill_mode */ { -#line 1150 "sql.y" -#line 3509 "sql.c" } break; case 502: /* ordering_specification_opt */ { -#line 1235 "sql.y" -#line 3516 "sql.c" } break; case 503: /* null_ordering_opt */ { -#line 1241 "sql.y" -#line 3523 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3687,7 +3311,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); + assert( i>=0 && iyytos; - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE ){ + if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", @@ -5165,21 +4790,15 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ -#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5170 "sql.c" yy_destructor(yypParser,346,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ -#line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 5176 "sql.c" yy_destructor(yypParser,347,&yymsp[0].minor); break; case 2: /* account_options ::= */ -#line 55 "sql.y" { } -#line 5182 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5191,24 +4810,18 @@ static YYACTIONTYPE yy_reduce( case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); { yy_destructor(yypParser,346,&yymsp[-2].minor); -#line 56 "sql.y" { } -#line 5196 "sql.c" yy_destructor(yypParser,348,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ { yy_destructor(yypParser,349,&yymsp[0].minor); -#line 68 "sql.y" { } -#line 5204 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ { yy_destructor(yypParser,347,&yymsp[-1].minor); -#line 69 "sql.y" { } -#line 5211 "sql.c" yy_destructor(yypParser,349,&yymsp[0].minor); } break; @@ -5222,2349 +4835,1587 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); -#line 73 "sql.y" { } -#line 5227 "sql.c" yy_destructor(yypParser,348,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -#line 86 "sql.y" { yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5233 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -#line 87 "sql.y" { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5239 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 26: /* white_list ::= HOST ip_range_list */ -#line 91 "sql.y" { yymsp[-1].minor.yy712 = yymsp[0].minor.yy712; } -#line 5245 "sql.c" break; case 27: /* white_list_opt ::= */ - case 184: /* specific_cols_opt ::= */ yytestcase(yyruleno==184); - case 215: /* tags_def_opt ::= */ yytestcase(yyruleno==215); - case 296: /* tag_list_opt ::= */ yytestcase(yyruleno==296); - case 358: /* col_list_opt ::= */ yytestcase(yyruleno==358); - case 360: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==360); - case 560: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==560); - case 588: /* group_by_clause_opt ::= */ yytestcase(yyruleno==588); - case 608: /* order_by_clause_opt ::= */ yytestcase(yyruleno==608); -#line 95 "sql.y" + case 185: /* specific_cols_opt ::= */ yytestcase(yyruleno==185); + case 216: /* tags_def_opt ::= */ yytestcase(yyruleno==216); + case 297: /* tag_list_opt ::= */ yytestcase(yyruleno==297); + case 359: /* col_list_opt ::= */ yytestcase(yyruleno==359); + case 361: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==361); + case 561: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==561); + case 589: /* group_by_clause_opt ::= */ yytestcase(yyruleno==589); + case 609: /* order_by_clause_opt ::= */ yytestcase(yyruleno==609); { yymsp[1].minor.yy712 = NULL; } -#line 5258 "sql.c" break; case 28: /* white_list_opt ::= white_list */ - case 216: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==216); - case 361: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==361); - case 485: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==485); -#line 96 "sql.y" + case 217: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==217); + case 362: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==362); + case 486: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==486); { yylhsminor.yy712 = yymsp[0].minor.yy712; } -#line 5266 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ -#line 100 "sql.y" { pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy785, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy215); pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy712); } -#line 5275 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -#line 104 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } -#line 5280 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -#line 105 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } -#line 5285 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -#line 106 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } -#line 5290 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -#line 107 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy712); } -#line 5295 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -#line 108 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy785, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy712); } -#line 5300 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ -#line 109 "sql.y" { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5305 "sql.c" break; case 36: /* sysinfo_opt ::= */ -#line 113 "sql.y" { yymsp[1].minor.yy215 = 1; } -#line 5310 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -#line 114 "sql.y" { yymsp[-1].minor.yy215 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } -#line 5315 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -#line 117 "sql.y" { pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } -#line 5320 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -#line 118 "sql.y" { pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy333, &yymsp[-3].minor.yy777, &yymsp[0].minor.yy785, yymsp[-2].minor.yy56); } -#line 5325 "sql.c" break; case 40: /* privileges ::= ALL */ -#line 122 "sql.y" { yymsp[0].minor.yy333 = PRIVILEGE_TYPE_ALL; } -#line 5330 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -#line 123 "sql.y" { yylhsminor.yy333 = yymsp[0].minor.yy333; } -#line 5336 "sql.c" yymsp[0].minor.yy333 = yylhsminor.yy333; break; case 42: /* privileges ::= SUBSCRIBE */ -#line 124 "sql.y" { yymsp[0].minor.yy333 = PRIVILEGE_TYPE_SUBSCRIBE; } -#line 5342 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -#line 129 "sql.y" { yylhsminor.yy333 = yymsp[-2].minor.yy333 | yymsp[0].minor.yy333; } -#line 5347 "sql.c" yymsp[-2].minor.yy333 = yylhsminor.yy333; break; case 45: /* priv_type ::= READ */ -#line 133 "sql.y" { yymsp[0].minor.yy333 = PRIVILEGE_TYPE_READ; } -#line 5353 "sql.c" break; case 46: /* priv_type ::= WRITE */ -#line 134 "sql.y" { yymsp[0].minor.yy333 = PRIVILEGE_TYPE_WRITE; } -#line 5358 "sql.c" break; case 47: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -#line 138 "sql.y" { yylhsminor.yy777.first = yymsp[-2].minor.yy0; yylhsminor.yy777.second = yymsp[0].minor.yy0; } -#line 5363 "sql.c" yymsp[-2].minor.yy777 = yylhsminor.yy777; break; case 48: /* priv_level ::= db_name NK_DOT NK_STAR */ -#line 139 "sql.y" { yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy0; } -#line 5369 "sql.c" yymsp[-2].minor.yy777 = yylhsminor.yy777; break; case 49: /* priv_level ::= db_name NK_DOT table_name */ -#line 140 "sql.y" { yylhsminor.yy777.first = yymsp[-2].minor.yy785; yylhsminor.yy777.second = yymsp[0].minor.yy785; } -#line 5375 "sql.c" yymsp[-2].minor.yy777 = yylhsminor.yy777; break; case 50: /* priv_level ::= topic_name */ -#line 141 "sql.y" { yylhsminor.yy777.first = yymsp[0].minor.yy785; yylhsminor.yy777.second = nil_token; } -#line 5381 "sql.c" yymsp[0].minor.yy777 = yylhsminor.yy777; break; case 51: /* with_opt ::= */ - case 153: /* start_opt ::= */ yytestcase(yyruleno==153); - case 157: /* end_opt ::= */ yytestcase(yyruleno==157); - case 291: /* like_pattern_opt ::= */ yytestcase(yyruleno==291); - case 372: /* subtable_opt ::= */ yytestcase(yyruleno==372); - case 495: /* case_when_else_opt ::= */ yytestcase(yyruleno==495); - case 525: /* from_clause_opt ::= */ yytestcase(yyruleno==525); - case 558: /* where_clause_opt ::= */ yytestcase(yyruleno==558); - case 567: /* twindow_clause_opt ::= */ yytestcase(yyruleno==567); - case 573: /* sliding_opt ::= */ yytestcase(yyruleno==573); - case 578: /* fill_opt ::= */ yytestcase(yyruleno==578); - case 592: /* having_clause_opt ::= */ yytestcase(yyruleno==592); - case 594: /* range_opt ::= */ yytestcase(yyruleno==594); - case 597: /* every_opt ::= */ yytestcase(yyruleno==597); - case 610: /* slimit_clause_opt ::= */ yytestcase(yyruleno==610); - case 614: /* limit_clause_opt ::= */ yytestcase(yyruleno==614); -#line 143 "sql.y" + case 154: /* start_opt ::= */ yytestcase(yyruleno==154); + case 158: /* end_opt ::= */ yytestcase(yyruleno==158); + case 292: /* like_pattern_opt ::= */ yytestcase(yyruleno==292); + case 373: /* subtable_opt ::= */ yytestcase(yyruleno==373); + case 496: /* case_when_else_opt ::= */ yytestcase(yyruleno==496); + case 526: /* from_clause_opt ::= */ yytestcase(yyruleno==526); + case 559: /* where_clause_opt ::= */ yytestcase(yyruleno==559); + case 568: /* twindow_clause_opt ::= */ yytestcase(yyruleno==568); + case 574: /* sliding_opt ::= */ yytestcase(yyruleno==574); + case 579: /* fill_opt ::= */ yytestcase(yyruleno==579); + case 593: /* having_clause_opt ::= */ yytestcase(yyruleno==593); + case 595: /* range_opt ::= */ yytestcase(yyruleno==595); + case 598: /* every_opt ::= */ yytestcase(yyruleno==598); + case 611: /* slimit_clause_opt ::= */ yytestcase(yyruleno==611); + case 615: /* limit_clause_opt ::= */ yytestcase(yyruleno==615); { yymsp[1].minor.yy56 = NULL; } -#line 5402 "sql.c" break; case 52: /* with_opt ::= WITH search_condition */ - case 526: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==526); - case 559: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==559); - case 593: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==593); -#line 144 "sql.y" + case 527: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==527); + case 560: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==560); + case 594: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==594); { yymsp[-1].minor.yy56 = yymsp[0].minor.yy56; } -#line 5410 "sql.c" break; case 53: /* cmd ::= CREATE DNODE dnode_endpoint */ -#line 147 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy785, NULL); } -#line 5415 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -#line 148 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } -#line 5420 "sql.c" break; case 55: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -#line 149 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy425, false); } -#line 5425 "sql.c" break; case 56: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -#line 150 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy425, false); } -#line 5430 "sql.c" break; case 57: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -#line 151 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy425); } -#line 5435 "sql.c" break; case 58: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -#line 152 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy785, false, yymsp[0].minor.yy425); } -#line 5440 "sql.c" break; case 59: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ -#line 153 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } -#line 5445 "sql.c" break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ -#line 154 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5450 "sql.c" break; case 61: /* cmd ::= ALTER ALL DNODES NK_STRING */ -#line 155 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } -#line 5455 "sql.c" break; case 62: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ -#line 156 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5460 "sql.c" break; case 63: /* cmd ::= RESTORE DNODE NK_INTEGER */ -#line 157 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } -#line 5465 "sql.c" break; case 64: /* dnode_endpoint ::= NK_STRING */ case 65: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==65); case 66: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==66); - case 318: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==318); - case 319: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==319); - case 320: /* sma_func_name ::= LAST */ yytestcase(yyruleno==320); - case 321: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==321); - case 418: /* db_name ::= NK_ID */ yytestcase(yyruleno==418); - case 419: /* table_name ::= NK_ID */ yytestcase(yyruleno==419); - case 420: /* column_name ::= NK_ID */ yytestcase(yyruleno==420); - case 421: /* function_name ::= NK_ID */ yytestcase(yyruleno==421); - case 422: /* table_alias ::= NK_ID */ yytestcase(yyruleno==422); - case 423: /* column_alias ::= NK_ID */ yytestcase(yyruleno==423); - case 424: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==424); - case 425: /* user_name ::= NK_ID */ yytestcase(yyruleno==425); - case 426: /* topic_name ::= NK_ID */ yytestcase(yyruleno==426); - case 427: /* stream_name ::= NK_ID */ yytestcase(yyruleno==427); - case 428: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==428); - case 429: /* index_name ::= NK_ID */ yytestcase(yyruleno==429); - case 471: /* noarg_func ::= NOW */ yytestcase(yyruleno==471); - case 472: /* noarg_func ::= TODAY */ yytestcase(yyruleno==472); - case 473: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==473); - case 474: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==474); - case 475: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==475); - case 476: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==476); - case 477: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==477); - case 478: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==478); - case 479: /* noarg_func ::= USER */ yytestcase(yyruleno==479); - case 480: /* star_func ::= COUNT */ yytestcase(yyruleno==480); - case 481: /* star_func ::= FIRST */ yytestcase(yyruleno==481); - case 482: /* star_func ::= LAST */ yytestcase(yyruleno==482); - case 483: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==483); -#line 161 "sql.y" + case 319: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==319); + case 320: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==320); + case 321: /* sma_func_name ::= LAST */ yytestcase(yyruleno==321); + case 322: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==322); + case 419: /* db_name ::= NK_ID */ yytestcase(yyruleno==419); + case 420: /* table_name ::= NK_ID */ yytestcase(yyruleno==420); + case 421: /* column_name ::= NK_ID */ yytestcase(yyruleno==421); + case 422: /* function_name ::= NK_ID */ yytestcase(yyruleno==422); + case 423: /* table_alias ::= NK_ID */ yytestcase(yyruleno==423); + case 424: /* column_alias ::= NK_ID */ yytestcase(yyruleno==424); + case 425: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==425); + case 426: /* user_name ::= NK_ID */ yytestcase(yyruleno==426); + case 427: /* topic_name ::= NK_ID */ yytestcase(yyruleno==427); + case 428: /* stream_name ::= NK_ID */ yytestcase(yyruleno==428); + case 429: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==429); + case 430: /* index_name ::= NK_ID */ yytestcase(yyruleno==430); + case 472: /* noarg_func ::= NOW */ yytestcase(yyruleno==472); + case 473: /* noarg_func ::= TODAY */ yytestcase(yyruleno==473); + case 474: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==474); + case 475: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==475); + case 476: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==476); + case 477: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==477); + case 478: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==478); + case 479: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==479); + case 480: /* noarg_func ::= USER */ yytestcase(yyruleno==480); + case 481: /* star_func ::= COUNT */ yytestcase(yyruleno==481); + case 482: /* star_func ::= FIRST */ yytestcase(yyruleno==482); + case 483: /* star_func ::= LAST */ yytestcase(yyruleno==483); + case 484: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==484); { yylhsminor.yy785 = yymsp[0].minor.yy0; } -#line 5501 "sql.c" yymsp[0].minor.yy785 = yylhsminor.yy785; break; case 67: /* force_opt ::= */ case 91: /* not_exists_opt ::= */ yytestcase(yyruleno==91); case 93: /* exists_opt ::= */ yytestcase(yyruleno==93); - case 339: /* analyze_opt ::= */ yytestcase(yyruleno==339); - case 346: /* agg_func_opt ::= */ yytestcase(yyruleno==346); - case 352: /* or_replace_opt ::= */ yytestcase(yyruleno==352); - case 374: /* ignore_opt ::= */ yytestcase(yyruleno==374); - case 546: /* tag_mode_opt ::= */ yytestcase(yyruleno==546); - case 548: /* set_quantifier_opt ::= */ yytestcase(yyruleno==548); -#line 167 "sql.y" + case 340: /* analyze_opt ::= */ yytestcase(yyruleno==340); + case 347: /* agg_func_opt ::= */ yytestcase(yyruleno==347); + case 353: /* or_replace_opt ::= */ yytestcase(yyruleno==353); + case 375: /* ignore_opt ::= */ yytestcase(yyruleno==375); + case 547: /* tag_mode_opt ::= */ yytestcase(yyruleno==547); + case 549: /* set_quantifier_opt ::= */ yytestcase(yyruleno==549); { yymsp[1].minor.yy425 = false; } -#line 5515 "sql.c" break; case 68: /* force_opt ::= FORCE */ case 69: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==69); - case 340: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==340); - case 347: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==347); - case 547: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==547); - case 549: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==549); -#line 168 "sql.y" + case 341: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==341); + case 348: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==348); + case 548: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==548); + case 550: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==550); { yymsp[0].minor.yy425 = true; } -#line 5525 "sql.c" break; case 70: /* cmd ::= ALTER LOCAL NK_STRING */ -#line 175 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5530 "sql.c" break; case 71: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ -#line 176 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 5535 "sql.c" break; case 72: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ -#line 179 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5540 "sql.c" break; case 73: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ -#line 180 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5545 "sql.c" break; case 74: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ -#line 181 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } -#line 5550 "sql.c" break; case 75: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ -#line 184 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5555 "sql.c" break; case 76: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ -#line 185 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } -#line 5560 "sql.c" break; case 77: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ -#line 188 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5565 "sql.c" break; case 78: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ -#line 189 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } -#line 5570 "sql.c" break; case 79: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ -#line 192 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5575 "sql.c" break; case 80: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ -#line 193 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5580 "sql.c" break; case 81: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ -#line 194 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } -#line 5585 "sql.c" break; case 82: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ -#line 197 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } -#line 5590 "sql.c" break; case 83: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -#line 200 "sql.y" { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy425, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } -#line 5595 "sql.c" break; case 84: /* cmd ::= DROP DATABASE exists_opt db_name */ -#line 201 "sql.y" { pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 5600 "sql.c" break; case 85: /* cmd ::= USE db_name */ -#line 202 "sql.y" { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5605 "sql.c" break; case 86: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -#line 203 "sql.y" { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy56); } -#line 5610 "sql.c" break; case 87: /* cmd ::= FLUSH DATABASE db_name */ -#line 204 "sql.y" { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 5615 "sql.c" break; case 88: /* cmd ::= TRIM DATABASE db_name speed_opt */ -#line 205 "sql.y" { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy676); } -#line 5620 "sql.c" break; case 89: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -#line 206 "sql.y" { pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy785, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 5625 "sql.c" break; case 90: /* not_exists_opt ::= IF NOT EXISTS */ -#line 210 "sql.y" { yymsp[-2].minor.yy425 = true; } -#line 5630 "sql.c" break; case 92: /* exists_opt ::= IF EXISTS */ - case 353: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==353); - case 375: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==375); -#line 215 "sql.y" + case 354: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==354); + case 376: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==376); { yymsp[-1].minor.yy425 = true; } -#line 5637 "sql.c" break; case 94: /* db_options ::= */ -#line 218 "sql.y" { yymsp[1].minor.yy56 = createDefaultDatabaseOptions(pCxt); } -#line 5642 "sql.c" break; case 95: /* db_options ::= db_options BUFFER NK_INTEGER */ -#line 219 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } -#line 5647 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 96: /* db_options ::= db_options CACHEMODEL NK_STRING */ -#line 220 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } -#line 5653 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 97: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -#line 221 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } -#line 5659 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 98: /* db_options ::= db_options COMP NK_INTEGER */ -#line 222 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_COMP, &yymsp[0].minor.yy0); } -#line 5665 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 99: /* db_options ::= db_options DURATION NK_INTEGER */ case 100: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==100); -#line 223 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } -#line 5672 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 101: /* db_options ::= db_options MAXROWS NK_INTEGER */ -#line 225 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } -#line 5678 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 102: /* db_options ::= db_options MINROWS NK_INTEGER */ -#line 226 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } -#line 5684 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 103: /* db_options ::= db_options KEEP integer_list */ case 104: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==104); -#line 227 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP, yymsp[0].minor.yy712); } -#line 5691 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 105: /* db_options ::= db_options PAGES NK_INTEGER */ -#line 229 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } -#line 5697 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 106: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -#line 230 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5703 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 107: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -#line 231 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } -#line 5709 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 108: /* db_options ::= db_options PRECISION NK_STRING */ -#line 232 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } -#line 5715 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 109: /* db_options ::= db_options REPLICA NK_INTEGER */ -#line 233 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } -#line 5721 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 110: /* db_options ::= db_options VGROUPS NK_INTEGER */ -#line 235 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } -#line 5727 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 111: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -#line 236 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } -#line 5733 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 112: /* db_options ::= db_options RETENTIONS retention_list */ -#line 237 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_RETENTIONS, yymsp[0].minor.yy712); } -#line 5739 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 113: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -#line 238 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } -#line 5745 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 114: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -#line 239 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL, &yymsp[0].minor.yy0); } -#line 5751 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 115: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -#line 240 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } -#line 5757 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 116: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -#line 241 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } -#line 5763 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 117: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ -#line 242 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-3].minor.yy56, DB_OPTION_WAL_RETENTION_PERIOD, &t); } -#line 5773 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; case 118: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -#line 247 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } -#line 5779 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 119: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ -#line 248 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-3].minor.yy56, DB_OPTION_WAL_RETENTION_SIZE, &t); } -#line 5789 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; case 120: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -#line 253 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } -#line 5795 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 121: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -#line 254 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } -#line 5801 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 122: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -#line 255 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } -#line 5807 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 123: /* db_options ::= db_options TABLE_PREFIX signed */ -#line 256 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy56); } -#line 5813 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 124: /* db_options ::= db_options TABLE_SUFFIX signed */ -#line 257 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy56); } -#line 5819 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 125: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -#line 258 "sql.y" { yylhsminor.yy56 = setDatabaseOption(pCxt, yymsp[-2].minor.yy56, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } -#line 5825 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; case 126: /* alter_db_options ::= alter_db_option */ -#line 260 "sql.y" { yylhsminor.yy56 = createAlterDatabaseOptions(pCxt); yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yylhsminor.yy56, &yymsp[0].minor.yy893); } -#line 5831 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; case 127: /* alter_db_options ::= alter_db_options alter_db_option */ -#line 261 "sql.y" { yylhsminor.yy56 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy56, &yymsp[0].minor.yy893); } -#line 5837 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; case 128: /* alter_db_option ::= BUFFER NK_INTEGER */ -#line 265 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5843 "sql.c" break; case 129: /* alter_db_option ::= CACHEMODEL NK_STRING */ -#line 266 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5848 "sql.c" break; case 130: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -#line 267 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5853 "sql.c" break; case 131: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -#line 268 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5858 "sql.c" break; case 132: /* alter_db_option ::= KEEP integer_list */ case 133: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==133); -#line 269 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_KEEP; yymsp[-1].minor.yy893.pList = yymsp[0].minor.yy712; } -#line 5864 "sql.c" break; case 134: /* alter_db_option ::= PAGES NK_INTEGER */ -#line 271 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_PAGES; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5869 "sql.c" break; case 135: /* alter_db_option ::= REPLICA NK_INTEGER */ -#line 272 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5874 "sql.c" break; case 136: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -#line 274 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_WAL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5879 "sql.c" break; case 137: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -#line 275 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5884 "sql.c" break; case 138: /* alter_db_option ::= MINROWS NK_INTEGER */ -#line 276 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5889 "sql.c" break; case 139: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -#line 277 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5894 "sql.c" break; case 140: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ -#line 278 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy893.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy893.val = t; } -#line 5903 "sql.c" break; case 141: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -#line 283 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5908 "sql.c" break; case 142: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ -#line 284 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy893.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy893.val = t; } -#line 5917 "sql.c" break; case 143: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -#line 289 "sql.y" { yymsp[-1].minor.yy893.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 5922 "sql.c" break; case 144: /* integer_list ::= NK_INTEGER */ -#line 293 "sql.y" { yylhsminor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5927 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 145: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 387: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==387); -#line 294 "sql.y" + case 388: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==388); { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 5934 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 146: /* variable_list ::= NK_VARIABLE */ -#line 298 "sql.y" { yylhsminor.yy712 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5940 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 147: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -#line 299 "sql.y" { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5946 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 148: /* retention_list ::= retention */ - case 178: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==178); - case 181: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==181); - case 188: /* column_def_list ::= column_def */ yytestcase(yyruleno==188); - case 232: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==232); - case 237: /* col_name_list ::= col_name */ yytestcase(yyruleno==237); - case 297: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==297); - case 314: /* func_list ::= func */ yytestcase(yyruleno==314); - case 416: /* literal_list ::= signed_literal */ yytestcase(yyruleno==416); - case 486: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==486); - case 492: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==492); - case 551: /* select_list ::= select_item */ yytestcase(yyruleno==551); - case 562: /* partition_list ::= partition_item */ yytestcase(yyruleno==562); - case 621: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==621); -#line 303 "sql.y" + case 179: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==179); + case 182: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==182); + case 189: /* column_def_list ::= column_def */ yytestcase(yyruleno==189); + case 233: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==233); + case 238: /* col_name_list ::= col_name */ yytestcase(yyruleno==238); + case 298: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==298); + case 315: /* func_list ::= func */ yytestcase(yyruleno==315); + case 417: /* literal_list ::= signed_literal */ yytestcase(yyruleno==417); + case 487: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==487); + case 493: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==493); + case 552: /* select_list ::= select_item */ yytestcase(yyruleno==552); + case 563: /* partition_list ::= partition_item */ yytestcase(yyruleno==563); + case 622: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==622); { yylhsminor.yy712 = createNodeList(pCxt, yymsp[0].minor.yy56); } -#line 5965 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 149: /* retention_list ::= retention_list NK_COMMA retention */ - case 182: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==182); - case 189: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==189); - case 233: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==233); - case 238: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==238); - case 298: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==298); - case 315: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==315); - case 417: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==417); - case 487: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==487); - case 552: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==552); - case 563: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==563); - case 622: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==622); -#line 304 "sql.y" + case 183: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==183); + case 190: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==190); + case 234: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==234); + case 239: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==239); + case 299: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==299); + case 316: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==316); + case 418: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==418); + case 488: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==488); + case 553: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==553); + case 564: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==564); + case 623: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==623); { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } -#line 5982 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 150: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -#line 306 "sql.y" + case 151: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==151); { yylhsminor.yy56 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 5988 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 151: /* speed_opt ::= */ - case 348: /* bufsize_opt ::= */ yytestcase(yyruleno==348); -#line 310 "sql.y" + case 152: /* speed_opt ::= */ + case 349: /* bufsize_opt ::= */ yytestcase(yyruleno==349); { yymsp[1].minor.yy676 = 0; } -#line 5995 "sql.c" break; - case 152: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 349: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==349); -#line 311 "sql.y" + case 153: /* speed_opt ::= BWLIMIT NK_INTEGER */ + case 350: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==350); { yymsp[-1].minor.yy676 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } -#line 6001 "sql.c" break; - case 154: /* start_opt ::= START WITH NK_INTEGER */ - case 158: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==158); -#line 314 "sql.y" + case 155: /* start_opt ::= START WITH NK_INTEGER */ + case 159: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==159); { yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } -#line 6007 "sql.c" break; - case 155: /* start_opt ::= START WITH NK_STRING */ - case 159: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==159); -#line 315 "sql.y" + case 156: /* start_opt ::= START WITH NK_STRING */ + case 160: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==160); { yymsp[-2].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6013 "sql.c" break; - case 156: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ - case 160: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==160); -#line 316 "sql.y" + case 157: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ + case 161: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==161); { yymsp[-3].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6019 "sql.c" break; - case 161: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 163: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==163); -#line 325 "sql.y" + case 162: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 164: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==164); { pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy712, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } -#line 6025 "sql.c" break; - case 162: /* cmd ::= CREATE TABLE multi_create_clause */ -#line 326 "sql.y" + case 163: /* cmd ::= CREATE TABLE multi_create_clause */ { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy712); } -#line 6030 "sql.c" break; - case 164: /* cmd ::= DROP TABLE multi_drop_clause */ -#line 329 "sql.y" + case 165: /* cmd ::= DROP TABLE multi_drop_clause */ { pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy712); } -#line 6035 "sql.c" break; - case 165: /* cmd ::= DROP STABLE exists_opt full_table_name */ -#line 330 "sql.y" + case 166: /* cmd ::= DROP STABLE exists_opt full_table_name */ { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6040 "sql.c" break; - case 166: /* cmd ::= ALTER TABLE alter_table_clause */ - case 389: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==389); - case 390: /* cmd ::= insert_query */ yytestcase(yyruleno==390); -#line 332 "sql.y" + case 167: /* cmd ::= ALTER TABLE alter_table_clause */ + case 390: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==390); + case 391: /* cmd ::= insert_query */ yytestcase(yyruleno==391); { pCxt->pRootNode = yymsp[0].minor.yy56; } -#line 6047 "sql.c" break; - case 167: /* cmd ::= ALTER STABLE alter_table_clause */ -#line 333 "sql.y" + case 168: /* cmd ::= ALTER STABLE alter_table_clause */ { pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy56); } -#line 6052 "sql.c" break; - case 168: /* alter_table_clause ::= full_table_name alter_table_options */ -#line 335 "sql.y" + case 169: /* alter_table_clause ::= full_table_name alter_table_options */ { yylhsminor.yy56 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6057 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 169: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -#line 337 "sql.y" + case 170: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ { yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6063 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 170: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -#line 338 "sql.y" + case 171: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ { yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy785); } -#line 6069 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 171: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -#line 340 "sql.y" + case 172: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ { yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6075 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 172: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -#line 342 "sql.y" + case 173: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ { yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 6081 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 173: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -#line 344 "sql.y" + case 174: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ { yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6087 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 174: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -#line 345 "sql.y" + case 175: /* alter_table_clause ::= full_table_name DROP TAG column_name */ { yylhsminor.yy56 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy56, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy785); } -#line 6093 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 175: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -#line 347 "sql.y" + case 176: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ { yylhsminor.yy56 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448); } -#line 6099 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 176: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -#line 349 "sql.y" + case 177: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ { yylhsminor.yy56 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy56, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 6105 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 177: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -#line 351 "sql.y" + case 178: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ { yylhsminor.yy56 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy56, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } -#line 6111 "sql.c" yymsp[-5].minor.yy56 = yylhsminor.yy56; break; - case 179: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 493: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==493); -#line 356 "sql.y" + case 180: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 494: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==494); { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy56); } -#line 6118 "sql.c" yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 180: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -#line 360 "sql.y" + case 181: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ { yylhsminor.yy56 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy425, yymsp[-8].minor.yy56, yymsp[-6].minor.yy56, yymsp[-5].minor.yy712, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } -#line 6124 "sql.c" yymsp[-9].minor.yy56 = yylhsminor.yy56; break; - case 183: /* drop_table_clause ::= exists_opt full_table_name */ -#line 367 "sql.y" + case 184: /* drop_table_clause ::= exists_opt full_table_name */ { yylhsminor.yy56 = createDropTableClause(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6130 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 185: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 359: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==359); -#line 372 "sql.y" + case 186: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ + case 360: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==360); { yymsp[-2].minor.yy712 = yymsp[-1].minor.yy712; } -#line 6137 "sql.c" break; - case 186: /* full_table_name ::= table_name */ -#line 374 "sql.y" + case 187: /* full_table_name ::= table_name */ { yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy785, NULL); } -#line 6142 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 187: /* full_table_name ::= db_name NK_DOT table_name */ -#line 375 "sql.y" + case 188: /* full_table_name ::= db_name NK_DOT table_name */ { yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, NULL); } -#line 6148 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 190: /* column_def ::= column_name type_name */ -#line 382 "sql.y" + case 191: /* column_def ::= column_name type_name */ { yylhsminor.yy56 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy785, yymsp[0].minor.yy448, NULL); } -#line 6154 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 191: /* type_name ::= BOOL */ -#line 387 "sql.y" + case 192: /* type_name ::= BOOL */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); } -#line 6160 "sql.c" break; - case 192: /* type_name ::= TINYINT */ -#line 388 "sql.y" + case 193: /* type_name ::= TINYINT */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); } -#line 6165 "sql.c" break; - case 193: /* type_name ::= SMALLINT */ -#line 389 "sql.y" + case 194: /* type_name ::= SMALLINT */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); } -#line 6170 "sql.c" break; - case 194: /* type_name ::= INT */ - case 195: /* type_name ::= INTEGER */ yytestcase(yyruleno==195); -#line 390 "sql.y" + case 195: /* type_name ::= INT */ + case 196: /* type_name ::= INTEGER */ yytestcase(yyruleno==196); { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); } -#line 6176 "sql.c" break; - case 196: /* type_name ::= BIGINT */ -#line 392 "sql.y" + case 197: /* type_name ::= BIGINT */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); } -#line 6181 "sql.c" break; - case 197: /* type_name ::= FLOAT */ -#line 393 "sql.y" + case 198: /* type_name ::= FLOAT */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); } -#line 6186 "sql.c" break; - case 198: /* type_name ::= DOUBLE */ -#line 394 "sql.y" + case 199: /* type_name ::= DOUBLE */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); } -#line 6191 "sql.c" break; - case 199: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -#line 395 "sql.y" + case 200: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } -#line 6196 "sql.c" break; - case 200: /* type_name ::= TIMESTAMP */ -#line 396 "sql.y" + case 201: /* type_name ::= TIMESTAMP */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } -#line 6201 "sql.c" break; - case 201: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -#line 397 "sql.y" + case 202: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } -#line 6206 "sql.c" break; - case 202: /* type_name ::= TINYINT UNSIGNED */ -#line 398 "sql.y" + case 203: /* type_name ::= TINYINT UNSIGNED */ { yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); } -#line 6211 "sql.c" break; - case 203: /* type_name ::= SMALLINT UNSIGNED */ -#line 399 "sql.y" + case 204: /* type_name ::= SMALLINT UNSIGNED */ { yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); } -#line 6216 "sql.c" break; - case 204: /* type_name ::= INT UNSIGNED */ -#line 400 "sql.y" + case 205: /* type_name ::= INT UNSIGNED */ { yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); } -#line 6221 "sql.c" break; - case 205: /* type_name ::= BIGINT UNSIGNED */ -#line 401 "sql.y" + case 206: /* type_name ::= BIGINT UNSIGNED */ { yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); } -#line 6226 "sql.c" break; - case 206: /* type_name ::= JSON */ -#line 402 "sql.y" + case 207: /* type_name ::= JSON */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); } -#line 6231 "sql.c" break; - case 207: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -#line 403 "sql.y" + case 208: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } -#line 6236 "sql.c" break; - case 208: /* type_name ::= MEDIUMBLOB */ -#line 404 "sql.y" + case 209: /* type_name ::= MEDIUMBLOB */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } -#line 6241 "sql.c" break; - case 209: /* type_name ::= BLOB */ -#line 405 "sql.y" + case 210: /* type_name ::= BLOB */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); } -#line 6246 "sql.c" break; - case 210: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -#line 406 "sql.y" + case 211: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } -#line 6251 "sql.c" break; - case 211: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -#line 407 "sql.y" + case 212: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } -#line 6256 "sql.c" break; - case 212: /* type_name ::= DECIMAL */ -#line 408 "sql.y" + case 213: /* type_name ::= DECIMAL */ { yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6261 "sql.c" break; - case 213: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -#line 409 "sql.y" + case 214: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ { yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6266 "sql.c" break; - case 214: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -#line 410 "sql.y" + case 215: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ { yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6271 "sql.c" break; - case 217: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 362: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==362); -#line 419 "sql.y" + case 218: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ + case 363: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==363); { yymsp[-3].minor.yy712 = yymsp[-1].minor.yy712; } -#line 6277 "sql.c" break; - case 218: /* table_options ::= */ -#line 421 "sql.y" + case 219: /* table_options ::= */ { yymsp[1].minor.yy56 = createDefaultTableOptions(pCxt); } -#line 6282 "sql.c" break; - case 219: /* table_options ::= table_options COMMENT NK_STRING */ -#line 422 "sql.y" + case 220: /* table_options ::= table_options COMMENT NK_STRING */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } -#line 6287 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 220: /* table_options ::= table_options MAX_DELAY duration_list */ -#line 423 "sql.y" + case 221: /* table_options ::= table_options MAX_DELAY duration_list */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy712); } -#line 6293 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 221: /* table_options ::= table_options WATERMARK duration_list */ -#line 424 "sql.y" + case 222: /* table_options ::= table_options WATERMARK duration_list */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy712); } -#line 6299 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 222: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -#line 425 "sql.y" + case 223: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy712); } -#line 6305 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 223: /* table_options ::= table_options TTL NK_INTEGER */ -#line 426 "sql.y" + case 224: /* table_options ::= table_options TTL NK_INTEGER */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } -#line 6311 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 224: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -#line 427 "sql.y" + case 225: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-4].minor.yy56, TABLE_OPTION_SMA, yymsp[-1].minor.yy712); } -#line 6317 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 225: /* table_options ::= table_options DELETE_MARK duration_list */ -#line 428 "sql.y" + case 226: /* table_options ::= table_options DELETE_MARK duration_list */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-2].minor.yy56, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy712); } -#line 6323 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 226: /* alter_table_options ::= alter_table_option */ -#line 430 "sql.y" + case 227: /* alter_table_options ::= alter_table_option */ { yylhsminor.yy56 = createAlterTableOptions(pCxt); yylhsminor.yy56 = setTableOption(pCxt, yylhsminor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } -#line 6329 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 227: /* alter_table_options ::= alter_table_options alter_table_option */ -#line 431 "sql.y" + case 228: /* alter_table_options ::= alter_table_options alter_table_option */ { yylhsminor.yy56 = setTableOption(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy893.type, &yymsp[0].minor.yy893.val); } -#line 6335 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 228: /* alter_table_option ::= COMMENT NK_STRING */ -#line 435 "sql.y" + case 229: /* alter_table_option ::= COMMENT NK_STRING */ { yymsp[-1].minor.yy893.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 6341 "sql.c" break; - case 229: /* alter_table_option ::= TTL NK_INTEGER */ -#line 436 "sql.y" + case 230: /* alter_table_option ::= TTL NK_INTEGER */ { yymsp[-1].minor.yy893.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy893.val = yymsp[0].minor.yy0; } -#line 6346 "sql.c" break; - case 230: /* duration_list ::= duration_literal */ - case 447: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==447); -#line 440 "sql.y" + case 231: /* duration_list ::= duration_literal */ + case 448: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==448); { yylhsminor.yy712 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6352 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 231: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 448: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==448); -#line 441 "sql.y" + case 232: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 449: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==449); { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6359 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 234: /* rollup_func_name ::= function_name */ -#line 448 "sql.y" + case 235: /* rollup_func_name ::= function_name */ { yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy785, NULL); } -#line 6365 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 235: /* rollup_func_name ::= FIRST */ - case 236: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==236); - case 300: /* tag_item ::= QTAGS */ yytestcase(yyruleno==300); -#line 449 "sql.y" + case 236: /* rollup_func_name ::= FIRST */ + case 237: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==237); + case 301: /* tag_item ::= QTAGS */ yytestcase(yyruleno==301); { yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6373 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 239: /* col_name ::= column_name */ - case 301: /* tag_item ::= column_name */ yytestcase(yyruleno==301); -#line 457 "sql.y" + case 240: /* col_name ::= column_name */ + case 302: /* tag_item ::= column_name */ yytestcase(yyruleno==302); { yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785); } -#line 6380 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 240: /* cmd ::= SHOW DNODES */ -#line 460 "sql.y" + case 241: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } -#line 6386 "sql.c" break; - case 241: /* cmd ::= SHOW USERS */ -#line 461 "sql.y" + case 242: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } -#line 6391 "sql.c" break; - case 242: /* cmd ::= SHOW USER PRIVILEGES */ -#line 462 "sql.y" + case 243: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } -#line 6396 "sql.c" break; - case 243: /* cmd ::= SHOW db_kind_opt DATABASES */ -#line 463 "sql.y" + case 244: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy33); } -#line 6404 "sql.c" break; - case 244: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ -#line 467 "sql.y" + case 245: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy205, yymsp[0].minor.yy56, OP_TYPE_LIKE); } -#line 6411 "sql.c" break; - case 245: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -#line 470 "sql.y" + case 246: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, OP_TYPE_LIKE); } -#line 6416 "sql.c" break; - case 246: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -#line 471 "sql.y" + case 247: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy56, NULL, OP_TYPE_LIKE); } -#line 6421 "sql.c" break; - case 247: /* cmd ::= SHOW MNODES */ -#line 472 "sql.y" + case 248: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -#line 6426 "sql.c" break; - case 248: /* cmd ::= SHOW QNODES */ -#line 474 "sql.y" + case 249: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } -#line 6431 "sql.c" break; - case 249: /* cmd ::= SHOW FUNCTIONS */ -#line 475 "sql.y" + case 250: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } -#line 6436 "sql.c" break; - case 250: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -#line 476 "sql.y" + case 251: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } -#line 6441 "sql.c" break; - case 251: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -#line 477 "sql.y" + case 252: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } -#line 6446 "sql.c" break; - case 252: /* cmd ::= SHOW STREAMS */ -#line 478 "sql.y" + case 253: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } -#line 6451 "sql.c" break; - case 253: /* cmd ::= SHOW ACCOUNTS */ -#line 479 "sql.y" + case 254: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6456 "sql.c" break; - case 254: /* cmd ::= SHOW APPS */ -#line 480 "sql.y" + case 255: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } -#line 6461 "sql.c" break; - case 255: /* cmd ::= SHOW CONNECTIONS */ -#line 481 "sql.y" + case 256: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } -#line 6466 "sql.c" break; - case 256: /* cmd ::= SHOW LICENCES */ - case 257: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==257); -#line 482 "sql.y" + case 257: /* cmd ::= SHOW LICENCES */ + case 258: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==258); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } -#line 6472 "sql.c" break; - case 258: /* cmd ::= SHOW CREATE DATABASE db_name */ -#line 484 "sql.y" + case 259: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy785); } -#line 6477 "sql.c" break; - case 259: /* cmd ::= SHOW CREATE TABLE full_table_name */ -#line 485 "sql.y" + case 260: /* cmd ::= SHOW CREATE TABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy56); } -#line 6482 "sql.c" break; - case 260: /* cmd ::= SHOW CREATE STABLE full_table_name */ -#line 486 "sql.y" + case 261: /* cmd ::= SHOW CREATE STABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy56); } -#line 6487 "sql.c" break; - case 261: /* cmd ::= SHOW QUERIES */ -#line 487 "sql.y" + case 262: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } -#line 6492 "sql.c" break; - case 262: /* cmd ::= SHOW SCORES */ -#line 488 "sql.y" + case 263: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } -#line 6497 "sql.c" break; - case 263: /* cmd ::= SHOW TOPICS */ -#line 489 "sql.y" + case 264: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } -#line 6502 "sql.c" break; - case 264: /* cmd ::= SHOW VARIABLES */ - case 265: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==265); -#line 490 "sql.y" + case 265: /* cmd ::= SHOW VARIABLES */ + case 266: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==266); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } -#line 6508 "sql.c" break; - case 266: /* cmd ::= SHOW LOCAL VARIABLES */ -#line 492 "sql.y" + case 267: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } -#line 6513 "sql.c" break; - case 267: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -#line 493 "sql.y" + case 268: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy56); } -#line 6518 "sql.c" break; - case 268: /* cmd ::= SHOW BNODES */ -#line 494 "sql.y" + case 269: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } -#line 6523 "sql.c" break; - case 269: /* cmd ::= SHOW SNODES */ -#line 495 "sql.y" + case 270: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } -#line 6528 "sql.c" break; - case 270: /* cmd ::= SHOW CLUSTER */ -#line 496 "sql.y" + case 271: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } -#line 6533 "sql.c" break; - case 271: /* cmd ::= SHOW TRANSACTIONS */ -#line 497 "sql.y" + case 272: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } -#line 6538 "sql.c" break; - case 272: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -#line 498 "sql.y" + case 273: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy56); } -#line 6543 "sql.c" break; - case 273: /* cmd ::= SHOW CONSUMERS */ -#line 499 "sql.y" + case 274: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } -#line 6548 "sql.c" break; - case 274: /* cmd ::= SHOW SUBSCRIPTIONS */ -#line 500 "sql.y" + case 275: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } -#line 6553 "sql.c" break; - case 275: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -#line 501 "sql.y" + case 276: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy56, yymsp[-1].minor.yy56, OP_TYPE_EQUAL); } -#line 6558 "sql.c" break; - case 276: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -#line 502 "sql.y" + case 277: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), OP_TYPE_EQUAL); } -#line 6563 "sql.c" break; - case 277: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -#line 503 "sql.y" + case 278: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56, yymsp[-3].minor.yy712); } -#line 6568 "sql.c" break; - case 278: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -#line 504 "sql.y" + case 279: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ { pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy785), yymsp[-4].minor.yy712); } -#line 6573 "sql.c" break; - case 279: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ -#line 505 "sql.y" + case 280: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } -#line 6578 "sql.c" break; - case 280: /* cmd ::= SHOW VNODES */ -#line 506 "sql.y" + case 281: /* cmd ::= SHOW VNODES */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } -#line 6583 "sql.c" break; - case 281: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -#line 508 "sql.y" + case 282: /* cmd ::= SHOW db_name_cond_opt ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy56, QUERY_NODE_SHOW_DB_ALIVE_STMT); } -#line 6588 "sql.c" break; - case 282: /* cmd ::= SHOW CLUSTER ALIVE */ -#line 509 "sql.y" + case 283: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -#line 6593 "sql.c" break; - case 283: /* table_kind_db_name_cond_opt ::= */ -#line 513 "sql.y" + case 284: /* table_kind_db_name_cond_opt ::= */ { yymsp[1].minor.yy205.kind = SHOW_KIND_ALL; yymsp[1].minor.yy205.dbName = nil_token; } -#line 6598 "sql.c" break; - case 284: /* table_kind_db_name_cond_opt ::= table_kind */ -#line 514 "sql.y" + case 285: /* table_kind_db_name_cond_opt ::= table_kind */ { yylhsminor.yy205.kind = yymsp[0].minor.yy33; yylhsminor.yy205.dbName = nil_token; } -#line 6603 "sql.c" yymsp[0].minor.yy205 = yylhsminor.yy205; break; - case 285: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -#line 515 "sql.y" + case 286: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ { yylhsminor.yy205.kind = SHOW_KIND_ALL; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } -#line 6609 "sql.c" yymsp[-1].minor.yy205 = yylhsminor.yy205; break; - case 286: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -#line 516 "sql.y" + case 287: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ { yylhsminor.yy205.kind = yymsp[-2].minor.yy33; yylhsminor.yy205.dbName = yymsp[-1].minor.yy785; } -#line 6615 "sql.c" yymsp[-2].minor.yy205 = yylhsminor.yy205; break; - case 287: /* table_kind ::= NORMAL */ -#line 520 "sql.y" + case 288: /* table_kind ::= NORMAL */ { yymsp[0].minor.yy33 = SHOW_KIND_TABLES_NORMAL; } -#line 6621 "sql.c" break; - case 288: /* table_kind ::= CHILD */ -#line 521 "sql.y" + case 289: /* table_kind ::= CHILD */ { yymsp[0].minor.yy33 = SHOW_KIND_TABLES_CHILD; } -#line 6626 "sql.c" break; - case 289: /* db_name_cond_opt ::= */ - case 294: /* from_db_opt ::= */ yytestcase(yyruleno==294); -#line 523 "sql.y" + case 290: /* db_name_cond_opt ::= */ + case 295: /* from_db_opt ::= */ yytestcase(yyruleno==295); { yymsp[1].minor.yy56 = createDefaultDatabaseCondValue(pCxt); } -#line 6632 "sql.c" break; - case 290: /* db_name_cond_opt ::= db_name NK_DOT */ -#line 524 "sql.y" + case 291: /* db_name_cond_opt ::= db_name NK_DOT */ { yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy785); } -#line 6637 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 292: /* like_pattern_opt ::= LIKE NK_STRING */ -#line 527 "sql.y" + case 293: /* like_pattern_opt ::= LIKE NK_STRING */ { yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 6643 "sql.c" break; - case 293: /* table_name_cond ::= table_name */ -#line 529 "sql.y" + case 294: /* table_name_cond ::= table_name */ { yylhsminor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } -#line 6648 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 295: /* from_db_opt ::= FROM db_name */ -#line 532 "sql.y" + case 296: /* from_db_opt ::= FROM db_name */ { yymsp[-1].minor.yy56 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy785); } -#line 6654 "sql.c" break; - case 299: /* tag_item ::= TBNAME */ -#line 540 "sql.y" + case 300: /* tag_item ::= TBNAME */ { yylhsminor.yy56 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } -#line 6659 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 302: /* tag_item ::= column_name column_alias */ -#line 543 "sql.y" + case 303: /* tag_item ::= column_name column_alias */ { yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy785), &yymsp[0].minor.yy785); } -#line 6665 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 303: /* tag_item ::= column_name AS column_alias */ -#line 544 "sql.y" + case 304: /* tag_item ::= column_name AS column_alias */ { yylhsminor.yy56 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy785), &yymsp[0].minor.yy785); } -#line 6671 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 304: /* db_kind_opt ::= */ -#line 548 "sql.y" + case 305: /* db_kind_opt ::= */ { yymsp[1].minor.yy33 = SHOW_KIND_ALL; } -#line 6677 "sql.c" break; - case 305: /* db_kind_opt ::= USER */ -#line 549 "sql.y" + case 306: /* db_kind_opt ::= USER */ { yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_USER; } -#line 6682 "sql.c" break; - case 306: /* db_kind_opt ::= SYSTEM */ -#line 550 "sql.y" + case 307: /* db_kind_opt ::= SYSTEM */ { yymsp[0].minor.yy33 = SHOW_KIND_DATABASES_SYSTEM; } -#line 6687 "sql.c" break; - case 307: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -#line 554 "sql.y" + case 308: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy425, yymsp[-3].minor.yy56, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } -#line 6692 "sql.c" break; - case 308: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -#line 556 "sql.y" + case 309: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy425, yymsp[-5].minor.yy56, yymsp[-3].minor.yy56, yymsp[-1].minor.yy712, NULL); } -#line 6697 "sql.c" break; - case 309: /* cmd ::= DROP INDEX exists_opt full_index_name */ -#line 557 "sql.y" + case 310: /* cmd ::= DROP INDEX exists_opt full_index_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy425, yymsp[0].minor.yy56); } -#line 6702 "sql.c" break; - case 310: /* full_index_name ::= index_name */ -#line 559 "sql.y" + case 311: /* full_index_name ::= index_name */ { yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy785); } -#line 6707 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 311: /* full_index_name ::= db_name NK_DOT index_name */ -#line 560 "sql.y" + case 312: /* full_index_name ::= db_name NK_DOT index_name */ { yylhsminor.yy56 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } -#line 6713 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 312: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -#line 563 "sql.y" + case 313: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { yymsp[-9].minor.yy56 = createIndexOption(pCxt, yymsp[-7].minor.yy712, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6719 "sql.c" break; - case 313: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -#line 566 "sql.y" + case 314: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ { yymsp[-11].minor.yy56 = createIndexOption(pCxt, yymsp[-9].minor.yy712, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6724 "sql.c" break; - case 316: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -#line 573 "sql.y" + case 317: /* func ::= sma_func_name NK_LP expression_list NK_RP */ { yylhsminor.yy56 = createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712); } -#line 6729 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 317: /* sma_func_name ::= function_name */ - case 536: /* alias_opt ::= table_alias */ yytestcase(yyruleno==536); -#line 577 "sql.y" + case 318: /* sma_func_name ::= function_name */ + case 537: /* alias_opt ::= table_alias */ yytestcase(yyruleno==537); { yylhsminor.yy785 = yymsp[0].minor.yy785; } -#line 6736 "sql.c" yymsp[0].minor.yy785 = yylhsminor.yy785; break; - case 322: /* sma_stream_opt ::= */ - case 363: /* stream_options ::= */ yytestcase(yyruleno==363); -#line 583 "sql.y" + case 323: /* sma_stream_opt ::= */ + case 364: /* stream_options ::= */ yytestcase(yyruleno==364); { yymsp[1].minor.yy56 = createStreamOptions(pCxt); } -#line 6743 "sql.c" break; - case 323: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -#line 584 "sql.y" + case 324: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy56)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6748 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 324: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -#line 585 "sql.y" + case 325: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy56)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6754 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 325: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -#line 586 "sql.y" + case 326: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy56)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = yymsp[-2].minor.yy56; } -#line 6760 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 326: /* with_meta ::= AS */ -#line 591 "sql.y" + case 327: /* with_meta ::= AS */ { yymsp[0].minor.yy676 = 0; } -#line 6766 "sql.c" break; - case 327: /* with_meta ::= WITH META AS */ -#line 592 "sql.y" + case 328: /* with_meta ::= WITH META AS */ { yymsp[-2].minor.yy676 = 1; } -#line 6771 "sql.c" break; - case 328: /* with_meta ::= ONLY META AS */ -#line 593 "sql.y" + case 329: /* with_meta ::= ONLY META AS */ { yymsp[-2].minor.yy676 = 2; } -#line 6776 "sql.c" break; - case 329: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -#line 595 "sql.y" + case 330: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, yymsp[0].minor.yy56); } -#line 6781 "sql.c" break; - case 330: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -#line 597 "sql.y" + case 331: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy425, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy785, yymsp[-2].minor.yy676); } -#line 6786 "sql.c" break; - case 331: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -#line 599 "sql.y" + case 332: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy425, &yymsp[-4].minor.yy785, yymsp[-1].minor.yy56, yymsp[-3].minor.yy676, yymsp[0].minor.yy56); } -#line 6791 "sql.c" break; - case 332: /* cmd ::= DROP TOPIC exists_opt topic_name */ -#line 601 "sql.y" + case 333: /* cmd ::= DROP TOPIC exists_opt topic_name */ { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6796 "sql.c" break; - case 333: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -#line 602 "sql.y" + case 334: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy425, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785); } -#line 6801 "sql.c" break; - case 334: /* cmd ::= DESC full_table_name */ - case 335: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==335); -#line 605 "sql.y" + case 335: /* cmd ::= DESC full_table_name */ + case 336: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==336); { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy56); } -#line 6807 "sql.c" break; - case 336: /* cmd ::= RESET QUERY CACHE */ -#line 609 "sql.y" + case 337: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } -#line 6812 "sql.c" break; - case 337: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 338: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==338); -#line 612 "sql.y" + case 338: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 339: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==339); { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6818 "sql.c" break; - case 341: /* explain_options ::= */ -#line 620 "sql.y" + case 342: /* explain_options ::= */ { yymsp[1].minor.yy56 = createDefaultExplainOptions(pCxt); } -#line 6823 "sql.c" break; - case 342: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -#line 621 "sql.y" + case 343: /* explain_options ::= explain_options VERBOSE NK_BOOL */ { yylhsminor.yy56 = setExplainVerbose(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } -#line 6828 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 343: /* explain_options ::= explain_options RATIO NK_FLOAT */ -#line 622 "sql.y" + case 344: /* explain_options ::= explain_options RATIO NK_FLOAT */ { yylhsminor.yy56 = setExplainRatio(pCxt, yymsp[-2].minor.yy56, &yymsp[0].minor.yy0); } -#line 6834 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 344: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -#line 627 "sql.y" + case 345: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ { pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy425, yymsp[-9].minor.yy425, &yymsp[-6].minor.yy785, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy448, yymsp[-1].minor.yy676, &yymsp[0].minor.yy785, yymsp[-10].minor.yy425); } -#line 6840 "sql.c" break; - case 345: /* cmd ::= DROP FUNCTION exists_opt function_name */ -#line 628 "sql.y" + case 346: /* cmd ::= DROP FUNCTION exists_opt function_name */ { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6845 "sql.c" break; - case 350: /* language_opt ::= */ - case 384: /* on_vgroup_id ::= */ yytestcase(yyruleno==384); -#line 642 "sql.y" + case 351: /* language_opt ::= */ + case 385: /* on_vgroup_id ::= */ yytestcase(yyruleno==385); { yymsp[1].minor.yy785 = nil_token; } -#line 6851 "sql.c" break; - case 351: /* language_opt ::= LANGUAGE NK_STRING */ - case 385: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==385); -#line 643 "sql.y" + case 352: /* language_opt ::= LANGUAGE NK_STRING */ + case 386: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==386); { yymsp[-1].minor.yy785 = yymsp[0].minor.yy0; } -#line 6857 "sql.c" break; - case 354: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -#line 653 "sql.y" + case 355: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ { pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy425, &yymsp[-8].minor.yy785, yymsp[-5].minor.yy56, yymsp[-7].minor.yy56, yymsp[-3].minor.yy712, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, yymsp[-4].minor.yy712); } -#line 6862 "sql.c" break; - case 355: /* cmd ::= DROP STREAM exists_opt stream_name */ -#line 654 "sql.y" + case 356: /* cmd ::= DROP STREAM exists_opt stream_name */ { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6867 "sql.c" break; - case 356: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -#line 655 "sql.y" + case 357: /* cmd ::= PAUSE STREAM exists_opt stream_name */ { pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6872 "sql.c" break; - case 357: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -#line 656 "sql.y" + case 358: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ { pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy425, yymsp[-1].minor.yy425, &yymsp[0].minor.yy785); } -#line 6877 "sql.c" break; - case 364: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 365: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==365); -#line 670 "sql.y" + case 365: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 366: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==366); { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6883 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 366: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -#line 672 "sql.y" + case 367: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6889 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 367: /* stream_options ::= stream_options WATERMARK duration_literal */ -#line 673 "sql.y" + case 368: /* stream_options ::= stream_options WATERMARK duration_literal */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6895 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 368: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -#line 674 "sql.y" + case 369: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } -#line 6901 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 369: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -#line 675 "sql.y" + case 370: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } -#line 6907 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 370: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -#line 676 "sql.y" + case 371: /* stream_options ::= stream_options DELETE_MARK duration_literal */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-2].minor.yy56, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 6913 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 371: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -#line 677 "sql.y" + case 372: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ { yylhsminor.yy56 = setStreamOptions(pCxt, yymsp[-3].minor.yy56, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } -#line 6919 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 373: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 574: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==574); - case 598: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==598); -#line 680 "sql.y" + case 374: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 575: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==575); + case 599: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==599); { yymsp[-3].minor.yy56 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy56); } -#line 6927 "sql.c" break; - case 376: /* cmd ::= KILL CONNECTION NK_INTEGER */ -#line 688 "sql.y" + case 377: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } -#line 6932 "sql.c" break; - case 377: /* cmd ::= KILL QUERY NK_STRING */ -#line 689 "sql.y" + case 378: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6937 "sql.c" break; - case 378: /* cmd ::= KILL TRANSACTION NK_INTEGER */ -#line 690 "sql.y" + case 379: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } -#line 6942 "sql.c" break; - case 379: /* cmd ::= BALANCE VGROUP */ -#line 693 "sql.y" + case 380: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -#line 6947 "sql.c" break; - case 380: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -#line 694 "sql.y" + case 381: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy785); } -#line 6952 "sql.c" break; - case 381: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ -#line 695 "sql.y" + case 382: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 6957 "sql.c" break; - case 382: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -#line 696 "sql.y" + case 383: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy712); } -#line 6962 "sql.c" break; - case 383: /* cmd ::= SPLIT VGROUP NK_INTEGER */ -#line 697 "sql.y" + case 384: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } -#line 6967 "sql.c" break; - case 386: /* dnode_list ::= DNODE NK_INTEGER */ -#line 706 "sql.y" + case 387: /* dnode_list ::= DNODE NK_INTEGER */ { yymsp[-1].minor.yy712 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6972 "sql.c" break; - case 388: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -#line 713 "sql.y" + case 389: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 6977 "sql.c" break; - case 391: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -#line 722 "sql.y" + case 392: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ { yymsp[-6].minor.yy56 = createInsertStmt(pCxt, yymsp[-4].minor.yy56, yymsp[-2].minor.yy712, yymsp[0].minor.yy56); } -#line 6982 "sql.c" break; - case 392: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -#line 723 "sql.y" + case 393: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ { yymsp[-3].minor.yy56 = createInsertStmt(pCxt, yymsp[-1].minor.yy56, NULL, yymsp[0].minor.yy56); } -#line 6987 "sql.c" break; - case 393: /* literal ::= NK_INTEGER */ -#line 726 "sql.y" + case 394: /* literal ::= NK_INTEGER */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } -#line 6992 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 394: /* literal ::= NK_FLOAT */ -#line 727 "sql.y" + case 395: /* literal ::= NK_FLOAT */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } -#line 6998 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 395: /* literal ::= NK_STRING */ -#line 728 "sql.y" + case 396: /* literal ::= NK_STRING */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 7004 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 396: /* literal ::= NK_BOOL */ -#line 729 "sql.y" + case 397: /* literal ::= NK_BOOL */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } -#line 7010 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 397: /* literal ::= TIMESTAMP NK_STRING */ -#line 730 "sql.y" + case 398: /* literal ::= TIMESTAMP NK_STRING */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } -#line 7016 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 398: /* literal ::= duration_literal */ - case 408: /* signed_literal ::= signed */ yytestcase(yyruleno==408); - case 430: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==430); - case 431: /* expression ::= literal */ yytestcase(yyruleno==431); - case 433: /* expression ::= column_reference */ yytestcase(yyruleno==433); - case 434: /* expression ::= function_expression */ yytestcase(yyruleno==434); - case 435: /* expression ::= case_when_expression */ yytestcase(yyruleno==435); - case 468: /* function_expression ::= literal_func */ yytestcase(yyruleno==468); - case 517: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==517); - case 521: /* boolean_primary ::= predicate */ yytestcase(yyruleno==521); - case 523: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==523); - case 524: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==524); - case 527: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==527); - case 529: /* table_reference ::= table_primary */ yytestcase(yyruleno==529); - case 530: /* table_reference ::= joined_table */ yytestcase(yyruleno==530); - case 534: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==534); - case 600: /* query_simple ::= query_specification */ yytestcase(yyruleno==600); - case 601: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==601); - case 604: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==604); - case 606: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==606); -#line 731 "sql.y" + case 399: /* literal ::= duration_literal */ + case 409: /* signed_literal ::= signed */ yytestcase(yyruleno==409); + case 431: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==431); + case 432: /* expression ::= literal */ yytestcase(yyruleno==432); + case 434: /* expression ::= column_reference */ yytestcase(yyruleno==434); + case 435: /* expression ::= function_expression */ yytestcase(yyruleno==435); + case 436: /* expression ::= case_when_expression */ yytestcase(yyruleno==436); + case 469: /* function_expression ::= literal_func */ yytestcase(yyruleno==469); + case 518: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==518); + case 522: /* boolean_primary ::= predicate */ yytestcase(yyruleno==522); + case 524: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==524); + case 525: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==525); + case 528: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==528); + case 530: /* table_reference ::= table_primary */ yytestcase(yyruleno==530); + case 531: /* table_reference ::= joined_table */ yytestcase(yyruleno==531); + case 535: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==535); + case 601: /* query_simple ::= query_specification */ yytestcase(yyruleno==601); + case 602: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==602); + case 605: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==605); + case 607: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==607); { yylhsminor.yy56 = yymsp[0].minor.yy56; } -#line 7041 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 399: /* literal ::= NULL */ -#line 732 "sql.y" + case 400: /* literal ::= NULL */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } -#line 7047 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 400: /* literal ::= NK_QUESTION */ -#line 733 "sql.y" + case 401: /* literal ::= NK_QUESTION */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7053 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 401: /* duration_literal ::= NK_VARIABLE */ - case 575: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==575); - case 576: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==576); - case 577: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==577); -#line 735 "sql.y" + case 402: /* duration_literal ::= NK_VARIABLE */ + case 576: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==576); + case 577: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==577); + case 578: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==578); { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7062 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 402: /* signed ::= NK_INTEGER */ -#line 737 "sql.y" + case 403: /* signed ::= NK_INTEGER */ { yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7068 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 403: /* signed ::= NK_PLUS NK_INTEGER */ -#line 738 "sql.y" + case 404: /* signed ::= NK_PLUS NK_INTEGER */ { yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7074 "sql.c" break; - case 404: /* signed ::= NK_MINUS NK_INTEGER */ -#line 739 "sql.y" + case 405: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } -#line 7083 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 405: /* signed ::= NK_FLOAT */ -#line 744 "sql.y" + case 406: /* signed ::= NK_FLOAT */ { yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7089 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 406: /* signed ::= NK_PLUS NK_FLOAT */ -#line 745 "sql.y" + case 407: /* signed ::= NK_PLUS NK_FLOAT */ { yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7095 "sql.c" break; - case 407: /* signed ::= NK_MINUS NK_FLOAT */ -#line 746 "sql.y" + case 408: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } -#line 7104 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 409: /* signed_literal ::= NK_STRING */ -#line 753 "sql.y" + case 410: /* signed_literal ::= NK_STRING */ { yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7110 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 410: /* signed_literal ::= NK_BOOL */ -#line 754 "sql.y" + case 411: /* signed_literal ::= NK_BOOL */ { yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } -#line 7116 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 411: /* signed_literal ::= TIMESTAMP NK_STRING */ -#line 755 "sql.y" + case 412: /* signed_literal ::= TIMESTAMP NK_STRING */ { yymsp[-1].minor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7122 "sql.c" break; - case 412: /* signed_literal ::= duration_literal */ - case 414: /* signed_literal ::= literal_func */ yytestcase(yyruleno==414); - case 488: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==488); - case 554: /* select_item ::= common_expression */ yytestcase(yyruleno==554); - case 564: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==564); - case 605: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==605); - case 607: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==607); - case 620: /* search_condition ::= common_expression */ yytestcase(yyruleno==620); -#line 756 "sql.y" + case 413: /* signed_literal ::= duration_literal */ + case 415: /* signed_literal ::= literal_func */ yytestcase(yyruleno==415); + case 489: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==489); + case 555: /* select_item ::= common_expression */ yytestcase(yyruleno==555); + case 565: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==565); + case 606: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==606); + case 608: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==608); + case 621: /* search_condition ::= common_expression */ yytestcase(yyruleno==621); { yylhsminor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } -#line 7134 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 413: /* signed_literal ::= NULL */ -#line 757 "sql.y" + case 414: /* signed_literal ::= NULL */ { yylhsminor.yy56 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } -#line 7140 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 415: /* signed_literal ::= NK_QUESTION */ -#line 759 "sql.y" + case 416: /* signed_literal ::= NK_QUESTION */ { yylhsminor.yy56 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } -#line 7146 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 432: /* expression ::= pseudo_column */ -#line 817 "sql.y" + case 433: /* expression ::= pseudo_column */ { yylhsminor.yy56 = yymsp[0].minor.yy56; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy56, true); } -#line 7152 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 436: /* expression ::= NK_LP expression NK_RP */ - case 522: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==522); - case 619: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==619); -#line 821 "sql.y" + case 437: /* expression ::= NK_LP expression NK_RP */ + case 523: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==523); + case 620: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==620); { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7160 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 437: /* expression ::= NK_PLUS expr_or_subquery */ -#line 822 "sql.y" + case 438: /* expression ::= NK_PLUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 7169 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 438: /* expression ::= NK_MINUS expr_or_subquery */ -#line 826 "sql.y" + case 439: /* expression ::= NK_MINUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy56), NULL)); } -#line 7178 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 439: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ -#line 830 "sql.y" + case 440: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7188 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 440: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ -#line 835 "sql.y" + case 441: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7198 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 441: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ -#line 840 "sql.y" + case 442: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7208 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 442: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ -#line 845 "sql.y" + case 443: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7218 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 443: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ -#line 850 "sql.y" + case 444: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7228 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 444: /* expression ::= column_reference NK_ARROW NK_STRING */ -#line 855 "sql.y" + case 445: /* expression ::= column_reference NK_ARROW NK_STRING */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } -#line 7237 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 445: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ -#line 859 "sql.y" + case 446: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7247 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 446: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ -#line 864 "sql.y" + case 447: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7257 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 449: /* column_reference ::= column_name */ -#line 875 "sql.y" + case 450: /* column_reference ::= column_name */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy785, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy785)); } -#line 7263 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 450: /* column_reference ::= table_name NK_DOT column_name */ -#line 876 "sql.y" + case 451: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy785)); } -#line 7269 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 451: /* column_reference ::= NK_ALIAS */ -#line 877 "sql.y" + case 452: /* column_reference ::= NK_ALIAS */ { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7275 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 452: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -#line 878 "sql.y" + case 453: /* column_reference ::= table_name NK_DOT NK_ALIAS */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0)); } -#line 7281 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 453: /* pseudo_column ::= ROWTS */ - case 454: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==454); - case 456: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==456); - case 457: /* pseudo_column ::= QEND */ yytestcase(yyruleno==457); - case 458: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==458); - case 459: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==459); - case 460: /* pseudo_column ::= WEND */ yytestcase(yyruleno==460); - case 461: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==461); - case 462: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==462); - case 463: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==463); - case 464: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==464); - case 470: /* literal_func ::= NOW */ yytestcase(yyruleno==470); -#line 880 "sql.y" + case 454: /* pseudo_column ::= ROWTS */ + case 455: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==455); + case 457: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==457); + case 458: /* pseudo_column ::= QEND */ yytestcase(yyruleno==458); + case 459: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==459); + case 460: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==460); + case 461: /* pseudo_column ::= WEND */ yytestcase(yyruleno==461); + case 462: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==462); + case 463: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==463); + case 464: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==464); + case 465: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==465); + case 471: /* literal_func ::= NOW */ yytestcase(yyruleno==471); { yylhsminor.yy56 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } -#line 7298 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 455: /* pseudo_column ::= table_name NK_DOT TBNAME */ -#line 882 "sql.y" + case 456: /* pseudo_column ::= table_name NK_DOT TBNAME */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy785)))); } -#line 7304 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 465: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 466: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==466); -#line 893 "sql.y" + case 466: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 467: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==467); { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy785, yymsp[-1].minor.yy712)); } -#line 7311 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 467: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -#line 896 "sql.y" + case 468: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy448)); } -#line 7317 "sql.c" yymsp[-5].minor.yy56 = yylhsminor.yy56; break; - case 469: /* literal_func ::= noarg_func NK_LP NK_RP */ -#line 899 "sql.y" + case 470: /* literal_func ::= noarg_func NK_LP NK_RP */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy785, NULL)); } -#line 7323 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 484: /* star_func_para_list ::= NK_STAR */ -#line 923 "sql.y" + case 485: /* star_func_para_list ::= NK_STAR */ { yylhsminor.yy712 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7329 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 489: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 557: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==557); -#line 932 "sql.y" + case 490: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 558: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==558); { yylhsminor.yy56 = createColumnNode(pCxt, &yymsp[-2].minor.yy785, &yymsp[0].minor.yy0); } -#line 7336 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 490: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -#line 935 "sql.y" + case 491: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy712, yymsp[-1].minor.yy56)); } -#line 7342 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 491: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -#line 937 "sql.y" + case 492: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-2].minor.yy712, yymsp[-1].minor.yy56)); } -#line 7348 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 494: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -#line 944 "sql.y" + case 495: /* when_then_expr ::= WHEN common_expression THEN common_expression */ { yymsp[-3].minor.yy56 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56)); } -#line 7354 "sql.c" break; - case 496: /* case_when_else_opt ::= ELSE common_expression */ -#line 947 "sql.y" + case 497: /* case_when_else_opt ::= ELSE common_expression */ { yymsp[-1].minor.yy56 = releaseRawExprNode(pCxt, yymsp[0].minor.yy56); } -#line 7359 "sql.c" break; - case 497: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 502: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==502); -#line 950 "sql.y" + case 498: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 503: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==503); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy380, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7369 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 498: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 957 "sql.y" + case 499: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy56), releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7379 "sql.c" yymsp[-4].minor.yy56 = yylhsminor.yy56; break; - case 499: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 963 "sql.y" + case 500: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7389 "sql.c" yymsp[-5].minor.yy56 = yylhsminor.yy56; break; - case 500: /* predicate ::= expr_or_subquery IS NULL */ -#line 968 "sql.y" + case 501: /* predicate ::= expr_or_subquery IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), NULL)); } -#line 7398 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 501: /* predicate ::= expr_or_subquery IS NOT NULL */ -#line 972 "sql.y" + case 502: /* predicate ::= expr_or_subquery IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL)); } -#line 7407 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 503: /* compare_op ::= NK_LT */ -#line 984 "sql.y" + case 504: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } -#line 7413 "sql.c" break; - case 504: /* compare_op ::= NK_GT */ -#line 985 "sql.y" + case 505: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } -#line 7418 "sql.c" break; - case 505: /* compare_op ::= NK_LE */ -#line 986 "sql.y" + case 506: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } -#line 7423 "sql.c" break; - case 506: /* compare_op ::= NK_GE */ -#line 987 "sql.y" + case 507: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } -#line 7428 "sql.c" break; - case 507: /* compare_op ::= NK_NE */ -#line 988 "sql.y" + case 508: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } -#line 7433 "sql.c" break; - case 508: /* compare_op ::= NK_EQ */ -#line 989 "sql.y" + case 509: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } -#line 7438 "sql.c" break; - case 509: /* compare_op ::= LIKE */ -#line 990 "sql.y" + case 510: /* compare_op ::= LIKE */ { yymsp[0].minor.yy380 = OP_TYPE_LIKE; } -#line 7443 "sql.c" break; - case 510: /* compare_op ::= NOT LIKE */ -#line 991 "sql.y" + case 511: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } -#line 7448 "sql.c" break; - case 511: /* compare_op ::= MATCH */ -#line 992 "sql.y" + case 512: /* compare_op ::= MATCH */ { yymsp[0].minor.yy380 = OP_TYPE_MATCH; } -#line 7453 "sql.c" break; - case 512: /* compare_op ::= NMATCH */ -#line 993 "sql.y" + case 513: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } -#line 7458 "sql.c" break; - case 513: /* compare_op ::= CONTAINS */ -#line 994 "sql.y" + case 514: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy380 = OP_TYPE_JSON_CONTAINS; } -#line 7463 "sql.c" break; - case 514: /* in_op ::= IN */ -#line 998 "sql.y" + case 515: /* in_op ::= IN */ { yymsp[0].minor.yy380 = OP_TYPE_IN; } -#line 7468 "sql.c" break; - case 515: /* in_op ::= NOT IN */ -#line 999 "sql.y" + case 516: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } -#line 7473 "sql.c" break; - case 516: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -#line 1001 "sql.y" + case 517: /* in_predicate_value ::= NK_LP literal_list NK_RP */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7478 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 518: /* boolean_value_expression ::= NOT boolean_primary */ -#line 1005 "sql.y" + case 519: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy56), NULL)); } -#line 7487 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 519: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ -#line 1010 "sql.y" + case 520: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7497 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 520: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ -#line 1016 "sql.y" + case 521: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy56); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy56); yylhsminor.yy56 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7507 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 528: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -#line 1034 "sql.y" + case 529: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy56 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy56, yymsp[0].minor.yy56, NULL); } -#line 7513 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 531: /* table_primary ::= table_name alias_opt */ -#line 1040 "sql.y" + case 532: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy56 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 7519 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 532: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -#line 1041 "sql.y" + case 533: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy56 = createRealTableNode(pCxt, &yymsp[-3].minor.yy785, &yymsp[-1].minor.yy785, &yymsp[0].minor.yy785); } -#line 7525 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 533: /* table_primary ::= subquery alias_opt */ -#line 1042 "sql.y" + case 534: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy56 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } -#line 7531 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 535: /* alias_opt ::= */ -#line 1047 "sql.y" + case 536: /* alias_opt ::= */ { yymsp[1].minor.yy785 = nil_token; } -#line 7537 "sql.c" break; - case 537: /* alias_opt ::= AS table_alias */ -#line 1049 "sql.y" + case 538: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy785 = yymsp[0].minor.yy785; } -#line 7542 "sql.c" break; - case 538: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 539: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==539); -#line 1051 "sql.y" + case 539: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 540: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==540); { yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56; } -#line 7548 "sql.c" break; - case 540: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -#line 1056 "sql.y" + case 541: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy56 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy56, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } -#line 7553 "sql.c" yymsp[-5].minor.yy56 = yylhsminor.yy56; break; - case 541: /* join_type ::= */ -#line 1060 "sql.y" + case 542: /* join_type ::= */ { yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } -#line 7559 "sql.c" break; - case 542: /* join_type ::= INNER */ -#line 1061 "sql.y" + case 543: /* join_type ::= INNER */ { yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } -#line 7564 "sql.c" break; - case 543: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ -#line 1067 "sql.y" + case 544: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { yymsp[-13].minor.yy56 = createSelectStmt(pCxt, yymsp[-11].minor.yy425, yymsp[-9].minor.yy712, yymsp[-8].minor.yy56, yymsp[-12].minor.yy712); yymsp[-13].minor.yy56 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy56, yymsp[-10].minor.yy425); @@ -7577,224 +6428,145 @@ static YYACTIONTYPE yy_reduce( yymsp[-13].minor.yy56 = addEveryClause(pCxt, yymsp[-13].minor.yy56, yymsp[-4].minor.yy56); yymsp[-13].minor.yy56 = addFillClause(pCxt, yymsp[-13].minor.yy56, yymsp[-3].minor.yy56); } -#line 7580 "sql.c" break; - case 544: /* hint_list ::= */ -#line 1082 "sql.y" + case 545: /* hint_list ::= */ { yymsp[1].minor.yy712 = createHintNodeList(pCxt, NULL); } -#line 7585 "sql.c" break; - case 545: /* hint_list ::= NK_HINT */ -#line 1083 "sql.y" + case 546: /* hint_list ::= NK_HINT */ { yylhsminor.yy712 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } -#line 7590 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 550: /* set_quantifier_opt ::= ALL */ -#line 1094 "sql.y" + case 551: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy425 = false; } -#line 7596 "sql.c" break; - case 553: /* select_item ::= NK_STAR */ -#line 1101 "sql.y" + case 554: /* select_item ::= NK_STAR */ { yylhsminor.yy56 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } -#line 7601 "sql.c" yymsp[0].minor.yy56 = yylhsminor.yy56; break; - case 555: /* select_item ::= common_expression column_alias */ - case 565: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==565); -#line 1103 "sql.y" + case 556: /* select_item ::= common_expression column_alias */ + case 566: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==566); { yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56), &yymsp[0].minor.yy785); } -#line 7608 "sql.c" yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 556: /* select_item ::= common_expression AS column_alias */ - case 566: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==566); -#line 1104 "sql.y" + case 557: /* select_item ::= common_expression AS column_alias */ + case 567: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==567); { yylhsminor.yy56 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), &yymsp[0].minor.yy785); } -#line 7615 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 561: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 589: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==589); - case 609: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==609); -#line 1113 "sql.y" + case 562: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 590: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==590); + case 610: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==610); { yymsp[-2].minor.yy712 = yymsp[0].minor.yy712; } -#line 7623 "sql.c" break; - case 568: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -#line 1126 "sql.y" + case 569: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ { yymsp[-5].minor.yy56 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7628 "sql.c" break; - case 569: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -#line 1127 "sql.y" + case 570: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy56 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7633 "sql.c" break; - case 570: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1129 "sql.y" + case 571: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy56 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), NULL, yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 7638 "sql.c" break; - case 571: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1133 "sql.y" + case 572: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy56 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy56), releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), yymsp[-1].minor.yy56, yymsp[0].minor.yy56); } -#line 7643 "sql.c" break; - case 572: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -#line 1135 "sql.y" + case 573: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ { yymsp[-6].minor.yy56 = createEventWindowNode(pCxt, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } -#line 7648 "sql.c" break; - case 579: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -#line 1145 "sql.y" + case 580: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy56 = createFillNode(pCxt, yymsp[-1].minor.yy774, NULL); } -#line 7653 "sql.c" break; - case 580: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -#line 1146 "sql.y" + case 581: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ { yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7658 "sql.c" break; - case 581: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -#line 1147 "sql.y" + case 582: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ { yymsp[-5].minor.yy56 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy712)); } -#line 7663 "sql.c" break; - case 582: /* fill_mode ::= NONE */ -#line 1151 "sql.y" + case 583: /* fill_mode ::= NONE */ { yymsp[0].minor.yy774 = FILL_MODE_NONE; } -#line 7668 "sql.c" break; - case 583: /* fill_mode ::= PREV */ -#line 1152 "sql.y" + case 584: /* fill_mode ::= PREV */ { yymsp[0].minor.yy774 = FILL_MODE_PREV; } -#line 7673 "sql.c" break; - case 584: /* fill_mode ::= NULL */ -#line 1153 "sql.y" + case 585: /* fill_mode ::= NULL */ { yymsp[0].minor.yy774 = FILL_MODE_NULL; } -#line 7678 "sql.c" break; - case 585: /* fill_mode ::= NULL_F */ -#line 1154 "sql.y" + case 586: /* fill_mode ::= NULL_F */ { yymsp[0].minor.yy774 = FILL_MODE_NULL_F; } -#line 7683 "sql.c" break; - case 586: /* fill_mode ::= LINEAR */ -#line 1155 "sql.y" + case 587: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy774 = FILL_MODE_LINEAR; } -#line 7688 "sql.c" break; - case 587: /* fill_mode ::= NEXT */ -#line 1156 "sql.y" + case 588: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy774 = FILL_MODE_NEXT; } -#line 7693 "sql.c" break; - case 590: /* group_by_list ::= expr_or_subquery */ -#line 1165 "sql.y" + case 591: /* group_by_list ::= expr_or_subquery */ { yylhsminor.yy712 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7698 "sql.c" yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 591: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -#line 1166 "sql.y" + case 592: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ { yylhsminor.yy712 = addNodeToList(pCxt, yymsp[-2].minor.yy712, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy56))); } -#line 7704 "sql.c" yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 595: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -#line 1173 "sql.y" + case 596: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ { yymsp[-5].minor.yy56 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy56), releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7710 "sql.c" break; - case 596: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -#line 1175 "sql.y" + case 597: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy56 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy56)); } -#line 7715 "sql.c" break; - case 599: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ -#line 1182 "sql.y" + case 600: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy56 = addOrderByClause(pCxt, yymsp[-3].minor.yy56, yymsp[-2].minor.yy712); yylhsminor.yy56 = addSlimitClause(pCxt, yylhsminor.yy56, yymsp[-1].minor.yy56); yylhsminor.yy56 = addLimitClause(pCxt, yylhsminor.yy56, yymsp[0].minor.yy56); } -#line 7724 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 602: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -#line 1192 "sql.y" + case 603: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ { yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy56, yymsp[0].minor.yy56); } -#line 7730 "sql.c" yymsp[-3].minor.yy56 = yylhsminor.yy56; break; - case 603: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -#line 1194 "sql.y" + case 604: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ { yylhsminor.yy56 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy56, yymsp[0].minor.yy56); } -#line 7736 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 611: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 615: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==615); -#line 1208 "sql.y" + case 612: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 616: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==616); { yymsp[-1].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 7743 "sql.c" break; - case 612: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 616: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==616); -#line 1209 "sql.y" + case 613: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 617: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==617); { yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } -#line 7749 "sql.c" break; - case 613: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 617: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==617); -#line 1210 "sql.y" + case 614: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 618: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==618); { yymsp[-3].minor.yy56 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } -#line 7755 "sql.c" break; - case 618: /* subquery ::= NK_LP query_expression NK_RP */ -#line 1218 "sql.y" + case 619: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy56 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy56); } -#line 7760 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 623: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -#line 1232 "sql.y" + case 624: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ { yylhsminor.yy56 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy56), yymsp[-1].minor.yy722, yymsp[0].minor.yy361); } -#line 7766 "sql.c" yymsp[-2].minor.yy56 = yylhsminor.yy56; break; - case 624: /* ordering_specification_opt ::= */ -#line 1236 "sql.y" + case 625: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy722 = ORDER_ASC; } -#line 7772 "sql.c" break; - case 625: /* ordering_specification_opt ::= ASC */ -#line 1237 "sql.y" + case 626: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy722 = ORDER_ASC; } -#line 7777 "sql.c" break; - case 626: /* ordering_specification_opt ::= DESC */ -#line 1238 "sql.y" + case 627: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy722 = ORDER_DESC; } -#line 7782 "sql.c" break; - case 627: /* null_ordering_opt ::= */ -#line 1242 "sql.y" + case 628: /* null_ordering_opt ::= */ { yymsp[1].minor.yy361 = NULL_ORDER_DEFAULT; } -#line 7787 "sql.c" break; - case 628: /* null_ordering_opt ::= NULLS FIRST */ -#line 1243 "sql.y" + case 629: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy361 = NULL_ORDER_FIRST; } -#line 7792 "sql.c" break; - case 629: /* null_ordering_opt ::= NULLS LAST */ -#line 1244 "sql.y" + case 630: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy361 = NULL_ORDER_LAST; } -#line 7797 "sql.c" break; default: break; @@ -7856,7 +6628,6 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ -#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -7867,7 +6638,6 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } -#line 7870 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE diff --git a/tests/script/tsim/sma/rsmaCreateInsertQuery.sim b/tests/script/tsim/sma/rsmaCreateInsertQuery.sim index b3144e4e0d..e5e07dfaec 100644 --- a/tests/script/tsim/sma/rsmaCreateInsertQuery.sim +++ b/tests/script/tsim/sma/rsmaCreateInsertQuery.sim @@ -5,7 +5,7 @@ sleep 50 sql connect print =============== create database with retentions -sql create database d0 retentions 5s:7d,10s:21d,15s:365d; +sql create database d0 retentions -:7d,10s:21d,15s:365d; sql use d0 print =============== create super table and register rsma diff --git a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim index 0b3938d773..6f78829db7 100644 --- a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim +++ b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim @@ -8,7 +8,7 @@ sql connect return 1 print =============== create database with retentions -sql create database d0 retentions 5s:7d,5m:21d,15m:365d; +sql create database d0 retentions -:7d,5m:21d,15m:365d; sql use d0 print =============== create super table and register rsma diff --git a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim index 6f8c095162..3b3cd01521 100644 --- a/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim +++ b/tests/script/tsim/sync/vnodesnapshot-rsma-test.sim @@ -47,7 +47,7 @@ endi $replica = 3 $vgroups = 1 -$retentions = 5s:7d,15s:21d,1m:365d +$retentions = -:7d,15s:21d,1m:365d print ============= create database sql create database db replica $replica vgroups $vgroups retentions $retentions diff --git a/tests/system-test/1-insert/block_wise.py b/tests/system-test/1-insert/block_wise.py index 8222000cd6..1aff2e7708 100644 --- a/tests/system-test/1-insert/block_wise.py +++ b/tests/system-test/1-insert/block_wise.py @@ -417,7 +417,7 @@ class TDTestCase: self.all_test() tdLog.printNoPrefix("==========step2:create table in rollup database") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db3") tdSql.query(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})") @@ -438,7 +438,7 @@ class TDTestCase: tdSql.execute("drop database if exists db_s20 ") tdLog.printNoPrefix("==========step4:insert and flush in rollup database") - tdSql.execute("create database db4 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db4 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db4") self.__create_tb(rollup="first") self.__insert_data(rollup="first") diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 9435dcd081..cd23098e60 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -54,53 +54,63 @@ class TDTestCase: return [ # check grammar "create database db1 retentions", - "create database db1 retentions 1s:1d,2s:2d,3s:3d,4s:4d", + "create database db1 retentions 1s:1d", + "create database db1 retentions 1s:1d,2s:2d", + "create database db1 retentions 1s:1d,2s:2d,3s:3d", + "create database db1 retentions -:1d,2s:2d,3s:3d,4s:4d", + "create database db1 retentions -:-", + "create database db1 retentions --:1d", + "create database db1 retentions +:1d", + "create database db1 retentions :1d", + "create database db1 retentions -:1d,-:2d", + "create database db1 retentions -:1d,1s:-", + "create database db1 retentions -:1d,15s:2d,-:3d", + # check unit - "create database db1 retentions 1b:1d", - "create database db1 retentions 1u:1d", - "create database db1 retentions 1a:1d", - "create database db1 retentions 1n:1d", - "create database db1 retentions 1y:1d", - "create database db1 retentions 1s:86400s", - "create database db1 retentions 1s:86400000a", - "create database db1 retentions 1s:86400000000u", - "create database db1 retentions 1s:86400000000000b", - "create database db1 retentions 1s:1w", - "create database db1 retentions 1s:1n", - "create database db1 retentions 1s:1y", + "create database db1 retentions -:1d,1b:1d", + "create database db1 retentions -:1d,1u:1d", + "create database db1 retentions -:1d,1a:1d", + "create database db1 retentions -:1d,1n:1d", + "create database db1 retentions -:1d,1y:1d", + "create database db1 retentions -:1d,1s:86400s", + "create database db1 retentions -:1d,1s:86400000a", + "create database db1 retentions -:1d,1s:86400000000u", + "create database db1 retentions -:1d,1s:86400000000000b", + "create database db1 retentions -:1d,1s:1w", + "create database db1 retentions -:1d,1s:1n", + "create database db1 retentions -:1d,1s:1y", + # check value range - "create database db1 retentions -1s:1d", - "create database db1 retentions 0s:1d", - "create database db3 retentions 1s:-1d", - "create database db3 retentions 1s:0d", - "create database db3 retentions 1s:1439m", - "create database db3 retentions 1s:365001d", - "create database db3 retentions 1s:8760001h", - "create database db3 retentions 1s:525600001m", - "create database db3 retentions 1s:106581d precision 'ns'", - "create database db3 retentions 1s:2557921h precision 'ns'", - "create database db3 retentions 1s:153475201m precision 'ns'", + "create database db3 retentions -:-1d", + "create database db3 retentions -:0d", + "create database db3 retentions -:1439m", + "create database db3 retentions -:365001d", + "create database db3 retentions -:8760001h", + "create database db3 retentions -:525600001m", + "create database db3 retentions -:106581d precision 'ns'", + "create database db3 retentions -:2557921h precision 'ns'", + "create database db3 retentions -:153475201m precision 'ns'", # check relationships - "create database db5 retentions 1441m:1440m,2d:3d", - "create database db5 retentions 2m:1d,1s:2d", - "create database db5 retentions 1s:2880m,2s:2879m", - "create database db5 retentions 1s:1d,2s:2d,2s:3d", - "create database db5 retentions 1s:1d,3s:2d,2s:3d", - "create database db1 retentions 1s:1d,2s:3d,3s:2d", + "create database db5 retentions -:1440m,1441m:1440m,2d:3d", + "create database db5 retentions -:1d,2m:1d,1s:2d", + "create database db5 retentions -:1440m,1s:2880m,2s:2879m", + "create database db5 retentions -:1d,2s:2d,2s:3d", + "create database db5 retentions -:1d,3s:2d,2s:3d", + "create database db1 retentions -:1d,2s:3d,3s:2d", ] @property def create_databases_sql_current(self): return [ - f"create database {DB1} retentions 1s:1d", - f"create database {DB2} retentions 1s:1d,2m:2d,3h:3d", + f"create database {DB1} retentions -:1d", + f"create database {DB2} retentions -:1d,2m:2d,3h:3d", ] @property def alter_database_sql(self): return [ - "alter database db1 retentions 99h:99d", - "alter database db2 retentions 97h:97d,98h:98d,99h:99d,", + "alter database db1 retentions -:99d", + "alter database db2 retentions -:97d,98h:98d,99h:99d,", ] @property @@ -281,7 +291,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step2:create table in rollup database") tdLog.printNoPrefix("==========step2.1 : rolluo func is not last/first") - tdSql.prepare(dbname=DB3, **{"retentions": "1s:1d, 3s:3d, 5s:5d"}) + tdSql.prepare(dbname=DB3, **{"retentions": "-:1d, 3s:3d, 5s:5d"}) db3_ctb_num = 10 self.__create_tb(rsma=True, dbname=DB3, ctb_num=db3_ctb_num, stb=STBNAME) @@ -338,7 +348,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step2.2 : rolluo func is last/first") - tdSql.prepare(dbname=DB4, **{"retentions": "1s:1d, 2m:3d, 3m:5d"}) + tdSql.prepare(dbname=DB4, **{"retentions": "-:1d, 2m:3d, 3m:5d"}) db4_ctb_num = 10 tdSql.execute(f"use {DB4}") diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py index df1cc516c5..14b717d1da 100644 --- a/tests/system-test/1-insert/time_range_wise.py +++ b/tests/system-test/1-insert/time_range_wise.py @@ -584,7 +584,7 @@ class TDTestCase: self.all_test() tdLog.printNoPrefix("==========step2:create table in rollup database") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") tdSql.execute("use db3") tdSql.execute(f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL}) ") self.all_test() @@ -603,7 +603,7 @@ class TDTestCase: # add for TS-2440 for i in range(self.rows): tdSql.execute("drop database if exists db3 ") - tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("create database db3 retentions -:4m,2s:8m,3s:12m") def stop(self): tdSql.close() From 0b4f19d55ac0aab455c7b55732622eb9f3b94b59 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 14:55:25 +0800 Subject: [PATCH 33/45] chore: check retentions of show create database --- tests/system-test/1-insert/create_retentions.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index cd23098e60..a4b2cae68a 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -182,9 +182,17 @@ class TDTestCase: def test_create_databases(self): for err_sql in self.create_databases_sql_err: tdSql.error(err_sql) + index = 0 for cur_sql in self.create_databases_sql_current: tdSql.execute(cur_sql) - # tdSql.query("select * from information_schema.ins_databases") + if(index == 0): + tdSql.query(f"show create database {DB1}") + else: + tdSql.query(f"show create database {DB2}") + tdSql.checkEqual(len(tdSql.queryResult),1) + tdLog.info("%s" % (tdSql.queryResult[0][1])) + tdSql.checkEqual(tdSql.queryResult[0][1].find("RETENTIONS -:") > 0, True) + index += 1 for alter_sql in self.alter_database_sql: tdSql.error(alter_sql) From be0a85a0ffd4fca365d150682af58ae1d562675e Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 30 Oct 2023 07:19:08 +0000 Subject: [PATCH 34/45] memory leak --- source/dnode/vnode/src/vnd/vnodeSvr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 040ae96972..d4bea4332b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1008,7 +1008,7 @@ _exit: taosArrayDestroy(tbUids); tDecoderClear(&decoder); tEncoderClear(&encoder); - taosArrayDestroy(tbNames); + taosArrayDestroyP(tbNames, taosMemoryFree); return rcode; } @@ -1225,7 +1225,7 @@ _exit: tEncodeSVDropTbBatchRsp(&encoder, &rsp); tEncoderClear(&encoder); taosArrayDestroy(rsp.pArray); - taosArrayDestroy(tbNames); + taosArrayDestroyP(tbNames, taosMemoryFree); return 0; } From 0f40e1dbb90fb638328412d83354103eafccc889 Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 30 Oct 2023 08:57:07 +0000 Subject: [PATCH 35/45] memory leak --- source/dnode/vnode/src/vnd/vnodeSvr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index d4bea4332b..81baa5a54e 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -1008,7 +1008,7 @@ _exit: taosArrayDestroy(tbUids); tDecoderClear(&decoder); tEncoderClear(&encoder); - taosArrayDestroyP(tbNames, taosMemoryFree); + taosArrayDestroyEx(tbNames, taosMemoryFree); return rcode; } @@ -1225,7 +1225,7 @@ _exit: tEncodeSVDropTbBatchRsp(&encoder, &rsp); tEncoderClear(&encoder); taosArrayDestroy(rsp.pArray); - taosArrayDestroyP(tbNames, taosMemoryFree); + taosArrayDestroyEx(tbNames, taosMemoryFree); return 0; } From da4fac4204bb9d8d17e0d7ddfc6b3ff393027f33 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 17:04:09 +0800 Subject: [PATCH 36/45] test: update test case for retentions --- source/libs/parser/test/parInitialCTest.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 856fdb4804..6219676c50 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -247,7 +247,11 @@ TEST_F(ParserInitialCTest, createDatabase) { for (int32_t i = 0; i < expect.numOfRetensions; ++i) { SRetention* pReten = (SRetention*)taosArrayGet(req.pRetensions, i); SRetention* pExpectReten = (SRetention*)taosArrayGet(expect.pRetensions, i); - ASSERT_EQ(pReten->freq, pExpectReten->freq); + if(i == 0) { + ASSERT_EQ(pReten->freq, 0); + } else { + ASSERT_EQ(pReten->freq, pExpectReten->freq); + } ASSERT_EQ(pReten->keep, pExpectReten->keep); ASSERT_EQ(pReten->freqUnit, pExpectReten->freqUnit); ASSERT_EQ(pReten->keepUnit, pExpectReten->keepUnit); @@ -304,7 +308,7 @@ TEST_F(ParserInitialCTest, createDatabase) { "PAGESIZE 8 " "PRECISION 'ns' " "REPLICA 3 " - "RETENTIONS 15s:7d,1m:21d,15m:500d " + "RETENTIONS -:7d,1m:21d,15m:500d " // "STRICT 'on' " "WAL_LEVEL 2 " "VGROUPS 100 " @@ -340,12 +344,12 @@ TEST_F(ParserInitialCTest, createDatabase) { TEST_F(ParserInitialCTest, createDatabaseSemanticCheck) { useDb("root", "test"); - run("create database db2 retentions 0s:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 10s:0d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 1w:1n", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 15s:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("create database db2 retentions 15s:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1d,0s:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:0d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1d,1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:1n,1w:1d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:7d,15m:21d,10m:500d", TSDB_CODE_PAR_INVALID_DB_OPTION); + run("create database db2 retentions -:7d,5m:21d,10m:10d", TSDB_CODE_PAR_INVALID_DB_OPTION); } /* From f852f87f94d9fff0156852bfc9f7cc35119735e3 Mon Sep 17 00:00:00 2001 From: tjuzyp Date: Mon, 30 Oct 2023 17:31:42 +0800 Subject: [PATCH 37/45] feat: do not build taosx in ci --- tests/parallel_test/container_build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index 94704b1c25..f4db7edb8b 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -69,7 +69,7 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/libuv/:${REP_DIR}/community/contrib/libuv \ -v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10|| exit 1" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j 10|| exit 1" # -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ if [[ -d ${WORKDIR}/debugNoSan ]] ;then @@ -99,7 +99,7 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=0;make -j 10|| exit 1 " + --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=false -DJEMALLOC_ENABLED=0;make -j 10|| exit 1 " mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan From 4a5b4b51e2245c463f400594ecd962090c050c32 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 17:51:42 +0800 Subject: [PATCH 38/45] chore: remove obsolete codes --- include/common/tmsg.h | 2 -- source/dnode/mgmt/node_mgmt/inc/dmMgmt.h | 8 ------ source/dnode/mgmt/node_mgmt/src/dmMgmt.c | 8 ------ source/dnode/mgmt/node_mgmt/src/dmTransport.c | 28 ------------------- source/dnode/mnode/impl/src/mndDnode.c | 2 -- 5 files changed, 48 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 331188c264..07eb8a461a 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1568,9 +1568,7 @@ typedef struct { typedef struct { int32_t id; int8_t isMnode; -#ifdef TD_GRANT_HB_OPTIMIZE int8_t offlineReason; -#endif SEp ep; char active[TSDB_ACTIVE_KEY_LEN]; char connActive[TSDB_CONN_ACTIVE_KEY_LEN]; diff --git a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h index b04d336c51..36097438a2 100644 --- a/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h +++ b/source/dnode/mgmt/node_mgmt/inc/dmMgmt.h @@ -97,11 +97,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper); void dmReleaseWrapper(SMgmtWrapper *pWrapper); int32_t dmInitVars(SDnode *pDnode); void dmClearVars(SDnode *pDnode); -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitModule(SDnode *pDnode, SMgmtWrapper *wrappers); -#else -int32_t dmInitModule(SDnode *pDnode); -#endif bool dmRequireNode(SDnode *pDnode, SMgmtWrapper *pWrapper); SMgmtInputOpt dmBuildMgmtInputOpt(SMgmtWrapper *pWrapper); void dmSetStatus(SDnode *pDnode, EDndRunStatus stype); @@ -123,11 +119,7 @@ int32_t dmInitStatusClient(SDnode *pDnode); void dmCleanupClient(SDnode *pDnode); void dmCleanupStatusClient(SDnode *pDnode); SMsgCb dmGetMsgcb(SDnode *pDnode); -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers); -#else -int32_t dmInitMsgHandle(SDnode *pDnode); -#endif int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg); // dmMonitor.c diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index e9ce4c4f89..409ee45cd3 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -66,15 +66,9 @@ int32_t dmInitDnode(SDnode *pDnode) { goto _OVER; } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) if (dmInitModule(pDnode, pDnode->wrappers) != 0) { goto _OVER; } -#else - if (dmInitModule(pDnode) != 0) { - goto _OVER; - } -#endif indexInit(tsNumOfCommitThreads); streamMetaInit(); @@ -113,7 +107,6 @@ void dmCleanupDnode(SDnode *pDnode) { dDebug("dnode is closed, ptr:%p", pDnode); } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitVars(SDnode *pDnode) { SDnodeData *pData = &pDnode->data; pData->dnodeId = 0; @@ -182,7 +175,6 @@ void dmClearVars(SDnode *pDnode) { taosThreadMutexDestroy(&pDnode->mutex); memset(&pDnode->mutex, 0, sizeof(pDnode->mutex)); } -#endif void dmSetStatus(SDnode *pDnode, EDndRunStatus status) { if (pDnode->status != status) { diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index b7381891d1..ad5ca2cecf 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -251,7 +251,6 @@ _OVER: dmReleaseWrapper(pWrapper); } -#if defined(TD_MODULE_OPTIMIZE) || !defined(TD_ENTERPRISE) int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { SDnodeTrans *pTrans = &pDnode->trans; @@ -277,33 +276,6 @@ int32_t dmInitMsgHandle(SDnode *pDnode, SMgmtWrapper *wrappers) { return 0; } -#else -int32_t dmInitMsgHandle(SDnode *pDnode) { - SDnodeTrans *pTrans = &pDnode->trans; - - for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - SArray *pArray = (*pWrapper->func.getHandlesFp)(); - if (pArray == NULL) return -1; - - for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { - SMgmtHandle *pMgmt = taosArrayGet(pArray, i); - SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)]; - if (pMgmt->needCheckVgId) { - pHandle->needCheckVgId = pMgmt->needCheckVgId; - } - if (!pMgmt->needCheckVgId) { - pHandle->defaultNtype = ntype; - } - pWrapper->msgFps[TMSG_INDEX(pMgmt->msgType)] = pMgmt->msgFp; - } - - taosArrayDestroy(pArray); - } - - return 0; -} -#endif static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { SDnode *pDnode = dmInstance(); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 4e93bcdbe7..a9aa96720c 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -397,9 +397,7 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) { SDnodeInfo dInfo; dInfo.id = pDnode->id; dInfo.ep.port = pDnode->port; -#ifdef TD_GRANT_HB_OPTIMIZE dInfo.offlineReason = pDnode->offlineReason; -#endif tstrncpy(dInfo.ep.fqdn, pDnode->fqdn, TSDB_FQDN_LEN); tstrncpy(dInfo.active, pDnode->active, TSDB_ACTIVE_KEY_LEN); tstrncpy(dInfo.connActive, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN); From fe044051c8ffd90d136bdf0192b9e53ae07ccf9f Mon Sep 17 00:00:00 2001 From: dmchen Date: Mon, 30 Oct 2023 11:34:34 +0000 Subject: [PATCH 39/45] memory leak --- source/dnode/vnode/src/vnd/vnodeSvr.c | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 81baa5a54e..b6a4aaf388 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -950,9 +950,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, taosArrayPush(rsp.pArray, &cRsp); - char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); - strcpy(str, pCreateReq->name); - taosArrayPush(tbNames, str); + if(tsEnableAuditCreateTable){ + char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); + strcpy(str, pCreateReq->name); + taosArrayPush(tbNames, &str); + } } vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); @@ -982,11 +984,12 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, SStringBuilder sb = {0}; for(int32_t iReq = 0; iReq < req.nReqs; iReq++){ - char* key = taosArrayGet(tbNames, iReq); - taosStringBuilderAppendStringLen(&sb, key, strlen(key)); + char** key = (char**)taosArrayGet(tbNames, iReq); + taosStringBuilderAppendStringLen(&sb, *key, strlen(*key)); if(iReq < req.nReqs - 1){ taosStringBuilderAppendChar(&sb, ','); } + taosMemoryFreeClear(*key); } size_t len = 0; @@ -1002,13 +1005,13 @@ _exit: pCreateReq = req.pReqs + iReq; taosMemoryFree(pCreateReq->sql); taosMemoryFree(pCreateReq->comment); - taosArrayDestroy(pCreateReq->ctb.tagName); + taosArrayDestroy(pCreateReq->ctb.tagName); } taosArrayDestroyEx(rsp.pArray, tFreeSVCreateTbRsp); taosArrayDestroy(tbUids); tDecoderClear(&decoder); tEncoderClear(&encoder); - taosArrayDestroyEx(tbNames, taosMemoryFree); + taosArrayDestroy(tbNames); return rcode; } @@ -1184,9 +1187,11 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in taosArrayPush(rsp.pArray, &dropTbRsp); - char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); - strcpy(str, pDropTbReq->name); - taosArrayPush(tbNames, str); + if(tsEnableAuditCreateTable){ + char* str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN); + strcpy(str, pDropTbReq->name); + taosArrayPush(tbNames, &str); + } } tqUpdateTbUidList(pVnode->pTq, tbUids, false); @@ -1200,17 +1205,18 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in SStringBuilder sb = {0}; for(int32_t iReq = 0; iReq < req.nReqs; iReq++){ - char* key = taosArrayGet(tbNames, iReq); - taosStringBuilderAppendStringLen(&sb, key, strlen(key)); + char** key = (char**)taosArrayGet(tbNames, iReq); + taosStringBuilderAppendStringLen(&sb, *key, strlen(*key)); if(iReq < req.nReqs - 1){ taosStringBuilderAppendChar(&sb, ','); } + taosMemoryFreeClear(*key); } size_t len = 0; char* keyJoined = taosStringBuilderGetResult(&sb, &len); - auditRecord(NULL, clusterId, "createTable", name.dbname, "", keyJoined, len); + auditRecord(NULL, clusterId, "dropTable", name.dbname, "", keyJoined, len); taosStringBuilderDestroy(&sb); } @@ -1225,7 +1231,7 @@ _exit: tEncodeSVDropTbBatchRsp(&encoder, &rsp); tEncoderClear(&encoder); taosArrayDestroy(rsp.pArray); - taosArrayDestroyEx(tbNames, taosMemoryFree); + taosArrayDestroy(tbNames); return 0; } From 89651626e3c90b627ebbaeafa49bfff2d9249783 Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 19:45:18 +0800 Subject: [PATCH 40/45] chore: reopen rsma stream commit --- source/dnode/vnode/src/inc/sma.h | 2 +- source/dnode/vnode/src/sma/smaCommit.c | 2 +- source/dnode/vnode/src/sma/smaRollup.c | 4 +++- tests/script/tsim/sma/rsmaPersistenceRecovery.sim | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index aaf0973b41..a029aadc0b 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -218,7 +218,7 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree); int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer, int8_t rollback); int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type); -// int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); +int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer, int8_t rollback); void tdRSmaQTaskInfoGetFullPath(SVnode *pVnode, tb_uid_t suid, int8_t level, STfs *pTfs, char *outputName); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index c26157f4b7..652aab3c01 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -178,7 +178,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit) { if (!isCommit) goto _exit; - // code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); + code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); TSDB_CHECK_CODE(code, lino, _exit); smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 8da2fff5a6..0d9ff4262f 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -1052,13 +1052,14 @@ _err: return code; } -#if 0 +#if 1 int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { int32_t code = 0; int32_t lino = 0; SSma *pSma = pRSmaStat->pSma; SVnode *pVnode = pSma->pVnode; SRSmaFS fs = {0}; + smaInfo("prop:%s:%d start", __func__, __LINE__); if (taosHashGetSize(pInfoHash) <= 0) { return TSDB_CODE_SUCCESS; @@ -1075,6 +1076,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pRSmaInfo, i); if (pItem && pItem->pStreamState) { + smaInfo("prop:%s:%d streamState commit", __func__, __LINE__); if (streamStateCommit(pItem->pStreamState) < 0) { code = TSDB_CODE_RSMA_STREAM_STATE_COMMIT; TSDB_CHECK_CODE(code, lino, _exit); diff --git a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim index 6f78829db7..c70f2dc20a 100644 --- a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim +++ b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim @@ -5,7 +5,7 @@ sleep 50 sql connect #todo wait for streamState checkpoint -return 1 +#return 1 print =============== create database with retentions sql create database d0 retentions -:7d,5m:21d,15m:365d; From b03baaed2cb7ce442941d846437fcb8bab00f00e Mon Sep 17 00:00:00 2001 From: kailixu Date: Mon, 30 Oct 2023 19:49:50 +0800 Subject: [PATCH 41/45] chore: revert the code change --- source/dnode/vnode/src/inc/sma.h | 2 +- source/dnode/vnode/src/sma/smaCommit.c | 2 +- source/dnode/vnode/src/sma/smaRollup.c | 4 +--- tests/script/tsim/sma/rsmaPersistenceRecovery.sim | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index a029aadc0b..aaf0973b41 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -218,7 +218,7 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree); int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer, int8_t rollback); int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName); int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type); -int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); +// int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash); int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer, int8_t rollback); void tdRSmaQTaskInfoGetFullPath(SVnode *pVnode, tb_uid_t suid, int8_t level, STfs *pTfs, char *outputName); diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index 652aab3c01..c26157f4b7 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -178,7 +178,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit) { if (!isCommit) goto _exit; - code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); + // code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)); TSDB_CHECK_CODE(code, lino, _exit); smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId()); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 0d9ff4262f..8da2fff5a6 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -1052,14 +1052,13 @@ _err: return code; } -#if 1 +#if 0 int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { int32_t code = 0; int32_t lino = 0; SSma *pSma = pRSmaStat->pSma; SVnode *pVnode = pSma->pVnode; SRSmaFS fs = {0}; - smaInfo("prop:%s:%d start", __func__, __LINE__); if (taosHashGetSize(pInfoHash) <= 0) { return TSDB_CODE_SUCCESS; @@ -1076,7 +1075,6 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) { for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) { SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pRSmaInfo, i); if (pItem && pItem->pStreamState) { - smaInfo("prop:%s:%d streamState commit", __func__, __LINE__); if (streamStateCommit(pItem->pStreamState) < 0) { code = TSDB_CODE_RSMA_STREAM_STATE_COMMIT; TSDB_CHECK_CODE(code, lino, _exit); diff --git a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim index c70f2dc20a..6f78829db7 100644 --- a/tests/script/tsim/sma/rsmaPersistenceRecovery.sim +++ b/tests/script/tsim/sma/rsmaPersistenceRecovery.sim @@ -5,7 +5,7 @@ sleep 50 sql connect #todo wait for streamState checkpoint -#return 1 +return 1 print =============== create database with retentions sql create database d0 retentions -:7d,5m:21d,15m:365d; From e800c993dd81b16175cbbf7622402d2262673587 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 31 Oct 2023 07:37:56 +0800 Subject: [PATCH 42/45] fix: set scan tags when bi mode --- source/libs/parser/src/parAstCreater.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index de7ffce2d3..c6d70667bf 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1028,11 +1028,13 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr return select; } -SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { - if (pCxt->pQueryCxt->biMode) { - ((SSelectStmt*)pStmt)->tagScan = true; - } else if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { - ((SSelectStmt*)pStmt)->tagScan = bSelectTags; +SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { + if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + if (pCxt->pQueryCxt->biMode) { + ((SSelectStmt*)pStmt)->tagScan = true; + } else { + ((SSelectStmt*)pStmt)->tagScan = bSelectTags; + } } return pStmt; } From 28cd8f4915e15f50439f09e4e7ed7088dde3935f Mon Sep 17 00:00:00 2001 From: kailixu Date: Tue, 31 Oct 2023 11:38:33 +0800 Subject: [PATCH 43/45] enh: file duration for rsma --- include/util/tdef.h | 2 +- source/dnode/vnode/src/sma/smaOpen.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/util/tdef.h b/include/util/tdef.h index bb5d4cfa96..21a290d358 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -325,7 +325,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) #define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) #define TSDB_MIN_DURATION_PER_FILE 60 // unit minute -#define TSDB_MAX_DURATION_PER_FILE (3650 * 1440) +#define TSDB_MAX_DURATION_PER_FILE (90 * 1440) #define TSDB_DEFAULT_DURATION_PER_FILE (10 * 1440) #define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute #define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index f0e329dfd7..633e096314 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -79,20 +79,18 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); - int32_t nFreqTimes = (r + level)->freq / (10 * 1000); // use 10s for freq of 1st level + int32_t nFreqTimes = (r + level)->freq / (60 * 1000); // use 60s for freq of 1st level days *= (nFreqTimes > 1 ? nFreqTimes : 1); - if (days > keepDuration) { - days = keepDuration; - } - - if (days > TSDB_MAX_DURATION_PER_FILE) { - days = TSDB_MAX_DURATION_PER_FILE; - } - if (days < freqDuration) { days = freqDuration; } + + int32_t maxKeepDuration = TMIN(keepDuration, TSDB_MAX_DURATION_PER_FILE); + if (days > maxKeepDuration) { + days = maxKeepDuration; + } + _exit: smaInfo("vgId:%d, evaluated duration for level %d is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); return days; From 72a866988bb602a9d782b5c32780714004257eec Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 31 Oct 2023 11:42:00 +0800 Subject: [PATCH 44/45] enh: disable telemetry in enterprise version --- source/common/src/tglobal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 0a155f4ea1..c6cff27011 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -104,13 +104,21 @@ uint16_t tsAuditPort = 6043; bool tsEnableAuditCreateTable = true; // telem +#ifdef TD_ENTERPRISE +bool tsEnableTelem = false; +#else bool tsEnableTelem = true; +#endif int32_t tsTelemInterval = 43200; char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.tdengine.com"; uint16_t tsTelemPort = 80; char *tsTelemUri = "/report"; +#ifdef TD_ENTERPRISE +bool tsEnableCrashReport = false; +#else bool tsEnableCrashReport = true; +#endif char *tsClientCrashReportUri = "/ccrashreport"; char *tsSvrCrashReportUri = "/dcrashreport"; From 48d5a908c20ba2059e6dd9eadbc31b09dfaff60a Mon Sep 17 00:00:00 2001 From: haoranchen Date: Tue, 31 Oct 2023 18:14:53 +0800 Subject: [PATCH 45/45] increase the timeout for CI --- Jenkinsfile2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 165d203a22..f308db759d 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -424,7 +424,7 @@ pipeline { echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}" } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 130, unit: 'MINUTES'){ + timeout(time: 150, unit: 'MINUTES'){ pre_test() script { sh '''