From da65b721d6ea0efd1b0360a406f36cd3f94e9b67 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 20:07:48 +0800 Subject: [PATCH 01/60] rename --- source/util/src/tuuid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index ceca33436a..69cf7baaad 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -15,43 +15,43 @@ #include "tuuid.h" -static int64_t hashId = 0; -static int32_t SerialNo = 0; +static int64_t tUUIDHashId = 0; +static int32_t tUUIDSerialNo = 0; int32_t tGenIdPI32(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int32_t id = ((hashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); + int32_t id = ((tUUIDHashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); return id; } int64_t tGenIdPI64(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int64_t id = ((hashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + int64_t id = ((tUUIDHashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } From b5b1417a8b0b3d9e5b19d6845b1625de817ff8d4 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 10:54:06 +0800 Subject: [PATCH 02/60] sync append entries (sync-io) --- source/libs/sync/inc/syncRaftStore.h | 12 +- source/libs/sync/src/syncIndexMgr.c | 34 +- source/libs/sync/src/syncMain.c | 235 +++++------ source/libs/sync/src/syncMessage.c | 560 +++++++++++++------------ source/libs/sync/src/syncRaftEntry.c | 42 +- source/libs/sync/src/syncRaftLog.c | 36 +- source/libs/sync/src/syncRaftStore.c | 53 ++- source/libs/sync/src/syncVoteMgr.c | 94 +++-- source/libs/sync/test/syncInitTest.cpp | 1 + 9 files changed, 565 insertions(+), 502 deletions(-) diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index 30f7c5d9f7..62bb94c834 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -43,11 +43,13 @@ int32_t raftStorePersist(SRaftStore *pRaftStore); int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len); int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len); -bool raftStoreHasVoted(SRaftStore *pRaftStore); -void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); -void raftStoreClearVote(SRaftStore *pRaftStore); -void raftStoreNextTerm(SRaftStore *pRaftStore); -void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +bool raftStoreHasVoted(SRaftStore *pRaftStore); +void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); +void raftStoreClearVote(SRaftStore *pRaftStore); +void raftStoreNextTerm(SRaftStore *pRaftStore); +void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +cJSON *raftStore2Json(SRaftStore *pRaftStore); +char *raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 9567938197..58a61ba77e 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -70,22 +70,24 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncIndexMgr->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); + if (pSyncIndexMgr != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncIndexMgr->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); + } + int respondNum = 0; + int *arr = (int *)malloc(sizeof(int) * pSyncIndexMgr->replicaNum); + for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { + arr[i] = pSyncIndexMgr->index[i]; + } + cJSON *pIndex = cJSON_CreateIntArray(arr, pSyncIndexMgr->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "index", pIndex); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); } - int respondNum = 0; - int *arr = (int *)malloc(sizeof(int) * pSyncIndexMgr->replicaNum); - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - arr[i] = pSyncIndexMgr->index[i]; - } - cJSON *pIndex = cJSON_CreateIntArray(arr, pSyncIndexMgr->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "index", pIndex); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "pSyncIndexMgr", pRoot); @@ -94,7 +96,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pJson = syncIndexMgr2Json(pSyncIndexMgr); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index dd2c142104..48a57dc0fb 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -355,128 +355,129 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - // init by SSyncInfo - cJSON_AddNumberToObject(pRoot, "vgId", pSyncNode->vgId); - cJSON_AddStringToObject(pRoot, "path", pSyncNode->path); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pWal); - cJSON_AddStringToObject(pRoot, "pWal", u64buf); + if (pSyncNode != NULL) { + // init by SSyncInfo + cJSON_AddNumberToObject(pRoot, "vgId", pSyncNode->vgId); + cJSON_AddStringToObject(pRoot, "path", pSyncNode->path); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pWal); + cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->rpcClient); - cJSON_AddStringToObject(pRoot, "rpcClient", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpSendMsg); - cJSON_AddStringToObject(pRoot, "FpSendMsg", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->rpcClient); + cJSON_AddStringToObject(pRoot, "rpcClient", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpSendMsg); + cJSON_AddStringToObject(pRoot, "FpSendMsg", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->queue); - cJSON_AddStringToObject(pRoot, "queue", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpEqMsg); - cJSON_AddStringToObject(pRoot, "FpEqMsg", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->queue); + cJSON_AddStringToObject(pRoot, "queue", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpEqMsg); + cJSON_AddStringToObject(pRoot, "FpEqMsg", u64buf); - // init internal - cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo); - cJSON_AddItemToObject(pRoot, "myNodeInfo", pMe); - cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); - cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); + // init internal + cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo); + cJSON_AddItemToObject(pRoot, "myNodeInfo", pMe); + cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); + cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); - cJSON_AddNumberToObject(pRoot, "peersNum", pSyncNode->peersNum); - cJSON* pPeers = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "peersNodeInfo", pPeers); - for (int i = 0; i < pSyncNode->peersNum; ++i) { - cJSON_AddItemToArray(pPeers, syncUtilNodeInfo2Json(&pSyncNode->peersNodeInfo[i])); + cJSON_AddNumberToObject(pRoot, "peersNum", pSyncNode->peersNum); + cJSON* pPeers = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "peersNodeInfo", pPeers); + for (int i = 0; i < pSyncNode->peersNum; ++i) { + cJSON_AddItemToArray(pPeers, syncUtilNodeInfo2Json(&pSyncNode->peersNodeInfo[i])); + } + cJSON* pPeersId = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "peersId", pPeersId); + for (int i = 0; i < pSyncNode->peersNum; ++i) { + cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); + } + + cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncNode->replicaNum); + cJSON* pReplicasId = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicasId", pReplicasId); + for (int i = 0; i < pSyncNode->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); + } + + // raft algorithm + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pFsm); + cJSON_AddStringToObject(pRoot, "pFsm", u64buf); + cJSON_AddNumberToObject(pRoot, "quorum", pSyncNode->quorum); + cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); + cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); + + // tla+ server vars + cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state); + cJSON_AddStringToObject(pRoot, "state_str", syncUtilState2String(pSyncNode->state)); + cJSON* pRaftStore = raftStore2Json(pSyncNode->pRaftStore); + cJSON_AddItemToObject(pRoot, "pRaftStore", pRaftStore); + + // tla+ candidate vars + cJSON_AddItemToObject(pRoot, "pVotesGranted", voteGranted2Json(pSyncNode->pVotesGranted)); + cJSON_AddItemToObject(pRoot, "pVotesRespond", votesRespond2Json(pSyncNode->pVotesRespond)); + + // tla+ leader vars + cJSON_AddItemToObject(pRoot, "pNextIndex", syncIndexMgr2Json(pSyncNode->pNextIndex)); + cJSON_AddItemToObject(pRoot, "pMatchIndex", syncIndexMgr2Json(pSyncNode->pMatchIndex)); + + // tla+ log vars + cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); + cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); + + // ping timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); + cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); + cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); + cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); + cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); + + // elect timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); + cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); + cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); + cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); + cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); + + // heartbeat timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); + cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); + cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); + cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); + cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); + + // callback + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPing); + cJSON_AddStringToObject(pRoot, "FpOnPing", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPingReply); + cJSON_AddStringToObject(pRoot, "FpOnPingReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVote); + cJSON_AddStringToObject(pRoot, "FpOnRequestVote", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVoteReply); + cJSON_AddStringToObject(pRoot, "FpOnRequestVoteReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntries); + cJSON_AddStringToObject(pRoot, "FpOnAppendEntries", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntriesReply); + cJSON_AddStringToObject(pRoot, "FpOnAppendEntriesReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnTimeout); + cJSON_AddStringToObject(pRoot, "FpOnTimeout", u64buf); } - cJSON* pPeersId = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "peersId", pPeersId); - for (int i = 0; i < pSyncNode->peersNum; ++i) { - cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); - } - - cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncNode->replicaNum); - cJSON* pReplicasId = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicasId", pReplicasId); - for (int i = 0; i < pSyncNode->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); - } - - // raft algorithm - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pFsm); - cJSON_AddStringToObject(pRoot, "pFsm", u64buf); - cJSON_AddNumberToObject(pRoot, "quorum", pSyncNode->quorum); - cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); - cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); - - // tla+ server vars - cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state); - cJSON_AddStringToObject(pRoot, "state_str", syncUtilState2String(pSyncNode->state)); - char tmpBuf[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pSyncNode->pRaftStore, tmpBuf, sizeof(tmpBuf)); - cJSON_AddStringToObject(pRoot, "pRaftStore", tmpBuf); - - // tla+ candidate vars - cJSON_AddItemToObject(pRoot, "pVotesGranted", voteGranted2Json(pSyncNode->pVotesGranted)); - cJSON_AddItemToObject(pRoot, "pVotesRespond", votesRespond2Json(pSyncNode->pVotesRespond)); - - // tla+ leader vars - cJSON_AddItemToObject(pRoot, "pNextIndex", syncIndexMgr2Json(pSyncNode->pNextIndex)); - cJSON_AddItemToObject(pRoot, "pMatchIndex", syncIndexMgr2Json(pSyncNode->pMatchIndex)); - - // tla+ log vars - cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); - snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); - cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); - - // ping timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); - cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); - cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); - cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); - cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); - - // elect timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); - cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); - cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); - cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); - cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); - - // heartbeat timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); - cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); - cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); - cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); - cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); - - // callback - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPing); - cJSON_AddStringToObject(pRoot, "FpOnPing", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPingReply); - cJSON_AddStringToObject(pRoot, "FpOnPingReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVote); - cJSON_AddStringToObject(pRoot, "FpOnRequestVote", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVoteReply); - cJSON_AddStringToObject(pRoot, "FpOnRequestVoteReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntries); - cJSON_AddStringToObject(pRoot, "FpOnAppendEntries", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntriesReply); - cJSON_AddStringToObject(pRoot, "FpOnAppendEntriesReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnTimeout); - cJSON_AddStringToObject(pRoot, "FpOnTimeout", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SSyncNode", pRoot); diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 509ede274b..ac7cbe9ca4 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -212,17 +212,19 @@ SyncTimeout* syncTimeoutFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncTimeout2Json(const SyncTimeout* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); - cJSON_AddStringToObject(pRoot, "logicClock", u64buf); - cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); - snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); - cJSON_AddStringToObject(pRoot, "data", u64buf); + + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); + cJSON_AddStringToObject(pRoot, "logicClock", u64buf); + cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); + snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); + cJSON_AddStringToObject(pRoot, "data", u64buf); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncTimeout", pRoot); @@ -342,50 +344,52 @@ SyncPing* syncPingFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncPing2Json(const SyncPing* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncPing", pRoot); @@ -505,50 +509,52 @@ SyncPingReply* syncPingReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncPingReply", pRoot); @@ -664,24 +670,26 @@ SyncClientRequest* syncClientRequestFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); - cJSON_AddStringToObject(pRoot, "seqNum", u64buf); - cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); + cJSON_AddStringToObject(pRoot, "seqNum", u64buf); + cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncClientRequest", pRoot); @@ -785,47 +793,49 @@ SyncRequestVote* syncRequestVoteFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); + cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); + cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); - cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); - cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncRequestVote", pRoot); @@ -929,44 +939,46 @@ SyncRequestVoteReply* syncRequestVoteReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncRequestVoteReply", pRoot); @@ -1072,62 +1084,64 @@ SyncAppendEntries* syncAppendEntriesFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); + cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); + cJSON_AddStringToObject(pRoot, "commit_index", u64buf); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); - cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); - cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); - cJSON_AddStringToObject(pRoot, "commit_index", u64buf); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncAppendEntries", pRoot); @@ -1231,47 +1245,49 @@ SyncAppendEntriesReply* syncAppendEntriesReplyFromRpcMsg2(const SRpcMsg* pRpcMsg } cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "success", pMsg->success); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); + cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "success", pMsg->success); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); - cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncAppendEntriesReply", pRoot); diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index f29b3022d8..41bfd7da1f 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -68,29 +68,31 @@ SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len) { } cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); - cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); - cJSON_AddStringToObject(pRoot, "seqNum", u64buf); - cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); - cJSON_AddStringToObject(pRoot, "index", u64buf); - cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); - char* s; - s = syncUtilprintBin((char*)(pEntry->data), pEntry->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); + if (pEntry != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); + cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + cJSON_AddStringToObject(pRoot, "seqNum", u64buf); + cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + cJSON_AddStringToObject(pRoot, "index", u64buf); + cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); - s = syncUtilprintBin2((char*)(pEntry->data), pEntry->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); + char* s; + s = syncUtilprintBin((char*)(pEntry->data), pEntry->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + + s = syncUtilprintBin2((char*)(pEntry->data), pEntry->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SSyncRaftEntry", pRoot); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 6ebeba1991..f3fd7f84a2 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -122,26 +122,28 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) { } cJSON* logStore2Json(SSyncLogStore* pLogStore) { - char u64buf[128]; - + char u64buf[128]; SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; cJSON* pRoot = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); - cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); - cJSON* pEntries = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "pEntries", pEntries); - SyncIndex lastIndex = logStoreLastIndex(pLogStore); - for (SyncIndex i = 0; i <= lastIndex; ++i) { - SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i); - cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); - syncEntryDestory(pEntry); + if (pData != NULL && pData->pWal != NULL) { + snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); + cJSON_AddStringToObject(pRoot, "pWal", u64buf); + snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); + cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); + cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); + + cJSON* pEntries = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "pEntries", pEntries); + SyncIndex lastIndex = logStoreLastIndex(pLogStore); + for (SyncIndex i = 0; i <= lastIndex; ++i) { + SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i); + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + syncEntryDestory(pEntry); + } } cJSON* pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 5ad618b9c0..9a5401e3f1 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -164,30 +164,63 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) { raftStorePersist(pRaftStore); } +cJSON *raftStore2Json(SRaftStore *pRaftStore) { + char u64buf[128]; + cJSON *pRoot = cJSON_CreateObject(); + + if (pRaftStore != NULL) { + snprintf(u64buf, sizeof(u64buf), "%lu", pRaftStore->currentTerm); + cJSON_AddStringToObject(pRoot, "currentTerm", u64buf); + + cJSON *pVoteFor = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pRaftStore->voteFor.addr); + cJSON_AddStringToObject(pVoteFor, "addr", u64buf); + { + uint64_t u64 = pRaftStore->voteFor.addr; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pVoteFor, "addr_host", host); + cJSON_AddNumberToObject(pVoteFor, "addr_port", port); + } + cJSON_AddNumberToObject(pVoteFor, "vgId", pRaftStore->voteFor.vgId); + cJSON_AddItemToObject(pRoot, "voteFor", pVoteFor); + } + + cJSON *pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SRaftStore", pRoot); + return pJson; +} + +char *raftStore2Str(SRaftStore *pRaftStore) { + cJSON *pJson = raftStore2Json(pRaftStore); + char *serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + // for debug ------------------- void raftStorePrint(SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); printf("raftStorePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); + free(serialized); } void raftStorePrint2(char *s, SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); printf("raftStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); + free(serialized); } void raftStoreLog(SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); sTrace("raftStoreLog | len:%lu | %s", strlen(serialized), serialized); - fflush(NULL); + free(serialized); } void raftStoreLog2(char *s, SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); sTrace("raftStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); - fflush(NULL); + free(serialized); } diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5c8e70979c..5830a0a54f 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -82,30 +82,32 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesGranted->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pVotesGranted->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); - } - int *arr = (int *)malloc(sizeof(int) * pVotesGranted->replicaNum); - for (int i = 0; i < pVotesGranted->replicaNum; ++i) { - arr[i] = pVotesGranted->isGranted[i]; - } - cJSON *pIsGranted = cJSON_CreateIntArray(arr, pVotesGranted->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); + if (pVotesGranted != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesGranted->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pVotesGranted->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); + } + int *arr = (int *)malloc(sizeof(int) * pVotesGranted->replicaNum); + for (int i = 0; i < pVotesGranted->replicaNum; ++i) { + arr[i] = pVotesGranted->isGranted[i]; + } + cJSON *pIsGranted = cJSON_CreateIntArray(arr, pVotesGranted->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); - cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); - cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); + snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); + cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); - bool majority = voteGrantedMajority(pVotesGranted); - cJSON_AddNumberToObject(pRoot, "majority", majority); + bool majority = voteGrantedMajority(pVotesGranted); + cJSON_AddNumberToObject(pRoot, "majority", majority); + } cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SVotesGranted", pRoot); @@ -114,7 +116,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -203,29 +205,31 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesRespond->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pVotesRespond->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); - } - int respondNum = 0; - int *arr = (int *)malloc(sizeof(int) * pVotesRespond->replicaNum); - for (int i = 0; i < pVotesRespond->replicaNum; ++i) { - arr[i] = pVotesRespond->isRespond[i]; - if (pVotesRespond->isRespond[i]) { - respondNum++; + if (pVotesRespond != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesRespond->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pVotesRespond->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); } - } - cJSON *pIsRespond = cJSON_CreateIntArray(arr, pVotesRespond->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); - cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); + int respondNum = 0; + int *arr = (int *)malloc(sizeof(int) * pVotesRespond->replicaNum); + for (int i = 0; i < pVotesRespond->replicaNum; ++i) { + arr[i] = pVotesRespond->isRespond[i]; + if (pVotesRespond->isRespond[i]) { + respondNum++; + } + } + cJSON *pIsRespond = cJSON_CreateIntArray(arr, pVotesRespond->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); + cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + } cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SVotesRespond", pRoot); @@ -234,7 +238,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/syncInitTest.cpp b/source/libs/sync/test/syncInitTest.cpp index 7898fda8c0..c0d2336ba7 100644 --- a/source/libs/sync/test/syncInitTest.cpp +++ b/source/libs/sync/test/syncInitTest.cpp @@ -47,6 +47,7 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; From 6fcbca5b395b27d54c96c7c696e845b63272137d Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 11:45:12 +0800 Subject: [PATCH 03/60] sync ping --- source/libs/sync/src/syncTimeout.c | 3 +- source/libs/sync/test/CMakeLists.txt | 28 +++++ source/libs/sync/test/syncInitTest.cpp | 2 - source/libs/sync/test/syncPingSelfTest.cpp | 102 ++++++++++++++++++ source/libs/sync/test/syncPingTimerTest.cpp | 1 + source/libs/sync/test/syncPingTimerTest2.cpp | 106 +++++++++++++++++++ 6 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 source/libs/sync/test/syncPingSelfTest.cpp create mode 100644 source/libs/sync/test/syncPingTimerTest2.cpp diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 3a48b0cbb3..0d3a3c3cc5 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -24,7 +24,8 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { if (pMsg->timeoutType == SYNC_TIMEOUT_PING) { if (atomic_load_64(&ths->pingTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->pingTimerCounter); - syncNodePingAll(ths); + // syncNodePingAll(ths); + syncNodePingPeers(ths); } } else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) { diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 6ade78936d..b542f55ec3 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -25,6 +25,8 @@ add_executable(syncTimeoutTest "") add_executable(syncPingTest "") add_executable(syncPingReplyTest "") add_executable(syncRpcMsgTest "") +add_executable(syncPingTimerTest2 "") +add_executable(syncPingSelfTest "") target_sources(syncTest @@ -135,6 +137,14 @@ target_sources(syncRpcMsgTest PRIVATE "syncRpcMsgTest.cpp" ) +target_sources(syncPingTimerTest2 + PRIVATE + "syncPingTimerTest2.cpp" +) +target_sources(syncPingSelfTest + PRIVATE + "syncPingSelfTest.cpp" +) target_include_directories(syncTest @@ -272,6 +282,16 @@ target_include_directories(syncRpcMsgTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncPingTimerTest2 + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(syncPingSelfTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -382,6 +402,14 @@ target_link_libraries(syncRpcMsgTest sync gtest_main ) +target_link_libraries(syncPingTimerTest2 + sync + gtest_main +) +target_link_libraries(syncPingSelfTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncInitTest.cpp b/source/libs/sync/test/syncInitTest.cpp index c0d2336ba7..a3e5f41c85 100644 --- a/source/libs/sync/test/syncInitTest.cpp +++ b/source/libs/sync/test/syncInitTest.cpp @@ -52,8 +52,6 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; - gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; - gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; gSyncIO->pSyncNode = pSyncNode; diff --git a/source/libs/sync/test/syncPingSelfTest.cpp b/source/libs/sync/test/syncPingSelfTest.cpp new file mode 100644 index 0000000000..05e4d99cb0 --- /dev/null +++ b/source/libs/sync/test/syncPingSelfTest.cpp @@ -0,0 +1,102 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 3; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./"); + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + SSyncNode* pSyncNode = syncInitTest(); + assert(pSyncNode != NULL); + syncNodePrint2((char*)"", pSyncNode); + + initRaftId(pSyncNode); + + //--------------------------- + + while (1) { + syncNodePingSelf(pSyncNode); + taosMsleep(1000); + } + + return 0; +} diff --git a/source/libs/sync/test/syncPingTimerTest.cpp b/source/libs/sync/test/syncPingTimerTest.cpp index e69878632f..20d4a9ce58 100644 --- a/source/libs/sync/test/syncPingTimerTest.cpp +++ b/source/libs/sync/test/syncPingTimerTest.cpp @@ -47,6 +47,7 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; diff --git a/source/libs/sync/test/syncPingTimerTest2.cpp b/source/libs/sync/test/syncPingTimerTest2.cpp new file mode 100644 index 0000000000..2a041f3f5d --- /dev/null +++ b/source/libs/sync/test/syncPingTimerTest2.cpp @@ -0,0 +1,106 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 3; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./"); + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + SSyncNode* pSyncNode = syncInitTest(); + assert(pSyncNode != NULL); + syncNodePrint2((char*)"", pSyncNode); + + initRaftId(pSyncNode); + + //--------------------------- + + sTrace("syncNodeStartPingTimer ..."); + ret = syncNodeStartPingTimer(pSyncNode); + assert(ret == 0); + + while (1) { + sTrace("while 1 sleep ..."); + taosMsleep(1000); + } + + return 0; +} From 8286d6efcffc13a835f185a607a4b814dd2e7957 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 14:00:41 +0800 Subject: [PATCH 04/60] migrate TS-1278 from 2.x --- source/common/src/trow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 861b4dc093..db4bc49425 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -353,10 +353,10 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i for (int i = 0; i < src2->numOfCols; i++) { SCellVal sVal = {0}; ASSERT(target->cols[i].type == src2->cols[i].type); - if (src2->cols[i].len > 0 && !isNull(src2->cols[i].pData, src2->cols[i].type)) { - if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { - TASSERT(0); - } + if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2) < 0) { + TASSERT(0); + } + if (src2->cols[i].len > 0 && !tdValTypeIsNull(sVal.valType)) { tdAppendValToDataCol(&(target->cols[i]), sVal.valType, sVal.val, target->numOfRows, target->maxPoints); } else if (!forceSetNull && key1 == key2 && src1->cols[i].len > 0) { if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { From f8f7aabfd9ddf41338016a038f80cfac279204ab Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:08:59 -0400 Subject: [PATCH 05/60] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- include/common/tmsg.h | 4 +- include/common/ttokendef.h | 95 +- include/libs/nodes/cmdnodes.h | 31 + include/libs/nodes/nodes.h | 5 + source/client/src/tmq.c | 4 +- source/common/src/tmsg.c | 41 +- source/dnode/mnode/impl/src/mndTopic.c | 27 +- source/dnode/mnode/impl/test/topic/topic.cpp | 3 +- source/libs/nodes/src/nodesCodeFuncs.c | 7 +- source/libs/nodes/src/nodesUtilFuncs.c | 10 + source/libs/parser/inc/parAst.h | 5 + source/libs/parser/inc/sql.y | 32 +- source/libs/parser/src/parAstCreater.c | 49 + source/libs/parser/src/parTokenizer.c | 2 +- source/libs/parser/src/parTranslater.c | 175 +- source/libs/parser/src/sql.c | 3099 +++++++++--------- source/libs/parser/test/parserAstTest.cpp | 57 + 17 files changed, 2024 insertions(+), 1622 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..dc418147b0 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1157,8 +1157,8 @@ typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; int8_t igExists; char* sql; - char* physicalPlan; - char* logicalPlan; + char* ast; + char subscribeDbName[TSDB_DB_NAME_LEN]; } SCMCreateTopicReq; int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 5693091bd5..167c72a778 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -108,53 +108,54 @@ #define TK_FULLTEXT 90 #define TK_FUNCTION 91 #define TK_INTERVAL 92 -#define TK_MNODES 93 -#define TK_NK_FLOAT 94 -#define TK_NK_BOOL 95 -#define TK_NK_VARIABLE 96 -#define TK_BETWEEN 97 -#define TK_IS 98 -#define TK_NULL 99 -#define TK_NK_LT 100 -#define TK_NK_GT 101 -#define TK_NK_LE 102 -#define TK_NK_GE 103 -#define TK_NK_NE 104 -#define TK_NK_EQ 105 -#define TK_LIKE 106 -#define TK_MATCH 107 -#define TK_NMATCH 108 -#define TK_IN 109 -#define TK_FROM 110 -#define TK_AS 111 -#define TK_JOIN 112 -#define TK_INNER 113 -#define TK_SELECT 114 -#define TK_DISTINCT 115 -#define TK_WHERE 116 -#define TK_PARTITION 117 -#define TK_BY 118 -#define TK_SESSION 119 -#define TK_STATE_WINDOW 120 -#define TK_SLIDING 121 -#define TK_FILL 122 -#define TK_VALUE 123 -#define TK_NONE 124 -#define TK_PREV 125 -#define TK_LINEAR 126 -#define TK_NEXT 127 -#define TK_GROUP 128 -#define TK_HAVING 129 -#define TK_ORDER 130 -#define TK_SLIMIT 131 -#define TK_SOFFSET 132 -#define TK_LIMIT 133 -#define TK_OFFSET 134 -#define TK_ASC 135 -#define TK_DESC 136 -#define TK_NULLS 137 -#define TK_FIRST 138 -#define TK_LAST 139 +#define TK_TOPIC 93 +#define TK_AS 94 +#define TK_MNODES 95 +#define TK_NK_FLOAT 96 +#define TK_NK_BOOL 97 +#define TK_NK_VARIABLE 98 +#define TK_BETWEEN 99 +#define TK_IS 100 +#define TK_NULL 101 +#define TK_NK_LT 102 +#define TK_NK_GT 103 +#define TK_NK_LE 104 +#define TK_NK_GE 105 +#define TK_NK_NE 106 +#define TK_NK_EQ 107 +#define TK_LIKE 108 +#define TK_MATCH 109 +#define TK_NMATCH 110 +#define TK_IN 111 +#define TK_FROM 112 +#define TK_JOIN 113 +#define TK_INNER 114 +#define TK_SELECT 115 +#define TK_DISTINCT 116 +#define TK_WHERE 117 +#define TK_PARTITION 118 +#define TK_BY 119 +#define TK_SESSION 120 +#define TK_STATE_WINDOW 121 +#define TK_SLIDING 122 +#define TK_FILL 123 +#define TK_VALUE 124 +#define TK_NONE 125 +#define TK_PREV 126 +#define TK_LINEAR 127 +#define TK_NEXT 128 +#define TK_GROUP 129 +#define TK_HAVING 130 +#define TK_ORDER 131 +#define TK_SLIMIT 132 +#define TK_SOFFSET 133 +#define TK_LIMIT 134 +#define TK_OFFSET 135 +#define TK_ASC 136 +#define TK_DESC 137 +#define TK_NULLS 138 +#define TK_FIRST 139 +#define TK_LAST 140 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 21d9ff83c8..5d7174fc08 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -61,6 +61,12 @@ typedef struct SDropDatabaseStmt { bool ignoreNotExists; } SDropDatabaseStmt; +typedef struct SAlterDatabaseStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + SDatabaseOptions* pOptions; +} SAlterDatabaseStmt; + typedef struct STableOptions { ENodeType type; int32_t keep; @@ -179,11 +185,36 @@ typedef struct SCreateIndexStmt { SIndexOptions* pOptions; } SCreateIndexStmt; +typedef struct SDropIndexStmt { + ENodeType type; + char indexName[TSDB_INDEX_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; +} SDropIndexStmt; + typedef struct SCreateQnodeStmt { ENodeType type; int32_t dnodeId; } SCreateQnodeStmt; +typedef struct SDropQnodeStmt { + ENodeType type; + int32_t dnodeId; +} SDropQnodeStmt; + +typedef struct SCreateTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + char subscribeDbName[TSDB_DB_NAME_LEN]; + bool ignoreExists; + SNode* pQuery; +} SCreateTopicStmt; + +typedef struct SDropTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + bool ignoreNotExists; +} SDropTopicStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index cf34c6665a..4ef70fc7ab 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -77,6 +77,7 @@ typedef enum ENodeType { QUERY_NODE_VNODE_MODIF_STMT, QUERY_NODE_CREATE_DATABASE_STMT, QUERY_NODE_DROP_DATABASE_STMT, + QUERY_NODE_ALTER_DATABASE_STMT, QUERY_NODE_SHOW_DATABASES_STMT, // temp QUERY_NODE_CREATE_TABLE_STMT, QUERY_NODE_CREATE_SUBTABLE_CLAUSE, @@ -98,7 +99,11 @@ typedef enum ENodeType { QUERY_NODE_SHOW_MNODES_STMT, QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_CREATE_INDEX_STMT, + QUERY_NODE_DROP_INDEX_STMT, QUERY_NODE_CREATE_QNODE_STMT, + QUERY_NODE_DROP_QNODE_STMT, + QUERY_NODE_CREATE_TOPIC_STMT, + QUERY_NODE_DROP_TOPIC_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index b3f71c1075..0ddd53be08 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,7 +482,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); - +#if 0 CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); @@ -536,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); - +#endif _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..abd341557f 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1990,11 +1990,9 @@ int32_t tDeserializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pR int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; if (pReq->sql != NULL) sqlLen = (int32_t)strlen(pReq->sql); - if (pReq->physicalPlan != NULL) physicalPlanLen = (int32_t)strlen(pReq->physicalPlan); - if (pReq->logicalPlan != NULL) logicalPlanLen = (int32_t)strlen(pReq->logicalPlan); + if (pReq->ast != NULL) astLen = (int32_t)strlen(pReq->ast); SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -2003,11 +2001,9 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; if (tEncodeI32(&encoder, sqlLen) < 0) return -1; - if (tEncodeI32(&encoder, physicalPlanLen) < 0) return -1; - if (tEncodeI32(&encoder, logicalPlanLen) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1; + if (tEncodeI32(&encoder, astLen) < 0) return -1; + if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; + if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; tEndEncode(&encoder); @@ -2018,8 +2014,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; SCoder decoder = {0}; tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); @@ -2028,17 +2023,20 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; - if (tDecodeI32(&decoder, &physicalPlanLen) < 0) return -1; - if (tDecodeI32(&decoder, &logicalPlanLen) < 0) return -1; + if (tDecodeI32(&decoder, &astLen) < 0) return -1; - pReq->sql = calloc(1, sqlLen + 1); - pReq->physicalPlan = calloc(1, physicalPlanLen + 1); - pReq->logicalPlan = calloc(1, logicalPlanLen + 1); - if (pReq->sql == NULL || pReq->physicalPlan == NULL || pReq->logicalPlan == NULL) return -1; + if (sqlLen > 0) { + pReq->sql = calloc(1, sqlLen + 1); + if (pReq->sql == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; + } + + if (astLen > 0) { + pReq->ast = calloc(1, astLen + 1); + if (pReq->ast == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; + } - if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->physicalPlan) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2047,8 +2045,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) { tfree(pReq->sql); - tfree(pReq->physicalPlan); - tfree(pReq->logicalPlan); + tfree(pReq->ast); } int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) { diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7d7c5f9975..32fa3df910 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -236,6 +236,25 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { return 0; } +static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + SNode* pAst = NULL; + int32_t code = nodesStringToNode(pCreate->ast, &pAst); + + SQueryPlan* pPlan = NULL; + if (TSDB_CODE_SUCCESS == code) { + SPlanContext cxt = { .pAstRoot = pAst, .streamQuery = true }; + code = qCreateQueryPlan(&cxt, &pPlan, NULL); + } + + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pPlan, false, pStr, NULL); + } + nodesDestroyNode(pAst); + nodesDestroyNode(pPlan); + terrno = code; + return code; +} + static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) { mDebug("topic:%s to create", pCreate->name); SMqTopicObj topicObj = {0}; @@ -247,10 +266,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.physicalPlan = pCreate->physicalPlan; - topicObj.logicalPlan = pCreate->logicalPlan; + topicObj.logicalPlan = NULL; topicObj.sqlLen = strlen(pCreate->sql); + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); + return -1; + } + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index f58d0a6771..79f353a4d6 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,8 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.physicalPlan = (char*)"physicalPlan"; - createReq.logicalPlan = (char*)"logicalPlan"; + createReq.ast = (char*)"ast"; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 457f863a5e..a2fd32d238 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1730,7 +1730,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p } int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) { - if (NULL == pNode || NULL == pStr || NULL == pLen) { + if (NULL == pNode || NULL == pStr) { terrno = TSDB_CODE_FAILED; return TSDB_CODE_FAILED; } @@ -1750,7 +1750,10 @@ int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_ *pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson); tjsonDelete(pJson); - *pLen = strlen(*pStr) + 1; + if (NULL != pLen) { + *pLen = strlen(*pStr) + 1; + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index b17a4904da..75568019cb 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -92,6 +92,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCreateDatabaseStmt)); case QUERY_NODE_DROP_DATABASE_STMT: return makeNode(type, sizeof(SDropDatabaseStmt)); + case QUERY_NODE_ALTER_DATABASE_STMT: + return makeNode(type, sizeof(SAlterDatabaseStmt)); case QUERY_NODE_SHOW_DATABASES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_TABLE_STMT: @@ -131,8 +133,16 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_INDEX_STMT: return makeNode(type, sizeof(SCreateIndexStmt)); + case QUERY_NODE_DROP_INDEX_STMT: + return makeNode(type, sizeof(SDropIndexStmt)); case QUERY_NODE_CREATE_QNODE_STMT: return makeNode(type, sizeof(SCreateQnodeStmt)); + case QUERY_NODE_DROP_QNODE_STMT: + return makeNode(type, sizeof(SDropQnodeStmt)); + case QUERY_NODE_CREATE_TOPIC_STMT: + return makeNode(type, sizeof(SCreateTopicStmt)); + case QUERY_NODE_DROP_TOPIC_STMT: + return makeNode(type, sizeof(SDropTopicStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index f2fcced1a9..31d7331d0e 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -113,6 +113,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions); SNode* createDefaultTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); @@ -134,7 +135,11 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName); SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName); +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index af2fb12c52..31c26e1e40 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -42,17 +42,17 @@ //%right NK_BITNOT. /************************************************ create/alter/drop/show user *****************************************/ -cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);} -cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);} -cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);} +cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } +cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); } +cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); } cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); } cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } /************************************************ create/drop/show dnode **********************************************/ -cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);} -cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);} -cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} -cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} +cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } +cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); } +cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } +cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } %type dnode_endpoint { SToken } @@ -64,15 +64,17 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } -/************************************************ create qnode ********************************************************/ +/************************************************ create/drop qnode ***************************************************/ cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } +cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } /************************************************ create/drop/show/use database ***************************************/ -cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);} +cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); } cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } -cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);} +cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); } +cmd ::= ALTER DATABASE db_name(A) db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } %type not_exists_opt { bool } %destructor not_exists_opt { } @@ -198,6 +200,7 @@ col_name(A) ::= column_name(B). cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } cmd ::= CREATE FULLTEXT INDEX index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); } +cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); } index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL @@ -212,6 +215,11 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } +/************************************************ create/drop topic ***************************************************/ +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); } +cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } + /************************************************ show vgroups ********************************************************/ cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); } @@ -270,6 +278,10 @@ user_name(A) ::= NK_ID(B). %destructor index_name { } index_name(A) ::= NK_ID(B). { A = B; } +%type topic_name { SToken } +%destructor topic_name { } +topic_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index b7ecf160fd..034346362c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -799,6 +799,17 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions) { + if (!checkDbName(pCxt, pDbName)) { + return NULL; + } + SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->dbName, pDbName->z, pDbName->n); + pStmt->pOptions = (SDatabaseOptions*)pOptions; + return (SNode*)pStmt; +} + SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); @@ -1022,9 +1033,47 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt return (SNode*)pOptions; } +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName) { + if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + return NULL; + } + SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); + strncpy(pStmt->tableName, pTableName->z, pTableName->n); + return (SNode*)pStmt; +} + SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; return (SNode*)pStmt; } + +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { + SDropQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_QNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; + return (SNode*)pStmt; +} + +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName) { + SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreExists = ignoreExists; + pStmt->pQuery = pQuery; + if (NULL != pSubscribeDbName) { + strncpy(pStmt->subscribeDbName, pSubscribeDbName->z, pSubscribeDbName->n); + } + return (SNode*)pStmt; +} + +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { + SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreNotExists = ignoreNotExists; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 4d50d92d9e..2d58d4e1e3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -121,6 +121,7 @@ static SKeyword keywordTable[] = { {"TAGS", TK_TAGS}, {"TIMESTAMP", TK_TIMESTAMP}, {"TINYINT", TK_TINYINT}, + {"TOPIC", TK_TOPIC}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, @@ -230,7 +231,6 @@ static SKeyword keywordTable[] = { // {"TBNAME", TK_TBNAME}, // {"VNODES", TK_VNODES}, // {"PARTITIONS", TK_PARTITIONS}, - // {"TOPIC", TK_TOPIC}, // {"TOPICS", TK_TOPICS}, // {"COMPACT", TK_COMPACT}, // {"MODIFY", TK_MODIFY}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 4f89e7e703..af7a38b702 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -21,14 +21,6 @@ #include "parUtil.h" #include "ttime.h" -static bool afterGroupBy(ESqlClause clause) { - return clause > SQL_CLAUSE_GROUP_BY; -} - -static bool beforeHaving(ESqlClause clause) { - return clause < SQL_CLAUSE_HAVING; -} - typedef struct STranslateContext { SParseContext* pParseCxt; int32_t errCode; @@ -41,6 +33,15 @@ typedef struct STranslateContext { } STranslateContext; static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode); +static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode); + +static bool afterGroupBy(ESqlClause clause) { + return clause > SQL_CLAUSE_GROUP_BY; +} + +static bool beforeHaving(ESqlClause clause) { + return clause < SQL_CLAUSE_HAVING; +} static EDealRes generateDealNodeErrMsg(STranslateContext* pCxt, int32_t errCode, ...) { va_list vArgList; @@ -833,6 +834,41 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* return TSDB_CODE_SUCCESS; } +static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) { + SName name = {0}; + tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + tNameGetFullDbName(&name, pReq->db); + pReq->totalBlocks = pStmt->pOptions->numOfBlocks; + pReq->daysToKeep0 = pStmt->pOptions->keep; + pReq->daysToKeep1 = -1; + pReq->daysToKeep2 = -1; + pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walLevel = pStmt->pOptions->walLevel; + pReq->quorum = pStmt->pOptions->quorum; + pReq->cacheLastRow = pStmt->pOptions->cachelast; + return; +} + +static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt) { + SAlterDbReq alterReq = {0}; + buildAlterDbReq(pCxt, pStmt, &alterReq); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB; + pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); SNode* pNode; @@ -1201,6 +1237,27 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } } +static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { + SVDropTSmaReq dropSmaReq = {0}; + strcpy(dropSmaReq.indexName, pStmt->indexName); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_VND_DROP_SMA; + pCxt->pCmdMsg->msgLen = tSerializeSVDropTSmaReq(NULL, &dropSmaReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + void* pBuf = pCxt->pCmdMsg->pMsg; + tSerializeSVDropTSmaReq(&pBuf, &dropSmaReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; @@ -1220,6 +1277,93 @@ static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* p return TSDB_CODE_SUCCESS; } +static int32_t translateDropQnode(STranslateContext* pCxt, SDropQnodeStmt* pStmt) { + SDDropQnodeReq dropReq = { .dnodeId = pStmt->dnodeId }; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_DND_DROP_QNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) { + SCMCreateTopicReq createReq = {0}; + + if (NULL != pStmt->pQuery) { + int32_t code = translateQuery(pCxt, pStmt->pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); + } + if (TSDB_CODE_SUCCESS != code ) { + return code; + } + } else { + strcpy(createReq.subscribeDbName, pStmt->subscribeDbName); + } + + createReq.sql = strdup(pCxt->pParseCxt->pSql); + if (NULL == createReq.sql) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, createReq.name); + createReq.igExists = pStmt->ignoreExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + tFreeSCMCreateTopicReq(&createReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) { + SMDropTopicReq dropReq = {0}; + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, dropReq.name); + dropReq.igNotExists = pStmt->ignoreNotExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1232,6 +1376,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_DATABASE_STMT: code = translateDropDatabase(pCxt, (SDropDatabaseStmt*)pNode); break; + case QUERY_NODE_ALTER_DATABASE_STMT: + code = translateAlterDatabase(pCxt, (SAlterDatabaseStmt*)pNode); + break; case QUERY_NODE_CREATE_TABLE_STMT: code = translateCreateSuperTable(pCxt, (SCreateTableStmt*)pNode); break; @@ -1274,9 +1421,21 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; + case QUERY_NODE_DROP_INDEX_STMT: + code = translateDropIndex(pCxt, (SDropIndexStmt*)pNode); + break; case QUERY_NODE_CREATE_QNODE_STMT: code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode); break; + case QUERY_NODE_DROP_QNODE_STMT: + code = translateDropQnode(pCxt, (SDropQnodeStmt*)pNode); + break; + case QUERY_NODE_CREATE_TOPIC_STMT: + code = translateCreateTopic(pCxt, (SCreateTopicStmt*)pNode); + break; + case QUERY_NODE_DROP_TOPIC_STMT: + code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 8b46d3600b..18b507c1b0 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 218 +#define YYNOCODE 220 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy5; - bool yy25; - SNodeList* yy40; - ENullOrder yy53; - EOrder yy54; - SNode* yy68; - EJoinType yy92; - EFillMode yy94; - SDataType yy372; - EOperatorType yy416; + SNodeList* yy24; + bool yy97; + SToken yy129; + SDataType yy224; + ENullOrder yy257; + EOperatorType yy260; + EFillMode yy294; + EJoinType yy332; + EOrder yy378; + SNode* yy432; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 313 -#define YYNRULE 248 -#define YYNTOKEN 140 -#define YY_MAX_SHIFT 312 -#define YY_MIN_SHIFTREDUCE 480 -#define YY_MAX_SHIFTREDUCE 727 -#define YY_ERROR_ACTION 728 -#define YY_ACCEPT_ACTION 729 -#define YY_NO_ACTION 730 -#define YY_MIN_REDUCE 731 -#define YY_MAX_REDUCE 978 +#define YYNSTATE 333 +#define YYNRULE 255 +#define YYNTOKEN 141 +#define YY_MAX_SHIFT 332 +#define YY_MIN_SHIFTREDUCE 501 +#define YY_MAX_SHIFTREDUCE 755 +#define YY_ERROR_ACTION 756 +#define YY_ACCEPT_ACTION 757 +#define YY_NO_ACTION 758 +#define YY_MIN_REDUCE 759 +#define YY_MAX_REDUCE 1013 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,307 +206,322 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (963) +#define YY_ACTTAB_COUNT (1012) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 152, 236, 277, 871, 844, 252, 252, 167, 186, 784, - /* 10 */ 847, 844, 31, 29, 27, 26, 25, 846, 844, 209, - /* 20 */ 787, 787, 309, 308, 846, 31, 29, 27, 26, 25, - /* 30 */ 746, 236, 151, 871, 106, 826, 39, 824, 251, 844, - /* 40 */ 145, 957, 238, 61, 236, 856, 871, 782, 57, 857, - /* 50 */ 860, 896, 910, 145, 956, 154, 892, 969, 955, 187, - /* 60 */ 164, 610, 213, 832, 239, 166, 930, 10, 826, 907, - /* 70 */ 824, 251, 301, 300, 299, 298, 297, 296, 295, 294, - /* 80 */ 293, 292, 291, 290, 289, 288, 287, 286, 285, 599, - /* 90 */ 31, 29, 27, 26, 25, 24, 109, 23, 159, 228, - /* 100 */ 628, 629, 630, 631, 632, 633, 634, 636, 637, 638, - /* 110 */ 23, 159, 39, 628, 629, 630, 631, 632, 633, 634, - /* 120 */ 636, 637, 638, 783, 542, 275, 274, 273, 546, 272, - /* 130 */ 548, 549, 271, 551, 268, 165, 557, 265, 559, 560, - /* 140 */ 262, 259, 236, 54, 871, 694, 251, 789, 70, 252, - /* 150 */ 844, 65, 249, 238, 779, 224, 856, 208, 214, 56, - /* 160 */ 857, 860, 896, 229, 787, 601, 144, 892, 775, 205, - /* 170 */ 692, 693, 695, 696, 220, 10, 910, 82, 957, 31, - /* 180 */ 29, 27, 26, 25, 215, 210, 223, 170, 871, 64, - /* 190 */ 826, 81, 824, 906, 844, 955, 600, 238, 773, 826, - /* 200 */ 856, 825, 224, 57, 857, 860, 896, 187, 62, 910, - /* 210 */ 154, 892, 76, 723, 724, 27, 26, 25, 102, 903, - /* 220 */ 219, 220, 218, 284, 105, 957, 905, 729, 610, 82, - /* 230 */ 201, 923, 87, 223, 21, 871, 64, 284, 81, 227, - /* 240 */ 75, 844, 955, 635, 238, 104, 639, 856, 490, 86, - /* 250 */ 57, 857, 860, 896, 197, 62, 190, 154, 892, 76, - /* 260 */ 173, 68, 236, 278, 871, 78, 903, 904, 127, 908, - /* 270 */ 844, 817, 40, 238, 252, 84, 856, 250, 924, 57, - /* 280 */ 857, 860, 896, 957, 9, 8, 154, 892, 969, 787, - /* 290 */ 236, 48, 871, 178, 30, 28, 81, 953, 844, 206, - /* 300 */ 955, 238, 780, 590, 856, 833, 239, 57, 857, 860, - /* 310 */ 896, 588, 6, 161, 154, 892, 969, 30, 28, 670, - /* 320 */ 169, 99, 12, 790, 70, 914, 590, 31, 29, 27, - /* 330 */ 26, 25, 789, 70, 588, 774, 161, 189, 490, 236, - /* 340 */ 602, 871, 1, 677, 646, 12, 53, 844, 491, 492, - /* 350 */ 238, 50, 224, 856, 30, 28, 133, 857, 860, 252, - /* 360 */ 599, 253, 122, 590, 252, 1, 226, 172, 915, 665, - /* 370 */ 235, 588, 590, 161, 787, 957, 589, 591, 594, 787, - /* 380 */ 588, 171, 12, 926, 253, 281, 30, 28, 81, 280, - /* 390 */ 669, 665, 955, 789, 70, 590, 82, 9, 8, 589, - /* 400 */ 591, 594, 1, 588, 282, 161, 691, 96, 236, 195, - /* 410 */ 871, 130, 193, 59, 94, 196, 844, 134, 71, 238, - /* 420 */ 91, 253, 856, 279, 221, 58, 857, 860, 896, 625, - /* 430 */ 253, 83, 895, 892, 7, 872, 589, 591, 594, 108, - /* 440 */ 236, 2, 871, 597, 174, 589, 591, 594, 844, 772, - /* 450 */ 231, 238, 188, 253, 856, 38, 640, 58, 857, 860, - /* 460 */ 896, 726, 727, 32, 234, 892, 30, 28, 589, 591, - /* 470 */ 594, 85, 30, 28, 237, 590, 236, 603, 871, 607, - /* 480 */ 191, 590, 150, 588, 844, 161, 32, 238, 82, 588, - /* 490 */ 856, 161, 198, 72, 857, 860, 30, 28, 20, 281, - /* 500 */ 598, 668, 604, 280, 602, 590, 207, 82, 31, 29, - /* 510 */ 27, 26, 25, 588, 7, 161, 232, 199, 282, 927, - /* 520 */ 7, 851, 242, 92, 236, 937, 871, 583, 849, 594, - /* 530 */ 225, 970, 844, 253, 32, 238, 160, 279, 856, 253, - /* 540 */ 114, 138, 857, 860, 1, 204, 936, 112, 589, 591, - /* 550 */ 594, 244, 95, 119, 589, 591, 594, 236, 66, 871, - /* 560 */ 67, 5, 153, 253, 917, 844, 217, 98, 238, 203, - /* 570 */ 74, 856, 4, 63, 58, 857, 860, 896, 589, 591, - /* 580 */ 594, 665, 893, 236, 220, 871, 535, 100, 601, 530, - /* 590 */ 911, 844, 33, 68, 238, 202, 59, 856, 101, 64, - /* 600 */ 138, 857, 860, 236, 155, 871, 563, 972, 233, 567, - /* 610 */ 954, 844, 572, 257, 238, 107, 67, 856, 62, 68, - /* 620 */ 137, 857, 860, 17, 230, 236, 831, 871, 79, 903, - /* 630 */ 904, 878, 908, 844, 245, 47, 238, 49, 240, 856, - /* 640 */ 241, 69, 72, 857, 860, 236, 830, 871, 67, 163, - /* 650 */ 126, 216, 246, 844, 116, 788, 238, 158, 236, 856, - /* 660 */ 871, 255, 138, 857, 860, 247, 844, 128, 123, 238, - /* 670 */ 162, 312, 856, 125, 185, 138, 857, 860, 184, 597, - /* 680 */ 971, 60, 129, 183, 22, 182, 142, 305, 143, 838, - /* 690 */ 124, 236, 749, 871, 31, 29, 27, 26, 25, 844, - /* 700 */ 176, 177, 238, 837, 179, 856, 836, 835, 136, 857, - /* 710 */ 860, 181, 180, 55, 778, 236, 120, 871, 777, 748, - /* 720 */ 745, 740, 735, 844, 776, 501, 238, 747, 739, 856, - /* 730 */ 738, 734, 139, 857, 860, 236, 733, 871, 192, 732, - /* 740 */ 828, 175, 248, 844, 200, 41, 238, 194, 88, 856, - /* 750 */ 89, 90, 131, 857, 860, 236, 3, 871, 32, 14, - /* 760 */ 93, 36, 690, 844, 73, 97, 238, 211, 42, 856, - /* 770 */ 212, 684, 140, 857, 860, 236, 683, 871, 849, 15, - /* 780 */ 19, 34, 11, 844, 662, 43, 238, 44, 236, 856, - /* 790 */ 871, 712, 132, 857, 860, 661, 844, 711, 156, 238, - /* 800 */ 35, 716, 856, 717, 103, 141, 857, 860, 80, 715, - /* 810 */ 157, 16, 236, 8, 871, 110, 608, 13, 18, 113, - /* 820 */ 844, 111, 688, 238, 115, 236, 856, 871, 827, 868, - /* 830 */ 857, 860, 117, 844, 626, 45, 238, 243, 236, 856, - /* 840 */ 871, 118, 867, 857, 860, 46, 844, 50, 592, 238, - /* 850 */ 37, 848, 856, 121, 220, 866, 857, 860, 254, 256, - /* 860 */ 236, 564, 871, 168, 258, 260, 561, 261, 844, 64, - /* 870 */ 558, 238, 263, 236, 856, 871, 264, 148, 857, 860, - /* 880 */ 552, 844, 266, 267, 238, 550, 269, 856, 62, 270, - /* 890 */ 147, 857, 860, 236, 556, 871, 555, 222, 77, 903, - /* 900 */ 904, 844, 908, 554, 238, 541, 553, 856, 276, 51, - /* 910 */ 149, 857, 860, 236, 52, 871, 571, 570, 569, 499, - /* 920 */ 283, 844, 520, 519, 238, 518, 744, 856, 517, 516, - /* 930 */ 146, 857, 860, 236, 515, 871, 514, 513, 512, 511, - /* 940 */ 510, 844, 509, 508, 238, 303, 507, 856, 506, 505, - /* 950 */ 135, 857, 860, 504, 302, 304, 737, 306, 307, 736, - /* 960 */ 731, 310, 311, + /* 0 */ 163, 856, 240, 855, 272, 162, 272, 200, 856, 814, + /* 10 */ 854, 878, 31, 29, 27, 26, 25, 65, 880, 817, + /* 20 */ 178, 817, 256, 176, 906, 31, 29, 27, 26, 25, + /* 30 */ 779, 878, 40, 705, 55, 819, 71, 63, 880, 62, + /* 40 */ 155, 229, 66, 812, 243, 809, 906, 79, 938, 939, + /* 50 */ 626, 943, 878, 155, 175, 258, 511, 863, 259, 891, + /* 60 */ 511, 638, 58, 892, 895, 931, 512, 513, 208, 165, + /* 70 */ 927, 77, 321, 320, 319, 318, 317, 316, 315, 314, + /* 80 */ 313, 312, 311, 310, 309, 308, 307, 306, 305, 775, + /* 90 */ 959, 27, 26, 25, 31, 29, 27, 26, 25, 23, + /* 100 */ 170, 271, 656, 657, 658, 659, 660, 661, 662, 664, + /* 110 */ 665, 666, 23, 170, 271, 656, 657, 658, 659, 660, + /* 120 */ 661, 662, 664, 665, 666, 31, 29, 27, 26, 25, + /* 130 */ 10, 321, 320, 319, 318, 317, 316, 315, 314, 313, + /* 140 */ 312, 311, 310, 309, 308, 307, 306, 305, 565, 295, + /* 150 */ 294, 293, 569, 292, 571, 572, 291, 574, 288, 804, + /* 160 */ 580, 285, 582, 583, 282, 279, 24, 117, 256, 196, + /* 170 */ 906, 992, 626, 195, 624, 256, 177, 906, 194, 856, + /* 180 */ 193, 854, 83, 878, 991, 83, 258, 233, 990, 244, + /* 190 */ 891, 180, 271, 57, 892, 895, 931, 54, 182, 190, + /* 200 */ 154, 927, 51, 819, 71, 272, 192, 191, 269, 301, + /* 210 */ 819, 71, 992, 300, 805, 243, 624, 906, 751, 752, + /* 220 */ 817, 10, 234, 878, 298, 82, 258, 945, 302, 990, + /* 230 */ 891, 757, 627, 58, 892, 895, 931, 256, 186, 906, + /* 240 */ 165, 927, 77, 228, 942, 878, 201, 299, 258, 628, + /* 250 */ 30, 28, 891, 201, 113, 58, 892, 895, 931, 617, + /* 260 */ 221, 958, 165, 927, 1004, 184, 256, 615, 906, 172, + /* 270 */ 629, 235, 230, 965, 878, 304, 878, 258, 12, 272, + /* 280 */ 297, 891, 270, 881, 58, 892, 895, 931, 992, 9, + /* 290 */ 8, 165, 927, 1004, 817, 256, 272, 906, 1, 130, + /* 300 */ 83, 82, 988, 878, 181, 990, 258, 856, 40, 854, + /* 310 */ 891, 817, 112, 58, 892, 895, 931, 273, 21, 813, + /* 320 */ 165, 927, 1004, 30, 28, 698, 272, 663, 189, 183, + /* 330 */ 667, 949, 617, 99, 616, 618, 621, 114, 30, 28, + /* 340 */ 615, 817, 172, 329, 328, 803, 247, 617, 256, 674, + /* 350 */ 906, 12, 722, 83, 140, 615, 878, 172, 161, 258, + /* 360 */ 141, 72, 244, 891, 30, 28, 144, 892, 895, 49, + /* 370 */ 945, 1, 945, 617, 84, 225, 720, 721, 723, 724, + /* 380 */ 810, 615, 226, 172, 304, 992, 7, 941, 6, 940, + /* 390 */ 273, 697, 12, 864, 259, 256, 248, 906, 82, 820, + /* 400 */ 71, 136, 990, 878, 847, 273, 258, 616, 618, 621, + /* 410 */ 891, 240, 1, 59, 892, 895, 931, 256, 107, 906, + /* 420 */ 930, 927, 616, 618, 621, 878, 65, 217, 258, 950, + /* 430 */ 693, 273, 891, 251, 69, 59, 892, 895, 931, 207, + /* 440 */ 244, 83, 254, 927, 213, 961, 63, 211, 616, 618, + /* 450 */ 621, 83, 94, 30, 28, 257, 110, 938, 239, 241, + /* 460 */ 238, 249, 617, 992, 719, 617, 30, 28, 693, 93, + /* 470 */ 615, 60, 172, 615, 246, 617, 82, 104, 907, 256, + /* 480 */ 990, 906, 668, 615, 102, 172, 116, 878, 255, 32, + /* 490 */ 258, 2, 754, 755, 891, 635, 624, 73, 892, 895, + /* 500 */ 252, 7, 32, 696, 607, 9, 8, 30, 28, 185, + /* 510 */ 256, 32, 906, 632, 7, 885, 617, 625, 878, 85, + /* 520 */ 273, 258, 883, 273, 615, 891, 172, 631, 59, 892, + /* 530 */ 895, 931, 214, 273, 245, 1005, 928, 616, 618, 621, + /* 540 */ 616, 618, 621, 197, 198, 256, 199, 906, 39, 653, + /* 550 */ 616, 618, 621, 878, 202, 1, 258, 171, 90, 122, + /* 560 */ 891, 215, 209, 148, 892, 895, 120, 256, 630, 906, + /* 570 */ 264, 134, 160, 127, 273, 878, 558, 67, 258, 222, + /* 580 */ 68, 216, 891, 69, 992, 148, 892, 895, 256, 218, + /* 590 */ 906, 616, 618, 621, 629, 553, 878, 82, 95, 258, + /* 600 */ 962, 990, 60, 891, 586, 133, 147, 892, 895, 590, + /* 610 */ 256, 277, 906, 61, 802, 227, 68, 219, 878, 325, + /* 620 */ 972, 258, 132, 262, 256, 891, 906, 100, 73, 892, + /* 630 */ 895, 621, 878, 224, 971, 258, 169, 236, 256, 891, + /* 640 */ 906, 103, 148, 892, 895, 56, 878, 164, 128, 258, + /* 650 */ 173, 5, 256, 891, 906, 952, 148, 892, 895, 237, + /* 660 */ 878, 75, 106, 258, 301, 223, 1006, 891, 300, 108, + /* 670 */ 146, 892, 895, 240, 268, 4, 220, 64, 256, 96, + /* 680 */ 906, 693, 628, 302, 595, 946, 878, 33, 65, 258, + /* 690 */ 253, 69, 256, 891, 906, 109, 149, 892, 895, 70, + /* 700 */ 878, 989, 299, 258, 1007, 250, 68, 891, 63, 166, + /* 710 */ 142, 892, 895, 256, 17, 906, 115, 242, 78, 938, + /* 720 */ 939, 878, 943, 913, 258, 862, 260, 256, 891, 906, + /* 730 */ 261, 150, 892, 895, 861, 878, 265, 174, 258, 266, + /* 740 */ 124, 256, 891, 906, 267, 143, 892, 895, 48, 878, + /* 750 */ 135, 818, 258, 50, 275, 256, 891, 906, 137, 151, + /* 760 */ 892, 895, 131, 878, 872, 138, 258, 332, 152, 256, + /* 770 */ 891, 906, 153, 903, 892, 895, 139, 878, 778, 871, + /* 780 */ 258, 870, 187, 256, 891, 906, 188, 902, 892, 895, + /* 790 */ 869, 878, 808, 807, 258, 777, 774, 256, 891, 906, + /* 800 */ 768, 901, 892, 895, 763, 878, 868, 859, 258, 87, + /* 810 */ 806, 256, 891, 906, 524, 158, 892, 895, 776, 878, + /* 820 */ 773, 205, 258, 203, 204, 256, 891, 906, 767, 157, + /* 830 */ 892, 895, 766, 878, 762, 761, 258, 210, 760, 867, + /* 840 */ 891, 866, 212, 159, 892, 895, 36, 858, 256, 42, + /* 850 */ 906, 97, 98, 3, 240, 14, 878, 15, 74, 258, + /* 860 */ 101, 105, 256, 891, 906, 43, 156, 892, 895, 65, + /* 870 */ 878, 32, 231, 258, 718, 712, 92, 891, 34, 37, + /* 880 */ 145, 892, 895, 711, 76, 44, 11, 232, 690, 63, + /* 890 */ 206, 883, 689, 91, 19, 45, 20, 111, 745, 80, + /* 900 */ 938, 939, 740, 943, 35, 739, 31, 29, 27, 26, + /* 910 */ 25, 22, 81, 167, 16, 744, 41, 743, 168, 89, + /* 920 */ 8, 31, 29, 27, 26, 25, 118, 636, 13, 31, + /* 930 */ 29, 27, 26, 25, 654, 18, 263, 857, 119, 716, + /* 940 */ 121, 123, 46, 126, 125, 47, 88, 619, 51, 276, + /* 950 */ 86, 179, 38, 280, 882, 579, 587, 129, 278, 274, + /* 960 */ 584, 281, 283, 581, 284, 286, 575, 287, 289, 573, + /* 970 */ 564, 290, 52, 53, 594, 296, 593, 578, 638, 592, + /* 980 */ 303, 577, 522, 543, 576, 542, 541, 536, 540, 539, + /* 990 */ 538, 537, 535, 534, 533, 772, 532, 531, 530, 529, + /* 1000 */ 528, 527, 322, 323, 765, 764, 326, 327, 324, 759, + /* 1010 */ 330, 331, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 157, 160, 163, 162, 168, 145, 145, 157, 148, 148, - /* 10 */ 174, 168, 12, 13, 14, 15, 16, 174, 168, 178, - /* 20 */ 160, 160, 142, 143, 174, 12, 13, 14, 15, 16, - /* 30 */ 0, 160, 159, 162, 216, 162, 147, 164, 31, 168, - /* 40 */ 40, 196, 171, 154, 160, 174, 162, 158, 177, 178, - /* 50 */ 179, 180, 175, 40, 209, 184, 185, 186, 213, 39, - /* 60 */ 167, 61, 178, 170, 171, 159, 195, 60, 162, 192, - /* 70 */ 164, 31, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 31, - /* 90 */ 12, 13, 14, 15, 16, 181, 182, 97, 98, 68, - /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 110 */ 97, 98, 147, 100, 101, 102, 103, 104, 105, 106, - /* 120 */ 107, 108, 109, 158, 70, 71, 72, 73, 74, 75, - /* 130 */ 76, 77, 78, 79, 80, 149, 82, 83, 84, 85, - /* 140 */ 86, 87, 160, 144, 162, 99, 31, 161, 162, 145, - /* 150 */ 168, 152, 148, 171, 155, 173, 174, 92, 31, 177, - /* 160 */ 178, 179, 180, 132, 160, 31, 184, 185, 0, 123, - /* 170 */ 124, 125, 126, 127, 145, 60, 175, 114, 196, 12, - /* 180 */ 13, 14, 15, 16, 119, 120, 160, 159, 162, 160, - /* 190 */ 162, 209, 164, 192, 168, 213, 31, 171, 0, 162, - /* 200 */ 174, 164, 173, 177, 178, 179, 180, 39, 179, 175, - /* 210 */ 184, 185, 186, 135, 136, 14, 15, 16, 189, 190, - /* 220 */ 191, 145, 193, 39, 198, 196, 192, 140, 61, 114, - /* 230 */ 204, 205, 19, 160, 97, 162, 160, 39, 209, 3, - /* 240 */ 27, 168, 213, 106, 171, 111, 109, 174, 21, 36, - /* 250 */ 177, 178, 179, 180, 61, 179, 29, 184, 185, 186, - /* 260 */ 173, 68, 160, 66, 162, 189, 190, 191, 150, 193, - /* 270 */ 168, 153, 59, 171, 145, 62, 174, 148, 205, 177, - /* 280 */ 178, 179, 180, 196, 1, 2, 184, 185, 186, 160, - /* 290 */ 160, 144, 162, 145, 12, 13, 209, 195, 168, 207, - /* 300 */ 213, 171, 155, 21, 174, 170, 171, 177, 178, 179, - /* 310 */ 180, 29, 34, 31, 184, 185, 186, 12, 13, 14, - /* 320 */ 149, 201, 40, 161, 162, 195, 21, 12, 13, 14, - /* 330 */ 15, 16, 161, 162, 29, 0, 31, 142, 21, 160, - /* 340 */ 31, 162, 60, 14, 61, 40, 60, 168, 31, 32, - /* 350 */ 171, 65, 173, 174, 12, 13, 177, 178, 179, 145, - /* 360 */ 31, 79, 148, 21, 145, 60, 130, 148, 112, 113, - /* 370 */ 40, 29, 21, 31, 160, 196, 94, 95, 96, 160, - /* 380 */ 29, 149, 40, 176, 79, 50, 12, 13, 209, 54, - /* 390 */ 4, 113, 213, 161, 162, 21, 114, 1, 2, 94, - /* 400 */ 95, 96, 60, 29, 69, 31, 61, 61, 160, 20, - /* 410 */ 162, 18, 23, 68, 68, 22, 168, 24, 25, 171, - /* 420 */ 111, 79, 174, 88, 194, 177, 178, 179, 180, 99, - /* 430 */ 79, 38, 184, 185, 60, 162, 94, 95, 96, 210, - /* 440 */ 160, 197, 162, 31, 145, 94, 95, 96, 168, 0, - /* 450 */ 68, 171, 145, 79, 174, 147, 61, 177, 178, 179, - /* 460 */ 180, 138, 139, 68, 184, 185, 12, 13, 94, 95, - /* 470 */ 96, 147, 12, 13, 14, 21, 160, 31, 162, 61, - /* 480 */ 141, 21, 141, 29, 168, 31, 68, 171, 114, 29, - /* 490 */ 174, 31, 160, 177, 178, 179, 12, 13, 2, 50, - /* 500 */ 31, 115, 31, 54, 31, 21, 122, 114, 12, 13, - /* 510 */ 14, 15, 16, 29, 60, 31, 134, 165, 69, 176, - /* 520 */ 60, 60, 121, 169, 160, 206, 162, 61, 67, 96, - /* 530 */ 214, 215, 168, 79, 68, 171, 172, 88, 174, 79, - /* 540 */ 61, 177, 178, 179, 60, 168, 206, 68, 94, 95, - /* 550 */ 96, 61, 169, 61, 94, 95, 96, 160, 68, 162, - /* 560 */ 68, 129, 168, 79, 203, 168, 128, 202, 171, 117, - /* 570 */ 200, 174, 116, 160, 177, 178, 179, 180, 94, 95, - /* 580 */ 96, 113, 185, 160, 145, 162, 61, 199, 31, 61, - /* 590 */ 175, 168, 110, 68, 171, 172, 68, 174, 187, 160, - /* 600 */ 177, 178, 179, 160, 137, 162, 61, 217, 133, 61, - /* 610 */ 212, 168, 61, 68, 171, 211, 68, 174, 179, 68, - /* 620 */ 177, 178, 179, 60, 131, 160, 169, 162, 189, 190, - /* 630 */ 191, 183, 193, 168, 91, 144, 171, 60, 168, 174, - /* 640 */ 168, 61, 177, 178, 179, 160, 169, 162, 68, 168, - /* 650 */ 153, 208, 166, 168, 160, 160, 171, 172, 160, 174, - /* 660 */ 162, 156, 177, 178, 179, 165, 168, 145, 144, 171, - /* 670 */ 172, 141, 174, 19, 26, 177, 178, 179, 30, 31, - /* 680 */ 215, 27, 146, 35, 2, 37, 151, 33, 151, 0, - /* 690 */ 36, 160, 0, 162, 12, 13, 14, 15, 16, 168, - /* 700 */ 56, 67, 171, 0, 56, 174, 0, 0, 177, 178, - /* 710 */ 179, 63, 64, 59, 0, 160, 62, 162, 0, 0, - /* 720 */ 0, 0, 0, 168, 0, 41, 171, 0, 0, 174, - /* 730 */ 0, 0, 177, 178, 179, 160, 0, 162, 21, 0, - /* 740 */ 0, 93, 88, 168, 90, 60, 171, 21, 19, 174, - /* 750 */ 34, 89, 177, 178, 179, 160, 68, 162, 68, 118, - /* 760 */ 61, 68, 61, 168, 60, 60, 171, 29, 60, 174, - /* 770 */ 68, 61, 177, 178, 179, 160, 61, 162, 67, 118, - /* 780 */ 68, 112, 118, 168, 61, 60, 171, 4, 160, 174, - /* 790 */ 162, 29, 177, 178, 179, 61, 168, 29, 29, 171, - /* 800 */ 68, 29, 174, 61, 67, 177, 178, 179, 67, 29, - /* 810 */ 29, 68, 160, 2, 162, 67, 61, 60, 60, 60, - /* 820 */ 168, 61, 61, 171, 60, 160, 174, 162, 0, 177, - /* 830 */ 178, 179, 34, 168, 99, 60, 171, 92, 160, 174, - /* 840 */ 162, 89, 177, 178, 179, 60, 168, 65, 21, 171, - /* 850 */ 60, 67, 174, 67, 145, 177, 178, 179, 66, 29, - /* 860 */ 160, 61, 162, 29, 60, 29, 61, 60, 168, 160, - /* 870 */ 61, 171, 29, 160, 174, 162, 60, 177, 178, 179, - /* 880 */ 61, 168, 29, 60, 171, 61, 29, 174, 179, 60, - /* 890 */ 177, 178, 179, 160, 81, 162, 81, 188, 189, 190, - /* 900 */ 191, 168, 193, 81, 171, 21, 81, 174, 69, 60, - /* 910 */ 177, 178, 179, 160, 60, 162, 29, 29, 21, 41, - /* 920 */ 40, 168, 29, 29, 171, 29, 0, 174, 29, 29, - /* 930 */ 177, 178, 179, 160, 29, 162, 29, 21, 29, 29, - /* 940 */ 29, 168, 29, 29, 171, 27, 29, 174, 29, 29, - /* 950 */ 177, 178, 179, 29, 29, 34, 0, 29, 28, 0, - /* 960 */ 0, 21, 20, 218, 218, 218, 218, 218, 218, 218, - /* 970 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 980 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 990 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1000 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1010 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1020 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1030 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1040 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1050 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1060 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1070 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1080 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1090 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1100 */ 218, 218, 218, + /* 0 */ 158, 163, 146, 165, 146, 160, 146, 149, 163, 149, + /* 10 */ 165, 169, 12, 13, 14, 15, 16, 161, 176, 161, + /* 20 */ 158, 161, 161, 150, 163, 12, 13, 14, 15, 16, + /* 30 */ 0, 169, 148, 14, 145, 162, 163, 181, 176, 155, + /* 40 */ 40, 180, 153, 159, 161, 156, 163, 191, 192, 193, + /* 50 */ 31, 195, 169, 40, 168, 172, 21, 171, 172, 176, + /* 60 */ 21, 61, 179, 180, 181, 182, 31, 32, 29, 186, + /* 70 */ 187, 188, 42, 43, 44, 45, 46, 47, 48, 49, + /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + /* 90 */ 207, 14, 15, 16, 12, 13, 14, 15, 16, 99, + /* 100 */ 100, 31, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 110, 111, 99, 100, 31, 102, 103, 104, 105, 106, + /* 120 */ 107, 108, 109, 110, 111, 12, 13, 14, 15, 16, + /* 130 */ 60, 42, 43, 44, 45, 46, 47, 48, 49, 50, + /* 140 */ 51, 52, 53, 54, 55, 56, 57, 58, 70, 71, + /* 150 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 0, + /* 160 */ 82, 83, 84, 85, 86, 87, 183, 184, 161, 26, + /* 170 */ 163, 198, 31, 30, 31, 161, 160, 163, 35, 163, + /* 180 */ 37, 165, 115, 169, 211, 115, 172, 180, 215, 175, + /* 190 */ 176, 150, 31, 179, 180, 181, 182, 60, 150, 56, + /* 200 */ 186, 187, 65, 162, 163, 146, 63, 64, 149, 50, + /* 210 */ 162, 163, 198, 54, 0, 161, 31, 163, 136, 137, + /* 220 */ 161, 60, 31, 169, 66, 211, 172, 177, 69, 215, + /* 230 */ 176, 141, 31, 179, 180, 181, 182, 161, 95, 163, + /* 240 */ 186, 187, 188, 92, 194, 169, 39, 88, 172, 31, + /* 250 */ 12, 13, 176, 39, 200, 179, 180, 181, 182, 21, + /* 260 */ 206, 207, 186, 187, 188, 175, 161, 29, 163, 31, + /* 270 */ 31, 120, 121, 197, 169, 39, 169, 172, 40, 146, + /* 280 */ 164, 176, 149, 176, 179, 180, 181, 182, 198, 1, + /* 290 */ 2, 186, 187, 188, 161, 161, 146, 163, 60, 149, + /* 300 */ 115, 211, 197, 169, 160, 215, 172, 163, 148, 165, + /* 310 */ 176, 161, 94, 179, 180, 181, 182, 79, 99, 159, + /* 320 */ 186, 187, 188, 12, 13, 14, 146, 108, 146, 149, + /* 330 */ 111, 197, 21, 94, 96, 97, 98, 218, 12, 13, + /* 340 */ 29, 161, 31, 143, 144, 0, 3, 21, 161, 61, + /* 350 */ 163, 40, 101, 115, 18, 29, 169, 31, 22, 172, + /* 360 */ 24, 25, 175, 176, 12, 13, 179, 180, 181, 145, + /* 370 */ 177, 60, 177, 21, 38, 124, 125, 126, 127, 128, + /* 380 */ 156, 29, 209, 31, 39, 198, 60, 194, 34, 194, + /* 390 */ 79, 4, 40, 171, 172, 161, 68, 163, 211, 162, + /* 400 */ 163, 151, 215, 169, 154, 79, 172, 96, 97, 98, + /* 410 */ 176, 146, 60, 179, 180, 181, 182, 161, 203, 163, + /* 420 */ 186, 187, 96, 97, 98, 169, 161, 61, 172, 113, + /* 430 */ 114, 79, 176, 68, 68, 179, 180, 181, 182, 143, + /* 440 */ 175, 115, 186, 187, 20, 178, 181, 23, 96, 97, + /* 450 */ 98, 115, 19, 12, 13, 14, 191, 192, 193, 196, + /* 460 */ 195, 133, 21, 198, 61, 21, 12, 13, 114, 36, + /* 470 */ 29, 68, 31, 29, 131, 21, 211, 61, 163, 161, + /* 480 */ 215, 163, 61, 29, 68, 31, 212, 169, 40, 68, + /* 490 */ 172, 199, 139, 140, 176, 61, 31, 179, 180, 181, + /* 500 */ 135, 60, 68, 116, 61, 1, 2, 12, 13, 146, + /* 510 */ 161, 68, 163, 31, 60, 60, 21, 31, 169, 148, + /* 520 */ 79, 172, 67, 79, 29, 176, 31, 31, 179, 180, + /* 530 */ 181, 182, 146, 79, 216, 217, 187, 96, 97, 98, + /* 540 */ 96, 97, 98, 174, 161, 161, 166, 163, 148, 101, + /* 550 */ 96, 97, 98, 169, 146, 60, 172, 173, 148, 61, + /* 560 */ 176, 175, 142, 179, 180, 181, 68, 161, 31, 163, + /* 570 */ 61, 146, 142, 61, 79, 169, 61, 68, 172, 173, + /* 580 */ 68, 174, 176, 68, 198, 179, 180, 181, 161, 161, + /* 590 */ 163, 96, 97, 98, 31, 61, 169, 211, 145, 172, + /* 600 */ 178, 215, 68, 176, 61, 19, 179, 180, 181, 61, + /* 610 */ 161, 68, 163, 27, 0, 123, 68, 166, 169, 33, + /* 620 */ 208, 172, 36, 122, 161, 176, 163, 170, 179, 180, + /* 630 */ 181, 98, 169, 169, 208, 172, 173, 210, 161, 176, + /* 640 */ 163, 170, 179, 180, 181, 59, 169, 169, 62, 172, + /* 650 */ 173, 130, 161, 176, 163, 205, 179, 180, 181, 129, + /* 660 */ 169, 202, 204, 172, 50, 118, 217, 176, 54, 201, + /* 670 */ 179, 180, 181, 146, 88, 117, 90, 161, 161, 93, + /* 680 */ 163, 114, 31, 69, 61, 177, 169, 112, 161, 172, + /* 690 */ 134, 68, 161, 176, 163, 189, 179, 180, 181, 61, + /* 700 */ 169, 214, 88, 172, 219, 132, 68, 176, 181, 138, + /* 710 */ 179, 180, 181, 161, 60, 163, 213, 190, 191, 192, + /* 720 */ 193, 169, 195, 185, 172, 170, 169, 161, 176, 163, + /* 730 */ 169, 179, 180, 181, 170, 169, 91, 169, 172, 167, + /* 740 */ 161, 161, 176, 163, 166, 179, 180, 181, 145, 169, + /* 750 */ 154, 161, 172, 60, 157, 161, 176, 163, 146, 179, + /* 760 */ 180, 181, 145, 169, 0, 147, 172, 142, 152, 161, + /* 770 */ 176, 163, 152, 179, 180, 181, 147, 169, 0, 0, + /* 780 */ 172, 0, 56, 161, 176, 163, 67, 179, 180, 181, + /* 790 */ 0, 169, 0, 0, 172, 0, 0, 161, 176, 163, + /* 800 */ 0, 179, 180, 181, 0, 169, 0, 0, 172, 34, + /* 810 */ 0, 161, 176, 163, 41, 179, 180, 181, 0, 169, + /* 820 */ 0, 34, 172, 29, 27, 161, 176, 163, 0, 179, + /* 830 */ 180, 181, 0, 169, 0, 0, 172, 21, 0, 0, + /* 840 */ 176, 0, 21, 179, 180, 181, 94, 0, 161, 60, + /* 850 */ 163, 34, 89, 68, 146, 119, 169, 119, 60, 172, + /* 860 */ 61, 60, 161, 176, 163, 60, 179, 180, 181, 161, + /* 870 */ 169, 68, 29, 172, 61, 61, 19, 176, 113, 68, + /* 880 */ 179, 180, 181, 61, 27, 60, 119, 68, 61, 181, + /* 890 */ 33, 67, 61, 36, 68, 4, 2, 67, 61, 191, + /* 900 */ 192, 193, 29, 195, 68, 29, 12, 13, 14, 15, + /* 910 */ 16, 2, 67, 29, 68, 29, 59, 29, 29, 62, + /* 920 */ 2, 12, 13, 14, 15, 16, 67, 61, 60, 12, + /* 930 */ 13, 14, 15, 16, 101, 60, 92, 0, 61, 61, + /* 940 */ 60, 60, 60, 89, 34, 60, 89, 21, 65, 29, + /* 950 */ 93, 29, 60, 29, 67, 81, 61, 67, 60, 66, + /* 960 */ 61, 60, 29, 61, 60, 29, 61, 60, 29, 61, + /* 970 */ 21, 60, 60, 60, 29, 69, 29, 81, 61, 21, + /* 980 */ 40, 81, 41, 29, 81, 29, 29, 21, 29, 29, + /* 990 */ 29, 29, 29, 29, 29, 0, 29, 29, 29, 29, + /* 1000 */ 29, 29, 29, 27, 0, 0, 29, 28, 34, 0, + /* 1010 */ 21, 20, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1020 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1030 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1040 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1050 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1060 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1070 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1080 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1090 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1100 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1110 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1120 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1130 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1140 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1150 */ 220, 220, 220, }; -#define YY_SHIFT_COUNT (312) +#define YY_SHIFT_COUNT (332) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (960) +#define YY_SHIFT_MAX (1009) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 393, 282, 305, 342, 342, 342, 342, 374, 342, 342, - /* 10 */ 115, 454, 484, 460, 454, 454, 454, 454, 454, 454, + /* 0 */ 336, 238, 311, 352, 352, 352, 352, 326, 352, 352, + /* 10 */ 70, 454, 495, 441, 454, 454, 454, 454, 454, 454, /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 30 */ 454, 454, 454, 7, 7, 7, 351, 351, 40, 40, - /* 40 */ 20, 58, 127, 127, 63, 165, 58, 40, 40, 58, - /* 50 */ 40, 58, 58, 58, 40, 184, 0, 13, 13, 351, - /* 60 */ 317, 168, 134, 134, 134, 198, 165, 58, 58, 197, - /* 70 */ 54, 648, 78, 46, 65, 227, 309, 256, 278, 256, - /* 80 */ 329, 236, 386, 412, 20, 412, 20, 446, 446, 469, - /* 90 */ 471, 473, 384, 401, 433, 384, 401, 433, 432, 438, - /* 100 */ 452, 456, 468, 469, 557, 482, 467, 475, 493, 563, - /* 110 */ 58, 401, 433, 433, 401, 433, 543, 469, 471, 197, - /* 120 */ 184, 469, 577, 412, 184, 446, 963, 963, 963, 30, - /* 130 */ 654, 496, 682, 167, 213, 315, 315, 315, 315, 315, - /* 140 */ 315, 315, 335, 449, 283, 137, 201, 201, 201, 201, - /* 150 */ 389, 193, 345, 346, 396, 323, 31, 382, 395, 330, - /* 160 */ 418, 461, 466, 479, 490, 492, 525, 528, 545, 548, - /* 170 */ 551, 580, 286, 689, 692, 703, 706, 644, 634, 707, - /* 180 */ 714, 718, 719, 720, 721, 722, 724, 684, 727, 728, - /* 190 */ 730, 731, 736, 717, 739, 726, 729, 740, 685, 716, - /* 200 */ 662, 688, 690, 641, 699, 693, 701, 704, 705, 710, - /* 210 */ 708, 715, 738, 702, 711, 725, 712, 661, 723, 734, - /* 220 */ 737, 669, 732, 741, 742, 743, 664, 783, 762, 768, - /* 230 */ 769, 772, 780, 781, 811, 735, 748, 755, 757, 758, - /* 240 */ 760, 761, 759, 764, 745, 775, 828, 798, 752, 785, - /* 250 */ 782, 784, 786, 827, 790, 792, 800, 830, 834, 804, - /* 260 */ 805, 836, 807, 809, 843, 816, 819, 853, 823, 824, - /* 270 */ 857, 829, 813, 815, 822, 825, 884, 839, 849, 854, - /* 280 */ 887, 888, 897, 878, 880, 893, 894, 896, 899, 900, - /* 290 */ 905, 907, 916, 909, 910, 911, 913, 914, 917, 919, - /* 300 */ 920, 924, 926, 925, 918, 921, 956, 928, 930, 959, - /* 310 */ 960, 940, 942, + /* 30 */ 454, 454, 454, 161, 161, 161, 185, 444, 444, 83, + /* 40 */ 83, 207, 141, 191, 191, 67, 201, 141, 83, 83, + /* 50 */ 141, 83, 141, 141, 141, 83, 236, 0, 13, 13, + /* 60 */ 444, 35, 214, 218, 218, 218, 345, 201, 141, 141, + /* 70 */ 158, 78, 143, 82, 251, 151, 39, 239, 316, 354, + /* 80 */ 316, 19, 343, 387, 465, 482, 207, 486, 496, 207, + /* 90 */ 465, 207, 537, 465, 537, 482, 236, 486, 496, 563, + /* 100 */ 492, 501, 533, 492, 501, 533, 521, 530, 547, 558, + /* 110 */ 567, 486, 651, 575, 571, 556, 573, 654, 141, 501, + /* 120 */ 533, 533, 501, 533, 645, 486, 496, 158, 236, 486, + /* 130 */ 693, 465, 236, 537, 1012, 1012, 1012, 1012, 30, 89, + /* 140 */ 586, 857, 894, 909, 917, 113, 113, 113, 113, 113, + /* 150 */ 113, 113, 159, 614, 288, 219, 77, 77, 77, 77, + /* 160 */ 424, 433, 366, 403, 416, 504, 353, 328, 365, 421, + /* 170 */ 448, 434, 455, 443, 498, 509, 512, 515, 534, 543, + /* 180 */ 548, 623, 638, 137, 764, 778, 779, 781, 726, 719, + /* 190 */ 790, 792, 793, 795, 796, 800, 804, 806, 807, 775, + /* 200 */ 810, 773, 818, 820, 794, 797, 787, 828, 832, 834, + /* 210 */ 835, 816, 838, 821, 839, 841, 752, 847, 789, 817, + /* 220 */ 763, 785, 803, 736, 799, 811, 813, 798, 801, 814, + /* 230 */ 805, 822, 843, 819, 824, 825, 826, 738, 827, 831, + /* 240 */ 830, 765, 836, 845, 837, 846, 767, 891, 873, 876, + /* 250 */ 884, 886, 888, 889, 918, 833, 859, 866, 868, 875, + /* 260 */ 877, 878, 880, 881, 844, 882, 937, 910, 854, 885, + /* 270 */ 883, 887, 890, 926, 892, 893, 895, 920, 922, 898, + /* 280 */ 899, 924, 901, 902, 933, 904, 905, 936, 907, 908, + /* 290 */ 939, 911, 874, 896, 900, 903, 949, 906, 912, 913, + /* 300 */ 945, 947, 958, 941, 940, 954, 956, 957, 959, 960, + /* 310 */ 961, 962, 966, 963, 964, 965, 967, 968, 969, 970, + /* 320 */ 971, 972, 995, 973, 976, 974, 1004, 977, 979, 1005, + /* 330 */ 1009, 989, 991, }; -#define YY_REDUCE_COUNT (128) -#define YY_REDUCE_MIN (-182) -#define YY_REDUCE_MAX (773) +#define YY_REDUCE_COUNT (137) +#define YY_REDUCE_MIN (-162) +#define YY_REDUCE_MAX (708) static const short yy_reduce_ofst[] = { - /* 0 */ 87, -18, 26, 73, -129, 102, 130, 179, 248, 280, - /* 10 */ 29, 316, 397, 364, 423, 443, 465, 485, 498, 531, - /* 20 */ 555, 575, 595, 615, 628, 652, 665, 678, 700, 713, - /* 30 */ 733, 753, 773, 709, 76, 439, -157, -150, -140, -139, - /* 40 */ -111, -127, -159, -116, -155, -107, -14, 4, 129, -94, - /* 50 */ 214, 171, 28, 232, 219, -1, -86, -86, -86, -164, - /* 60 */ -120, -35, -123, 1, 34, 147, 135, 162, 37, 118, - /* 70 */ -161, 148, -182, 92, 120, 195, 207, 230, 230, 230, - /* 80 */ 273, 229, 244, 299, 308, 307, 324, 339, 341, 332, - /* 90 */ 352, 343, 319, 354, 377, 340, 383, 394, 361, 365, - /* 100 */ 370, 388, 230, 413, 415, 411, 390, 398, 404, 448, - /* 110 */ 273, 457, 470, 472, 477, 481, 486, 494, 500, 497, - /* 120 */ 491, 495, 505, 522, 524, 530, 535, 537, 536, + /* 0 */ 90, 14, 54, -117, 76, 105, 134, 187, 234, 256, + /* 10 */ 265, 318, 349, 384, 406, 427, 449, 463, 477, 491, + /* 20 */ 517, 531, 552, 566, 580, 594, 608, 622, 636, 650, + /* 30 */ 664, 687, 701, 527, -144, 708, 386, -158, -138, -142, + /* 40 */ -140, -116, -155, -139, 7, -27, -114, -127, 59, 133, + /* 50 */ 16, 150, 41, 144, 48, 180, -111, -17, -17, -17, + /* 60 */ 107, 200, 160, 50, 193, 195, 224, 222, 237, -162, + /* 70 */ 250, 116, 182, 119, 173, 215, 296, 267, 263, 263, + /* 80 */ 263, 315, 274, 292, 363, 369, 371, 383, 380, 400, + /* 90 */ 408, 410, 420, 425, 430, 407, 453, 428, 451, 422, + /* 100 */ 412, 457, 464, 426, 471, 478, 450, 458, 459, 468, + /* 110 */ 263, 516, 508, 506, 485, 487, 503, 538, 315, 555, + /* 120 */ 557, 561, 564, 568, 572, 579, 578, 596, 603, 590, + /* 130 */ 597, 612, 617, 625, 618, 616, 620, 629, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 10 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 20 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 30 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 40 */ 753, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 50 */ 728, 728, 728, 728, 728, 751, 728, 898, 728, 728, - /* 60 */ 728, 753, 909, 909, 909, 751, 728, 728, 728, 816, - /* 70 */ 728, 728, 973, 728, 933, 728, 925, 901, 915, 902, - /* 80 */ 728, 958, 918, 728, 753, 728, 753, 728, 728, 728, - /* 90 */ 728, 728, 940, 938, 728, 940, 938, 728, 952, 948, - /* 100 */ 931, 929, 915, 728, 728, 728, 976, 964, 960, 728, - /* 110 */ 728, 938, 728, 728, 938, 728, 829, 728, 728, 728, - /* 120 */ 751, 728, 785, 728, 751, 728, 819, 819, 754, 728, - /* 130 */ 728, 728, 728, 728, 728, 870, 951, 950, 869, 875, - /* 140 */ 874, 873, 728, 728, 728, 728, 864, 865, 863, 862, - /* 150 */ 728, 728, 728, 728, 899, 728, 961, 965, 728, 728, - /* 160 */ 728, 850, 728, 728, 728, 728, 728, 728, 728, 728, - /* 170 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 180 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 190 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 200 */ 728, 922, 932, 728, 728, 728, 728, 728, 728, 728, - /* 210 */ 728, 728, 728, 728, 850, 728, 949, 728, 908, 904, - /* 220 */ 728, 728, 900, 728, 728, 959, 728, 728, 728, 728, - /* 230 */ 728, 728, 728, 728, 894, 728, 728, 728, 728, 728, - /* 240 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 250 */ 728, 849, 728, 728, 728, 728, 728, 728, 728, 813, - /* 260 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 270 */ 728, 728, 798, 796, 795, 794, 728, 791, 728, 728, - /* 280 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 290 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 300 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 310 */ 728, 728, 728, + /* 0 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 10 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 20 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 30 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 40 */ 756, 783, 756, 756, 756, 756, 756, 756, 756, 756, + /* 50 */ 756, 756, 756, 756, 756, 756, 781, 756, 933, 756, + /* 60 */ 756, 756, 783, 944, 944, 944, 781, 756, 756, 756, + /* 70 */ 846, 756, 756, 1008, 756, 968, 756, 960, 936, 950, + /* 80 */ 937, 756, 993, 953, 756, 756, 783, 756, 756, 783, + /* 90 */ 756, 783, 756, 756, 756, 756, 781, 756, 756, 756, + /* 100 */ 975, 973, 756, 975, 973, 756, 987, 983, 966, 964, + /* 110 */ 950, 756, 756, 756, 1011, 999, 995, 756, 756, 973, + /* 120 */ 756, 756, 973, 756, 860, 756, 756, 756, 781, 756, + /* 130 */ 815, 756, 781, 756, 784, 849, 849, 784, 756, 756, + /* 140 */ 756, 756, 756, 756, 756, 905, 986, 985, 904, 910, + /* 150 */ 909, 908, 756, 756, 756, 756, 899, 900, 898, 897, + /* 160 */ 756, 756, 756, 756, 756, 934, 756, 996, 1000, 756, + /* 170 */ 756, 756, 884, 756, 756, 756, 756, 756, 756, 756, + /* 180 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 190 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 200 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 210 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 220 */ 756, 957, 967, 756, 756, 756, 756, 756, 756, 756, + /* 230 */ 756, 756, 756, 756, 884, 756, 984, 756, 943, 939, + /* 240 */ 756, 756, 935, 756, 756, 994, 756, 756, 756, 756, + /* 250 */ 756, 756, 756, 756, 929, 756, 756, 756, 756, 756, + /* 260 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 270 */ 756, 883, 756, 756, 756, 756, 756, 756, 756, 843, + /* 280 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 290 */ 756, 756, 828, 826, 825, 824, 756, 821, 756, 756, + /* 300 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 310 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 320 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 330 */ 756, 756, 756, }; /********** End of lemon-generated parsing tables *****************************/ @@ -706,131 +721,133 @@ static const char *const yyTokenName[] = { /* 90 */ "FULLTEXT", /* 91 */ "FUNCTION", /* 92 */ "INTERVAL", - /* 93 */ "MNODES", - /* 94 */ "NK_FLOAT", - /* 95 */ "NK_BOOL", - /* 96 */ "NK_VARIABLE", - /* 97 */ "BETWEEN", - /* 98 */ "IS", - /* 99 */ "NULL", - /* 100 */ "NK_LT", - /* 101 */ "NK_GT", - /* 102 */ "NK_LE", - /* 103 */ "NK_GE", - /* 104 */ "NK_NE", - /* 105 */ "NK_EQ", - /* 106 */ "LIKE", - /* 107 */ "MATCH", - /* 108 */ "NMATCH", - /* 109 */ "IN", - /* 110 */ "FROM", - /* 111 */ "AS", - /* 112 */ "JOIN", - /* 113 */ "INNER", - /* 114 */ "SELECT", - /* 115 */ "DISTINCT", - /* 116 */ "WHERE", - /* 117 */ "PARTITION", - /* 118 */ "BY", - /* 119 */ "SESSION", - /* 120 */ "STATE_WINDOW", - /* 121 */ "SLIDING", - /* 122 */ "FILL", - /* 123 */ "VALUE", - /* 124 */ "NONE", - /* 125 */ "PREV", - /* 126 */ "LINEAR", - /* 127 */ "NEXT", - /* 128 */ "GROUP", - /* 129 */ "HAVING", - /* 130 */ "ORDER", - /* 131 */ "SLIMIT", - /* 132 */ "SOFFSET", - /* 133 */ "LIMIT", - /* 134 */ "OFFSET", - /* 135 */ "ASC", - /* 136 */ "DESC", - /* 137 */ "NULLS", - /* 138 */ "FIRST", - /* 139 */ "LAST", - /* 140 */ "cmd", - /* 141 */ "user_name", - /* 142 */ "dnode_endpoint", - /* 143 */ "dnode_host_name", - /* 144 */ "not_exists_opt", - /* 145 */ "db_name", - /* 146 */ "db_options", - /* 147 */ "exists_opt", - /* 148 */ "full_table_name", - /* 149 */ "column_def_list", - /* 150 */ "tags_def_opt", - /* 151 */ "table_options", - /* 152 */ "multi_create_clause", - /* 153 */ "tags_def", - /* 154 */ "multi_drop_clause", - /* 155 */ "create_subtable_clause", - /* 156 */ "specific_tags_opt", - /* 157 */ "literal_list", - /* 158 */ "drop_table_clause", - /* 159 */ "col_name_list", - /* 160 */ "table_name", - /* 161 */ "column_def", - /* 162 */ "column_name", - /* 163 */ "type_name", - /* 164 */ "col_name", - /* 165 */ "index_name", - /* 166 */ "index_options", - /* 167 */ "func_list", - /* 168 */ "duration_literal", - /* 169 */ "sliding_opt", - /* 170 */ "func", - /* 171 */ "function_name", - /* 172 */ "expression_list", - /* 173 */ "query_expression", - /* 174 */ "literal", - /* 175 */ "table_alias", - /* 176 */ "column_alias", - /* 177 */ "expression", - /* 178 */ "column_reference", - /* 179 */ "subquery", - /* 180 */ "predicate", - /* 181 */ "compare_op", - /* 182 */ "in_op", - /* 183 */ "in_predicate_value", - /* 184 */ "boolean_value_expression", - /* 185 */ "boolean_primary", - /* 186 */ "common_expression", - /* 187 */ "from_clause", - /* 188 */ "table_reference_list", - /* 189 */ "table_reference", - /* 190 */ "table_primary", - /* 191 */ "joined_table", - /* 192 */ "alias_opt", - /* 193 */ "parenthesized_joined_table", - /* 194 */ "join_type", - /* 195 */ "search_condition", - /* 196 */ "query_specification", - /* 197 */ "set_quantifier_opt", - /* 198 */ "select_list", - /* 199 */ "where_clause_opt", - /* 200 */ "partition_by_clause_opt", - /* 201 */ "twindow_clause_opt", - /* 202 */ "group_by_clause_opt", - /* 203 */ "having_clause_opt", - /* 204 */ "select_sublist", - /* 205 */ "select_item", - /* 206 */ "fill_opt", - /* 207 */ "fill_mode", - /* 208 */ "group_by_list", - /* 209 */ "query_expression_body", - /* 210 */ "order_by_clause_opt", - /* 211 */ "slimit_clause_opt", - /* 212 */ "limit_clause_opt", - /* 213 */ "query_primary", - /* 214 */ "sort_specification_list", - /* 215 */ "sort_specification", - /* 216 */ "ordering_specification_opt", - /* 217 */ "null_ordering_opt", + /* 93 */ "TOPIC", + /* 94 */ "AS", + /* 95 */ "MNODES", + /* 96 */ "NK_FLOAT", + /* 97 */ "NK_BOOL", + /* 98 */ "NK_VARIABLE", + /* 99 */ "BETWEEN", + /* 100 */ "IS", + /* 101 */ "NULL", + /* 102 */ "NK_LT", + /* 103 */ "NK_GT", + /* 104 */ "NK_LE", + /* 105 */ "NK_GE", + /* 106 */ "NK_NE", + /* 107 */ "NK_EQ", + /* 108 */ "LIKE", + /* 109 */ "MATCH", + /* 110 */ "NMATCH", + /* 111 */ "IN", + /* 112 */ "FROM", + /* 113 */ "JOIN", + /* 114 */ "INNER", + /* 115 */ "SELECT", + /* 116 */ "DISTINCT", + /* 117 */ "WHERE", + /* 118 */ "PARTITION", + /* 119 */ "BY", + /* 120 */ "SESSION", + /* 121 */ "STATE_WINDOW", + /* 122 */ "SLIDING", + /* 123 */ "FILL", + /* 124 */ "VALUE", + /* 125 */ "NONE", + /* 126 */ "PREV", + /* 127 */ "LINEAR", + /* 128 */ "NEXT", + /* 129 */ "GROUP", + /* 130 */ "HAVING", + /* 131 */ "ORDER", + /* 132 */ "SLIMIT", + /* 133 */ "SOFFSET", + /* 134 */ "LIMIT", + /* 135 */ "OFFSET", + /* 136 */ "ASC", + /* 137 */ "DESC", + /* 138 */ "NULLS", + /* 139 */ "FIRST", + /* 140 */ "LAST", + /* 141 */ "cmd", + /* 142 */ "user_name", + /* 143 */ "dnode_endpoint", + /* 144 */ "dnode_host_name", + /* 145 */ "not_exists_opt", + /* 146 */ "db_name", + /* 147 */ "db_options", + /* 148 */ "exists_opt", + /* 149 */ "full_table_name", + /* 150 */ "column_def_list", + /* 151 */ "tags_def_opt", + /* 152 */ "table_options", + /* 153 */ "multi_create_clause", + /* 154 */ "tags_def", + /* 155 */ "multi_drop_clause", + /* 156 */ "create_subtable_clause", + /* 157 */ "specific_tags_opt", + /* 158 */ "literal_list", + /* 159 */ "drop_table_clause", + /* 160 */ "col_name_list", + /* 161 */ "table_name", + /* 162 */ "column_def", + /* 163 */ "column_name", + /* 164 */ "type_name", + /* 165 */ "col_name", + /* 166 */ "index_name", + /* 167 */ "index_options", + /* 168 */ "func_list", + /* 169 */ "duration_literal", + /* 170 */ "sliding_opt", + /* 171 */ "func", + /* 172 */ "function_name", + /* 173 */ "expression_list", + /* 174 */ "topic_name", + /* 175 */ "query_expression", + /* 176 */ "literal", + /* 177 */ "table_alias", + /* 178 */ "column_alias", + /* 179 */ "expression", + /* 180 */ "column_reference", + /* 181 */ "subquery", + /* 182 */ "predicate", + /* 183 */ "compare_op", + /* 184 */ "in_op", + /* 185 */ "in_predicate_value", + /* 186 */ "boolean_value_expression", + /* 187 */ "boolean_primary", + /* 188 */ "common_expression", + /* 189 */ "from_clause", + /* 190 */ "table_reference_list", + /* 191 */ "table_reference", + /* 192 */ "table_primary", + /* 193 */ "joined_table", + /* 194 */ "alias_opt", + /* 195 */ "parenthesized_joined_table", + /* 196 */ "join_type", + /* 197 */ "search_condition", + /* 198 */ "query_specification", + /* 199 */ "set_quantifier_opt", + /* 200 */ "select_list", + /* 201 */ "where_clause_opt", + /* 202 */ "partition_by_clause_opt", + /* 203 */ "twindow_clause_opt", + /* 204 */ "group_by_clause_opt", + /* 205 */ "having_clause_opt", + /* 206 */ "select_sublist", + /* 207 */ "select_item", + /* 208 */ "fill_opt", + /* 209 */ "fill_mode", + /* 210 */ "group_by_list", + /* 211 */ "query_expression_body", + /* 212 */ "order_by_clause_opt", + /* 213 */ "slimit_clause_opt", + /* 214 */ "limit_clause_opt", + /* 215 */ "query_primary", + /* 216 */ "sort_specification_list", + /* 217 */ "sort_specification", + /* 218 */ "ordering_specification_opt", + /* 219 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -852,240 +869,247 @@ static const char *const yyRuleName[] = { /* 11 */ "dnode_host_name ::= NK_ID", /* 12 */ "dnode_host_name ::= NK_IPTOKEN", /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 14 */ "cmd ::= SHOW QNODES", - /* 15 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 16 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 17 */ "cmd ::= SHOW DATABASES", - /* 18 */ "cmd ::= USE db_name", - /* 19 */ "not_exists_opt ::= IF NOT EXISTS", - /* 20 */ "not_exists_opt ::=", - /* 21 */ "exists_opt ::= IF EXISTS", - /* 22 */ "exists_opt ::=", - /* 23 */ "db_options ::=", - /* 24 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 25 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 26 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 27 */ "db_options ::= db_options COMP NK_INTEGER", - /* 28 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 29 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 30 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 31 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 32 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 33 */ "db_options ::= db_options PRECISION NK_STRING", - /* 34 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 35 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 36 */ "db_options ::= db_options TTL NK_INTEGER", - /* 37 */ "db_options ::= db_options WAL NK_INTEGER", - /* 38 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 39 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 40 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 41 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 42 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 43 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 44 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 45 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 46 */ "cmd ::= SHOW TABLES", - /* 47 */ "cmd ::= SHOW STABLES", - /* 48 */ "multi_create_clause ::= create_subtable_clause", - /* 49 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 50 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 51 */ "multi_drop_clause ::= drop_table_clause", - /* 52 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 53 */ "drop_table_clause ::= exists_opt full_table_name", - /* 54 */ "specific_tags_opt ::=", - /* 55 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 56 */ "full_table_name ::= table_name", - /* 57 */ "full_table_name ::= db_name NK_DOT table_name", - /* 58 */ "column_def_list ::= column_def", - /* 59 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 60 */ "column_def ::= column_name type_name", - /* 61 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 62 */ "type_name ::= BOOL", - /* 63 */ "type_name ::= TINYINT", - /* 64 */ "type_name ::= SMALLINT", - /* 65 */ "type_name ::= INT", - /* 66 */ "type_name ::= INTEGER", - /* 67 */ "type_name ::= BIGINT", - /* 68 */ "type_name ::= FLOAT", - /* 69 */ "type_name ::= DOUBLE", - /* 70 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 71 */ "type_name ::= TIMESTAMP", - /* 72 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 73 */ "type_name ::= TINYINT UNSIGNED", - /* 74 */ "type_name ::= SMALLINT UNSIGNED", - /* 75 */ "type_name ::= INT UNSIGNED", - /* 76 */ "type_name ::= BIGINT UNSIGNED", - /* 77 */ "type_name ::= JSON", - /* 78 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 79 */ "type_name ::= MEDIUMBLOB", - /* 80 */ "type_name ::= BLOB", - /* 81 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 82 */ "type_name ::= DECIMAL", - /* 83 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 84 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 85 */ "tags_def_opt ::=", - /* 86 */ "tags_def_opt ::= tags_def", - /* 87 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 88 */ "table_options ::=", - /* 89 */ "table_options ::= table_options COMMENT NK_STRING", - /* 90 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 91 */ "table_options ::= table_options TTL NK_INTEGER", - /* 92 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 93 */ "col_name_list ::= col_name", - /* 94 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 95 */ "col_name ::= column_name", - /* 96 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 97 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 98 */ "index_options ::=", - /* 99 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 100 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 101 */ "func_list ::= func", - /* 102 */ "func_list ::= func_list NK_COMMA func", - /* 103 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 104 */ "cmd ::= SHOW VGROUPS", - /* 105 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 106 */ "cmd ::= SHOW MNODES", - /* 107 */ "cmd ::= query_expression", - /* 108 */ "literal ::= NK_INTEGER", - /* 109 */ "literal ::= NK_FLOAT", - /* 110 */ "literal ::= NK_STRING", - /* 111 */ "literal ::= NK_BOOL", - /* 112 */ "literal ::= TIMESTAMP NK_STRING", - /* 113 */ "literal ::= duration_literal", - /* 114 */ "duration_literal ::= NK_VARIABLE", - /* 115 */ "literal_list ::= literal", - /* 116 */ "literal_list ::= literal_list NK_COMMA literal", - /* 117 */ "db_name ::= NK_ID", - /* 118 */ "table_name ::= NK_ID", - /* 119 */ "column_name ::= NK_ID", - /* 120 */ "function_name ::= NK_ID", - /* 121 */ "table_alias ::= NK_ID", - /* 122 */ "column_alias ::= NK_ID", - /* 123 */ "user_name ::= NK_ID", - /* 124 */ "index_name ::= NK_ID", - /* 125 */ "expression ::= literal", - /* 126 */ "expression ::= column_reference", - /* 127 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 128 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 129 */ "expression ::= subquery", - /* 130 */ "expression ::= NK_LP expression NK_RP", - /* 131 */ "expression ::= NK_PLUS expression", - /* 132 */ "expression ::= NK_MINUS expression", - /* 133 */ "expression ::= expression NK_PLUS expression", - /* 134 */ "expression ::= expression NK_MINUS expression", - /* 135 */ "expression ::= expression NK_STAR expression", - /* 136 */ "expression ::= expression NK_SLASH expression", - /* 137 */ "expression ::= expression NK_REM expression", - /* 138 */ "expression_list ::= expression", - /* 139 */ "expression_list ::= expression_list NK_COMMA expression", - /* 140 */ "column_reference ::= column_name", - /* 141 */ "column_reference ::= table_name NK_DOT column_name", - /* 142 */ "predicate ::= expression compare_op expression", - /* 143 */ "predicate ::= expression BETWEEN expression AND expression", - /* 144 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 145 */ "predicate ::= expression IS NULL", - /* 146 */ "predicate ::= expression IS NOT NULL", - /* 147 */ "predicate ::= expression in_op in_predicate_value", - /* 148 */ "compare_op ::= NK_LT", - /* 149 */ "compare_op ::= NK_GT", - /* 150 */ "compare_op ::= NK_LE", - /* 151 */ "compare_op ::= NK_GE", - /* 152 */ "compare_op ::= NK_NE", - /* 153 */ "compare_op ::= NK_EQ", - /* 154 */ "compare_op ::= LIKE", - /* 155 */ "compare_op ::= NOT LIKE", - /* 156 */ "compare_op ::= MATCH", - /* 157 */ "compare_op ::= NMATCH", - /* 158 */ "in_op ::= IN", - /* 159 */ "in_op ::= NOT IN", - /* 160 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 161 */ "boolean_value_expression ::= boolean_primary", - /* 162 */ "boolean_value_expression ::= NOT boolean_primary", - /* 163 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 164 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 165 */ "boolean_primary ::= predicate", - /* 166 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 167 */ "common_expression ::= expression", - /* 168 */ "common_expression ::= boolean_value_expression", - /* 169 */ "from_clause ::= FROM table_reference_list", - /* 170 */ "table_reference_list ::= table_reference", - /* 171 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 172 */ "table_reference ::= table_primary", - /* 173 */ "table_reference ::= joined_table", - /* 174 */ "table_primary ::= table_name alias_opt", - /* 175 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 176 */ "table_primary ::= subquery alias_opt", - /* 177 */ "table_primary ::= parenthesized_joined_table", - /* 178 */ "alias_opt ::=", - /* 179 */ "alias_opt ::= table_alias", - /* 180 */ "alias_opt ::= AS table_alias", - /* 181 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 182 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 183 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 184 */ "join_type ::=", - /* 185 */ "join_type ::= INNER", - /* 186 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 187 */ "set_quantifier_opt ::=", - /* 188 */ "set_quantifier_opt ::= DISTINCT", - /* 189 */ "set_quantifier_opt ::= ALL", - /* 190 */ "select_list ::= NK_STAR", - /* 191 */ "select_list ::= select_sublist", - /* 192 */ "select_sublist ::= select_item", - /* 193 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 194 */ "select_item ::= common_expression", - /* 195 */ "select_item ::= common_expression column_alias", - /* 196 */ "select_item ::= common_expression AS column_alias", - /* 197 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 198 */ "where_clause_opt ::=", - /* 199 */ "where_clause_opt ::= WHERE search_condition", - /* 200 */ "partition_by_clause_opt ::=", - /* 201 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 202 */ "twindow_clause_opt ::=", - /* 203 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 204 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 205 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 206 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 207 */ "sliding_opt ::=", - /* 208 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 209 */ "fill_opt ::=", - /* 210 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 211 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 212 */ "fill_mode ::= NONE", - /* 213 */ "fill_mode ::= PREV", - /* 214 */ "fill_mode ::= NULL", - /* 215 */ "fill_mode ::= LINEAR", - /* 216 */ "fill_mode ::= NEXT", - /* 217 */ "group_by_clause_opt ::=", - /* 218 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 219 */ "group_by_list ::= expression", - /* 220 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 221 */ "having_clause_opt ::=", - /* 222 */ "having_clause_opt ::= HAVING search_condition", - /* 223 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 224 */ "query_expression_body ::= query_primary", - /* 225 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 226 */ "query_primary ::= query_specification", - /* 227 */ "order_by_clause_opt ::=", - /* 228 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 229 */ "slimit_clause_opt ::=", - /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 231 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 232 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 233 */ "limit_clause_opt ::=", - /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 235 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 236 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 237 */ "subquery ::= NK_LP query_expression NK_RP", - /* 238 */ "search_condition ::= common_expression", - /* 239 */ "sort_specification_list ::= sort_specification", - /* 240 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 241 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 242 */ "ordering_specification_opt ::=", - /* 243 */ "ordering_specification_opt ::= ASC", - /* 244 */ "ordering_specification_opt ::= DESC", - /* 245 */ "null_ordering_opt ::=", - /* 246 */ "null_ordering_opt ::= NULLS FIRST", - /* 247 */ "null_ordering_opt ::= NULLS LAST", + /* 14 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 15 */ "cmd ::= SHOW QNODES", + /* 16 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 17 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 18 */ "cmd ::= SHOW DATABASES", + /* 19 */ "cmd ::= USE db_name", + /* 20 */ "cmd ::= ALTER DATABASE db_name db_options", + /* 21 */ "not_exists_opt ::= IF NOT EXISTS", + /* 22 */ "not_exists_opt ::=", + /* 23 */ "exists_opt ::= IF EXISTS", + /* 24 */ "exists_opt ::=", + /* 25 */ "db_options ::=", + /* 26 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 27 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 28 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 29 */ "db_options ::= db_options COMP NK_INTEGER", + /* 30 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 31 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 32 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 33 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 34 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 35 */ "db_options ::= db_options PRECISION NK_STRING", + /* 36 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 37 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 38 */ "db_options ::= db_options TTL NK_INTEGER", + /* 39 */ "db_options ::= db_options WAL NK_INTEGER", + /* 40 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 41 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 42 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 43 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 44 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 45 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 46 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 47 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 48 */ "cmd ::= SHOW TABLES", + /* 49 */ "cmd ::= SHOW STABLES", + /* 50 */ "multi_create_clause ::= create_subtable_clause", + /* 51 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 52 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 53 */ "multi_drop_clause ::= drop_table_clause", + /* 54 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 55 */ "drop_table_clause ::= exists_opt full_table_name", + /* 56 */ "specific_tags_opt ::=", + /* 57 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 58 */ "full_table_name ::= table_name", + /* 59 */ "full_table_name ::= db_name NK_DOT table_name", + /* 60 */ "column_def_list ::= column_def", + /* 61 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 62 */ "column_def ::= column_name type_name", + /* 63 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 64 */ "type_name ::= BOOL", + /* 65 */ "type_name ::= TINYINT", + /* 66 */ "type_name ::= SMALLINT", + /* 67 */ "type_name ::= INT", + /* 68 */ "type_name ::= INTEGER", + /* 69 */ "type_name ::= BIGINT", + /* 70 */ "type_name ::= FLOAT", + /* 71 */ "type_name ::= DOUBLE", + /* 72 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 73 */ "type_name ::= TIMESTAMP", + /* 74 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 75 */ "type_name ::= TINYINT UNSIGNED", + /* 76 */ "type_name ::= SMALLINT UNSIGNED", + /* 77 */ "type_name ::= INT UNSIGNED", + /* 78 */ "type_name ::= BIGINT UNSIGNED", + /* 79 */ "type_name ::= JSON", + /* 80 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 81 */ "type_name ::= MEDIUMBLOB", + /* 82 */ "type_name ::= BLOB", + /* 83 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 84 */ "type_name ::= DECIMAL", + /* 85 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 86 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 87 */ "tags_def_opt ::=", + /* 88 */ "tags_def_opt ::= tags_def", + /* 89 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 90 */ "table_options ::=", + /* 91 */ "table_options ::= table_options COMMENT NK_STRING", + /* 92 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 93 */ "table_options ::= table_options TTL NK_INTEGER", + /* 94 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 95 */ "col_name_list ::= col_name", + /* 96 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 97 */ "col_name ::= column_name", + /* 98 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 99 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 100 */ "cmd ::= DROP INDEX index_name ON table_name", + /* 101 */ "index_options ::=", + /* 102 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 103 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 104 */ "func_list ::= func", + /* 105 */ "func_list ::= func_list NK_COMMA func", + /* 106 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 107 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 108 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 109 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 110 */ "cmd ::= SHOW VGROUPS", + /* 111 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 112 */ "cmd ::= SHOW MNODES", + /* 113 */ "cmd ::= query_expression", + /* 114 */ "literal ::= NK_INTEGER", + /* 115 */ "literal ::= NK_FLOAT", + /* 116 */ "literal ::= NK_STRING", + /* 117 */ "literal ::= NK_BOOL", + /* 118 */ "literal ::= TIMESTAMP NK_STRING", + /* 119 */ "literal ::= duration_literal", + /* 120 */ "duration_literal ::= NK_VARIABLE", + /* 121 */ "literal_list ::= literal", + /* 122 */ "literal_list ::= literal_list NK_COMMA literal", + /* 123 */ "db_name ::= NK_ID", + /* 124 */ "table_name ::= NK_ID", + /* 125 */ "column_name ::= NK_ID", + /* 126 */ "function_name ::= NK_ID", + /* 127 */ "table_alias ::= NK_ID", + /* 128 */ "column_alias ::= NK_ID", + /* 129 */ "user_name ::= NK_ID", + /* 130 */ "index_name ::= NK_ID", + /* 131 */ "topic_name ::= NK_ID", + /* 132 */ "expression ::= literal", + /* 133 */ "expression ::= column_reference", + /* 134 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 135 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 136 */ "expression ::= subquery", + /* 137 */ "expression ::= NK_LP expression NK_RP", + /* 138 */ "expression ::= NK_PLUS expression", + /* 139 */ "expression ::= NK_MINUS expression", + /* 140 */ "expression ::= expression NK_PLUS expression", + /* 141 */ "expression ::= expression NK_MINUS expression", + /* 142 */ "expression ::= expression NK_STAR expression", + /* 143 */ "expression ::= expression NK_SLASH expression", + /* 144 */ "expression ::= expression NK_REM expression", + /* 145 */ "expression_list ::= expression", + /* 146 */ "expression_list ::= expression_list NK_COMMA expression", + /* 147 */ "column_reference ::= column_name", + /* 148 */ "column_reference ::= table_name NK_DOT column_name", + /* 149 */ "predicate ::= expression compare_op expression", + /* 150 */ "predicate ::= expression BETWEEN expression AND expression", + /* 151 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 152 */ "predicate ::= expression IS NULL", + /* 153 */ "predicate ::= expression IS NOT NULL", + /* 154 */ "predicate ::= expression in_op in_predicate_value", + /* 155 */ "compare_op ::= NK_LT", + /* 156 */ "compare_op ::= NK_GT", + /* 157 */ "compare_op ::= NK_LE", + /* 158 */ "compare_op ::= NK_GE", + /* 159 */ "compare_op ::= NK_NE", + /* 160 */ "compare_op ::= NK_EQ", + /* 161 */ "compare_op ::= LIKE", + /* 162 */ "compare_op ::= NOT LIKE", + /* 163 */ "compare_op ::= MATCH", + /* 164 */ "compare_op ::= NMATCH", + /* 165 */ "in_op ::= IN", + /* 166 */ "in_op ::= NOT IN", + /* 167 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 168 */ "boolean_value_expression ::= boolean_primary", + /* 169 */ "boolean_value_expression ::= NOT boolean_primary", + /* 170 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 171 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 172 */ "boolean_primary ::= predicate", + /* 173 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 174 */ "common_expression ::= expression", + /* 175 */ "common_expression ::= boolean_value_expression", + /* 176 */ "from_clause ::= FROM table_reference_list", + /* 177 */ "table_reference_list ::= table_reference", + /* 178 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 179 */ "table_reference ::= table_primary", + /* 180 */ "table_reference ::= joined_table", + /* 181 */ "table_primary ::= table_name alias_opt", + /* 182 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 183 */ "table_primary ::= subquery alias_opt", + /* 184 */ "table_primary ::= parenthesized_joined_table", + /* 185 */ "alias_opt ::=", + /* 186 */ "alias_opt ::= table_alias", + /* 187 */ "alias_opt ::= AS table_alias", + /* 188 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 189 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 190 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 191 */ "join_type ::=", + /* 192 */ "join_type ::= INNER", + /* 193 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 194 */ "set_quantifier_opt ::=", + /* 195 */ "set_quantifier_opt ::= DISTINCT", + /* 196 */ "set_quantifier_opt ::= ALL", + /* 197 */ "select_list ::= NK_STAR", + /* 198 */ "select_list ::= select_sublist", + /* 199 */ "select_sublist ::= select_item", + /* 200 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 201 */ "select_item ::= common_expression", + /* 202 */ "select_item ::= common_expression column_alias", + /* 203 */ "select_item ::= common_expression AS column_alias", + /* 204 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 205 */ "where_clause_opt ::=", + /* 206 */ "where_clause_opt ::= WHERE search_condition", + /* 207 */ "partition_by_clause_opt ::=", + /* 208 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 209 */ "twindow_clause_opt ::=", + /* 210 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 211 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 212 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 213 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 214 */ "sliding_opt ::=", + /* 215 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 216 */ "fill_opt ::=", + /* 217 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 218 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 219 */ "fill_mode ::= NONE", + /* 220 */ "fill_mode ::= PREV", + /* 221 */ "fill_mode ::= NULL", + /* 222 */ "fill_mode ::= LINEAR", + /* 223 */ "fill_mode ::= NEXT", + /* 224 */ "group_by_clause_opt ::=", + /* 225 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 226 */ "group_by_list ::= expression", + /* 227 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 228 */ "having_clause_opt ::=", + /* 229 */ "having_clause_opt ::= HAVING search_condition", + /* 230 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 231 */ "query_expression_body ::= query_primary", + /* 232 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 233 */ "query_primary ::= query_specification", + /* 234 */ "order_by_clause_opt ::=", + /* 235 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 236 */ "slimit_clause_opt ::=", + /* 237 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 238 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 239 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 240 */ "limit_clause_opt ::=", + /* 241 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 242 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 243 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 244 */ "subquery ::= NK_LP query_expression NK_RP", + /* 245 */ "search_condition ::= common_expression", + /* 246 */ "sort_specification_list ::= sort_specification", + /* 247 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 248 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 249 */ "ordering_specification_opt ::=", + /* 250 */ "ordering_specification_opt ::= ASC", + /* 251 */ "ordering_specification_opt ::= DESC", + /* 252 */ "null_ordering_opt ::=", + /* 253 */ "null_ordering_opt ::= NULLS FIRST", + /* 254 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1212,120 +1236,121 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 140: /* cmd */ - case 146: /* db_options */ - case 148: /* full_table_name */ - case 151: /* table_options */ - case 155: /* create_subtable_clause */ - case 158: /* drop_table_clause */ - case 161: /* column_def */ - case 164: /* col_name */ - case 166: /* index_options */ - case 168: /* duration_literal */ - case 169: /* sliding_opt */ - case 170: /* func */ - case 173: /* query_expression */ - case 174: /* literal */ - case 177: /* expression */ - case 178: /* column_reference */ - case 179: /* subquery */ - case 180: /* predicate */ - case 183: /* in_predicate_value */ - case 184: /* boolean_value_expression */ - case 185: /* boolean_primary */ - case 186: /* common_expression */ - case 187: /* from_clause */ - case 188: /* table_reference_list */ - case 189: /* table_reference */ - case 190: /* table_primary */ - case 191: /* joined_table */ - case 193: /* parenthesized_joined_table */ - case 195: /* search_condition */ - case 196: /* query_specification */ - case 199: /* where_clause_opt */ - case 201: /* twindow_clause_opt */ - case 203: /* having_clause_opt */ - case 205: /* select_item */ - case 206: /* fill_opt */ - case 209: /* query_expression_body */ - case 211: /* slimit_clause_opt */ - case 212: /* limit_clause_opt */ - case 213: /* query_primary */ - case 215: /* sort_specification */ + case 141: /* cmd */ + case 147: /* db_options */ + case 149: /* full_table_name */ + case 152: /* table_options */ + case 156: /* create_subtable_clause */ + case 159: /* drop_table_clause */ + case 162: /* column_def */ + case 165: /* col_name */ + case 167: /* index_options */ + case 169: /* duration_literal */ + case 170: /* sliding_opt */ + case 171: /* func */ + case 175: /* query_expression */ + case 176: /* literal */ + case 179: /* expression */ + case 180: /* column_reference */ + case 181: /* subquery */ + case 182: /* predicate */ + case 185: /* in_predicate_value */ + case 186: /* boolean_value_expression */ + case 187: /* boolean_primary */ + case 188: /* common_expression */ + case 189: /* from_clause */ + case 190: /* table_reference_list */ + case 191: /* table_reference */ + case 192: /* table_primary */ + case 193: /* joined_table */ + case 195: /* parenthesized_joined_table */ + case 197: /* search_condition */ + case 198: /* query_specification */ + case 201: /* where_clause_opt */ + case 203: /* twindow_clause_opt */ + case 205: /* having_clause_opt */ + case 207: /* select_item */ + case 208: /* fill_opt */ + case 211: /* query_expression_body */ + case 213: /* slimit_clause_opt */ + case 214: /* limit_clause_opt */ + case 215: /* query_primary */ + case 217: /* sort_specification */ { - nodesDestroyNode((yypminor->yy68)); + nodesDestroyNode((yypminor->yy432)); } break; - case 141: /* user_name */ - case 142: /* dnode_endpoint */ - case 143: /* dnode_host_name */ - case 145: /* db_name */ - case 160: /* table_name */ - case 162: /* column_name */ - case 165: /* index_name */ - case 171: /* function_name */ - case 175: /* table_alias */ - case 176: /* column_alias */ - case 192: /* alias_opt */ + case 142: /* user_name */ + case 143: /* dnode_endpoint */ + case 144: /* dnode_host_name */ + case 146: /* db_name */ + case 161: /* table_name */ + case 163: /* column_name */ + case 166: /* index_name */ + case 172: /* function_name */ + case 174: /* topic_name */ + case 177: /* table_alias */ + case 178: /* column_alias */ + case 194: /* alias_opt */ { } break; - case 144: /* not_exists_opt */ - case 147: /* exists_opt */ - case 197: /* set_quantifier_opt */ + case 145: /* not_exists_opt */ + case 148: /* exists_opt */ + case 199: /* set_quantifier_opt */ { } break; - case 149: /* column_def_list */ - case 150: /* tags_def_opt */ - case 152: /* multi_create_clause */ - case 153: /* tags_def */ - case 154: /* multi_drop_clause */ - case 156: /* specific_tags_opt */ - case 157: /* literal_list */ - case 159: /* col_name_list */ - case 167: /* func_list */ - case 172: /* expression_list */ - case 198: /* select_list */ - case 200: /* partition_by_clause_opt */ - case 202: /* group_by_clause_opt */ - case 204: /* select_sublist */ - case 208: /* group_by_list */ - case 210: /* order_by_clause_opt */ - case 214: /* sort_specification_list */ + case 150: /* column_def_list */ + case 151: /* tags_def_opt */ + case 153: /* multi_create_clause */ + case 154: /* tags_def */ + case 155: /* multi_drop_clause */ + case 157: /* specific_tags_opt */ + case 158: /* literal_list */ + case 160: /* col_name_list */ + case 168: /* func_list */ + case 173: /* expression_list */ + case 200: /* select_list */ + case 202: /* partition_by_clause_opt */ + case 204: /* group_by_clause_opt */ + case 206: /* select_sublist */ + case 210: /* group_by_list */ + case 212: /* order_by_clause_opt */ + case 216: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy40)); + nodesDestroyList((yypminor->yy24)); } break; - case 163: /* type_name */ + case 164: /* type_name */ { } break; - case 181: /* compare_op */ - case 182: /* in_op */ + case 183: /* compare_op */ + case 184: /* in_op */ { } break; - case 194: /* join_type */ + case 196: /* join_type */ { } break; - case 207: /* fill_mode */ + case 209: /* fill_mode */ { } break; - case 216: /* ordering_specification_opt */ + case 218: /* ordering_specification_opt */ { } break; - case 217: /* null_ordering_opt */ + case 219: /* null_ordering_opt */ { } @@ -1624,254 +1649,261 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 140, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 140, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 140, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 140, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 140, -2 }, /* (4) cmd ::= SHOW USERS */ - { 140, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 140, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 140, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 140, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 140, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 142, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 143, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 143, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 140, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 140, -2 }, /* (14) cmd ::= SHOW QNODES */ - { 140, -5 }, /* (15) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 140, -4 }, /* (16) cmd ::= DROP DATABASE exists_opt db_name */ - { 140, -2 }, /* (17) cmd ::= SHOW DATABASES */ - { 140, -2 }, /* (18) cmd ::= USE db_name */ - { 144, -3 }, /* (19) not_exists_opt ::= IF NOT EXISTS */ - { 144, 0 }, /* (20) not_exists_opt ::= */ - { 147, -2 }, /* (21) exists_opt ::= IF EXISTS */ - { 147, 0 }, /* (22) exists_opt ::= */ - { 146, 0 }, /* (23) db_options ::= */ - { 146, -3 }, /* (24) db_options ::= db_options BLOCKS NK_INTEGER */ - { 146, -3 }, /* (25) db_options ::= db_options CACHE NK_INTEGER */ - { 146, -3 }, /* (26) db_options ::= db_options CACHELAST NK_INTEGER */ - { 146, -3 }, /* (27) db_options ::= db_options COMP NK_INTEGER */ - { 146, -3 }, /* (28) db_options ::= db_options DAYS NK_INTEGER */ - { 146, -3 }, /* (29) db_options ::= db_options FSYNC NK_INTEGER */ - { 146, -3 }, /* (30) db_options ::= db_options MAXROWS NK_INTEGER */ - { 146, -3 }, /* (31) db_options ::= db_options MINROWS NK_INTEGER */ - { 146, -3 }, /* (32) db_options ::= db_options KEEP NK_INTEGER */ - { 146, -3 }, /* (33) db_options ::= db_options PRECISION NK_STRING */ - { 146, -3 }, /* (34) db_options ::= db_options QUORUM NK_INTEGER */ - { 146, -3 }, /* (35) db_options ::= db_options REPLICA NK_INTEGER */ - { 146, -3 }, /* (36) db_options ::= db_options TTL NK_INTEGER */ - { 146, -3 }, /* (37) db_options ::= db_options WAL NK_INTEGER */ - { 146, -3 }, /* (38) db_options ::= db_options VGROUPS NK_INTEGER */ - { 146, -3 }, /* (39) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 146, -3 }, /* (40) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 140, -9 }, /* (41) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 140, -3 }, /* (42) cmd ::= CREATE TABLE multi_create_clause */ - { 140, -9 }, /* (43) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 140, -3 }, /* (44) cmd ::= DROP TABLE multi_drop_clause */ - { 140, -4 }, /* (45) cmd ::= DROP STABLE exists_opt full_table_name */ - { 140, -2 }, /* (46) cmd ::= SHOW TABLES */ - { 140, -2 }, /* (47) cmd ::= SHOW STABLES */ - { 152, -1 }, /* (48) multi_create_clause ::= create_subtable_clause */ - { 152, -2 }, /* (49) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 155, -9 }, /* (50) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 154, -1 }, /* (51) multi_drop_clause ::= drop_table_clause */ - { 154, -2 }, /* (52) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 158, -2 }, /* (53) drop_table_clause ::= exists_opt full_table_name */ - { 156, 0 }, /* (54) specific_tags_opt ::= */ - { 156, -3 }, /* (55) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 148, -1 }, /* (56) full_table_name ::= table_name */ - { 148, -3 }, /* (57) full_table_name ::= db_name NK_DOT table_name */ - { 149, -1 }, /* (58) column_def_list ::= column_def */ - { 149, -3 }, /* (59) column_def_list ::= column_def_list NK_COMMA column_def */ - { 161, -2 }, /* (60) column_def ::= column_name type_name */ - { 161, -4 }, /* (61) column_def ::= column_name type_name COMMENT NK_STRING */ - { 163, -1 }, /* (62) type_name ::= BOOL */ - { 163, -1 }, /* (63) type_name ::= TINYINT */ - { 163, -1 }, /* (64) type_name ::= SMALLINT */ - { 163, -1 }, /* (65) type_name ::= INT */ - { 163, -1 }, /* (66) type_name ::= INTEGER */ - { 163, -1 }, /* (67) type_name ::= BIGINT */ - { 163, -1 }, /* (68) type_name ::= FLOAT */ - { 163, -1 }, /* (69) type_name ::= DOUBLE */ - { 163, -4 }, /* (70) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (71) type_name ::= TIMESTAMP */ - { 163, -4 }, /* (72) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -2 }, /* (73) type_name ::= TINYINT UNSIGNED */ - { 163, -2 }, /* (74) type_name ::= SMALLINT UNSIGNED */ - { 163, -2 }, /* (75) type_name ::= INT UNSIGNED */ - { 163, -2 }, /* (76) type_name ::= BIGINT UNSIGNED */ - { 163, -1 }, /* (77) type_name ::= JSON */ - { 163, -4 }, /* (78) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (79) type_name ::= MEDIUMBLOB */ - { 163, -1 }, /* (80) type_name ::= BLOB */ - { 163, -4 }, /* (81) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (82) type_name ::= DECIMAL */ - { 163, -4 }, /* (83) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 163, -6 }, /* (84) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 150, 0 }, /* (85) tags_def_opt ::= */ - { 150, -1 }, /* (86) tags_def_opt ::= tags_def */ - { 153, -4 }, /* (87) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 151, 0 }, /* (88) table_options ::= */ - { 151, -3 }, /* (89) table_options ::= table_options COMMENT NK_STRING */ - { 151, -3 }, /* (90) table_options ::= table_options KEEP NK_INTEGER */ - { 151, -3 }, /* (91) table_options ::= table_options TTL NK_INTEGER */ - { 151, -5 }, /* (92) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 159, -1 }, /* (93) col_name_list ::= col_name */ - { 159, -3 }, /* (94) col_name_list ::= col_name_list NK_COMMA col_name */ - { 164, -1 }, /* (95) col_name ::= column_name */ - { 140, -7 }, /* (96) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 140, -9 }, /* (97) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 166, 0 }, /* (98) index_options ::= */ - { 166, -9 }, /* (99) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 166, -11 }, /* (100) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 167, -1 }, /* (101) func_list ::= func */ - { 167, -3 }, /* (102) func_list ::= func_list NK_COMMA func */ - { 170, -4 }, /* (103) func ::= function_name NK_LP expression_list NK_RP */ - { 140, -2 }, /* (104) cmd ::= SHOW VGROUPS */ - { 140, -4 }, /* (105) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 140, -2 }, /* (106) cmd ::= SHOW MNODES */ - { 140, -1 }, /* (107) cmd ::= query_expression */ - { 174, -1 }, /* (108) literal ::= NK_INTEGER */ - { 174, -1 }, /* (109) literal ::= NK_FLOAT */ - { 174, -1 }, /* (110) literal ::= NK_STRING */ - { 174, -1 }, /* (111) literal ::= NK_BOOL */ - { 174, -2 }, /* (112) literal ::= TIMESTAMP NK_STRING */ - { 174, -1 }, /* (113) literal ::= duration_literal */ - { 168, -1 }, /* (114) duration_literal ::= NK_VARIABLE */ - { 157, -1 }, /* (115) literal_list ::= literal */ - { 157, -3 }, /* (116) literal_list ::= literal_list NK_COMMA literal */ - { 145, -1 }, /* (117) db_name ::= NK_ID */ - { 160, -1 }, /* (118) table_name ::= NK_ID */ - { 162, -1 }, /* (119) column_name ::= NK_ID */ - { 171, -1 }, /* (120) function_name ::= NK_ID */ - { 175, -1 }, /* (121) table_alias ::= NK_ID */ - { 176, -1 }, /* (122) column_alias ::= NK_ID */ - { 141, -1 }, /* (123) user_name ::= NK_ID */ - { 165, -1 }, /* (124) index_name ::= NK_ID */ - { 177, -1 }, /* (125) expression ::= literal */ - { 177, -1 }, /* (126) expression ::= column_reference */ - { 177, -4 }, /* (127) expression ::= function_name NK_LP expression_list NK_RP */ - { 177, -4 }, /* (128) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 177, -1 }, /* (129) expression ::= subquery */ - { 177, -3 }, /* (130) expression ::= NK_LP expression NK_RP */ - { 177, -2 }, /* (131) expression ::= NK_PLUS expression */ - { 177, -2 }, /* (132) expression ::= NK_MINUS expression */ - { 177, -3 }, /* (133) expression ::= expression NK_PLUS expression */ - { 177, -3 }, /* (134) expression ::= expression NK_MINUS expression */ - { 177, -3 }, /* (135) expression ::= expression NK_STAR expression */ - { 177, -3 }, /* (136) expression ::= expression NK_SLASH expression */ - { 177, -3 }, /* (137) expression ::= expression NK_REM expression */ - { 172, -1 }, /* (138) expression_list ::= expression */ - { 172, -3 }, /* (139) expression_list ::= expression_list NK_COMMA expression */ - { 178, -1 }, /* (140) column_reference ::= column_name */ - { 178, -3 }, /* (141) column_reference ::= table_name NK_DOT column_name */ - { 180, -3 }, /* (142) predicate ::= expression compare_op expression */ - { 180, -5 }, /* (143) predicate ::= expression BETWEEN expression AND expression */ - { 180, -6 }, /* (144) predicate ::= expression NOT BETWEEN expression AND expression */ - { 180, -3 }, /* (145) predicate ::= expression IS NULL */ - { 180, -4 }, /* (146) predicate ::= expression IS NOT NULL */ - { 180, -3 }, /* (147) predicate ::= expression in_op in_predicate_value */ - { 181, -1 }, /* (148) compare_op ::= NK_LT */ - { 181, -1 }, /* (149) compare_op ::= NK_GT */ - { 181, -1 }, /* (150) compare_op ::= NK_LE */ - { 181, -1 }, /* (151) compare_op ::= NK_GE */ - { 181, -1 }, /* (152) compare_op ::= NK_NE */ - { 181, -1 }, /* (153) compare_op ::= NK_EQ */ - { 181, -1 }, /* (154) compare_op ::= LIKE */ - { 181, -2 }, /* (155) compare_op ::= NOT LIKE */ - { 181, -1 }, /* (156) compare_op ::= MATCH */ - { 181, -1 }, /* (157) compare_op ::= NMATCH */ - { 182, -1 }, /* (158) in_op ::= IN */ - { 182, -2 }, /* (159) in_op ::= NOT IN */ - { 183, -3 }, /* (160) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 184, -1 }, /* (161) boolean_value_expression ::= boolean_primary */ - { 184, -2 }, /* (162) boolean_value_expression ::= NOT boolean_primary */ - { 184, -3 }, /* (163) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 184, -3 }, /* (164) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 185, -1 }, /* (165) boolean_primary ::= predicate */ - { 185, -3 }, /* (166) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 186, -1 }, /* (167) common_expression ::= expression */ - { 186, -1 }, /* (168) common_expression ::= boolean_value_expression */ - { 187, -2 }, /* (169) from_clause ::= FROM table_reference_list */ - { 188, -1 }, /* (170) table_reference_list ::= table_reference */ - { 188, -3 }, /* (171) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 189, -1 }, /* (172) table_reference ::= table_primary */ - { 189, -1 }, /* (173) table_reference ::= joined_table */ - { 190, -2 }, /* (174) table_primary ::= table_name alias_opt */ - { 190, -4 }, /* (175) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 190, -2 }, /* (176) table_primary ::= subquery alias_opt */ - { 190, -1 }, /* (177) table_primary ::= parenthesized_joined_table */ - { 192, 0 }, /* (178) alias_opt ::= */ - { 192, -1 }, /* (179) alias_opt ::= table_alias */ - { 192, -2 }, /* (180) alias_opt ::= AS table_alias */ - { 193, -3 }, /* (181) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 193, -3 }, /* (182) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 191, -6 }, /* (183) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 194, 0 }, /* (184) join_type ::= */ - { 194, -1 }, /* (185) join_type ::= INNER */ - { 196, -9 }, /* (186) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 197, 0 }, /* (187) set_quantifier_opt ::= */ - { 197, -1 }, /* (188) set_quantifier_opt ::= DISTINCT */ - { 197, -1 }, /* (189) set_quantifier_opt ::= ALL */ - { 198, -1 }, /* (190) select_list ::= NK_STAR */ - { 198, -1 }, /* (191) select_list ::= select_sublist */ - { 204, -1 }, /* (192) select_sublist ::= select_item */ - { 204, -3 }, /* (193) select_sublist ::= select_sublist NK_COMMA select_item */ - { 205, -1 }, /* (194) select_item ::= common_expression */ - { 205, -2 }, /* (195) select_item ::= common_expression column_alias */ - { 205, -3 }, /* (196) select_item ::= common_expression AS column_alias */ - { 205, -3 }, /* (197) select_item ::= table_name NK_DOT NK_STAR */ - { 199, 0 }, /* (198) where_clause_opt ::= */ - { 199, -2 }, /* (199) where_clause_opt ::= WHERE search_condition */ - { 200, 0 }, /* (200) partition_by_clause_opt ::= */ - { 200, -3 }, /* (201) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 201, 0 }, /* (202) twindow_clause_opt ::= */ - { 201, -6 }, /* (203) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 201, -4 }, /* (204) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 201, -6 }, /* (205) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 201, -8 }, /* (206) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 169, 0 }, /* (207) sliding_opt ::= */ - { 169, -4 }, /* (208) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 206, 0 }, /* (209) fill_opt ::= */ - { 206, -4 }, /* (210) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 206, -6 }, /* (211) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 207, -1 }, /* (212) fill_mode ::= NONE */ - { 207, -1 }, /* (213) fill_mode ::= PREV */ - { 207, -1 }, /* (214) fill_mode ::= NULL */ - { 207, -1 }, /* (215) fill_mode ::= LINEAR */ - { 207, -1 }, /* (216) fill_mode ::= NEXT */ - { 202, 0 }, /* (217) group_by_clause_opt ::= */ - { 202, -3 }, /* (218) group_by_clause_opt ::= GROUP BY group_by_list */ - { 208, -1 }, /* (219) group_by_list ::= expression */ - { 208, -3 }, /* (220) group_by_list ::= group_by_list NK_COMMA expression */ - { 203, 0 }, /* (221) having_clause_opt ::= */ - { 203, -2 }, /* (222) having_clause_opt ::= HAVING search_condition */ - { 173, -4 }, /* (223) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 209, -1 }, /* (224) query_expression_body ::= query_primary */ - { 209, -4 }, /* (225) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 213, -1 }, /* (226) query_primary ::= query_specification */ - { 210, 0 }, /* (227) order_by_clause_opt ::= */ - { 210, -3 }, /* (228) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 211, 0 }, /* (229) slimit_clause_opt ::= */ - { 211, -2 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 211, -4 }, /* (231) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 211, -4 }, /* (232) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 212, 0 }, /* (233) limit_clause_opt ::= */ - { 212, -2 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 212, -4 }, /* (235) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 212, -4 }, /* (236) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 179, -3 }, /* (237) subquery ::= NK_LP query_expression NK_RP */ - { 195, -1 }, /* (238) search_condition ::= common_expression */ - { 214, -1 }, /* (239) sort_specification_list ::= sort_specification */ - { 214, -3 }, /* (240) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 215, -3 }, /* (241) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 216, 0 }, /* (242) ordering_specification_opt ::= */ - { 216, -1 }, /* (243) ordering_specification_opt ::= ASC */ - { 216, -1 }, /* (244) ordering_specification_opt ::= DESC */ - { 217, 0 }, /* (245) null_ordering_opt ::= */ - { 217, -2 }, /* (246) null_ordering_opt ::= NULLS FIRST */ - { 217, -2 }, /* (247) null_ordering_opt ::= NULLS LAST */ + { 141, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 141, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 141, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 141, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 141, -2 }, /* (4) cmd ::= SHOW USERS */ + { 141, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 141, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 141, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 141, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 141, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 143, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 144, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 144, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 141, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 141, -5 }, /* (14) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 141, -2 }, /* (15) cmd ::= SHOW QNODES */ + { 141, -5 }, /* (16) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 141, -4 }, /* (17) cmd ::= DROP DATABASE exists_opt db_name */ + { 141, -2 }, /* (18) cmd ::= SHOW DATABASES */ + { 141, -2 }, /* (19) cmd ::= USE db_name */ + { 141, -4 }, /* (20) cmd ::= ALTER DATABASE db_name db_options */ + { 145, -3 }, /* (21) not_exists_opt ::= IF NOT EXISTS */ + { 145, 0 }, /* (22) not_exists_opt ::= */ + { 148, -2 }, /* (23) exists_opt ::= IF EXISTS */ + { 148, 0 }, /* (24) exists_opt ::= */ + { 147, 0 }, /* (25) db_options ::= */ + { 147, -3 }, /* (26) db_options ::= db_options BLOCKS NK_INTEGER */ + { 147, -3 }, /* (27) db_options ::= db_options CACHE NK_INTEGER */ + { 147, -3 }, /* (28) db_options ::= db_options CACHELAST NK_INTEGER */ + { 147, -3 }, /* (29) db_options ::= db_options COMP NK_INTEGER */ + { 147, -3 }, /* (30) db_options ::= db_options DAYS NK_INTEGER */ + { 147, -3 }, /* (31) db_options ::= db_options FSYNC NK_INTEGER */ + { 147, -3 }, /* (32) db_options ::= db_options MAXROWS NK_INTEGER */ + { 147, -3 }, /* (33) db_options ::= db_options MINROWS NK_INTEGER */ + { 147, -3 }, /* (34) db_options ::= db_options KEEP NK_INTEGER */ + { 147, -3 }, /* (35) db_options ::= db_options PRECISION NK_STRING */ + { 147, -3 }, /* (36) db_options ::= db_options QUORUM NK_INTEGER */ + { 147, -3 }, /* (37) db_options ::= db_options REPLICA NK_INTEGER */ + { 147, -3 }, /* (38) db_options ::= db_options TTL NK_INTEGER */ + { 147, -3 }, /* (39) db_options ::= db_options WAL NK_INTEGER */ + { 147, -3 }, /* (40) db_options ::= db_options VGROUPS NK_INTEGER */ + { 147, -3 }, /* (41) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 147, -3 }, /* (42) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 141, -9 }, /* (43) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 141, -3 }, /* (44) cmd ::= CREATE TABLE multi_create_clause */ + { 141, -9 }, /* (45) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 141, -3 }, /* (46) cmd ::= DROP TABLE multi_drop_clause */ + { 141, -4 }, /* (47) cmd ::= DROP STABLE exists_opt full_table_name */ + { 141, -2 }, /* (48) cmd ::= SHOW TABLES */ + { 141, -2 }, /* (49) cmd ::= SHOW STABLES */ + { 153, -1 }, /* (50) multi_create_clause ::= create_subtable_clause */ + { 153, -2 }, /* (51) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 156, -9 }, /* (52) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 155, -1 }, /* (53) multi_drop_clause ::= drop_table_clause */ + { 155, -2 }, /* (54) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 159, -2 }, /* (55) drop_table_clause ::= exists_opt full_table_name */ + { 157, 0 }, /* (56) specific_tags_opt ::= */ + { 157, -3 }, /* (57) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 149, -1 }, /* (58) full_table_name ::= table_name */ + { 149, -3 }, /* (59) full_table_name ::= db_name NK_DOT table_name */ + { 150, -1 }, /* (60) column_def_list ::= column_def */ + { 150, -3 }, /* (61) column_def_list ::= column_def_list NK_COMMA column_def */ + { 162, -2 }, /* (62) column_def ::= column_name type_name */ + { 162, -4 }, /* (63) column_def ::= column_name type_name COMMENT NK_STRING */ + { 164, -1 }, /* (64) type_name ::= BOOL */ + { 164, -1 }, /* (65) type_name ::= TINYINT */ + { 164, -1 }, /* (66) type_name ::= SMALLINT */ + { 164, -1 }, /* (67) type_name ::= INT */ + { 164, -1 }, /* (68) type_name ::= INTEGER */ + { 164, -1 }, /* (69) type_name ::= BIGINT */ + { 164, -1 }, /* (70) type_name ::= FLOAT */ + { 164, -1 }, /* (71) type_name ::= DOUBLE */ + { 164, -4 }, /* (72) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (73) type_name ::= TIMESTAMP */ + { 164, -4 }, /* (74) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -2 }, /* (75) type_name ::= TINYINT UNSIGNED */ + { 164, -2 }, /* (76) type_name ::= SMALLINT UNSIGNED */ + { 164, -2 }, /* (77) type_name ::= INT UNSIGNED */ + { 164, -2 }, /* (78) type_name ::= BIGINT UNSIGNED */ + { 164, -1 }, /* (79) type_name ::= JSON */ + { 164, -4 }, /* (80) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (81) type_name ::= MEDIUMBLOB */ + { 164, -1 }, /* (82) type_name ::= BLOB */ + { 164, -4 }, /* (83) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (84) type_name ::= DECIMAL */ + { 164, -4 }, /* (85) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 164, -6 }, /* (86) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 151, 0 }, /* (87) tags_def_opt ::= */ + { 151, -1 }, /* (88) tags_def_opt ::= tags_def */ + { 154, -4 }, /* (89) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 152, 0 }, /* (90) table_options ::= */ + { 152, -3 }, /* (91) table_options ::= table_options COMMENT NK_STRING */ + { 152, -3 }, /* (92) table_options ::= table_options KEEP NK_INTEGER */ + { 152, -3 }, /* (93) table_options ::= table_options TTL NK_INTEGER */ + { 152, -5 }, /* (94) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 160, -1 }, /* (95) col_name_list ::= col_name */ + { 160, -3 }, /* (96) col_name_list ::= col_name_list NK_COMMA col_name */ + { 165, -1 }, /* (97) col_name ::= column_name */ + { 141, -7 }, /* (98) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 141, -9 }, /* (99) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 141, -5 }, /* (100) cmd ::= DROP INDEX index_name ON table_name */ + { 167, 0 }, /* (101) index_options ::= */ + { 167, -9 }, /* (102) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 167, -11 }, /* (103) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 168, -1 }, /* (104) func_list ::= func */ + { 168, -3 }, /* (105) func_list ::= func_list NK_COMMA func */ + { 171, -4 }, /* (106) func ::= function_name NK_LP expression_list NK_RP */ + { 141, -6 }, /* (107) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 141, -6 }, /* (108) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 141, -4 }, /* (109) cmd ::= DROP TOPIC exists_opt topic_name */ + { 141, -2 }, /* (110) cmd ::= SHOW VGROUPS */ + { 141, -4 }, /* (111) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 141, -2 }, /* (112) cmd ::= SHOW MNODES */ + { 141, -1 }, /* (113) cmd ::= query_expression */ + { 176, -1 }, /* (114) literal ::= NK_INTEGER */ + { 176, -1 }, /* (115) literal ::= NK_FLOAT */ + { 176, -1 }, /* (116) literal ::= NK_STRING */ + { 176, -1 }, /* (117) literal ::= NK_BOOL */ + { 176, -2 }, /* (118) literal ::= TIMESTAMP NK_STRING */ + { 176, -1 }, /* (119) literal ::= duration_literal */ + { 169, -1 }, /* (120) duration_literal ::= NK_VARIABLE */ + { 158, -1 }, /* (121) literal_list ::= literal */ + { 158, -3 }, /* (122) literal_list ::= literal_list NK_COMMA literal */ + { 146, -1 }, /* (123) db_name ::= NK_ID */ + { 161, -1 }, /* (124) table_name ::= NK_ID */ + { 163, -1 }, /* (125) column_name ::= NK_ID */ + { 172, -1 }, /* (126) function_name ::= NK_ID */ + { 177, -1 }, /* (127) table_alias ::= NK_ID */ + { 178, -1 }, /* (128) column_alias ::= NK_ID */ + { 142, -1 }, /* (129) user_name ::= NK_ID */ + { 166, -1 }, /* (130) index_name ::= NK_ID */ + { 174, -1 }, /* (131) topic_name ::= NK_ID */ + { 179, -1 }, /* (132) expression ::= literal */ + { 179, -1 }, /* (133) expression ::= column_reference */ + { 179, -4 }, /* (134) expression ::= function_name NK_LP expression_list NK_RP */ + { 179, -4 }, /* (135) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 179, -1 }, /* (136) expression ::= subquery */ + { 179, -3 }, /* (137) expression ::= NK_LP expression NK_RP */ + { 179, -2 }, /* (138) expression ::= NK_PLUS expression */ + { 179, -2 }, /* (139) expression ::= NK_MINUS expression */ + { 179, -3 }, /* (140) expression ::= expression NK_PLUS expression */ + { 179, -3 }, /* (141) expression ::= expression NK_MINUS expression */ + { 179, -3 }, /* (142) expression ::= expression NK_STAR expression */ + { 179, -3 }, /* (143) expression ::= expression NK_SLASH expression */ + { 179, -3 }, /* (144) expression ::= expression NK_REM expression */ + { 173, -1 }, /* (145) expression_list ::= expression */ + { 173, -3 }, /* (146) expression_list ::= expression_list NK_COMMA expression */ + { 180, -1 }, /* (147) column_reference ::= column_name */ + { 180, -3 }, /* (148) column_reference ::= table_name NK_DOT column_name */ + { 182, -3 }, /* (149) predicate ::= expression compare_op expression */ + { 182, -5 }, /* (150) predicate ::= expression BETWEEN expression AND expression */ + { 182, -6 }, /* (151) predicate ::= expression NOT BETWEEN expression AND expression */ + { 182, -3 }, /* (152) predicate ::= expression IS NULL */ + { 182, -4 }, /* (153) predicate ::= expression IS NOT NULL */ + { 182, -3 }, /* (154) predicate ::= expression in_op in_predicate_value */ + { 183, -1 }, /* (155) compare_op ::= NK_LT */ + { 183, -1 }, /* (156) compare_op ::= NK_GT */ + { 183, -1 }, /* (157) compare_op ::= NK_LE */ + { 183, -1 }, /* (158) compare_op ::= NK_GE */ + { 183, -1 }, /* (159) compare_op ::= NK_NE */ + { 183, -1 }, /* (160) compare_op ::= NK_EQ */ + { 183, -1 }, /* (161) compare_op ::= LIKE */ + { 183, -2 }, /* (162) compare_op ::= NOT LIKE */ + { 183, -1 }, /* (163) compare_op ::= MATCH */ + { 183, -1 }, /* (164) compare_op ::= NMATCH */ + { 184, -1 }, /* (165) in_op ::= IN */ + { 184, -2 }, /* (166) in_op ::= NOT IN */ + { 185, -3 }, /* (167) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 186, -1 }, /* (168) boolean_value_expression ::= boolean_primary */ + { 186, -2 }, /* (169) boolean_value_expression ::= NOT boolean_primary */ + { 186, -3 }, /* (170) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 186, -3 }, /* (171) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 187, -1 }, /* (172) boolean_primary ::= predicate */ + { 187, -3 }, /* (173) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 188, -1 }, /* (174) common_expression ::= expression */ + { 188, -1 }, /* (175) common_expression ::= boolean_value_expression */ + { 189, -2 }, /* (176) from_clause ::= FROM table_reference_list */ + { 190, -1 }, /* (177) table_reference_list ::= table_reference */ + { 190, -3 }, /* (178) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 191, -1 }, /* (179) table_reference ::= table_primary */ + { 191, -1 }, /* (180) table_reference ::= joined_table */ + { 192, -2 }, /* (181) table_primary ::= table_name alias_opt */ + { 192, -4 }, /* (182) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 192, -2 }, /* (183) table_primary ::= subquery alias_opt */ + { 192, -1 }, /* (184) table_primary ::= parenthesized_joined_table */ + { 194, 0 }, /* (185) alias_opt ::= */ + { 194, -1 }, /* (186) alias_opt ::= table_alias */ + { 194, -2 }, /* (187) alias_opt ::= AS table_alias */ + { 195, -3 }, /* (188) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 195, -3 }, /* (189) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 193, -6 }, /* (190) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 196, 0 }, /* (191) join_type ::= */ + { 196, -1 }, /* (192) join_type ::= INNER */ + { 198, -9 }, /* (193) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 199, 0 }, /* (194) set_quantifier_opt ::= */ + { 199, -1 }, /* (195) set_quantifier_opt ::= DISTINCT */ + { 199, -1 }, /* (196) set_quantifier_opt ::= ALL */ + { 200, -1 }, /* (197) select_list ::= NK_STAR */ + { 200, -1 }, /* (198) select_list ::= select_sublist */ + { 206, -1 }, /* (199) select_sublist ::= select_item */ + { 206, -3 }, /* (200) select_sublist ::= select_sublist NK_COMMA select_item */ + { 207, -1 }, /* (201) select_item ::= common_expression */ + { 207, -2 }, /* (202) select_item ::= common_expression column_alias */ + { 207, -3 }, /* (203) select_item ::= common_expression AS column_alias */ + { 207, -3 }, /* (204) select_item ::= table_name NK_DOT NK_STAR */ + { 201, 0 }, /* (205) where_clause_opt ::= */ + { 201, -2 }, /* (206) where_clause_opt ::= WHERE search_condition */ + { 202, 0 }, /* (207) partition_by_clause_opt ::= */ + { 202, -3 }, /* (208) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 203, 0 }, /* (209) twindow_clause_opt ::= */ + { 203, -6 }, /* (210) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 203, -4 }, /* (211) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 203, -6 }, /* (212) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 203, -8 }, /* (213) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 170, 0 }, /* (214) sliding_opt ::= */ + { 170, -4 }, /* (215) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 208, 0 }, /* (216) fill_opt ::= */ + { 208, -4 }, /* (217) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 208, -6 }, /* (218) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 209, -1 }, /* (219) fill_mode ::= NONE */ + { 209, -1 }, /* (220) fill_mode ::= PREV */ + { 209, -1 }, /* (221) fill_mode ::= NULL */ + { 209, -1 }, /* (222) fill_mode ::= LINEAR */ + { 209, -1 }, /* (223) fill_mode ::= NEXT */ + { 204, 0 }, /* (224) group_by_clause_opt ::= */ + { 204, -3 }, /* (225) group_by_clause_opt ::= GROUP BY group_by_list */ + { 210, -1 }, /* (226) group_by_list ::= expression */ + { 210, -3 }, /* (227) group_by_list ::= group_by_list NK_COMMA expression */ + { 205, 0 }, /* (228) having_clause_opt ::= */ + { 205, -2 }, /* (229) having_clause_opt ::= HAVING search_condition */ + { 175, -4 }, /* (230) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 211, -1 }, /* (231) query_expression_body ::= query_primary */ + { 211, -4 }, /* (232) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 215, -1 }, /* (233) query_primary ::= query_specification */ + { 212, 0 }, /* (234) order_by_clause_opt ::= */ + { 212, -3 }, /* (235) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 213, 0 }, /* (236) slimit_clause_opt ::= */ + { 213, -2 }, /* (237) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 213, -4 }, /* (238) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 213, -4 }, /* (239) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 214, 0 }, /* (240) limit_clause_opt ::= */ + { 214, -2 }, /* (241) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 214, -4 }, /* (242) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 214, -4 }, /* (243) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 181, -3 }, /* (244) subquery ::= NK_LP query_expression NK_RP */ + { 197, -1 }, /* (245) search_condition ::= common_expression */ + { 216, -1 }, /* (246) sort_specification_list ::= sort_specification */ + { 216, -3 }, /* (247) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 217, -3 }, /* (248) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 218, 0 }, /* (249) ordering_specification_opt ::= */ + { 218, -1 }, /* (250) ordering_specification_opt ::= ASC */ + { 218, -1 }, /* (251) ordering_specification_opt ::= DESC */ + { 219, 0 }, /* (252) null_ordering_opt ::= */ + { 219, -2 }, /* (253) null_ordering_opt ::= NULLS FIRST */ + { 219, -2 }, /* (254) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1959,31 +1991,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1991,742 +2023,761 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 117: /* db_name ::= NK_ID */ yytestcase(yyruleno==117); - case 118: /* table_name ::= NK_ID */ yytestcase(yyruleno==118); - case 119: /* column_name ::= NK_ID */ yytestcase(yyruleno==119); - case 120: /* function_name ::= NK_ID */ yytestcase(yyruleno==120); - case 121: /* table_alias ::= NK_ID */ yytestcase(yyruleno==121); - case 122: /* column_alias ::= NK_ID */ yytestcase(yyruleno==122); - case 123: /* user_name ::= NK_ID */ yytestcase(yyruleno==123); - case 124: /* index_name ::= NK_ID */ yytestcase(yyruleno==124); -{ yylhsminor.yy5 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 123: /* db_name ::= NK_ID */ yytestcase(yyruleno==123); + case 124: /* table_name ::= NK_ID */ yytestcase(yyruleno==124); + case 125: /* column_name ::= NK_ID */ yytestcase(yyruleno==125); + case 126: /* function_name ::= NK_ID */ yytestcase(yyruleno==126); + case 127: /* table_alias ::= NK_ID */ yytestcase(yyruleno==127); + case 128: /* column_alias ::= NK_ID */ yytestcase(yyruleno==128); + case 129: /* user_name ::= NK_ID */ yytestcase(yyruleno==129); + case 130: /* index_name ::= NK_ID */ yytestcase(yyruleno==130); + case 131: /* topic_name ::= NK_ID */ yytestcase(yyruleno==131); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= SHOW QNODES */ + case 14: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +{ pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } + break; + case 15: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 15: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy25, &yymsp[-1].minor.yy5, yymsp[0].minor.yy68);} + case 16: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 16: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy25, &yymsp[0].minor.yy5); } + case 17: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } break; - case 17: /* cmd ::= SHOW DATABASES */ + case 18: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 18: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5);} + case 19: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 19: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy25 = true; } + case 20: /* cmd ::= ALTER DATABASE db_name db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 20: /* not_exists_opt ::= */ - case 22: /* exists_opt ::= */ yytestcase(yyruleno==22); - case 187: /* set_quantifier_opt ::= */ yytestcase(yyruleno==187); -{ yymsp[1].minor.yy25 = false; } + case 21: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy97 = true; } break; - case 21: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy25 = true; } + case 22: /* not_exists_opt ::= */ + case 24: /* exists_opt ::= */ yytestcase(yyruleno==24); + case 194: /* set_quantifier_opt ::= */ yytestcase(yyruleno==194); +{ yymsp[1].minor.yy97 = false; } break; - case 23: /* db_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultDatabaseOptions(pCxt); } + case 23: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy97 = true; } break; - case 24: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 25: /* db_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultDatabaseOptions(pCxt); } break; - case 25: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 26: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 26: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 27: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 27: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 28: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 28: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 29: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 29: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 30: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 30: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 31: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 31: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 32: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 32: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 33: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 33: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 34: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 34: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 35: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 35: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 36: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 36: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 37: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 37: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 38: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 38: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 39: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 39: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 40: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 40: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 41: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 41: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 43: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==43); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy25, yymsp[-5].minor.yy68, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy68);} + case 42: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 42: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40);} + case 43: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 45: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==45); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy432, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy432);} break; - case 44: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } + case 44: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24);} break; - case 45: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } + case 46: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } break; - case 46: /* cmd ::= SHOW TABLES */ + case 47: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + break; + case 48: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 47: /* cmd ::= SHOW STABLES */ + case 49: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 48: /* multi_create_clause ::= create_subtable_clause */ - case 51: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==51); - case 58: /* column_def_list ::= column_def */ yytestcase(yyruleno==58); - case 93: /* col_name_list ::= col_name */ yytestcase(yyruleno==93); - case 101: /* func_list ::= func */ yytestcase(yyruleno==101); - case 192: /* select_sublist ::= select_item */ yytestcase(yyruleno==192); - case 239: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==239); -{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 50: /* multi_create_clause ::= create_subtable_clause */ + case 53: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==53); + case 60: /* column_def_list ::= column_def */ yytestcase(yyruleno==60); + case 95: /* col_name_list ::= col_name */ yytestcase(yyruleno==95); + case 104: /* func_list ::= func */ yytestcase(yyruleno==104); + case 199: /* select_sublist ::= select_item */ yytestcase(yyruleno==199); + case 246: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==246); +{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 49: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 52: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==52); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy40 = yylhsminor.yy40; + case 51: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 54: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==54); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 50: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy68 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy25, yymsp[-7].minor.yy68, yymsp[-5].minor.yy68, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } - yymsp[-8].minor.yy68 = yylhsminor.yy68; + case 52: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy432 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy97, yymsp[-7].minor.yy432, yymsp[-5].minor.yy432, yymsp[-4].minor.yy24, yymsp[-1].minor.yy24); } + yymsp[-8].minor.yy432 = yylhsminor.yy432; break; - case 53: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy68 = createDropTableClause(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 55: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy432 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 54: /* specific_tags_opt ::= */ - case 85: /* tags_def_opt ::= */ yytestcase(yyruleno==85); - case 200: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==200); - case 217: /* group_by_clause_opt ::= */ yytestcase(yyruleno==217); - case 227: /* order_by_clause_opt ::= */ yytestcase(yyruleno==227); -{ yymsp[1].minor.yy40 = NULL; } + case 56: /* specific_tags_opt ::= */ + case 87: /* tags_def_opt ::= */ yytestcase(yyruleno==87); + case 207: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==207); + case 224: /* group_by_clause_opt ::= */ yytestcase(yyruleno==224); + case 234: /* order_by_clause_opt ::= */ yytestcase(yyruleno==234); +{ yymsp[1].minor.yy24 = NULL; } break; - case 55: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } + case 57: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 56: /* full_table_name ::= table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 58: /* full_table_name ::= table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 57: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 59: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 59: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 94: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==94); - case 102: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==102); - case 193: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==193); - case 240: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==240); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 61: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 96: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==96); + case 105: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==105); + case 200: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==200); + case 247: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==247); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 60: /* column_def ::= column_name type_name */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy372, NULL); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 62: /* column_def ::= column_name type_name */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy224, NULL); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 61: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy372, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 63: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy224, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 62: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 64: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 63: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 65: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 64: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 66: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 65: /* type_name ::= INT */ - case 66: /* type_name ::= INTEGER */ yytestcase(yyruleno==66); -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_INT); } + case 67: /* type_name ::= INT */ + case 68: /* type_name ::= INTEGER */ yytestcase(yyruleno==68); +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 67: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 69: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 68: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 70: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 69: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 71: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 70: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 72: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 71: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 73: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 72: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 74: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 73: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 75: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 74: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 76: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 75: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UINT); } + case 77: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 76: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 78: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 77: /* type_name ::= JSON */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_JSON); } + case 79: /* type_name ::= JSON */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 78: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 80: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 79: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 81: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 80: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 82: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 81: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 83: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 82: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 84: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 83: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 85: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 84: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 86: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 86: /* tags_def_opt ::= tags_def */ - case 191: /* select_list ::= select_sublist */ yytestcase(yyruleno==191); -{ yylhsminor.yy40 = yymsp[0].minor.yy40; } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 88: /* tags_def_opt ::= tags_def */ + case 198: /* select_list ::= select_sublist */ yytestcase(yyruleno==198); +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 87: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } + case 89: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 88: /* table_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultTableOptions(pCxt);} + case 90: /* table_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultTableOptions(pCxt);} break; - case 89: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 91: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 90: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 92: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 91: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 93: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 92: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy68 = setTableSmaOption(pCxt, yymsp[-4].minor.yy68, yymsp[-1].minor.yy40); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + case 94: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy432 = setTableSmaOption(pCxt, yymsp[-4].minor.yy432, yymsp[-1].minor.yy24); } + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 95: /* col_name ::= column_name */ -{ yylhsminor.yy68 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 97: /* col_name ::= column_name */ +{ yylhsminor.yy432 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 96: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy68); } + case 98: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy432); } break; - case 97: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40, NULL); } + case 99: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24, NULL); } break; - case 98: /* index_options ::= */ - case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); - case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); - case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); - case 209: /* fill_opt ::= */ yytestcase(yyruleno==209); - case 221: /* having_clause_opt ::= */ yytestcase(yyruleno==221); - case 229: /* slimit_clause_opt ::= */ yytestcase(yyruleno==229); - case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); -{ yymsp[1].minor.yy68 = NULL; } + case 100: /* cmd ::= DROP INDEX index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; - case 99: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy68 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL, yymsp[0].minor.yy68); } + case 101: /* index_options ::= */ + case 205: /* where_clause_opt ::= */ yytestcase(yyruleno==205); + case 209: /* twindow_clause_opt ::= */ yytestcase(yyruleno==209); + case 214: /* sliding_opt ::= */ yytestcase(yyruleno==214); + case 216: /* fill_opt ::= */ yytestcase(yyruleno==216); + case 228: /* having_clause_opt ::= */ yytestcase(yyruleno==228); + case 236: /* slimit_clause_opt ::= */ yytestcase(yyruleno==236); + case 240: /* limit_clause_opt ::= */ yytestcase(yyruleno==240); +{ yymsp[1].minor.yy432 = NULL; } break; - case 100: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy68 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[0].minor.yy68); } + case 102: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy432 = createIndexOption(pCxt, yymsp[-6].minor.yy24, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL, yymsp[0].minor.yy432); } break; - case 103: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 103: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy432 = createIndexOption(pCxt, yymsp[-8].minor.yy24, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[0].minor.yy432); } break; - case 104: /* cmd ::= SHOW VGROUPS */ + case 106: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; + break; + case 107: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, yymsp[0].minor.yy432, NULL); } + break; + case 108: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, NULL, &yymsp[0].minor.yy129); } + break; + case 109: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } + break; + case 110: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 105: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy5); } + case 111: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } break; - case 106: /* cmd ::= SHOW MNODES */ + case 112: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 107: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy68; } + case 113: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy432; } break; - case 108: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 114: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 109: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 115: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 110: /* literal ::= NK_STRING */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 116: /* literal ::= NK_STRING */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 111: /* literal ::= NK_BOOL */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 117: /* literal ::= NK_BOOL */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 112: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 118: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 113: /* literal ::= duration_literal */ - case 125: /* expression ::= literal */ yytestcase(yyruleno==125); - case 126: /* expression ::= column_reference */ yytestcase(yyruleno==126); - case 129: /* expression ::= subquery */ yytestcase(yyruleno==129); - case 161: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==161); - case 165: /* boolean_primary ::= predicate */ yytestcase(yyruleno==165); - case 167: /* common_expression ::= expression */ yytestcase(yyruleno==167); - case 168: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==168); - case 170: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==170); - case 172: /* table_reference ::= table_primary */ yytestcase(yyruleno==172); - case 173: /* table_reference ::= joined_table */ yytestcase(yyruleno==173); - case 177: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==177); - case 224: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==224); - case 226: /* query_primary ::= query_specification */ yytestcase(yyruleno==226); -{ yylhsminor.yy68 = yymsp[0].minor.yy68; } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 119: /* literal ::= duration_literal */ + case 132: /* expression ::= literal */ yytestcase(yyruleno==132); + case 133: /* expression ::= column_reference */ yytestcase(yyruleno==133); + case 136: /* expression ::= subquery */ yytestcase(yyruleno==136); + case 168: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==168); + case 172: /* boolean_primary ::= predicate */ yytestcase(yyruleno==172); + case 174: /* common_expression ::= expression */ yytestcase(yyruleno==174); + case 175: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==175); + case 177: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==177); + case 179: /* table_reference ::= table_primary */ yytestcase(yyruleno==179); + case 180: /* table_reference ::= joined_table */ yytestcase(yyruleno==180); + case 184: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==184); + case 231: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==231); + case 233: /* query_primary ::= query_specification */ yytestcase(yyruleno==233); +{ yylhsminor.yy432 = yymsp[0].minor.yy432; } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 114: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 120: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 115: /* literal_list ::= literal */ - case 138: /* expression_list ::= expression */ yytestcase(yyruleno==138); -{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 121: /* literal_list ::= literal */ + case 145: /* expression_list ::= expression */ yytestcase(yyruleno==145); +{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 116: /* literal_list ::= literal_list NK_COMMA literal */ - case 139: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==139); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 122: /* literal_list ::= literal_list NK_COMMA literal */ + case 146: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==146); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 127: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 134: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24)); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 128: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 135: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 130: /* expression ::= NK_LP expression NK_RP */ - case 166: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==166); -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 137: /* expression ::= NK_LP expression NK_RP */ + case 173: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==173); +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 131: /* expression ::= NK_PLUS expression */ + case 138: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 132: /* expression ::= NK_MINUS expression */ + case 139: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 133: /* expression ::= expression NK_PLUS expression */ + case 140: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 134: /* expression ::= expression NK_MINUS expression */ + case 141: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 135: /* expression ::= expression NK_STAR expression */ + case 142: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 136: /* expression ::= expression NK_SLASH expression */ + case 143: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 137: /* expression ::= expression NK_REM expression */ + case 144: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 140: /* column_reference ::= column_name */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 147: /* column_reference ::= column_name */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 141: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 148: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 142: /* predicate ::= expression compare_op expression */ - case 147: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==147); + case 149: /* predicate ::= expression compare_op expression */ + case 154: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==154); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy260, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 143: /* predicate ::= expression BETWEEN expression AND expression */ + case 150: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 144: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 151: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 145: /* predicate ::= expression IS NULL */ + case 152: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 146: /* predicate ::= expression IS NOT NULL */ + case 153: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 148: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } + case 155: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_THAN; } break; - case 149: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } + case 156: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_THAN; } break; - case 150: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } + case 157: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_EQUAL; } break; - case 151: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } + case 158: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_EQUAL; } break; - case 152: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } + case 159: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy260 = OP_TYPE_NOT_EQUAL; } break; - case 153: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } + case 160: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy260 = OP_TYPE_EQUAL; } break; - case 154: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } + case 161: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LIKE; } break; - case 155: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } + case 162: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_LIKE; } break; - case 156: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } + case 163: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_MATCH; } break; - case 157: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } + case 164: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_NMATCH; } break; - case 158: /* in_op ::= IN */ -{ yymsp[0].minor.yy416 = OP_TYPE_IN; } + case 165: /* in_op ::= IN */ +{ yymsp[0].minor.yy260 = OP_TYPE_IN; } break; - case 159: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } + case 166: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_IN; } break; - case 160: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 167: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 162: /* boolean_value_expression ::= NOT boolean_primary */ + case 169: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 163: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 170: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 164: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 171: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 169: /* from_clause ::= FROM table_reference_list */ - case 199: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==199); - case 222: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==222); -{ yymsp[-1].minor.yy68 = yymsp[0].minor.yy68; } + case 176: /* from_clause ::= FROM table_reference_list */ + case 206: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==206); + case 229: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==229); +{ yymsp[-1].minor.yy432 = yymsp[0].minor.yy432; } break; - case 171: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy68, yymsp[0].minor.yy68, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 178: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy432, yymsp[0].minor.yy432, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 174: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 181: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 175: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 182: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 176: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy68 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 183: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy432 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 178: /* alias_opt ::= */ -{ yymsp[1].minor.yy5 = nil_token; } + case 185: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 179: /* alias_opt ::= table_alias */ -{ yylhsminor.yy5 = yymsp[0].minor.yy5; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 186: /* alias_opt ::= table_alias */ +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; - case 180: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } + case 187: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 181: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 182: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==182); -{ yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68; } + case 188: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 189: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==189); +{ yymsp[-2].minor.yy432 = yymsp[-1].minor.yy432; } break; - case 183: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, yymsp[-4].minor.yy92, yymsp[-5].minor.yy68, yymsp[-2].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + case 190: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, yymsp[-4].minor.yy332, yymsp[-5].minor.yy432, yymsp[-2].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 184: /* join_type ::= */ -{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } + case 191: /* join_type ::= */ +{ yymsp[1].minor.yy332 = JOIN_TYPE_INNER; } break; - case 185: /* join_type ::= INNER */ -{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } + case 192: /* join_type ::= INNER */ +{ yymsp[0].minor.yy332 = JOIN_TYPE_INNER; } break; - case 186: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 193: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy68 = createSelectStmt(pCxt, yymsp[-7].minor.yy25, yymsp[-6].minor.yy40, yymsp[-5].minor.yy68); - yymsp[-8].minor.yy68 = addWhereClause(pCxt, yymsp[-8].minor.yy68, yymsp[-4].minor.yy68); - yymsp[-8].minor.yy68 = addPartitionByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-3].minor.yy40); - yymsp[-8].minor.yy68 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy68, yymsp[-2].minor.yy68); - yymsp[-8].minor.yy68 = addGroupByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-1].minor.yy40); - yymsp[-8].minor.yy68 = addHavingClause(pCxt, yymsp[-8].minor.yy68, yymsp[0].minor.yy68); + yymsp[-8].minor.yy432 = createSelectStmt(pCxt, yymsp[-7].minor.yy97, yymsp[-6].minor.yy24, yymsp[-5].minor.yy432); + yymsp[-8].minor.yy432 = addWhereClause(pCxt, yymsp[-8].minor.yy432, yymsp[-4].minor.yy432); + yymsp[-8].minor.yy432 = addPartitionByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-3].minor.yy24); + yymsp[-8].minor.yy432 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy432, yymsp[-2].minor.yy432); + yymsp[-8].minor.yy432 = addGroupByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-1].minor.yy24); + yymsp[-8].minor.yy432 = addHavingClause(pCxt, yymsp[-8].minor.yy432, yymsp[0].minor.yy432); } break; - case 188: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy25 = true; } + case 195: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy97 = true; } break; - case 189: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy25 = false; } + case 196: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy97 = false; } break; - case 190: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy40 = NULL; } + case 197: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy24 = NULL; } break; - case 194: /* select_item ::= common_expression */ + case 201: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), &t); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 195: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 202: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 196: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 203: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 197: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy68 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 204: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy432 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 201: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 218: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==218); - case 228: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==228); -{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } + case 208: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 225: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==225); + case 235: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==235); +{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } break; - case 203: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy68 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), &yymsp[-1].minor.yy0); } + case 210: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy432 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), &yymsp[-1].minor.yy0); } break; - case 204: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy68 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } + case 211: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy432 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } break; - case 205: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL, yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 212: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL, yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 206: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 213: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 208: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy68 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy68); } + case 215: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy432 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy432); } break; - case 210: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy68 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } + case 217: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy432 = createFillNode(pCxt, yymsp[-1].minor.yy294, NULL); } break; - case 211: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy68 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + case 218: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy432 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 212: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } + case 219: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy294 = FILL_MODE_NONE; } break; - case 213: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } + case 220: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy294 = FILL_MODE_PREV; } break; - case 214: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } + case 221: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy294 = FILL_MODE_NULL; } break; - case 215: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } + case 222: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy294 = FILL_MODE_LINEAR; } break; - case 216: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } + case 223: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy294 = FILL_MODE_NEXT; } break; - case 219: /* group_by_list ::= expression */ -{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 226: /* group_by_list ::= expression */ +{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 220: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 227: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 223: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 230: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy68 = addOrderByClause(pCxt, yymsp[-3].minor.yy68, yymsp[-2].minor.yy40); - yylhsminor.yy68 = addSlimitClause(pCxt, yylhsminor.yy68, yymsp[-1].minor.yy68); - yylhsminor.yy68 = addLimitClause(pCxt, yylhsminor.yy68, yymsp[0].minor.yy68); + yylhsminor.yy432 = addOrderByClause(pCxt, yymsp[-3].minor.yy432, yymsp[-2].minor.yy24); + yylhsminor.yy432 = addSlimitClause(pCxt, yylhsminor.yy432, yymsp[-1].minor.yy432); + yylhsminor.yy432 = addLimitClause(pCxt, yylhsminor.yy432, yymsp[0].minor.yy432); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 225: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy68 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 232: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy432 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==234); -{ yymsp[-1].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 237: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 241: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==241); +{ yymsp[-1].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 231: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 235: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==235); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 238: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 242: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==242); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 232: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 236: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==236); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 239: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 243: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==243); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 237: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy68); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 244: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy432); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 238: /* search_condition ::= common_expression */ -{ yylhsminor.yy68 = releaseRawExprNode(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 245: /* search_condition ::= common_expression */ +{ yylhsminor.yy432 = releaseRawExprNode(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 241: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy68 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[-1].minor.yy54, yymsp[0].minor.yy53); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 248: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy432 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[-1].minor.yy378, yymsp[0].minor.yy257); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 242: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy54 = ORDER_ASC; } + case 249: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy378 = ORDER_ASC; } break; - case 243: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy54 = ORDER_ASC; } + case 250: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy378 = ORDER_ASC; } break; - case 244: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy54 = ORDER_DESC; } + case 251: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy378 = ORDER_DESC; } break; - case 245: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy53 = NULL_ORDER_DEFAULT; } + case 252: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy257 = NULL_ORDER_DEFAULT; } break; - case 246: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_FIRST; } + case 253: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_FIRST; } break; - case 247: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_LAST; } + case 254: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 259c4712ba..f4c1bde478 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -340,6 +340,23 @@ TEST_F(ParserTest, createDatabase) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, alterDatabase) { + setDatabase("root", "test"); + + bind("alter database wxy_db BLOCKS 200"); + ASSERT_TRUE(run()); + + bind("alter database wxy_db " + "BLOCKS 200 " + "CACHELAST 1 " + "FSYNC 200 " + "KEEP 200 " + "QUORUM 2 " + "WAL 1 " + ); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, showDatabase) { setDatabase("root", "test"); @@ -406,9 +423,49 @@ TEST_F(ParserTest, createSmaIndex) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, dropIndex) { + setDatabase("root", "test"); + + bind("drop index index1 on t1"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, createQnode) { setDatabase("root", "test"); bind("create qnode on dnode 1"); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, dropQnode) { + setDatabase("root", "test"); + + bind("drop qnode on dnode 1"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, createTopic) { + setDatabase("root", "test"); + + bind("create topic tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic tp1 as test"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as test"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, dropTopic) { + setDatabase("root", "test"); + + bind("drop topic tp1"); + ASSERT_TRUE(run()); + + bind("drop topic if exists tp1"); + ASSERT_TRUE(run()); +} From 4046173c48d05f3a6f849ef5443dacb6a7cbc7b9 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Wed, 16 Mar 2022 14:17:03 +0800 Subject: [PATCH 06/60] [add interval case] --- tests/script/tsim/query/interval.sim | 207 +++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 tests/script/tsim/query/interval.sim diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim new file mode 100644 index 0000000000..35e7c938d8 --- /dev/null +++ b/tests/script/tsim/query/interval.sim @@ -0,0 +1,207 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wal -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +print ====== start create child tables and insert data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 5967a4dff8c36f0754352758c900587e0c6e4c36 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:53:25 -0400 Subject: [PATCH 07/60] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- source/dnode/mnode/impl/src/mndTopic.c | 17 +++++++++++++++-- source/dnode/mnode/impl/test/topic/topic.cpp | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 32fa3df910..e913cae1ac 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -237,6 +237,10 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { } static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + if (NULL == pCreate->ast) { + return TSDB_CODE_SUCCESS; + } + SNode* pAst = NULL; int32_t code = nodesStringToNode(pCreate->ast, &pAst); @@ -266,17 +270,23 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.logicalPlan = NULL; + topicObj.physicalPlan = ""; + topicObj.logicalPlan = ""; topicObj.sqlLen = strlen(pCreate->sql); - if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + char* pPlanStr = NULL; + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) { mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); return -1; } + if (NULL != pPlanStr) { + topicObj.physicalPlan = pPlanStr; + } STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + tfree(pPlanStr); return -1; } mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name); @@ -284,6 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj); if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } @@ -291,10 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } + tfree(pPlanStr); mndTransDrop(pTrans); return 0; } diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 79f353a4d6..73eefd875d 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,7 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.ast = (char*)"ast"; + createReq.ast = NULL; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); From f7cd75544c3247a54de75bd8e5a6bf7b5bfa0bf2 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:09:56 +0800 Subject: [PATCH 08/60] sync raft store --- source/libs/sync/inc/syncIO.h | 6 +- source/libs/sync/inc/syncRaftStore.h | 15 +-- source/libs/sync/src/syncElection.c | 3 +- source/libs/sync/src/syncIO.c | 6 +- source/libs/sync/src/syncIndexMgr.c | 2 +- source/libs/sync/src/syncMain.c | 9 ++ source/libs/sync/src/syncRaftStore.c | 36 ++++-- source/libs/sync/src/syncVoteMgr.c | 4 +- source/libs/sync/test/CMakeLists.txt | 19 +++ source/libs/sync/test/syncElectTest.cpp | 121 ++++++++++++++++++++ source/libs/sync/test/syncRaftStoreTest.cpp | 56 ++++++--- 11 files changed, 239 insertions(+), 38 deletions(-) create mode 100644 source/libs/sync/test/syncElectTest.cpp diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index 09e93fda1c..5a4b7555bf 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -34,11 +34,11 @@ extern "C" { typedef struct SSyncIO { STaosQueue *pMsgQ; - STaosQset *pQset; + STaosQset * pQset; pthread_t consumerTid; - void *serverRpc; - void *clientRpc; + void * serverRpc; + void * clientRpc; SEpSet myAddr; tmr_h qTimer; diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index 62bb94c834..355a08ac84 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -43,13 +43,14 @@ int32_t raftStorePersist(SRaftStore *pRaftStore); int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len); int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len); -bool raftStoreHasVoted(SRaftStore *pRaftStore); -void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); -void raftStoreClearVote(SRaftStore *pRaftStore); -void raftStoreNextTerm(SRaftStore *pRaftStore); -void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); -cJSON *raftStore2Json(SRaftStore *pRaftStore); -char *raftStore2Str(SRaftStore *pRaftStore); +bool raftStoreHasVoted(SRaftStore *pRaftStore); +void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); +void raftStoreClearVote(SRaftStore *pRaftStore); +void raftStoreNextTerm(SRaftStore *pRaftStore); +void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson); +cJSON * raftStore2Json(SRaftStore *pRaftStore); +char * raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 77c3d07698..12e20ef762 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -50,6 +50,7 @@ int32_t syncNodeRequestVotePeers(SSyncNode* pSyncNode) { } int32_t syncNodeElect(SSyncNode* pSyncNode) { + int32_t ret = 0; if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { syncNodeFollower2Candidate(pSyncNode); } @@ -62,7 +63,7 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { votesRespondReset(pSyncNode->pVotesRespond, pSyncNode->pRaftStore->currentTerm); syncNodeVoteForSelf(pSyncNode); - int32_t ret = syncNodeRequestVotePeers(pSyncNode); + ret = syncNodeRequestVotePeers(pSyncNode); assert(ret == 0); syncNodeResetElectTimer(pSyncNode); diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index 8176ac417a..e6a43f2bb5 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void *syncIOConsumerFunc(void *param); +static void * syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO *io = param; + SSyncIO * io = param; STaosQall *qall; - SRpcMsg *pRpcMsg, rpcMsg; + SRpcMsg * pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 58a61ba77e..aa97104180 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -96,7 +96,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pJson = syncIndexMgr2Json(pSyncIndexMgr); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 48a57dc0fb..58710d7d1f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -103,6 +103,12 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { assert(pSyncNode != NULL); memset(pSyncNode, 0, sizeof(SSyncNode)); + if (taosMkDir(pSyncInfo->path) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("failed to create dir:%s since %s", pSyncInfo->path, terrstr()); + return NULL; + } + // init by SSyncInfo pSyncNode->vgId = pSyncInfo->vgId; pSyncNode->syncCfg = pSyncInfo->syncCfg; @@ -200,6 +206,9 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { pSyncNode->FpOnAppendEntriesReply = syncNodeOnAppendEntriesReplyCb; pSyncNode->FpOnTimeout = syncNodeOnTimeoutCb; + // start raft + syncNodeBecomeFollower(pSyncNode); + return pSyncNode; } diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 9a5401e3f1..bb0eab0fdc 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -97,16 +97,32 @@ int32_t raftStorePersist(SRaftStore *pRaftStore) { return 0; } -static bool raftStoreFileExist(char *path) { return taosStatFile(path, NULL, NULL) >= 0; } +static bool raftStoreFileExist(char *path) { + bool b = taosStatFile(path, NULL, NULL) >= 0; + return b; +} int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) { assert(pRaftStore != NULL); cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "current_term", pRaftStore->currentTerm); - cJSON_AddNumberToObject(pRoot, "vote_for_addr", pRaftStore->voteFor.addr); + + char u64Buf[128]; + snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->currentTerm); + cJSON_AddStringToObject(pRoot, "current_term", u64Buf); + + snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->voteFor.addr); + cJSON_AddStringToObject(pRoot, "vote_for_addr", u64Buf); + cJSON_AddNumberToObject(pRoot, "vote_for_vgid", pRaftStore->voteFor.vgId); + uint64_t u64 = pRaftStore->voteFor.addr; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pRoot, "addr_host", host); + cJSON_AddNumberToObject(pRoot, "addr_port", port); + char *serialized = cJSON_Print(pRoot); int len2 = strlen(serialized); assert(len2 < len); @@ -125,10 +141,12 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len) { cJSON *pRoot = cJSON_Parse(buf); cJSON *pCurrentTerm = cJSON_GetObjectItem(pRoot, "current_term"); - pRaftStore->currentTerm = pCurrentTerm->valueint; + assert(cJSON_IsString(pCurrentTerm)); + sscanf(pCurrentTerm->valuestring, "%lu", &(pRaftStore->currentTerm)); cJSON *pVoteForAddr = cJSON_GetObjectItem(pRoot, "vote_for_addr"); - pRaftStore->voteFor.addr = pVoteForAddr->valueint; + assert(cJSON_IsString(pVoteForAddr)); + sscanf(pVoteForAddr->valuestring, "%lu", &(pRaftStore->voteFor.addr)); cJSON *pVoteForVgid = cJSON_GetObjectItem(pRoot, "vote_for_vgid"); pRaftStore->voteFor.vgId = pVoteForVgid->valueint; @@ -139,11 +157,10 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len) { bool raftStoreHasVoted(SRaftStore *pRaftStore) { bool b = syncUtilEmptyId(&(pRaftStore->voteFor)); - return b; + return (!b); } void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId) { - assert(!raftStoreHasVoted(pRaftStore)); assert(!syncUtilEmptyId(pRaftId)); pRaftStore->voteFor = *pRaftId; raftStorePersist(pRaftStore); @@ -164,6 +181,8 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) { raftStorePersist(pRaftStore); } +int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson) { return 0; } + cJSON *raftStore2Json(SRaftStore *pRaftStore) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); @@ -185,6 +204,9 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { } cJSON_AddNumberToObject(pVoteFor, "vgId", pRaftStore->voteFor.vgId); cJSON_AddItemToObject(pRoot, "voteFor", pVoteFor); + + int hasVoted = raftStoreHasVoted(pRaftStore); + cJSON_AddNumberToObject(pRoot, "hasVoted", hasVoted); } cJSON *pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5830a0a54f..00851a7b4f 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -116,7 +116,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -238,7 +238,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index b542f55ec3..2583deb32f 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -27,6 +27,7 @@ add_executable(syncPingReplyTest "") add_executable(syncRpcMsgTest "") add_executable(syncPingTimerTest2 "") add_executable(syncPingSelfTest "") +add_executable(syncElectTest "") target_sources(syncTest @@ -145,6 +146,10 @@ target_sources(syncPingSelfTest PRIVATE "syncPingSelfTest.cpp" ) +target_sources(syncElectTest + PRIVATE + "syncElectTest.cpp" +) target_include_directories(syncTest @@ -292,6 +297,16 @@ target_include_directories(syncPingSelfTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncElectTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(syncElectTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -410,6 +425,10 @@ target_link_libraries(syncPingSelfTest sync gtest_main ) +target_link_libraries(syncElectTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp new file mode 100644 index 0000000000..e52fe61ef5 --- /dev/null +++ b/source/libs/sync/test/syncElectTest.cpp @@ -0,0 +1,121 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 1; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; +SWal* pWal; +SSyncNode* gSyncNode; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./elect_test"); + + int code = walInit(); + assert(code == 0); + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = syncInfo.vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + pWal = walOpen("./elect_test_wal", &walCfg); + assert(pWal != NULL); + + syncInfo.pWal = pWal; + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + gSyncNode = syncInitTest(); + assert(gSyncNode != NULL); + syncNodePrint2((char*)"", gSyncNode); + + initRaftId(gSyncNode); + + //--------------------------- + while (1) { + sTrace("while 1 sleep, state: %d, %s", gSyncNode->state, syncUtilState2String(gSyncNode->state)); + taosMsleep(1000); + } + + return 0; +} diff --git a/source/libs/sync/test/syncRaftStoreTest.cpp b/source/libs/sync/test/syncRaftStoreTest.cpp index 0c1c9b881e..688802625a 100644 --- a/source/libs/sync/test/syncRaftStoreTest.cpp +++ b/source/libs/sync/test/syncRaftStoreTest.cpp @@ -3,6 +3,7 @@ #include #include "syncIO.h" #include "syncInt.h" +#include "syncUtil.h" void logTest() { sTrace("--- sync log test: trace"); @@ -13,6 +14,21 @@ void logTest() { sFatal("--- sync log test: fatal"); } +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 5; +int32_t myIndex = 0; +SRaftId ids[TSDB_MAX_REPLICA]; + +void initRaftId() { + for (int i = 0; i < replicaNum; ++i) { + ids[i].addr = syncUtilAddr2U64("127.0.0.1", ports[i]); + ids[i].vgId = 1234; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + int main() { // taosInitLog((char *)"syncTest.log", 100000, 10); tsAsyncLog = 0; @@ -20,23 +36,35 @@ int main() { logTest(); - SRaftStore *pRaftStore = raftStoreOpen("./raft_store.json"); + initRaftId(); + + SRaftStore* pRaftStore = raftStoreOpen("./test_raft_store.json"); assert(pRaftStore != NULL); - raftStorePrint(pRaftStore); + raftStorePrint2((char*)"==raftStoreOpen==", pRaftStore); -#if 0 - pRaftStore->currentTerm = 100; - pRaftStore->voteFor.addr = 200; - pRaftStore->voteFor.vgId = 300; - raftStorePersist(pRaftStore); - raftStorePrint(pRaftStore); -#endif + raftStoreSetTerm(pRaftStore, 100); + raftStorePrint2((char*)"==raftStoreSetTerm==", pRaftStore); - ++(pRaftStore->currentTerm); - ++(pRaftStore->voteFor.addr); - ++(pRaftStore->voteFor.vgId); - raftStorePersist(pRaftStore); - raftStorePrint(pRaftStore); + raftStoreVote(pRaftStore, &ids[0]); + raftStorePrint2((char*)"==raftStoreVote==", pRaftStore); + + raftStoreClearVote(pRaftStore); + raftStorePrint2((char*)"==raftStoreClearVote==", pRaftStore); + + raftStoreVote(pRaftStore, &ids[1]); + raftStorePrint2((char*)"==raftStoreVote==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); return 0; } From 90478b87421a09e1c20e4228ebe1ace8c00fb5dc Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:24:11 +0800 Subject: [PATCH 09/60] sync refactor --- source/libs/sync/inc/syncEnv.h | 6 +++--- source/libs/sync/src/syncElection.c | 8 ++++++++ source/libs/sync/src/syncRequestVoteReply.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/libs/sync/inc/syncEnv.h b/source/libs/sync/inc/syncEnv.h index 40ff79287b..66c7c8620d 100644 --- a/source/libs/sync/inc/syncEnv.h +++ b/source/libs/sync/inc/syncEnv.h @@ -31,10 +31,10 @@ extern "C" { #define TIMER_MAX_MS 0x7FFFFFFF #define ENV_TICK_TIMER_MS 1000 #define PING_TIMER_MS 1000 -#define ELECT_TIMER_MS_MIN 150 -#define ELECT_TIMER_MS_MAX 300 +#define ELECT_TIMER_MS_MIN 1500 +#define ELECT_TIMER_MS_MAX 3000 #define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN) -#define HEARTBEAT_TIMER_MS 30 +#define HEARTBEAT_TIMER_MS 300 #define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0}) diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 12e20ef762..6ae70689ef 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -63,6 +63,14 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { votesRespondReset(pSyncNode->pVotesRespond, pSyncNode->pRaftStore->currentTerm); syncNodeVoteForSelf(pSyncNode); + if (voteGrantedMajority(pSyncNode->pVotesGranted)) { + // only myself, to leader + assert(!pSyncNode->pVotesGranted->toLeader); + syncNodeCandidate2Leader(pSyncNode); + pSyncNode->pVotesGranted->toLeader = true; + return ret; + } + ret = syncNodeRequestVotePeers(pSyncNode); assert(ret == 0); syncNodeResetElectTimer(pSyncNode); diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 7cdeace166..802d95076c 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -57,7 +57,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) if (pMsg->voteGranted) { voteGrantedVote(ths->pVotesGranted, pMsg); if (voteGrantedMajority(ths->pVotesGranted)) { - if (ths->pVotesGranted->toLeader) { + if (!ths->pVotesGranted->toLeader) { syncNodeCandidate2Leader(ths); ths->pVotesGranted->toLeader = true; } From acfe73ed18987b145af656ee01c2b5b4da84b1c5 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:47:49 +0800 Subject: [PATCH 10/60] sync refactor --- source/libs/sync/src/syncRequestVote.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index be4f40aaad..062b0244bd 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -56,6 +56,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { bool grant = (pMsg->term == ths->pRaftStore->currentTerm) && logOK && ((!raftStoreHasVoted(ths->pRaftStore)) || (syncUtilSameId(&(ths->pRaftStore->voteFor), &(pMsg->srcId)))); if (grant) { + // maybe has already voted for pMsg->srcId + // vote again, no harm raftStoreVote(ths->pRaftStore, &(pMsg->srcId)); } From b08cdf2f824d5149257df715313b676bd3d39679 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 16:20:01 +0800 Subject: [PATCH 11/60] sync refactor --- source/libs/sync/src/syncMain.c | 22 +++++++++++++++++++-- source/libs/sync/src/syncRaftStore.c | 2 +- source/libs/sync/src/syncRequestVoteReply.c | 13 ++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 58710d7d1f..c146c2fa7a 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -510,15 +510,17 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) { } void syncNodeBecomeFollower(SSyncNode* pSyncNode) { + // maybe clear leader cache if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { pSyncNode->leaderCache = EMPTY_RAFT_ID; } + // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; syncNodeStopHeartbeatTimer(pSyncNode); - int32_t electMS = syncUtilElectRandomMS(); - syncNodeRestartElectTimer(pSyncNode, electMS); + // reset elect timer + syncNodeResetElectTimer(pSyncNode); } // TLA+ Spec @@ -540,19 +542,31 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode) { // /\ UNCHANGED <> // void syncNodeBecomeLeader(SSyncNode* pSyncNode) { + // state change pSyncNode->state = TAOS_SYNC_STATE_LEADER; + + // set leader cache pSyncNode->leaderCache = pSyncNode->myRaftId; for (int i = 0; i < pSyncNode->pNextIndex->replicaNum; ++i) { + // maybe overwrite myself, no harm + // just do it! pSyncNode->pNextIndex->index[i] = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1; } for (int i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) { + // maybe overwrite myself, no harm + // just do it! pSyncNode->pMatchIndex->index[i] = SYNC_INDEX_INVALID; } + // stop elect timer syncNodeStopElectTimer(pSyncNode); + + // start heartbeat timer syncNodeStartHeartbeatTimer(pSyncNode); + + // start replicate right now! syncNodeReplicate(pSyncNode); } @@ -578,6 +592,9 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) { } // raft vote -------------- + +// just called by syncNodeVoteForSelf +// need assert void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) { assert(term == pSyncNode->pRaftStore->currentTerm); assert(!raftStoreHasVoted(pSyncNode->pRaftStore)); @@ -585,6 +602,7 @@ void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) raftStoreVote(pSyncNode->pRaftStore, pRaftId); } +// simulate get vote from outside void syncNodeVoteForSelf(SSyncNode* pSyncNode) { syncNodeVoteForTerm(pSyncNode, pSyncNode->pRaftStore->currentTerm, &(pSyncNode->myRaftId)); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index bb0eab0fdc..3f6db129ce 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -216,7 +216,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { char *raftStore2Str(SRaftStore *pRaftStore) { cJSON *pJson = raftStore2Json(pRaftStore); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 802d95076c..10ea53864f 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -45,6 +45,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) return ret; } + assert(!(pMsg->term > ths->pRaftStore->currentTerm)); // no need this code, because if I receive reply.term, then I must have sent for that term. // if (pMsg->term > ths->pRaftStore->currentTerm) { // syncNodeUpdateTerm(ths, pMsg->term); @@ -52,17 +53,29 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) assert(pMsg->term == ths->pRaftStore->currentTerm); + // This tallies votes even when the current state is not Candidate, + // but they won't be looked at, so it doesn't matter. if (ths->state == TAOS_SYNC_STATE_CANDIDATE) { votesRespondAdd(ths->pVotesRespond, pMsg); if (pMsg->voteGranted) { + // add vote voteGrantedVote(ths->pVotesGranted, pMsg); + + // maybe to leader if (voteGrantedMajority(ths->pVotesGranted)) { if (!ths->pVotesGranted->toLeader) { syncNodeCandidate2Leader(ths); + + // prevent to leader again! ths->pVotesGranted->toLeader = true; } } + } else { + ; + // do nothing + // UNCHANGED <> } } + return ret; } From 5387e4ff7d59fcc9a1030085d48e155831d2baab Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 16:54:55 +0800 Subject: [PATCH 12/60] sync refactor --- source/libs/sync/src/syncReplication.c | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index b935943a1d..ca04db81b6 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -18,6 +18,7 @@ #include "syncMessage.h" #include "syncRaftEntry.h" #include "syncRaftLog.h" +#include "syncRaftStore.h" #include "syncUtil.h" // TLA+ Spec @@ -50,33 +51,54 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) { int32_t ret = 0; for (int i = 0; i < pSyncNode->peersNum; ++i) { - SRaftId* pDestId = &(pSyncNode->peersId[i]); - SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); + SRaftId* pDestId = &(pSyncNode->peersId[i]); + // set prevLogIndex + SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); SyncIndex preLogIndex = nextIndex - 1; + // set preLogTerm SyncTerm preLogTerm = 0; if (preLogIndex >= SYNC_INDEX_BEGIN) { SSyncRaftEntry* pPreEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, preLogIndex); + assert(pPreEntry != NULL); + preLogTerm = pPreEntry->term; + syncEntryDestory(pPreEntry); } - SyncIndex lastIndex = syncUtilMinIndex(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore), nextIndex); - assert(nextIndex == lastIndex); + // batch optimized + // SyncIndex lastIndex = syncUtilMinIndex(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore), nextIndex); - SSyncRaftEntry* pEntry = logStoreGetEntry(pSyncNode->pLogStore, nextIndex); - assert(pEntry != NULL); + SyncAppendEntries* pMsg = NULL; + SSyncRaftEntry* pEntry = logStoreGetEntry(pSyncNode->pLogStore, nextIndex); + if (pEntry != NULL) { + SyncAppendEntries* pMsg = syncAppendEntriesBuild(pEntry->bytes); + + // add pEntry into msg + uint32_t len; + char* serialized = syncEntrySerialize(pEntry, &len); + assert(len == pEntry->bytes); + memcpy(pMsg->data, serialized, len); + + free(serialized); + syncEntryDestory(pEntry); + + } else { + // maybe overflow, send empty record + SyncAppendEntries* pMsg = syncAppendEntriesBuild(0); + } - SyncAppendEntries* pMsg = syncAppendEntriesBuild(pEntry->bytes); pMsg->srcId = pSyncNode->myRaftId; pMsg->destId = *pDestId; + pMsg->term = pSyncNode->pRaftStore->currentTerm; pMsg->prevLogIndex = preLogIndex; pMsg->prevLogTerm = preLogTerm; pMsg->commitIndex = pSyncNode->commitIndex; - pMsg->dataLen = pEntry->bytes; - // add pEntry into msg + // send AppendEntries syncNodeAppendEntries(pSyncNode, pDestId, pMsg); + syncAppendEntriesDestroy(pMsg); } return ret; From f22226a44ec541e0c9492ab8bdeb6eb6b21620f8 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 17:16:10 +0800 Subject: [PATCH 13/60] sync refactor --- source/libs/sync/src/syncAppendEntriesReply.c | 6 ++- source/libs/sync/src/syncCommit.c | 41 +++++++++++++++++++ source/libs/sync/src/syncMain.c | 2 - 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 source/libs/sync/src/syncCommit.c diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 61eb4884e2..4fa4f89628 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -51,10 +51,10 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p assert(pMsg->term == ths->pRaftStore->currentTerm); if (pMsg->success) { - // nextIndex = reply.matchIndex + 1 + // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); - // matchIndex = reply.matchIndex + // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); // maybe commit @@ -62,6 +62,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); + + // notice! int64, uint64 if (nextIndex > SYNC_INDEX_BEGIN) { --nextIndex; } else { diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c new file mode 100644 index 0000000000..ec4272fdd0 --- /dev/null +++ b/source/libs/sync/src/syncCommit.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "syncInt.h" + +// \* Leader i advances its commitIndex. +// \* This is done as a separate step from handling AppendEntries responses, +// \* in part to minimize atomic regions, and in part so that leaders of +// \* single-server clusters are able to mark entries committed. +// AdvanceCommitIndex(i) == +// /\ state[i] = Leader +// /\ LET \* The set of servers that agree up through index. +// Agree(index) == {i} \cup {k \in Server : +// matchIndex[i][k] >= index} +// \* The maximum indexes for which a quorum agrees +// agreeIndexes == {index \in 1..Len(log[i]) : +// Agree(index) \in Quorum} +// \* New value for commitIndex'[i] +// newCommitIndex == +// IF /\ agreeIndexes /= {} +// /\ log[i][Max(agreeIndexes)].term = currentTerm[i] +// THEN +// Max(agreeIndexes) +// ELSE +// commitIndex[i] +// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] +// /\ UNCHANGED <> +// +void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} \ No newline at end of file diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index c146c2fa7a..7d2087eded 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -617,8 +617,6 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode) { syncRequestVoteReplyDestroy(pMsg); } -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} - // for debug -------------- void syncNodePrint(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); From e10f471b9525e452746c98820f8034c2766741e1 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 18:19:26 +0800 Subject: [PATCH 14/60] refactor --- include/common/tmsg.h | 25 +--- include/util/taoserror.h | 1 + source/dnode/vnode/src/inc/tsdbDef.h | 9 +- source/dnode/vnode/src/tsdb/tsdbBDBImpl.c | 4 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 170 ++++++++++++++-------- source/dnode/vnode/test/tsdbSmaTest.cpp | 121 +++++++-------- source/util/src/terror.c | 1 + 7 files changed, 184 insertions(+), 147 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..40bf9a7f62 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1896,33 +1896,18 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) } return buf; } -typedef enum { - TD_TIME_UNIT_UNKNOWN = -1, - TD_TIME_UNIT_YEAR = 0, - TD_TIME_UNIT_SEASON = 1, - TD_TIME_UNIT_MONTH = 2, - TD_TIME_UNIT_WEEK = 3, - TD_TIME_UNIT_DAY = 4, - TD_TIME_UNIT_HOUR = 5, - TD_TIME_UNIT_MINUTE = 6, - TD_TIME_UNIT_SEC = 7, - TD_TIME_UNIT_MILLISEC = 8, - TD_TIME_UNIT_MICROSEC = 9, - TD_TIME_UNIT_NANOSEC = 10 -} ETDTimeUnit; - typedef struct { int8_t version; // for compatibility(default 0) - int8_t intervalUnit; - int8_t slidingUnit; + int8_t intervalUnit; // MACRO: TIME_UNIT_XXX + int8_t slidingUnit; // MACRO: TIME_UNIT_XXX char indexName[TSDB_INDEX_NAME_LEN]; - char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change. + char timezone[TD_TIMEZONE_LEN]; // sma data expired if timezone changes. int32_t exprLen; int32_t tagsFilterLen; int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; - int64_t offset; + int64_t offset; // use unit by precision of DB int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -1967,7 +1952,7 @@ typedef struct { typedef struct { int64_t indexUid; - TSKEY skey; // startTS of one interval/sliding + TSKEY skey; // startKey of one interval/sliding window int64_t interval; int32_t dataLen; // not including head int8_t intervalUnit; diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 1c61d738b5..fe06a1c4a2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -354,6 +354,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) #define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0617) +#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0618) // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) diff --git a/source/dnode/vnode/src/inc/tsdbDef.h b/source/dnode/vnode/src/inc/tsdbDef.h index 6f91b4d3ab..5e4c852621 100644 --- a/source/dnode/vnode/src/inc/tsdbDef.h +++ b/source/dnode/vnode/src/inc/tsdbDef.h @@ -60,10 +60,11 @@ struct STsdb { SSmaEnv * pRSmaEnv; }; -#define REPO_ID(r) ((r)->vgId) -#define REPO_CFG(r) (&(r)->config) -#define REPO_FS(r) (r)->fs -#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_ID(r) ((r)->vgId) +#define REPO_CFG(r) (&(r)->config) +#define REPO_FS(r) (r)->fs +#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv) int tsdbLockRepo(STsdb *pTsdb); int tsdbUnlockRepo(STsdb *pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c index cf3351c5d8..ee279abf47 100644 --- a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c @@ -68,8 +68,8 @@ int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) { ret = pEnv->open(pEnv, path, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0); if (ret != 0) { - // BDB_PERR("Failed to open tsdb env", ret); - tsdbWarn("Failed to open tsdb env for path %s since %d", path ? path : "NULL", ret); + terrno = TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR; + tsdbWarn("Failed to open tsdb env for path %s since ret %d != 0", path ? path : "NULL", ret); return -1; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7335e4f585..880eb403f4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -17,7 +17,7 @@ #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 -#define SMA_STORAGE_TSDB_TIMES 30 +#define SMA_STORAGE_TSDB_TIMES 10 #define SMA_STORAGE_SPLIT_HOURS 24 #define SMA_KEY_LEN 18 // tableUid_colId_TSKEY 8+2+8 @@ -93,6 +93,11 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); + +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +} static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { SSmaEnv *pEnv = NULL; @@ -136,7 +141,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (pEnv && *pEnv) { + if (*pEnv) { return TSDB_CODE_SUCCESS; } @@ -144,7 +149,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (*pEnv == NULL) { + if (*pEnv == NULL) { // 2nd phase check if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; @@ -152,7 +157,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { } if (tsdbUnlockRepo(pTsdb) != 0) { - tsdbFreeSmaEnv(*pEnv); + *pEnv = tsdbFreeSmaEnv(*pEnv); return TSDB_CODE_FAILED; } @@ -244,6 +249,39 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } } +static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { + switch (smaType) { + case TSDB_SMA_TYPE_TIME_RANGE: + if (pTsdb->pTSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + case TSDB_SMA_TYPE_ROLLUP: + if (pTsdb->pRSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + default: + terrno = TSDB_CODE_INVALID_PARA; + return TSDB_CODE_FAILED; + } + + // SDiskID did = {0}; + SSmaEnv *pEnv = NULL; + char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; + if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_FAILED; + } + + if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { + pTsdb->pTSmaEnv = pEnv; + } else { + pTsdb->pRSmaEnv = pEnv; + } + + return TSDB_CODE_SUCCESS; +}; + /** * @brief Update expired window according to msg from stream computing module. * @@ -253,26 +291,17 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { * @return int32_t */ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { - STsdbCfg *pCfg = REPO_CFG(pTsdb); - SSmaEnv * pEnv = NULL; - if (!msg || !pTsdb->pMeta) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } - char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; - if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } - if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - pTsdb->pTSmaEnv = pEnv; - } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - pTsdb->pRSmaEnv = pEnv; - } else { - ASSERT(0); - } + SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, smaType); // TODO: decode the msg => start int64_t indexUid = SMA_TEST_INDEX_UID; @@ -308,7 +337,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { } pItem->pSma = pSma; - // TODO: change indexName to indexUid if (taosHashPut(pItemsHash, &indexUid, sizeof(indexUid), &pItem, sizeof(pItem)) != 0) { // If error occurs during put smaStatItem, free the resources of pItem taosHashCleanup(pItem->expiredWindows); @@ -378,32 +406,32 @@ static int32_t tsdbResetExpiredWindow(SSmaStat *pStat, int64_t indexUid, TSKEY s static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { // TODO: configurable for SMA_STORAGE_SPLIT_HOURS? switch (intervalUnit) { - case TD_TIME_UNIT_HOUR: + case TIME_UNIT_HOUR: if (interval < SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MINUTE: + case TIME_UNIT_MINUTE: if (interval < 60 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_SEC: + case TIME_UNIT_SECOND: if (interval < 3600 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MILLISEC: + case TIME_UNIT_MILLISECOND: if (interval < 3600 * 1e3 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MICROSEC: + case TIME_UNIT_MICROSECOND: if (interval < 3600 * 1e6 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_NANOSEC: + case TIME_UNIT_NANOSECOND: if (interval < 3600 * 1e9 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } @@ -429,8 +457,8 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k // TODO: insert sma data blocks into B+Tree tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d", - REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); + REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) { return TSDB_CODE_FAILED; @@ -447,66 +475,73 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k return TSDB_CODE_SUCCESS; } +/** + * @brief Approximate value for week/month/year. + * + * @param interval + * @param intervalUnit + * @param precision + * @return int64_t + */ static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision) { - if (intervalUnit < TD_TIME_UNIT_MILLISEC) { - switch (intervalUnit) { - case TD_TIME_UNIT_YEAR: - case TD_TIME_UNIT_SEASON: - case TD_TIME_UNIT_MONTH: - case TD_TIME_UNIT_WEEK: - // illegal time unit - tsdbError("invalid interval unit: %d\n", intervalUnit); - TASSERT(0); - break; - case TD_TIME_UNIT_DAY: // the interval for tSma calculation must <= day - interval *= 86400 * 1e3; - break; - case TD_TIME_UNIT_HOUR: - interval *= 3600 * 1e3; - break; - case TD_TIME_UNIT_MINUTE: - interval *= 60 * 1e3; - break; - case TD_TIME_UNIT_SEC: - interval *= 1e3; - break; - default: - break; - } + switch (intervalUnit) { + case TIME_UNIT_YEAR: // approximate value + interval *= 365 * 86400 * 1e3; + break; + case TIME_UNIT_MONTH: // approximate value + interval *= 30 * 86400 * 1e3; + break; + case TIME_UNIT_WEEK: // approximate value + interval *= 7 * 86400 * 1e3; + break; + case TIME_UNIT_DAY: // the interval for tSma calculation must <= day + interval *= 86400 * 1e3; + break; + case TIME_UNIT_HOUR: + interval *= 3600 * 1e3; + break; + case TIME_UNIT_MINUTE: + interval *= 60 * 1e3; + break; + case TIME_UNIT_SECOND: + interval *= 1e3; + break; + default: + break; } switch (precision) { case TSDB_TIME_PRECISION_MILLI: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; } break; case TSDB_TIME_PRECISION_MICRO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e3; } else { return interval * 1e3; } break; case TSDB_TIME_PRECISION_NANO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { + if (TIME_UNIT_MICROSECOND == intervalUnit) { return interval * 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval; } else { return interval * 1e6; } break; default: // ms - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; @@ -800,10 +835,19 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, int32_t nMaxResult) { + if (!pTsdb->pTSmaEnv) { + terrno = TSDB_CODE_INVALID_PTR; + tsdbWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); + return TSDB_CODE_FAILED; + } + SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); if (pItem == NULL) { - // mark all window as expired and notify query module to query raw TS data. - return TSDB_CODE_SUCCESS; + // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if + // it's NULL. + terrno = TSDB_CODE_TDB_INVALID_ACTION; + tsdbWarn("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", REPO_ID(pTsdb), indexUid); + return TSDB_CODE_FAILED; } #if 0 @@ -815,6 +859,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ } } #endif + #if 0 if (taosHashGet(pItem->expiredWindows, &querySkey, sizeof(TSKEY)) != NULL) { // TODO: mark this window as expired. @@ -835,8 +880,8 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ tsdbEncodeTSmaKey(tableUid, colId, querySkey, (void **)&pSmaKey); tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), - tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); + tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); void * result = NULL; uint32_t valueSize = 0; @@ -947,7 +992,6 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) { * @brief Insert Time-range-wise Rollup Sma(RSma) data * * @param pTsdb - * @param param * @param msg * @return int32_t */ diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 18dca33bda..96fd35e700 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -37,9 +37,9 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN); tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN); @@ -50,37 +50,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper); void *buf = calloc(bufLen, 1); - assert(buf != NULL); + ASSERT_NE(buf, nullptr); STSmaWrapper *pSW = (STSmaWrapper *)buf; uint32_t len = tEncodeTSmaWrapper(&buf, &tSmaWrapper); - EXPECT_EQ(len, bufLen); + ASSERT_EQ(len, bufLen); // decode STSmaWrapper dstTSmaWrapper = {0}; void * result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper); - assert(result != NULL); + ASSERT_NE(result, nullptr); - EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); + ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); for (int i = 0; i < tSmaWrapper.number; ++i) { STSma *pSma = tSmaWrapper.tSma + i; STSma *qSma = dstTSmaWrapper.tSma + i; - EXPECT_EQ(pSma->version, qSma->version); - EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit); - EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit); - EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName); - EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone); - EXPECT_EQ(pSma->indexUid, qSma->indexUid); - EXPECT_EQ(pSma->tableUid, qSma->tableUid); - EXPECT_EQ(pSma->interval, qSma->interval); - EXPECT_EQ(pSma->sliding, qSma->sliding); - EXPECT_EQ(pSma->exprLen, qSma->exprLen); - EXPECT_STRCASEEQ(pSma->expr, qSma->expr); - EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); - EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); + ASSERT_EQ(pSma->version, qSma->version); + ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit); + ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit); + ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName); + ASSERT_STRCASEEQ(pSma->timezone, qSma->timezone); + ASSERT_EQ(pSma->indexUid, qSma->indexUid); + ASSERT_EQ(pSma->tableUid, qSma->tableUid); + ASSERT_EQ(pSma->interval, qSma->interval); + ASSERT_EQ(pSma->sliding, qSma->sliding); + ASSERT_EQ(pSma->exprLen, qSma->exprLen); + ASSERT_STRCASEEQ(pSma->expr, qSma->expr); + ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); + ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); } // resource release @@ -103,9 +103,9 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -114,10 +114,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -129,18 +131,18 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); pSmaCfg->indexUid = indexUid2; tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN); pSmaCfg->version = 1; - pSmaCfg->intervalUnit = TD_TIME_UNIT_HOUR; + pSmaCfg->intervalUnit = TIME_UNIT_HOUR; pSmaCfg->interval = 1; - pSmaCfg->slidingUnit = TD_TIME_UNIT_MINUTE; + pSmaCfg->slidingUnit = TIME_UNIT_MINUTE; pSmaCfg->sliding = 5; // save index 2 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // get value by indexName STSma *qSmaCfg = NULL; @@ -150,8 +152,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone1 = %s\n", qSmaCfg->timezone); printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); - EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); + ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -161,8 +163,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone2 = %s\n", qSmaCfg->timezone); printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); - EXPECT_EQ(qSmaCfg->interval, tSma.interval); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); + ASSERT_EQ(qSmaCfg->interval, tSma.interval); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -178,25 +180,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("indexName = %s\n", indexName); ++indexCnt; } - EXPECT_EQ(indexCnt, nCntTSma); + ASSERT_EQ(indexCnt, nCntTSma); metaCloseSmaCurosr(pSmaCur); // get wrapper by table uid STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid); assert(pSW != NULL); - EXPECT_EQ(pSW->number, nCntTSma); - EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); - EXPECT_STRCASEEQ(pSW->tSma->timezone, timezone); - EXPECT_STRCASEEQ(pSW->tSma->expr, expr); - EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); - EXPECT_EQ(pSW->tSma->indexUid, indexUid1); - EXPECT_EQ(pSW->tSma->tableUid, tbUid); - EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); - EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); - EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr); - EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); - EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2); - EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid); + ASSERT_EQ(pSW->number, nCntTSma); + ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); + ASSERT_STRCASEEQ(pSW->tSma->timezone, timezone); + ASSERT_STRCASEEQ(pSW->tSma->expr, expr); + ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); + ASSERT_EQ(pSW->tSma->indexUid, indexUid1); + ASSERT_EQ(pSW->tSma->tableUid, tbUid); + ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); + ASSERT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); + ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr); + ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); + ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2); + ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid); tdDestroyTSmaWrapper(pSW); tfree(pSW); @@ -208,7 +210,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i)); // printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i)); } - EXPECT_EQ(taosArrayGetSize(pUids), 1); + ASSERT_EQ(taosArrayGetSize(pUids), 1); taosArrayDestroy(pUids); // resource release @@ -231,7 +233,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { const tb_uid_t tbUid = 1234567890; const int64_t indexUid1 = 2000000001; const int64_t interval1 = 1; - const int8_t intervalUnit1 = TD_TIME_UNIT_DAY; + const int8_t intervalUnit1 = TIME_UNIT_DAY; const uint32_t nCntTSma = 2; TSKEY skey1 = 1646987196; const int64_t testSmaData1 = 100; @@ -239,9 +241,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -250,10 +252,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -265,7 +269,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // step 2: insert data STSmaDataWrapper *pSmaData = NULL; @@ -298,18 +302,19 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } char *msg = (char *)calloc(100, 1); - EXPECT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); + assert(msg != NULL); + ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); // init int32_t allocCnt = 0; - int32_t allocStep = 40960; - int32_t buffer = 4096; + int32_t allocStep = 16384; + int32_t buffer = 1024; void * buf = NULL; - EXPECT_EQ(tsdbMakeRoom(&buf, allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, allocStep), 0); int32_t bufSize = taosTSizeof(buf); int32_t numOfTables = 10; col_id_t numOfCols = 4096; - EXPECT_GT(numOfCols, 0); + ASSERT_GT(numOfCols, 0); pSmaData = (STSmaDataWrapper *)buf; printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData); @@ -326,7 +331,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { int32_t tableDataLen = sizeof(STSmaTbData); for (col_id_t c = 0; c < numOfCols; ++c) { if (bufSize - len - tableDataLen < buffer) { - EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); pSmaData = (STSmaDataWrapper *)buf; pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len); bufSize = taosTSizeof(buf); @@ -353,22 +358,22 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } pSmaData->dataLen = (len - sizeof(STSmaDataWrapper)); - EXPECT_GE(bufSize, pSmaData->dataLen); + ASSERT_GE(bufSize, pSmaData->dataLen); // execute - EXPECT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); + ASSERT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); // step 3: query uint32_t checkDataCnt = 0; for (int32_t t = 0; t < numOfTables; ++t) { for (col_id_t c = 0; c < numOfCols; ++c) { - EXPECT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, + ASSERT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1), TSDB_CODE_SUCCESS); ++checkDataCnt; } } - + printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt); // release data diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f97df62ccc..469b944bf9 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -350,6 +350,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_SMA_INDEX_IN_META, "No sma index in meta") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") From 18f254a0178cd1487b3e31dee4994da4f30d3d9b Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 18:29:31 +0800 Subject: [PATCH 15/60] task deploy and task exec --- include/common/tcommon.h | 21 +++-- include/common/tmsg.h | 100 ++++++++++++++------- include/common/tmsgdef.h | 1 + include/dnode/snode/snode.h | 3 +- source/common/src/tmsg.c | 72 ++++++++++----- source/dnode/mgmt/impl/src/dndSnode.c | 27 ++++-- source/dnode/mnode/impl/inc/mndDef.h | 10 +-- source/dnode/mnode/impl/inc/mndScheduler.h | 2 + source/dnode/mnode/impl/src/mndScheduler.c | 75 ++++++++++------ source/dnode/mnode/impl/src/mndStream.c | 7 ++ source/dnode/snode/CMakeLists.txt | 3 +- source/dnode/snode/inc/sndInt.h | 31 ++----- source/dnode/snode/src/snode.c | 75 +++++++++++++--- 13 files changed, 285 insertions(+), 142 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 23dd349861..cb8b077b47 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -58,7 +58,10 @@ typedef struct SDataBlockInfo { int32_t rows; int32_t rowSize; int32_t numOfCols; - union {int64_t uid; int64_t blockId;}; + union { + int64_t uid; + int64_t blockId; + }; } SDataBlockInfo; typedef struct SConstantItem { @@ -70,10 +73,10 @@ typedef struct SConstantItem { // info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList); typedef struct SSDataBlock { - SColumnDataAgg *pBlockAgg; - SArray *pDataBlock; // SArray - SArray *pConstantList; // SArray, it is a constant/tags value of the corresponding result value. - SDataBlockInfo info; + SColumnDataAgg* pBlockAgg; + SArray* pDataBlock; // SArray + SArray* pConstantList; // SArray, it is a constant/tags value of the corresponding result value. + SDataBlockInfo info; } SSDataBlock; typedef struct SVarColAttr { @@ -244,7 +247,7 @@ typedef struct SGroupbyExpr { typedef struct SFunctParam { int32_t type; - SColumn *pCol; + SColumn* pCol; SVariant param; } SFunctParam; @@ -262,12 +265,12 @@ typedef struct SResSchame { typedef struct SExprBasicInfo { SResSchema resSchema; int16_t numOfParams; // argument value of each function - SFunctParam *pParam; + SFunctParam* pParam; } SExprBasicInfo; typedef struct SExprInfo { - struct SExprBasicInfo base; - struct tExprNode *pExpr; + struct SExprBasicInfo base; + struct tExprNode* pExpr; } SExprInfo; typedef struct SStateWindow { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a3e35e1874..30f61374ea 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -24,6 +24,7 @@ #include "thash.h" #include "tlist.h" #include "trow.h" +#include "tuuid.h" #ifdef __cplusplus extern "C" { @@ -171,7 +172,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SBuildUseDBInput; typedef struct SField { @@ -427,10 +428,10 @@ typedef struct { int16_t slotId; }; - int16_t type; - int32_t bytes; - uint8_t precision; - uint8_t scale; + int16_t type; + int32_t bytes; + uint8_t precision; + uint8_t scale; } SColumnInfo; typedef struct { @@ -526,7 +527,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SUseDbReq; int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq); @@ -553,15 +554,13 @@ int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); typedef struct { - SArray *epSetList; // SArray + SArray* epSetList; // SArray } SQnodeListRsp; int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); void tFreeSQnodeListRsp(SQnodeListRsp* pRsp); - - typedef struct { SArray* pArray; // Array of SUseDbRsp } SUseDbBatchRsp; @@ -777,7 +776,6 @@ typedef struct SVgroupInfo { int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SVgroupInfo; - typedef struct { int32_t numOfVgroups; SVgroupInfo vgroups[]; @@ -1062,8 +1060,8 @@ typedef struct { } STaskStatus; typedef struct { - int64_t refId; - SArray *taskStatus; //SArray + int64_t refId; + SArray* taskStatus; // SArray } SSchedulerStatusRsp; typedef struct { @@ -1072,35 +1070,31 @@ typedef struct { int8_t action; } STaskAction; - typedef struct SQueryNodeEpId { int32_t nodeId; // vgId or qnodeId SEp ep; } SQueryNodeEpId; - typedef struct { SMsgHead header; uint64_t sId; SQueryNodeEpId epId; - SArray *taskAction; //SArray + SArray* taskAction; // SArray } SSchedulerHbReq; -int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq); - +int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +void tFreeSSchedulerHbReq(SSchedulerHbReq* pReq); typedef struct { uint64_t seqId; SQueryNodeEpId epId; - SArray *taskStatus; //SArray + SArray* taskStatus; // SArray } SSchedulerHbRsp; -int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -void tFreeSSchedulerHbRsp(SSchedulerHbRsp *pRsp); - +int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +void tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp); typedef struct { SMsgHead header; @@ -1370,7 +1364,7 @@ typedef struct SVCreateTbReq { } SVCreateTbReq, SVUpdateTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbRsp, SVUpdateTbRsp; int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq); @@ -1382,7 +1376,7 @@ typedef struct { } SVCreateTbBatchReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbBatchRsp; int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq); @@ -1396,7 +1390,7 @@ typedef struct { } SVDropTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVDropTbRsp; int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq); @@ -1933,7 +1927,7 @@ typedef struct { } SVCreateTSmaReq; typedef struct { - int8_t type; // 0 status report, 1 update data + int8_t type; // 0 status report, 1 update data char indexName[TSDB_INDEX_NAME_LEN]; // STimeWindow windows; } STSmaMsg; @@ -1944,7 +1938,7 @@ typedef struct { } SVDropTSmaReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTSmaRsp, SVDropTSmaRsp; int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq); @@ -2029,7 +2023,7 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); tlen += taosEncodeFixedI64(buf, pSma->sliding); - + if (pSma->exprLen > 0) { tlen += taosEncodeString(buf, pSma->expr); } @@ -2064,7 +2058,6 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI64(buf, &pSma->interval); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->exprLen > 0) { pSma->expr = (char*)calloc(pSma->exprLen, 1); if (pSma->expr != NULL) { @@ -2265,6 +2258,51 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p return buf; } +enum { + STREAM_TASK_STATUS__RUNNING = 1, + STREAM_TASK_STATUS__STOP, +}; + +typedef struct { + int64_t streamId; + int32_t taskId; + int32_t level; + int8_t status; + char* qmsg; + void* executor; + // void* stateStore; + // storage handle +} SStreamTask; + +static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level) { + SStreamTask* pTask = (SStreamTask*)calloc(1, sizeof(SStreamTask)); + if (pTask == NULL) { + return NULL; + } + pTask->taskId = tGenIdPI32(); + pTask->status = STREAM_TASK_STATUS__RUNNING; + pTask->qmsg = NULL; + return pTask; +} + +int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask); +int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask); +void tFreeSStreamTask(SStreamTask* pTask); + +typedef struct { + SMsgHead head; + SStreamTask* task; +} SStreamTaskDeployReq; + +typedef struct { + int32_t reserved; +} SStreamTaskDeployRsp; + +typedef struct { + SMsgHead head; + // TODO: other info needed by task +} SStreamTaskExecReq; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 03f8daad42..b30a325d7c 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -199,6 +199,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 21a93532e0..b25f8a8666 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -16,6 +16,7 @@ #ifndef _TD_SNODE_H_ #define _TD_SNODE_H_ +#include "tcommon.h" #include "tmsg.h" #include "trpc.h" @@ -78,7 +79,7 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); * @param pRsp The response message * @return int32_t 0 for success, -1 for failure */ -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +// int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..121f5271b3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1467,8 +1467,7 @@ int32_t tDeserializeSUseDbReq(void *buf, int32_t bufLen, SUseDbReq *pReq) { return 0; } - -int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq) { +int32_t tSerializeSQnodeListReq(void *buf, int32_t bufLen, SQnodeListReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -1499,7 +1498,7 @@ int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) if (tStartEncode(&encoder) < 0) return -1; int32_t num = taosArrayGetSize(pRsp->epSetList); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { SEpSet *epSet = taosArrayGet(pRsp->epSetList, i); if (tEncodeSEpSet(&encoder, epSet) < 0) return -1; @@ -2491,27 +2490,27 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pReq->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; if (pReq->taskAction) { int32_t num = taosArrayGetSize(pReq->taskAction); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskAction *action = taosArrayGet(pReq->taskAction, i); - if (tEncodeU64(&encoder, action->queryId) < 0) return -1; - if (tEncodeU64(&encoder, action->taskId) < 0) return -1; - if (tEncodeI8(&encoder, action->action) < 0) return -1; + if (tEncodeU64(&encoder, action->queryId) < 0) return -1; + if (tEncodeU64(&encoder, action->taskId) < 0) return -1; + if (tEncodeI8(&encoder, action->action) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); int32_t tlen = encoder.pos; tCoderClear(&encoder); - + if (buf != NULL) { SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); pHead->vgId = htonl(pReq->header.vgId); @@ -2559,29 +2558,27 @@ int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq * void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq) { taosArrayDestroy(pReq->taskAction); } - - int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pRsp->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; if (pRsp->taskStatus) { int32_t num = taosArrayGetSize(pRsp->taskStatus); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskStatus *status = taosArrayGet(pRsp->taskStatus, i); - if (tEncodeU64(&encoder, status->queryId) < 0) return -1; - if (tEncodeU64(&encoder, status->taskId) < 0) return -1; - if (tEncodeI64(&encoder, status->refId) < 0) return -1; - if (tEncodeI8(&encoder, status->status) < 0) return -1; + if (tEncodeU64(&encoder, status->queryId) < 0) return -1; + if (tEncodeU64(&encoder, status->taskId) < 0) return -1; + if (tEncodeI64(&encoder, status->refId) < 0) return -1; + if (tEncodeI8(&encoder, status->status) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); @@ -2694,3 +2691,32 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { tfree(pReq->physicalPlan); tfree(pReq->logicalPlan); } + +int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->level) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->status) < 0) return -1; + if (tEncodeCStr(pEncoder, pTask->qmsg) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; + if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +void tFreeSStreamTask(SStreamTask *pTask) { + // TODO + /*free(pTask->qmsg);*/ + /*free(pTask->executor);*/ + /*free(pTask);*/ +} diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index 5ea8a841d2..8667952f2c 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -323,8 +323,8 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pReq) { } static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { @@ -334,22 +334,35 @@ static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t sndProcessUMsg(pSnode, pMsg); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + dndReleaseSnode(pDnode, pSnode); + } else { + for (int32_t i = 0; i < numOfMsgs; i++) { + SRpcMsg *pMsg = NULL; + taosGetQitem(qall, (void **)&pMsg); + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); + rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } } - dndReleaseSnode(pDnode, pSnode); } static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { - code = sndProcessSMsg(pSnode, pMsg); + sndProcessSMsg(pSnode, pMsg); + dndReleaseSnode(pDnode, pSnode); + } else { + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); } - dndReleaseSnode(pDnode, pSnode); #if 0 if (pMsg->msgType & 1u) { diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index a7116b72ff..8ea9cc141f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -85,6 +85,8 @@ typedef enum { TRN_TYPE_REBALANCE = 1017, TRN_TYPE_COMMIT_OFFSET = 1018, TRN_TYPE_CREATE_STREAM = 1019, + TRN_TYPE_DROP_STREAM = 1020, + TRN_TYPE_ALTER_STREAM = 1021, TRN_TYPE_BASIC_SCOPE_END, TRN_TYPE_GLOBAL_SCOPE = 2000, TRN_TYPE_CREATE_DNODE = 2001, @@ -679,12 +681,6 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons return buf; } -typedef struct { - int32_t taskId; - int32_t level; - SSubplan* plan; -} SStreamTaskMeta; - typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; @@ -700,7 +696,7 @@ typedef struct { char* sql; char* logicalPlan; char* physicalPlan; - SArray* tasks; // SArray> + SArray* tasks; // SArray> } SStreamObj; int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/inc/mndScheduler.h b/source/dnode/mnode/impl/inc/mndScheduler.h index 3bf6e0c33a..42951beca2 100644 --- a/source/dnode/mnode/impl/inc/mndScheduler.h +++ b/source/dnode/mnode/impl/inc/mndScheduler.h @@ -27,6 +27,8 @@ void mndCleanupScheduler(SMnode* pMnode); int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub); +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 855e244daa..16b1ba8a5c 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -31,7 +31,7 @@ #include "tname.h" #include "tuuid.h" -int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; SVgObj* pVgroup = NULL; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); @@ -41,17 +41,18 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } ASSERT(pStream->vgNum == 0); - int32_t levelNum = LIST_LENGTH(pPlan->pSubplans); - pStream->tasks = taosArrayInit(levelNum, sizeof(SArray)); + int32_t totLevel = LIST_LENGTH(pPlan->pSubplans); + pStream->tasks = taosArrayInit(totLevel, sizeof(SArray)); - for (int32_t i = 0; i < levelNum; i++) { - SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTaskMeta)); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, i); + int32_t msgLen; + for (int32_t level = 0; level < totLevel; level++) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTask)); + SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level); int32_t opNum = LIST_LENGTH(inner->pNodeList); ASSERT(opNum == 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); - if (i == 0) { + SSubplan* plan = nodesListGetNode(inner->pNodeList, level); + if (level == 0) { ASSERT(plan->type == SUBPLAN_TYPE_SCAN); void* pIter = NULL; while (1) { @@ -63,15 +64,19 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } pStream->vgNum++; + // send to vnode + + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + plan->execNode.nodeId = pVgroup->vgId; plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - // send to vnode - taosArrayPush(taskOneLevel, &task); + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { // duplicatable @@ -82,22 +87,36 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { // if has snode, set to shared thread num in snode parallel = SND_SHARED_THREAD_NUM; - for (int32_t j = 0; j < parallel; j++) { - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + for (int32_t i = 0; i < parallel; i++) { + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + + taosArrayPush(taskOneLevel, pTask); } } else { // not duplicatable - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } taosArrayPush(pStream->tasks, taskOneLevel); } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 54ad9cd7e2..67011dfe8a 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" +#include "mndScheduler.h" #include "mndShow.h" #include "mndStb.h" #include "mndTrans.h" @@ -237,6 +238,12 @@ static int32_t mndCreateStream(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateStreamR } sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); + if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { + mError("stream:%ld, schedule stream since %s", streamObj.uid, terrstr()); + mndTransDrop(pTrans); + return -1; + } + if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mndTransDrop(pTrans); diff --git a/source/dnode/snode/CMakeLists.txt b/source/dnode/snode/CMakeLists.txt index dafd5d6594..d1b1abdf1d 100644 --- a/source/dnode/snode/CMakeLists.txt +++ b/source/dnode/snode/CMakeLists.txt @@ -7,8 +7,9 @@ target_include_directories( ) target_link_libraries( snode + PRIVATE executor PRIVATE transport PRIVATE os PRIVATE common PRIVATE util -) \ No newline at end of file +) diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index 3fe816845d..e5f6c3c266 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -38,13 +38,8 @@ enum { STREAM_STATUS__DELETING, }; -enum { - STREAM_TASK_STATUS__RUNNING = 1, - STREAM_TASK_STATUS__STOP, -}; - typedef struct { - SHashObj* pHash; // taskId -> streamTask + SHashObj* pHash; // taskId -> SStreamTask } SStreamMeta; typedef struct SSnode { @@ -52,26 +47,16 @@ typedef struct SSnode { SSnodeOpt cfg; } SSnode; -typedef struct { - int64_t streamId; - int32_t taskId; - int32_t IdxInLevel; - int32_t level; -} SStreamTaskInfo; +SStreamMeta* sndMetaNew(); +void sndMetaDelete(SStreamMeta* pMeta); -typedef struct { - SStreamTaskInfo meta; - int8_t status; - void* executor; - void* stateStore; - // storage handle -} SStreamTask; +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); -int32_t sndCreateTask(); -int32_t sndDropTaskOfStream(int64_t streamId); +int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); -int32_t sndStopTaskOfStream(int64_t streamId); -int32_t sndResumeTaskOfStream(int64_t streamId); +int32_t sndStopTaskOfStream(SStreamMeta* pMeta, int64_t streamId); +int32_t sndResumeTaskOfStream(SStreamMeta* pMeta, int64_t streamId); #ifdef __cplusplus } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 74e41d45c5..80e33bd971 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -13,40 +13,91 @@ * along with this program. If not, see . */ +#include "executor.h" #include "sndInt.h" #include "tuuid.h" SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *pSnode = calloc(1, sizeof(SSnode)); + if (pSnode == NULL) { + return NULL; + } memcpy(&pSnode->cfg, pOption, sizeof(SSnodeOpt)); + pSnode->pMeta = sndMetaNew(); + if (pSnode->pMeta == NULL) { + free(pSnode); + return NULL; + } return pSnode; } -void sndClose(SSnode *pSnode) { free(pSnode); } +void sndClose(SSnode *pSnode) { + sndMetaDelete(pSnode->pMeta); + free(pSnode); +} int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; } -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - *pRsp = NULL; - return 0; -} +/*int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {*/ +/**pRsp = NULL;*/ +/*return 0;*/ +/*}*/ void sndDestroy(const char *path) {} -static int32_t sndDeployTask(SSnode *pSnode, SRpcMsg *pMsg) { - SStreamTask *task = malloc(sizeof(SStreamTask)); - if (task == NULL) { +SStreamMeta *sndMetaNew() { + SStreamMeta *pMeta = calloc(1, sizeof(SStreamMeta)); + if (pMeta == NULL) { + return NULL; + } + pMeta->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + if (pMeta->pHash == NULL) { + free(pMeta); + return NULL; + } + return pMeta; +} + +void sndMetaDelete(SStreamMeta *pMeta) { + taosHashCleanup(pMeta->pHash); + free(pMeta); +} + +int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { + pTask->executor = qCreateStreamExecTaskInfo(pTask->qmsg, NULL); + return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); +} + +int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { + SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); + if (pTask == NULL) { return -1; } - task->meta.taskId = tGenIdPI32(); - taosHashPut(pSnode->pMeta->pHash, &task->meta.taskId, sizeof(int32_t), &task, sizeof(void *)); - return 0; + free(pTask->qmsg); + // TODO:free executor + free(pTask); + return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { - // stream deployment + // stream deploy // stream stop/resume // operator exec + if (pMsg->msgType == TDMT_SND_TASK_DEPLOY) { + void *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + SStreamTask *pTask = malloc(sizeof(SStreamTask)); + if (pTask == NULL) { + return -1; + } + SCoder decoder; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, msg, pMsg->contLen - sizeof(SMsgHead), TD_DECODER); + tDecodeSStreamTask(&decoder, pTask); + tCoderClear(&decoder); + + sndMetaDeployTask(pSnode->pMeta, pTask); + } else { + // + } return 0; } From 231ac079bee6f2304da05d2d5a66dc87dc4211be Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:01:45 +0800 Subject: [PATCH 16/60] refactor --- source/dnode/vnode/src/tsdb/tsdbFile.c | 4 ++-- source/dnode/vnode/src/tsdb/tsdbSma.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index b756cc9862..00e97c7b61 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -23,8 +23,8 @@ static const char *TSDB_FNAME_SUFFIX[] = { "smal", // TSDB_FILE_SMAL "", // TSDB_FILE_MAX "meta", // TSDB_FILE_META - "sma", // TSDB_FILE_TSMA(directory name) - "sma", // TSDB_FILE_RSMA(directory name) + "tsma", // TSDB_FILE_TSMA + "rsma", // TSDB_FILE_RSMA }; static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname); diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 880eb403f4..cd8b60385f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -15,6 +15,12 @@ #include "tsdbDef.h" +static const char *TSDB_SMA_DNAME[] = { + "", // TSDB_SMA_TYPE_BLOCK + "tsma", // TSDB_SMA_TYPE_TIME_RANGE + "rsma", // TSDB_SMA_TYPE_ROLLUP +}; + #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 @@ -93,10 +99,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { - snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); } static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { From 575ab144393190af14a10914d71ceaaf4fbbeebd Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:28:33 +0800 Subject: [PATCH 17/60] trow bug fix --- include/common/trow.h | 30 +++++++++++++++--------------- source/libs/parser/src/parInsert.c | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/common/trow.h b/include/common/trow.h index 4dd3daba4d..47edf6f1ad 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -98,13 +98,13 @@ typedef void *SRow; typedef struct { TDRowValT valType; - void *val; + void * val; } SCellVal; typedef struct { // TODO - int tmp; // TODO: to avoid compile error -} STpRow; // tuple + int tmp; // TODO: to avoid compile error +} STpRow; // tuple #pragma pack(push, 1) typedef struct { @@ -158,8 +158,8 @@ typedef struct { int16_t nBitmaps; int16_t nBoundBitmaps; int32_t offset; - void *pBitmap; - void *pOffset; + void * pBitmap; + void * pOffset; int32_t extendedRowSize; } SRowBuilder; @@ -273,7 +273,7 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6); @@ -311,7 +311,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pValType = (((*pDestByte) & 0xC0) >> 6); @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa if (tdValIsNorm(valType, val, colType)) { // ts key stored in STSRow.ts SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN @@ -635,7 +635,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa // NULL/None value else { SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN const void *nullVal = getNullValue(colType); @@ -697,9 +697,9 @@ static FORCE_INLINE int32_t tdAppendColValToRow(SRowBuilder *pBuilder, int16_t c } // TODO: We can avoid the type judegement by FP, but would prevent the inline scheme. if (TD_IS_TP_ROW(pRow)) { - tdAppendColValToTpRow(pBuilder, valType, val, true, colType, colIdx, offset); + tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset); } else { - tdAppendColValToKvRow(pBuilder, valType, val, true, colType, colIdx, offset, colId); + tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId); } return TSDB_CODE_SUCCESS; } @@ -771,8 +771,8 @@ static FORCE_INLINE int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, v typedef struct { STSchema *pSchema; - STSRow *pRow; - void *pBitmap; + STSRow * pRow; + void * pBitmap; uint32_t offset; col_id_t maxColId; col_id_t colIdx; // [PRIMARYKEY_TIMESTAMP_COL_ID, nSchemaCols], PRIMARYKEY_TIMESTAMP_COL_ID equals 1 @@ -877,7 +877,7 @@ static FORCE_INLINE bool tdGetTpRowDataOfCol(STSRowIter *pIter, col_type_t colTy // internal static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, col_type_t colType, col_id_t *nIdx, SCellVal *pVal) { - STSRow *pRow = pIter->pRow; + STSRow * pRow = pIter->pRow; SKvRowIdx *pKvIdx = NULL; bool colFound = false; col_id_t kvNCols = tdRowGetNCols(pRow); @@ -1068,7 +1068,7 @@ typedef struct { typedef struct { STSchema *pSchema; - STSRow *pRow; + STSRow * pRow; } STSRowReader; typedef struct { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 28f680cfbb..6db3abb9d6 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { const char* rowEnd = tdRowEnd(rb->pBuf); STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; @@ -626,9 +626,9 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } varDataSetLen(rowEnd, output); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else { - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, true, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); } return TSDB_CODE_SUCCESS; } From 4e0b56324aec492d50f22a1bf5c667762ce6fe92 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 07:28:40 -0400 Subject: [PATCH 18/60] TD-13675 rollup, alter db, alter table syntax definition --- include/common/ttokendef.h | 265 +- include/libs/nodes/cmdnodes.h | 20 + include/libs/nodes/nodes.h | 3 + include/util/taoserror.h | 1 + source/libs/nodes/src/nodesUtilFuncs.c | 2 + source/libs/parser/inc/parAst.h | 21 +- source/libs/parser/inc/sql.y | 115 +- source/libs/parser/src/parAstCreater.c | 93 +- source/libs/parser/src/parTokenizer.c | 2 +- source/libs/parser/src/parTranslater.c | 55 + source/libs/parser/src/parUtil.c | 14 +- source/libs/parser/src/sql.c | 3689 +++++++++++---------- source/libs/parser/test/parserAstTest.cpp | 17 + 13 files changed, 2466 insertions(+), 1831 deletions(-) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 167c72a778..e89df62b8e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -33,129 +33,148 @@ #define TK_NK_SLASH 15 #define TK_NK_REM 16 #define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_USER 19 -#define TK_PASS 20 -#define TK_NK_STRING 21 -#define TK_ALTER 22 -#define TK_PRIVILEGE 23 -#define TK_DROP 24 -#define TK_SHOW 25 -#define TK_USERS 26 -#define TK_DNODE 27 -#define TK_PORT 28 -#define TK_NK_INTEGER 29 -#define TK_DNODES 30 -#define TK_NK_ID 31 -#define TK_NK_IPTOKEN 32 -#define TK_QNODE 33 -#define TK_ON 34 -#define TK_QNODES 35 -#define TK_DATABASE 36 -#define TK_DATABASES 37 -#define TK_USE 38 -#define TK_IF 39 -#define TK_NOT 40 -#define TK_EXISTS 41 -#define TK_BLOCKS 42 -#define TK_CACHE 43 -#define TK_CACHELAST 44 -#define TK_COMP 45 -#define TK_DAYS 46 -#define TK_FSYNC 47 -#define TK_MAXROWS 48 -#define TK_MINROWS 49 -#define TK_KEEP 50 -#define TK_PRECISION 51 -#define TK_QUORUM 52 -#define TK_REPLICA 53 -#define TK_TTL 54 -#define TK_WAL 55 -#define TK_VGROUPS 56 -#define TK_SINGLE_STABLE 57 -#define TK_STREAM_MODE 58 -#define TK_TABLE 59 -#define TK_NK_LP 60 -#define TK_NK_RP 61 -#define TK_STABLE 62 -#define TK_TABLES 63 -#define TK_STABLES 64 -#define TK_USING 65 -#define TK_TAGS 66 -#define TK_NK_DOT 67 -#define TK_NK_COMMA 68 -#define TK_COMMENT 69 -#define TK_BOOL 70 -#define TK_TINYINT 71 -#define TK_SMALLINT 72 -#define TK_INT 73 -#define TK_INTEGER 74 -#define TK_BIGINT 75 -#define TK_FLOAT 76 -#define TK_DOUBLE 77 -#define TK_BINARY 78 -#define TK_TIMESTAMP 79 -#define TK_NCHAR 80 -#define TK_UNSIGNED 81 -#define TK_JSON 82 -#define TK_VARCHAR 83 -#define TK_MEDIUMBLOB 84 -#define TK_BLOB 85 -#define TK_VARBINARY 86 -#define TK_DECIMAL 87 -#define TK_SMA 88 -#define TK_INDEX 89 -#define TK_FULLTEXT 90 -#define TK_FUNCTION 91 -#define TK_INTERVAL 92 -#define TK_TOPIC 93 -#define TK_AS 94 -#define TK_MNODES 95 -#define TK_NK_FLOAT 96 -#define TK_NK_BOOL 97 -#define TK_NK_VARIABLE 98 -#define TK_BETWEEN 99 -#define TK_IS 100 -#define TK_NULL 101 -#define TK_NK_LT 102 -#define TK_NK_GT 103 -#define TK_NK_LE 104 -#define TK_NK_GE 105 -#define TK_NK_NE 106 -#define TK_NK_EQ 107 -#define TK_LIKE 108 -#define TK_MATCH 109 -#define TK_NMATCH 110 -#define TK_IN 111 -#define TK_FROM 112 -#define TK_JOIN 113 -#define TK_INNER 114 -#define TK_SELECT 115 -#define TK_DISTINCT 116 -#define TK_WHERE 117 -#define TK_PARTITION 118 -#define TK_BY 119 -#define TK_SESSION 120 -#define TK_STATE_WINDOW 121 -#define TK_SLIDING 122 -#define TK_FILL 123 -#define TK_VALUE 124 -#define TK_NONE 125 -#define TK_PREV 126 -#define TK_LINEAR 127 -#define TK_NEXT 128 -#define TK_GROUP 129 -#define TK_HAVING 130 -#define TK_ORDER 131 -#define TK_SLIMIT 132 -#define TK_SOFFSET 133 -#define TK_LIMIT 134 -#define TK_OFFSET 135 -#define TK_ASC 136 -#define TK_DESC 137 -#define TK_NULLS 138 -#define TK_FIRST 139 -#define TK_LAST 140 +#define TK_ALTER 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_PPS 22 +#define TK_TSERIES 23 +#define TK_STORAGE 24 +#define TK_STREAMS 25 +#define TK_QTIME 26 +#define TK_DBS 27 +#define TK_USERS 28 +#define TK_CONNS 29 +#define TK_STATE 30 +#define TK_CREATE 31 +#define TK_USER 32 +#define TK_NK_STRING 33 +#define TK_PRIVILEGE 34 +#define TK_DROP 35 +#define TK_SHOW 36 +#define TK_DNODE 37 +#define TK_PORT 38 +#define TK_NK_INTEGER 39 +#define TK_DNODES 40 +#define TK_NK_IPTOKEN 41 +#define TK_LOCAL 42 +#define TK_QNODE 43 +#define TK_ON 44 +#define TK_QNODES 45 +#define TK_DATABASE 46 +#define TK_DATABASES 47 +#define TK_USE 48 +#define TK_IF 49 +#define TK_NOT 50 +#define TK_EXISTS 51 +#define TK_BLOCKS 52 +#define TK_CACHE 53 +#define TK_CACHELAST 54 +#define TK_COMP 55 +#define TK_DAYS 56 +#define TK_FSYNC 57 +#define TK_MAXROWS 58 +#define TK_MINROWS 59 +#define TK_KEEP 60 +#define TK_PRECISION 61 +#define TK_QUORUM 62 +#define TK_REPLICA 63 +#define TK_TTL 64 +#define TK_WAL 65 +#define TK_VGROUPS 66 +#define TK_SINGLE_STABLE 67 +#define TK_STREAM_MODE 68 +#define TK_RETENTIONS 69 +#define TK_FILE_FACTOR 70 +#define TK_NK_FLOAT 71 +#define TK_TABLE 72 +#define TK_NK_LP 73 +#define TK_NK_RP 74 +#define TK_STABLE 75 +#define TK_TABLES 76 +#define TK_STABLES 77 +#define TK_ADD 78 +#define TK_COLUMN 79 +#define TK_MODIFY 80 +#define TK_RENAME 81 +#define TK_TAG 82 +#define TK_SET 83 +#define TK_NK_EQ 84 +#define TK_USING 85 +#define TK_TAGS 86 +#define TK_NK_DOT 87 +#define TK_NK_COMMA 88 +#define TK_COMMENT 89 +#define TK_BOOL 90 +#define TK_TINYINT 91 +#define TK_SMALLINT 92 +#define TK_INT 93 +#define TK_INTEGER 94 +#define TK_BIGINT 95 +#define TK_FLOAT 96 +#define TK_DOUBLE 97 +#define TK_BINARY 98 +#define TK_TIMESTAMP 99 +#define TK_NCHAR 100 +#define TK_UNSIGNED 101 +#define TK_JSON 102 +#define TK_VARCHAR 103 +#define TK_MEDIUMBLOB 104 +#define TK_BLOB 105 +#define TK_VARBINARY 106 +#define TK_DECIMAL 107 +#define TK_SMA 108 +#define TK_ROLLUP 109 +#define TK_INDEX 110 +#define TK_FULLTEXT 111 +#define TK_FUNCTION 112 +#define TK_INTERVAL 113 +#define TK_TOPIC 114 +#define TK_AS 115 +#define TK_MNODES 116 +#define TK_NK_BOOL 117 +#define TK_NK_VARIABLE 118 +#define TK_BETWEEN 119 +#define TK_IS 120 +#define TK_NULL 121 +#define TK_NK_LT 122 +#define TK_NK_GT 123 +#define TK_NK_LE 124 +#define TK_NK_GE 125 +#define TK_NK_NE 126 +#define TK_LIKE 127 +#define TK_MATCH 128 +#define TK_NMATCH 129 +#define TK_IN 130 +#define TK_FROM 131 +#define TK_JOIN 132 +#define TK_INNER 133 +#define TK_SELECT 134 +#define TK_DISTINCT 135 +#define TK_WHERE 136 +#define TK_PARTITION 137 +#define TK_BY 138 +#define TK_SESSION 139 +#define TK_STATE_WINDOW 140 +#define TK_SLIDING 141 +#define TK_FILL 142 +#define TK_VALUE 143 +#define TK_NONE 144 +#define TK_PREV 145 +#define TK_LINEAR 146 +#define TK_NEXT 147 +#define TK_GROUP 148 +#define TK_HAVING 149 +#define TK_ORDER 150 +#define TK_SLIMIT 151 +#define TK_SOFFSET 152 +#define TK_LIMIT 153 +#define TK_OFFSET 154 +#define TK_ASC 155 +#define TK_DESC 156 +#define TK_NULLS 157 +#define TK_FIRST 158 +#define TK_LAST 159 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 5d7174fc08..7508b71785 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -127,6 +127,13 @@ typedef struct SDropSuperTableStmt { bool ignoreNotExists; } SDropSuperTableStmt; +typedef struct SAlterTableStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + // todo +} SAlterTableStmt; + typedef struct SCreateUserStmt { ENodeType type; char useName[TSDB_USER_LEN]; @@ -158,6 +165,13 @@ typedef struct SDropDnodeStmt { int32_t port; } SDropDnodeStmt; +typedef struct SAlterDnodeStmt { + ENodeType type; + int32_t dnodeId; + char config[TSDB_DNODE_CONFIG_LEN]; + char value[TSDB_DNODE_VALUE_LEN]; +} SAlterDnodeStmt; + typedef struct SShowStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; @@ -215,6 +229,12 @@ typedef struct SDropTopicStmt { bool ignoreNotExists; } SDropTopicStmt; +typedef struct SAlterLocalStmt { + ENodeType type; + char config[TSDB_DNODE_CONFIG_LEN]; + char value[TSDB_DNODE_VALUE_LEN]; +} SAlterLocalStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 4ef70fc7ab..6825fe470a 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -85,6 +85,7 @@ typedef enum ENodeType { QUERY_NODE_DROP_TABLE_CLAUSE, QUERY_NODE_DROP_TABLE_STMT, QUERY_NODE_DROP_SUPER_TABLE_STMT, + QUERY_NODE_ALTER_TABLE_STMT, QUERY_NODE_SHOW_TABLES_STMT, // temp QUERY_NODE_SHOW_STABLES_STMT, QUERY_NODE_CREATE_USER_STMT, @@ -94,6 +95,7 @@ typedef enum ENodeType { QUERY_NODE_USE_DATABASE_STMT, QUERY_NODE_CREATE_DNODE_STMT, QUERY_NODE_DROP_DNODE_STMT, + QUERY_NODE_ALTER_DNODE_STMT, QUERY_NODE_SHOW_DNODES_STMT, QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, @@ -104,6 +106,7 @@ typedef enum ENodeType { QUERY_NODE_DROP_QNODE_STMT, QUERY_NODE_CREATE_TOPIC_STMT, QUERY_NODE_DROP_TOPIC_STMT, + QUERY_NODE_ALTER_LOCAL_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 1c61d738b5..b5cab30088 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -481,6 +481,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_PASSWD_EMPTY TAOS_DEF_ERROR_CODE(0, 0x2611) #define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612) #define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613) +#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614) #ifdef __cplusplus } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 75568019cb..0fabb00040 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -125,6 +125,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCreateDnodeStmt)); case QUERY_NODE_DROP_DNODE_STMT: return makeNode(type, sizeof(SDropDnodeStmt)); + case QUERY_NODE_ALTER_DNODE_STMT: + return makeNode(type, sizeof(SAlterDnodeStmt)); case QUERY_NODE_SHOW_DNODES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_VGROUPS_STMT: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 31d7331d0e..46bed1d61e 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -50,8 +50,10 @@ typedef enum EDatabaseOptionType { DB_OPTION_TTL, DB_OPTION_WAL, DB_OPTION_VGROUPS, - DB_OPTION_SINGLESTABLE, - DB_OPTION_STREAMMODE, + DB_OPTION_SINGLE_STABLE, + DB_OPTION_STREAM_MODE, + DB_OPTION_RETENTIONS, + DB_OPTION_FILE_FACTOR, DB_OPTION_MAX } EDatabaseOptionType; @@ -65,6 +67,11 @@ typedef enum ETableOptionType { TABLE_OPTION_MAX } ETableOptionType; +typedef struct SAlterOption { + int32_t type; + SToken val; +} SAlterOption; + extern SToken nil_token; void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt); @@ -110,13 +117,16 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight); SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); +SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions); SNode* createDefaultTableOptions(SAstCreateContext* pCxt); +SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); +SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pFuncs); SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment); SDataType createDataType(uint8_t type); SDataType createVarLenDataType(uint8_t type, const SToken* pLen); @@ -126,6 +136,11 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable); SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables); SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable); +SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions); +SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType); +SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName); +SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName); +SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal); SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName); SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDbName); SNode* createCreateUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, const SToken* pPassword); @@ -133,6 +148,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int SNode* createDropUserStmt(SAstCreateContext* pCxt, const SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); +SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName); @@ -140,6 +156,7 @@ SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName); SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); +SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 31c26e1e40..46775b7927 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -21,13 +21,15 @@ #include "parAst.h" } -%syntax_error { - if(TOKEN.z) { - generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); - } else { - generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); +%syntax_error { + if (pCxt->valid) { + if(TOKEN.z) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); + } else { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); + } + pCxt->valid = false; } - pCxt->valid = false; } %left OR. @@ -41,6 +43,27 @@ %left NK_CONCAT. //%right NK_BITNOT. +/************************************************ create/alter account *****************************************/ +cmd ::= ALTER ACCOUNT NK_ID account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } + +%type account_options { int32_t } +%destructor account_options { } +account_options ::= account_option. { } +account_options ::= account_options account_option. { } + +%type account_option { int32_t } +%destructor account_option { } +account_option ::= PASS literal. { } +account_option ::= PPS literal. { } +account_option ::= TSERIES literal. { } +account_option ::= STORAGE literal. { } +account_option ::= STREAMS literal. { } +account_option ::= QTIME literal. { } +account_option ::= DBS literal. { } +account_option ::= USERS literal. { } +account_option ::= CONNS literal. { } +account_option ::= STATE literal. { } + /************************************************ create/alter/drop/show user *****************************************/ cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); } @@ -48,12 +71,16 @@ cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); } cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } -/************************************************ create/drop/show dnode **********************************************/ +/************************************************ create/drop/alter/show dnode ****************************************/ cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); } cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } +cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, NULL); } +cmd ::= ALTER DNODE NK_INTEGER(A) NK_STRING(B) NK_STRING(C). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &A, &B, &C); } +cmd ::= ALTER ALL DNODES NK_STRING(A). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, NULL); } +cmd ::= ALTER ALL DNODES NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &A, &B); } %type dnode_endpoint { SToken } %destructor dnode_endpoint { } @@ -64,9 +91,13 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } +/************************************************ alter local *********************************************************/ +cmd ::= ALTER LOCAL NK_STRING(A). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, NULL); } +cmd ::= ALTER LOCAL NK_STRING(A) NK_STRING(B). { pCxt->pRootNode = createAlterLocalStmt(pCxt, &A, &B); } + /************************************************ create/drop qnode ***************************************************/ cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } -cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); } +cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } /************************************************ create/drop/show/use database ***************************************/ @@ -74,7 +105,7 @@ cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); } -cmd ::= ALTER DATABASE db_name(A) db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } +cmd ::= ALTER DATABASE db_name(A) alter_db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } %type not_exists_opt { bool } %destructor not_exists_opt { } @@ -102,20 +133,55 @@ db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). db_options(A) ::= db_options(B) TTL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TTL, &C); } db_options(A) ::= db_options(B) WAL NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL, &C); } db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); } -db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); } -db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); } +db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); } +db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAM_MODE, &C); } +db_options(A) ::= db_options(B) RETENTIONS NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, &C); } +db_options(A) ::= db_options(B) FILE_FACTOR NK_FLOAT(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FILE_FACTOR, &C); } + +alter_db_options(A) ::= alter_db_option(B). { A = createDefaultAlterDatabaseOptions(pCxt); A = setDatabaseOption(pCxt, A, B.type, &B.val); } +alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseOption(pCxt, B, C.type, &C.val); } + +%type alter_db_option { SAlterOption } +%destructor alter_db_option { } +alter_db_option(A) ::= BLOCKS NK_INTEGER(B). { A.type = DB_OPTION_BLOCKS; A.val = B; } +alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } +alter_db_option(A) ::= KEEP NK_INTEGER(B). { A.type = DB_OPTION_KEEP; A.val = B; } +alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } +alter_db_option(A) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.val = B; } +alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; } /************************************************ create/drop/show table/stable ***************************************/ cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B) - NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);} -cmd ::= CREATE TABLE multi_create_clause(A). { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, A);} + NK_LP column_def_list(C) NK_RP tags_def_opt(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); } +cmd ::= CREATE TABLE multi_create_clause(A). { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, A); } cmd ::= CREATE STABLE not_exists_opt(A) full_table_name(B) - NK_LP column_def_list(C) NK_RP tags_def(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E);} + NK_LP column_def_list(C) NK_RP tags_def(D) table_options(E). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, B, C, D, E); } cmd ::= DROP TABLE multi_drop_clause(A). { pCxt->pRootNode = createDropTableStmt(pCxt, A); } cmd ::= DROP STABLE exists_opt(A) full_table_name(B). { pCxt->pRootNode = createDropSuperTableStmt(pCxt, A, B); } cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } cmd ::= SHOW STABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } +cmd ::= ALTER TABLE alter_table_clause(A). { pCxt->pRootNode = A; } +cmd ::= ALTER STABLE alter_table_clause(A). { pCxt->pRootNode = A; } + +alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTableOption(pCxt, B, C); } +alter_table_clause(A) ::= + full_table_name(B) ADD COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } +alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C); } +alter_table_clause(A) ::= + full_table_name(B) MODIFY COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } +alter_table_clause(A) ::= + full_table_name(B) RENAME COLUMN column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, &D); } +alter_table_clause(A) ::= + full_table_name(B) ADD TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } +alter_table_clause(A) ::= full_table_name(B) DROP TAG column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C); } +alter_table_clause(A) ::= + full_table_name(B) MODIFY TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } +alter_table_clause(A) ::= + full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, &D); } +alter_table_clause(A) ::= + full_table_name(B) SET TAG column_name(C) NK_EQ literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } + %type multi_create_clause { SNodeList* } %destructor multi_create_clause { nodesDestroyList($$); } multi_create_clause(A) ::= create_subtable_clause(B). { A = createNodeList(pCxt, B); } @@ -183,11 +249,21 @@ tags_def_opt(A) ::= tags_def(B). %destructor tags_def { nodesDestroyList($$); } tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; } -table_options(A) ::= . { A = createDefaultTableOptions(pCxt);} +table_options(A) ::= . { A = createDefaultTableOptions(pCxt); } table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); } table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); } table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); } table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableSmaOption(pCxt, B, C); } +table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableRollupOption(pCxt, B, C); } + +alter_table_options(A) ::= alter_table_option(B). { A = createDefaultAlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val); } +alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableOption(pCxt, B, C.type, &C.val); } + +%type alter_table_option { SAlterOption } +%destructor alter_table_option { } +alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; } +alter_table_option(A) ::= KEEP NK_INTEGER(B). { A.type = TABLE_OPTION_KEEP; A.val = B; } +alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; } %type col_name_list { SNodeList* } %destructor col_name_list { nodesDestroyList($$); } @@ -196,6 +272,13 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C). col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); } +%type func_name_list { SNodeList* } +%destructor func_name_list { nodesDestroyList($$); } +func_name_list(A) ::= func_name(B). { A = createNodeList(pCxt, B); } +func_name_list(A) ::= func_name_list(B) NK_COMMA col_name(C). { A = addNodeToList(pCxt, B, C); } + +func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); } + /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } cmd ::= CREATE FULLTEXT INDEX @@ -546,7 +629,7 @@ query_expression_body(A) ::= query_primary(A) ::= query_specification(B). { A = B; } //query_primary(A) ::= // NK_LP query_expression_body(B) -// order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { A = B;} +// order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP. { A = B; } %type order_by_clause_opt { SNodeList* } %destructor order_by_clause_opt { nodesDestroyList($$); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 034346362c..764f545ce3 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -246,6 +246,16 @@ static SDatabaseOptions* setDbStreamMode(SAstCreateContext* pCxt, SDatabaseOptio return pOptions; } +static SDatabaseOptions* setDbRetentions(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { + // todo + return pOptions; +} + +static SDatabaseOptions* setDbFileFactor(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { + // todo + return pOptions; +} + static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_BLOCKS] = setDbBlocks; setDbOptionFuncs[DB_OPTION_CACHE] = setDbCache; @@ -262,8 +272,10 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_TTL] = setDbTtl; setDbOptionFuncs[DB_OPTION_WAL] = setDbWal; setDbOptionFuncs[DB_OPTION_VGROUPS] = setDbVgroups; - setDbOptionFuncs[DB_OPTION_SINGLESTABLE] = setDbSingleStable; - setDbOptionFuncs[DB_OPTION_STREAMMODE] = setDbStreamMode; + setDbOptionFuncs[DB_OPTION_SINGLE_STABLE] = setDbSingleStable; + setDbOptionFuncs[DB_OPTION_STREAM_MODE] = setDbStreamMode; + setDbOptionFuncs[DB_OPTION_RETENTIONS] = setDbRetentions; + setDbOptionFuncs[DB_OPTION_FILE_FACTOR] = setDbFileFactor; } static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { @@ -772,6 +784,29 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } +SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt) { + SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + pOptions->numOfBlocks = -1; + pOptions->cacheBlockSize = -1; + pOptions->cachelast = -1; + pOptions->compressionLevel = -1; + pOptions->daysPerFile = -1; + pOptions->fsyncPeriod = -1; + pOptions->maxRowsPerBlock = -1; + pOptions->minRowsPerBlock = -1; + pOptions->keep = -1; + pOptions->precision = -1; + pOptions->quorum = -1; + pOptions->replica = -1; + pOptions->ttl = -1; + pOptions->walLevel = -1; + pOptions->numOfVgroups = -1; + pOptions->singleStable = -1; + pOptions->streamMode = -1; + return (SNode*)pOptions; +} + SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal) { return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal); } @@ -818,6 +853,14 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } +SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt) { + STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + pOptions->keep = -1; + pOptions->ttl = -1; + return (SNode*)pOptions; +} + SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal) { return (SNode*)setTableOptionFuncs[type](pCxt, (STableOptions*)pOptions, pVal); } @@ -827,6 +870,11 @@ SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pS return pOptions; } +SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pFuncs) { + // todo + return pOptions; +} + SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment) { SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF); CHECK_OUT_OF_MEM(pCol); @@ -912,6 +960,26 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S return (SNode*)pStmt; } +SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { + +} + +SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType) { + +} + +SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName) { + +} + +SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName) { + +} + +SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal) { + +} + SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { SUseDatabaseStmt* pStmt = (SUseDatabaseStmt*)nodesMakeNode(QUERY_NODE_USE_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); @@ -1009,6 +1077,17 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { return (SNode*)pStmt; } +SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue) { + SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnode->z, NULL, 10); + trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); + if (NULL != pValue) { + trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value)); + } + return (SNode*)pStmt; +} + SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions) { if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { return NULL; @@ -1077,3 +1156,13 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const pStmt->ignoreNotExists = ignoreNotExists; return (SNode*)pStmt; } + +SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) { + SAlterLocalStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); + CHECK_OUT_OF_MEM(pStmt); + trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); + if (NULL != pValue) { + trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value)); + } + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 2d58d4e1e3..4549660c76 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -28,6 +28,7 @@ typedef struct SKeyword { // keywords in sql string static SKeyword keywordTable[] = { + {"ACCOUNT", TK_ACCOUNT}, {"ALL", TK_ALL}, {"ALTER", TK_ALTER}, {"AND", TK_AND}, @@ -168,7 +169,6 @@ static SKeyword keywordTable[] = { // {"SCORES", TK_SCORES}, // {"GRANTS", TK_GRANTS}, // {"DOT", TK_DOT}, - // {"ACCOUNT", TK_ACCOUNT}, // {"DESCRIBE", TK_DESCRIBE}, // {"SYNCDB", TK_SYNCDB}, // {"LOCAL", TK_LOCAL}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index af7a38b702..e852a21c4e 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -962,6 +962,25 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS return doTranslateDropSuperTable(pCxt, &tableName, pStmt->ignoreNotExists); } +static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { + SMAltertbReq alterReq = {0}; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_STB; + pCxt->pCmdMsg->msgLen = tSerializeSMAlterStbReq(NULL, 0, &alterReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMAlterStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* pStmt) { SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); @@ -1099,6 +1118,28 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt return TSDB_CODE_SUCCESS; } +static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pStmt) { + SMCfgDnodeReq cfgReq = {0}; + cfgReq.dnodeId = pStmt->dnodeId; + strcpy(cfgReq.config, pStmt->config); + strcpy(cfgReq.value, pStmt->value); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CONFIG_DNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCfgDnodeReq(NULL, 0, &cfgReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCfgDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &cfgReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t nodeTypeToShowType(ENodeType nt) { switch (nt) { case QUERY_NODE_SHOW_DATABASES_STMT: @@ -1364,6 +1405,11 @@ static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt return TSDB_CODE_SUCCESS; } +static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pStmt) { + // todo + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1388,6 +1434,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_SUPER_TABLE_STMT: code = translateDropSuperTable(pCxt, (SDropSuperTableStmt*)pNode); break; + case QUERY_NODE_ALTER_TABLE_STMT: + code = translateAlterTable(pCxt, (SAlterTableStmt*)pNode); + break; case QUERY_NODE_CREATE_USER_STMT: code = translateCreateUser(pCxt, (SCreateUserStmt*)pNode); break; @@ -1406,6 +1455,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_DNODE_STMT: code = translateDropDnode(pCxt, (SDropDnodeStmt*)pNode); break; + case QUERY_NODE_ALTER_DNODE_STMT: + code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode); + break; case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_STABLES_STMT: case QUERY_NODE_SHOW_USERS_STMT: @@ -1436,6 +1488,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_TOPIC_STMT: code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode); break; + case QUERY_NODE_ALTER_LOCAL_STMT: + code = translateAlterLocal(pCxt, (SAlterLocalStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index aa2516e2b9..69c2380b45 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -46,17 +46,19 @@ static char* getSyntaxErrFormat(int32_t errCode) { case TSDB_CODE_PAR_NOT_SINGLE_GROUP: return "Not a single-group group function"; case TSDB_CODE_PAR_TAGS_NOT_MATCHED: - return "tags number not matched"; + return "Tags number not matched"; case TSDB_CODE_PAR_INVALID_TAG_NAME: - return "invalid tag name : %s"; + return "Invalid tag name : %s"; case TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG: - return "name or password too long"; + return "Name or password too long"; case TSDB_CODE_PAR_PASSWD_EMPTY: - return "password can not be empty"; + return "Password can not be empty"; case TSDB_CODE_PAR_INVALID_PORT: - return "port should be an integer that is less than 65535 and greater than 0"; + return "Port should be an integer that is less than 65535 and greater than 0"; case TSDB_CODE_PAR_INVALID_ENDPOINT: - return "endpoint should be in the format of 'fqdn:port'"; + return "Endpoint should be in the format of 'fqdn:port'"; + case TSDB_CODE_PAR_EXPRIE_STATEMENT: + return "This statement is no longer supported"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 18b507c1b0..4f2149ac88 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 220 +#define YYNOCODE 248 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SNodeList* yy24; - bool yy97; - SToken yy129; - SDataType yy224; - ENullOrder yy257; - EOperatorType yy260; - EFillMode yy294; - EJoinType yy332; - EOrder yy378; - SNode* yy432; + SNode* yy168; + SDataType yy208; + EJoinType yy228; + SToken yy241; + EOrder yy258; + EFillMode yy262; + int32_t yy324; + SAlterOption yy349; + ENullOrder yy425; + SNodeList* yy440; + bool yy457; + EOperatorType yy476; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +131,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 333 -#define YYNRULE 255 -#define YYNTOKEN 141 -#define YY_MAX_SHIFT 332 -#define YY_MIN_SHIFTREDUCE 501 -#define YY_MAX_SHIFTREDUCE 755 -#define YY_ERROR_ACTION 756 -#define YY_ACCEPT_ACTION 757 -#define YY_NO_ACTION 758 -#define YY_MIN_REDUCE 759 -#define YY_MAX_REDUCE 1013 +#define YYNSTATE 400 +#define YYNRULE 305 +#define YYNTOKEN 160 +#define YY_MAX_SHIFT 399 +#define YY_MIN_SHIFTREDUCE 608 +#define YY_MAX_SHIFTREDUCE 912 +#define YY_ERROR_ACTION 913 +#define YY_ACCEPT_ACTION 914 +#define YY_NO_ACTION 915 +#define YY_MIN_REDUCE 916 +#define YY_MAX_REDUCE 1220 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,322 +208,366 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1012) +#define YY_ACTTAB_COUNT (1150) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 163, 856, 240, 855, 272, 162, 272, 200, 856, 814, - /* 10 */ 854, 878, 31, 29, 27, 26, 25, 65, 880, 817, - /* 20 */ 178, 817, 256, 176, 906, 31, 29, 27, 26, 25, - /* 30 */ 779, 878, 40, 705, 55, 819, 71, 63, 880, 62, - /* 40 */ 155, 229, 66, 812, 243, 809, 906, 79, 938, 939, - /* 50 */ 626, 943, 878, 155, 175, 258, 511, 863, 259, 891, - /* 60 */ 511, 638, 58, 892, 895, 931, 512, 513, 208, 165, - /* 70 */ 927, 77, 321, 320, 319, 318, 317, 316, 315, 314, - /* 80 */ 313, 312, 311, 310, 309, 308, 307, 306, 305, 775, - /* 90 */ 959, 27, 26, 25, 31, 29, 27, 26, 25, 23, - /* 100 */ 170, 271, 656, 657, 658, 659, 660, 661, 662, 664, - /* 110 */ 665, 666, 23, 170, 271, 656, 657, 658, 659, 660, - /* 120 */ 661, 662, 664, 665, 666, 31, 29, 27, 26, 25, - /* 130 */ 10, 321, 320, 319, 318, 317, 316, 315, 314, 313, - /* 140 */ 312, 311, 310, 309, 308, 307, 306, 305, 565, 295, - /* 150 */ 294, 293, 569, 292, 571, 572, 291, 574, 288, 804, - /* 160 */ 580, 285, 582, 583, 282, 279, 24, 117, 256, 196, - /* 170 */ 906, 992, 626, 195, 624, 256, 177, 906, 194, 856, - /* 180 */ 193, 854, 83, 878, 991, 83, 258, 233, 990, 244, - /* 190 */ 891, 180, 271, 57, 892, 895, 931, 54, 182, 190, - /* 200 */ 154, 927, 51, 819, 71, 272, 192, 191, 269, 301, - /* 210 */ 819, 71, 992, 300, 805, 243, 624, 906, 751, 752, - /* 220 */ 817, 10, 234, 878, 298, 82, 258, 945, 302, 990, - /* 230 */ 891, 757, 627, 58, 892, 895, 931, 256, 186, 906, - /* 240 */ 165, 927, 77, 228, 942, 878, 201, 299, 258, 628, - /* 250 */ 30, 28, 891, 201, 113, 58, 892, 895, 931, 617, - /* 260 */ 221, 958, 165, 927, 1004, 184, 256, 615, 906, 172, - /* 270 */ 629, 235, 230, 965, 878, 304, 878, 258, 12, 272, - /* 280 */ 297, 891, 270, 881, 58, 892, 895, 931, 992, 9, - /* 290 */ 8, 165, 927, 1004, 817, 256, 272, 906, 1, 130, - /* 300 */ 83, 82, 988, 878, 181, 990, 258, 856, 40, 854, - /* 310 */ 891, 817, 112, 58, 892, 895, 931, 273, 21, 813, - /* 320 */ 165, 927, 1004, 30, 28, 698, 272, 663, 189, 183, - /* 330 */ 667, 949, 617, 99, 616, 618, 621, 114, 30, 28, - /* 340 */ 615, 817, 172, 329, 328, 803, 247, 617, 256, 674, - /* 350 */ 906, 12, 722, 83, 140, 615, 878, 172, 161, 258, - /* 360 */ 141, 72, 244, 891, 30, 28, 144, 892, 895, 49, - /* 370 */ 945, 1, 945, 617, 84, 225, 720, 721, 723, 724, - /* 380 */ 810, 615, 226, 172, 304, 992, 7, 941, 6, 940, - /* 390 */ 273, 697, 12, 864, 259, 256, 248, 906, 82, 820, - /* 400 */ 71, 136, 990, 878, 847, 273, 258, 616, 618, 621, - /* 410 */ 891, 240, 1, 59, 892, 895, 931, 256, 107, 906, - /* 420 */ 930, 927, 616, 618, 621, 878, 65, 217, 258, 950, - /* 430 */ 693, 273, 891, 251, 69, 59, 892, 895, 931, 207, - /* 440 */ 244, 83, 254, 927, 213, 961, 63, 211, 616, 618, - /* 450 */ 621, 83, 94, 30, 28, 257, 110, 938, 239, 241, - /* 460 */ 238, 249, 617, 992, 719, 617, 30, 28, 693, 93, - /* 470 */ 615, 60, 172, 615, 246, 617, 82, 104, 907, 256, - /* 480 */ 990, 906, 668, 615, 102, 172, 116, 878, 255, 32, - /* 490 */ 258, 2, 754, 755, 891, 635, 624, 73, 892, 895, - /* 500 */ 252, 7, 32, 696, 607, 9, 8, 30, 28, 185, - /* 510 */ 256, 32, 906, 632, 7, 885, 617, 625, 878, 85, - /* 520 */ 273, 258, 883, 273, 615, 891, 172, 631, 59, 892, - /* 530 */ 895, 931, 214, 273, 245, 1005, 928, 616, 618, 621, - /* 540 */ 616, 618, 621, 197, 198, 256, 199, 906, 39, 653, - /* 550 */ 616, 618, 621, 878, 202, 1, 258, 171, 90, 122, - /* 560 */ 891, 215, 209, 148, 892, 895, 120, 256, 630, 906, - /* 570 */ 264, 134, 160, 127, 273, 878, 558, 67, 258, 222, - /* 580 */ 68, 216, 891, 69, 992, 148, 892, 895, 256, 218, - /* 590 */ 906, 616, 618, 621, 629, 553, 878, 82, 95, 258, - /* 600 */ 962, 990, 60, 891, 586, 133, 147, 892, 895, 590, - /* 610 */ 256, 277, 906, 61, 802, 227, 68, 219, 878, 325, - /* 620 */ 972, 258, 132, 262, 256, 891, 906, 100, 73, 892, - /* 630 */ 895, 621, 878, 224, 971, 258, 169, 236, 256, 891, - /* 640 */ 906, 103, 148, 892, 895, 56, 878, 164, 128, 258, - /* 650 */ 173, 5, 256, 891, 906, 952, 148, 892, 895, 237, - /* 660 */ 878, 75, 106, 258, 301, 223, 1006, 891, 300, 108, - /* 670 */ 146, 892, 895, 240, 268, 4, 220, 64, 256, 96, - /* 680 */ 906, 693, 628, 302, 595, 946, 878, 33, 65, 258, - /* 690 */ 253, 69, 256, 891, 906, 109, 149, 892, 895, 70, - /* 700 */ 878, 989, 299, 258, 1007, 250, 68, 891, 63, 166, - /* 710 */ 142, 892, 895, 256, 17, 906, 115, 242, 78, 938, - /* 720 */ 939, 878, 943, 913, 258, 862, 260, 256, 891, 906, - /* 730 */ 261, 150, 892, 895, 861, 878, 265, 174, 258, 266, - /* 740 */ 124, 256, 891, 906, 267, 143, 892, 895, 48, 878, - /* 750 */ 135, 818, 258, 50, 275, 256, 891, 906, 137, 151, - /* 760 */ 892, 895, 131, 878, 872, 138, 258, 332, 152, 256, - /* 770 */ 891, 906, 153, 903, 892, 895, 139, 878, 778, 871, - /* 780 */ 258, 870, 187, 256, 891, 906, 188, 902, 892, 895, - /* 790 */ 869, 878, 808, 807, 258, 777, 774, 256, 891, 906, - /* 800 */ 768, 901, 892, 895, 763, 878, 868, 859, 258, 87, - /* 810 */ 806, 256, 891, 906, 524, 158, 892, 895, 776, 878, - /* 820 */ 773, 205, 258, 203, 204, 256, 891, 906, 767, 157, - /* 830 */ 892, 895, 766, 878, 762, 761, 258, 210, 760, 867, - /* 840 */ 891, 866, 212, 159, 892, 895, 36, 858, 256, 42, - /* 850 */ 906, 97, 98, 3, 240, 14, 878, 15, 74, 258, - /* 860 */ 101, 105, 256, 891, 906, 43, 156, 892, 895, 65, - /* 870 */ 878, 32, 231, 258, 718, 712, 92, 891, 34, 37, - /* 880 */ 145, 892, 895, 711, 76, 44, 11, 232, 690, 63, - /* 890 */ 206, 883, 689, 91, 19, 45, 20, 111, 745, 80, - /* 900 */ 938, 939, 740, 943, 35, 739, 31, 29, 27, 26, - /* 910 */ 25, 22, 81, 167, 16, 744, 41, 743, 168, 89, - /* 920 */ 8, 31, 29, 27, 26, 25, 118, 636, 13, 31, - /* 930 */ 29, 27, 26, 25, 654, 18, 263, 857, 119, 716, - /* 940 */ 121, 123, 46, 126, 125, 47, 88, 619, 51, 276, - /* 950 */ 86, 179, 38, 280, 882, 579, 587, 129, 278, 274, - /* 960 */ 584, 281, 283, 581, 284, 286, 575, 287, 289, 573, - /* 970 */ 564, 290, 52, 53, 594, 296, 593, 578, 638, 592, - /* 980 */ 303, 577, 522, 543, 576, 542, 541, 536, 540, 539, - /* 990 */ 538, 537, 535, 534, 533, 772, 532, 531, 530, 529, - /* 1000 */ 528, 527, 322, 323, 765, 764, 326, 327, 324, 759, - /* 1010 */ 330, 331, + /* 0 */ 951, 1087, 1087, 42, 297, 914, 1199, 208, 24, 140, + /* 10 */ 1070, 312, 79, 31, 29, 27, 26, 25, 916, 1198, + /* 20 */ 1010, 94, 917, 1197, 196, 211, 89, 31, 29, 27, + /* 30 */ 26, 25, 213, 352, 1018, 1061, 1063, 1085, 1085, 77, + /* 40 */ 76, 75, 74, 73, 72, 71, 70, 69, 68, 226, + /* 50 */ 991, 190, 339, 338, 337, 336, 335, 334, 333, 332, + /* 60 */ 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, + /* 70 */ 321, 1199, 100, 30, 28, 795, 31, 29, 27, 26, + /* 80 */ 25, 205, 352, 1053, 107, 818, 10, 1060, 1197, 297, + /* 90 */ 781, 353, 278, 195, 774, 1071, 242, 989, 1058, 243, + /* 100 */ 772, 77, 76, 75, 74, 73, 72, 71, 70, 69, + /* 110 */ 68, 12, 1015, 82, 190, 31, 29, 27, 26, 25, + /* 120 */ 23, 203, 243, 813, 814, 815, 816, 817, 819, 821, + /* 130 */ 822, 823, 773, 80, 1, 774, 31, 29, 27, 26, + /* 140 */ 25, 772, 280, 103, 1145, 1146, 320, 1150, 818, 713, + /* 150 */ 375, 374, 373, 717, 372, 719, 720, 371, 722, 368, + /* 160 */ 398, 728, 365, 730, 731, 362, 359, 97, 980, 1060, + /* 170 */ 908, 909, 854, 773, 352, 210, 783, 1098, 775, 778, + /* 180 */ 1058, 9, 8, 23, 203, 272, 813, 814, 815, 816, + /* 190 */ 817, 819, 821, 822, 823, 108, 1113, 385, 795, 380, + /* 200 */ 209, 398, 384, 294, 108, 383, 1060, 381, 89, 296, + /* 210 */ 382, 785, 214, 1085, 252, 1098, 1017, 1058, 282, 775, + /* 220 */ 778, 60, 1099, 1102, 1138, 353, 6, 10, 189, 1134, + /* 230 */ 64, 30, 28, 855, 1113, 1088, 635, 351, 1060, 205, + /* 240 */ 1199, 281, 250, 353, 347, 346, 1015, 296, 64, 1062, + /* 250 */ 253, 1085, 774, 107, 831, 379, 42, 1197, 772, 61, + /* 260 */ 1099, 1102, 1138, 286, 1015, 155, 198, 1134, 102, 12, + /* 270 */ 78, 1085, 1199, 1011, 1113, 1098, 343, 353, 1098, 154, + /* 280 */ 136, 294, 1012, 1157, 850, 107, 259, 1165, 108, 1197, + /* 290 */ 773, 21, 1, 171, 1113, 786, 1045, 1113, 1015, 820, + /* 300 */ 267, 294, 824, 853, 281, 59, 135, 296, 151, 990, + /* 310 */ 296, 1085, 353, 1098, 1085, 850, 282, 307, 398, 179, + /* 320 */ 1099, 1102, 61, 1099, 1102, 1138, 212, 287, 1113, 198, + /* 330 */ 1134, 102, 1113, 1015, 89, 294, 775, 778, 1199, 294, + /* 340 */ 636, 306, 1017, 219, 258, 296, 58, 119, 1098, 1085, + /* 350 */ 1166, 107, 988, 635, 271, 1197, 83, 61, 1099, 1102, + /* 360 */ 1138, 637, 215, 1007, 198, 1134, 1211, 1113, 377, 317, + /* 370 */ 89, 1060, 376, 316, 294, 1172, 108, 1098, 1017, 377, + /* 380 */ 296, 862, 1059, 376, 1085, 285, 221, 783, 218, 217, + /* 390 */ 122, 355, 61, 1099, 1102, 1138, 1113, 378, 318, 198, + /* 400 */ 1134, 1211, 1152, 294, 1006, 946, 30, 28, 378, 296, + /* 410 */ 1195, 784, 317, 1085, 205, 289, 316, 315, 314, 1149, + /* 420 */ 1152, 61, 1099, 1102, 1138, 1152, 353, 774, 198, 1134, + /* 430 */ 1211, 308, 1098, 772, 928, 30, 28, 1148, 386, 1156, + /* 440 */ 1085, 318, 1147, 205, 12, 255, 927, 1015, 353, 926, + /* 450 */ 353, 1113, 925, 152, 1098, 216, 774, 320, 294, 87, + /* 460 */ 315, 314, 772, 57, 296, 773, 278, 1, 1085, 1015, + /* 470 */ 1085, 1015, 51, 1113, 278, 53, 62, 1099, 1102, 1138, + /* 480 */ 294, 290, 1085, 1137, 1134, 1085, 296, 82, 1085, 1008, + /* 490 */ 1085, 918, 278, 398, 773, 82, 7, 313, 62, 1099, + /* 500 */ 1102, 1138, 27, 26, 25, 292, 1134, 80, 1004, 117, + /* 510 */ 293, 775, 778, 82, 101, 80, 876, 104, 1145, 1146, + /* 520 */ 248, 1150, 398, 116, 20, 105, 1145, 1146, 282, 1150, + /* 530 */ 65, 1000, 284, 80, 31, 29, 27, 26, 25, 1002, + /* 540 */ 775, 778, 924, 133, 1145, 277, 266, 276, 923, 43, + /* 550 */ 1199, 998, 114, 30, 28, 295, 1098, 108, 30, 28, + /* 560 */ 231, 205, 922, 107, 9, 8, 205, 1197, 30, 28, + /* 570 */ 981, 264, 273, 268, 774, 1113, 205, 1098, 1085, 774, + /* 580 */ 772, 810, 294, 161, 1085, 772, 159, 113, 296, 774, + /* 590 */ 921, 111, 1085, 137, 22, 772, 1113, 920, 1085, 919, + /* 600 */ 96, 1099, 1102, 294, 31, 29, 27, 26, 25, 296, + /* 610 */ 1054, 127, 773, 1085, 7, 163, 204, 773, 162, 7, + /* 620 */ 1092, 185, 1099, 1102, 781, 125, 1085, 773, 825, 1, + /* 630 */ 911, 912, 238, 1085, 1090, 1085, 792, 283, 1212, 764, + /* 640 */ 398, 130, 32, 1098, 237, 398, 249, 145, 279, 236, + /* 650 */ 32, 235, 302, 32, 150, 398, 1168, 706, 775, 778, + /* 660 */ 941, 143, 1113, 775, 778, 1098, 84, 1114, 85, 294, + /* 670 */ 232, 87, 397, 775, 778, 296, 2, 139, 781, 1085, + /* 680 */ 234, 233, 701, 227, 1113, 395, 1098, 62, 1099, 1102, + /* 690 */ 1138, 294, 939, 388, 738, 1135, 65, 296, 789, 744, + /* 700 */ 743, 1085, 88, 165, 260, 1113, 164, 1098, 85, 185, + /* 710 */ 1099, 1102, 294, 86, 87, 734, 85, 239, 296, 110, + /* 720 */ 228, 782, 1085, 1098, 167, 391, 1113, 166, 176, 357, + /* 730 */ 184, 1099, 1102, 294, 240, 788, 241, 41, 1098, 296, + /* 740 */ 244, 174, 1113, 1085, 115, 175, 95, 787, 251, 294, + /* 750 */ 256, 96, 1099, 1102, 254, 296, 118, 1113, 109, 1085, + /* 760 */ 1098, 274, 202, 786, 294, 257, 1179, 185, 1099, 1102, + /* 770 */ 296, 265, 1169, 300, 1085, 778, 1098, 206, 262, 1113, + /* 780 */ 197, 1098, 185, 1099, 1102, 123, 294, 126, 1178, 1213, + /* 790 */ 1159, 5, 296, 261, 99, 1113, 1085, 275, 4, 131, + /* 800 */ 1113, 850, 294, 129, 183, 1099, 1102, 294, 296, 1098, + /* 810 */ 81, 785, 1085, 296, 1153, 33, 132, 1085, 199, 291, + /* 820 */ 186, 1099, 1102, 1214, 1196, 177, 1099, 1102, 1113, 138, + /* 830 */ 288, 17, 1120, 1098, 1069, 294, 298, 299, 1098, 1068, + /* 840 */ 303, 296, 207, 147, 108, 1085, 52, 304, 305, 170, + /* 850 */ 50, 350, 1113, 187, 1099, 1102, 172, 1113, 390, 294, + /* 860 */ 153, 1098, 310, 1016, 294, 296, 225, 354, 1005, 1085, + /* 870 */ 296, 955, 158, 399, 1085, 1079, 1098, 178, 1099, 1102, + /* 880 */ 1113, 1001, 188, 1099, 1102, 160, 169, 294, 90, 91, + /* 890 */ 1003, 393, 67, 296, 999, 1113, 387, 1085, 92, 93, + /* 900 */ 168, 180, 294, 173, 954, 1110, 1099, 1102, 296, 181, + /* 910 */ 1078, 1077, 1085, 1098, 229, 230, 1098, 1076, 994, 993, + /* 920 */ 1109, 1099, 1102, 385, 953, 380, 38, 950, 384, 37, + /* 930 */ 938, 383, 1113, 381, 933, 1113, 382, 1075, 1066, 294, + /* 940 */ 992, 112, 294, 650, 952, 296, 1098, 949, 296, 1085, + /* 950 */ 246, 245, 1085, 247, 937, 936, 932, 1108, 1099, 1102, + /* 960 */ 193, 1099, 1102, 1074, 1073, 1113, 36, 1065, 1098, 120, + /* 970 */ 121, 44, 294, 3, 32, 14, 124, 39, 296, 875, + /* 980 */ 98, 128, 1085, 270, 1098, 269, 1090, 1113, 869, 1098, + /* 990 */ 192, 1099, 1102, 45, 294, 868, 46, 15, 34, 11, + /* 1000 */ 296, 47, 847, 1113, 1085, 897, 846, 902, 1113, 134, + /* 1010 */ 294, 896, 194, 1099, 1102, 294, 296, 879, 200, 19, + /* 1020 */ 1085, 296, 901, 35, 16, 1085, 106, 900, 191, 1099, + /* 1030 */ 1102, 201, 8, 182, 1099, 1102, 811, 141, 13, 263, + /* 1040 */ 877, 878, 880, 881, 793, 142, 18, 1064, 873, 144, + /* 1050 */ 146, 48, 148, 149, 301, 49, 712, 40, 311, 54, + /* 1060 */ 53, 742, 55, 56, 741, 740, 309, 648, 319, 671, + /* 1070 */ 670, 948, 669, 668, 667, 666, 662, 665, 664, 663, + /* 1080 */ 661, 660, 935, 659, 658, 657, 934, 656, 655, 654, + /* 1090 */ 653, 340, 341, 344, 345, 929, 348, 342, 349, 996, + /* 1100 */ 1089, 156, 157, 66, 356, 735, 220, 360, 363, 366, + /* 1110 */ 727, 726, 369, 725, 749, 748, 724, 747, 995, 679, + /* 1120 */ 678, 947, 677, 222, 676, 942, 675, 674, 940, 223, + /* 1130 */ 358, 389, 732, 361, 224, 729, 723, 364, 931, 367, + /* 1140 */ 394, 392, 930, 396, 776, 915, 721, 370, 915, 63, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 158, 163, 146, 165, 146, 160, 146, 149, 163, 149, - /* 10 */ 165, 169, 12, 13, 14, 15, 16, 161, 176, 161, - /* 20 */ 158, 161, 161, 150, 163, 12, 13, 14, 15, 16, - /* 30 */ 0, 169, 148, 14, 145, 162, 163, 181, 176, 155, - /* 40 */ 40, 180, 153, 159, 161, 156, 163, 191, 192, 193, - /* 50 */ 31, 195, 169, 40, 168, 172, 21, 171, 172, 176, - /* 60 */ 21, 61, 179, 180, 181, 182, 31, 32, 29, 186, - /* 70 */ 187, 188, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, - /* 90 */ 207, 14, 15, 16, 12, 13, 14, 15, 16, 99, - /* 100 */ 100, 31, 102, 103, 104, 105, 106, 107, 108, 109, - /* 110 */ 110, 111, 99, 100, 31, 102, 103, 104, 105, 106, - /* 120 */ 107, 108, 109, 110, 111, 12, 13, 14, 15, 16, - /* 130 */ 60, 42, 43, 44, 45, 46, 47, 48, 49, 50, - /* 140 */ 51, 52, 53, 54, 55, 56, 57, 58, 70, 71, - /* 150 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 0, - /* 160 */ 82, 83, 84, 85, 86, 87, 183, 184, 161, 26, - /* 170 */ 163, 198, 31, 30, 31, 161, 160, 163, 35, 163, - /* 180 */ 37, 165, 115, 169, 211, 115, 172, 180, 215, 175, - /* 190 */ 176, 150, 31, 179, 180, 181, 182, 60, 150, 56, - /* 200 */ 186, 187, 65, 162, 163, 146, 63, 64, 149, 50, - /* 210 */ 162, 163, 198, 54, 0, 161, 31, 163, 136, 137, - /* 220 */ 161, 60, 31, 169, 66, 211, 172, 177, 69, 215, - /* 230 */ 176, 141, 31, 179, 180, 181, 182, 161, 95, 163, - /* 240 */ 186, 187, 188, 92, 194, 169, 39, 88, 172, 31, - /* 250 */ 12, 13, 176, 39, 200, 179, 180, 181, 182, 21, - /* 260 */ 206, 207, 186, 187, 188, 175, 161, 29, 163, 31, - /* 270 */ 31, 120, 121, 197, 169, 39, 169, 172, 40, 146, - /* 280 */ 164, 176, 149, 176, 179, 180, 181, 182, 198, 1, - /* 290 */ 2, 186, 187, 188, 161, 161, 146, 163, 60, 149, - /* 300 */ 115, 211, 197, 169, 160, 215, 172, 163, 148, 165, - /* 310 */ 176, 161, 94, 179, 180, 181, 182, 79, 99, 159, - /* 320 */ 186, 187, 188, 12, 13, 14, 146, 108, 146, 149, - /* 330 */ 111, 197, 21, 94, 96, 97, 98, 218, 12, 13, - /* 340 */ 29, 161, 31, 143, 144, 0, 3, 21, 161, 61, - /* 350 */ 163, 40, 101, 115, 18, 29, 169, 31, 22, 172, - /* 360 */ 24, 25, 175, 176, 12, 13, 179, 180, 181, 145, - /* 370 */ 177, 60, 177, 21, 38, 124, 125, 126, 127, 128, - /* 380 */ 156, 29, 209, 31, 39, 198, 60, 194, 34, 194, - /* 390 */ 79, 4, 40, 171, 172, 161, 68, 163, 211, 162, - /* 400 */ 163, 151, 215, 169, 154, 79, 172, 96, 97, 98, - /* 410 */ 176, 146, 60, 179, 180, 181, 182, 161, 203, 163, - /* 420 */ 186, 187, 96, 97, 98, 169, 161, 61, 172, 113, - /* 430 */ 114, 79, 176, 68, 68, 179, 180, 181, 182, 143, - /* 440 */ 175, 115, 186, 187, 20, 178, 181, 23, 96, 97, - /* 450 */ 98, 115, 19, 12, 13, 14, 191, 192, 193, 196, - /* 460 */ 195, 133, 21, 198, 61, 21, 12, 13, 114, 36, - /* 470 */ 29, 68, 31, 29, 131, 21, 211, 61, 163, 161, - /* 480 */ 215, 163, 61, 29, 68, 31, 212, 169, 40, 68, - /* 490 */ 172, 199, 139, 140, 176, 61, 31, 179, 180, 181, - /* 500 */ 135, 60, 68, 116, 61, 1, 2, 12, 13, 146, - /* 510 */ 161, 68, 163, 31, 60, 60, 21, 31, 169, 148, - /* 520 */ 79, 172, 67, 79, 29, 176, 31, 31, 179, 180, - /* 530 */ 181, 182, 146, 79, 216, 217, 187, 96, 97, 98, - /* 540 */ 96, 97, 98, 174, 161, 161, 166, 163, 148, 101, - /* 550 */ 96, 97, 98, 169, 146, 60, 172, 173, 148, 61, - /* 560 */ 176, 175, 142, 179, 180, 181, 68, 161, 31, 163, - /* 570 */ 61, 146, 142, 61, 79, 169, 61, 68, 172, 173, - /* 580 */ 68, 174, 176, 68, 198, 179, 180, 181, 161, 161, - /* 590 */ 163, 96, 97, 98, 31, 61, 169, 211, 145, 172, - /* 600 */ 178, 215, 68, 176, 61, 19, 179, 180, 181, 61, - /* 610 */ 161, 68, 163, 27, 0, 123, 68, 166, 169, 33, - /* 620 */ 208, 172, 36, 122, 161, 176, 163, 170, 179, 180, - /* 630 */ 181, 98, 169, 169, 208, 172, 173, 210, 161, 176, - /* 640 */ 163, 170, 179, 180, 181, 59, 169, 169, 62, 172, - /* 650 */ 173, 130, 161, 176, 163, 205, 179, 180, 181, 129, - /* 660 */ 169, 202, 204, 172, 50, 118, 217, 176, 54, 201, - /* 670 */ 179, 180, 181, 146, 88, 117, 90, 161, 161, 93, - /* 680 */ 163, 114, 31, 69, 61, 177, 169, 112, 161, 172, - /* 690 */ 134, 68, 161, 176, 163, 189, 179, 180, 181, 61, - /* 700 */ 169, 214, 88, 172, 219, 132, 68, 176, 181, 138, - /* 710 */ 179, 180, 181, 161, 60, 163, 213, 190, 191, 192, - /* 720 */ 193, 169, 195, 185, 172, 170, 169, 161, 176, 163, - /* 730 */ 169, 179, 180, 181, 170, 169, 91, 169, 172, 167, - /* 740 */ 161, 161, 176, 163, 166, 179, 180, 181, 145, 169, - /* 750 */ 154, 161, 172, 60, 157, 161, 176, 163, 146, 179, - /* 760 */ 180, 181, 145, 169, 0, 147, 172, 142, 152, 161, - /* 770 */ 176, 163, 152, 179, 180, 181, 147, 169, 0, 0, - /* 780 */ 172, 0, 56, 161, 176, 163, 67, 179, 180, 181, - /* 790 */ 0, 169, 0, 0, 172, 0, 0, 161, 176, 163, - /* 800 */ 0, 179, 180, 181, 0, 169, 0, 0, 172, 34, - /* 810 */ 0, 161, 176, 163, 41, 179, 180, 181, 0, 169, - /* 820 */ 0, 34, 172, 29, 27, 161, 176, 163, 0, 179, - /* 830 */ 180, 181, 0, 169, 0, 0, 172, 21, 0, 0, - /* 840 */ 176, 0, 21, 179, 180, 181, 94, 0, 161, 60, - /* 850 */ 163, 34, 89, 68, 146, 119, 169, 119, 60, 172, - /* 860 */ 61, 60, 161, 176, 163, 60, 179, 180, 181, 161, - /* 870 */ 169, 68, 29, 172, 61, 61, 19, 176, 113, 68, - /* 880 */ 179, 180, 181, 61, 27, 60, 119, 68, 61, 181, - /* 890 */ 33, 67, 61, 36, 68, 4, 2, 67, 61, 191, - /* 900 */ 192, 193, 29, 195, 68, 29, 12, 13, 14, 15, - /* 910 */ 16, 2, 67, 29, 68, 29, 59, 29, 29, 62, - /* 920 */ 2, 12, 13, 14, 15, 16, 67, 61, 60, 12, - /* 930 */ 13, 14, 15, 16, 101, 60, 92, 0, 61, 61, - /* 940 */ 60, 60, 60, 89, 34, 60, 89, 21, 65, 29, - /* 950 */ 93, 29, 60, 29, 67, 81, 61, 67, 60, 66, - /* 960 */ 61, 60, 29, 61, 60, 29, 61, 60, 29, 61, - /* 970 */ 21, 60, 60, 60, 29, 69, 29, 81, 61, 21, - /* 980 */ 40, 81, 41, 29, 81, 29, 29, 21, 29, 29, - /* 990 */ 29, 29, 29, 29, 29, 0, 29, 29, 29, 29, - /* 1000 */ 29, 29, 29, 27, 0, 0, 29, 28, 34, 0, - /* 1010 */ 21, 20, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1020 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1030 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1040 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1050 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1060 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1070 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1080 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1090 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1100 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1110 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1120 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1130 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1140 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, - /* 1150 */ 220, 220, 220, + /* 0 */ 0, 163, 163, 170, 195, 160, 226, 198, 211, 212, + /* 10 */ 201, 183, 179, 12, 13, 14, 15, 16, 0, 239, + /* 20 */ 187, 161, 162, 243, 186, 186, 182, 12, 13, 14, + /* 30 */ 15, 16, 191, 20, 190, 194, 195, 199, 199, 21, + /* 40 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 204, + /* 50 */ 0, 50, 52, 53, 54, 55, 56, 57, 58, 59, + /* 60 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + /* 70 */ 70, 226, 181, 12, 13, 74, 12, 13, 14, 15, + /* 80 */ 16, 20, 20, 192, 239, 84, 73, 182, 243, 195, + /* 90 */ 20, 168, 168, 188, 33, 201, 173, 0, 193, 49, + /* 100 */ 39, 21, 22, 23, 24, 25, 26, 27, 28, 29, + /* 110 */ 30, 50, 189, 189, 50, 12, 13, 14, 15, 16, + /* 120 */ 119, 120, 49, 122, 123, 124, 125, 126, 127, 128, + /* 130 */ 129, 130, 71, 209, 73, 33, 12, 13, 14, 15, + /* 140 */ 16, 39, 218, 219, 220, 221, 49, 223, 84, 90, + /* 150 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + /* 160 */ 99, 102, 103, 104, 105, 106, 107, 171, 172, 182, + /* 170 */ 155, 156, 4, 71, 20, 188, 20, 163, 117, 118, + /* 180 */ 193, 1, 2, 119, 120, 20, 122, 123, 124, 125, + /* 190 */ 126, 127, 128, 129, 130, 134, 182, 52, 74, 54, + /* 200 */ 174, 99, 57, 189, 134, 60, 182, 62, 182, 195, + /* 210 */ 65, 20, 188, 199, 168, 163, 190, 193, 204, 117, + /* 220 */ 118, 207, 208, 209, 210, 168, 44, 73, 214, 215, + /* 230 */ 173, 12, 13, 14, 182, 163, 33, 180, 182, 20, + /* 240 */ 226, 189, 39, 168, 165, 166, 189, 195, 173, 193, + /* 250 */ 204, 199, 33, 239, 74, 180, 170, 243, 39, 207, + /* 260 */ 208, 209, 210, 88, 189, 32, 214, 215, 216, 50, + /* 270 */ 37, 199, 226, 187, 182, 163, 43, 168, 163, 46, + /* 280 */ 228, 189, 173, 132, 133, 239, 234, 235, 134, 243, + /* 290 */ 71, 119, 73, 175, 182, 20, 178, 182, 189, 127, + /* 300 */ 208, 189, 130, 135, 189, 72, 115, 195, 75, 0, + /* 310 */ 195, 199, 168, 163, 199, 133, 204, 173, 99, 207, + /* 320 */ 208, 209, 207, 208, 209, 210, 174, 152, 182, 214, + /* 330 */ 215, 216, 182, 189, 182, 189, 117, 118, 226, 189, + /* 340 */ 20, 108, 190, 35, 111, 195, 167, 114, 163, 199, + /* 350 */ 235, 239, 0, 33, 208, 243, 177, 207, 208, 209, + /* 360 */ 210, 41, 174, 184, 214, 215, 216, 182, 60, 60, + /* 370 */ 182, 182, 64, 64, 189, 225, 134, 163, 190, 60, + /* 380 */ 195, 14, 193, 64, 199, 3, 78, 20, 80, 81, + /* 390 */ 115, 83, 207, 208, 209, 210, 182, 89, 89, 214, + /* 400 */ 215, 216, 205, 189, 163, 0, 12, 13, 89, 195, + /* 410 */ 225, 20, 60, 199, 20, 88, 64, 108, 109, 222, + /* 420 */ 205, 207, 208, 209, 210, 205, 168, 33, 214, 215, + /* 430 */ 216, 173, 163, 39, 163, 12, 13, 222, 33, 225, + /* 440 */ 199, 89, 222, 20, 50, 74, 163, 189, 168, 163, + /* 450 */ 168, 182, 163, 173, 163, 173, 33, 49, 189, 88, + /* 460 */ 108, 109, 39, 73, 195, 71, 168, 73, 199, 189, + /* 470 */ 199, 189, 167, 182, 168, 85, 207, 208, 209, 210, + /* 480 */ 189, 154, 199, 214, 215, 199, 195, 189, 199, 184, + /* 490 */ 199, 162, 168, 99, 71, 189, 73, 86, 207, 208, + /* 500 */ 209, 210, 14, 15, 16, 214, 215, 209, 183, 32, + /* 510 */ 50, 117, 118, 189, 37, 209, 74, 219, 220, 221, + /* 520 */ 43, 223, 99, 46, 2, 219, 220, 221, 204, 223, + /* 530 */ 88, 183, 150, 209, 12, 13, 14, 15, 16, 183, + /* 540 */ 117, 118, 163, 219, 220, 221, 113, 223, 163, 72, + /* 550 */ 226, 183, 75, 12, 13, 14, 163, 134, 12, 13, + /* 560 */ 168, 20, 163, 239, 1, 2, 20, 243, 12, 13, + /* 570 */ 172, 237, 139, 140, 33, 182, 20, 163, 199, 33, + /* 580 */ 39, 121, 189, 79, 199, 39, 82, 110, 195, 33, + /* 590 */ 163, 114, 199, 246, 2, 39, 182, 163, 199, 163, + /* 600 */ 207, 208, 209, 189, 12, 13, 14, 15, 16, 195, + /* 610 */ 192, 74, 71, 199, 73, 79, 202, 71, 82, 73, + /* 620 */ 73, 207, 208, 209, 20, 88, 199, 71, 74, 73, + /* 630 */ 158, 159, 28, 199, 87, 199, 74, 244, 245, 74, + /* 640 */ 99, 231, 88, 163, 40, 99, 165, 74, 224, 45, + /* 650 */ 88, 47, 74, 88, 74, 99, 206, 74, 117, 118, + /* 660 */ 0, 88, 182, 117, 118, 163, 88, 182, 88, 189, + /* 670 */ 66, 88, 21, 117, 118, 195, 227, 240, 20, 199, + /* 680 */ 76, 77, 74, 168, 182, 34, 163, 207, 208, 209, + /* 690 */ 210, 189, 0, 33, 74, 215, 88, 195, 20, 74, + /* 700 */ 74, 199, 74, 79, 202, 182, 82, 163, 88, 207, + /* 710 */ 208, 209, 189, 88, 88, 74, 88, 203, 195, 170, + /* 720 */ 116, 20, 199, 163, 79, 33, 182, 82, 18, 88, + /* 730 */ 207, 208, 209, 189, 189, 20, 196, 170, 163, 195, + /* 740 */ 168, 31, 182, 199, 170, 35, 36, 20, 164, 189, + /* 750 */ 189, 207, 208, 209, 203, 195, 167, 182, 48, 199, + /* 760 */ 163, 238, 202, 20, 189, 196, 236, 207, 208, 209, + /* 770 */ 195, 142, 206, 141, 199, 118, 163, 202, 199, 182, + /* 780 */ 199, 163, 207, 208, 209, 200, 189, 200, 236, 245, + /* 790 */ 233, 149, 195, 137, 230, 182, 199, 148, 136, 229, + /* 800 */ 182, 133, 189, 232, 207, 208, 209, 189, 195, 163, + /* 810 */ 189, 20, 199, 195, 205, 131, 217, 199, 157, 153, + /* 820 */ 207, 208, 209, 247, 242, 207, 208, 209, 182, 241, + /* 830 */ 151, 73, 213, 163, 200, 189, 199, 199, 163, 200, + /* 840 */ 112, 195, 199, 189, 134, 199, 73, 197, 196, 178, + /* 850 */ 167, 164, 182, 207, 208, 209, 168, 182, 4, 189, + /* 860 */ 167, 163, 185, 189, 189, 195, 164, 182, 182, 199, + /* 870 */ 195, 0, 182, 19, 199, 0, 163, 207, 208, 209, + /* 880 */ 182, 182, 207, 208, 209, 182, 32, 189, 182, 182, + /* 890 */ 182, 37, 168, 195, 182, 182, 42, 199, 182, 182, + /* 900 */ 46, 176, 189, 169, 0, 207, 208, 209, 195, 176, + /* 910 */ 0, 0, 199, 163, 66, 87, 163, 0, 0, 0, + /* 920 */ 207, 208, 209, 52, 0, 54, 72, 0, 57, 75, + /* 930 */ 0, 60, 182, 62, 0, 182, 65, 0, 0, 189, + /* 940 */ 0, 44, 189, 51, 0, 195, 163, 0, 195, 199, + /* 950 */ 37, 39, 199, 44, 0, 0, 0, 207, 208, 209, + /* 960 */ 207, 208, 209, 0, 0, 182, 115, 0, 163, 44, + /* 970 */ 110, 73, 189, 88, 88, 138, 74, 88, 195, 74, + /* 980 */ 73, 73, 199, 88, 163, 39, 87, 182, 74, 163, + /* 990 */ 207, 208, 209, 73, 189, 74, 73, 138, 132, 138, + /* 1000 */ 195, 4, 74, 182, 199, 39, 74, 74, 182, 87, + /* 1010 */ 189, 39, 207, 208, 209, 189, 195, 121, 39, 88, + /* 1020 */ 199, 195, 39, 88, 88, 199, 87, 39, 207, 208, + /* 1030 */ 209, 39, 2, 207, 208, 209, 121, 87, 73, 143, + /* 1040 */ 144, 145, 146, 147, 74, 74, 73, 0, 74, 73, + /* 1050 */ 73, 73, 44, 110, 113, 73, 33, 73, 89, 73, + /* 1060 */ 85, 39, 73, 73, 39, 33, 86, 51, 50, 71, + /* 1070 */ 33, 0, 39, 39, 39, 39, 33, 39, 39, 39, + /* 1080 */ 39, 39, 0, 39, 39, 39, 0, 39, 39, 39, + /* 1090 */ 39, 39, 37, 39, 38, 0, 33, 44, 21, 0, + /* 1100 */ 87, 87, 82, 84, 39, 74, 39, 39, 39, 39, + /* 1110 */ 101, 101, 39, 101, 39, 39, 101, 33, 0, 39, + /* 1120 */ 39, 0, 39, 33, 39, 0, 39, 39, 0, 33, + /* 1130 */ 73, 40, 74, 73, 33, 74, 74, 73, 0, 73, + /* 1140 */ 33, 39, 0, 33, 33, 248, 74, 73, 248, 20, + /* 1150 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1160 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1170 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1180 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1190 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1200 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1210 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1220 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1230 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1240 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1250 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1260 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1270 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1280 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1290 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 1300 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, }; -#define YY_SHIFT_COUNT (332) +#define YY_SHIFT_COUNT (399) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1009) +#define YY_SHIFT_MAX (1142) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 336, 238, 311, 352, 352, 352, 352, 326, 352, 352, - /* 10 */ 70, 454, 495, 441, 454, 454, 454, 454, 454, 454, - /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 30 */ 454, 454, 454, 161, 161, 161, 185, 444, 444, 83, - /* 40 */ 83, 207, 141, 191, 191, 67, 201, 141, 83, 83, - /* 50 */ 141, 83, 141, 141, 141, 83, 236, 0, 13, 13, - /* 60 */ 444, 35, 214, 218, 218, 218, 345, 201, 141, 141, - /* 70 */ 158, 78, 143, 82, 251, 151, 39, 239, 316, 354, - /* 80 */ 316, 19, 343, 387, 465, 482, 207, 486, 496, 207, - /* 90 */ 465, 207, 537, 465, 537, 482, 236, 486, 496, 563, - /* 100 */ 492, 501, 533, 492, 501, 533, 521, 530, 547, 558, - /* 110 */ 567, 486, 651, 575, 571, 556, 573, 654, 141, 501, - /* 120 */ 533, 533, 501, 533, 645, 486, 496, 158, 236, 486, - /* 130 */ 693, 465, 236, 537, 1012, 1012, 1012, 1012, 30, 89, - /* 140 */ 586, 857, 894, 909, 917, 113, 113, 113, 113, 113, - /* 150 */ 113, 113, 159, 614, 288, 219, 77, 77, 77, 77, - /* 160 */ 424, 433, 366, 403, 416, 504, 353, 328, 365, 421, - /* 170 */ 448, 434, 455, 443, 498, 509, 512, 515, 534, 543, - /* 180 */ 548, 623, 638, 137, 764, 778, 779, 781, 726, 719, - /* 190 */ 790, 792, 793, 795, 796, 800, 804, 806, 807, 775, - /* 200 */ 810, 773, 818, 820, 794, 797, 787, 828, 832, 834, - /* 210 */ 835, 816, 838, 821, 839, 841, 752, 847, 789, 817, - /* 220 */ 763, 785, 803, 736, 799, 811, 813, 798, 801, 814, - /* 230 */ 805, 822, 843, 819, 824, 825, 826, 738, 827, 831, - /* 240 */ 830, 765, 836, 845, 837, 846, 767, 891, 873, 876, - /* 250 */ 884, 886, 888, 889, 918, 833, 859, 866, 868, 875, - /* 260 */ 877, 878, 880, 881, 844, 882, 937, 910, 854, 885, - /* 270 */ 883, 887, 890, 926, 892, 893, 895, 920, 922, 898, - /* 280 */ 899, 924, 901, 902, 933, 904, 905, 936, 907, 908, - /* 290 */ 939, 911, 874, 896, 900, 903, 949, 906, 912, 913, - /* 300 */ 945, 947, 958, 941, 940, 954, 956, 957, 959, 960, - /* 310 */ 961, 962, 966, 963, 964, 965, 967, 968, 969, 970, - /* 320 */ 971, 972, 995, 973, 976, 974, 1004, 977, 979, 1005, - /* 330 */ 1009, 989, 991, + /* 0 */ 710, 61, 219, 394, 394, 394, 394, 423, 394, 394, + /* 10 */ 154, 546, 556, 541, 546, 546, 546, 546, 546, 546, + /* 20 */ 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, + /* 30 */ 546, 546, 546, 13, 13, 13, 70, 62, 62, 102, + /* 40 */ 102, 62, 62, 73, 156, 165, 165, 242, 391, 156, + /* 50 */ 62, 62, 156, 62, 156, 391, 156, 156, 62, 408, + /* 60 */ 1, 64, 64, 80, 308, 102, 102, 145, 102, 102, + /* 70 */ 102, 102, 102, 102, 102, 102, 102, 102, 320, 50, + /* 80 */ 191, 191, 191, 97, 391, 156, 156, 156, 411, 59, + /* 90 */ 59, 59, 59, 59, 18, 604, 15, 871, 896, 433, + /* 100 */ 319, 203, 275, 151, 182, 151, 367, 382, 168, 658, + /* 110 */ 678, 73, 701, 715, 73, 658, 73, 727, 678, 408, + /* 120 */ 701, 715, 743, 629, 632, 657, 629, 632, 657, 642, + /* 130 */ 649, 656, 662, 668, 701, 791, 684, 661, 666, 679, + /* 140 */ 758, 156, 632, 657, 657, 632, 657, 728, 701, 715, + /* 150 */ 411, 408, 773, 658, 408, 727, 701, 156, 156, 156, + /* 160 */ 156, 156, 156, 156, 156, 156, 156, 156, 658, 727, + /* 170 */ 1150, 1150, 1150, 0, 233, 477, 854, 522, 592, 124, + /* 180 */ 309, 352, 103, 103, 103, 103, 103, 103, 103, 180, + /* 190 */ 172, 488, 488, 488, 488, 371, 442, 537, 563, 472, + /* 200 */ 175, 327, 554, 460, 562, 547, 565, 573, 578, 580, + /* 210 */ 583, 608, 620, 625, 626, 628, 390, 504, 536, 624, + /* 220 */ 641, 645, 405, 660, 692, 651, 875, 904, 910, 911, + /* 230 */ 848, 828, 917, 918, 919, 924, 927, 930, 934, 937, + /* 240 */ 938, 897, 940, 892, 944, 947, 912, 913, 909, 954, + /* 250 */ 955, 956, 963, 964, 851, 967, 898, 925, 860, 885, + /* 260 */ 886, 837, 902, 889, 905, 907, 908, 914, 920, 921, + /* 270 */ 946, 895, 899, 923, 931, 859, 928, 932, 922, 866, + /* 280 */ 935, 939, 933, 936, 861, 997, 966, 972, 979, 983, + /* 290 */ 988, 992, 1030, 915, 950, 970, 965, 973, 971, 974, + /* 300 */ 976, 977, 941, 978, 1047, 1008, 943, 982, 975, 984, + /* 310 */ 980, 1023, 969, 986, 989, 990, 1022, 1025, 1032, 1016, + /* 320 */ 1018, 998, 1037, 1033, 1034, 1035, 1036, 1038, 1039, 1040, + /* 330 */ 1043, 1041, 1042, 1044, 1045, 1046, 1048, 1049, 1050, 1051, + /* 340 */ 1071, 1052, 1055, 1053, 1082, 1054, 1056, 1086, 1095, 1063, + /* 350 */ 1077, 1099, 1013, 1014, 1019, 1020, 1031, 1065, 1067, 1057, + /* 360 */ 1058, 1068, 1060, 1061, 1069, 1064, 1062, 1070, 1066, 1072, + /* 370 */ 1073, 1074, 1009, 1010, 1012, 1015, 1075, 1076, 1084, 1118, + /* 380 */ 1080, 1081, 1083, 1085, 1087, 1088, 1121, 1090, 1125, 1096, + /* 390 */ 1091, 1128, 1101, 1102, 1138, 1107, 1142, 1110, 1111, 1129, }; -#define YY_REDUCE_COUNT (137) -#define YY_REDUCE_MIN (-162) -#define YY_REDUCE_MAX (708) +#define YY_REDUCE_COUNT (172) +#define YY_REDUCE_MIN (-220) +#define YY_REDUCE_MAX (826) static const short yy_reduce_ofst[] = { - /* 0 */ 90, 14, 54, -117, 76, 105, 134, 187, 234, 256, - /* 10 */ 265, 318, 349, 384, 406, 427, 449, 463, 477, 491, - /* 20 */ 517, 531, 552, 566, 580, 594, 608, 622, 636, 650, - /* 30 */ 664, 687, 701, 527, -144, 708, 386, -158, -138, -142, - /* 40 */ -140, -116, -155, -139, 7, -27, -114, -127, 59, 133, - /* 50 */ 16, 150, 41, 144, 48, 180, -111, -17, -17, -17, - /* 60 */ 107, 200, 160, 50, 193, 195, 224, 222, 237, -162, - /* 70 */ 250, 116, 182, 119, 173, 215, 296, 267, 263, 263, - /* 80 */ 263, 315, 274, 292, 363, 369, 371, 383, 380, 400, - /* 90 */ 408, 410, 420, 425, 430, 407, 453, 428, 451, 422, - /* 100 */ 412, 457, 464, 426, 471, 478, 450, 458, 459, 468, - /* 110 */ 263, 516, 508, 506, 485, 487, 503, 538, 315, 555, - /* 120 */ 557, 561, 564, 568, 572, 579, 578, 596, 603, 590, - /* 130 */ 597, 612, 617, 625, 618, 616, 620, 629, + /* 0 */ -155, 14, 52, 115, 150, 185, 214, 112, 269, 291, + /* 10 */ 324, 393, 480, 414, 502, 523, 544, 560, 575, 597, + /* 20 */ 613, 618, 646, 670, 675, 698, 713, 750, 753, 783, + /* 30 */ 805, 821, 826, -76, 298, 306, 46, 57, 75, -162, + /* 40 */ -161, -77, 109, -167, -95, 92, 146, -220, -191, 26, + /* 50 */ 144, 258, -13, 280, 152, -159, 24, 188, 282, 179, + /* 60 */ -203, -203, -203, -140, -109, 72, 241, -4, 271, 283, + /* 70 */ 286, 289, 379, 385, 399, 427, 434, 436, 79, 86, + /* 80 */ 197, 215, 220, 305, -106, -156, 56, 189, 118, -172, + /* 90 */ 325, 348, 356, 368, 329, 392, 347, 398, 334, 410, + /* 100 */ 418, 481, 450, 424, 424, 424, 485, 437, 449, 515, + /* 110 */ 514, 549, 545, 540, 567, 572, 574, 584, 551, 589, + /* 120 */ 561, 569, 566, 530, 585, 579, 552, 587, 581, 557, + /* 130 */ 571, 564, 570, 424, 621, 609, 599, 576, 582, 588, + /* 140 */ 619, 485, 634, 637, 638, 639, 643, 650, 654, 652, + /* 150 */ 671, 683, 677, 688, 693, 687, 674, 685, 686, 690, + /* 160 */ 699, 703, 706, 707, 708, 712, 716, 717, 724, 702, + /* 170 */ 725, 733, 734, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 10 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 20 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 30 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 40 */ 756, 783, 756, 756, 756, 756, 756, 756, 756, 756, - /* 50 */ 756, 756, 756, 756, 756, 756, 781, 756, 933, 756, - /* 60 */ 756, 756, 783, 944, 944, 944, 781, 756, 756, 756, - /* 70 */ 846, 756, 756, 1008, 756, 968, 756, 960, 936, 950, - /* 80 */ 937, 756, 993, 953, 756, 756, 783, 756, 756, 783, - /* 90 */ 756, 783, 756, 756, 756, 756, 781, 756, 756, 756, - /* 100 */ 975, 973, 756, 975, 973, 756, 987, 983, 966, 964, - /* 110 */ 950, 756, 756, 756, 1011, 999, 995, 756, 756, 973, - /* 120 */ 756, 756, 973, 756, 860, 756, 756, 756, 781, 756, - /* 130 */ 815, 756, 781, 756, 784, 849, 849, 784, 756, 756, - /* 140 */ 756, 756, 756, 756, 756, 905, 986, 985, 904, 910, - /* 150 */ 909, 908, 756, 756, 756, 756, 899, 900, 898, 897, - /* 160 */ 756, 756, 756, 756, 756, 934, 756, 996, 1000, 756, - /* 170 */ 756, 756, 884, 756, 756, 756, 756, 756, 756, 756, - /* 180 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 190 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 200 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 210 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 220 */ 756, 957, 967, 756, 756, 756, 756, 756, 756, 756, - /* 230 */ 756, 756, 756, 756, 884, 756, 984, 756, 943, 939, - /* 240 */ 756, 756, 935, 756, 756, 994, 756, 756, 756, 756, - /* 250 */ 756, 756, 756, 756, 929, 756, 756, 756, 756, 756, - /* 260 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 270 */ 756, 883, 756, 756, 756, 756, 756, 756, 756, 843, - /* 280 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 290 */ 756, 756, 828, 826, 825, 824, 756, 821, 756, 756, - /* 300 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 310 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 320 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, - /* 330 */ 756, 756, 756, + /* 0 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 10 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 20 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 30 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 40 */ 913, 913, 913, 959, 913, 913, 913, 913, 913, 913, + /* 50 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 957, + /* 60 */ 913, 1140, 913, 913, 913, 913, 913, 913, 913, 913, + /* 70 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 959, + /* 80 */ 1151, 1151, 1151, 957, 913, 913, 913, 913, 1044, 913, + /* 90 */ 913, 913, 913, 913, 913, 913, 1215, 913, 913, 1175, + /* 100 */ 997, 913, 1167, 1143, 1157, 1144, 913, 1200, 1160, 913, + /* 110 */ 913, 959, 913, 913, 959, 913, 959, 913, 913, 957, + /* 120 */ 913, 913, 913, 1182, 1180, 913, 1182, 1180, 913, 1194, + /* 130 */ 1190, 1173, 1171, 1157, 913, 913, 913, 1218, 1206, 1202, + /* 140 */ 913, 913, 1180, 913, 913, 1180, 913, 1067, 913, 913, + /* 150 */ 913, 957, 1013, 913, 957, 913, 913, 913, 913, 913, + /* 160 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 170 */ 1047, 1047, 960, 913, 913, 913, 913, 913, 913, 913, + /* 180 */ 913, 913, 1112, 1193, 1192, 1111, 1117, 1116, 1115, 913, + /* 190 */ 913, 1106, 1107, 1105, 1104, 913, 913, 913, 1141, 913, + /* 200 */ 1203, 1207, 913, 913, 913, 1091, 913, 913, 913, 913, + /* 210 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 220 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 230 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 240 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 250 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 1164, + /* 260 */ 1174, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 270 */ 913, 913, 1091, 913, 1191, 913, 1150, 1146, 913, 913, + /* 280 */ 1142, 913, 913, 1201, 913, 913, 913, 913, 913, 913, + /* 290 */ 913, 913, 1136, 913, 913, 913, 913, 913, 913, 913, + /* 300 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 310 */ 913, 913, 1019, 913, 913, 913, 913, 913, 913, 913, + /* 320 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 330 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 340 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 350 */ 913, 913, 1090, 913, 913, 913, 913, 913, 913, 1041, + /* 360 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 370 */ 913, 913, 1026, 1024, 1023, 1022, 913, 913, 913, 913, + /* 380 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 390 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, }; /********** End of lemon-generated parsing tables *****************************/ @@ -646,208 +692,236 @@ static const char *const yyTokenName[] = { /* 15 */ "NK_SLASH", /* 16 */ "NK_REM", /* 17 */ "NK_CONCAT", - /* 18 */ "CREATE", - /* 19 */ "USER", - /* 20 */ "PASS", - /* 21 */ "NK_STRING", - /* 22 */ "ALTER", - /* 23 */ "PRIVILEGE", - /* 24 */ "DROP", - /* 25 */ "SHOW", - /* 26 */ "USERS", - /* 27 */ "DNODE", - /* 28 */ "PORT", - /* 29 */ "NK_INTEGER", - /* 30 */ "DNODES", - /* 31 */ "NK_ID", - /* 32 */ "NK_IPTOKEN", - /* 33 */ "QNODE", - /* 34 */ "ON", - /* 35 */ "QNODES", - /* 36 */ "DATABASE", - /* 37 */ "DATABASES", - /* 38 */ "USE", - /* 39 */ "IF", - /* 40 */ "NOT", - /* 41 */ "EXISTS", - /* 42 */ "BLOCKS", - /* 43 */ "CACHE", - /* 44 */ "CACHELAST", - /* 45 */ "COMP", - /* 46 */ "DAYS", - /* 47 */ "FSYNC", - /* 48 */ "MAXROWS", - /* 49 */ "MINROWS", - /* 50 */ "KEEP", - /* 51 */ "PRECISION", - /* 52 */ "QUORUM", - /* 53 */ "REPLICA", - /* 54 */ "TTL", - /* 55 */ "WAL", - /* 56 */ "VGROUPS", - /* 57 */ "SINGLE_STABLE", - /* 58 */ "STREAM_MODE", - /* 59 */ "TABLE", - /* 60 */ "NK_LP", - /* 61 */ "NK_RP", - /* 62 */ "STABLE", - /* 63 */ "TABLES", - /* 64 */ "STABLES", - /* 65 */ "USING", - /* 66 */ "TAGS", - /* 67 */ "NK_DOT", - /* 68 */ "NK_COMMA", - /* 69 */ "COMMENT", - /* 70 */ "BOOL", - /* 71 */ "TINYINT", - /* 72 */ "SMALLINT", - /* 73 */ "INT", - /* 74 */ "INTEGER", - /* 75 */ "BIGINT", - /* 76 */ "FLOAT", - /* 77 */ "DOUBLE", - /* 78 */ "BINARY", - /* 79 */ "TIMESTAMP", - /* 80 */ "NCHAR", - /* 81 */ "UNSIGNED", - /* 82 */ "JSON", - /* 83 */ "VARCHAR", - /* 84 */ "MEDIUMBLOB", - /* 85 */ "BLOB", - /* 86 */ "VARBINARY", - /* 87 */ "DECIMAL", - /* 88 */ "SMA", - /* 89 */ "INDEX", - /* 90 */ "FULLTEXT", - /* 91 */ "FUNCTION", - /* 92 */ "INTERVAL", - /* 93 */ "TOPIC", - /* 94 */ "AS", - /* 95 */ "MNODES", - /* 96 */ "NK_FLOAT", - /* 97 */ "NK_BOOL", - /* 98 */ "NK_VARIABLE", - /* 99 */ "BETWEEN", - /* 100 */ "IS", - /* 101 */ "NULL", - /* 102 */ "NK_LT", - /* 103 */ "NK_GT", - /* 104 */ "NK_LE", - /* 105 */ "NK_GE", - /* 106 */ "NK_NE", - /* 107 */ "NK_EQ", - /* 108 */ "LIKE", - /* 109 */ "MATCH", - /* 110 */ "NMATCH", - /* 111 */ "IN", - /* 112 */ "FROM", - /* 113 */ "JOIN", - /* 114 */ "INNER", - /* 115 */ "SELECT", - /* 116 */ "DISTINCT", - /* 117 */ "WHERE", - /* 118 */ "PARTITION", - /* 119 */ "BY", - /* 120 */ "SESSION", - /* 121 */ "STATE_WINDOW", - /* 122 */ "SLIDING", - /* 123 */ "FILL", - /* 124 */ "VALUE", - /* 125 */ "NONE", - /* 126 */ "PREV", - /* 127 */ "LINEAR", - /* 128 */ "NEXT", - /* 129 */ "GROUP", - /* 130 */ "HAVING", - /* 131 */ "ORDER", - /* 132 */ "SLIMIT", - /* 133 */ "SOFFSET", - /* 134 */ "LIMIT", - /* 135 */ "OFFSET", - /* 136 */ "ASC", - /* 137 */ "DESC", - /* 138 */ "NULLS", - /* 139 */ "FIRST", - /* 140 */ "LAST", - /* 141 */ "cmd", - /* 142 */ "user_name", - /* 143 */ "dnode_endpoint", - /* 144 */ "dnode_host_name", - /* 145 */ "not_exists_opt", - /* 146 */ "db_name", - /* 147 */ "db_options", - /* 148 */ "exists_opt", - /* 149 */ "full_table_name", - /* 150 */ "column_def_list", - /* 151 */ "tags_def_opt", - /* 152 */ "table_options", - /* 153 */ "multi_create_clause", - /* 154 */ "tags_def", - /* 155 */ "multi_drop_clause", - /* 156 */ "create_subtable_clause", - /* 157 */ "specific_tags_opt", - /* 158 */ "literal_list", - /* 159 */ "drop_table_clause", - /* 160 */ "col_name_list", - /* 161 */ "table_name", - /* 162 */ "column_def", - /* 163 */ "column_name", - /* 164 */ "type_name", - /* 165 */ "col_name", - /* 166 */ "index_name", - /* 167 */ "index_options", - /* 168 */ "func_list", - /* 169 */ "duration_literal", - /* 170 */ "sliding_opt", - /* 171 */ "func", - /* 172 */ "function_name", - /* 173 */ "expression_list", - /* 174 */ "topic_name", - /* 175 */ "query_expression", - /* 176 */ "literal", - /* 177 */ "table_alias", - /* 178 */ "column_alias", - /* 179 */ "expression", - /* 180 */ "column_reference", - /* 181 */ "subquery", - /* 182 */ "predicate", - /* 183 */ "compare_op", - /* 184 */ "in_op", - /* 185 */ "in_predicate_value", - /* 186 */ "boolean_value_expression", - /* 187 */ "boolean_primary", - /* 188 */ "common_expression", - /* 189 */ "from_clause", - /* 190 */ "table_reference_list", - /* 191 */ "table_reference", - /* 192 */ "table_primary", - /* 193 */ "joined_table", - /* 194 */ "alias_opt", - /* 195 */ "parenthesized_joined_table", - /* 196 */ "join_type", - /* 197 */ "search_condition", - /* 198 */ "query_specification", - /* 199 */ "set_quantifier_opt", - /* 200 */ "select_list", - /* 201 */ "where_clause_opt", - /* 202 */ "partition_by_clause_opt", - /* 203 */ "twindow_clause_opt", - /* 204 */ "group_by_clause_opt", - /* 205 */ "having_clause_opt", - /* 206 */ "select_sublist", - /* 207 */ "select_item", - /* 208 */ "fill_opt", - /* 209 */ "fill_mode", - /* 210 */ "group_by_list", - /* 211 */ "query_expression_body", - /* 212 */ "order_by_clause_opt", - /* 213 */ "slimit_clause_opt", - /* 214 */ "limit_clause_opt", - /* 215 */ "query_primary", - /* 216 */ "sort_specification_list", - /* 217 */ "sort_specification", - /* 218 */ "ordering_specification_opt", - /* 219 */ "null_ordering_opt", + /* 18 */ "ALTER", + /* 19 */ "ACCOUNT", + /* 20 */ "NK_ID", + /* 21 */ "PASS", + /* 22 */ "PPS", + /* 23 */ "TSERIES", + /* 24 */ "STORAGE", + /* 25 */ "STREAMS", + /* 26 */ "QTIME", + /* 27 */ "DBS", + /* 28 */ "USERS", + /* 29 */ "CONNS", + /* 30 */ "STATE", + /* 31 */ "CREATE", + /* 32 */ "USER", + /* 33 */ "NK_STRING", + /* 34 */ "PRIVILEGE", + /* 35 */ "DROP", + /* 36 */ "SHOW", + /* 37 */ "DNODE", + /* 38 */ "PORT", + /* 39 */ "NK_INTEGER", + /* 40 */ "DNODES", + /* 41 */ "NK_IPTOKEN", + /* 42 */ "LOCAL", + /* 43 */ "QNODE", + /* 44 */ "ON", + /* 45 */ "QNODES", + /* 46 */ "DATABASE", + /* 47 */ "DATABASES", + /* 48 */ "USE", + /* 49 */ "IF", + /* 50 */ "NOT", + /* 51 */ "EXISTS", + /* 52 */ "BLOCKS", + /* 53 */ "CACHE", + /* 54 */ "CACHELAST", + /* 55 */ "COMP", + /* 56 */ "DAYS", + /* 57 */ "FSYNC", + /* 58 */ "MAXROWS", + /* 59 */ "MINROWS", + /* 60 */ "KEEP", + /* 61 */ "PRECISION", + /* 62 */ "QUORUM", + /* 63 */ "REPLICA", + /* 64 */ "TTL", + /* 65 */ "WAL", + /* 66 */ "VGROUPS", + /* 67 */ "SINGLE_STABLE", + /* 68 */ "STREAM_MODE", + /* 69 */ "RETENTIONS", + /* 70 */ "FILE_FACTOR", + /* 71 */ "NK_FLOAT", + /* 72 */ "TABLE", + /* 73 */ "NK_LP", + /* 74 */ "NK_RP", + /* 75 */ "STABLE", + /* 76 */ "TABLES", + /* 77 */ "STABLES", + /* 78 */ "ADD", + /* 79 */ "COLUMN", + /* 80 */ "MODIFY", + /* 81 */ "RENAME", + /* 82 */ "TAG", + /* 83 */ "SET", + /* 84 */ "NK_EQ", + /* 85 */ "USING", + /* 86 */ "TAGS", + /* 87 */ "NK_DOT", + /* 88 */ "NK_COMMA", + /* 89 */ "COMMENT", + /* 90 */ "BOOL", + /* 91 */ "TINYINT", + /* 92 */ "SMALLINT", + /* 93 */ "INT", + /* 94 */ "INTEGER", + /* 95 */ "BIGINT", + /* 96 */ "FLOAT", + /* 97 */ "DOUBLE", + /* 98 */ "BINARY", + /* 99 */ "TIMESTAMP", + /* 100 */ "NCHAR", + /* 101 */ "UNSIGNED", + /* 102 */ "JSON", + /* 103 */ "VARCHAR", + /* 104 */ "MEDIUMBLOB", + /* 105 */ "BLOB", + /* 106 */ "VARBINARY", + /* 107 */ "DECIMAL", + /* 108 */ "SMA", + /* 109 */ "ROLLUP", + /* 110 */ "INDEX", + /* 111 */ "FULLTEXT", + /* 112 */ "FUNCTION", + /* 113 */ "INTERVAL", + /* 114 */ "TOPIC", + /* 115 */ "AS", + /* 116 */ "MNODES", + /* 117 */ "NK_BOOL", + /* 118 */ "NK_VARIABLE", + /* 119 */ "BETWEEN", + /* 120 */ "IS", + /* 121 */ "NULL", + /* 122 */ "NK_LT", + /* 123 */ "NK_GT", + /* 124 */ "NK_LE", + /* 125 */ "NK_GE", + /* 126 */ "NK_NE", + /* 127 */ "LIKE", + /* 128 */ "MATCH", + /* 129 */ "NMATCH", + /* 130 */ "IN", + /* 131 */ "FROM", + /* 132 */ "JOIN", + /* 133 */ "INNER", + /* 134 */ "SELECT", + /* 135 */ "DISTINCT", + /* 136 */ "WHERE", + /* 137 */ "PARTITION", + /* 138 */ "BY", + /* 139 */ "SESSION", + /* 140 */ "STATE_WINDOW", + /* 141 */ "SLIDING", + /* 142 */ "FILL", + /* 143 */ "VALUE", + /* 144 */ "NONE", + /* 145 */ "PREV", + /* 146 */ "LINEAR", + /* 147 */ "NEXT", + /* 148 */ "GROUP", + /* 149 */ "HAVING", + /* 150 */ "ORDER", + /* 151 */ "SLIMIT", + /* 152 */ "SOFFSET", + /* 153 */ "LIMIT", + /* 154 */ "OFFSET", + /* 155 */ "ASC", + /* 156 */ "DESC", + /* 157 */ "NULLS", + /* 158 */ "FIRST", + /* 159 */ "LAST", + /* 160 */ "cmd", + /* 161 */ "account_options", + /* 162 */ "account_option", + /* 163 */ "literal", + /* 164 */ "user_name", + /* 165 */ "dnode_endpoint", + /* 166 */ "dnode_host_name", + /* 167 */ "not_exists_opt", + /* 168 */ "db_name", + /* 169 */ "db_options", + /* 170 */ "exists_opt", + /* 171 */ "alter_db_options", + /* 172 */ "alter_db_option", + /* 173 */ "full_table_name", + /* 174 */ "column_def_list", + /* 175 */ "tags_def_opt", + /* 176 */ "table_options", + /* 177 */ "multi_create_clause", + /* 178 */ "tags_def", + /* 179 */ "multi_drop_clause", + /* 180 */ "alter_table_clause", + /* 181 */ "alter_table_options", + /* 182 */ "column_name", + /* 183 */ "type_name", + /* 184 */ "create_subtable_clause", + /* 185 */ "specific_tags_opt", + /* 186 */ "literal_list", + /* 187 */ "drop_table_clause", + /* 188 */ "col_name_list", + /* 189 */ "table_name", + /* 190 */ "column_def", + /* 191 */ "func_name_list", + /* 192 */ "alter_table_option", + /* 193 */ "col_name", + /* 194 */ "func_name", + /* 195 */ "function_name", + /* 196 */ "index_name", + /* 197 */ "index_options", + /* 198 */ "func_list", + /* 199 */ "duration_literal", + /* 200 */ "sliding_opt", + /* 201 */ "func", + /* 202 */ "expression_list", + /* 203 */ "topic_name", + /* 204 */ "query_expression", + /* 205 */ "table_alias", + /* 206 */ "column_alias", + /* 207 */ "expression", + /* 208 */ "column_reference", + /* 209 */ "subquery", + /* 210 */ "predicate", + /* 211 */ "compare_op", + /* 212 */ "in_op", + /* 213 */ "in_predicate_value", + /* 214 */ "boolean_value_expression", + /* 215 */ "boolean_primary", + /* 216 */ "common_expression", + /* 217 */ "from_clause", + /* 218 */ "table_reference_list", + /* 219 */ "table_reference", + /* 220 */ "table_primary", + /* 221 */ "joined_table", + /* 222 */ "alias_opt", + /* 223 */ "parenthesized_joined_table", + /* 224 */ "join_type", + /* 225 */ "search_condition", + /* 226 */ "query_specification", + /* 227 */ "set_quantifier_opt", + /* 228 */ "select_list", + /* 229 */ "where_clause_opt", + /* 230 */ "partition_by_clause_opt", + /* 231 */ "twindow_clause_opt", + /* 232 */ "group_by_clause_opt", + /* 233 */ "having_clause_opt", + /* 234 */ "select_sublist", + /* 235 */ "select_item", + /* 236 */ "fill_opt", + /* 237 */ "fill_mode", + /* 238 */ "group_by_list", + /* 239 */ "query_expression_body", + /* 240 */ "order_by_clause_opt", + /* 241 */ "slimit_clause_opt", + /* 242 */ "limit_clause_opt", + /* 243 */ "query_primary", + /* 244 */ "sort_specification_list", + /* 245 */ "sort_specification", + /* 246 */ "ordering_specification_opt", + /* 247 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -855,261 +929,311 @@ static const char *const yyTokenName[] = { /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { - /* 0 */ "cmd ::= CREATE USER user_name PASS NK_STRING", - /* 1 */ "cmd ::= ALTER USER user_name PASS NK_STRING", - /* 2 */ "cmd ::= ALTER USER user_name PRIVILEGE NK_STRING", - /* 3 */ "cmd ::= DROP USER user_name", - /* 4 */ "cmd ::= SHOW USERS", - /* 5 */ "cmd ::= CREATE DNODE dnode_endpoint", - /* 6 */ "cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER", - /* 7 */ "cmd ::= DROP DNODE NK_INTEGER", - /* 8 */ "cmd ::= DROP DNODE dnode_endpoint", - /* 9 */ "cmd ::= SHOW DNODES", - /* 10 */ "dnode_endpoint ::= NK_STRING", - /* 11 */ "dnode_host_name ::= NK_ID", - /* 12 */ "dnode_host_name ::= NK_IPTOKEN", - /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 14 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", - /* 15 */ "cmd ::= SHOW QNODES", - /* 16 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 17 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 18 */ "cmd ::= SHOW DATABASES", - /* 19 */ "cmd ::= USE db_name", - /* 20 */ "cmd ::= ALTER DATABASE db_name db_options", - /* 21 */ "not_exists_opt ::= IF NOT EXISTS", - /* 22 */ "not_exists_opt ::=", - /* 23 */ "exists_opt ::= IF EXISTS", - /* 24 */ "exists_opt ::=", - /* 25 */ "db_options ::=", - /* 26 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 27 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 28 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 29 */ "db_options ::= db_options COMP NK_INTEGER", - /* 30 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 31 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 32 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 33 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 34 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 35 */ "db_options ::= db_options PRECISION NK_STRING", - /* 36 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 37 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 38 */ "db_options ::= db_options TTL NK_INTEGER", - /* 39 */ "db_options ::= db_options WAL NK_INTEGER", - /* 40 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 41 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 42 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 43 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 44 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 45 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 46 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 47 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 48 */ "cmd ::= SHOW TABLES", - /* 49 */ "cmd ::= SHOW STABLES", - /* 50 */ "multi_create_clause ::= create_subtable_clause", - /* 51 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 52 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 53 */ "multi_drop_clause ::= drop_table_clause", - /* 54 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 55 */ "drop_table_clause ::= exists_opt full_table_name", - /* 56 */ "specific_tags_opt ::=", - /* 57 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 58 */ "full_table_name ::= table_name", - /* 59 */ "full_table_name ::= db_name NK_DOT table_name", - /* 60 */ "column_def_list ::= column_def", - /* 61 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 62 */ "column_def ::= column_name type_name", - /* 63 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 64 */ "type_name ::= BOOL", - /* 65 */ "type_name ::= TINYINT", - /* 66 */ "type_name ::= SMALLINT", - /* 67 */ "type_name ::= INT", - /* 68 */ "type_name ::= INTEGER", - /* 69 */ "type_name ::= BIGINT", - /* 70 */ "type_name ::= FLOAT", - /* 71 */ "type_name ::= DOUBLE", - /* 72 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 73 */ "type_name ::= TIMESTAMP", - /* 74 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 75 */ "type_name ::= TINYINT UNSIGNED", - /* 76 */ "type_name ::= SMALLINT UNSIGNED", - /* 77 */ "type_name ::= INT UNSIGNED", - /* 78 */ "type_name ::= BIGINT UNSIGNED", - /* 79 */ "type_name ::= JSON", - /* 80 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 81 */ "type_name ::= MEDIUMBLOB", - /* 82 */ "type_name ::= BLOB", - /* 83 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 84 */ "type_name ::= DECIMAL", - /* 85 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 86 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 87 */ "tags_def_opt ::=", - /* 88 */ "tags_def_opt ::= tags_def", - /* 89 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 90 */ "table_options ::=", - /* 91 */ "table_options ::= table_options COMMENT NK_STRING", - /* 92 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 93 */ "table_options ::= table_options TTL NK_INTEGER", - /* 94 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 95 */ "col_name_list ::= col_name", - /* 96 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 97 */ "col_name ::= column_name", - /* 98 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 99 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 100 */ "cmd ::= DROP INDEX index_name ON table_name", - /* 101 */ "index_options ::=", - /* 102 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 103 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 104 */ "func_list ::= func", - /* 105 */ "func_list ::= func_list NK_COMMA func", - /* 106 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 107 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 108 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 109 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 110 */ "cmd ::= SHOW VGROUPS", - /* 111 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 112 */ "cmd ::= SHOW MNODES", - /* 113 */ "cmd ::= query_expression", - /* 114 */ "literal ::= NK_INTEGER", - /* 115 */ "literal ::= NK_FLOAT", - /* 116 */ "literal ::= NK_STRING", - /* 117 */ "literal ::= NK_BOOL", - /* 118 */ "literal ::= TIMESTAMP NK_STRING", - /* 119 */ "literal ::= duration_literal", - /* 120 */ "duration_literal ::= NK_VARIABLE", - /* 121 */ "literal_list ::= literal", - /* 122 */ "literal_list ::= literal_list NK_COMMA literal", - /* 123 */ "db_name ::= NK_ID", - /* 124 */ "table_name ::= NK_ID", - /* 125 */ "column_name ::= NK_ID", - /* 126 */ "function_name ::= NK_ID", - /* 127 */ "table_alias ::= NK_ID", - /* 128 */ "column_alias ::= NK_ID", - /* 129 */ "user_name ::= NK_ID", - /* 130 */ "index_name ::= NK_ID", - /* 131 */ "topic_name ::= NK_ID", - /* 132 */ "expression ::= literal", - /* 133 */ "expression ::= column_reference", - /* 134 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 135 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 136 */ "expression ::= subquery", - /* 137 */ "expression ::= NK_LP expression NK_RP", - /* 138 */ "expression ::= NK_PLUS expression", - /* 139 */ "expression ::= NK_MINUS expression", - /* 140 */ "expression ::= expression NK_PLUS expression", - /* 141 */ "expression ::= expression NK_MINUS expression", - /* 142 */ "expression ::= expression NK_STAR expression", - /* 143 */ "expression ::= expression NK_SLASH expression", - /* 144 */ "expression ::= expression NK_REM expression", - /* 145 */ "expression_list ::= expression", - /* 146 */ "expression_list ::= expression_list NK_COMMA expression", - /* 147 */ "column_reference ::= column_name", - /* 148 */ "column_reference ::= table_name NK_DOT column_name", - /* 149 */ "predicate ::= expression compare_op expression", - /* 150 */ "predicate ::= expression BETWEEN expression AND expression", - /* 151 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 152 */ "predicate ::= expression IS NULL", - /* 153 */ "predicate ::= expression IS NOT NULL", - /* 154 */ "predicate ::= expression in_op in_predicate_value", - /* 155 */ "compare_op ::= NK_LT", - /* 156 */ "compare_op ::= NK_GT", - /* 157 */ "compare_op ::= NK_LE", - /* 158 */ "compare_op ::= NK_GE", - /* 159 */ "compare_op ::= NK_NE", - /* 160 */ "compare_op ::= NK_EQ", - /* 161 */ "compare_op ::= LIKE", - /* 162 */ "compare_op ::= NOT LIKE", - /* 163 */ "compare_op ::= MATCH", - /* 164 */ "compare_op ::= NMATCH", - /* 165 */ "in_op ::= IN", - /* 166 */ "in_op ::= NOT IN", - /* 167 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 168 */ "boolean_value_expression ::= boolean_primary", - /* 169 */ "boolean_value_expression ::= NOT boolean_primary", - /* 170 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 171 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 172 */ "boolean_primary ::= predicate", - /* 173 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 174 */ "common_expression ::= expression", - /* 175 */ "common_expression ::= boolean_value_expression", - /* 176 */ "from_clause ::= FROM table_reference_list", - /* 177 */ "table_reference_list ::= table_reference", - /* 178 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 179 */ "table_reference ::= table_primary", - /* 180 */ "table_reference ::= joined_table", - /* 181 */ "table_primary ::= table_name alias_opt", - /* 182 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 183 */ "table_primary ::= subquery alias_opt", - /* 184 */ "table_primary ::= parenthesized_joined_table", - /* 185 */ "alias_opt ::=", - /* 186 */ "alias_opt ::= table_alias", - /* 187 */ "alias_opt ::= AS table_alias", - /* 188 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 189 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 190 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 191 */ "join_type ::=", - /* 192 */ "join_type ::= INNER", - /* 193 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 194 */ "set_quantifier_opt ::=", - /* 195 */ "set_quantifier_opt ::= DISTINCT", - /* 196 */ "set_quantifier_opt ::= ALL", - /* 197 */ "select_list ::= NK_STAR", - /* 198 */ "select_list ::= select_sublist", - /* 199 */ "select_sublist ::= select_item", - /* 200 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 201 */ "select_item ::= common_expression", - /* 202 */ "select_item ::= common_expression column_alias", - /* 203 */ "select_item ::= common_expression AS column_alias", - /* 204 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 205 */ "where_clause_opt ::=", - /* 206 */ "where_clause_opt ::= WHERE search_condition", - /* 207 */ "partition_by_clause_opt ::=", - /* 208 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 209 */ "twindow_clause_opt ::=", - /* 210 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 211 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 212 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 213 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 214 */ "sliding_opt ::=", - /* 215 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 216 */ "fill_opt ::=", - /* 217 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 218 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 219 */ "fill_mode ::= NONE", - /* 220 */ "fill_mode ::= PREV", - /* 221 */ "fill_mode ::= NULL", - /* 222 */ "fill_mode ::= LINEAR", - /* 223 */ "fill_mode ::= NEXT", - /* 224 */ "group_by_clause_opt ::=", - /* 225 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 226 */ "group_by_list ::= expression", - /* 227 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 228 */ "having_clause_opt ::=", - /* 229 */ "having_clause_opt ::= HAVING search_condition", - /* 230 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 231 */ "query_expression_body ::= query_primary", - /* 232 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 233 */ "query_primary ::= query_specification", - /* 234 */ "order_by_clause_opt ::=", - /* 235 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 236 */ "slimit_clause_opt ::=", - /* 237 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 238 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 239 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 240 */ "limit_clause_opt ::=", - /* 241 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 242 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 243 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 244 */ "subquery ::= NK_LP query_expression NK_RP", - /* 245 */ "search_condition ::= common_expression", - /* 246 */ "sort_specification_list ::= sort_specification", - /* 247 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 248 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 249 */ "ordering_specification_opt ::=", - /* 250 */ "ordering_specification_opt ::= ASC", - /* 251 */ "ordering_specification_opt ::= DESC", - /* 252 */ "null_ordering_opt ::=", - /* 253 */ "null_ordering_opt ::= NULLS FIRST", - /* 254 */ "null_ordering_opt ::= NULLS LAST", + /* 0 */ "cmd ::= ALTER ACCOUNT NK_ID account_options", + /* 1 */ "account_options ::= account_option", + /* 2 */ "account_options ::= account_options account_option", + /* 3 */ "account_option ::= PASS literal", + /* 4 */ "account_option ::= PPS literal", + /* 5 */ "account_option ::= TSERIES literal", + /* 6 */ "account_option ::= STORAGE literal", + /* 7 */ "account_option ::= STREAMS literal", + /* 8 */ "account_option ::= QTIME literal", + /* 9 */ "account_option ::= DBS literal", + /* 10 */ "account_option ::= USERS literal", + /* 11 */ "account_option ::= CONNS literal", + /* 12 */ "account_option ::= STATE literal", + /* 13 */ "cmd ::= CREATE USER user_name PASS NK_STRING", + /* 14 */ "cmd ::= ALTER USER user_name PASS NK_STRING", + /* 15 */ "cmd ::= ALTER USER user_name PRIVILEGE NK_STRING", + /* 16 */ "cmd ::= DROP USER user_name", + /* 17 */ "cmd ::= SHOW USERS", + /* 18 */ "cmd ::= CREATE DNODE dnode_endpoint", + /* 19 */ "cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER", + /* 20 */ "cmd ::= DROP DNODE NK_INTEGER", + /* 21 */ "cmd ::= DROP DNODE dnode_endpoint", + /* 22 */ "cmd ::= SHOW DNODES", + /* 23 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", + /* 24 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", + /* 25 */ "cmd ::= ALTER ALL DNODES NK_STRING", + /* 26 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", + /* 27 */ "dnode_endpoint ::= NK_STRING", + /* 28 */ "dnode_host_name ::= NK_ID", + /* 29 */ "dnode_host_name ::= NK_IPTOKEN", + /* 30 */ "cmd ::= ALTER LOCAL NK_STRING", + /* 31 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", + /* 32 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 33 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 34 */ "cmd ::= SHOW QNODES", + /* 35 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 36 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 37 */ "cmd ::= SHOW DATABASES", + /* 38 */ "cmd ::= USE db_name", + /* 39 */ "cmd ::= ALTER DATABASE db_name alter_db_options", + /* 40 */ "not_exists_opt ::= IF NOT EXISTS", + /* 41 */ "not_exists_opt ::=", + /* 42 */ "exists_opt ::= IF EXISTS", + /* 43 */ "exists_opt ::=", + /* 44 */ "db_options ::=", + /* 45 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 46 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 47 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 48 */ "db_options ::= db_options COMP NK_INTEGER", + /* 49 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 50 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 51 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 52 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 53 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 54 */ "db_options ::= db_options PRECISION NK_STRING", + /* 55 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 56 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 57 */ "db_options ::= db_options TTL NK_INTEGER", + /* 58 */ "db_options ::= db_options WAL NK_INTEGER", + /* 59 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 60 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 61 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 62 */ "db_options ::= db_options RETENTIONS NK_STRING", + /* 63 */ "db_options ::= db_options FILE_FACTOR NK_FLOAT", + /* 64 */ "alter_db_options ::= alter_db_option", + /* 65 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 66 */ "alter_db_option ::= BLOCKS NK_INTEGER", + /* 67 */ "alter_db_option ::= FSYNC NK_INTEGER", + /* 68 */ "alter_db_option ::= KEEP NK_INTEGER", + /* 69 */ "alter_db_option ::= WAL NK_INTEGER", + /* 70 */ "alter_db_option ::= QUORUM NK_INTEGER", + /* 71 */ "alter_db_option ::= CACHELAST NK_INTEGER", + /* 72 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 73 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 74 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 75 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 76 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 77 */ "cmd ::= SHOW TABLES", + /* 78 */ "cmd ::= SHOW STABLES", + /* 79 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 80 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 81 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 82 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 83 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 84 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 85 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 86 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 87 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 88 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 89 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 90 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", + /* 91 */ "multi_create_clause ::= create_subtable_clause", + /* 92 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 93 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 94 */ "multi_drop_clause ::= drop_table_clause", + /* 95 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 96 */ "drop_table_clause ::= exists_opt full_table_name", + /* 97 */ "specific_tags_opt ::=", + /* 98 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 99 */ "full_table_name ::= table_name", + /* 100 */ "full_table_name ::= db_name NK_DOT table_name", + /* 101 */ "column_def_list ::= column_def", + /* 102 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 103 */ "column_def ::= column_name type_name", + /* 104 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 105 */ "type_name ::= BOOL", + /* 106 */ "type_name ::= TINYINT", + /* 107 */ "type_name ::= SMALLINT", + /* 108 */ "type_name ::= INT", + /* 109 */ "type_name ::= INTEGER", + /* 110 */ "type_name ::= BIGINT", + /* 111 */ "type_name ::= FLOAT", + /* 112 */ "type_name ::= DOUBLE", + /* 113 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 114 */ "type_name ::= TIMESTAMP", + /* 115 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 116 */ "type_name ::= TINYINT UNSIGNED", + /* 117 */ "type_name ::= SMALLINT UNSIGNED", + /* 118 */ "type_name ::= INT UNSIGNED", + /* 119 */ "type_name ::= BIGINT UNSIGNED", + /* 120 */ "type_name ::= JSON", + /* 121 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 122 */ "type_name ::= MEDIUMBLOB", + /* 123 */ "type_name ::= BLOB", + /* 124 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 125 */ "type_name ::= DECIMAL", + /* 126 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 127 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 128 */ "tags_def_opt ::=", + /* 129 */ "tags_def_opt ::= tags_def", + /* 130 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 131 */ "table_options ::=", + /* 132 */ "table_options ::= table_options COMMENT NK_STRING", + /* 133 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 134 */ "table_options ::= table_options TTL NK_INTEGER", + /* 135 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 136 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 137 */ "alter_table_options ::= alter_table_option", + /* 138 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 139 */ "alter_table_option ::= COMMENT NK_STRING", + /* 140 */ "alter_table_option ::= KEEP NK_INTEGER", + /* 141 */ "alter_table_option ::= TTL NK_INTEGER", + /* 142 */ "col_name_list ::= col_name", + /* 143 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 144 */ "col_name ::= column_name", + /* 145 */ "func_name_list ::= func_name", + /* 146 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 147 */ "func_name ::= function_name", + /* 148 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 149 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 150 */ "cmd ::= DROP INDEX index_name ON table_name", + /* 151 */ "index_options ::=", + /* 152 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 153 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 154 */ "func_list ::= func", + /* 155 */ "func_list ::= func_list NK_COMMA func", + /* 156 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 157 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 158 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 159 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 160 */ "cmd ::= SHOW VGROUPS", + /* 161 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 162 */ "cmd ::= SHOW MNODES", + /* 163 */ "cmd ::= query_expression", + /* 164 */ "literal ::= NK_INTEGER", + /* 165 */ "literal ::= NK_FLOAT", + /* 166 */ "literal ::= NK_STRING", + /* 167 */ "literal ::= NK_BOOL", + /* 168 */ "literal ::= TIMESTAMP NK_STRING", + /* 169 */ "literal ::= duration_literal", + /* 170 */ "duration_literal ::= NK_VARIABLE", + /* 171 */ "literal_list ::= literal", + /* 172 */ "literal_list ::= literal_list NK_COMMA literal", + /* 173 */ "db_name ::= NK_ID", + /* 174 */ "table_name ::= NK_ID", + /* 175 */ "column_name ::= NK_ID", + /* 176 */ "function_name ::= NK_ID", + /* 177 */ "table_alias ::= NK_ID", + /* 178 */ "column_alias ::= NK_ID", + /* 179 */ "user_name ::= NK_ID", + /* 180 */ "index_name ::= NK_ID", + /* 181 */ "topic_name ::= NK_ID", + /* 182 */ "expression ::= literal", + /* 183 */ "expression ::= column_reference", + /* 184 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 185 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 186 */ "expression ::= subquery", + /* 187 */ "expression ::= NK_LP expression NK_RP", + /* 188 */ "expression ::= NK_PLUS expression", + /* 189 */ "expression ::= NK_MINUS expression", + /* 190 */ "expression ::= expression NK_PLUS expression", + /* 191 */ "expression ::= expression NK_MINUS expression", + /* 192 */ "expression ::= expression NK_STAR expression", + /* 193 */ "expression ::= expression NK_SLASH expression", + /* 194 */ "expression ::= expression NK_REM expression", + /* 195 */ "expression_list ::= expression", + /* 196 */ "expression_list ::= expression_list NK_COMMA expression", + /* 197 */ "column_reference ::= column_name", + /* 198 */ "column_reference ::= table_name NK_DOT column_name", + /* 199 */ "predicate ::= expression compare_op expression", + /* 200 */ "predicate ::= expression BETWEEN expression AND expression", + /* 201 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 202 */ "predicate ::= expression IS NULL", + /* 203 */ "predicate ::= expression IS NOT NULL", + /* 204 */ "predicate ::= expression in_op in_predicate_value", + /* 205 */ "compare_op ::= NK_LT", + /* 206 */ "compare_op ::= NK_GT", + /* 207 */ "compare_op ::= NK_LE", + /* 208 */ "compare_op ::= NK_GE", + /* 209 */ "compare_op ::= NK_NE", + /* 210 */ "compare_op ::= NK_EQ", + /* 211 */ "compare_op ::= LIKE", + /* 212 */ "compare_op ::= NOT LIKE", + /* 213 */ "compare_op ::= MATCH", + /* 214 */ "compare_op ::= NMATCH", + /* 215 */ "in_op ::= IN", + /* 216 */ "in_op ::= NOT IN", + /* 217 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 218 */ "boolean_value_expression ::= boolean_primary", + /* 219 */ "boolean_value_expression ::= NOT boolean_primary", + /* 220 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 221 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 222 */ "boolean_primary ::= predicate", + /* 223 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 224 */ "common_expression ::= expression", + /* 225 */ "common_expression ::= boolean_value_expression", + /* 226 */ "from_clause ::= FROM table_reference_list", + /* 227 */ "table_reference_list ::= table_reference", + /* 228 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 229 */ "table_reference ::= table_primary", + /* 230 */ "table_reference ::= joined_table", + /* 231 */ "table_primary ::= table_name alias_opt", + /* 232 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 233 */ "table_primary ::= subquery alias_opt", + /* 234 */ "table_primary ::= parenthesized_joined_table", + /* 235 */ "alias_opt ::=", + /* 236 */ "alias_opt ::= table_alias", + /* 237 */ "alias_opt ::= AS table_alias", + /* 238 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 239 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 240 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 241 */ "join_type ::=", + /* 242 */ "join_type ::= INNER", + /* 243 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 244 */ "set_quantifier_opt ::=", + /* 245 */ "set_quantifier_opt ::= DISTINCT", + /* 246 */ "set_quantifier_opt ::= ALL", + /* 247 */ "select_list ::= NK_STAR", + /* 248 */ "select_list ::= select_sublist", + /* 249 */ "select_sublist ::= select_item", + /* 250 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 251 */ "select_item ::= common_expression", + /* 252 */ "select_item ::= common_expression column_alias", + /* 253 */ "select_item ::= common_expression AS column_alias", + /* 254 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 255 */ "where_clause_opt ::=", + /* 256 */ "where_clause_opt ::= WHERE search_condition", + /* 257 */ "partition_by_clause_opt ::=", + /* 258 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 259 */ "twindow_clause_opt ::=", + /* 260 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 261 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 262 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 263 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 264 */ "sliding_opt ::=", + /* 265 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 266 */ "fill_opt ::=", + /* 267 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 268 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 269 */ "fill_mode ::= NONE", + /* 270 */ "fill_mode ::= PREV", + /* 271 */ "fill_mode ::= NULL", + /* 272 */ "fill_mode ::= LINEAR", + /* 273 */ "fill_mode ::= NEXT", + /* 274 */ "group_by_clause_opt ::=", + /* 275 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 276 */ "group_by_list ::= expression", + /* 277 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 278 */ "having_clause_opt ::=", + /* 279 */ "having_clause_opt ::= HAVING search_condition", + /* 280 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 281 */ "query_expression_body ::= query_primary", + /* 282 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 283 */ "query_primary ::= query_specification", + /* 284 */ "order_by_clause_opt ::=", + /* 285 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 286 */ "slimit_clause_opt ::=", + /* 287 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 288 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 289 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 290 */ "limit_clause_opt ::=", + /* 291 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 292 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 293 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 294 */ "subquery ::= NK_LP query_expression NK_RP", + /* 295 */ "search_condition ::= common_expression", + /* 296 */ "sort_specification_list ::= sort_specification", + /* 297 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 298 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 299 */ "ordering_specification_opt ::=", + /* 300 */ "ordering_specification_opt ::= ASC", + /* 301 */ "ordering_specification_opt ::= DESC", + /* 302 */ "null_ordering_opt ::=", + /* 303 */ "null_ordering_opt ::= NULLS FIRST", + /* 304 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1236,121 +1360,138 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 141: /* cmd */ - case 147: /* db_options */ - case 149: /* full_table_name */ - case 152: /* table_options */ - case 156: /* create_subtable_clause */ - case 159: /* drop_table_clause */ - case 162: /* column_def */ - case 165: /* col_name */ - case 167: /* index_options */ - case 169: /* duration_literal */ - case 170: /* sliding_opt */ - case 171: /* func */ - case 175: /* query_expression */ - case 176: /* literal */ - case 179: /* expression */ - case 180: /* column_reference */ - case 181: /* subquery */ - case 182: /* predicate */ - case 185: /* in_predicate_value */ - case 186: /* boolean_value_expression */ - case 187: /* boolean_primary */ - case 188: /* common_expression */ - case 189: /* from_clause */ - case 190: /* table_reference_list */ - case 191: /* table_reference */ - case 192: /* table_primary */ - case 193: /* joined_table */ - case 195: /* parenthesized_joined_table */ - case 197: /* search_condition */ - case 198: /* query_specification */ - case 201: /* where_clause_opt */ - case 203: /* twindow_clause_opt */ - case 205: /* having_clause_opt */ - case 207: /* select_item */ - case 208: /* fill_opt */ - case 211: /* query_expression_body */ - case 213: /* slimit_clause_opt */ - case 214: /* limit_clause_opt */ - case 215: /* query_primary */ - case 217: /* sort_specification */ + case 160: /* cmd */ + case 163: /* literal */ + case 169: /* db_options */ + case 171: /* alter_db_options */ + case 173: /* full_table_name */ + case 176: /* table_options */ + case 180: /* alter_table_clause */ + case 181: /* alter_table_options */ + case 184: /* create_subtable_clause */ + case 187: /* drop_table_clause */ + case 190: /* column_def */ + case 193: /* col_name */ + case 194: /* func_name */ + case 197: /* index_options */ + case 199: /* duration_literal */ + case 200: /* sliding_opt */ + case 201: /* func */ + case 204: /* query_expression */ + case 207: /* expression */ + case 208: /* column_reference */ + case 209: /* subquery */ + case 210: /* predicate */ + case 213: /* in_predicate_value */ + case 214: /* boolean_value_expression */ + case 215: /* boolean_primary */ + case 216: /* common_expression */ + case 217: /* from_clause */ + case 218: /* table_reference_list */ + case 219: /* table_reference */ + case 220: /* table_primary */ + case 221: /* joined_table */ + case 223: /* parenthesized_joined_table */ + case 225: /* search_condition */ + case 226: /* query_specification */ + case 229: /* where_clause_opt */ + case 231: /* twindow_clause_opt */ + case 233: /* having_clause_opt */ + case 235: /* select_item */ + case 236: /* fill_opt */ + case 239: /* query_expression_body */ + case 241: /* slimit_clause_opt */ + case 242: /* limit_clause_opt */ + case 243: /* query_primary */ + case 245: /* sort_specification */ { - nodesDestroyNode((yypminor->yy432)); + nodesDestroyNode((yypminor->yy168)); } break; - case 142: /* user_name */ - case 143: /* dnode_endpoint */ - case 144: /* dnode_host_name */ - case 146: /* db_name */ - case 161: /* table_name */ - case 163: /* column_name */ - case 166: /* index_name */ - case 172: /* function_name */ - case 174: /* topic_name */ - case 177: /* table_alias */ - case 178: /* column_alias */ - case 194: /* alias_opt */ + case 161: /* account_options */ + case 162: /* account_option */ { } break; - case 145: /* not_exists_opt */ - case 148: /* exists_opt */ - case 199: /* set_quantifier_opt */ + case 164: /* user_name */ + case 165: /* dnode_endpoint */ + case 166: /* dnode_host_name */ + case 168: /* db_name */ + case 182: /* column_name */ + case 189: /* table_name */ + case 195: /* function_name */ + case 196: /* index_name */ + case 203: /* topic_name */ + case 205: /* table_alias */ + case 206: /* column_alias */ + case 222: /* alias_opt */ { } break; - case 150: /* column_def_list */ - case 151: /* tags_def_opt */ - case 153: /* multi_create_clause */ - case 154: /* tags_def */ - case 155: /* multi_drop_clause */ - case 157: /* specific_tags_opt */ - case 158: /* literal_list */ - case 160: /* col_name_list */ - case 168: /* func_list */ - case 173: /* expression_list */ - case 200: /* select_list */ - case 202: /* partition_by_clause_opt */ - case 204: /* group_by_clause_opt */ - case 206: /* select_sublist */ - case 210: /* group_by_list */ - case 212: /* order_by_clause_opt */ - case 216: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy24)); -} - break; - case 164: /* type_name */ + case 167: /* not_exists_opt */ + case 170: /* exists_opt */ + case 227: /* set_quantifier_opt */ { } break; - case 183: /* compare_op */ - case 184: /* in_op */ + case 172: /* alter_db_option */ + case 192: /* alter_table_option */ { } break; - case 196: /* join_type */ + case 174: /* column_def_list */ + case 175: /* tags_def_opt */ + case 177: /* multi_create_clause */ + case 178: /* tags_def */ + case 179: /* multi_drop_clause */ + case 185: /* specific_tags_opt */ + case 186: /* literal_list */ + case 188: /* col_name_list */ + case 191: /* func_name_list */ + case 198: /* func_list */ + case 202: /* expression_list */ + case 228: /* select_list */ + case 230: /* partition_by_clause_opt */ + case 232: /* group_by_clause_opt */ + case 234: /* select_sublist */ + case 238: /* group_by_list */ + case 240: /* order_by_clause_opt */ + case 244: /* sort_specification_list */ +{ + nodesDestroyList((yypminor->yy440)); +} + break; + case 183: /* type_name */ { } break; - case 209: /* fill_mode */ + case 211: /* compare_op */ + case 212: /* in_op */ { } break; - case 218: /* ordering_specification_opt */ + case 224: /* join_type */ { } break; - case 219: /* null_ordering_opt */ + case 237: /* fill_mode */ +{ + +} + break; + case 246: /* ordering_specification_opt */ +{ + +} + break; + case 247: /* null_ordering_opt */ { } @@ -1649,261 +1790,311 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 141, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 141, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 141, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 141, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 141, -2 }, /* (4) cmd ::= SHOW USERS */ - { 141, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 141, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 141, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 141, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 141, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 143, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 144, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 144, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 141, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 141, -5 }, /* (14) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 141, -2 }, /* (15) cmd ::= SHOW QNODES */ - { 141, -5 }, /* (16) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 141, -4 }, /* (17) cmd ::= DROP DATABASE exists_opt db_name */ - { 141, -2 }, /* (18) cmd ::= SHOW DATABASES */ - { 141, -2 }, /* (19) cmd ::= USE db_name */ - { 141, -4 }, /* (20) cmd ::= ALTER DATABASE db_name db_options */ - { 145, -3 }, /* (21) not_exists_opt ::= IF NOT EXISTS */ - { 145, 0 }, /* (22) not_exists_opt ::= */ - { 148, -2 }, /* (23) exists_opt ::= IF EXISTS */ - { 148, 0 }, /* (24) exists_opt ::= */ - { 147, 0 }, /* (25) db_options ::= */ - { 147, -3 }, /* (26) db_options ::= db_options BLOCKS NK_INTEGER */ - { 147, -3 }, /* (27) db_options ::= db_options CACHE NK_INTEGER */ - { 147, -3 }, /* (28) db_options ::= db_options CACHELAST NK_INTEGER */ - { 147, -3 }, /* (29) db_options ::= db_options COMP NK_INTEGER */ - { 147, -3 }, /* (30) db_options ::= db_options DAYS NK_INTEGER */ - { 147, -3 }, /* (31) db_options ::= db_options FSYNC NK_INTEGER */ - { 147, -3 }, /* (32) db_options ::= db_options MAXROWS NK_INTEGER */ - { 147, -3 }, /* (33) db_options ::= db_options MINROWS NK_INTEGER */ - { 147, -3 }, /* (34) db_options ::= db_options KEEP NK_INTEGER */ - { 147, -3 }, /* (35) db_options ::= db_options PRECISION NK_STRING */ - { 147, -3 }, /* (36) db_options ::= db_options QUORUM NK_INTEGER */ - { 147, -3 }, /* (37) db_options ::= db_options REPLICA NK_INTEGER */ - { 147, -3 }, /* (38) db_options ::= db_options TTL NK_INTEGER */ - { 147, -3 }, /* (39) db_options ::= db_options WAL NK_INTEGER */ - { 147, -3 }, /* (40) db_options ::= db_options VGROUPS NK_INTEGER */ - { 147, -3 }, /* (41) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 147, -3 }, /* (42) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 141, -9 }, /* (43) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 141, -3 }, /* (44) cmd ::= CREATE TABLE multi_create_clause */ - { 141, -9 }, /* (45) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 141, -3 }, /* (46) cmd ::= DROP TABLE multi_drop_clause */ - { 141, -4 }, /* (47) cmd ::= DROP STABLE exists_opt full_table_name */ - { 141, -2 }, /* (48) cmd ::= SHOW TABLES */ - { 141, -2 }, /* (49) cmd ::= SHOW STABLES */ - { 153, -1 }, /* (50) multi_create_clause ::= create_subtable_clause */ - { 153, -2 }, /* (51) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 156, -9 }, /* (52) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 155, -1 }, /* (53) multi_drop_clause ::= drop_table_clause */ - { 155, -2 }, /* (54) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 159, -2 }, /* (55) drop_table_clause ::= exists_opt full_table_name */ - { 157, 0 }, /* (56) specific_tags_opt ::= */ - { 157, -3 }, /* (57) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 149, -1 }, /* (58) full_table_name ::= table_name */ - { 149, -3 }, /* (59) full_table_name ::= db_name NK_DOT table_name */ - { 150, -1 }, /* (60) column_def_list ::= column_def */ - { 150, -3 }, /* (61) column_def_list ::= column_def_list NK_COMMA column_def */ - { 162, -2 }, /* (62) column_def ::= column_name type_name */ - { 162, -4 }, /* (63) column_def ::= column_name type_name COMMENT NK_STRING */ - { 164, -1 }, /* (64) type_name ::= BOOL */ - { 164, -1 }, /* (65) type_name ::= TINYINT */ - { 164, -1 }, /* (66) type_name ::= SMALLINT */ - { 164, -1 }, /* (67) type_name ::= INT */ - { 164, -1 }, /* (68) type_name ::= INTEGER */ - { 164, -1 }, /* (69) type_name ::= BIGINT */ - { 164, -1 }, /* (70) type_name ::= FLOAT */ - { 164, -1 }, /* (71) type_name ::= DOUBLE */ - { 164, -4 }, /* (72) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 164, -1 }, /* (73) type_name ::= TIMESTAMP */ - { 164, -4 }, /* (74) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 164, -2 }, /* (75) type_name ::= TINYINT UNSIGNED */ - { 164, -2 }, /* (76) type_name ::= SMALLINT UNSIGNED */ - { 164, -2 }, /* (77) type_name ::= INT UNSIGNED */ - { 164, -2 }, /* (78) type_name ::= BIGINT UNSIGNED */ - { 164, -1 }, /* (79) type_name ::= JSON */ - { 164, -4 }, /* (80) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 164, -1 }, /* (81) type_name ::= MEDIUMBLOB */ - { 164, -1 }, /* (82) type_name ::= BLOB */ - { 164, -4 }, /* (83) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 164, -1 }, /* (84) type_name ::= DECIMAL */ - { 164, -4 }, /* (85) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 164, -6 }, /* (86) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 151, 0 }, /* (87) tags_def_opt ::= */ - { 151, -1 }, /* (88) tags_def_opt ::= tags_def */ - { 154, -4 }, /* (89) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 152, 0 }, /* (90) table_options ::= */ - { 152, -3 }, /* (91) table_options ::= table_options COMMENT NK_STRING */ - { 152, -3 }, /* (92) table_options ::= table_options KEEP NK_INTEGER */ - { 152, -3 }, /* (93) table_options ::= table_options TTL NK_INTEGER */ - { 152, -5 }, /* (94) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 160, -1 }, /* (95) col_name_list ::= col_name */ - { 160, -3 }, /* (96) col_name_list ::= col_name_list NK_COMMA col_name */ - { 165, -1 }, /* (97) col_name ::= column_name */ - { 141, -7 }, /* (98) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 141, -9 }, /* (99) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 141, -5 }, /* (100) cmd ::= DROP INDEX index_name ON table_name */ - { 167, 0 }, /* (101) index_options ::= */ - { 167, -9 }, /* (102) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 167, -11 }, /* (103) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 168, -1 }, /* (104) func_list ::= func */ - { 168, -3 }, /* (105) func_list ::= func_list NK_COMMA func */ - { 171, -4 }, /* (106) func ::= function_name NK_LP expression_list NK_RP */ - { 141, -6 }, /* (107) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 141, -6 }, /* (108) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 141, -4 }, /* (109) cmd ::= DROP TOPIC exists_opt topic_name */ - { 141, -2 }, /* (110) cmd ::= SHOW VGROUPS */ - { 141, -4 }, /* (111) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 141, -2 }, /* (112) cmd ::= SHOW MNODES */ - { 141, -1 }, /* (113) cmd ::= query_expression */ - { 176, -1 }, /* (114) literal ::= NK_INTEGER */ - { 176, -1 }, /* (115) literal ::= NK_FLOAT */ - { 176, -1 }, /* (116) literal ::= NK_STRING */ - { 176, -1 }, /* (117) literal ::= NK_BOOL */ - { 176, -2 }, /* (118) literal ::= TIMESTAMP NK_STRING */ - { 176, -1 }, /* (119) literal ::= duration_literal */ - { 169, -1 }, /* (120) duration_literal ::= NK_VARIABLE */ - { 158, -1 }, /* (121) literal_list ::= literal */ - { 158, -3 }, /* (122) literal_list ::= literal_list NK_COMMA literal */ - { 146, -1 }, /* (123) db_name ::= NK_ID */ - { 161, -1 }, /* (124) table_name ::= NK_ID */ - { 163, -1 }, /* (125) column_name ::= NK_ID */ - { 172, -1 }, /* (126) function_name ::= NK_ID */ - { 177, -1 }, /* (127) table_alias ::= NK_ID */ - { 178, -1 }, /* (128) column_alias ::= NK_ID */ - { 142, -1 }, /* (129) user_name ::= NK_ID */ - { 166, -1 }, /* (130) index_name ::= NK_ID */ - { 174, -1 }, /* (131) topic_name ::= NK_ID */ - { 179, -1 }, /* (132) expression ::= literal */ - { 179, -1 }, /* (133) expression ::= column_reference */ - { 179, -4 }, /* (134) expression ::= function_name NK_LP expression_list NK_RP */ - { 179, -4 }, /* (135) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 179, -1 }, /* (136) expression ::= subquery */ - { 179, -3 }, /* (137) expression ::= NK_LP expression NK_RP */ - { 179, -2 }, /* (138) expression ::= NK_PLUS expression */ - { 179, -2 }, /* (139) expression ::= NK_MINUS expression */ - { 179, -3 }, /* (140) expression ::= expression NK_PLUS expression */ - { 179, -3 }, /* (141) expression ::= expression NK_MINUS expression */ - { 179, -3 }, /* (142) expression ::= expression NK_STAR expression */ - { 179, -3 }, /* (143) expression ::= expression NK_SLASH expression */ - { 179, -3 }, /* (144) expression ::= expression NK_REM expression */ - { 173, -1 }, /* (145) expression_list ::= expression */ - { 173, -3 }, /* (146) expression_list ::= expression_list NK_COMMA expression */ - { 180, -1 }, /* (147) column_reference ::= column_name */ - { 180, -3 }, /* (148) column_reference ::= table_name NK_DOT column_name */ - { 182, -3 }, /* (149) predicate ::= expression compare_op expression */ - { 182, -5 }, /* (150) predicate ::= expression BETWEEN expression AND expression */ - { 182, -6 }, /* (151) predicate ::= expression NOT BETWEEN expression AND expression */ - { 182, -3 }, /* (152) predicate ::= expression IS NULL */ - { 182, -4 }, /* (153) predicate ::= expression IS NOT NULL */ - { 182, -3 }, /* (154) predicate ::= expression in_op in_predicate_value */ - { 183, -1 }, /* (155) compare_op ::= NK_LT */ - { 183, -1 }, /* (156) compare_op ::= NK_GT */ - { 183, -1 }, /* (157) compare_op ::= NK_LE */ - { 183, -1 }, /* (158) compare_op ::= NK_GE */ - { 183, -1 }, /* (159) compare_op ::= NK_NE */ - { 183, -1 }, /* (160) compare_op ::= NK_EQ */ - { 183, -1 }, /* (161) compare_op ::= LIKE */ - { 183, -2 }, /* (162) compare_op ::= NOT LIKE */ - { 183, -1 }, /* (163) compare_op ::= MATCH */ - { 183, -1 }, /* (164) compare_op ::= NMATCH */ - { 184, -1 }, /* (165) in_op ::= IN */ - { 184, -2 }, /* (166) in_op ::= NOT IN */ - { 185, -3 }, /* (167) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 186, -1 }, /* (168) boolean_value_expression ::= boolean_primary */ - { 186, -2 }, /* (169) boolean_value_expression ::= NOT boolean_primary */ - { 186, -3 }, /* (170) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 186, -3 }, /* (171) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 187, -1 }, /* (172) boolean_primary ::= predicate */ - { 187, -3 }, /* (173) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 188, -1 }, /* (174) common_expression ::= expression */ - { 188, -1 }, /* (175) common_expression ::= boolean_value_expression */ - { 189, -2 }, /* (176) from_clause ::= FROM table_reference_list */ - { 190, -1 }, /* (177) table_reference_list ::= table_reference */ - { 190, -3 }, /* (178) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 191, -1 }, /* (179) table_reference ::= table_primary */ - { 191, -1 }, /* (180) table_reference ::= joined_table */ - { 192, -2 }, /* (181) table_primary ::= table_name alias_opt */ - { 192, -4 }, /* (182) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 192, -2 }, /* (183) table_primary ::= subquery alias_opt */ - { 192, -1 }, /* (184) table_primary ::= parenthesized_joined_table */ - { 194, 0 }, /* (185) alias_opt ::= */ - { 194, -1 }, /* (186) alias_opt ::= table_alias */ - { 194, -2 }, /* (187) alias_opt ::= AS table_alias */ - { 195, -3 }, /* (188) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 195, -3 }, /* (189) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 193, -6 }, /* (190) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 196, 0 }, /* (191) join_type ::= */ - { 196, -1 }, /* (192) join_type ::= INNER */ - { 198, -9 }, /* (193) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 199, 0 }, /* (194) set_quantifier_opt ::= */ - { 199, -1 }, /* (195) set_quantifier_opt ::= DISTINCT */ - { 199, -1 }, /* (196) set_quantifier_opt ::= ALL */ - { 200, -1 }, /* (197) select_list ::= NK_STAR */ - { 200, -1 }, /* (198) select_list ::= select_sublist */ - { 206, -1 }, /* (199) select_sublist ::= select_item */ - { 206, -3 }, /* (200) select_sublist ::= select_sublist NK_COMMA select_item */ - { 207, -1 }, /* (201) select_item ::= common_expression */ - { 207, -2 }, /* (202) select_item ::= common_expression column_alias */ - { 207, -3 }, /* (203) select_item ::= common_expression AS column_alias */ - { 207, -3 }, /* (204) select_item ::= table_name NK_DOT NK_STAR */ - { 201, 0 }, /* (205) where_clause_opt ::= */ - { 201, -2 }, /* (206) where_clause_opt ::= WHERE search_condition */ - { 202, 0 }, /* (207) partition_by_clause_opt ::= */ - { 202, -3 }, /* (208) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 203, 0 }, /* (209) twindow_clause_opt ::= */ - { 203, -6 }, /* (210) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 203, -4 }, /* (211) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 203, -6 }, /* (212) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 203, -8 }, /* (213) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 170, 0 }, /* (214) sliding_opt ::= */ - { 170, -4 }, /* (215) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 208, 0 }, /* (216) fill_opt ::= */ - { 208, -4 }, /* (217) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 208, -6 }, /* (218) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 209, -1 }, /* (219) fill_mode ::= NONE */ - { 209, -1 }, /* (220) fill_mode ::= PREV */ - { 209, -1 }, /* (221) fill_mode ::= NULL */ - { 209, -1 }, /* (222) fill_mode ::= LINEAR */ - { 209, -1 }, /* (223) fill_mode ::= NEXT */ - { 204, 0 }, /* (224) group_by_clause_opt ::= */ - { 204, -3 }, /* (225) group_by_clause_opt ::= GROUP BY group_by_list */ - { 210, -1 }, /* (226) group_by_list ::= expression */ - { 210, -3 }, /* (227) group_by_list ::= group_by_list NK_COMMA expression */ - { 205, 0 }, /* (228) having_clause_opt ::= */ - { 205, -2 }, /* (229) having_clause_opt ::= HAVING search_condition */ - { 175, -4 }, /* (230) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 211, -1 }, /* (231) query_expression_body ::= query_primary */ - { 211, -4 }, /* (232) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 215, -1 }, /* (233) query_primary ::= query_specification */ - { 212, 0 }, /* (234) order_by_clause_opt ::= */ - { 212, -3 }, /* (235) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 213, 0 }, /* (236) slimit_clause_opt ::= */ - { 213, -2 }, /* (237) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 213, -4 }, /* (238) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 213, -4 }, /* (239) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 214, 0 }, /* (240) limit_clause_opt ::= */ - { 214, -2 }, /* (241) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 214, -4 }, /* (242) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 214, -4 }, /* (243) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 181, -3 }, /* (244) subquery ::= NK_LP query_expression NK_RP */ - { 197, -1 }, /* (245) search_condition ::= common_expression */ - { 216, -1 }, /* (246) sort_specification_list ::= sort_specification */ - { 216, -3 }, /* (247) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 217, -3 }, /* (248) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 218, 0 }, /* (249) ordering_specification_opt ::= */ - { 218, -1 }, /* (250) ordering_specification_opt ::= ASC */ - { 218, -1 }, /* (251) ordering_specification_opt ::= DESC */ - { 219, 0 }, /* (252) null_ordering_opt ::= */ - { 219, -2 }, /* (253) null_ordering_opt ::= NULLS FIRST */ - { 219, -2 }, /* (254) null_ordering_opt ::= NULLS LAST */ + { 160, -4 }, /* (0) cmd ::= ALTER ACCOUNT NK_ID account_options */ + { 161, -1 }, /* (1) account_options ::= account_option */ + { 161, -2 }, /* (2) account_options ::= account_options account_option */ + { 162, -2 }, /* (3) account_option ::= PASS literal */ + { 162, -2 }, /* (4) account_option ::= PPS literal */ + { 162, -2 }, /* (5) account_option ::= TSERIES literal */ + { 162, -2 }, /* (6) account_option ::= STORAGE literal */ + { 162, -2 }, /* (7) account_option ::= STREAMS literal */ + { 162, -2 }, /* (8) account_option ::= QTIME literal */ + { 162, -2 }, /* (9) account_option ::= DBS literal */ + { 162, -2 }, /* (10) account_option ::= USERS literal */ + { 162, -2 }, /* (11) account_option ::= CONNS literal */ + { 162, -2 }, /* (12) account_option ::= STATE literal */ + { 160, -5 }, /* (13) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 160, -5 }, /* (14) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 160, -5 }, /* (15) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 160, -3 }, /* (16) cmd ::= DROP USER user_name */ + { 160, -2 }, /* (17) cmd ::= SHOW USERS */ + { 160, -3 }, /* (18) cmd ::= CREATE DNODE dnode_endpoint */ + { 160, -5 }, /* (19) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 160, -3 }, /* (20) cmd ::= DROP DNODE NK_INTEGER */ + { 160, -3 }, /* (21) cmd ::= DROP DNODE dnode_endpoint */ + { 160, -2 }, /* (22) cmd ::= SHOW DNODES */ + { 160, -4 }, /* (23) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 160, -5 }, /* (24) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 160, -4 }, /* (25) cmd ::= ALTER ALL DNODES NK_STRING */ + { 160, -5 }, /* (26) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 165, -1 }, /* (27) dnode_endpoint ::= NK_STRING */ + { 166, -1 }, /* (28) dnode_host_name ::= NK_ID */ + { 166, -1 }, /* (29) dnode_host_name ::= NK_IPTOKEN */ + { 160, -3 }, /* (30) cmd ::= ALTER LOCAL NK_STRING */ + { 160, -4 }, /* (31) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 160, -5 }, /* (32) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 160, -5 }, /* (33) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 160, -2 }, /* (34) cmd ::= SHOW QNODES */ + { 160, -5 }, /* (35) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 160, -4 }, /* (36) cmd ::= DROP DATABASE exists_opt db_name */ + { 160, -2 }, /* (37) cmd ::= SHOW DATABASES */ + { 160, -2 }, /* (38) cmd ::= USE db_name */ + { 160, -4 }, /* (39) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 167, -3 }, /* (40) not_exists_opt ::= IF NOT EXISTS */ + { 167, 0 }, /* (41) not_exists_opt ::= */ + { 170, -2 }, /* (42) exists_opt ::= IF EXISTS */ + { 170, 0 }, /* (43) exists_opt ::= */ + { 169, 0 }, /* (44) db_options ::= */ + { 169, -3 }, /* (45) db_options ::= db_options BLOCKS NK_INTEGER */ + { 169, -3 }, /* (46) db_options ::= db_options CACHE NK_INTEGER */ + { 169, -3 }, /* (47) db_options ::= db_options CACHELAST NK_INTEGER */ + { 169, -3 }, /* (48) db_options ::= db_options COMP NK_INTEGER */ + { 169, -3 }, /* (49) db_options ::= db_options DAYS NK_INTEGER */ + { 169, -3 }, /* (50) db_options ::= db_options FSYNC NK_INTEGER */ + { 169, -3 }, /* (51) db_options ::= db_options MAXROWS NK_INTEGER */ + { 169, -3 }, /* (52) db_options ::= db_options MINROWS NK_INTEGER */ + { 169, -3 }, /* (53) db_options ::= db_options KEEP NK_INTEGER */ + { 169, -3 }, /* (54) db_options ::= db_options PRECISION NK_STRING */ + { 169, -3 }, /* (55) db_options ::= db_options QUORUM NK_INTEGER */ + { 169, -3 }, /* (56) db_options ::= db_options REPLICA NK_INTEGER */ + { 169, -3 }, /* (57) db_options ::= db_options TTL NK_INTEGER */ + { 169, -3 }, /* (58) db_options ::= db_options WAL NK_INTEGER */ + { 169, -3 }, /* (59) db_options ::= db_options VGROUPS NK_INTEGER */ + { 169, -3 }, /* (60) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 169, -3 }, /* (61) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 169, -3 }, /* (62) db_options ::= db_options RETENTIONS NK_STRING */ + { 169, -3 }, /* (63) db_options ::= db_options FILE_FACTOR NK_FLOAT */ + { 171, -1 }, /* (64) alter_db_options ::= alter_db_option */ + { 171, -2 }, /* (65) alter_db_options ::= alter_db_options alter_db_option */ + { 172, -2 }, /* (66) alter_db_option ::= BLOCKS NK_INTEGER */ + { 172, -2 }, /* (67) alter_db_option ::= FSYNC NK_INTEGER */ + { 172, -2 }, /* (68) alter_db_option ::= KEEP NK_INTEGER */ + { 172, -2 }, /* (69) alter_db_option ::= WAL NK_INTEGER */ + { 172, -2 }, /* (70) alter_db_option ::= QUORUM NK_INTEGER */ + { 172, -2 }, /* (71) alter_db_option ::= CACHELAST NK_INTEGER */ + { 160, -9 }, /* (72) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 160, -3 }, /* (73) cmd ::= CREATE TABLE multi_create_clause */ + { 160, -9 }, /* (74) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 160, -3 }, /* (75) cmd ::= DROP TABLE multi_drop_clause */ + { 160, -4 }, /* (76) cmd ::= DROP STABLE exists_opt full_table_name */ + { 160, -2 }, /* (77) cmd ::= SHOW TABLES */ + { 160, -2 }, /* (78) cmd ::= SHOW STABLES */ + { 160, -3 }, /* (79) cmd ::= ALTER TABLE alter_table_clause */ + { 160, -3 }, /* (80) cmd ::= ALTER STABLE alter_table_clause */ + { 180, -2 }, /* (81) alter_table_clause ::= full_table_name alter_table_options */ + { 180, -5 }, /* (82) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 180, -4 }, /* (83) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 180, -5 }, /* (84) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 180, -5 }, /* (85) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 180, -5 }, /* (86) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 180, -4 }, /* (87) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 180, -5 }, /* (88) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 180, -5 }, /* (89) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 180, -6 }, /* (90) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 177, -1 }, /* (91) multi_create_clause ::= create_subtable_clause */ + { 177, -2 }, /* (92) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 184, -9 }, /* (93) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 179, -1 }, /* (94) multi_drop_clause ::= drop_table_clause */ + { 179, -2 }, /* (95) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 187, -2 }, /* (96) drop_table_clause ::= exists_opt full_table_name */ + { 185, 0 }, /* (97) specific_tags_opt ::= */ + { 185, -3 }, /* (98) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 173, -1 }, /* (99) full_table_name ::= table_name */ + { 173, -3 }, /* (100) full_table_name ::= db_name NK_DOT table_name */ + { 174, -1 }, /* (101) column_def_list ::= column_def */ + { 174, -3 }, /* (102) column_def_list ::= column_def_list NK_COMMA column_def */ + { 190, -2 }, /* (103) column_def ::= column_name type_name */ + { 190, -4 }, /* (104) column_def ::= column_name type_name COMMENT NK_STRING */ + { 183, -1 }, /* (105) type_name ::= BOOL */ + { 183, -1 }, /* (106) type_name ::= TINYINT */ + { 183, -1 }, /* (107) type_name ::= SMALLINT */ + { 183, -1 }, /* (108) type_name ::= INT */ + { 183, -1 }, /* (109) type_name ::= INTEGER */ + { 183, -1 }, /* (110) type_name ::= BIGINT */ + { 183, -1 }, /* (111) type_name ::= FLOAT */ + { 183, -1 }, /* (112) type_name ::= DOUBLE */ + { 183, -4 }, /* (113) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 183, -1 }, /* (114) type_name ::= TIMESTAMP */ + { 183, -4 }, /* (115) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 183, -2 }, /* (116) type_name ::= TINYINT UNSIGNED */ + { 183, -2 }, /* (117) type_name ::= SMALLINT UNSIGNED */ + { 183, -2 }, /* (118) type_name ::= INT UNSIGNED */ + { 183, -2 }, /* (119) type_name ::= BIGINT UNSIGNED */ + { 183, -1 }, /* (120) type_name ::= JSON */ + { 183, -4 }, /* (121) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 183, -1 }, /* (122) type_name ::= MEDIUMBLOB */ + { 183, -1 }, /* (123) type_name ::= BLOB */ + { 183, -4 }, /* (124) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 183, -1 }, /* (125) type_name ::= DECIMAL */ + { 183, -4 }, /* (126) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 183, -6 }, /* (127) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 175, 0 }, /* (128) tags_def_opt ::= */ + { 175, -1 }, /* (129) tags_def_opt ::= tags_def */ + { 178, -4 }, /* (130) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 176, 0 }, /* (131) table_options ::= */ + { 176, -3 }, /* (132) table_options ::= table_options COMMENT NK_STRING */ + { 176, -3 }, /* (133) table_options ::= table_options KEEP NK_INTEGER */ + { 176, -3 }, /* (134) table_options ::= table_options TTL NK_INTEGER */ + { 176, -5 }, /* (135) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 176, -5 }, /* (136) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 181, -1 }, /* (137) alter_table_options ::= alter_table_option */ + { 181, -2 }, /* (138) alter_table_options ::= alter_table_options alter_table_option */ + { 192, -2 }, /* (139) alter_table_option ::= COMMENT NK_STRING */ + { 192, -2 }, /* (140) alter_table_option ::= KEEP NK_INTEGER */ + { 192, -2 }, /* (141) alter_table_option ::= TTL NK_INTEGER */ + { 188, -1 }, /* (142) col_name_list ::= col_name */ + { 188, -3 }, /* (143) col_name_list ::= col_name_list NK_COMMA col_name */ + { 193, -1 }, /* (144) col_name ::= column_name */ + { 191, -1 }, /* (145) func_name_list ::= func_name */ + { 191, -3 }, /* (146) func_name_list ::= func_name_list NK_COMMA col_name */ + { 194, -1 }, /* (147) func_name ::= function_name */ + { 160, -7 }, /* (148) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 160, -9 }, /* (149) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 160, -5 }, /* (150) cmd ::= DROP INDEX index_name ON table_name */ + { 197, 0 }, /* (151) index_options ::= */ + { 197, -9 }, /* (152) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 197, -11 }, /* (153) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 198, -1 }, /* (154) func_list ::= func */ + { 198, -3 }, /* (155) func_list ::= func_list NK_COMMA func */ + { 201, -4 }, /* (156) func ::= function_name NK_LP expression_list NK_RP */ + { 160, -6 }, /* (157) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 160, -6 }, /* (158) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 160, -4 }, /* (159) cmd ::= DROP TOPIC exists_opt topic_name */ + { 160, -2 }, /* (160) cmd ::= SHOW VGROUPS */ + { 160, -4 }, /* (161) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 160, -2 }, /* (162) cmd ::= SHOW MNODES */ + { 160, -1 }, /* (163) cmd ::= query_expression */ + { 163, -1 }, /* (164) literal ::= NK_INTEGER */ + { 163, -1 }, /* (165) literal ::= NK_FLOAT */ + { 163, -1 }, /* (166) literal ::= NK_STRING */ + { 163, -1 }, /* (167) literal ::= NK_BOOL */ + { 163, -2 }, /* (168) literal ::= TIMESTAMP NK_STRING */ + { 163, -1 }, /* (169) literal ::= duration_literal */ + { 199, -1 }, /* (170) duration_literal ::= NK_VARIABLE */ + { 186, -1 }, /* (171) literal_list ::= literal */ + { 186, -3 }, /* (172) literal_list ::= literal_list NK_COMMA literal */ + { 168, -1 }, /* (173) db_name ::= NK_ID */ + { 189, -1 }, /* (174) table_name ::= NK_ID */ + { 182, -1 }, /* (175) column_name ::= NK_ID */ + { 195, -1 }, /* (176) function_name ::= NK_ID */ + { 205, -1 }, /* (177) table_alias ::= NK_ID */ + { 206, -1 }, /* (178) column_alias ::= NK_ID */ + { 164, -1 }, /* (179) user_name ::= NK_ID */ + { 196, -1 }, /* (180) index_name ::= NK_ID */ + { 203, -1 }, /* (181) topic_name ::= NK_ID */ + { 207, -1 }, /* (182) expression ::= literal */ + { 207, -1 }, /* (183) expression ::= column_reference */ + { 207, -4 }, /* (184) expression ::= function_name NK_LP expression_list NK_RP */ + { 207, -4 }, /* (185) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 207, -1 }, /* (186) expression ::= subquery */ + { 207, -3 }, /* (187) expression ::= NK_LP expression NK_RP */ + { 207, -2 }, /* (188) expression ::= NK_PLUS expression */ + { 207, -2 }, /* (189) expression ::= NK_MINUS expression */ + { 207, -3 }, /* (190) expression ::= expression NK_PLUS expression */ + { 207, -3 }, /* (191) expression ::= expression NK_MINUS expression */ + { 207, -3 }, /* (192) expression ::= expression NK_STAR expression */ + { 207, -3 }, /* (193) expression ::= expression NK_SLASH expression */ + { 207, -3 }, /* (194) expression ::= expression NK_REM expression */ + { 202, -1 }, /* (195) expression_list ::= expression */ + { 202, -3 }, /* (196) expression_list ::= expression_list NK_COMMA expression */ + { 208, -1 }, /* (197) column_reference ::= column_name */ + { 208, -3 }, /* (198) column_reference ::= table_name NK_DOT column_name */ + { 210, -3 }, /* (199) predicate ::= expression compare_op expression */ + { 210, -5 }, /* (200) predicate ::= expression BETWEEN expression AND expression */ + { 210, -6 }, /* (201) predicate ::= expression NOT BETWEEN expression AND expression */ + { 210, -3 }, /* (202) predicate ::= expression IS NULL */ + { 210, -4 }, /* (203) predicate ::= expression IS NOT NULL */ + { 210, -3 }, /* (204) predicate ::= expression in_op in_predicate_value */ + { 211, -1 }, /* (205) compare_op ::= NK_LT */ + { 211, -1 }, /* (206) compare_op ::= NK_GT */ + { 211, -1 }, /* (207) compare_op ::= NK_LE */ + { 211, -1 }, /* (208) compare_op ::= NK_GE */ + { 211, -1 }, /* (209) compare_op ::= NK_NE */ + { 211, -1 }, /* (210) compare_op ::= NK_EQ */ + { 211, -1 }, /* (211) compare_op ::= LIKE */ + { 211, -2 }, /* (212) compare_op ::= NOT LIKE */ + { 211, -1 }, /* (213) compare_op ::= MATCH */ + { 211, -1 }, /* (214) compare_op ::= NMATCH */ + { 212, -1 }, /* (215) in_op ::= IN */ + { 212, -2 }, /* (216) in_op ::= NOT IN */ + { 213, -3 }, /* (217) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 214, -1 }, /* (218) boolean_value_expression ::= boolean_primary */ + { 214, -2 }, /* (219) boolean_value_expression ::= NOT boolean_primary */ + { 214, -3 }, /* (220) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 214, -3 }, /* (221) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 215, -1 }, /* (222) boolean_primary ::= predicate */ + { 215, -3 }, /* (223) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 216, -1 }, /* (224) common_expression ::= expression */ + { 216, -1 }, /* (225) common_expression ::= boolean_value_expression */ + { 217, -2 }, /* (226) from_clause ::= FROM table_reference_list */ + { 218, -1 }, /* (227) table_reference_list ::= table_reference */ + { 218, -3 }, /* (228) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 219, -1 }, /* (229) table_reference ::= table_primary */ + { 219, -1 }, /* (230) table_reference ::= joined_table */ + { 220, -2 }, /* (231) table_primary ::= table_name alias_opt */ + { 220, -4 }, /* (232) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 220, -2 }, /* (233) table_primary ::= subquery alias_opt */ + { 220, -1 }, /* (234) table_primary ::= parenthesized_joined_table */ + { 222, 0 }, /* (235) alias_opt ::= */ + { 222, -1 }, /* (236) alias_opt ::= table_alias */ + { 222, -2 }, /* (237) alias_opt ::= AS table_alias */ + { 223, -3 }, /* (238) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 223, -3 }, /* (239) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 221, -6 }, /* (240) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 224, 0 }, /* (241) join_type ::= */ + { 224, -1 }, /* (242) join_type ::= INNER */ + { 226, -9 }, /* (243) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 227, 0 }, /* (244) set_quantifier_opt ::= */ + { 227, -1 }, /* (245) set_quantifier_opt ::= DISTINCT */ + { 227, -1 }, /* (246) set_quantifier_opt ::= ALL */ + { 228, -1 }, /* (247) select_list ::= NK_STAR */ + { 228, -1 }, /* (248) select_list ::= select_sublist */ + { 234, -1 }, /* (249) select_sublist ::= select_item */ + { 234, -3 }, /* (250) select_sublist ::= select_sublist NK_COMMA select_item */ + { 235, -1 }, /* (251) select_item ::= common_expression */ + { 235, -2 }, /* (252) select_item ::= common_expression column_alias */ + { 235, -3 }, /* (253) select_item ::= common_expression AS column_alias */ + { 235, -3 }, /* (254) select_item ::= table_name NK_DOT NK_STAR */ + { 229, 0 }, /* (255) where_clause_opt ::= */ + { 229, -2 }, /* (256) where_clause_opt ::= WHERE search_condition */ + { 230, 0 }, /* (257) partition_by_clause_opt ::= */ + { 230, -3 }, /* (258) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 231, 0 }, /* (259) twindow_clause_opt ::= */ + { 231, -6 }, /* (260) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 231, -4 }, /* (261) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 231, -6 }, /* (262) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 231, -8 }, /* (263) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 200, 0 }, /* (264) sliding_opt ::= */ + { 200, -4 }, /* (265) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 236, 0 }, /* (266) fill_opt ::= */ + { 236, -4 }, /* (267) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 236, -6 }, /* (268) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 237, -1 }, /* (269) fill_mode ::= NONE */ + { 237, -1 }, /* (270) fill_mode ::= PREV */ + { 237, -1 }, /* (271) fill_mode ::= NULL */ + { 237, -1 }, /* (272) fill_mode ::= LINEAR */ + { 237, -1 }, /* (273) fill_mode ::= NEXT */ + { 232, 0 }, /* (274) group_by_clause_opt ::= */ + { 232, -3 }, /* (275) group_by_clause_opt ::= GROUP BY group_by_list */ + { 238, -1 }, /* (276) group_by_list ::= expression */ + { 238, -3 }, /* (277) group_by_list ::= group_by_list NK_COMMA expression */ + { 233, 0 }, /* (278) having_clause_opt ::= */ + { 233, -2 }, /* (279) having_clause_opt ::= HAVING search_condition */ + { 204, -4 }, /* (280) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 239, -1 }, /* (281) query_expression_body ::= query_primary */ + { 239, -4 }, /* (282) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 243, -1 }, /* (283) query_primary ::= query_specification */ + { 240, 0 }, /* (284) order_by_clause_opt ::= */ + { 240, -3 }, /* (285) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 241, 0 }, /* (286) slimit_clause_opt ::= */ + { 241, -2 }, /* (287) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 241, -4 }, /* (288) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 241, -4 }, /* (289) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 242, 0 }, /* (290) limit_clause_opt ::= */ + { 242, -2 }, /* (291) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 242, -4 }, /* (292) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 242, -4 }, /* (293) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 209, -3 }, /* (294) subquery ::= NK_LP query_expression NK_RP */ + { 225, -1 }, /* (295) search_condition ::= common_expression */ + { 244, -1 }, /* (296) sort_specification_list ::= sort_specification */ + { 244, -3 }, /* (297) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 245, -3 }, /* (298) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 246, 0 }, /* (299) ordering_specification_opt ::= */ + { 246, -1 }, /* (300) ordering_specification_opt ::= ASC */ + { 246, -1 }, /* (301) ordering_specification_opt ::= DESC */ + { 247, 0 }, /* (302) null_ordering_opt ::= */ + { 247, -2 }, /* (303) null_ordering_opt ::= NULLS FIRST */ + { 247, -2 }, /* (304) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1990,794 +2181,928 @@ static YYACTIONTYPE yy_reduce( */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; - case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + case 0: /* cmd ::= ALTER ACCOUNT NK_ID account_options */ +{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } + yy_destructor(yypParser,161,&yymsp[0].minor); break; - case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } + case 1: /* account_options ::= account_option */ +{ yy_destructor(yypParser,162,&yymsp[0].minor); +{ } +} break; - case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } + case 2: /* account_options ::= account_options account_option */ +{ yy_destructor(yypParser,161,&yymsp[-1].minor); +{ } + yy_destructor(yypParser,162,&yymsp[0].minor); +} break; - case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } + case 3: /* account_option ::= PASS literal */ + case 4: /* account_option ::= PPS literal */ yytestcase(yyruleno==4); + case 5: /* account_option ::= TSERIES literal */ yytestcase(yyruleno==5); + case 6: /* account_option ::= STORAGE literal */ yytestcase(yyruleno==6); + case 7: /* account_option ::= STREAMS literal */ yytestcase(yyruleno==7); + case 8: /* account_option ::= QTIME literal */ yytestcase(yyruleno==8); + case 9: /* account_option ::= DBS literal */ yytestcase(yyruleno==9); + case 10: /* account_option ::= USERS literal */ yytestcase(yyruleno==10); + case 11: /* account_option ::= CONNS literal */ yytestcase(yyruleno==11); + case 12: /* account_option ::= STATE literal */ yytestcase(yyruleno==12); +{ } + yy_destructor(yypParser,163,&yymsp[0].minor); break; - case 4: /* cmd ::= SHOW USERS */ + case 13: /* cmd ::= CREATE USER user_name PASS NK_STRING */ +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + break; + case 14: /* cmd ::= ALTER USER user_name PASS NK_STRING */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } + break; + case 15: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } + break; + case 16: /* cmd ::= DROP USER user_name */ +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy241); } + break; + case 17: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; - case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } + case 18: /* cmd ::= CREATE DNODE dnode_endpoint */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy241, NULL); } break; - case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + case 19: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } break; - case 7: /* cmd ::= DROP DNODE NK_INTEGER */ + case 20: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } + case 21: /* cmd ::= DROP DNODE dnode_endpoint */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 9: /* cmd ::= SHOW DNODES */ + case 22: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } break; - case 10: /* dnode_endpoint ::= NK_STRING */ - case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); - case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 123: /* db_name ::= NK_ID */ yytestcase(yyruleno==123); - case 124: /* table_name ::= NK_ID */ yytestcase(yyruleno==124); - case 125: /* column_name ::= NK_ID */ yytestcase(yyruleno==125); - case 126: /* function_name ::= NK_ID */ yytestcase(yyruleno==126); - case 127: /* table_alias ::= NK_ID */ yytestcase(yyruleno==127); - case 128: /* column_alias ::= NK_ID */ yytestcase(yyruleno==128); - case 129: /* user_name ::= NK_ID */ yytestcase(yyruleno==129); - case 130: /* index_name ::= NK_ID */ yytestcase(yyruleno==130); - case 131: /* topic_name ::= NK_ID */ yytestcase(yyruleno==131); -{ yylhsminor.yy129 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 23: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ +{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + case 24: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ +{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } + break; + case 25: /* cmd ::= ALTER ALL DNODES NK_STRING */ +{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } + break; + case 26: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ +{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } + break; + case 27: /* dnode_endpoint ::= NK_STRING */ + case 28: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==28); + case 29: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==29); + case 173: /* db_name ::= NK_ID */ yytestcase(yyruleno==173); + case 174: /* table_name ::= NK_ID */ yytestcase(yyruleno==174); + case 175: /* column_name ::= NK_ID */ yytestcase(yyruleno==175); + case 176: /* function_name ::= NK_ID */ yytestcase(yyruleno==176); + case 177: /* table_alias ::= NK_ID */ yytestcase(yyruleno==177); + case 178: /* column_alias ::= NK_ID */ yytestcase(yyruleno==178); + case 179: /* user_name ::= NK_ID */ yytestcase(yyruleno==179); + case 180: /* index_name ::= NK_ID */ yytestcase(yyruleno==180); + case 181: /* topic_name ::= NK_ID */ yytestcase(yyruleno==181); +{ yylhsminor.yy241 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy241 = yylhsminor.yy241; + break; + case 30: /* cmd ::= ALTER LOCAL NK_STRING */ +{ pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } + break; + case 31: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ +{ pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } + break; + case 32: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + case 33: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 15: /* cmd ::= SHOW QNODES */ + case 34: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 16: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } + case 35: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy457, &yymsp[-1].minor.yy241, yymsp[0].minor.yy168); } break; - case 17: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } + case 36: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy457, &yymsp[0].minor.yy241); } break; - case 18: /* cmd ::= SHOW DATABASES */ + case 37: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 19: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } + case 38: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 20: /* cmd ::= ALTER DATABASE db_name db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } + case 39: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy168); } break; - case 21: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy97 = true; } + case 40: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy457 = true; } break; - case 22: /* not_exists_opt ::= */ - case 24: /* exists_opt ::= */ yytestcase(yyruleno==24); - case 194: /* set_quantifier_opt ::= */ yytestcase(yyruleno==194); -{ yymsp[1].minor.yy97 = false; } + case 41: /* not_exists_opt ::= */ + case 43: /* exists_opt ::= */ yytestcase(yyruleno==43); + case 244: /* set_quantifier_opt ::= */ yytestcase(yyruleno==244); +{ yymsp[1].minor.yy457 = false; } break; - case 23: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy97 = true; } + case 42: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy457 = true; } break; - case 25: /* db_options ::= */ -{ yymsp[1].minor.yy432 = createDefaultDatabaseOptions(pCxt); } + case 44: /* db_options ::= */ +{ yymsp[1].minor.yy168 = createDefaultDatabaseOptions(pCxt); } break; - case 26: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 45: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 27: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 46: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 28: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 47: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 29: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 48: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 30: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 49: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 31: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 50: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 32: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 51: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 33: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 52: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 34: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 53: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 35: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 54: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 36: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 55: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 37: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 56: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 38: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 57: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 39: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 58: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 40: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 59: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 41: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 60: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 42: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 61: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 43: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 45: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==45); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy432, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy432);} + case 62: /* db_options ::= db_options RETENTIONS NK_STRING */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 44: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24);} + case 63: /* db_options ::= db_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 46: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } + case 64: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy168 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy168 = setDatabaseOption(pCxt, yylhsminor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 47: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + case 65: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 48: /* cmd ::= SHOW TABLES */ + case 66: /* alter_db_option ::= BLOCKS NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 67: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 68: /* alter_db_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_KEEP; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 69: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_WAL; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 70: /* alter_db_option ::= QUORUM NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 71: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 72: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 74: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==74); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy457, yymsp[-5].minor.yy168, yymsp[-3].minor.yy440, yymsp[-1].minor.yy440, yymsp[0].minor.yy168); } + break; + case 73: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy440); } + break; + case 75: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy440); } + break; + case 76: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy457, yymsp[0].minor.yy168); } + break; + case 77: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 49: /* cmd ::= SHOW STABLES */ + case 78: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 50: /* multi_create_clause ::= create_subtable_clause */ - case 53: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==53); - case 60: /* column_def_list ::= column_def */ yytestcase(yyruleno==60); - case 95: /* col_name_list ::= col_name */ yytestcase(yyruleno==95); - case 104: /* func_list ::= func */ yytestcase(yyruleno==104); - case 199: /* select_sublist ::= select_item */ yytestcase(yyruleno==199); - case 246: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==246); -{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy432); } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 79: /* cmd ::= ALTER TABLE alter_table_clause */ + case 80: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==80); + case 163: /* cmd ::= query_expression */ yytestcase(yyruleno==163); +{ pCxt->pRootNode = yymsp[0].minor.yy168; } break; - case 51: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 54: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==54); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy432); } - yymsp[-1].minor.yy24 = yylhsminor.yy24; + case 81: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy168 = createAlterTableOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 52: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy432 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy97, yymsp[-7].minor.yy432, yymsp[-5].minor.yy432, yymsp[-4].minor.yy24, yymsp[-1].minor.yy24); } - yymsp[-8].minor.yy432 = yylhsminor.yy432; + case 82: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + case 84: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ yytestcase(yyruleno==84); + case 86: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ yytestcase(yyruleno==86); + case 88: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ yytestcase(yyruleno==88); +{ yylhsminor.yy168 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, yymsp[0].minor.yy208); } + yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 55: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy432 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 83: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ + case 87: /* alter_table_clause ::= full_table_name DROP TAG column_name */ yytestcase(yyruleno==87); +{ yylhsminor.yy168 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[0].minor.yy241); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 56: /* specific_tags_opt ::= */ - case 87: /* tags_def_opt ::= */ yytestcase(yyruleno==87); - case 207: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==207); - case 224: /* group_by_clause_opt ::= */ yytestcase(yyruleno==224); - case 234: /* order_by_clause_opt ::= */ yytestcase(yyruleno==234); -{ yymsp[1].minor.yy24 = NULL; } + case 85: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + case 89: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ yytestcase(yyruleno==89); +{ yylhsminor.yy168 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 57: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } + case 90: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ +{ yylhsminor.yy168 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy168, &yymsp[-2].minor.yy241, yymsp[0].minor.yy168); } + yymsp[-5].minor.yy168 = yylhsminor.yy168; break; - case 58: /* full_table_name ::= table_name */ -{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 91: /* multi_create_clause ::= create_subtable_clause */ + case 94: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==94); + case 101: /* column_def_list ::= column_def */ yytestcase(yyruleno==101); + case 142: /* col_name_list ::= col_name */ yytestcase(yyruleno==142); + case 145: /* func_name_list ::= func_name */ yytestcase(yyruleno==145); + case 154: /* func_list ::= func */ yytestcase(yyruleno==154); + case 249: /* select_sublist ::= select_item */ yytestcase(yyruleno==249); + case 296: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==296); +{ yylhsminor.yy440 = createNodeList(pCxt, yymsp[0].minor.yy168); } + yymsp[0].minor.yy440 = yylhsminor.yy440; break; - case 59: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 92: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 95: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==95); +{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-1].minor.yy440, yymsp[0].minor.yy168); } + yymsp[-1].minor.yy440 = yylhsminor.yy440; break; - case 61: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 96: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==96); - case 105: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==105); - case 200: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==200); - case 247: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==247); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy432); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; + case 93: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy168 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy457, yymsp[-7].minor.yy168, yymsp[-5].minor.yy168, yymsp[-4].minor.yy440, yymsp[-1].minor.yy440); } + yymsp[-8].minor.yy168 = yylhsminor.yy168; break; - case 62: /* column_def ::= column_name type_name */ -{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy224, NULL); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 96: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy168 = createDropTableClause(pCxt, yymsp[-1].minor.yy457, yymsp[0].minor.yy168); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 63: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy224, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 97: /* specific_tags_opt ::= */ + case 128: /* tags_def_opt ::= */ yytestcase(yyruleno==128); + case 257: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==257); + case 274: /* group_by_clause_opt ::= */ yytestcase(yyruleno==274); + case 284: /* order_by_clause_opt ::= */ yytestcase(yyruleno==284); +{ yymsp[1].minor.yy440 = NULL; } break; - case 64: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 98: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy440 = yymsp[-1].minor.yy440; } break; - case 65: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 99: /* full_table_name ::= table_name */ +{ yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy241, NULL); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 66: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 100: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, NULL); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 67: /* type_name ::= INT */ - case 68: /* type_name ::= INTEGER */ yytestcase(yyruleno==68); -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_INT); } + case 102: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 143: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==143); + case 146: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==146); + case 155: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==155); + case 250: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==250); + case 297: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==297); +{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, yymsp[0].minor.yy168); } + yymsp[-2].minor.yy440 = yylhsminor.yy440; break; - case 69: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 103: /* column_def ::= column_name type_name */ +{ yylhsminor.yy168 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy208, NULL); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 70: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 104: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy168 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-2].minor.yy208, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 71: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 105: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 72: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 106: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 73: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 107: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 74: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 108: /* type_name ::= INT */ + case 109: /* type_name ::= INTEGER */ yytestcase(yyruleno==109); +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 75: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 110: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 76: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 111: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 77: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UINT); } + case 112: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 78: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 113: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 79: /* type_name ::= JSON */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_JSON); } + case 114: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 80: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 115: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 81: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 116: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 82: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 117: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 83: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 118: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 84: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 119: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 85: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 120: /* type_name ::= JSON */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 86: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 121: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 88: /* tags_def_opt ::= tags_def */ - case 198: /* select_list ::= select_sublist */ yytestcase(yyruleno==198); -{ yylhsminor.yy24 = yymsp[0].minor.yy24; } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 122: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 89: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } + case 123: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 90: /* table_options ::= */ -{ yymsp[1].minor.yy432 = createDefaultTableOptions(pCxt);} + case 124: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 91: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 125: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 92: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 126: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 93: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 127: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 94: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy432 = setTableSmaOption(pCxt, yymsp[-4].minor.yy432, yymsp[-1].minor.yy24); } - yymsp[-4].minor.yy432 = yylhsminor.yy432; + case 129: /* tags_def_opt ::= tags_def */ + case 248: /* select_list ::= select_sublist */ yytestcase(yyruleno==248); +{ yylhsminor.yy440 = yymsp[0].minor.yy440; } + yymsp[0].minor.yy440 = yylhsminor.yy440; break; - case 97: /* col_name ::= column_name */ -{ yylhsminor.yy432 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 130: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy440 = yymsp[-1].minor.yy440; } break; - case 98: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy432); } + case 131: /* table_options ::= */ +{ yymsp[1].minor.yy168 = createDefaultTableOptions(pCxt); } break; - case 99: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24, NULL); } + case 132: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 100: /* cmd ::= DROP INDEX index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } + case 133: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 101: /* index_options ::= */ - case 205: /* where_clause_opt ::= */ yytestcase(yyruleno==205); - case 209: /* twindow_clause_opt ::= */ yytestcase(yyruleno==209); - case 214: /* sliding_opt ::= */ yytestcase(yyruleno==214); - case 216: /* fill_opt ::= */ yytestcase(yyruleno==216); - case 228: /* having_clause_opt ::= */ yytestcase(yyruleno==228); - case 236: /* slimit_clause_opt ::= */ yytestcase(yyruleno==236); - case 240: /* limit_clause_opt ::= */ yytestcase(yyruleno==240); -{ yymsp[1].minor.yy432 = NULL; } + case 134: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 102: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy432 = createIndexOption(pCxt, yymsp[-6].minor.yy24, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL, yymsp[0].minor.yy432); } + case 135: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy168 = setTableSmaOption(pCxt, yymsp[-4].minor.yy168, yymsp[-1].minor.yy440); } + yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 103: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy432 = createIndexOption(pCxt, yymsp[-8].minor.yy24, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[0].minor.yy432); } + case 136: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy168 = setTableRollupOption(pCxt, yymsp[-4].minor.yy168, yymsp[-1].minor.yy440); } + yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 106: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy432 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 137: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy168 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy168 = setTableOption(pCxt, yylhsminor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 107: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, yymsp[0].minor.yy432, NULL); } + case 138: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 108: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, NULL, &yymsp[0].minor.yy129); } + case 139: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy349.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } break; - case 109: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } + case 140: /* alter_table_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } break; - case 110: /* cmd ::= SHOW VGROUPS */ + case 141: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy349.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + break; + case 144: /* col_name ::= column_name */ +{ yylhsminor.yy168 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); } + yymsp[0].minor.yy168 = yylhsminor.yy168; + break; + case 147: /* func_name ::= function_name */ +{ yylhsminor.yy168 = createFunctionNode(pCxt, &yymsp[0].minor.yy241, NULL); } + yymsp[0].minor.yy168 = yylhsminor.yy168; + break; + case 148: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, NULL, yymsp[0].minor.yy168); } + break; + case 149: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy241, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440, NULL); } + break; + case 150: /* cmd ::= DROP INDEX index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } + break; + case 151: /* index_options ::= */ + case 255: /* where_clause_opt ::= */ yytestcase(yyruleno==255); + case 259: /* twindow_clause_opt ::= */ yytestcase(yyruleno==259); + case 264: /* sliding_opt ::= */ yytestcase(yyruleno==264); + case 266: /* fill_opt ::= */ yytestcase(yyruleno==266); + case 278: /* having_clause_opt ::= */ yytestcase(yyruleno==278); + case 286: /* slimit_clause_opt ::= */ yytestcase(yyruleno==286); + case 290: /* limit_clause_opt ::= */ yytestcase(yyruleno==290); +{ yymsp[1].minor.yy168 = NULL; } + break; + case 152: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy168 = createIndexOption(pCxt, yymsp[-6].minor.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), NULL, yymsp[0].minor.yy168); } + break; + case 153: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy168 = createIndexOption(pCxt, yymsp[-8].minor.yy440, releaseRawExprNode(pCxt, yymsp[-4].minor.yy168), releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[0].minor.yy168); } + break; + case 156: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy168 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; + break; + case 157: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy457, &yymsp[-2].minor.yy241, yymsp[0].minor.yy168, NULL); } + break; + case 158: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy457, &yymsp[-2].minor.yy241, NULL, &yymsp[0].minor.yy241); } + break; + case 159: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy457, &yymsp[0].minor.yy241); } + break; + case 160: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 111: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } + case 161: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy241); } break; - case 112: /* cmd ::= SHOW MNODES */ + case 162: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 113: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy432; } + case 164: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 114: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 165: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 115: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 166: /* literal ::= NK_STRING */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 116: /* literal ::= NK_STRING */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 167: /* literal ::= NK_BOOL */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 117: /* literal ::= NK_BOOL */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 168: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 118: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 169: /* literal ::= duration_literal */ + case 182: /* expression ::= literal */ yytestcase(yyruleno==182); + case 183: /* expression ::= column_reference */ yytestcase(yyruleno==183); + case 186: /* expression ::= subquery */ yytestcase(yyruleno==186); + case 218: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==218); + case 222: /* boolean_primary ::= predicate */ yytestcase(yyruleno==222); + case 224: /* common_expression ::= expression */ yytestcase(yyruleno==224); + case 225: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==225); + case 227: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==227); + case 229: /* table_reference ::= table_primary */ yytestcase(yyruleno==229); + case 230: /* table_reference ::= joined_table */ yytestcase(yyruleno==230); + case 234: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==234); + case 281: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==281); + case 283: /* query_primary ::= query_specification */ yytestcase(yyruleno==283); +{ yylhsminor.yy168 = yymsp[0].minor.yy168; } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 119: /* literal ::= duration_literal */ - case 132: /* expression ::= literal */ yytestcase(yyruleno==132); - case 133: /* expression ::= column_reference */ yytestcase(yyruleno==133); - case 136: /* expression ::= subquery */ yytestcase(yyruleno==136); - case 168: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==168); - case 172: /* boolean_primary ::= predicate */ yytestcase(yyruleno==172); - case 174: /* common_expression ::= expression */ yytestcase(yyruleno==174); - case 175: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==175); - case 177: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==177); - case 179: /* table_reference ::= table_primary */ yytestcase(yyruleno==179); - case 180: /* table_reference ::= joined_table */ yytestcase(yyruleno==180); - case 184: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==184); - case 231: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==231); - case 233: /* query_primary ::= query_specification */ yytestcase(yyruleno==233); -{ yylhsminor.yy432 = yymsp[0].minor.yy432; } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 170: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 120: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 171: /* literal_list ::= literal */ + case 195: /* expression_list ::= expression */ yytestcase(yyruleno==195); +{ yylhsminor.yy440 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } + yymsp[0].minor.yy440 = yylhsminor.yy440; break; - case 121: /* literal_list ::= literal */ - case 145: /* expression_list ::= expression */ yytestcase(yyruleno==145); -{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 172: /* literal_list ::= literal_list NK_COMMA literal */ + case 196: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==196); +{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } + yymsp[-2].minor.yy440 = yylhsminor.yy440; break; - case 122: /* literal_list ::= literal_list NK_COMMA literal */ - case 146: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==146); -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; + case 184: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440)); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 134: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24)); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 185: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 135: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 187: /* expression ::= NK_LP expression NK_RP */ + case 223: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==223); +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 137: /* expression ::= NK_LP expression NK_RP */ - case 173: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==173); -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; - break; - case 138: /* expression ::= NK_PLUS expression */ + case 188: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 139: /* expression ::= NK_MINUS expression */ + case 189: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 140: /* expression ::= expression NK_PLUS expression */ + case 190: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 141: /* expression ::= expression NK_MINUS expression */ + case 191: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 142: /* expression ::= expression NK_STAR expression */ + case 192: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 143: /* expression ::= expression NK_SLASH expression */ + case 193: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 144: /* expression ::= expression NK_REM expression */ + case 194: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 147: /* column_reference ::= column_name */ -{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 197: /* column_reference ::= column_name */ +{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 148: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 198: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 149: /* predicate ::= expression compare_op expression */ - case 154: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==154); + case 199: /* predicate ::= expression compare_op expression */ + case 204: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==204); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy260, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy476, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 150: /* predicate ::= expression BETWEEN expression AND expression */ + case 200: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy168), releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-4].minor.yy432 = yylhsminor.yy432; + yymsp[-4].minor.yy168 = yylhsminor.yy168; break; - case 151: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 201: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-5].minor.yy432 = yylhsminor.yy432; + yymsp[-5].minor.yy168 = yylhsminor.yy168; break; - case 152: /* predicate ::= expression IS NULL */ + case 202: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), NULL)); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 153: /* predicate ::= expression IS NOT NULL */ + case 203: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL)); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 155: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_THAN; } + case 205: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy476 = OP_TYPE_LOWER_THAN; } break; - case 156: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_THAN; } + case 206: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy476 = OP_TYPE_GREATER_THAN; } break; - case 157: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_EQUAL; } + case 207: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy476 = OP_TYPE_LOWER_EQUAL; } break; - case 158: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_EQUAL; } + case 208: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy476 = OP_TYPE_GREATER_EQUAL; } break; - case 159: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy260 = OP_TYPE_NOT_EQUAL; } + case 209: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy476 = OP_TYPE_NOT_EQUAL; } break; - case 160: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy260 = OP_TYPE_EQUAL; } + case 210: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy476 = OP_TYPE_EQUAL; } break; - case 161: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy260 = OP_TYPE_LIKE; } + case 211: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy476 = OP_TYPE_LIKE; } break; - case 162: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_LIKE; } + case 212: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy476 = OP_TYPE_NOT_LIKE; } break; - case 163: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy260 = OP_TYPE_MATCH; } + case 213: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy476 = OP_TYPE_MATCH; } break; - case 164: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy260 = OP_TYPE_NMATCH; } + case 214: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy476 = OP_TYPE_NMATCH; } break; - case 165: /* in_op ::= IN */ -{ yymsp[0].minor.yy260 = OP_TYPE_IN; } + case 215: /* in_op ::= IN */ +{ yymsp[0].minor.yy476 = OP_TYPE_IN; } break; - case 166: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_IN; } + case 216: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy476 = OP_TYPE_NOT_IN; } break; - case 167: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 217: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy440)); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 169: /* boolean_value_expression ::= NOT boolean_primary */ + case 219: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 170: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 220: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 171: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 221: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 176: /* from_clause ::= FROM table_reference_list */ - case 206: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==206); - case 229: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==229); -{ yymsp[-1].minor.yy432 = yymsp[0].minor.yy432; } + case 226: /* from_clause ::= FROM table_reference_list */ + case 256: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==256); + case 279: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==279); +{ yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; } break; - case 178: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy432 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy432, yymsp[0].minor.yy432, NULL); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 228: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 181: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 231: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 182: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 232: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 183: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy432 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 233: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy168 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 185: /* alias_opt ::= */ -{ yymsp[1].minor.yy129 = nil_token; } + case 235: /* alias_opt ::= */ +{ yymsp[1].minor.yy241 = nil_token; } break; - case 186: /* alias_opt ::= table_alias */ -{ yylhsminor.yy129 = yymsp[0].minor.yy129; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 236: /* alias_opt ::= table_alias */ +{ yylhsminor.yy241 = yymsp[0].minor.yy241; } + yymsp[0].minor.yy241 = yylhsminor.yy241; break; - case 187: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } + case 237: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } break; - case 188: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 189: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==189); -{ yymsp[-2].minor.yy432 = yymsp[-1].minor.yy432; } + case 238: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 239: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==239); +{ yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; } break; - case 190: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy432 = createJoinTableNode(pCxt, yymsp[-4].minor.yy332, yymsp[-5].minor.yy432, yymsp[-2].minor.yy432, yymsp[0].minor.yy432); } - yymsp[-5].minor.yy432 = yylhsminor.yy432; + case 240: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy228, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } + yymsp[-5].minor.yy168 = yylhsminor.yy168; break; - case 191: /* join_type ::= */ -{ yymsp[1].minor.yy332 = JOIN_TYPE_INNER; } + case 241: /* join_type ::= */ +{ yymsp[1].minor.yy228 = JOIN_TYPE_INNER; } break; - case 192: /* join_type ::= INNER */ -{ yymsp[0].minor.yy332 = JOIN_TYPE_INNER; } + case 242: /* join_type ::= INNER */ +{ yymsp[0].minor.yy228 = JOIN_TYPE_INNER; } break; - case 193: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 243: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy432 = createSelectStmt(pCxt, yymsp[-7].minor.yy97, yymsp[-6].minor.yy24, yymsp[-5].minor.yy432); - yymsp[-8].minor.yy432 = addWhereClause(pCxt, yymsp[-8].minor.yy432, yymsp[-4].minor.yy432); - yymsp[-8].minor.yy432 = addPartitionByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-3].minor.yy24); - yymsp[-8].minor.yy432 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy432, yymsp[-2].minor.yy432); - yymsp[-8].minor.yy432 = addGroupByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-1].minor.yy24); - yymsp[-8].minor.yy432 = addHavingClause(pCxt, yymsp[-8].minor.yy432, yymsp[0].minor.yy432); + yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy457, yymsp[-6].minor.yy440, yymsp[-5].minor.yy168); + yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168); + yymsp[-8].minor.yy168 = addPartitionByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-3].minor.yy440); + yymsp[-8].minor.yy168 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy168, yymsp[-2].minor.yy168); + yymsp[-8].minor.yy168 = addGroupByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-1].minor.yy440); + yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168); } break; - case 195: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy97 = true; } + case 245: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy457 = true; } break; - case 196: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy97 = false; } + case 246: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy457 = false; } break; - case 197: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy24 = NULL; } + case 247: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy440 = NULL; } break; - case 201: /* select_item ::= common_expression */ + case 251: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); - yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); + yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), &t); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 202: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy432 = yylhsminor.yy432; + case 252: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy168 = yylhsminor.yy168; break; - case 203: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), &yymsp[0].minor.yy129); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 253: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), &yymsp[0].minor.yy241); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 204: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy432 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 254: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 208: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 225: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==225); - case 235: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==235); -{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } + case 258: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 275: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==275); + case 285: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==285); +{ yymsp[-2].minor.yy440 = yymsp[0].minor.yy440; } break; - case 210: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy432 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), &yymsp[-1].minor.yy0); } + case 260: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy168 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), &yymsp[-1].minor.yy0); } break; - case 211: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy432 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } + case 261: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy168 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } break; - case 212: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL, yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } + case 262: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } break; - case 213: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } + case 263: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } break; - case 215: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy432 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy432); } + case 265: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy168 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy168); } break; - case 217: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy432 = createFillNode(pCxt, yymsp[-1].minor.yy294, NULL); } + case 267: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy168 = createFillNode(pCxt, yymsp[-1].minor.yy262, NULL); } break; - case 218: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy432 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } + case 268: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy168 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy440)); } break; - case 219: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy294 = FILL_MODE_NONE; } + case 269: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy262 = FILL_MODE_NONE; } break; - case 220: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy294 = FILL_MODE_PREV; } + case 270: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy262 = FILL_MODE_PREV; } break; - case 221: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy294 = FILL_MODE_NULL; } + case 271: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy262 = FILL_MODE_NULL; } break; - case 222: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy294 = FILL_MODE_LINEAR; } + case 272: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy262 = FILL_MODE_LINEAR; } break; - case 223: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy294 = FILL_MODE_NEXT; } + case 273: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy262 = FILL_MODE_NEXT; } break; - case 226: /* group_by_list ::= expression */ -{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[0].minor.yy24 = yylhsminor.yy24; + case 276: /* group_by_list ::= expression */ +{ yylhsminor.yy440 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } + yymsp[0].minor.yy440 = yylhsminor.yy440; break; - case 227: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy24 = yylhsminor.yy24; + case 277: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } + yymsp[-2].minor.yy440 = yylhsminor.yy440; break; - case 230: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 280: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy432 = addOrderByClause(pCxt, yymsp[-3].minor.yy432, yymsp[-2].minor.yy24); - yylhsminor.yy432 = addSlimitClause(pCxt, yylhsminor.yy432, yymsp[-1].minor.yy432); - yylhsminor.yy432 = addLimitClause(pCxt, yylhsminor.yy432, yymsp[0].minor.yy432); + yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy440); + yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168); + yylhsminor.yy168 = addLimitClause(pCxt, yylhsminor.yy168, yymsp[0].minor.yy168); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 232: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy432 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy432, yymsp[0].minor.yy432); } - yymsp[-3].minor.yy432 = yylhsminor.yy432; + case 282: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); } + yymsp[-3].minor.yy168 = yylhsminor.yy168; break; - case 237: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 241: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==241); -{ yymsp[-1].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 287: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 291: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==291); +{ yymsp[-1].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 238: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 242: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==242); -{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 288: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 292: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==292); +{ yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 239: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 243: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==243); -{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 289: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 293: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==293); +{ yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 244: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy432); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 294: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy168); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 245: /* search_condition ::= common_expression */ -{ yylhsminor.yy432 = releaseRawExprNode(pCxt, yymsp[0].minor.yy432); } - yymsp[0].minor.yy432 = yylhsminor.yy432; + case 295: /* search_condition ::= common_expression */ +{ yylhsminor.yy168 = releaseRawExprNode(pCxt, yymsp[0].minor.yy168); } + yymsp[0].minor.yy168 = yylhsminor.yy168; break; - case 248: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy432 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[-1].minor.yy378, yymsp[0].minor.yy257); } - yymsp[-2].minor.yy432 = yylhsminor.yy432; + case 298: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy168 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[-1].minor.yy258, yymsp[0].minor.yy425); } + yymsp[-2].minor.yy168 = yylhsminor.yy168; break; - case 249: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy378 = ORDER_ASC; } + case 299: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy258 = ORDER_ASC; } break; - case 250: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy378 = ORDER_ASC; } + case 300: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy258 = ORDER_ASC; } break; - case 251: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy378 = ORDER_DESC; } + case 301: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy258 = ORDER_DESC; } break; - case 252: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy257 = NULL_ORDER_DEFAULT; } + case 302: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy425 = NULL_ORDER_DEFAULT; } break; - case 253: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy257 = NULL_ORDER_FIRST; } + case 303: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy425 = NULL_ORDER_FIRST; } break; - case 254: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy257 = NULL_ORDER_LAST; } + case 304: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy425 = NULL_ORDER_LAST; } break; default: break; @@ -2839,13 +3164,15 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ - - if(TOKEN.z) { - generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); - } else { - generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); + + if (pCxt->valid) { + if(TOKEN.z) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); + } else { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INCOMPLETE_SQL); + } + pCxt->valid = false; } - pCxt->valid = false; /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index f4c1bde478..bb2f2539e9 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -302,6 +302,13 @@ TEST_F(ParserTest, createUser) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, alterAccount) { + setDatabase("root", "test"); + + bind("alter account ac_wxy pass '123456'"); + ASSERT_TRUE(run(TSDB_CODE_PAR_EXPRIE_STATEMENT)); +} + TEST_F(ParserTest, createDnode) { setDatabase("root", "test"); @@ -312,6 +319,16 @@ TEST_F(ParserTest, createDnode) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, alterDnode) { + setDatabase("root", "test"); + + bind("alter dnode 1 'resetLog'"); + ASSERT_TRUE(run()); + + bind("alter dnode 1 'debugFlag' '134'"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, createDatabase) { setDatabase("root", "test"); From 7f4c88b756c5c42b34f29379a1efde747549edce Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 19:40:48 +0800 Subject: [PATCH 19/60] task deploy and task exec --- include/common/tmsg.h | 4 ++++ include/common/tmsgdef.h | 1 + include/util/tencode.h | 25 ++++++++++++++++++++++++- source/common/src/tmsg.c | 8 ++++---- source/dnode/mnode/impl/src/mndDef.c | 6 +++--- source/dnode/snode/inc/sndInt.h | 5 +++-- source/dnode/snode/src/snode.c | 23 ++++++++++++++++++++++- 7 files changed, 61 insertions(+), 11 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 7e9b2186da..b449cad2a1 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2306,6 +2306,10 @@ typedef struct { // TODO: other info needed by task } SStreamTaskExecReq; +typedef struct { + int32_t reserved; +} SStreamTaskExecRsp; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b30a325d7c..6a07887721 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -200,6 +200,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/util/tencode.h b/include/util/tencode.h index c058eebb50..cbbd55c8a3 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -402,10 +402,33 @@ static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val) { return 0; } +static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uint64_t* len) { + if (tDecodeU64v(pDecoder, len) < 0) return -1; + + if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1; + *val = malloc(*len); + if (*val == NULL) return -1; + memcpy(*val, TD_CODER_CURRENT(pDecoder), *len); + + TD_CODER_MOVE_POS(pDecoder, *len); + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SCoder* pDecoder, char** val, uint64_t* len) { + if (tDecodeBinaryAlloc(pDecoder, (void**)val, len) < 0) return -1; + (*len) -= 1; + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAlloc(SCoder* pDecoder, char** val) { + uint64_t len; + return tDecodeCStrAndLenAlloc(pDecoder, val, &len); +} + static FORCE_INLINE bool tDecodeIsEnd(SCoder* pCoder) { return (pCoder->size == pCoder->pos); } #ifdef __cplusplus } #endif -#endif /*_TD_UTIL_ENCODE_H_*/ \ No newline at end of file +#endif /*_TD_UTIL_ENCODE_H_*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 469090c05b..794e5a8542 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2674,9 +2674,9 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->sql) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->physicalPlan) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2706,7 +2706,7 @@ int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pTask->qmsg) < 0) return -1; tEndDecode(pDecoder); return 0; } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 6e8d9aa79f..cc5bf843ce 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -39,8 +39,8 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) { if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1; if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->sql) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->logicalPlan) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1; return 0; } diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index e5f6c3c266..d1122fc4ec 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -50,8 +50,9 @@ typedef struct SSnode { SStreamMeta* sndMetaNew(); void sndMetaDelete(SStreamMeta* pMeta); -int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); -int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +SStreamTask* sndMetaGetTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 80e33bd971..2ecaeb00e9 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -68,6 +68,10 @@ int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); } +SStreamTask *sndMetaGetTask(SStreamMeta *pMeta, int32_t taskId) { + return taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); +} + int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); if (pTask == NULL) { @@ -79,6 +83,16 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } +static int32_t sndProcessTaskExecReq(SSnode *pSnode, SRpcMsg *pMsg) { + SMsgHead *pHead = pMsg->pCont; + int32_t taskId = pHead->streamTaskId; + SStreamTask *pTask = sndMetaGetTask(pSnode->pMeta, taskId); + if (pTask == NULL) { + return -1; + } + return 0; +} + int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { // stream deploy // stream stop/resume @@ -95,13 +109,20 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { tCoderClear(&decoder); sndMetaDeployTask(pSnode->pMeta, pTask); + } else if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); } else { - // + ASSERT(0); } return 0; } int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) { // operator exec + if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); + } else { + ASSERT(0); + } return 0; } From fda9803c176f47826aba16466267bbb5d5a7638a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 20:03:22 +0800 Subject: [PATCH 20/60] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 20 ++++++++++++-------- source/libs/sync/src/syncCommit.c | 6 +++++- source/libs/sync/src/syncIO.c | 13 ++++++++++--- source/libs/sync/src/syncMain.c | 6 +++--- source/libs/sync/src/syncRaftLog.c | 17 ++++++++++------- source/libs/sync/test/syncElectTest.cpp | 9 ++++++--- source/libs/sync/test/syncLogStoreTest.cpp | 6 +++--- 7 files changed, 49 insertions(+), 28 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 87d6669f59..888d7e16d1 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -102,7 +102,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SyncTerm localPreLogTerm = 0; if (pMsg->prevLogTerm >= SYNC_INDEX_BEGIN && pMsg->prevLogTerm <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogTerm); + SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); assert(pEntry != NULL); localPreLogTerm = pEntry->term; syncEntryDestory(pEntry); @@ -111,9 +111,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { bool logOK = (pMsg->prevLogIndex == SYNC_INDEX_INVALID) || ((pMsg->prevLogIndex >= SYNC_INDEX_BEGIN) && - (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogIndex == localPreLogTerm)); + (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogTerm == localPreLogTerm)); - // reject + // reject request if ((pMsg->term < ths->pRaftStore->currentTerm) || ((pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK)) { SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(); @@ -134,6 +134,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { // return to follower state if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE) { syncNodeBecomeFollower(ths); + + // need ret? + return ret; } // accept request @@ -144,17 +147,17 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { matchSuccess = true; } if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogTerm); - assert(pEntry != NULL); - if (pMsg->prevLogTerm == pEntry->term) { + SSyncRaftEntry* pPreEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); + assert(pPreEntry != NULL); + if (pMsg->prevLogTerm == pPreEntry->term) { matchSuccess = true; } - syncEntryDestory(pEntry); + syncEntryDestory(pPreEntry); } if (matchSuccess) { // delete conflict entries - if (ths->pLogStore->getLastIndex(ths->pLogStore) > pMsg->prevLogIndex) { + if (pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore)) { SyncIndex fromIndex = pMsg->prevLogIndex + 1; ths->pLogStore->truncate(ths->pLogStore, fromIndex); } @@ -178,6 +181,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); syncAppendEntriesReplyDestroy(pReply); + } else { SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(); pReply->srcId = ths->myRaftId; diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index ec4272fdd0..850468f393 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "syncIndexMgr.h" #include "syncInt.h" // \* Leader i advances its commitIndex. @@ -38,4 +39,7 @@ // IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] // /\ UNCHANGED <> // -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} \ No newline at end of file +void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { + syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pNextIndex", pSyncNode->pNextIndex); + syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pMatchIndex", pSyncNode->pMatchIndex); +} \ No newline at end of file diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index e6a43f2bb5..c8448c32eb 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void * syncIOConsumerFunc(void *param); +static void *syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO * io = param; + SSyncIO *io = param; STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { @@ -269,6 +269,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_PING_REPLY) { if (io->FpOnSyncPingReply != NULL) { SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg); syncPingReplyDestroy(pSyncMsg); } @@ -276,6 +277,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_CLIENT_REQUEST) { if (io->FpOnSyncClientRequest != NULL) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg); syncClientRequestDestroy(pSyncMsg); } @@ -283,6 +285,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_REQUEST_VOTE) { if (io->FpOnSyncRequestVote != NULL) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncRequestVote(io->pSyncNode, pSyncMsg); syncRequestVoteDestroy(pSyncMsg); } @@ -290,6 +293,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_REQUEST_VOTE_REPLY) { if (io->FpOnSyncRequestVoteReply != NULL) { SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncRequestVoteReply(io->pSyncNode, pSyncMsg); syncRequestVoteReplyDestroy(pSyncMsg); } @@ -297,6 +301,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_APPEND_ENTRIES) { if (io->FpOnSyncAppendEntries != NULL) { SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncAppendEntries(io->pSyncNode, pSyncMsg); syncAppendEntriesDestroy(pSyncMsg); } @@ -304,6 +309,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_APPEND_ENTRIES_REPLY) { if (io->FpOnSyncAppendEntriesReply != NULL) { SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncAppendEntriesReply(io->pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); } @@ -311,6 +317,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_TIMEOUT) { if (io->FpOnSyncTimeout != NULL) { SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncTimeout(io->pSyncNode, pSyncMsg); syncTimeoutDestroy(pSyncMsg); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 7d2087eded..ff446dfc27 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -563,11 +563,11 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode) { // stop elect timer syncNodeStopElectTimer(pSyncNode); - // start heartbeat timer - syncNodeStartHeartbeatTimer(pSyncNode); - // start replicate right now! syncNodeReplicate(pSyncNode); + + // start heartbeat timer + syncNodeStartHeartbeatTimer(pSyncNode); } void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index f3fd7f84a2..01ec761a9c 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -63,15 +63,18 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; - SSyncRaftEntry* pEntry; + SSyncRaftEntry* pEntry = NULL; - SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); - walReadWithHandle(pWalHandle, index); - pEntry = syncEntryDeserialize(pWalHandle->pHead->head.body, pWalHandle->pHead->head.len); - assert(pEntry != NULL); + if (index >= SYNC_INDEX_BEGIN && index <= logStoreLastIndex(pLogStore)) { + SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); + walReadWithHandle(pWalHandle, index); + pEntry = syncEntryDeserialize(pWalHandle->pHead->head.body, pWalHandle->pHead->head.len); + assert(pEntry != NULL); + + // need to hold, do not new every time!! + walCloseReadHandle(pWalHandle); + } - // need to hold, do not new every time!! - walCloseReadHandle(pWalHandle); return pEntry; } diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp index e52fe61ef5..b8a1460f35 100644 --- a/source/libs/sync/test/syncElectTest.cpp +++ b/source/libs/sync/test/syncElectTest.cpp @@ -17,7 +17,7 @@ void logTest() { } uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; -int32_t replicaNum = 1; +int32_t replicaNum = 3; int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; @@ -33,7 +33,7 @@ SSyncNode* syncNodeInit() { syncInfo.queue = gSyncIO->pMsgQ; syncInfo.FpEqMsg = syncIOEqMsg; syncInfo.pFsm = pFsm; - snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./elect_test"); + snprintf(syncInfo.path, sizeof(syncInfo.path), "./elect_test_%d", myIndex); int code = walInit(); assert(code == 0); @@ -46,7 +46,10 @@ SSyncNode* syncNodeInit() { walCfg.retentionSize = 1000; walCfg.segSize = 1000; walCfg.level = TAOS_WAL_FSYNC; - pWal = walOpen("./elect_test_wal", &walCfg); + + char tmpdir[128]; + snprintf(tmpdir, sizeof(tmpdir), "./elect_test_wal_%d", myIndex); + pWal = walOpen(tmpdir, &walCfg); assert(pWal != NULL); syncInfo.pWal = pWal; diff --git a/source/libs/sync/test/syncLogStoreTest.cpp b/source/libs/sync/test/syncLogStoreTest.cpp index 1b05f76fa2..c1cb66f382 100644 --- a/source/libs/sync/test/syncLogStoreTest.cpp +++ b/source/libs/sync/test/syncLogStoreTest.cpp @@ -81,7 +81,7 @@ SSyncNode* syncNodeInit() { SSyncNode* syncInitTest() { return syncNodeInit(); } void logStoreTest() { - logStorePrint2((char*)"logStoreTest2", pSyncNode->pLogStore); + logStorePrint2((char*)"logStoreTest", pSyncNode->pLogStore); assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_INVALID); @@ -105,10 +105,10 @@ void logStoreTest() { assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_BEGIN); } } - logStorePrint(pSyncNode->pLogStore); + logStorePrint2((char*)"after appendEntry", pSyncNode->pLogStore); pSyncNode->pLogStore->truncate(pSyncNode->pLogStore, 3); - logStorePrint(pSyncNode->pLogStore); + logStorePrint2((char*)"after truncate 3", pSyncNode->pLogStore); } void initRaftId(SSyncNode* pSyncNode) { From 4d4fabf4031259c9954306d80d1f8dc7a5c8828b Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 21:11:20 +0800 Subject: [PATCH 21/60] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 9 +++++++-- source/libs/sync/src/syncReplication.c | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 888d7e16d1..7013d281e3 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -101,7 +101,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { assert(pMsg->dataLen >= 0); SyncTerm localPreLogTerm = 0; - if (pMsg->prevLogTerm >= SYNC_INDEX_BEGIN && pMsg->prevLogTerm <= ths->pLogStore->getLastIndex(ths->pLogStore)) { + if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); assert(pEntry != NULL); localPreLogTerm = pEntry->term; @@ -174,7 +174,12 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { pReply->destId = pMsg->srcId; pReply->term = ths->pRaftStore->currentTerm; pReply->success = true; - pReply->matchIndex = pMsg->prevLogIndex + 1; + + if (pMsg->dataLen > 0) { + pReply->matchIndex = pMsg->prevLogIndex + 1; + } else { + pReply->matchIndex = pMsg->prevLogIndex; + } SRpcMsg rpcMsg; syncAppendEntriesReply2RpcMsg(pReply, &rpcMsg); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index ca04db81b6..0bb701fc09 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -73,7 +73,8 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) { SyncAppendEntries* pMsg = NULL; SSyncRaftEntry* pEntry = logStoreGetEntry(pSyncNode->pLogStore, nextIndex); if (pEntry != NULL) { - SyncAppendEntries* pMsg = syncAppendEntriesBuild(pEntry->bytes); + pMsg = syncAppendEntriesBuild(pEntry->bytes); + assert(pMsg != NULL); // add pEntry into msg uint32_t len; @@ -86,9 +87,11 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) { } else { // maybe overflow, send empty record - SyncAppendEntries* pMsg = syncAppendEntriesBuild(0); + pMsg = syncAppendEntriesBuild(0); + assert(pMsg != NULL); } + assert(pMsg != NULL); pMsg->srcId = pSyncNode->myRaftId; pMsg->destId = *pDestId; pMsg->term = pSyncNode->pRaftStore->currentTerm; From 5ab55c6554e69fd0e1ab88cb9b11f3bba4bd1c46 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 21:21:48 +0800 Subject: [PATCH 22/60] sync refactor --- source/libs/sync/test/syncElectTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp index b8a1460f35..f3b2cde6e5 100644 --- a/source/libs/sync/test/syncElectTest.cpp +++ b/source/libs/sync/test/syncElectTest.cpp @@ -116,7 +116,7 @@ int main(int argc, char** argv) { //--------------------------- while (1) { - sTrace("while 1 sleep, state: %d, %s", gSyncNode->state, syncUtilState2String(gSyncNode->state)); + sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); taosMsleep(1000); } From bc60b00d751565390b6e3fc2ce4b34d7577f177b Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 21:22:56 +0800 Subject: [PATCH 23/60] sync refactor --- source/libs/sync/src/syncAppendEntriesReply.c | 3 ++- source/libs/sync/src/syncEnv.c | 22 ++++++++++--------- source/libs/sync/src/syncIO.c | 6 ++--- source/libs/sync/src/syncRequestVoteReply.c | 3 ++- source/libs/sync/test/syncElectTest.cpp | 4 +++- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index f9630f7cfe..93539db938 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -39,7 +39,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, + ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index 4b650ec087..d47a525e25 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -54,20 +54,22 @@ static void syncEnvTick(void *param, void *tmrId) { SSyncEnv *pSyncEnv = (SSyncEnv *)param; if (atomic_load_64(&pSyncEnv->envTickTimerLogicClockUser) <= atomic_load_64(&pSyncEnv->envTickTimerLogicClock)) { ++(pSyncEnv->envTickTimerCounter); - sTrace( - "syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " - "envTickTimerMS:%d, tmrId:%p", - pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, - pSyncEnv->envTickTimerMS, tmrId); + sTrace("syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 + ", envTickTimerCounter:%" PRIu64 + ", " + "envTickTimerMS:%d, tmrId:%p", + pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, + pSyncEnv->envTickTimerMS, tmrId); // do something, tick ... taosTmrReset(syncEnvTick, pSyncEnv->envTickTimerMS, pSyncEnv, pSyncEnv->pTimerManager, &pSyncEnv->pEnvTickTimer); } else { - sTrace( - "syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " - "envTickTimerMS:%d, tmrId:%p", - pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, - pSyncEnv->envTickTimerMS, tmrId); + sTrace("syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 + ", envTickTimerCounter:%" PRIu64 + ", " + "envTickTimerMS:%d, tmrId:%p", + pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, + pSyncEnv->envTickTimerMS, tmrId); } } diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index c8448c32eb..c841c2ac06 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void *syncIOConsumerFunc(void *param); +static void * syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO *io = param; + SSyncIO * io = param; STaosQall *qall; - SRpcMsg *pRpcMsg, rpcMsg; + SRpcMsg * pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 11537c1e98..12603bb337 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -41,7 +41,8 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) syncRequestVoteReplyLog2("==syncNodeOnRequestVoteReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, + ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp index f3b2cde6e5..502263cfbf 100644 --- a/source/libs/sync/test/syncElectTest.cpp +++ b/source/libs/sync/test/syncElectTest.cpp @@ -116,7 +116,9 @@ int main(int argc, char** argv) { //--------------------------- while (1) { - sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); + sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); taosMsleep(1000); } From 83b40facc25bc1f9e26fbcafa61e4320436ee18a Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 23:11:49 -0400 Subject: [PATCH 24/60] TD-13675 rollup, alter db, alter table syntax definition --- source/libs/parser/inc/sql.y | 44 +- source/libs/parser/src/sql.c | 3672 +++++++++++++++++----------------- 2 files changed, 1894 insertions(+), 1822 deletions(-) diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 46775b7927..aa8ced8d7e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -44,25 +44,39 @@ //%right NK_BITNOT. /************************************************ create/alter account *****************************************/ -cmd ::= ALTER ACCOUNT NK_ID account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +cmd ::= ALTER ACCOUNT NK_ID alter_account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } %type account_options { int32_t } %destructor account_options { } -account_options ::= account_option. { } -account_options ::= account_options account_option. { } +account_options ::= . { } +account_options ::= account_options PPS literal. { } +account_options ::= account_options TSERIES literal. { } +account_options ::= account_options STORAGE literal. { } +account_options ::= account_options STREAMS literal. { } +account_options ::= account_options QTIME literal. { } +account_options ::= account_options DBS literal. { } +account_options ::= account_options USERS literal. { } +account_options ::= account_options CONNS literal. { } +account_options ::= account_options STATE literal. { } -%type account_option { int32_t } -%destructor account_option { } -account_option ::= PASS literal. { } -account_option ::= PPS literal. { } -account_option ::= TSERIES literal. { } -account_option ::= STORAGE literal. { } -account_option ::= STREAMS literal. { } -account_option ::= QTIME literal. { } -account_option ::= DBS literal. { } -account_option ::= USERS literal. { } -account_option ::= CONNS literal. { } -account_option ::= STATE literal. { } +%type alter_account_options { int32_t } +%destructor alter_account_options { } +alter_account_options ::= alter_account_option. { } +alter_account_options ::= alter_account_options alter_account_option. { } + +%type alter_account_option { int32_t } +%destructor alter_account_option { } +alter_account_option ::= PASS literal. { } +alter_account_option ::= PPS literal. { } +alter_account_option ::= TSERIES literal. { } +alter_account_option ::= STORAGE literal. { } +alter_account_option ::= STREAMS literal. { } +alter_account_option ::= QTIME literal. { } +alter_account_option ::= DBS literal. { } +alter_account_option ::= USERS literal. { } +alter_account_option ::= CONNS literal. { } +alter_account_option ::= STATE literal. { } /************************************************ create/alter/drop/show user *****************************************/ cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 4f2149ac88..fa7eb6bc89 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,24 +99,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 248 +#define YYNOCODE 249 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SNode* yy168; - SDataType yy208; - EJoinType yy228; - SToken yy241; - EOrder yy258; - EFillMode yy262; - int32_t yy324; - SAlterOption yy349; - ENullOrder yy425; - SNodeList* yy440; - bool yy457; - EOperatorType yy476; + SNode* yy26; + EOrder yy32; + SNodeList* yy64; + EOperatorType yy80; + bool yy107; + EFillMode yy192; + SToken yy353; + SDataType yy370; + EJoinType yy372; + ENullOrder yy391; + SAlterOption yy443; + int32_t yy448; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -131,17 +131,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 400 -#define YYNRULE 305 +#define YYNSTATE 414 +#define YYNRULE 316 #define YYNTOKEN 160 -#define YY_MAX_SHIFT 399 -#define YY_MIN_SHIFTREDUCE 608 -#define YY_MAX_SHIFTREDUCE 912 -#define YY_ERROR_ACTION 913 -#define YY_ACCEPT_ACTION 914 -#define YY_NO_ACTION 915 -#define YY_MIN_REDUCE 916 -#define YY_MAX_REDUCE 1220 +#define YY_MAX_SHIFT 413 +#define YY_MIN_SHIFTREDUCE 631 +#define YY_MAX_SHIFTREDUCE 946 +#define YY_ERROR_ACTION 947 +#define YY_ACCEPT_ACTION 948 +#define YY_NO_ACTION 949 +#define YY_MIN_REDUCE 950 +#define YY_MAX_REDUCE 1265 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -208,366 +208,379 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1150) +#define YY_ACTTAB_COUNT (1182) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 951, 1087, 1087, 42, 297, 914, 1199, 208, 24, 140, - /* 10 */ 1070, 312, 79, 31, 29, 27, 26, 25, 916, 1198, - /* 20 */ 1010, 94, 917, 1197, 196, 211, 89, 31, 29, 27, - /* 30 */ 26, 25, 213, 352, 1018, 1061, 1063, 1085, 1085, 77, - /* 40 */ 76, 75, 74, 73, 72, 71, 70, 69, 68, 226, - /* 50 */ 991, 190, 339, 338, 337, 336, 335, 334, 333, 332, - /* 60 */ 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, - /* 70 */ 321, 1199, 100, 30, 28, 795, 31, 29, 27, 26, - /* 80 */ 25, 205, 352, 1053, 107, 818, 10, 1060, 1197, 297, - /* 90 */ 781, 353, 278, 195, 774, 1071, 242, 989, 1058, 243, - /* 100 */ 772, 77, 76, 75, 74, 73, 72, 71, 70, 69, - /* 110 */ 68, 12, 1015, 82, 190, 31, 29, 27, 26, 25, - /* 120 */ 23, 203, 243, 813, 814, 815, 816, 817, 819, 821, - /* 130 */ 822, 823, 773, 80, 1, 774, 31, 29, 27, 26, - /* 140 */ 25, 772, 280, 103, 1145, 1146, 320, 1150, 818, 713, - /* 150 */ 375, 374, 373, 717, 372, 719, 720, 371, 722, 368, - /* 160 */ 398, 728, 365, 730, 731, 362, 359, 97, 980, 1060, - /* 170 */ 908, 909, 854, 773, 352, 210, 783, 1098, 775, 778, - /* 180 */ 1058, 9, 8, 23, 203, 272, 813, 814, 815, 816, - /* 190 */ 817, 819, 821, 822, 823, 108, 1113, 385, 795, 380, - /* 200 */ 209, 398, 384, 294, 108, 383, 1060, 381, 89, 296, - /* 210 */ 382, 785, 214, 1085, 252, 1098, 1017, 1058, 282, 775, - /* 220 */ 778, 60, 1099, 1102, 1138, 353, 6, 10, 189, 1134, - /* 230 */ 64, 30, 28, 855, 1113, 1088, 635, 351, 1060, 205, - /* 240 */ 1199, 281, 250, 353, 347, 346, 1015, 296, 64, 1062, - /* 250 */ 253, 1085, 774, 107, 831, 379, 42, 1197, 772, 61, - /* 260 */ 1099, 1102, 1138, 286, 1015, 155, 198, 1134, 102, 12, - /* 270 */ 78, 1085, 1199, 1011, 1113, 1098, 343, 353, 1098, 154, - /* 280 */ 136, 294, 1012, 1157, 850, 107, 259, 1165, 108, 1197, - /* 290 */ 773, 21, 1, 171, 1113, 786, 1045, 1113, 1015, 820, - /* 300 */ 267, 294, 824, 853, 281, 59, 135, 296, 151, 990, - /* 310 */ 296, 1085, 353, 1098, 1085, 850, 282, 307, 398, 179, - /* 320 */ 1099, 1102, 61, 1099, 1102, 1138, 212, 287, 1113, 198, - /* 330 */ 1134, 102, 1113, 1015, 89, 294, 775, 778, 1199, 294, - /* 340 */ 636, 306, 1017, 219, 258, 296, 58, 119, 1098, 1085, - /* 350 */ 1166, 107, 988, 635, 271, 1197, 83, 61, 1099, 1102, - /* 360 */ 1138, 637, 215, 1007, 198, 1134, 1211, 1113, 377, 317, - /* 370 */ 89, 1060, 376, 316, 294, 1172, 108, 1098, 1017, 377, - /* 380 */ 296, 862, 1059, 376, 1085, 285, 221, 783, 218, 217, - /* 390 */ 122, 355, 61, 1099, 1102, 1138, 1113, 378, 318, 198, - /* 400 */ 1134, 1211, 1152, 294, 1006, 946, 30, 28, 378, 296, - /* 410 */ 1195, 784, 317, 1085, 205, 289, 316, 315, 314, 1149, - /* 420 */ 1152, 61, 1099, 1102, 1138, 1152, 353, 774, 198, 1134, - /* 430 */ 1211, 308, 1098, 772, 928, 30, 28, 1148, 386, 1156, - /* 440 */ 1085, 318, 1147, 205, 12, 255, 927, 1015, 353, 926, - /* 450 */ 353, 1113, 925, 152, 1098, 216, 774, 320, 294, 87, - /* 460 */ 315, 314, 772, 57, 296, 773, 278, 1, 1085, 1015, - /* 470 */ 1085, 1015, 51, 1113, 278, 53, 62, 1099, 1102, 1138, - /* 480 */ 294, 290, 1085, 1137, 1134, 1085, 296, 82, 1085, 1008, - /* 490 */ 1085, 918, 278, 398, 773, 82, 7, 313, 62, 1099, - /* 500 */ 1102, 1138, 27, 26, 25, 292, 1134, 80, 1004, 117, - /* 510 */ 293, 775, 778, 82, 101, 80, 876, 104, 1145, 1146, - /* 520 */ 248, 1150, 398, 116, 20, 105, 1145, 1146, 282, 1150, - /* 530 */ 65, 1000, 284, 80, 31, 29, 27, 26, 25, 1002, - /* 540 */ 775, 778, 924, 133, 1145, 277, 266, 276, 923, 43, - /* 550 */ 1199, 998, 114, 30, 28, 295, 1098, 108, 30, 28, - /* 560 */ 231, 205, 922, 107, 9, 8, 205, 1197, 30, 28, - /* 570 */ 981, 264, 273, 268, 774, 1113, 205, 1098, 1085, 774, - /* 580 */ 772, 810, 294, 161, 1085, 772, 159, 113, 296, 774, - /* 590 */ 921, 111, 1085, 137, 22, 772, 1113, 920, 1085, 919, - /* 600 */ 96, 1099, 1102, 294, 31, 29, 27, 26, 25, 296, - /* 610 */ 1054, 127, 773, 1085, 7, 163, 204, 773, 162, 7, - /* 620 */ 1092, 185, 1099, 1102, 781, 125, 1085, 773, 825, 1, - /* 630 */ 911, 912, 238, 1085, 1090, 1085, 792, 283, 1212, 764, - /* 640 */ 398, 130, 32, 1098, 237, 398, 249, 145, 279, 236, - /* 650 */ 32, 235, 302, 32, 150, 398, 1168, 706, 775, 778, - /* 660 */ 941, 143, 1113, 775, 778, 1098, 84, 1114, 85, 294, - /* 670 */ 232, 87, 397, 775, 778, 296, 2, 139, 781, 1085, - /* 680 */ 234, 233, 701, 227, 1113, 395, 1098, 62, 1099, 1102, - /* 690 */ 1138, 294, 939, 388, 738, 1135, 65, 296, 789, 744, - /* 700 */ 743, 1085, 88, 165, 260, 1113, 164, 1098, 85, 185, - /* 710 */ 1099, 1102, 294, 86, 87, 734, 85, 239, 296, 110, - /* 720 */ 228, 782, 1085, 1098, 167, 391, 1113, 166, 176, 357, - /* 730 */ 184, 1099, 1102, 294, 240, 788, 241, 41, 1098, 296, - /* 740 */ 244, 174, 1113, 1085, 115, 175, 95, 787, 251, 294, - /* 750 */ 256, 96, 1099, 1102, 254, 296, 118, 1113, 109, 1085, - /* 760 */ 1098, 274, 202, 786, 294, 257, 1179, 185, 1099, 1102, - /* 770 */ 296, 265, 1169, 300, 1085, 778, 1098, 206, 262, 1113, - /* 780 */ 197, 1098, 185, 1099, 1102, 123, 294, 126, 1178, 1213, - /* 790 */ 1159, 5, 296, 261, 99, 1113, 1085, 275, 4, 131, - /* 800 */ 1113, 850, 294, 129, 183, 1099, 1102, 294, 296, 1098, - /* 810 */ 81, 785, 1085, 296, 1153, 33, 132, 1085, 199, 291, - /* 820 */ 186, 1099, 1102, 1214, 1196, 177, 1099, 1102, 1113, 138, - /* 830 */ 288, 17, 1120, 1098, 1069, 294, 298, 299, 1098, 1068, - /* 840 */ 303, 296, 207, 147, 108, 1085, 52, 304, 305, 170, - /* 850 */ 50, 350, 1113, 187, 1099, 1102, 172, 1113, 390, 294, - /* 860 */ 153, 1098, 310, 1016, 294, 296, 225, 354, 1005, 1085, - /* 870 */ 296, 955, 158, 399, 1085, 1079, 1098, 178, 1099, 1102, - /* 880 */ 1113, 1001, 188, 1099, 1102, 160, 169, 294, 90, 91, - /* 890 */ 1003, 393, 67, 296, 999, 1113, 387, 1085, 92, 93, - /* 900 */ 168, 180, 294, 173, 954, 1110, 1099, 1102, 296, 181, - /* 910 */ 1078, 1077, 1085, 1098, 229, 230, 1098, 1076, 994, 993, - /* 920 */ 1109, 1099, 1102, 385, 953, 380, 38, 950, 384, 37, - /* 930 */ 938, 383, 1113, 381, 933, 1113, 382, 1075, 1066, 294, - /* 940 */ 992, 112, 294, 650, 952, 296, 1098, 949, 296, 1085, - /* 950 */ 246, 245, 1085, 247, 937, 936, 932, 1108, 1099, 1102, - /* 960 */ 193, 1099, 1102, 1074, 1073, 1113, 36, 1065, 1098, 120, - /* 970 */ 121, 44, 294, 3, 32, 14, 124, 39, 296, 875, - /* 980 */ 98, 128, 1085, 270, 1098, 269, 1090, 1113, 869, 1098, - /* 990 */ 192, 1099, 1102, 45, 294, 868, 46, 15, 34, 11, - /* 1000 */ 296, 47, 847, 1113, 1085, 897, 846, 902, 1113, 134, - /* 1010 */ 294, 896, 194, 1099, 1102, 294, 296, 879, 200, 19, - /* 1020 */ 1085, 296, 901, 35, 16, 1085, 106, 900, 191, 1099, - /* 1030 */ 1102, 201, 8, 182, 1099, 1102, 811, 141, 13, 263, - /* 1040 */ 877, 878, 880, 881, 793, 142, 18, 1064, 873, 144, - /* 1050 */ 146, 48, 148, 149, 301, 49, 712, 40, 311, 54, - /* 1060 */ 53, 742, 55, 56, 741, 740, 309, 648, 319, 671, - /* 1070 */ 670, 948, 669, 668, 667, 666, 662, 665, 664, 663, - /* 1080 */ 661, 660, 935, 659, 658, 657, 934, 656, 655, 654, - /* 1090 */ 653, 340, 341, 344, 345, 929, 348, 342, 349, 996, - /* 1100 */ 1089, 156, 157, 66, 356, 735, 220, 360, 363, 366, - /* 1110 */ 727, 726, 369, 725, 749, 748, 724, 747, 995, 679, - /* 1120 */ 678, 947, 677, 222, 676, 942, 675, 674, 940, 223, - /* 1130 */ 358, 389, 732, 361, 224, 729, 723, 364, 931, 367, - /* 1140 */ 394, 392, 930, 396, 776, 915, 721, 370, 915, 63, + /* 0 */ 996, 347, 347, 24, 162, 334, 253, 1057, 227, 1049, + /* 10 */ 108, 1115, 1158, 31, 29, 27, 26, 25, 951, 331, + /* 20 */ 347, 1098, 1060, 1060, 103, 64, 962, 31, 29, 27, + /* 30 */ 26, 25, 263, 233, 1051, 973, 1106, 1108, 304, 76, + /* 40 */ 346, 1060, 75, 74, 73, 72, 71, 70, 69, 68, + /* 50 */ 67, 201, 398, 397, 396, 395, 394, 393, 392, 391, + /* 60 */ 390, 389, 388, 387, 386, 385, 384, 383, 382, 381, + /* 70 */ 380, 1130, 1130, 30, 28, 829, 31, 29, 27, 26, + /* 80 */ 25, 224, 346, 808, 76, 852, 42, 75, 74, 73, + /* 90 */ 72, 71, 70, 69, 68, 67, 275, 102, 270, 42, + /* 100 */ 806, 274, 1244, 1056, 273, 1063, 271, 1105, 88, 272, + /* 110 */ 289, 12, 950, 214, 201, 1243, 1055, 815, 1103, 1242, + /* 120 */ 23, 222, 346, 847, 848, 849, 850, 851, 853, 855, + /* 130 */ 856, 857, 807, 254, 1, 10, 86, 85, 84, 83, + /* 140 */ 82, 81, 80, 79, 78, 1132, 290, 303, 852, 747, + /* 150 */ 369, 368, 367, 751, 366, 753, 754, 365, 756, 362, + /* 160 */ 410, 762, 359, 764, 765, 356, 353, 287, 1244, 215, + /* 170 */ 942, 943, 817, 310, 305, 10, 913, 1143, 809, 812, + /* 180 */ 285, 116, 1130, 23, 222, 1242, 847, 848, 849, 850, + /* 190 */ 851, 853, 855, 856, 857, 117, 117, 1158, 300, 911, + /* 200 */ 912, 914, 915, 1132, 331, 31, 29, 27, 26, 25, + /* 210 */ 333, 347, 347, 888, 1130, 1143, 344, 345, 815, 319, + /* 220 */ 105, 1025, 60, 1144, 1147, 1183, 948, 230, 249, 200, + /* 230 */ 1179, 117, 1060, 1060, 347, 1158, 972, 292, 248, 64, + /* 240 */ 1130, 1244, 318, 247, 315, 246, 269, 309, 333, 379, + /* 250 */ 1158, 96, 1130, 1197, 116, 1060, 180, 331, 1242, 1090, + /* 260 */ 61, 1144, 1147, 1183, 243, 91, 1105, 217, 1179, 111, + /* 270 */ 1194, 237, 229, 1130, 245, 244, 308, 1103, 1143, 406, + /* 280 */ 405, 158, 30, 28, 889, 89, 347, 296, 1210, 819, + /* 290 */ 224, 175, 808, 1244, 317, 112, 1190, 1191, 1158, 1195, + /* 300 */ 228, 315, 27, 26, 25, 318, 116, 1060, 102, 806, + /* 310 */ 1242, 333, 51, 1143, 239, 1130, 1062, 58, 1202, 884, + /* 320 */ 12, 818, 91, 61, 1144, 1147, 1183, 92, 1036, 1053, + /* 330 */ 217, 1179, 111, 1158, 1052, 31, 29, 27, 26, 25, + /* 340 */ 331, 807, 89, 1, 887, 267, 333, 232, 1143, 266, + /* 350 */ 1130, 1211, 113, 1190, 1191, 102, 1195, 910, 61, 1144, + /* 360 */ 1147, 1183, 235, 1062, 117, 217, 1179, 1256, 1158, 410, + /* 370 */ 102, 77, 372, 971, 268, 331, 1217, 254, 1062, 1143, + /* 380 */ 1105, 333, 30, 28, 157, 1130, 234, 809, 812, 1035, + /* 390 */ 224, 1103, 808, 61, 1144, 1147, 1183, 829, 347, 1158, + /* 400 */ 217, 1179, 1256, 236, 9, 8, 331, 30, 28, 806, + /* 410 */ 1130, 1240, 333, 30, 28, 224, 1130, 808, 1143, 1060, + /* 420 */ 12, 224, 334, 808, 61, 1144, 1147, 1183, 1116, 1197, + /* 430 */ 808, 217, 1179, 1256, 806, 669, 970, 670, 1158, 669, + /* 440 */ 806, 807, 1201, 1, 1045, 331, 1193, 806, 1047, 376, + /* 450 */ 1105, 333, 261, 375, 969, 1130, 1143, 1034, 671, 21, + /* 460 */ 319, 1107, 322, 190, 1144, 1147, 807, 854, 7, 410, + /* 470 */ 858, 149, 807, 1130, 7, 1105, 1158, 865, 377, 807, + /* 480 */ 57, 6, 1244, 331, 968, 147, 1104, 809, 812, 333, + /* 490 */ 1143, 1130, 53, 1130, 410, 116, 967, 374, 373, 1242, + /* 500 */ 410, 62, 1144, 1147, 1183, 820, 379, 410, 1182, 1179, + /* 510 */ 1158, 315, 809, 812, 30, 28, 332, 331, 809, 812, + /* 520 */ 966, 1130, 224, 333, 808, 809, 812, 1130, 896, 117, + /* 530 */ 965, 964, 91, 1130, 817, 62, 1144, 1147, 1183, 1133, + /* 540 */ 961, 806, 329, 1179, 960, 30, 28, 319, 945, 946, + /* 550 */ 959, 1143, 89, 224, 958, 808, 957, 1130, 131, 9, + /* 560 */ 8, 129, 155, 1190, 314, 413, 313, 1130, 1130, 1244, + /* 570 */ 884, 1158, 806, 807, 956, 7, 1130, 1130, 331, 178, + /* 580 */ 1043, 1130, 116, 87, 333, 955, 1242, 1130, 1130, 402, + /* 590 */ 1143, 1130, 177, 1130, 954, 323, 106, 1144, 1147, 330, + /* 600 */ 144, 410, 953, 126, 807, 326, 1, 110, 1197, 321, + /* 610 */ 1158, 1130, 371, 259, 963, 242, 125, 331, 59, 809, + /* 620 */ 812, 173, 1130, 333, 1026, 1192, 133, 1130, 1143, 132, + /* 630 */ 159, 1130, 410, 320, 1257, 62, 1144, 1147, 1183, 1130, + /* 640 */ 991, 135, 43, 1180, 134, 123, 137, 301, 1158, 136, + /* 650 */ 809, 812, 1143, 859, 343, 331, 986, 295, 152, 324, + /* 660 */ 141, 333, 276, 1143, 185, 1130, 984, 32, 223, 187, + /* 670 */ 844, 327, 1158, 196, 1144, 1147, 1099, 826, 278, 331, + /* 680 */ 122, 186, 104, 1158, 120, 333, 1143, 260, 281, 1130, + /* 690 */ 331, 32, 297, 1137, 118, 1213, 333, 196, 1144, 1147, + /* 700 */ 1130, 1143, 316, 798, 167, 1159, 1158, 1135, 195, 1144, + /* 710 */ 1147, 1033, 339, 331, 161, 172, 1143, 32, 165, 333, + /* 720 */ 2, 1158, 250, 1130, 238, 815, 93, 823, 331, 94, + /* 730 */ 119, 106, 1144, 1147, 333, 816, 1158, 1143, 1130, 311, + /* 740 */ 251, 221, 252, 331, 740, 735, 196, 1144, 1147, 333, + /* 750 */ 822, 41, 1143, 1130, 255, 124, 225, 1158, 96, 77, + /* 760 */ 821, 196, 1144, 1147, 331, 262, 264, 768, 1143, 1258, + /* 770 */ 333, 376, 1158, 772, 1130, 375, 778, 1050, 777, 331, + /* 780 */ 117, 351, 194, 1144, 1147, 333, 66, 94, 1158, 1130, + /* 790 */ 95, 1143, 96, 128, 97, 331, 1143, 197, 1144, 1147, + /* 800 */ 377, 333, 1046, 291, 130, 1130, 98, 1143, 94, 99, + /* 810 */ 1048, 1158, 1143, 188, 1144, 1147, 1158, 1044, 331, 374, + /* 820 */ 373, 140, 100, 331, 333, 101, 213, 1158, 1130, 333, + /* 830 */ 820, 1214, 1158, 1130, 331, 293, 198, 1144, 1147, 331, + /* 840 */ 333, 189, 1144, 1147, 1130, 333, 1224, 1143, 294, 1130, + /* 850 */ 1143, 302, 199, 1144, 1147, 337, 145, 1155, 1144, 1147, + /* 860 */ 812, 148, 299, 216, 298, 5, 1204, 1158, 1223, 312, + /* 870 */ 1158, 4, 884, 90, 331, 819, 151, 331, 109, 1198, + /* 880 */ 333, 33, 153, 333, 1130, 1143, 154, 1130, 218, 328, + /* 890 */ 17, 1241, 1154, 1144, 1147, 1153, 1144, 1147, 1259, 325, + /* 900 */ 1143, 160, 1165, 340, 1114, 1158, 335, 169, 336, 50, + /* 910 */ 341, 1113, 331, 226, 1061, 342, 1143, 179, 333, 52, + /* 920 */ 1158, 1143, 1130, 315, 181, 176, 409, 331, 191, 349, + /* 930 */ 204, 1144, 1147, 333, 183, 184, 1158, 1130, 1124, 192, + /* 940 */ 999, 1158, 1123, 331, 91, 203, 1144, 1147, 331, 333, + /* 950 */ 1122, 240, 1143, 1130, 333, 241, 1121, 208, 1130, 1039, + /* 960 */ 1038, 205, 1144, 1147, 89, 998, 202, 1144, 1147, 1000, + /* 970 */ 995, 983, 1158, 121, 114, 1190, 1191, 280, 1195, 331, + /* 980 */ 978, 1120, 267, 1111, 1037, 333, 266, 684, 997, 1130, + /* 990 */ 994, 256, 288, 258, 257, 982, 981, 193, 1144, 1147, + /* 1000 */ 209, 977, 207, 206, 1041, 265, 139, 65, 127, 781, + /* 1010 */ 283, 268, 1040, 783, 782, 277, 713, 712, 711, 138, + /* 1020 */ 992, 275, 210, 270, 710, 709, 274, 987, 708, 273, + /* 1030 */ 211, 271, 279, 985, 272, 212, 282, 976, 284, 975, + /* 1040 */ 286, 63, 1119, 1118, 1110, 38, 36, 142, 37, 44, + /* 1050 */ 3, 20, 32, 143, 14, 39, 146, 15, 306, 34, + /* 1060 */ 307, 31, 29, 27, 26, 25, 22, 909, 903, 47, + /* 1070 */ 11, 107, 150, 931, 930, 45, 31, 29, 27, 26, + /* 1080 */ 25, 902, 46, 8, 881, 880, 219, 935, 1109, 934, + /* 1090 */ 220, 993, 1135, 980, 19, 949, 936, 170, 827, 164, + /* 1100 */ 350, 156, 13, 35, 115, 18, 231, 354, 357, 360, + /* 1110 */ 907, 16, 845, 163, 166, 363, 53, 746, 168, 48, + /* 1120 */ 774, 704, 776, 775, 348, 49, 400, 1134, 769, 40, + /* 1130 */ 352, 399, 766, 355, 401, 378, 763, 757, 682, 358, + /* 1140 */ 171, 338, 174, 703, 361, 702, 755, 364, 701, 700, + /* 1150 */ 699, 698, 54, 55, 697, 56, 696, 705, 695, 694, + /* 1160 */ 761, 693, 692, 691, 690, 689, 403, 370, 688, 687, + /* 1170 */ 404, 979, 974, 407, 760, 408, 759, 810, 758, 182, + /* 1180 */ 411, 412, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 0, 163, 163, 170, 195, 160, 226, 198, 211, 212, - /* 10 */ 201, 183, 179, 12, 13, 14, 15, 16, 0, 239, - /* 20 */ 187, 161, 162, 243, 186, 186, 182, 12, 13, 14, - /* 30 */ 15, 16, 191, 20, 190, 194, 195, 199, 199, 21, - /* 40 */ 22, 23, 24, 25, 26, 27, 28, 29, 30, 204, - /* 50 */ 0, 50, 52, 53, 54, 55, 56, 57, 58, 59, + /* 0 */ 0, 169, 169, 212, 213, 196, 174, 174, 199, 184, + /* 10 */ 182, 202, 183, 12, 13, 14, 15, 16, 0, 190, + /* 20 */ 169, 193, 190, 190, 162, 174, 164, 12, 13, 14, + /* 30 */ 15, 16, 181, 192, 163, 163, 195, 196, 209, 21, + /* 40 */ 20, 190, 24, 25, 26, 27, 28, 29, 30, 31, + /* 50 */ 32, 50, 52, 53, 54, 55, 56, 57, 58, 59, /* 60 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - /* 70 */ 70, 226, 181, 12, 13, 74, 12, 13, 14, 15, - /* 80 */ 16, 20, 20, 192, 239, 84, 73, 182, 243, 195, - /* 90 */ 20, 168, 168, 188, 33, 201, 173, 0, 193, 49, - /* 100 */ 39, 21, 22, 23, 24, 25, 26, 27, 28, 29, - /* 110 */ 30, 50, 189, 189, 50, 12, 13, 14, 15, 16, - /* 120 */ 119, 120, 49, 122, 123, 124, 125, 126, 127, 128, - /* 130 */ 129, 130, 71, 209, 73, 33, 12, 13, 14, 15, - /* 140 */ 16, 39, 218, 219, 220, 221, 49, 223, 84, 90, + /* 70 */ 70, 200, 200, 12, 13, 74, 12, 13, 14, 15, + /* 80 */ 16, 20, 20, 22, 21, 84, 171, 24, 25, 26, + /* 90 */ 27, 28, 29, 30, 31, 32, 52, 183, 54, 171, + /* 100 */ 39, 57, 227, 188, 60, 191, 62, 183, 180, 65, + /* 110 */ 169, 50, 0, 189, 50, 240, 188, 20, 194, 244, + /* 120 */ 119, 120, 20, 122, 123, 124, 125, 126, 127, 128, + /* 130 */ 129, 130, 71, 49, 73, 73, 24, 25, 26, 27, + /* 140 */ 28, 29, 30, 31, 32, 163, 205, 113, 84, 90, /* 150 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - /* 160 */ 99, 102, 103, 104, 105, 106, 107, 171, 172, 182, - /* 170 */ 155, 156, 4, 71, 20, 188, 20, 163, 117, 118, - /* 180 */ 193, 1, 2, 119, 120, 20, 122, 123, 124, 125, - /* 190 */ 126, 127, 128, 129, 130, 134, 182, 52, 74, 54, - /* 200 */ 174, 99, 57, 189, 134, 60, 182, 62, 182, 195, - /* 210 */ 65, 20, 188, 199, 168, 163, 190, 193, 204, 117, - /* 220 */ 118, 207, 208, 209, 210, 168, 44, 73, 214, 215, - /* 230 */ 173, 12, 13, 14, 182, 163, 33, 180, 182, 20, - /* 240 */ 226, 189, 39, 168, 165, 166, 189, 195, 173, 193, - /* 250 */ 204, 199, 33, 239, 74, 180, 170, 243, 39, 207, - /* 260 */ 208, 209, 210, 88, 189, 32, 214, 215, 216, 50, - /* 270 */ 37, 199, 226, 187, 182, 163, 43, 168, 163, 46, - /* 280 */ 228, 189, 173, 132, 133, 239, 234, 235, 134, 243, - /* 290 */ 71, 119, 73, 175, 182, 20, 178, 182, 189, 127, - /* 300 */ 208, 189, 130, 135, 189, 72, 115, 195, 75, 0, - /* 310 */ 195, 199, 168, 163, 199, 133, 204, 173, 99, 207, - /* 320 */ 208, 209, 207, 208, 209, 210, 174, 152, 182, 214, - /* 330 */ 215, 216, 182, 189, 182, 189, 117, 118, 226, 189, - /* 340 */ 20, 108, 190, 35, 111, 195, 167, 114, 163, 199, - /* 350 */ 235, 239, 0, 33, 208, 243, 177, 207, 208, 209, - /* 360 */ 210, 41, 174, 184, 214, 215, 216, 182, 60, 60, - /* 370 */ 182, 182, 64, 64, 189, 225, 134, 163, 190, 60, - /* 380 */ 195, 14, 193, 64, 199, 3, 78, 20, 80, 81, - /* 390 */ 115, 83, 207, 208, 209, 210, 182, 89, 89, 214, - /* 400 */ 215, 216, 205, 189, 163, 0, 12, 13, 89, 195, - /* 410 */ 225, 20, 60, 199, 20, 88, 64, 108, 109, 222, - /* 420 */ 205, 207, 208, 209, 210, 205, 168, 33, 214, 215, - /* 430 */ 216, 173, 163, 39, 163, 12, 13, 222, 33, 225, - /* 440 */ 199, 89, 222, 20, 50, 74, 163, 189, 168, 163, - /* 450 */ 168, 182, 163, 173, 163, 173, 33, 49, 189, 88, - /* 460 */ 108, 109, 39, 73, 195, 71, 168, 73, 199, 189, - /* 470 */ 199, 189, 167, 182, 168, 85, 207, 208, 209, 210, - /* 480 */ 189, 154, 199, 214, 215, 199, 195, 189, 199, 184, - /* 490 */ 199, 162, 168, 99, 71, 189, 73, 86, 207, 208, - /* 500 */ 209, 210, 14, 15, 16, 214, 215, 209, 183, 32, - /* 510 */ 50, 117, 118, 189, 37, 209, 74, 219, 220, 221, - /* 520 */ 43, 223, 99, 46, 2, 219, 220, 221, 204, 223, - /* 530 */ 88, 183, 150, 209, 12, 13, 14, 15, 16, 183, - /* 540 */ 117, 118, 163, 219, 220, 221, 113, 223, 163, 72, - /* 550 */ 226, 183, 75, 12, 13, 14, 163, 134, 12, 13, - /* 560 */ 168, 20, 163, 239, 1, 2, 20, 243, 12, 13, - /* 570 */ 172, 237, 139, 140, 33, 182, 20, 163, 199, 33, - /* 580 */ 39, 121, 189, 79, 199, 39, 82, 110, 195, 33, - /* 590 */ 163, 114, 199, 246, 2, 39, 182, 163, 199, 163, - /* 600 */ 207, 208, 209, 189, 12, 13, 14, 15, 16, 195, - /* 610 */ 192, 74, 71, 199, 73, 79, 202, 71, 82, 73, - /* 620 */ 73, 207, 208, 209, 20, 88, 199, 71, 74, 73, - /* 630 */ 158, 159, 28, 199, 87, 199, 74, 244, 245, 74, - /* 640 */ 99, 231, 88, 163, 40, 99, 165, 74, 224, 45, - /* 650 */ 88, 47, 74, 88, 74, 99, 206, 74, 117, 118, - /* 660 */ 0, 88, 182, 117, 118, 163, 88, 182, 88, 189, - /* 670 */ 66, 88, 21, 117, 118, 195, 227, 240, 20, 199, - /* 680 */ 76, 77, 74, 168, 182, 34, 163, 207, 208, 209, - /* 690 */ 210, 189, 0, 33, 74, 215, 88, 195, 20, 74, - /* 700 */ 74, 199, 74, 79, 202, 182, 82, 163, 88, 207, - /* 710 */ 208, 209, 189, 88, 88, 74, 88, 203, 195, 170, - /* 720 */ 116, 20, 199, 163, 79, 33, 182, 82, 18, 88, - /* 730 */ 207, 208, 209, 189, 189, 20, 196, 170, 163, 195, - /* 740 */ 168, 31, 182, 199, 170, 35, 36, 20, 164, 189, - /* 750 */ 189, 207, 208, 209, 203, 195, 167, 182, 48, 199, - /* 760 */ 163, 238, 202, 20, 189, 196, 236, 207, 208, 209, - /* 770 */ 195, 142, 206, 141, 199, 118, 163, 202, 199, 182, - /* 780 */ 199, 163, 207, 208, 209, 200, 189, 200, 236, 245, - /* 790 */ 233, 149, 195, 137, 230, 182, 199, 148, 136, 229, - /* 800 */ 182, 133, 189, 232, 207, 208, 209, 189, 195, 163, - /* 810 */ 189, 20, 199, 195, 205, 131, 217, 199, 157, 153, - /* 820 */ 207, 208, 209, 247, 242, 207, 208, 209, 182, 241, - /* 830 */ 151, 73, 213, 163, 200, 189, 199, 199, 163, 200, - /* 840 */ 112, 195, 199, 189, 134, 199, 73, 197, 196, 178, - /* 850 */ 167, 164, 182, 207, 208, 209, 168, 182, 4, 189, - /* 860 */ 167, 163, 185, 189, 189, 195, 164, 182, 182, 199, - /* 870 */ 195, 0, 182, 19, 199, 0, 163, 207, 208, 209, - /* 880 */ 182, 182, 207, 208, 209, 182, 32, 189, 182, 182, - /* 890 */ 182, 37, 168, 195, 182, 182, 42, 199, 182, 182, - /* 900 */ 46, 176, 189, 169, 0, 207, 208, 209, 195, 176, - /* 910 */ 0, 0, 199, 163, 66, 87, 163, 0, 0, 0, - /* 920 */ 207, 208, 209, 52, 0, 54, 72, 0, 57, 75, - /* 930 */ 0, 60, 182, 62, 0, 182, 65, 0, 0, 189, - /* 940 */ 0, 44, 189, 51, 0, 195, 163, 0, 195, 199, - /* 950 */ 37, 39, 199, 44, 0, 0, 0, 207, 208, 209, - /* 960 */ 207, 208, 209, 0, 0, 182, 115, 0, 163, 44, - /* 970 */ 110, 73, 189, 88, 88, 138, 74, 88, 195, 74, - /* 980 */ 73, 73, 199, 88, 163, 39, 87, 182, 74, 163, - /* 990 */ 207, 208, 209, 73, 189, 74, 73, 138, 132, 138, - /* 1000 */ 195, 4, 74, 182, 199, 39, 74, 74, 182, 87, - /* 1010 */ 189, 39, 207, 208, 209, 189, 195, 121, 39, 88, - /* 1020 */ 199, 195, 39, 88, 88, 199, 87, 39, 207, 208, - /* 1030 */ 209, 39, 2, 207, 208, 209, 121, 87, 73, 143, - /* 1040 */ 144, 145, 146, 147, 74, 74, 73, 0, 74, 73, - /* 1050 */ 73, 73, 44, 110, 113, 73, 33, 73, 89, 73, - /* 1060 */ 85, 39, 73, 73, 39, 33, 86, 51, 50, 71, - /* 1070 */ 33, 0, 39, 39, 39, 39, 33, 39, 39, 39, - /* 1080 */ 39, 39, 0, 39, 39, 39, 0, 39, 39, 39, - /* 1090 */ 39, 39, 37, 39, 38, 0, 33, 44, 21, 0, - /* 1100 */ 87, 87, 82, 84, 39, 74, 39, 39, 39, 39, - /* 1110 */ 101, 101, 39, 101, 39, 39, 101, 33, 0, 39, - /* 1120 */ 39, 0, 39, 33, 39, 0, 39, 39, 0, 33, - /* 1130 */ 73, 40, 74, 73, 33, 74, 74, 73, 0, 73, - /* 1140 */ 33, 39, 0, 33, 33, 248, 74, 73, 248, 20, - /* 1150 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1160 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1170 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1180 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1190 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1200 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1210 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1220 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1230 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1240 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1250 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1260 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1270 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1280 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1290 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, - /* 1300 */ 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + /* 160 */ 99, 102, 103, 104, 105, 106, 107, 21, 227, 187, + /* 170 */ 155, 156, 20, 139, 140, 73, 121, 163, 117, 118, + /* 180 */ 34, 240, 200, 119, 120, 244, 122, 123, 124, 125, + /* 190 */ 126, 127, 128, 129, 130, 134, 134, 183, 143, 144, + /* 200 */ 145, 146, 147, 163, 190, 12, 13, 14, 15, 16, + /* 210 */ 196, 169, 169, 4, 200, 163, 174, 174, 20, 205, + /* 220 */ 172, 173, 208, 209, 210, 211, 160, 187, 30, 215, + /* 230 */ 216, 134, 190, 190, 169, 183, 163, 74, 40, 174, + /* 240 */ 200, 227, 190, 45, 169, 47, 181, 20, 196, 49, + /* 250 */ 183, 88, 200, 206, 240, 190, 176, 190, 244, 179, + /* 260 */ 208, 209, 210, 211, 66, 190, 183, 215, 216, 217, + /* 270 */ 223, 205, 189, 200, 76, 77, 209, 194, 163, 166, + /* 280 */ 167, 229, 12, 13, 14, 210, 169, 235, 236, 20, + /* 290 */ 20, 174, 22, 227, 219, 220, 221, 222, 183, 224, + /* 300 */ 175, 169, 14, 15, 16, 190, 240, 190, 183, 39, + /* 310 */ 244, 196, 168, 163, 116, 200, 191, 168, 132, 133, + /* 320 */ 50, 20, 190, 208, 209, 210, 211, 178, 0, 185, + /* 330 */ 215, 216, 217, 183, 185, 12, 13, 14, 15, 16, + /* 340 */ 190, 71, 210, 73, 135, 60, 196, 175, 163, 64, + /* 350 */ 200, 236, 220, 221, 222, 183, 224, 74, 208, 209, + /* 360 */ 210, 211, 175, 191, 134, 215, 216, 217, 183, 99, + /* 370 */ 183, 88, 86, 163, 89, 190, 226, 49, 191, 163, + /* 380 */ 183, 196, 12, 13, 115, 200, 189, 117, 118, 0, + /* 390 */ 20, 194, 22, 208, 209, 210, 211, 74, 169, 183, + /* 400 */ 215, 216, 217, 174, 1, 2, 190, 12, 13, 39, + /* 410 */ 200, 226, 196, 12, 13, 20, 200, 22, 163, 190, + /* 420 */ 50, 20, 196, 22, 208, 209, 210, 211, 202, 206, + /* 430 */ 22, 215, 216, 217, 39, 22, 163, 20, 183, 22, + /* 440 */ 39, 71, 226, 73, 184, 190, 223, 39, 184, 60, + /* 450 */ 183, 196, 39, 64, 163, 200, 163, 0, 41, 119, + /* 460 */ 205, 194, 3, 208, 209, 210, 71, 127, 73, 99, + /* 470 */ 130, 74, 71, 200, 73, 183, 183, 74, 89, 71, + /* 480 */ 73, 44, 227, 190, 163, 88, 194, 117, 118, 196, + /* 490 */ 163, 200, 85, 200, 99, 240, 163, 108, 109, 244, + /* 500 */ 99, 208, 209, 210, 211, 20, 49, 99, 215, 216, + /* 510 */ 183, 169, 117, 118, 12, 13, 14, 190, 117, 118, + /* 520 */ 163, 200, 20, 196, 22, 117, 118, 200, 14, 134, + /* 530 */ 163, 163, 190, 200, 20, 208, 209, 210, 211, 163, + /* 540 */ 163, 39, 215, 216, 163, 12, 13, 205, 158, 159, + /* 550 */ 163, 163, 210, 20, 163, 22, 163, 200, 79, 1, + /* 560 */ 2, 82, 220, 221, 222, 19, 224, 200, 200, 227, + /* 570 */ 133, 183, 39, 71, 163, 73, 200, 200, 190, 33, + /* 580 */ 184, 200, 240, 37, 196, 163, 244, 200, 200, 43, + /* 590 */ 163, 200, 46, 200, 163, 88, 208, 209, 210, 50, + /* 600 */ 115, 99, 163, 33, 71, 88, 73, 37, 206, 150, + /* 610 */ 183, 200, 184, 43, 164, 169, 46, 190, 72, 117, + /* 620 */ 118, 75, 200, 196, 173, 223, 79, 200, 163, 82, + /* 630 */ 247, 200, 99, 245, 246, 208, 209, 210, 211, 200, + /* 640 */ 0, 79, 72, 216, 82, 75, 79, 238, 183, 82, + /* 650 */ 117, 118, 163, 74, 108, 190, 0, 111, 232, 152, + /* 660 */ 114, 196, 22, 163, 18, 200, 0, 88, 203, 23, + /* 670 */ 121, 154, 183, 208, 209, 210, 193, 74, 22, 190, + /* 680 */ 110, 35, 36, 183, 114, 196, 163, 166, 22, 200, + /* 690 */ 190, 88, 203, 73, 48, 207, 196, 208, 209, 210, + /* 700 */ 200, 163, 225, 74, 74, 183, 183, 87, 208, 209, + /* 710 */ 210, 0, 74, 190, 241, 74, 163, 88, 88, 196, + /* 720 */ 228, 183, 204, 200, 169, 20, 88, 20, 190, 88, + /* 730 */ 171, 208, 209, 210, 196, 20, 183, 163, 200, 239, + /* 740 */ 190, 203, 197, 190, 74, 74, 208, 209, 210, 196, + /* 750 */ 20, 171, 163, 200, 169, 171, 203, 183, 88, 88, + /* 760 */ 20, 208, 209, 210, 190, 165, 183, 74, 163, 246, + /* 770 */ 196, 60, 183, 74, 200, 64, 74, 183, 74, 190, + /* 780 */ 134, 88, 208, 209, 210, 196, 169, 88, 183, 200, + /* 790 */ 88, 163, 88, 183, 74, 190, 163, 208, 209, 210, + /* 800 */ 89, 196, 183, 204, 183, 200, 183, 163, 88, 183, + /* 810 */ 183, 183, 163, 208, 209, 210, 183, 183, 190, 108, + /* 820 */ 109, 168, 183, 190, 196, 183, 165, 183, 200, 196, + /* 830 */ 20, 207, 183, 200, 190, 190, 208, 209, 210, 190, + /* 840 */ 196, 208, 209, 210, 200, 196, 237, 163, 197, 200, + /* 850 */ 163, 142, 208, 209, 210, 141, 201, 208, 209, 210, + /* 860 */ 118, 201, 200, 200, 137, 149, 234, 183, 237, 148, + /* 870 */ 183, 136, 133, 190, 190, 20, 233, 190, 231, 206, + /* 880 */ 196, 131, 230, 196, 200, 163, 218, 200, 157, 153, + /* 890 */ 73, 243, 208, 209, 210, 208, 209, 210, 248, 151, + /* 900 */ 163, 242, 214, 112, 201, 183, 200, 190, 200, 168, + /* 910 */ 198, 201, 190, 200, 190, 197, 163, 179, 196, 73, + /* 920 */ 183, 163, 200, 169, 169, 168, 165, 190, 177, 186, + /* 930 */ 208, 209, 210, 196, 170, 161, 183, 200, 0, 177, + /* 940 */ 0, 183, 0, 190, 190, 208, 209, 210, 190, 196, + /* 950 */ 0, 66, 163, 200, 196, 87, 0, 35, 200, 0, + /* 960 */ 0, 208, 209, 210, 210, 0, 208, 209, 210, 0, + /* 970 */ 0, 0, 183, 44, 220, 221, 222, 4, 224, 190, + /* 980 */ 0, 0, 60, 0, 0, 196, 64, 51, 0, 200, + /* 990 */ 0, 39, 19, 44, 37, 0, 0, 208, 209, 210, + /* 1000 */ 78, 0, 80, 81, 0, 83, 33, 84, 82, 22, + /* 1010 */ 37, 89, 0, 39, 39, 42, 39, 39, 39, 46, + /* 1020 */ 0, 52, 22, 54, 39, 39, 57, 0, 39, 60, + /* 1030 */ 22, 62, 40, 0, 65, 22, 39, 0, 22, 0, + /* 1040 */ 22, 20, 0, 0, 0, 72, 115, 44, 75, 73, + /* 1050 */ 88, 2, 88, 110, 138, 88, 74, 138, 39, 132, + /* 1060 */ 88, 12, 13, 14, 15, 16, 2, 74, 74, 4, + /* 1070 */ 138, 73, 73, 39, 39, 73, 12, 13, 14, 15, + /* 1080 */ 16, 74, 73, 2, 74, 74, 39, 39, 0, 39, + /* 1090 */ 39, 0, 87, 0, 88, 249, 74, 44, 74, 74, + /* 1100 */ 39, 87, 73, 88, 87, 73, 39, 39, 39, 39, + /* 1110 */ 74, 88, 121, 87, 73, 39, 85, 22, 73, 73, + /* 1120 */ 22, 22, 39, 39, 86, 73, 37, 87, 74, 73, + /* 1130 */ 73, 39, 74, 73, 44, 50, 74, 74, 51, 73, + /* 1140 */ 110, 113, 87, 39, 73, 39, 74, 73, 39, 39, + /* 1150 */ 39, 39, 73, 73, 39, 73, 22, 71, 39, 39, + /* 1160 */ 101, 39, 39, 39, 39, 39, 39, 89, 39, 39, + /* 1170 */ 38, 0, 0, 22, 101, 21, 101, 22, 101, 22, + /* 1180 */ 21, 20, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1190 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1200 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1210 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1220 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1230 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1240 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1250 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1260 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1270 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1280 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1290 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1300 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1310 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1320 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1330 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, + /* 1340 */ 249, 249, }; -#define YY_SHIFT_COUNT (399) +#define YY_SHIFT_COUNT (413) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1142) +#define YY_SHIFT_MAX (1172) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 710, 61, 219, 394, 394, 394, 394, 423, 394, 394, - /* 10 */ 154, 546, 556, 541, 546, 546, 546, 546, 546, 546, - /* 20 */ 546, 546, 546, 546, 546, 546, 546, 546, 546, 546, - /* 30 */ 546, 546, 546, 13, 13, 13, 70, 62, 62, 102, - /* 40 */ 102, 62, 62, 73, 156, 165, 165, 242, 391, 156, - /* 50 */ 62, 62, 156, 62, 156, 391, 156, 156, 62, 408, - /* 60 */ 1, 64, 64, 80, 308, 102, 102, 145, 102, 102, - /* 70 */ 102, 102, 102, 102, 102, 102, 102, 102, 320, 50, - /* 80 */ 191, 191, 191, 97, 391, 156, 156, 156, 411, 59, - /* 90 */ 59, 59, 59, 59, 18, 604, 15, 871, 896, 433, - /* 100 */ 319, 203, 275, 151, 182, 151, 367, 382, 168, 658, - /* 110 */ 678, 73, 701, 715, 73, 658, 73, 727, 678, 408, - /* 120 */ 701, 715, 743, 629, 632, 657, 629, 632, 657, 642, - /* 130 */ 649, 656, 662, 668, 701, 791, 684, 661, 666, 679, - /* 140 */ 758, 156, 632, 657, 657, 632, 657, 728, 701, 715, - /* 150 */ 411, 408, 773, 658, 408, 727, 701, 156, 156, 156, - /* 160 */ 156, 156, 156, 156, 156, 156, 156, 156, 658, 727, - /* 170 */ 1150, 1150, 1150, 0, 233, 477, 854, 522, 592, 124, - /* 180 */ 309, 352, 103, 103, 103, 103, 103, 103, 103, 180, - /* 190 */ 172, 488, 488, 488, 488, 371, 442, 537, 563, 472, - /* 200 */ 175, 327, 554, 460, 562, 547, 565, 573, 578, 580, - /* 210 */ 583, 608, 620, 625, 626, 628, 390, 504, 536, 624, - /* 220 */ 641, 645, 405, 660, 692, 651, 875, 904, 910, 911, - /* 230 */ 848, 828, 917, 918, 919, 924, 927, 930, 934, 937, - /* 240 */ 938, 897, 940, 892, 944, 947, 912, 913, 909, 954, - /* 250 */ 955, 956, 963, 964, 851, 967, 898, 925, 860, 885, - /* 260 */ 886, 837, 902, 889, 905, 907, 908, 914, 920, 921, - /* 270 */ 946, 895, 899, 923, 931, 859, 928, 932, 922, 866, - /* 280 */ 935, 939, 933, 936, 861, 997, 966, 972, 979, 983, - /* 290 */ 988, 992, 1030, 915, 950, 970, 965, 973, 971, 974, - /* 300 */ 976, 977, 941, 978, 1047, 1008, 943, 982, 975, 984, - /* 310 */ 980, 1023, 969, 986, 989, 990, 1022, 1025, 1032, 1016, - /* 320 */ 1018, 998, 1037, 1033, 1034, 1035, 1036, 1038, 1039, 1040, - /* 330 */ 1043, 1041, 1042, 1044, 1045, 1046, 1048, 1049, 1050, 1051, - /* 340 */ 1071, 1052, 1055, 1053, 1082, 1054, 1056, 1086, 1095, 1063, - /* 350 */ 1077, 1099, 1013, 1014, 1019, 1020, 1031, 1065, 1067, 1057, - /* 360 */ 1058, 1068, 1060, 1061, 1069, 1064, 1062, 1070, 1066, 1072, - /* 370 */ 1073, 1074, 1009, 1010, 1012, 1015, 1075, 1076, 1084, 1118, - /* 380 */ 1080, 1081, 1083, 1085, 1087, 1088, 1121, 1090, 1125, 1096, - /* 390 */ 1091, 1128, 1101, 1102, 1138, 1107, 1142, 1110, 1111, 1129, + /* 0 */ 646, 61, 270, 370, 370, 370, 370, 395, 370, 370, + /* 10 */ 62, 401, 533, 502, 401, 401, 401, 401, 401, 401, + /* 20 */ 401, 401, 401, 401, 401, 401, 401, 401, 401, 401, + /* 30 */ 401, 401, 401, 102, 102, 102, 97, 20, 20, 408, + /* 40 */ 408, 20, 20, 84, 152, 227, 227, 230, 301, 152, + /* 50 */ 20, 20, 152, 20, 152, 301, 152, 152, 20, 200, + /* 60 */ 1, 64, 64, 63, 922, 408, 44, 408, 408, 408, + /* 70 */ 408, 408, 408, 408, 408, 408, 408, 408, 408, 408, + /* 80 */ 408, 408, 408, 408, 408, 408, 408, 417, 328, 269, + /* 90 */ 269, 269, 457, 301, 152, 152, 152, 286, 59, 59, + /* 100 */ 59, 59, 59, 18, 198, 969, 15, 55, 285, 34, + /* 110 */ 413, 485, 186, 437, 186, 514, 459, 209, 705, 707, + /* 120 */ 84, 715, 730, 84, 705, 84, 740, 152, 152, 152, + /* 130 */ 152, 152, 152, 152, 152, 152, 152, 152, 705, 740, + /* 140 */ 707, 200, 715, 730, 810, 709, 714, 742, 709, 714, + /* 150 */ 742, 716, 721, 727, 735, 739, 715, 855, 750, 731, + /* 160 */ 736, 748, 817, 152, 714, 742, 742, 714, 742, 791, + /* 170 */ 715, 730, 286, 200, 715, 846, 705, 200, 740, 1182, + /* 180 */ 1182, 1182, 1182, 0, 112, 546, 570, 973, 1049, 1064, + /* 190 */ 323, 389, 711, 193, 193, 193, 193, 193, 193, 193, + /* 200 */ 403, 340, 288, 288, 288, 288, 479, 547, 562, 567, + /* 210 */ 640, 656, 666, 146, 163, 283, 397, 558, 390, 507, + /* 220 */ 517, 579, 549, 603, 620, 629, 630, 638, 641, 670, + /* 230 */ 671, 693, 699, 702, 704, 720, 407, 938, 940, 942, + /* 240 */ 950, 885, 868, 956, 959, 960, 965, 970, 971, 980, + /* 250 */ 981, 983, 929, 984, 936, 988, 990, 952, 957, 949, + /* 260 */ 995, 996, 1001, 1004, 923, 926, 974, 975, 987, 1012, + /* 270 */ 977, 978, 979, 985, 986, 989, 1020, 1000, 1027, 1008, + /* 280 */ 992, 1033, 1013, 997, 1037, 1016, 1039, 1018, 1021, 1042, + /* 290 */ 1043, 931, 1044, 976, 1003, 943, 962, 964, 916, 982, + /* 300 */ 967, 993, 998, 999, 994, 1002, 1007, 1019, 972, 1005, + /* 310 */ 1009, 1006, 919, 1010, 1011, 1014, 927, 1015, 1017, 1022, + /* 320 */ 1023, 932, 1065, 1034, 1035, 1047, 1048, 1050, 1051, 1081, + /* 330 */ 991, 1026, 1024, 1029, 1032, 1025, 1036, 1041, 1045, 1028, + /* 340 */ 1046, 1088, 1053, 1030, 1052, 1031, 1040, 1055, 1056, 1038, + /* 350 */ 1054, 1061, 1067, 1057, 1058, 1068, 1060, 1062, 1069, 1066, + /* 360 */ 1063, 1070, 1071, 1072, 1076, 1074, 1059, 1073, 1075, 1077, + /* 370 */ 1095, 1078, 1079, 1080, 1082, 1083, 1084, 1098, 1087, 1085, + /* 380 */ 1086, 1099, 1104, 1106, 1109, 1110, 1111, 1112, 1115, 1134, + /* 390 */ 1119, 1120, 1122, 1123, 1124, 1125, 1126, 1129, 1130, 1091, + /* 400 */ 1092, 1089, 1090, 1093, 1127, 1132, 1171, 1172, 1151, 1154, + /* 410 */ 1155, 1157, 1159, 1161, }; -#define YY_REDUCE_COUNT (172) -#define YY_REDUCE_MIN (-220) -#define YY_REDUCE_MAX (826) +#define YY_REDUCE_COUNT (182) +#define YY_REDUCE_MIN (-209) +#define YY_REDUCE_MAX (789) static const short yy_reduce_ofst[] = { - /* 0 */ -155, 14, 52, 115, 150, 185, 214, 112, 269, 291, - /* 10 */ 324, 393, 480, 414, 502, 523, 544, 560, 575, 597, - /* 20 */ 613, 618, 646, 670, 675, 698, 713, 750, 753, 783, - /* 30 */ 805, 821, 826, -76, 298, 306, 46, 57, 75, -162, - /* 40 */ -161, -77, 109, -167, -95, 92, 146, -220, -191, 26, - /* 50 */ 144, 258, -13, 280, 152, -159, 24, 188, 282, 179, - /* 60 */ -203, -203, -203, -140, -109, 72, 241, -4, 271, 283, - /* 70 */ 286, 289, 379, 385, 399, 427, 434, 436, 79, 86, - /* 80 */ 197, 215, 220, 305, -106, -156, 56, 189, 118, -172, - /* 90 */ 325, 348, 356, 368, 329, 392, 347, 398, 334, 410, - /* 100 */ 418, 481, 450, 424, 424, 424, 485, 437, 449, 515, - /* 110 */ 514, 549, 545, 540, 567, 572, 574, 584, 551, 589, - /* 120 */ 561, 569, 566, 530, 585, 579, 552, 587, 581, 557, - /* 130 */ 571, 564, 570, 424, 621, 609, 599, 576, 582, 588, - /* 140 */ 619, 485, 634, 637, 638, 639, 643, 650, 654, 652, - /* 150 */ 671, 683, 677, 688, 693, 687, 674, 685, 686, 690, - /* 160 */ 699, 703, 706, 707, 708, 712, 716, 717, 724, 702, - /* 170 */ 725, 733, 734, + /* 0 */ 66, 14, 52, 115, 150, 185, 216, 255, 293, 327, + /* 10 */ 342, 388, 427, 465, 489, 500, 523, 538, 553, 574, + /* 20 */ 589, 605, 628, 633, 644, 649, 684, 687, 722, 737, + /* 30 */ 753, 758, 789, 75, 132, 754, -59, -149, 65, -18, + /* 40 */ 40, -168, -167, -72, -76, -171, 67, -125, -191, 125, + /* 50 */ 42, 43, 83, 117, 172, -159, 197, 187, 229, 149, + /* 60 */ -209, -209, -209, -138, -172, -129, 48, -128, 73, 210, + /* 70 */ 273, 291, 321, 333, 357, 367, 368, 376, 377, 381, + /* 80 */ 387, 391, 393, 411, 422, 431, 439, 113, -85, 47, + /* 90 */ 223, 402, 144, 226, -86, 267, 292, 80, -175, 260, + /* 100 */ 264, 396, 428, 450, 446, 451, 383, 409, 483, 426, + /* 110 */ 521, 488, 477, 477, 477, 522, 473, 492, 555, 518, + /* 120 */ 559, 550, 545, 580, 585, 584, 600, 583, 594, 610, + /* 130 */ 619, 621, 623, 626, 627, 634, 639, 642, 617, 661, + /* 140 */ 599, 653, 645, 651, 624, 609, 655, 662, 631, 660, + /* 150 */ 663, 632, 643, 647, 652, 477, 683, 673, 668, 650, + /* 160 */ 648, 659, 688, 522, 703, 706, 708, 710, 713, 712, + /* 170 */ 717, 718, 738, 741, 724, 743, 755, 757, 761, 751, + /* 180 */ 762, 764, 774, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 10 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 20 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 30 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 40 */ 913, 913, 913, 959, 913, 913, 913, 913, 913, 913, - /* 50 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 957, - /* 60 */ 913, 1140, 913, 913, 913, 913, 913, 913, 913, 913, - /* 70 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 959, - /* 80 */ 1151, 1151, 1151, 957, 913, 913, 913, 913, 1044, 913, - /* 90 */ 913, 913, 913, 913, 913, 913, 1215, 913, 913, 1175, - /* 100 */ 997, 913, 1167, 1143, 1157, 1144, 913, 1200, 1160, 913, - /* 110 */ 913, 959, 913, 913, 959, 913, 959, 913, 913, 957, - /* 120 */ 913, 913, 913, 1182, 1180, 913, 1182, 1180, 913, 1194, - /* 130 */ 1190, 1173, 1171, 1157, 913, 913, 913, 1218, 1206, 1202, - /* 140 */ 913, 913, 1180, 913, 913, 1180, 913, 1067, 913, 913, - /* 150 */ 913, 957, 1013, 913, 957, 913, 913, 913, 913, 913, - /* 160 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 170 */ 1047, 1047, 960, 913, 913, 913, 913, 913, 913, 913, - /* 180 */ 913, 913, 1112, 1193, 1192, 1111, 1117, 1116, 1115, 913, - /* 190 */ 913, 1106, 1107, 1105, 1104, 913, 913, 913, 1141, 913, - /* 200 */ 1203, 1207, 913, 913, 913, 1091, 913, 913, 913, 913, - /* 210 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 220 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 230 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 240 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 250 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 1164, - /* 260 */ 1174, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 270 */ 913, 913, 1091, 913, 1191, 913, 1150, 1146, 913, 913, - /* 280 */ 1142, 913, 913, 1201, 913, 913, 913, 913, 913, 913, - /* 290 */ 913, 913, 1136, 913, 913, 913, 913, 913, 913, 913, - /* 300 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 310 */ 913, 913, 1019, 913, 913, 913, 913, 913, 913, 913, - /* 320 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 330 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 340 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 350 */ 913, 913, 1090, 913, 913, 913, 913, 913, 913, 1041, - /* 360 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 370 */ 913, 913, 1026, 1024, 1023, 1022, 913, 913, 913, 913, - /* 380 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, - /* 390 */ 913, 913, 913, 913, 913, 913, 913, 913, 913, 913, + /* 0 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 10 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 20 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 30 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 40 */ 947, 947, 947, 1004, 947, 947, 947, 947, 947, 947, + /* 50 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 1002, + /* 60 */ 947, 1185, 947, 947, 947, 947, 947, 947, 947, 947, + /* 70 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 80 */ 947, 947, 947, 947, 947, 947, 947, 947, 1004, 1196, + /* 90 */ 1196, 1196, 1002, 947, 947, 947, 947, 1089, 947, 947, + /* 100 */ 947, 947, 947, 947, 947, 947, 1260, 947, 1042, 1220, + /* 110 */ 947, 1212, 1188, 1202, 1189, 947, 1245, 1205, 947, 947, + /* 120 */ 1004, 947, 947, 1004, 947, 1004, 947, 947, 947, 947, + /* 130 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 140 */ 947, 1002, 947, 947, 947, 1227, 1225, 947, 1227, 1225, + /* 150 */ 947, 1239, 1235, 1218, 1216, 1202, 947, 947, 947, 1263, + /* 160 */ 1251, 1247, 947, 947, 1225, 947, 947, 1225, 947, 1112, + /* 170 */ 947, 947, 947, 1002, 947, 1058, 947, 1002, 947, 1092, + /* 180 */ 1092, 1005, 952, 947, 947, 947, 947, 947, 947, 947, + /* 190 */ 947, 947, 947, 1157, 1238, 1237, 1156, 1162, 1161, 1160, + /* 200 */ 947, 947, 1151, 1152, 1150, 1149, 947, 947, 947, 947, + /* 210 */ 947, 947, 947, 947, 947, 947, 947, 1186, 947, 1248, + /* 220 */ 1252, 947, 947, 947, 1136, 947, 947, 947, 947, 947, + /* 230 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 240 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 250 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 260 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 270 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 280 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 290 */ 947, 947, 947, 947, 947, 947, 1209, 1219, 947, 947, + /* 300 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 1136, + /* 310 */ 947, 1236, 947, 1195, 1191, 947, 947, 1187, 947, 947, + /* 320 */ 1246, 947, 947, 947, 947, 947, 947, 947, 947, 1181, + /* 330 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 340 */ 947, 947, 947, 947, 947, 947, 1135, 947, 947, 947, + /* 350 */ 947, 947, 947, 1086, 947, 947, 947, 947, 947, 947, + /* 360 */ 947, 947, 947, 947, 947, 947, 1071, 1069, 1068, 1067, + /* 370 */ 947, 1064, 947, 947, 947, 947, 947, 947, 947, 947, + /* 380 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 390 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 400 */ 947, 947, 947, 947, 947, 947, 947, 947, 947, 947, + /* 410 */ 947, 947, 947, 947, }; /********** End of lemon-generated parsing tables *****************************/ @@ -692,22 +705,22 @@ static const char *const yyTokenName[] = { /* 15 */ "NK_SLASH", /* 16 */ "NK_REM", /* 17 */ "NK_CONCAT", - /* 18 */ "ALTER", + /* 18 */ "CREATE", /* 19 */ "ACCOUNT", /* 20 */ "NK_ID", /* 21 */ "PASS", - /* 22 */ "PPS", - /* 23 */ "TSERIES", - /* 24 */ "STORAGE", - /* 25 */ "STREAMS", - /* 26 */ "QTIME", - /* 27 */ "DBS", - /* 28 */ "USERS", - /* 29 */ "CONNS", - /* 30 */ "STATE", - /* 31 */ "CREATE", - /* 32 */ "USER", - /* 33 */ "NK_STRING", + /* 22 */ "NK_STRING", + /* 23 */ "ALTER", + /* 24 */ "PPS", + /* 25 */ "TSERIES", + /* 26 */ "STORAGE", + /* 27 */ "STREAMS", + /* 28 */ "QTIME", + /* 29 */ "DBS", + /* 30 */ "USERS", + /* 31 */ "CONNS", + /* 32 */ "STATE", + /* 33 */ "USER", /* 34 */ "PRIVILEGE", /* 35 */ "DROP", /* 36 */ "SHOW", @@ -836,92 +849,93 @@ static const char *const yyTokenName[] = { /* 159 */ "LAST", /* 160 */ "cmd", /* 161 */ "account_options", - /* 162 */ "account_option", + /* 162 */ "alter_account_options", /* 163 */ "literal", - /* 164 */ "user_name", - /* 165 */ "dnode_endpoint", - /* 166 */ "dnode_host_name", - /* 167 */ "not_exists_opt", - /* 168 */ "db_name", - /* 169 */ "db_options", - /* 170 */ "exists_opt", - /* 171 */ "alter_db_options", - /* 172 */ "alter_db_option", - /* 173 */ "full_table_name", - /* 174 */ "column_def_list", - /* 175 */ "tags_def_opt", - /* 176 */ "table_options", - /* 177 */ "multi_create_clause", - /* 178 */ "tags_def", - /* 179 */ "multi_drop_clause", - /* 180 */ "alter_table_clause", - /* 181 */ "alter_table_options", - /* 182 */ "column_name", - /* 183 */ "type_name", - /* 184 */ "create_subtable_clause", - /* 185 */ "specific_tags_opt", - /* 186 */ "literal_list", - /* 187 */ "drop_table_clause", - /* 188 */ "col_name_list", - /* 189 */ "table_name", - /* 190 */ "column_def", - /* 191 */ "func_name_list", - /* 192 */ "alter_table_option", - /* 193 */ "col_name", - /* 194 */ "func_name", - /* 195 */ "function_name", - /* 196 */ "index_name", - /* 197 */ "index_options", - /* 198 */ "func_list", - /* 199 */ "duration_literal", - /* 200 */ "sliding_opt", - /* 201 */ "func", - /* 202 */ "expression_list", - /* 203 */ "topic_name", - /* 204 */ "query_expression", - /* 205 */ "table_alias", - /* 206 */ "column_alias", - /* 207 */ "expression", - /* 208 */ "column_reference", - /* 209 */ "subquery", - /* 210 */ "predicate", - /* 211 */ "compare_op", - /* 212 */ "in_op", - /* 213 */ "in_predicate_value", - /* 214 */ "boolean_value_expression", - /* 215 */ "boolean_primary", - /* 216 */ "common_expression", - /* 217 */ "from_clause", - /* 218 */ "table_reference_list", - /* 219 */ "table_reference", - /* 220 */ "table_primary", - /* 221 */ "joined_table", - /* 222 */ "alias_opt", - /* 223 */ "parenthesized_joined_table", - /* 224 */ "join_type", - /* 225 */ "search_condition", - /* 226 */ "query_specification", - /* 227 */ "set_quantifier_opt", - /* 228 */ "select_list", - /* 229 */ "where_clause_opt", - /* 230 */ "partition_by_clause_opt", - /* 231 */ "twindow_clause_opt", - /* 232 */ "group_by_clause_opt", - /* 233 */ "having_clause_opt", - /* 234 */ "select_sublist", - /* 235 */ "select_item", - /* 236 */ "fill_opt", - /* 237 */ "fill_mode", - /* 238 */ "group_by_list", - /* 239 */ "query_expression_body", - /* 240 */ "order_by_clause_opt", - /* 241 */ "slimit_clause_opt", - /* 242 */ "limit_clause_opt", - /* 243 */ "query_primary", - /* 244 */ "sort_specification_list", - /* 245 */ "sort_specification", - /* 246 */ "ordering_specification_opt", - /* 247 */ "null_ordering_opt", + /* 164 */ "alter_account_option", + /* 165 */ "user_name", + /* 166 */ "dnode_endpoint", + /* 167 */ "dnode_host_name", + /* 168 */ "not_exists_opt", + /* 169 */ "db_name", + /* 170 */ "db_options", + /* 171 */ "exists_opt", + /* 172 */ "alter_db_options", + /* 173 */ "alter_db_option", + /* 174 */ "full_table_name", + /* 175 */ "column_def_list", + /* 176 */ "tags_def_opt", + /* 177 */ "table_options", + /* 178 */ "multi_create_clause", + /* 179 */ "tags_def", + /* 180 */ "multi_drop_clause", + /* 181 */ "alter_table_clause", + /* 182 */ "alter_table_options", + /* 183 */ "column_name", + /* 184 */ "type_name", + /* 185 */ "create_subtable_clause", + /* 186 */ "specific_tags_opt", + /* 187 */ "literal_list", + /* 188 */ "drop_table_clause", + /* 189 */ "col_name_list", + /* 190 */ "table_name", + /* 191 */ "column_def", + /* 192 */ "func_name_list", + /* 193 */ "alter_table_option", + /* 194 */ "col_name", + /* 195 */ "func_name", + /* 196 */ "function_name", + /* 197 */ "index_name", + /* 198 */ "index_options", + /* 199 */ "func_list", + /* 200 */ "duration_literal", + /* 201 */ "sliding_opt", + /* 202 */ "func", + /* 203 */ "expression_list", + /* 204 */ "topic_name", + /* 205 */ "query_expression", + /* 206 */ "table_alias", + /* 207 */ "column_alias", + /* 208 */ "expression", + /* 209 */ "column_reference", + /* 210 */ "subquery", + /* 211 */ "predicate", + /* 212 */ "compare_op", + /* 213 */ "in_op", + /* 214 */ "in_predicate_value", + /* 215 */ "boolean_value_expression", + /* 216 */ "boolean_primary", + /* 217 */ "common_expression", + /* 218 */ "from_clause", + /* 219 */ "table_reference_list", + /* 220 */ "table_reference", + /* 221 */ "table_primary", + /* 222 */ "joined_table", + /* 223 */ "alias_opt", + /* 224 */ "parenthesized_joined_table", + /* 225 */ "join_type", + /* 226 */ "search_condition", + /* 227 */ "query_specification", + /* 228 */ "set_quantifier_opt", + /* 229 */ "select_list", + /* 230 */ "where_clause_opt", + /* 231 */ "partition_by_clause_opt", + /* 232 */ "twindow_clause_opt", + /* 233 */ "group_by_clause_opt", + /* 234 */ "having_clause_opt", + /* 235 */ "select_sublist", + /* 236 */ "select_item", + /* 237 */ "fill_opt", + /* 238 */ "fill_mode", + /* 239 */ "group_by_list", + /* 240 */ "query_expression_body", + /* 241 */ "order_by_clause_opt", + /* 242 */ "slimit_clause_opt", + /* 243 */ "limit_clause_opt", + /* 244 */ "query_primary", + /* 245 */ "sort_specification_list", + /* 246 */ "sort_specification", + /* 247 */ "ordering_specification_opt", + /* 248 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -929,311 +943,322 @@ static const char *const yyTokenName[] = { /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { - /* 0 */ "cmd ::= ALTER ACCOUNT NK_ID account_options", - /* 1 */ "account_options ::= account_option", - /* 2 */ "account_options ::= account_options account_option", - /* 3 */ "account_option ::= PASS literal", - /* 4 */ "account_option ::= PPS literal", - /* 5 */ "account_option ::= TSERIES literal", - /* 6 */ "account_option ::= STORAGE literal", - /* 7 */ "account_option ::= STREAMS literal", - /* 8 */ "account_option ::= QTIME literal", - /* 9 */ "account_option ::= DBS literal", - /* 10 */ "account_option ::= USERS literal", - /* 11 */ "account_option ::= CONNS literal", - /* 12 */ "account_option ::= STATE literal", - /* 13 */ "cmd ::= CREATE USER user_name PASS NK_STRING", - /* 14 */ "cmd ::= ALTER USER user_name PASS NK_STRING", - /* 15 */ "cmd ::= ALTER USER user_name PRIVILEGE NK_STRING", - /* 16 */ "cmd ::= DROP USER user_name", - /* 17 */ "cmd ::= SHOW USERS", - /* 18 */ "cmd ::= CREATE DNODE dnode_endpoint", - /* 19 */ "cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER", - /* 20 */ "cmd ::= DROP DNODE NK_INTEGER", - /* 21 */ "cmd ::= DROP DNODE dnode_endpoint", - /* 22 */ "cmd ::= SHOW DNODES", - /* 23 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", - /* 24 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", - /* 25 */ "cmd ::= ALTER ALL DNODES NK_STRING", - /* 26 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", - /* 27 */ "dnode_endpoint ::= NK_STRING", - /* 28 */ "dnode_host_name ::= NK_ID", - /* 29 */ "dnode_host_name ::= NK_IPTOKEN", - /* 30 */ "cmd ::= ALTER LOCAL NK_STRING", - /* 31 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", - /* 32 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 33 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", - /* 34 */ "cmd ::= SHOW QNODES", - /* 35 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 36 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 37 */ "cmd ::= SHOW DATABASES", - /* 38 */ "cmd ::= USE db_name", - /* 39 */ "cmd ::= ALTER DATABASE db_name alter_db_options", - /* 40 */ "not_exists_opt ::= IF NOT EXISTS", - /* 41 */ "not_exists_opt ::=", - /* 42 */ "exists_opt ::= IF EXISTS", - /* 43 */ "exists_opt ::=", - /* 44 */ "db_options ::=", - /* 45 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 46 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 47 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 48 */ "db_options ::= db_options COMP NK_INTEGER", - /* 49 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 50 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 51 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 52 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 53 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 54 */ "db_options ::= db_options PRECISION NK_STRING", - /* 55 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 56 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 57 */ "db_options ::= db_options TTL NK_INTEGER", - /* 58 */ "db_options ::= db_options WAL NK_INTEGER", - /* 59 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 60 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 61 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 62 */ "db_options ::= db_options RETENTIONS NK_STRING", - /* 63 */ "db_options ::= db_options FILE_FACTOR NK_FLOAT", - /* 64 */ "alter_db_options ::= alter_db_option", - /* 65 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 66 */ "alter_db_option ::= BLOCKS NK_INTEGER", - /* 67 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 68 */ "alter_db_option ::= KEEP NK_INTEGER", - /* 69 */ "alter_db_option ::= WAL NK_INTEGER", - /* 70 */ "alter_db_option ::= QUORUM NK_INTEGER", - /* 71 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 72 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 73 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 74 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 75 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 76 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 77 */ "cmd ::= SHOW TABLES", - /* 78 */ "cmd ::= SHOW STABLES", - /* 79 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 80 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 81 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 82 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 83 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 84 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 85 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 86 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 87 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 88 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 89 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 90 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", - /* 91 */ "multi_create_clause ::= create_subtable_clause", - /* 92 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 93 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 94 */ "multi_drop_clause ::= drop_table_clause", - /* 95 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 96 */ "drop_table_clause ::= exists_opt full_table_name", - /* 97 */ "specific_tags_opt ::=", - /* 98 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 99 */ "full_table_name ::= table_name", - /* 100 */ "full_table_name ::= db_name NK_DOT table_name", - /* 101 */ "column_def_list ::= column_def", - /* 102 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 103 */ "column_def ::= column_name type_name", - /* 104 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 105 */ "type_name ::= BOOL", - /* 106 */ "type_name ::= TINYINT", - /* 107 */ "type_name ::= SMALLINT", - /* 108 */ "type_name ::= INT", - /* 109 */ "type_name ::= INTEGER", - /* 110 */ "type_name ::= BIGINT", - /* 111 */ "type_name ::= FLOAT", - /* 112 */ "type_name ::= DOUBLE", - /* 113 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 114 */ "type_name ::= TIMESTAMP", - /* 115 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 116 */ "type_name ::= TINYINT UNSIGNED", - /* 117 */ "type_name ::= SMALLINT UNSIGNED", - /* 118 */ "type_name ::= INT UNSIGNED", - /* 119 */ "type_name ::= BIGINT UNSIGNED", - /* 120 */ "type_name ::= JSON", - /* 121 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 122 */ "type_name ::= MEDIUMBLOB", - /* 123 */ "type_name ::= BLOB", - /* 124 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 125 */ "type_name ::= DECIMAL", - /* 126 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 127 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 128 */ "tags_def_opt ::=", - /* 129 */ "tags_def_opt ::= tags_def", - /* 130 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 131 */ "table_options ::=", - /* 132 */ "table_options ::= table_options COMMENT NK_STRING", - /* 133 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 134 */ "table_options ::= table_options TTL NK_INTEGER", - /* 135 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 136 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 137 */ "alter_table_options ::= alter_table_option", - /* 138 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 139 */ "alter_table_option ::= COMMENT NK_STRING", - /* 140 */ "alter_table_option ::= KEEP NK_INTEGER", - /* 141 */ "alter_table_option ::= TTL NK_INTEGER", - /* 142 */ "col_name_list ::= col_name", - /* 143 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 144 */ "col_name ::= column_name", - /* 145 */ "func_name_list ::= func_name", - /* 146 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 147 */ "func_name ::= function_name", - /* 148 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 149 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 150 */ "cmd ::= DROP INDEX index_name ON table_name", - /* 151 */ "index_options ::=", - /* 152 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 153 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 154 */ "func_list ::= func", - /* 155 */ "func_list ::= func_list NK_COMMA func", - /* 156 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 157 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 158 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 159 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 160 */ "cmd ::= SHOW VGROUPS", - /* 161 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 162 */ "cmd ::= SHOW MNODES", - /* 163 */ "cmd ::= query_expression", - /* 164 */ "literal ::= NK_INTEGER", - /* 165 */ "literal ::= NK_FLOAT", - /* 166 */ "literal ::= NK_STRING", - /* 167 */ "literal ::= NK_BOOL", - /* 168 */ "literal ::= TIMESTAMP NK_STRING", - /* 169 */ "literal ::= duration_literal", - /* 170 */ "duration_literal ::= NK_VARIABLE", - /* 171 */ "literal_list ::= literal", - /* 172 */ "literal_list ::= literal_list NK_COMMA literal", - /* 173 */ "db_name ::= NK_ID", - /* 174 */ "table_name ::= NK_ID", - /* 175 */ "column_name ::= NK_ID", - /* 176 */ "function_name ::= NK_ID", - /* 177 */ "table_alias ::= NK_ID", - /* 178 */ "column_alias ::= NK_ID", - /* 179 */ "user_name ::= NK_ID", - /* 180 */ "index_name ::= NK_ID", - /* 181 */ "topic_name ::= NK_ID", - /* 182 */ "expression ::= literal", - /* 183 */ "expression ::= column_reference", - /* 184 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 185 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 186 */ "expression ::= subquery", - /* 187 */ "expression ::= NK_LP expression NK_RP", - /* 188 */ "expression ::= NK_PLUS expression", - /* 189 */ "expression ::= NK_MINUS expression", - /* 190 */ "expression ::= expression NK_PLUS expression", - /* 191 */ "expression ::= expression NK_MINUS expression", - /* 192 */ "expression ::= expression NK_STAR expression", - /* 193 */ "expression ::= expression NK_SLASH expression", - /* 194 */ "expression ::= expression NK_REM expression", - /* 195 */ "expression_list ::= expression", - /* 196 */ "expression_list ::= expression_list NK_COMMA expression", - /* 197 */ "column_reference ::= column_name", - /* 198 */ "column_reference ::= table_name NK_DOT column_name", - /* 199 */ "predicate ::= expression compare_op expression", - /* 200 */ "predicate ::= expression BETWEEN expression AND expression", - /* 201 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 202 */ "predicate ::= expression IS NULL", - /* 203 */ "predicate ::= expression IS NOT NULL", - /* 204 */ "predicate ::= expression in_op in_predicate_value", - /* 205 */ "compare_op ::= NK_LT", - /* 206 */ "compare_op ::= NK_GT", - /* 207 */ "compare_op ::= NK_LE", - /* 208 */ "compare_op ::= NK_GE", - /* 209 */ "compare_op ::= NK_NE", - /* 210 */ "compare_op ::= NK_EQ", - /* 211 */ "compare_op ::= LIKE", - /* 212 */ "compare_op ::= NOT LIKE", - /* 213 */ "compare_op ::= MATCH", - /* 214 */ "compare_op ::= NMATCH", - /* 215 */ "in_op ::= IN", - /* 216 */ "in_op ::= NOT IN", - /* 217 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 218 */ "boolean_value_expression ::= boolean_primary", - /* 219 */ "boolean_value_expression ::= NOT boolean_primary", - /* 220 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 221 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 222 */ "boolean_primary ::= predicate", - /* 223 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 224 */ "common_expression ::= expression", - /* 225 */ "common_expression ::= boolean_value_expression", - /* 226 */ "from_clause ::= FROM table_reference_list", - /* 227 */ "table_reference_list ::= table_reference", - /* 228 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 229 */ "table_reference ::= table_primary", - /* 230 */ "table_reference ::= joined_table", - /* 231 */ "table_primary ::= table_name alias_opt", - /* 232 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 233 */ "table_primary ::= subquery alias_opt", - /* 234 */ "table_primary ::= parenthesized_joined_table", - /* 235 */ "alias_opt ::=", - /* 236 */ "alias_opt ::= table_alias", - /* 237 */ "alias_opt ::= AS table_alias", - /* 238 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 239 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 240 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 241 */ "join_type ::=", - /* 242 */ "join_type ::= INNER", - /* 243 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 244 */ "set_quantifier_opt ::=", - /* 245 */ "set_quantifier_opt ::= DISTINCT", - /* 246 */ "set_quantifier_opt ::= ALL", - /* 247 */ "select_list ::= NK_STAR", - /* 248 */ "select_list ::= select_sublist", - /* 249 */ "select_sublist ::= select_item", - /* 250 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 251 */ "select_item ::= common_expression", - /* 252 */ "select_item ::= common_expression column_alias", - /* 253 */ "select_item ::= common_expression AS column_alias", - /* 254 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 255 */ "where_clause_opt ::=", - /* 256 */ "where_clause_opt ::= WHERE search_condition", - /* 257 */ "partition_by_clause_opt ::=", - /* 258 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 259 */ "twindow_clause_opt ::=", - /* 260 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 261 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 262 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 263 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 264 */ "sliding_opt ::=", - /* 265 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 266 */ "fill_opt ::=", - /* 267 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 268 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 269 */ "fill_mode ::= NONE", - /* 270 */ "fill_mode ::= PREV", - /* 271 */ "fill_mode ::= NULL", - /* 272 */ "fill_mode ::= LINEAR", - /* 273 */ "fill_mode ::= NEXT", - /* 274 */ "group_by_clause_opt ::=", - /* 275 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 276 */ "group_by_list ::= expression", - /* 277 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 278 */ "having_clause_opt ::=", - /* 279 */ "having_clause_opt ::= HAVING search_condition", - /* 280 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 281 */ "query_expression_body ::= query_primary", - /* 282 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 283 */ "query_primary ::= query_specification", - /* 284 */ "order_by_clause_opt ::=", - /* 285 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 286 */ "slimit_clause_opt ::=", - /* 287 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 288 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 289 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 290 */ "limit_clause_opt ::=", - /* 291 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 292 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 293 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 294 */ "subquery ::= NK_LP query_expression NK_RP", - /* 295 */ "search_condition ::= common_expression", - /* 296 */ "sort_specification_list ::= sort_specification", - /* 297 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 298 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 299 */ "ordering_specification_opt ::=", - /* 300 */ "ordering_specification_opt ::= ASC", - /* 301 */ "ordering_specification_opt ::= DESC", - /* 302 */ "null_ordering_opt ::=", - /* 303 */ "null_ordering_opt ::= NULLS FIRST", - /* 304 */ "null_ordering_opt ::= NULLS LAST", + /* 0 */ "cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options", + /* 1 */ "cmd ::= ALTER ACCOUNT NK_ID alter_account_options", + /* 2 */ "account_options ::=", + /* 3 */ "account_options ::= account_options PPS literal", + /* 4 */ "account_options ::= account_options TSERIES literal", + /* 5 */ "account_options ::= account_options STORAGE literal", + /* 6 */ "account_options ::= account_options STREAMS literal", + /* 7 */ "account_options ::= account_options QTIME literal", + /* 8 */ "account_options ::= account_options DBS literal", + /* 9 */ "account_options ::= account_options USERS literal", + /* 10 */ "account_options ::= account_options CONNS literal", + /* 11 */ "account_options ::= account_options STATE literal", + /* 12 */ "alter_account_options ::= alter_account_option", + /* 13 */ "alter_account_options ::= alter_account_options alter_account_option", + /* 14 */ "alter_account_option ::= PASS literal", + /* 15 */ "alter_account_option ::= PPS literal", + /* 16 */ "alter_account_option ::= TSERIES literal", + /* 17 */ "alter_account_option ::= STORAGE literal", + /* 18 */ "alter_account_option ::= STREAMS literal", + /* 19 */ "alter_account_option ::= QTIME literal", + /* 20 */ "alter_account_option ::= DBS literal", + /* 21 */ "alter_account_option ::= USERS literal", + /* 22 */ "alter_account_option ::= CONNS literal", + /* 23 */ "alter_account_option ::= STATE literal", + /* 24 */ "cmd ::= CREATE USER user_name PASS NK_STRING", + /* 25 */ "cmd ::= ALTER USER user_name PASS NK_STRING", + /* 26 */ "cmd ::= ALTER USER user_name PRIVILEGE NK_STRING", + /* 27 */ "cmd ::= DROP USER user_name", + /* 28 */ "cmd ::= SHOW USERS", + /* 29 */ "cmd ::= CREATE DNODE dnode_endpoint", + /* 30 */ "cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER", + /* 31 */ "cmd ::= DROP DNODE NK_INTEGER", + /* 32 */ "cmd ::= DROP DNODE dnode_endpoint", + /* 33 */ "cmd ::= SHOW DNODES", + /* 34 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", + /* 35 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", + /* 36 */ "cmd ::= ALTER ALL DNODES NK_STRING", + /* 37 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", + /* 38 */ "dnode_endpoint ::= NK_STRING", + /* 39 */ "dnode_host_name ::= NK_ID", + /* 40 */ "dnode_host_name ::= NK_IPTOKEN", + /* 41 */ "cmd ::= ALTER LOCAL NK_STRING", + /* 42 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", + /* 43 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 44 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 45 */ "cmd ::= SHOW QNODES", + /* 46 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 47 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 48 */ "cmd ::= SHOW DATABASES", + /* 49 */ "cmd ::= USE db_name", + /* 50 */ "cmd ::= ALTER DATABASE db_name alter_db_options", + /* 51 */ "not_exists_opt ::= IF NOT EXISTS", + /* 52 */ "not_exists_opt ::=", + /* 53 */ "exists_opt ::= IF EXISTS", + /* 54 */ "exists_opt ::=", + /* 55 */ "db_options ::=", + /* 56 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 57 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 58 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 59 */ "db_options ::= db_options COMP NK_INTEGER", + /* 60 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 61 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 62 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 63 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 64 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 65 */ "db_options ::= db_options PRECISION NK_STRING", + /* 66 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 67 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 68 */ "db_options ::= db_options TTL NK_INTEGER", + /* 69 */ "db_options ::= db_options WAL NK_INTEGER", + /* 70 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 71 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 72 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 73 */ "db_options ::= db_options RETENTIONS NK_STRING", + /* 74 */ "db_options ::= db_options FILE_FACTOR NK_FLOAT", + /* 75 */ "alter_db_options ::= alter_db_option", + /* 76 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 77 */ "alter_db_option ::= BLOCKS NK_INTEGER", + /* 78 */ "alter_db_option ::= FSYNC NK_INTEGER", + /* 79 */ "alter_db_option ::= KEEP NK_INTEGER", + /* 80 */ "alter_db_option ::= WAL NK_INTEGER", + /* 81 */ "alter_db_option ::= QUORUM NK_INTEGER", + /* 82 */ "alter_db_option ::= CACHELAST NK_INTEGER", + /* 83 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 84 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 85 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 86 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 87 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 88 */ "cmd ::= SHOW TABLES", + /* 89 */ "cmd ::= SHOW STABLES", + /* 90 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 91 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 92 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 93 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 94 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 95 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 96 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 97 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 98 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 99 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 100 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 101 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", + /* 102 */ "multi_create_clause ::= create_subtable_clause", + /* 103 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 104 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 105 */ "multi_drop_clause ::= drop_table_clause", + /* 106 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 107 */ "drop_table_clause ::= exists_opt full_table_name", + /* 108 */ "specific_tags_opt ::=", + /* 109 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 110 */ "full_table_name ::= table_name", + /* 111 */ "full_table_name ::= db_name NK_DOT table_name", + /* 112 */ "column_def_list ::= column_def", + /* 113 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 114 */ "column_def ::= column_name type_name", + /* 115 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 116 */ "type_name ::= BOOL", + /* 117 */ "type_name ::= TINYINT", + /* 118 */ "type_name ::= SMALLINT", + /* 119 */ "type_name ::= INT", + /* 120 */ "type_name ::= INTEGER", + /* 121 */ "type_name ::= BIGINT", + /* 122 */ "type_name ::= FLOAT", + /* 123 */ "type_name ::= DOUBLE", + /* 124 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 125 */ "type_name ::= TIMESTAMP", + /* 126 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 127 */ "type_name ::= TINYINT UNSIGNED", + /* 128 */ "type_name ::= SMALLINT UNSIGNED", + /* 129 */ "type_name ::= INT UNSIGNED", + /* 130 */ "type_name ::= BIGINT UNSIGNED", + /* 131 */ "type_name ::= JSON", + /* 132 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 133 */ "type_name ::= MEDIUMBLOB", + /* 134 */ "type_name ::= BLOB", + /* 135 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 136 */ "type_name ::= DECIMAL", + /* 137 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 138 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 139 */ "tags_def_opt ::=", + /* 140 */ "tags_def_opt ::= tags_def", + /* 141 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 142 */ "table_options ::=", + /* 143 */ "table_options ::= table_options COMMENT NK_STRING", + /* 144 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 145 */ "table_options ::= table_options TTL NK_INTEGER", + /* 146 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 147 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 148 */ "alter_table_options ::= alter_table_option", + /* 149 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 150 */ "alter_table_option ::= COMMENT NK_STRING", + /* 151 */ "alter_table_option ::= KEEP NK_INTEGER", + /* 152 */ "alter_table_option ::= TTL NK_INTEGER", + /* 153 */ "col_name_list ::= col_name", + /* 154 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 155 */ "col_name ::= column_name", + /* 156 */ "func_name_list ::= func_name", + /* 157 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 158 */ "func_name ::= function_name", + /* 159 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 160 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 161 */ "cmd ::= DROP INDEX index_name ON table_name", + /* 162 */ "index_options ::=", + /* 163 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 164 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 165 */ "func_list ::= func", + /* 166 */ "func_list ::= func_list NK_COMMA func", + /* 167 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 168 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 169 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 170 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 171 */ "cmd ::= SHOW VGROUPS", + /* 172 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 173 */ "cmd ::= SHOW MNODES", + /* 174 */ "cmd ::= query_expression", + /* 175 */ "literal ::= NK_INTEGER", + /* 176 */ "literal ::= NK_FLOAT", + /* 177 */ "literal ::= NK_STRING", + /* 178 */ "literal ::= NK_BOOL", + /* 179 */ "literal ::= TIMESTAMP NK_STRING", + /* 180 */ "literal ::= duration_literal", + /* 181 */ "duration_literal ::= NK_VARIABLE", + /* 182 */ "literal_list ::= literal", + /* 183 */ "literal_list ::= literal_list NK_COMMA literal", + /* 184 */ "db_name ::= NK_ID", + /* 185 */ "table_name ::= NK_ID", + /* 186 */ "column_name ::= NK_ID", + /* 187 */ "function_name ::= NK_ID", + /* 188 */ "table_alias ::= NK_ID", + /* 189 */ "column_alias ::= NK_ID", + /* 190 */ "user_name ::= NK_ID", + /* 191 */ "index_name ::= NK_ID", + /* 192 */ "topic_name ::= NK_ID", + /* 193 */ "expression ::= literal", + /* 194 */ "expression ::= column_reference", + /* 195 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 196 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 197 */ "expression ::= subquery", + /* 198 */ "expression ::= NK_LP expression NK_RP", + /* 199 */ "expression ::= NK_PLUS expression", + /* 200 */ "expression ::= NK_MINUS expression", + /* 201 */ "expression ::= expression NK_PLUS expression", + /* 202 */ "expression ::= expression NK_MINUS expression", + /* 203 */ "expression ::= expression NK_STAR expression", + /* 204 */ "expression ::= expression NK_SLASH expression", + /* 205 */ "expression ::= expression NK_REM expression", + /* 206 */ "expression_list ::= expression", + /* 207 */ "expression_list ::= expression_list NK_COMMA expression", + /* 208 */ "column_reference ::= column_name", + /* 209 */ "column_reference ::= table_name NK_DOT column_name", + /* 210 */ "predicate ::= expression compare_op expression", + /* 211 */ "predicate ::= expression BETWEEN expression AND expression", + /* 212 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 213 */ "predicate ::= expression IS NULL", + /* 214 */ "predicate ::= expression IS NOT NULL", + /* 215 */ "predicate ::= expression in_op in_predicate_value", + /* 216 */ "compare_op ::= NK_LT", + /* 217 */ "compare_op ::= NK_GT", + /* 218 */ "compare_op ::= NK_LE", + /* 219 */ "compare_op ::= NK_GE", + /* 220 */ "compare_op ::= NK_NE", + /* 221 */ "compare_op ::= NK_EQ", + /* 222 */ "compare_op ::= LIKE", + /* 223 */ "compare_op ::= NOT LIKE", + /* 224 */ "compare_op ::= MATCH", + /* 225 */ "compare_op ::= NMATCH", + /* 226 */ "in_op ::= IN", + /* 227 */ "in_op ::= NOT IN", + /* 228 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 229 */ "boolean_value_expression ::= boolean_primary", + /* 230 */ "boolean_value_expression ::= NOT boolean_primary", + /* 231 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 232 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 233 */ "boolean_primary ::= predicate", + /* 234 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 235 */ "common_expression ::= expression", + /* 236 */ "common_expression ::= boolean_value_expression", + /* 237 */ "from_clause ::= FROM table_reference_list", + /* 238 */ "table_reference_list ::= table_reference", + /* 239 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 240 */ "table_reference ::= table_primary", + /* 241 */ "table_reference ::= joined_table", + /* 242 */ "table_primary ::= table_name alias_opt", + /* 243 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 244 */ "table_primary ::= subquery alias_opt", + /* 245 */ "table_primary ::= parenthesized_joined_table", + /* 246 */ "alias_opt ::=", + /* 247 */ "alias_opt ::= table_alias", + /* 248 */ "alias_opt ::= AS table_alias", + /* 249 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 250 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 251 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 252 */ "join_type ::=", + /* 253 */ "join_type ::= INNER", + /* 254 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 255 */ "set_quantifier_opt ::=", + /* 256 */ "set_quantifier_opt ::= DISTINCT", + /* 257 */ "set_quantifier_opt ::= ALL", + /* 258 */ "select_list ::= NK_STAR", + /* 259 */ "select_list ::= select_sublist", + /* 260 */ "select_sublist ::= select_item", + /* 261 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 262 */ "select_item ::= common_expression", + /* 263 */ "select_item ::= common_expression column_alias", + /* 264 */ "select_item ::= common_expression AS column_alias", + /* 265 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 266 */ "where_clause_opt ::=", + /* 267 */ "where_clause_opt ::= WHERE search_condition", + /* 268 */ "partition_by_clause_opt ::=", + /* 269 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 270 */ "twindow_clause_opt ::=", + /* 271 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 272 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 273 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 274 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 275 */ "sliding_opt ::=", + /* 276 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 277 */ "fill_opt ::=", + /* 278 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 279 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 280 */ "fill_mode ::= NONE", + /* 281 */ "fill_mode ::= PREV", + /* 282 */ "fill_mode ::= NULL", + /* 283 */ "fill_mode ::= LINEAR", + /* 284 */ "fill_mode ::= NEXT", + /* 285 */ "group_by_clause_opt ::=", + /* 286 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 287 */ "group_by_list ::= expression", + /* 288 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 289 */ "having_clause_opt ::=", + /* 290 */ "having_clause_opt ::= HAVING search_condition", + /* 291 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 292 */ "query_expression_body ::= query_primary", + /* 293 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 294 */ "query_primary ::= query_specification", + /* 295 */ "order_by_clause_opt ::=", + /* 296 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 297 */ "slimit_clause_opt ::=", + /* 298 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 299 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 300 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 301 */ "limit_clause_opt ::=", + /* 302 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 303 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 304 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 305 */ "subquery ::= NK_LP query_expression NK_RP", + /* 306 */ "search_condition ::= common_expression", + /* 307 */ "sort_specification_list ::= sort_specification", + /* 308 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 309 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 310 */ "ordering_specification_opt ::=", + /* 311 */ "ordering_specification_opt ::= ASC", + /* 312 */ "ordering_specification_opt ::= DESC", + /* 313 */ "null_ordering_opt ::=", + /* 314 */ "null_ordering_opt ::= NULLS FIRST", + /* 315 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1362,136 +1387,137 @@ static void yy_destructor( /* Default NON-TERMINAL Destructor */ case 160: /* cmd */ case 163: /* literal */ - case 169: /* db_options */ - case 171: /* alter_db_options */ - case 173: /* full_table_name */ - case 176: /* table_options */ - case 180: /* alter_table_clause */ - case 181: /* alter_table_options */ - case 184: /* create_subtable_clause */ - case 187: /* drop_table_clause */ - case 190: /* column_def */ - case 193: /* col_name */ - case 194: /* func_name */ - case 197: /* index_options */ - case 199: /* duration_literal */ - case 200: /* sliding_opt */ - case 201: /* func */ - case 204: /* query_expression */ - case 207: /* expression */ - case 208: /* column_reference */ - case 209: /* subquery */ - case 210: /* predicate */ - case 213: /* in_predicate_value */ - case 214: /* boolean_value_expression */ - case 215: /* boolean_primary */ - case 216: /* common_expression */ - case 217: /* from_clause */ - case 218: /* table_reference_list */ - case 219: /* table_reference */ - case 220: /* table_primary */ - case 221: /* joined_table */ - case 223: /* parenthesized_joined_table */ - case 225: /* search_condition */ - case 226: /* query_specification */ - case 229: /* where_clause_opt */ - case 231: /* twindow_clause_opt */ - case 233: /* having_clause_opt */ - case 235: /* select_item */ - case 236: /* fill_opt */ - case 239: /* query_expression_body */ - case 241: /* slimit_clause_opt */ - case 242: /* limit_clause_opt */ - case 243: /* query_primary */ - case 245: /* sort_specification */ + case 170: /* db_options */ + case 172: /* alter_db_options */ + case 174: /* full_table_name */ + case 177: /* table_options */ + case 181: /* alter_table_clause */ + case 182: /* alter_table_options */ + case 185: /* create_subtable_clause */ + case 188: /* drop_table_clause */ + case 191: /* column_def */ + case 194: /* col_name */ + case 195: /* func_name */ + case 198: /* index_options */ + case 200: /* duration_literal */ + case 201: /* sliding_opt */ + case 202: /* func */ + case 205: /* query_expression */ + case 208: /* expression */ + case 209: /* column_reference */ + case 210: /* subquery */ + case 211: /* predicate */ + case 214: /* in_predicate_value */ + case 215: /* boolean_value_expression */ + case 216: /* boolean_primary */ + case 217: /* common_expression */ + case 218: /* from_clause */ + case 219: /* table_reference_list */ + case 220: /* table_reference */ + case 221: /* table_primary */ + case 222: /* joined_table */ + case 224: /* parenthesized_joined_table */ + case 226: /* search_condition */ + case 227: /* query_specification */ + case 230: /* where_clause_opt */ + case 232: /* twindow_clause_opt */ + case 234: /* having_clause_opt */ + case 236: /* select_item */ + case 237: /* fill_opt */ + case 240: /* query_expression_body */ + case 242: /* slimit_clause_opt */ + case 243: /* limit_clause_opt */ + case 244: /* query_primary */ + case 246: /* sort_specification */ { - nodesDestroyNode((yypminor->yy168)); + nodesDestroyNode((yypminor->yy26)); } break; case 161: /* account_options */ - case 162: /* account_option */ + case 162: /* alter_account_options */ + case 164: /* alter_account_option */ { } break; - case 164: /* user_name */ - case 165: /* dnode_endpoint */ - case 166: /* dnode_host_name */ - case 168: /* db_name */ - case 182: /* column_name */ - case 189: /* table_name */ - case 195: /* function_name */ - case 196: /* index_name */ - case 203: /* topic_name */ - case 205: /* table_alias */ - case 206: /* column_alias */ - case 222: /* alias_opt */ + case 165: /* user_name */ + case 166: /* dnode_endpoint */ + case 167: /* dnode_host_name */ + case 169: /* db_name */ + case 183: /* column_name */ + case 190: /* table_name */ + case 196: /* function_name */ + case 197: /* index_name */ + case 204: /* topic_name */ + case 206: /* table_alias */ + case 207: /* column_alias */ + case 223: /* alias_opt */ { } break; - case 167: /* not_exists_opt */ - case 170: /* exists_opt */ - case 227: /* set_quantifier_opt */ + case 168: /* not_exists_opt */ + case 171: /* exists_opt */ + case 228: /* set_quantifier_opt */ { } break; - case 172: /* alter_db_option */ - case 192: /* alter_table_option */ + case 173: /* alter_db_option */ + case 193: /* alter_table_option */ { } break; - case 174: /* column_def_list */ - case 175: /* tags_def_opt */ - case 177: /* multi_create_clause */ - case 178: /* tags_def */ - case 179: /* multi_drop_clause */ - case 185: /* specific_tags_opt */ - case 186: /* literal_list */ - case 188: /* col_name_list */ - case 191: /* func_name_list */ - case 198: /* func_list */ - case 202: /* expression_list */ - case 228: /* select_list */ - case 230: /* partition_by_clause_opt */ - case 232: /* group_by_clause_opt */ - case 234: /* select_sublist */ - case 238: /* group_by_list */ - case 240: /* order_by_clause_opt */ - case 244: /* sort_specification_list */ + case 175: /* column_def_list */ + case 176: /* tags_def_opt */ + case 178: /* multi_create_clause */ + case 179: /* tags_def */ + case 180: /* multi_drop_clause */ + case 186: /* specific_tags_opt */ + case 187: /* literal_list */ + case 189: /* col_name_list */ + case 192: /* func_name_list */ + case 199: /* func_list */ + case 203: /* expression_list */ + case 229: /* select_list */ + case 231: /* partition_by_clause_opt */ + case 233: /* group_by_clause_opt */ + case 235: /* select_sublist */ + case 239: /* group_by_list */ + case 241: /* order_by_clause_opt */ + case 245: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy440)); + nodesDestroyList((yypminor->yy64)); } break; - case 183: /* type_name */ + case 184: /* type_name */ { } break; - case 211: /* compare_op */ - case 212: /* in_op */ + case 212: /* compare_op */ + case 213: /* in_op */ { } break; - case 224: /* join_type */ + case 225: /* join_type */ { } break; - case 237: /* fill_mode */ + case 238: /* fill_mode */ { } break; - case 246: /* ordering_specification_opt */ + case 247: /* ordering_specification_opt */ { } break; - case 247: /* null_ordering_opt */ + case 248: /* null_ordering_opt */ { } @@ -1790,311 +1816,322 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 160, -4 }, /* (0) cmd ::= ALTER ACCOUNT NK_ID account_options */ - { 161, -1 }, /* (1) account_options ::= account_option */ - { 161, -2 }, /* (2) account_options ::= account_options account_option */ - { 162, -2 }, /* (3) account_option ::= PASS literal */ - { 162, -2 }, /* (4) account_option ::= PPS literal */ - { 162, -2 }, /* (5) account_option ::= TSERIES literal */ - { 162, -2 }, /* (6) account_option ::= STORAGE literal */ - { 162, -2 }, /* (7) account_option ::= STREAMS literal */ - { 162, -2 }, /* (8) account_option ::= QTIME literal */ - { 162, -2 }, /* (9) account_option ::= DBS literal */ - { 162, -2 }, /* (10) account_option ::= USERS literal */ - { 162, -2 }, /* (11) account_option ::= CONNS literal */ - { 162, -2 }, /* (12) account_option ::= STATE literal */ - { 160, -5 }, /* (13) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 160, -5 }, /* (14) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 160, -5 }, /* (15) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 160, -3 }, /* (16) cmd ::= DROP USER user_name */ - { 160, -2 }, /* (17) cmd ::= SHOW USERS */ - { 160, -3 }, /* (18) cmd ::= CREATE DNODE dnode_endpoint */ - { 160, -5 }, /* (19) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 160, -3 }, /* (20) cmd ::= DROP DNODE NK_INTEGER */ - { 160, -3 }, /* (21) cmd ::= DROP DNODE dnode_endpoint */ - { 160, -2 }, /* (22) cmd ::= SHOW DNODES */ - { 160, -4 }, /* (23) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 160, -5 }, /* (24) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 160, -4 }, /* (25) cmd ::= ALTER ALL DNODES NK_STRING */ - { 160, -5 }, /* (26) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 165, -1 }, /* (27) dnode_endpoint ::= NK_STRING */ - { 166, -1 }, /* (28) dnode_host_name ::= NK_ID */ - { 166, -1 }, /* (29) dnode_host_name ::= NK_IPTOKEN */ - { 160, -3 }, /* (30) cmd ::= ALTER LOCAL NK_STRING */ - { 160, -4 }, /* (31) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 160, -5 }, /* (32) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 160, -5 }, /* (33) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 160, -2 }, /* (34) cmd ::= SHOW QNODES */ - { 160, -5 }, /* (35) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 160, -4 }, /* (36) cmd ::= DROP DATABASE exists_opt db_name */ - { 160, -2 }, /* (37) cmd ::= SHOW DATABASES */ - { 160, -2 }, /* (38) cmd ::= USE db_name */ - { 160, -4 }, /* (39) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 167, -3 }, /* (40) not_exists_opt ::= IF NOT EXISTS */ - { 167, 0 }, /* (41) not_exists_opt ::= */ - { 170, -2 }, /* (42) exists_opt ::= IF EXISTS */ - { 170, 0 }, /* (43) exists_opt ::= */ - { 169, 0 }, /* (44) db_options ::= */ - { 169, -3 }, /* (45) db_options ::= db_options BLOCKS NK_INTEGER */ - { 169, -3 }, /* (46) db_options ::= db_options CACHE NK_INTEGER */ - { 169, -3 }, /* (47) db_options ::= db_options CACHELAST NK_INTEGER */ - { 169, -3 }, /* (48) db_options ::= db_options COMP NK_INTEGER */ - { 169, -3 }, /* (49) db_options ::= db_options DAYS NK_INTEGER */ - { 169, -3 }, /* (50) db_options ::= db_options FSYNC NK_INTEGER */ - { 169, -3 }, /* (51) db_options ::= db_options MAXROWS NK_INTEGER */ - { 169, -3 }, /* (52) db_options ::= db_options MINROWS NK_INTEGER */ - { 169, -3 }, /* (53) db_options ::= db_options KEEP NK_INTEGER */ - { 169, -3 }, /* (54) db_options ::= db_options PRECISION NK_STRING */ - { 169, -3 }, /* (55) db_options ::= db_options QUORUM NK_INTEGER */ - { 169, -3 }, /* (56) db_options ::= db_options REPLICA NK_INTEGER */ - { 169, -3 }, /* (57) db_options ::= db_options TTL NK_INTEGER */ - { 169, -3 }, /* (58) db_options ::= db_options WAL NK_INTEGER */ - { 169, -3 }, /* (59) db_options ::= db_options VGROUPS NK_INTEGER */ - { 169, -3 }, /* (60) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 169, -3 }, /* (61) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 169, -3 }, /* (62) db_options ::= db_options RETENTIONS NK_STRING */ - { 169, -3 }, /* (63) db_options ::= db_options FILE_FACTOR NK_FLOAT */ - { 171, -1 }, /* (64) alter_db_options ::= alter_db_option */ - { 171, -2 }, /* (65) alter_db_options ::= alter_db_options alter_db_option */ - { 172, -2 }, /* (66) alter_db_option ::= BLOCKS NK_INTEGER */ - { 172, -2 }, /* (67) alter_db_option ::= FSYNC NK_INTEGER */ - { 172, -2 }, /* (68) alter_db_option ::= KEEP NK_INTEGER */ - { 172, -2 }, /* (69) alter_db_option ::= WAL NK_INTEGER */ - { 172, -2 }, /* (70) alter_db_option ::= QUORUM NK_INTEGER */ - { 172, -2 }, /* (71) alter_db_option ::= CACHELAST NK_INTEGER */ - { 160, -9 }, /* (72) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 160, -3 }, /* (73) cmd ::= CREATE TABLE multi_create_clause */ - { 160, -9 }, /* (74) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 160, -3 }, /* (75) cmd ::= DROP TABLE multi_drop_clause */ - { 160, -4 }, /* (76) cmd ::= DROP STABLE exists_opt full_table_name */ - { 160, -2 }, /* (77) cmd ::= SHOW TABLES */ - { 160, -2 }, /* (78) cmd ::= SHOW STABLES */ - { 160, -3 }, /* (79) cmd ::= ALTER TABLE alter_table_clause */ - { 160, -3 }, /* (80) cmd ::= ALTER STABLE alter_table_clause */ - { 180, -2 }, /* (81) alter_table_clause ::= full_table_name alter_table_options */ - { 180, -5 }, /* (82) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 180, -4 }, /* (83) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 180, -5 }, /* (84) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 180, -5 }, /* (85) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 180, -5 }, /* (86) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 180, -4 }, /* (87) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 180, -5 }, /* (88) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 180, -5 }, /* (89) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 180, -6 }, /* (90) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - { 177, -1 }, /* (91) multi_create_clause ::= create_subtable_clause */ - { 177, -2 }, /* (92) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 184, -9 }, /* (93) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 179, -1 }, /* (94) multi_drop_clause ::= drop_table_clause */ - { 179, -2 }, /* (95) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 187, -2 }, /* (96) drop_table_clause ::= exists_opt full_table_name */ - { 185, 0 }, /* (97) specific_tags_opt ::= */ - { 185, -3 }, /* (98) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 173, -1 }, /* (99) full_table_name ::= table_name */ - { 173, -3 }, /* (100) full_table_name ::= db_name NK_DOT table_name */ - { 174, -1 }, /* (101) column_def_list ::= column_def */ - { 174, -3 }, /* (102) column_def_list ::= column_def_list NK_COMMA column_def */ - { 190, -2 }, /* (103) column_def ::= column_name type_name */ - { 190, -4 }, /* (104) column_def ::= column_name type_name COMMENT NK_STRING */ - { 183, -1 }, /* (105) type_name ::= BOOL */ - { 183, -1 }, /* (106) type_name ::= TINYINT */ - { 183, -1 }, /* (107) type_name ::= SMALLINT */ - { 183, -1 }, /* (108) type_name ::= INT */ - { 183, -1 }, /* (109) type_name ::= INTEGER */ - { 183, -1 }, /* (110) type_name ::= BIGINT */ - { 183, -1 }, /* (111) type_name ::= FLOAT */ - { 183, -1 }, /* (112) type_name ::= DOUBLE */ - { 183, -4 }, /* (113) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 183, -1 }, /* (114) type_name ::= TIMESTAMP */ - { 183, -4 }, /* (115) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 183, -2 }, /* (116) type_name ::= TINYINT UNSIGNED */ - { 183, -2 }, /* (117) type_name ::= SMALLINT UNSIGNED */ - { 183, -2 }, /* (118) type_name ::= INT UNSIGNED */ - { 183, -2 }, /* (119) type_name ::= BIGINT UNSIGNED */ - { 183, -1 }, /* (120) type_name ::= JSON */ - { 183, -4 }, /* (121) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 183, -1 }, /* (122) type_name ::= MEDIUMBLOB */ - { 183, -1 }, /* (123) type_name ::= BLOB */ - { 183, -4 }, /* (124) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 183, -1 }, /* (125) type_name ::= DECIMAL */ - { 183, -4 }, /* (126) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 183, -6 }, /* (127) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 175, 0 }, /* (128) tags_def_opt ::= */ - { 175, -1 }, /* (129) tags_def_opt ::= tags_def */ - { 178, -4 }, /* (130) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 176, 0 }, /* (131) table_options ::= */ - { 176, -3 }, /* (132) table_options ::= table_options COMMENT NK_STRING */ - { 176, -3 }, /* (133) table_options ::= table_options KEEP NK_INTEGER */ - { 176, -3 }, /* (134) table_options ::= table_options TTL NK_INTEGER */ - { 176, -5 }, /* (135) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 176, -5 }, /* (136) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 181, -1 }, /* (137) alter_table_options ::= alter_table_option */ - { 181, -2 }, /* (138) alter_table_options ::= alter_table_options alter_table_option */ - { 192, -2 }, /* (139) alter_table_option ::= COMMENT NK_STRING */ - { 192, -2 }, /* (140) alter_table_option ::= KEEP NK_INTEGER */ - { 192, -2 }, /* (141) alter_table_option ::= TTL NK_INTEGER */ - { 188, -1 }, /* (142) col_name_list ::= col_name */ - { 188, -3 }, /* (143) col_name_list ::= col_name_list NK_COMMA col_name */ - { 193, -1 }, /* (144) col_name ::= column_name */ - { 191, -1 }, /* (145) func_name_list ::= func_name */ - { 191, -3 }, /* (146) func_name_list ::= func_name_list NK_COMMA col_name */ - { 194, -1 }, /* (147) func_name ::= function_name */ - { 160, -7 }, /* (148) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 160, -9 }, /* (149) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 160, -5 }, /* (150) cmd ::= DROP INDEX index_name ON table_name */ - { 197, 0 }, /* (151) index_options ::= */ - { 197, -9 }, /* (152) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 197, -11 }, /* (153) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 198, -1 }, /* (154) func_list ::= func */ - { 198, -3 }, /* (155) func_list ::= func_list NK_COMMA func */ - { 201, -4 }, /* (156) func ::= function_name NK_LP expression_list NK_RP */ - { 160, -6 }, /* (157) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 160, -6 }, /* (158) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 160, -4 }, /* (159) cmd ::= DROP TOPIC exists_opt topic_name */ - { 160, -2 }, /* (160) cmd ::= SHOW VGROUPS */ - { 160, -4 }, /* (161) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 160, -2 }, /* (162) cmd ::= SHOW MNODES */ - { 160, -1 }, /* (163) cmd ::= query_expression */ - { 163, -1 }, /* (164) literal ::= NK_INTEGER */ - { 163, -1 }, /* (165) literal ::= NK_FLOAT */ - { 163, -1 }, /* (166) literal ::= NK_STRING */ - { 163, -1 }, /* (167) literal ::= NK_BOOL */ - { 163, -2 }, /* (168) literal ::= TIMESTAMP NK_STRING */ - { 163, -1 }, /* (169) literal ::= duration_literal */ - { 199, -1 }, /* (170) duration_literal ::= NK_VARIABLE */ - { 186, -1 }, /* (171) literal_list ::= literal */ - { 186, -3 }, /* (172) literal_list ::= literal_list NK_COMMA literal */ - { 168, -1 }, /* (173) db_name ::= NK_ID */ - { 189, -1 }, /* (174) table_name ::= NK_ID */ - { 182, -1 }, /* (175) column_name ::= NK_ID */ - { 195, -1 }, /* (176) function_name ::= NK_ID */ - { 205, -1 }, /* (177) table_alias ::= NK_ID */ - { 206, -1 }, /* (178) column_alias ::= NK_ID */ - { 164, -1 }, /* (179) user_name ::= NK_ID */ - { 196, -1 }, /* (180) index_name ::= NK_ID */ - { 203, -1 }, /* (181) topic_name ::= NK_ID */ - { 207, -1 }, /* (182) expression ::= literal */ - { 207, -1 }, /* (183) expression ::= column_reference */ - { 207, -4 }, /* (184) expression ::= function_name NK_LP expression_list NK_RP */ - { 207, -4 }, /* (185) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 207, -1 }, /* (186) expression ::= subquery */ - { 207, -3 }, /* (187) expression ::= NK_LP expression NK_RP */ - { 207, -2 }, /* (188) expression ::= NK_PLUS expression */ - { 207, -2 }, /* (189) expression ::= NK_MINUS expression */ - { 207, -3 }, /* (190) expression ::= expression NK_PLUS expression */ - { 207, -3 }, /* (191) expression ::= expression NK_MINUS expression */ - { 207, -3 }, /* (192) expression ::= expression NK_STAR expression */ - { 207, -3 }, /* (193) expression ::= expression NK_SLASH expression */ - { 207, -3 }, /* (194) expression ::= expression NK_REM expression */ - { 202, -1 }, /* (195) expression_list ::= expression */ - { 202, -3 }, /* (196) expression_list ::= expression_list NK_COMMA expression */ - { 208, -1 }, /* (197) column_reference ::= column_name */ - { 208, -3 }, /* (198) column_reference ::= table_name NK_DOT column_name */ - { 210, -3 }, /* (199) predicate ::= expression compare_op expression */ - { 210, -5 }, /* (200) predicate ::= expression BETWEEN expression AND expression */ - { 210, -6 }, /* (201) predicate ::= expression NOT BETWEEN expression AND expression */ - { 210, -3 }, /* (202) predicate ::= expression IS NULL */ - { 210, -4 }, /* (203) predicate ::= expression IS NOT NULL */ - { 210, -3 }, /* (204) predicate ::= expression in_op in_predicate_value */ - { 211, -1 }, /* (205) compare_op ::= NK_LT */ - { 211, -1 }, /* (206) compare_op ::= NK_GT */ - { 211, -1 }, /* (207) compare_op ::= NK_LE */ - { 211, -1 }, /* (208) compare_op ::= NK_GE */ - { 211, -1 }, /* (209) compare_op ::= NK_NE */ - { 211, -1 }, /* (210) compare_op ::= NK_EQ */ - { 211, -1 }, /* (211) compare_op ::= LIKE */ - { 211, -2 }, /* (212) compare_op ::= NOT LIKE */ - { 211, -1 }, /* (213) compare_op ::= MATCH */ - { 211, -1 }, /* (214) compare_op ::= NMATCH */ - { 212, -1 }, /* (215) in_op ::= IN */ - { 212, -2 }, /* (216) in_op ::= NOT IN */ - { 213, -3 }, /* (217) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 214, -1 }, /* (218) boolean_value_expression ::= boolean_primary */ - { 214, -2 }, /* (219) boolean_value_expression ::= NOT boolean_primary */ - { 214, -3 }, /* (220) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 214, -3 }, /* (221) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 215, -1 }, /* (222) boolean_primary ::= predicate */ - { 215, -3 }, /* (223) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 216, -1 }, /* (224) common_expression ::= expression */ - { 216, -1 }, /* (225) common_expression ::= boolean_value_expression */ - { 217, -2 }, /* (226) from_clause ::= FROM table_reference_list */ - { 218, -1 }, /* (227) table_reference_list ::= table_reference */ - { 218, -3 }, /* (228) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 219, -1 }, /* (229) table_reference ::= table_primary */ - { 219, -1 }, /* (230) table_reference ::= joined_table */ - { 220, -2 }, /* (231) table_primary ::= table_name alias_opt */ - { 220, -4 }, /* (232) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 220, -2 }, /* (233) table_primary ::= subquery alias_opt */ - { 220, -1 }, /* (234) table_primary ::= parenthesized_joined_table */ - { 222, 0 }, /* (235) alias_opt ::= */ - { 222, -1 }, /* (236) alias_opt ::= table_alias */ - { 222, -2 }, /* (237) alias_opt ::= AS table_alias */ - { 223, -3 }, /* (238) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 223, -3 }, /* (239) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 221, -6 }, /* (240) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 224, 0 }, /* (241) join_type ::= */ - { 224, -1 }, /* (242) join_type ::= INNER */ - { 226, -9 }, /* (243) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 227, 0 }, /* (244) set_quantifier_opt ::= */ - { 227, -1 }, /* (245) set_quantifier_opt ::= DISTINCT */ - { 227, -1 }, /* (246) set_quantifier_opt ::= ALL */ - { 228, -1 }, /* (247) select_list ::= NK_STAR */ - { 228, -1 }, /* (248) select_list ::= select_sublist */ - { 234, -1 }, /* (249) select_sublist ::= select_item */ - { 234, -3 }, /* (250) select_sublist ::= select_sublist NK_COMMA select_item */ - { 235, -1 }, /* (251) select_item ::= common_expression */ - { 235, -2 }, /* (252) select_item ::= common_expression column_alias */ - { 235, -3 }, /* (253) select_item ::= common_expression AS column_alias */ - { 235, -3 }, /* (254) select_item ::= table_name NK_DOT NK_STAR */ - { 229, 0 }, /* (255) where_clause_opt ::= */ - { 229, -2 }, /* (256) where_clause_opt ::= WHERE search_condition */ - { 230, 0 }, /* (257) partition_by_clause_opt ::= */ - { 230, -3 }, /* (258) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 231, 0 }, /* (259) twindow_clause_opt ::= */ - { 231, -6 }, /* (260) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 231, -4 }, /* (261) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 231, -6 }, /* (262) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 231, -8 }, /* (263) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 200, 0 }, /* (264) sliding_opt ::= */ - { 200, -4 }, /* (265) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 236, 0 }, /* (266) fill_opt ::= */ - { 236, -4 }, /* (267) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 236, -6 }, /* (268) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 237, -1 }, /* (269) fill_mode ::= NONE */ - { 237, -1 }, /* (270) fill_mode ::= PREV */ - { 237, -1 }, /* (271) fill_mode ::= NULL */ - { 237, -1 }, /* (272) fill_mode ::= LINEAR */ - { 237, -1 }, /* (273) fill_mode ::= NEXT */ - { 232, 0 }, /* (274) group_by_clause_opt ::= */ - { 232, -3 }, /* (275) group_by_clause_opt ::= GROUP BY group_by_list */ - { 238, -1 }, /* (276) group_by_list ::= expression */ - { 238, -3 }, /* (277) group_by_list ::= group_by_list NK_COMMA expression */ - { 233, 0 }, /* (278) having_clause_opt ::= */ - { 233, -2 }, /* (279) having_clause_opt ::= HAVING search_condition */ - { 204, -4 }, /* (280) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 239, -1 }, /* (281) query_expression_body ::= query_primary */ - { 239, -4 }, /* (282) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 243, -1 }, /* (283) query_primary ::= query_specification */ - { 240, 0 }, /* (284) order_by_clause_opt ::= */ - { 240, -3 }, /* (285) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 241, 0 }, /* (286) slimit_clause_opt ::= */ - { 241, -2 }, /* (287) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 241, -4 }, /* (288) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 241, -4 }, /* (289) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 242, 0 }, /* (290) limit_clause_opt ::= */ - { 242, -2 }, /* (291) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 242, -4 }, /* (292) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 242, -4 }, /* (293) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 209, -3 }, /* (294) subquery ::= NK_LP query_expression NK_RP */ - { 225, -1 }, /* (295) search_condition ::= common_expression */ - { 244, -1 }, /* (296) sort_specification_list ::= sort_specification */ - { 244, -3 }, /* (297) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 245, -3 }, /* (298) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 246, 0 }, /* (299) ordering_specification_opt ::= */ - { 246, -1 }, /* (300) ordering_specification_opt ::= ASC */ - { 246, -1 }, /* (301) ordering_specification_opt ::= DESC */ - { 247, 0 }, /* (302) null_ordering_opt ::= */ - { 247, -2 }, /* (303) null_ordering_opt ::= NULLS FIRST */ - { 247, -2 }, /* (304) null_ordering_opt ::= NULLS LAST */ + { 160, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 160, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 161, 0 }, /* (2) account_options ::= */ + { 161, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 161, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 161, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 161, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 161, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 161, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 161, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 161, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 161, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 162, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 162, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 164, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 164, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 164, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 164, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 164, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 164, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 164, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 164, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 164, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 164, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 160, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 160, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 160, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 160, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 160, -2 }, /* (28) cmd ::= SHOW USERS */ + { 160, -3 }, /* (29) cmd ::= CREATE DNODE dnode_endpoint */ + { 160, -5 }, /* (30) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 160, -3 }, /* (31) cmd ::= DROP DNODE NK_INTEGER */ + { 160, -3 }, /* (32) cmd ::= DROP DNODE dnode_endpoint */ + { 160, -2 }, /* (33) cmd ::= SHOW DNODES */ + { 160, -4 }, /* (34) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 160, -5 }, /* (35) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 160, -4 }, /* (36) cmd ::= ALTER ALL DNODES NK_STRING */ + { 160, -5 }, /* (37) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 166, -1 }, /* (38) dnode_endpoint ::= NK_STRING */ + { 167, -1 }, /* (39) dnode_host_name ::= NK_ID */ + { 167, -1 }, /* (40) dnode_host_name ::= NK_IPTOKEN */ + { 160, -3 }, /* (41) cmd ::= ALTER LOCAL NK_STRING */ + { 160, -4 }, /* (42) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 160, -5 }, /* (43) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 160, -5 }, /* (44) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 160, -2 }, /* (45) cmd ::= SHOW QNODES */ + { 160, -5 }, /* (46) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 160, -4 }, /* (47) cmd ::= DROP DATABASE exists_opt db_name */ + { 160, -2 }, /* (48) cmd ::= SHOW DATABASES */ + { 160, -2 }, /* (49) cmd ::= USE db_name */ + { 160, -4 }, /* (50) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 168, -3 }, /* (51) not_exists_opt ::= IF NOT EXISTS */ + { 168, 0 }, /* (52) not_exists_opt ::= */ + { 171, -2 }, /* (53) exists_opt ::= IF EXISTS */ + { 171, 0 }, /* (54) exists_opt ::= */ + { 170, 0 }, /* (55) db_options ::= */ + { 170, -3 }, /* (56) db_options ::= db_options BLOCKS NK_INTEGER */ + { 170, -3 }, /* (57) db_options ::= db_options CACHE NK_INTEGER */ + { 170, -3 }, /* (58) db_options ::= db_options CACHELAST NK_INTEGER */ + { 170, -3 }, /* (59) db_options ::= db_options COMP NK_INTEGER */ + { 170, -3 }, /* (60) db_options ::= db_options DAYS NK_INTEGER */ + { 170, -3 }, /* (61) db_options ::= db_options FSYNC NK_INTEGER */ + { 170, -3 }, /* (62) db_options ::= db_options MAXROWS NK_INTEGER */ + { 170, -3 }, /* (63) db_options ::= db_options MINROWS NK_INTEGER */ + { 170, -3 }, /* (64) db_options ::= db_options KEEP NK_INTEGER */ + { 170, -3 }, /* (65) db_options ::= db_options PRECISION NK_STRING */ + { 170, -3 }, /* (66) db_options ::= db_options QUORUM NK_INTEGER */ + { 170, -3 }, /* (67) db_options ::= db_options REPLICA NK_INTEGER */ + { 170, -3 }, /* (68) db_options ::= db_options TTL NK_INTEGER */ + { 170, -3 }, /* (69) db_options ::= db_options WAL NK_INTEGER */ + { 170, -3 }, /* (70) db_options ::= db_options VGROUPS NK_INTEGER */ + { 170, -3 }, /* (71) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 170, -3 }, /* (72) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 170, -3 }, /* (73) db_options ::= db_options RETENTIONS NK_STRING */ + { 170, -3 }, /* (74) db_options ::= db_options FILE_FACTOR NK_FLOAT */ + { 172, -1 }, /* (75) alter_db_options ::= alter_db_option */ + { 172, -2 }, /* (76) alter_db_options ::= alter_db_options alter_db_option */ + { 173, -2 }, /* (77) alter_db_option ::= BLOCKS NK_INTEGER */ + { 173, -2 }, /* (78) alter_db_option ::= FSYNC NK_INTEGER */ + { 173, -2 }, /* (79) alter_db_option ::= KEEP NK_INTEGER */ + { 173, -2 }, /* (80) alter_db_option ::= WAL NK_INTEGER */ + { 173, -2 }, /* (81) alter_db_option ::= QUORUM NK_INTEGER */ + { 173, -2 }, /* (82) alter_db_option ::= CACHELAST NK_INTEGER */ + { 160, -9 }, /* (83) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 160, -3 }, /* (84) cmd ::= CREATE TABLE multi_create_clause */ + { 160, -9 }, /* (85) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 160, -3 }, /* (86) cmd ::= DROP TABLE multi_drop_clause */ + { 160, -4 }, /* (87) cmd ::= DROP STABLE exists_opt full_table_name */ + { 160, -2 }, /* (88) cmd ::= SHOW TABLES */ + { 160, -2 }, /* (89) cmd ::= SHOW STABLES */ + { 160, -3 }, /* (90) cmd ::= ALTER TABLE alter_table_clause */ + { 160, -3 }, /* (91) cmd ::= ALTER STABLE alter_table_clause */ + { 181, -2 }, /* (92) alter_table_clause ::= full_table_name alter_table_options */ + { 181, -5 }, /* (93) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 181, -4 }, /* (94) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 181, -5 }, /* (95) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 181, -5 }, /* (96) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 181, -5 }, /* (97) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 181, -4 }, /* (98) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 181, -5 }, /* (99) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 181, -5 }, /* (100) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 181, -6 }, /* (101) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 178, -1 }, /* (102) multi_create_clause ::= create_subtable_clause */ + { 178, -2 }, /* (103) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 185, -9 }, /* (104) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 180, -1 }, /* (105) multi_drop_clause ::= drop_table_clause */ + { 180, -2 }, /* (106) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 188, -2 }, /* (107) drop_table_clause ::= exists_opt full_table_name */ + { 186, 0 }, /* (108) specific_tags_opt ::= */ + { 186, -3 }, /* (109) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 174, -1 }, /* (110) full_table_name ::= table_name */ + { 174, -3 }, /* (111) full_table_name ::= db_name NK_DOT table_name */ + { 175, -1 }, /* (112) column_def_list ::= column_def */ + { 175, -3 }, /* (113) column_def_list ::= column_def_list NK_COMMA column_def */ + { 191, -2 }, /* (114) column_def ::= column_name type_name */ + { 191, -4 }, /* (115) column_def ::= column_name type_name COMMENT NK_STRING */ + { 184, -1 }, /* (116) type_name ::= BOOL */ + { 184, -1 }, /* (117) type_name ::= TINYINT */ + { 184, -1 }, /* (118) type_name ::= SMALLINT */ + { 184, -1 }, /* (119) type_name ::= INT */ + { 184, -1 }, /* (120) type_name ::= INTEGER */ + { 184, -1 }, /* (121) type_name ::= BIGINT */ + { 184, -1 }, /* (122) type_name ::= FLOAT */ + { 184, -1 }, /* (123) type_name ::= DOUBLE */ + { 184, -4 }, /* (124) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 184, -1 }, /* (125) type_name ::= TIMESTAMP */ + { 184, -4 }, /* (126) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 184, -2 }, /* (127) type_name ::= TINYINT UNSIGNED */ + { 184, -2 }, /* (128) type_name ::= SMALLINT UNSIGNED */ + { 184, -2 }, /* (129) type_name ::= INT UNSIGNED */ + { 184, -2 }, /* (130) type_name ::= BIGINT UNSIGNED */ + { 184, -1 }, /* (131) type_name ::= JSON */ + { 184, -4 }, /* (132) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 184, -1 }, /* (133) type_name ::= MEDIUMBLOB */ + { 184, -1 }, /* (134) type_name ::= BLOB */ + { 184, -4 }, /* (135) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 184, -1 }, /* (136) type_name ::= DECIMAL */ + { 184, -4 }, /* (137) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 184, -6 }, /* (138) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 176, 0 }, /* (139) tags_def_opt ::= */ + { 176, -1 }, /* (140) tags_def_opt ::= tags_def */ + { 179, -4 }, /* (141) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 177, 0 }, /* (142) table_options ::= */ + { 177, -3 }, /* (143) table_options ::= table_options COMMENT NK_STRING */ + { 177, -3 }, /* (144) table_options ::= table_options KEEP NK_INTEGER */ + { 177, -3 }, /* (145) table_options ::= table_options TTL NK_INTEGER */ + { 177, -5 }, /* (146) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 177, -5 }, /* (147) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 182, -1 }, /* (148) alter_table_options ::= alter_table_option */ + { 182, -2 }, /* (149) alter_table_options ::= alter_table_options alter_table_option */ + { 193, -2 }, /* (150) alter_table_option ::= COMMENT NK_STRING */ + { 193, -2 }, /* (151) alter_table_option ::= KEEP NK_INTEGER */ + { 193, -2 }, /* (152) alter_table_option ::= TTL NK_INTEGER */ + { 189, -1 }, /* (153) col_name_list ::= col_name */ + { 189, -3 }, /* (154) col_name_list ::= col_name_list NK_COMMA col_name */ + { 194, -1 }, /* (155) col_name ::= column_name */ + { 192, -1 }, /* (156) func_name_list ::= func_name */ + { 192, -3 }, /* (157) func_name_list ::= func_name_list NK_COMMA col_name */ + { 195, -1 }, /* (158) func_name ::= function_name */ + { 160, -7 }, /* (159) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 160, -9 }, /* (160) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 160, -5 }, /* (161) cmd ::= DROP INDEX index_name ON table_name */ + { 198, 0 }, /* (162) index_options ::= */ + { 198, -9 }, /* (163) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 198, -11 }, /* (164) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 199, -1 }, /* (165) func_list ::= func */ + { 199, -3 }, /* (166) func_list ::= func_list NK_COMMA func */ + { 202, -4 }, /* (167) func ::= function_name NK_LP expression_list NK_RP */ + { 160, -6 }, /* (168) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 160, -6 }, /* (169) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 160, -4 }, /* (170) cmd ::= DROP TOPIC exists_opt topic_name */ + { 160, -2 }, /* (171) cmd ::= SHOW VGROUPS */ + { 160, -4 }, /* (172) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 160, -2 }, /* (173) cmd ::= SHOW MNODES */ + { 160, -1 }, /* (174) cmd ::= query_expression */ + { 163, -1 }, /* (175) literal ::= NK_INTEGER */ + { 163, -1 }, /* (176) literal ::= NK_FLOAT */ + { 163, -1 }, /* (177) literal ::= NK_STRING */ + { 163, -1 }, /* (178) literal ::= NK_BOOL */ + { 163, -2 }, /* (179) literal ::= TIMESTAMP NK_STRING */ + { 163, -1 }, /* (180) literal ::= duration_literal */ + { 200, -1 }, /* (181) duration_literal ::= NK_VARIABLE */ + { 187, -1 }, /* (182) literal_list ::= literal */ + { 187, -3 }, /* (183) literal_list ::= literal_list NK_COMMA literal */ + { 169, -1 }, /* (184) db_name ::= NK_ID */ + { 190, -1 }, /* (185) table_name ::= NK_ID */ + { 183, -1 }, /* (186) column_name ::= NK_ID */ + { 196, -1 }, /* (187) function_name ::= NK_ID */ + { 206, -1 }, /* (188) table_alias ::= NK_ID */ + { 207, -1 }, /* (189) column_alias ::= NK_ID */ + { 165, -1 }, /* (190) user_name ::= NK_ID */ + { 197, -1 }, /* (191) index_name ::= NK_ID */ + { 204, -1 }, /* (192) topic_name ::= NK_ID */ + { 208, -1 }, /* (193) expression ::= literal */ + { 208, -1 }, /* (194) expression ::= column_reference */ + { 208, -4 }, /* (195) expression ::= function_name NK_LP expression_list NK_RP */ + { 208, -4 }, /* (196) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 208, -1 }, /* (197) expression ::= subquery */ + { 208, -3 }, /* (198) expression ::= NK_LP expression NK_RP */ + { 208, -2 }, /* (199) expression ::= NK_PLUS expression */ + { 208, -2 }, /* (200) expression ::= NK_MINUS expression */ + { 208, -3 }, /* (201) expression ::= expression NK_PLUS expression */ + { 208, -3 }, /* (202) expression ::= expression NK_MINUS expression */ + { 208, -3 }, /* (203) expression ::= expression NK_STAR expression */ + { 208, -3 }, /* (204) expression ::= expression NK_SLASH expression */ + { 208, -3 }, /* (205) expression ::= expression NK_REM expression */ + { 203, -1 }, /* (206) expression_list ::= expression */ + { 203, -3 }, /* (207) expression_list ::= expression_list NK_COMMA expression */ + { 209, -1 }, /* (208) column_reference ::= column_name */ + { 209, -3 }, /* (209) column_reference ::= table_name NK_DOT column_name */ + { 211, -3 }, /* (210) predicate ::= expression compare_op expression */ + { 211, -5 }, /* (211) predicate ::= expression BETWEEN expression AND expression */ + { 211, -6 }, /* (212) predicate ::= expression NOT BETWEEN expression AND expression */ + { 211, -3 }, /* (213) predicate ::= expression IS NULL */ + { 211, -4 }, /* (214) predicate ::= expression IS NOT NULL */ + { 211, -3 }, /* (215) predicate ::= expression in_op in_predicate_value */ + { 212, -1 }, /* (216) compare_op ::= NK_LT */ + { 212, -1 }, /* (217) compare_op ::= NK_GT */ + { 212, -1 }, /* (218) compare_op ::= NK_LE */ + { 212, -1 }, /* (219) compare_op ::= NK_GE */ + { 212, -1 }, /* (220) compare_op ::= NK_NE */ + { 212, -1 }, /* (221) compare_op ::= NK_EQ */ + { 212, -1 }, /* (222) compare_op ::= LIKE */ + { 212, -2 }, /* (223) compare_op ::= NOT LIKE */ + { 212, -1 }, /* (224) compare_op ::= MATCH */ + { 212, -1 }, /* (225) compare_op ::= NMATCH */ + { 213, -1 }, /* (226) in_op ::= IN */ + { 213, -2 }, /* (227) in_op ::= NOT IN */ + { 214, -3 }, /* (228) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 215, -1 }, /* (229) boolean_value_expression ::= boolean_primary */ + { 215, -2 }, /* (230) boolean_value_expression ::= NOT boolean_primary */ + { 215, -3 }, /* (231) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 215, -3 }, /* (232) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 216, -1 }, /* (233) boolean_primary ::= predicate */ + { 216, -3 }, /* (234) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 217, -1 }, /* (235) common_expression ::= expression */ + { 217, -1 }, /* (236) common_expression ::= boolean_value_expression */ + { 218, -2 }, /* (237) from_clause ::= FROM table_reference_list */ + { 219, -1 }, /* (238) table_reference_list ::= table_reference */ + { 219, -3 }, /* (239) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 220, -1 }, /* (240) table_reference ::= table_primary */ + { 220, -1 }, /* (241) table_reference ::= joined_table */ + { 221, -2 }, /* (242) table_primary ::= table_name alias_opt */ + { 221, -4 }, /* (243) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 221, -2 }, /* (244) table_primary ::= subquery alias_opt */ + { 221, -1 }, /* (245) table_primary ::= parenthesized_joined_table */ + { 223, 0 }, /* (246) alias_opt ::= */ + { 223, -1 }, /* (247) alias_opt ::= table_alias */ + { 223, -2 }, /* (248) alias_opt ::= AS table_alias */ + { 224, -3 }, /* (249) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 224, -3 }, /* (250) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 222, -6 }, /* (251) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 225, 0 }, /* (252) join_type ::= */ + { 225, -1 }, /* (253) join_type ::= INNER */ + { 227, -9 }, /* (254) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 228, 0 }, /* (255) set_quantifier_opt ::= */ + { 228, -1 }, /* (256) set_quantifier_opt ::= DISTINCT */ + { 228, -1 }, /* (257) set_quantifier_opt ::= ALL */ + { 229, -1 }, /* (258) select_list ::= NK_STAR */ + { 229, -1 }, /* (259) select_list ::= select_sublist */ + { 235, -1 }, /* (260) select_sublist ::= select_item */ + { 235, -3 }, /* (261) select_sublist ::= select_sublist NK_COMMA select_item */ + { 236, -1 }, /* (262) select_item ::= common_expression */ + { 236, -2 }, /* (263) select_item ::= common_expression column_alias */ + { 236, -3 }, /* (264) select_item ::= common_expression AS column_alias */ + { 236, -3 }, /* (265) select_item ::= table_name NK_DOT NK_STAR */ + { 230, 0 }, /* (266) where_clause_opt ::= */ + { 230, -2 }, /* (267) where_clause_opt ::= WHERE search_condition */ + { 231, 0 }, /* (268) partition_by_clause_opt ::= */ + { 231, -3 }, /* (269) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 232, 0 }, /* (270) twindow_clause_opt ::= */ + { 232, -6 }, /* (271) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 232, -4 }, /* (272) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 232, -6 }, /* (273) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 232, -8 }, /* (274) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 201, 0 }, /* (275) sliding_opt ::= */ + { 201, -4 }, /* (276) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 237, 0 }, /* (277) fill_opt ::= */ + { 237, -4 }, /* (278) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 237, -6 }, /* (279) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 238, -1 }, /* (280) fill_mode ::= NONE */ + { 238, -1 }, /* (281) fill_mode ::= PREV */ + { 238, -1 }, /* (282) fill_mode ::= NULL */ + { 238, -1 }, /* (283) fill_mode ::= LINEAR */ + { 238, -1 }, /* (284) fill_mode ::= NEXT */ + { 233, 0 }, /* (285) group_by_clause_opt ::= */ + { 233, -3 }, /* (286) group_by_clause_opt ::= GROUP BY group_by_list */ + { 239, -1 }, /* (287) group_by_list ::= expression */ + { 239, -3 }, /* (288) group_by_list ::= group_by_list NK_COMMA expression */ + { 234, 0 }, /* (289) having_clause_opt ::= */ + { 234, -2 }, /* (290) having_clause_opt ::= HAVING search_condition */ + { 205, -4 }, /* (291) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 240, -1 }, /* (292) query_expression_body ::= query_primary */ + { 240, -4 }, /* (293) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 244, -1 }, /* (294) query_primary ::= query_specification */ + { 241, 0 }, /* (295) order_by_clause_opt ::= */ + { 241, -3 }, /* (296) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 242, 0 }, /* (297) slimit_clause_opt ::= */ + { 242, -2 }, /* (298) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 242, -4 }, /* (299) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 242, -4 }, /* (300) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 243, 0 }, /* (301) limit_clause_opt ::= */ + { 243, -2 }, /* (302) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 243, -4 }, /* (303) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 243, -4 }, /* (304) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 210, -3 }, /* (305) subquery ::= NK_LP query_expression NK_RP */ + { 226, -1 }, /* (306) search_condition ::= common_expression */ + { 245, -1 }, /* (307) sort_specification_list ::= sort_specification */ + { 245, -3 }, /* (308) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 246, -3 }, /* (309) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 247, 0 }, /* (310) ordering_specification_opt ::= */ + { 247, -1 }, /* (311) ordering_specification_opt ::= ASC */ + { 247, -1 }, /* (312) ordering_specification_opt ::= DESC */ + { 248, 0 }, /* (313) null_ordering_opt ::= */ + { 248, -2 }, /* (314) null_ordering_opt ::= NULLS FIRST */ + { 248, -2 }, /* (315) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2181,928 +2218,949 @@ static YYACTIONTYPE yy_reduce( */ /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; - case 0: /* cmd ::= ALTER ACCOUNT NK_ID account_options */ + case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } yy_destructor(yypParser,161,&yymsp[0].minor); break; - case 1: /* account_options ::= account_option */ -{ yy_destructor(yypParser,162,&yymsp[0].minor); -{ } -} - break; - case 2: /* account_options ::= account_options account_option */ -{ yy_destructor(yypParser,161,&yymsp[-1].minor); -{ } + case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ +{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } yy_destructor(yypParser,162,&yymsp[0].minor); + break; + case 2: /* account_options ::= */ +{ } + break; + case 3: /* account_options ::= account_options PPS literal */ + case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); + case 5: /* account_options ::= account_options STORAGE literal */ yytestcase(yyruleno==5); + case 6: /* account_options ::= account_options STREAMS literal */ yytestcase(yyruleno==6); + case 7: /* account_options ::= account_options QTIME literal */ yytestcase(yyruleno==7); + case 8: /* account_options ::= account_options DBS literal */ yytestcase(yyruleno==8); + case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); + 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,161,&yymsp[-2].minor); +{ } + yy_destructor(yypParser,163,&yymsp[0].minor); } break; - case 3: /* account_option ::= PASS literal */ - case 4: /* account_option ::= PPS literal */ yytestcase(yyruleno==4); - case 5: /* account_option ::= TSERIES literal */ yytestcase(yyruleno==5); - case 6: /* account_option ::= STORAGE literal */ yytestcase(yyruleno==6); - case 7: /* account_option ::= STREAMS literal */ yytestcase(yyruleno==7); - case 8: /* account_option ::= QTIME literal */ yytestcase(yyruleno==8); - case 9: /* account_option ::= DBS literal */ yytestcase(yyruleno==9); - case 10: /* account_option ::= USERS literal */ yytestcase(yyruleno==10); - case 11: /* account_option ::= CONNS literal */ yytestcase(yyruleno==11); - case 12: /* account_option ::= STATE literal */ yytestcase(yyruleno==12); + case 12: /* alter_account_options ::= alter_account_option */ +{ yy_destructor(yypParser,164,&yymsp[0].minor); +{ } +} + break; + case 13: /* alter_account_options ::= alter_account_options alter_account_option */ +{ yy_destructor(yypParser,162,&yymsp[-1].minor); +{ } + yy_destructor(yypParser,164,&yymsp[0].minor); +} + break; + case 14: /* alter_account_option ::= PASS literal */ + case 15: /* alter_account_option ::= PPS literal */ yytestcase(yyruleno==15); + case 16: /* alter_account_option ::= TSERIES literal */ yytestcase(yyruleno==16); + case 17: /* alter_account_option ::= STORAGE literal */ yytestcase(yyruleno==17); + case 18: /* alter_account_option ::= STREAMS literal */ yytestcase(yyruleno==18); + case 19: /* alter_account_option ::= QTIME literal */ yytestcase(yyruleno==19); + case 20: /* alter_account_option ::= DBS literal */ yytestcase(yyruleno==20); + 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); { } yy_destructor(yypParser,163,&yymsp[0].minor); break; - case 13: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } + case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy353, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; - case 15: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } + case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy353, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; - case 16: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy241); } + case 27: /* cmd ::= DROP USER user_name */ +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy353); } break; - case 17: /* cmd ::= SHOW USERS */ + case 28: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; - case 18: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy241, NULL); } + case 29: /* cmd ::= CREATE DNODE dnode_endpoint */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy353, NULL); } break; - case 19: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + case 30: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy0); } break; - case 20: /* cmd ::= DROP DNODE NK_INTEGER */ + case 31: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 21: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy241); } + case 32: /* cmd ::= DROP DNODE dnode_endpoint */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy353); } break; - case 22: /* cmd ::= SHOW DNODES */ + case 33: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } break; - case 23: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + case 34: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 24: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + case 35: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 25: /* cmd ::= ALTER ALL DNODES NK_STRING */ + case 36: /* cmd ::= ALTER ALL DNODES NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } break; - case 26: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + case 37: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 27: /* dnode_endpoint ::= NK_STRING */ - case 28: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==28); - case 29: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==29); - case 173: /* db_name ::= NK_ID */ yytestcase(yyruleno==173); - case 174: /* table_name ::= NK_ID */ yytestcase(yyruleno==174); - case 175: /* column_name ::= NK_ID */ yytestcase(yyruleno==175); - case 176: /* function_name ::= NK_ID */ yytestcase(yyruleno==176); - case 177: /* table_alias ::= NK_ID */ yytestcase(yyruleno==177); - case 178: /* column_alias ::= NK_ID */ yytestcase(yyruleno==178); - case 179: /* user_name ::= NK_ID */ yytestcase(yyruleno==179); - case 180: /* index_name ::= NK_ID */ yytestcase(yyruleno==180); - case 181: /* topic_name ::= NK_ID */ yytestcase(yyruleno==181); -{ yylhsminor.yy241 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 38: /* dnode_endpoint ::= NK_STRING */ + case 39: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==39); + case 40: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==40); + case 184: /* db_name ::= NK_ID */ yytestcase(yyruleno==184); + case 185: /* table_name ::= NK_ID */ yytestcase(yyruleno==185); + case 186: /* column_name ::= NK_ID */ yytestcase(yyruleno==186); + case 187: /* function_name ::= NK_ID */ yytestcase(yyruleno==187); + case 188: /* table_alias ::= NK_ID */ yytestcase(yyruleno==188); + case 189: /* column_alias ::= NK_ID */ yytestcase(yyruleno==189); + case 190: /* user_name ::= NK_ID */ yytestcase(yyruleno==190); + case 191: /* index_name ::= NK_ID */ yytestcase(yyruleno==191); + case 192: /* topic_name ::= NK_ID */ yytestcase(yyruleno==192); +{ yylhsminor.yy353 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy353 = yylhsminor.yy353; break; - case 30: /* cmd ::= ALTER LOCAL NK_STRING */ + case 41: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 31: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + case 42: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 32: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + case 43: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 33: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + case 44: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 34: /* cmd ::= SHOW QNODES */ + case 45: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 35: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy457, &yymsp[-1].minor.yy241, yymsp[0].minor.yy168); } + case 46: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy107, &yymsp[-1].minor.yy353, yymsp[0].minor.yy26); } break; - case 36: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy457, &yymsp[0].minor.yy241); } + case 47: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy107, &yymsp[0].minor.yy353); } break; - case 37: /* cmd ::= SHOW DATABASES */ + case 48: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 38: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } + case 49: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy353); } break; - case 39: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy168); } + case 50: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy353, yymsp[0].minor.yy26); } break; - case 40: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy457 = true; } + case 51: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy107 = true; } break; - case 41: /* not_exists_opt ::= */ - case 43: /* exists_opt ::= */ yytestcase(yyruleno==43); - case 244: /* set_quantifier_opt ::= */ yytestcase(yyruleno==244); -{ yymsp[1].minor.yy457 = false; } + case 52: /* not_exists_opt ::= */ + case 54: /* exists_opt ::= */ yytestcase(yyruleno==54); + case 255: /* set_quantifier_opt ::= */ yytestcase(yyruleno==255); +{ yymsp[1].minor.yy107 = false; } break; - case 42: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy457 = true; } + case 53: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy107 = true; } break; - case 44: /* db_options ::= */ -{ yymsp[1].minor.yy168 = createDefaultDatabaseOptions(pCxt); } + case 55: /* db_options ::= */ +{ yymsp[1].minor.yy26 = createDefaultDatabaseOptions(pCxt); } break; - case 45: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 56: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 46: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 57: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 47: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 58: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 48: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 59: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 49: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 60: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 50: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 61: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 51: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 62: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 52: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 63: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 53: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 64: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 54: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 65: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 55: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 66: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 56: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 67: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 57: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 68: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 58: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 69: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 59: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 70: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 60: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 71: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 61: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 72: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 62: /* db_options ::= db_options RETENTIONS NK_STRING */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 73: /* db_options ::= db_options RETENTIONS NK_STRING */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 63: /* db_options ::= db_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-2].minor.yy168, DB_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 74: /* db_options ::= db_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-2].minor.yy26, DB_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 64: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy168 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy168 = setDatabaseOption(pCxt, yylhsminor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 75: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy26 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy26 = setDatabaseOption(pCxt, yylhsminor.yy26, yymsp[0].minor.yy443.type, &yymsp[0].minor.yy443.val); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 65: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy168 = setDatabaseOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 76: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy26 = setDatabaseOption(pCxt, yymsp[-1].minor.yy26, yymsp[0].minor.yy443.type, &yymsp[0].minor.yy443.val); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 66: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 77: /* alter_db_option ::= BLOCKS NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 67: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 78: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 68: /* alter_db_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_KEEP; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 79: /* alter_db_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_KEEP; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 69: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_WAL; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 80: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_WAL; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 70: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 81: /* alter_db_option ::= QUORUM NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 71: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 82: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 72: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 74: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==74); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy457, yymsp[-5].minor.yy168, yymsp[-3].minor.yy440, yymsp[-1].minor.yy440, yymsp[0].minor.yy168); } + case 83: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 85: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==85); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy107, yymsp[-5].minor.yy26, yymsp[-3].minor.yy64, yymsp[-1].minor.yy64, yymsp[0].minor.yy26); } break; - case 73: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy440); } + case 84: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy64); } break; - case 75: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy440); } + case 86: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy64); } break; - case 76: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy457, yymsp[0].minor.yy168); } + case 87: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy107, yymsp[0].minor.yy26); } break; - case 77: /* cmd ::= SHOW TABLES */ + case 88: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 78: /* cmd ::= SHOW STABLES */ + case 89: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 79: /* cmd ::= ALTER TABLE alter_table_clause */ - case 80: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==80); - case 163: /* cmd ::= query_expression */ yytestcase(yyruleno==163); -{ pCxt->pRootNode = yymsp[0].minor.yy168; } + case 90: /* cmd ::= ALTER TABLE alter_table_clause */ + case 91: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==91); + case 174: /* cmd ::= query_expression */ yytestcase(yyruleno==174); +{ pCxt->pRootNode = yymsp[0].minor.yy26; } break; - case 81: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy168 = createAlterTableOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 92: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy26 = createAlterTableOption(pCxt, yymsp[-1].minor.yy26, yymsp[0].minor.yy26); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 82: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - case 84: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ yytestcase(yyruleno==84); - case 86: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ yytestcase(yyruleno==86); - case 88: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ yytestcase(yyruleno==88); -{ yylhsminor.yy168 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, yymsp[0].minor.yy208); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; + case 93: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + case 95: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ yytestcase(yyruleno==95); + case 97: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ yytestcase(yyruleno==97); + case 99: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ yytestcase(yyruleno==99); +{ yylhsminor.yy26 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; break; - case 83: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ - case 87: /* alter_table_clause ::= full_table_name DROP TAG column_name */ yytestcase(yyruleno==87); -{ yylhsminor.yy168 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 94: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ + case 98: /* alter_table_clause ::= full_table_name DROP TAG column_name */ yytestcase(yyruleno==98); +{ yylhsminor.yy26 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[0].minor.yy353); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 85: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - case 89: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ yytestcase(yyruleno==89); -{ yylhsminor.yy168 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy168, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; + case 96: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + case 100: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ yytestcase(yyruleno==100); +{ yylhsminor.yy26 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; break; - case 90: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy168 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy168, &yymsp[-2].minor.yy241, yymsp[0].minor.yy168); } - yymsp[-5].minor.yy168 = yylhsminor.yy168; + case 101: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ +{ yylhsminor.yy26 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy26, &yymsp[-2].minor.yy353, yymsp[0].minor.yy26); } + yymsp[-5].minor.yy26 = yylhsminor.yy26; break; - case 91: /* multi_create_clause ::= create_subtable_clause */ - case 94: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==94); - case 101: /* column_def_list ::= column_def */ yytestcase(yyruleno==101); - case 142: /* col_name_list ::= col_name */ yytestcase(yyruleno==142); - case 145: /* func_name_list ::= func_name */ yytestcase(yyruleno==145); - case 154: /* func_list ::= func */ yytestcase(yyruleno==154); - case 249: /* select_sublist ::= select_item */ yytestcase(yyruleno==249); - case 296: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==296); -{ yylhsminor.yy440 = createNodeList(pCxt, yymsp[0].minor.yy168); } - yymsp[0].minor.yy440 = yylhsminor.yy440; + case 102: /* multi_create_clause ::= create_subtable_clause */ + case 105: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==105); + case 112: /* column_def_list ::= column_def */ yytestcase(yyruleno==112); + case 153: /* col_name_list ::= col_name */ yytestcase(yyruleno==153); + case 156: /* func_name_list ::= func_name */ yytestcase(yyruleno==156); + case 165: /* func_list ::= func */ yytestcase(yyruleno==165); + case 260: /* select_sublist ::= select_item */ yytestcase(yyruleno==260); + case 307: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==307); +{ yylhsminor.yy64 = createNodeList(pCxt, yymsp[0].minor.yy26); } + yymsp[0].minor.yy64 = yylhsminor.yy64; break; - case 92: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 95: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==95); -{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-1].minor.yy440, yymsp[0].minor.yy168); } - yymsp[-1].minor.yy440 = yylhsminor.yy440; + case 103: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 106: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==106); +{ yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-1].minor.yy64, yymsp[0].minor.yy26); } + yymsp[-1].minor.yy64 = yylhsminor.yy64; break; - case 93: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy168 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy457, yymsp[-7].minor.yy168, yymsp[-5].minor.yy168, yymsp[-4].minor.yy440, yymsp[-1].minor.yy440); } - yymsp[-8].minor.yy168 = yylhsminor.yy168; + case 104: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy26 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy107, yymsp[-7].minor.yy26, yymsp[-5].minor.yy26, yymsp[-4].minor.yy64, yymsp[-1].minor.yy64); } + yymsp[-8].minor.yy26 = yylhsminor.yy26; break; - case 96: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy168 = createDropTableClause(pCxt, yymsp[-1].minor.yy457, yymsp[0].minor.yy168); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 107: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy26 = createDropTableClause(pCxt, yymsp[-1].minor.yy107, yymsp[0].minor.yy26); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 97: /* specific_tags_opt ::= */ - case 128: /* tags_def_opt ::= */ yytestcase(yyruleno==128); - case 257: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==257); - case 274: /* group_by_clause_opt ::= */ yytestcase(yyruleno==274); - case 284: /* order_by_clause_opt ::= */ yytestcase(yyruleno==284); -{ yymsp[1].minor.yy440 = NULL; } + case 108: /* specific_tags_opt ::= */ + case 139: /* tags_def_opt ::= */ yytestcase(yyruleno==139); + case 268: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==268); + case 285: /* group_by_clause_opt ::= */ yytestcase(yyruleno==285); + case 295: /* order_by_clause_opt ::= */ yytestcase(yyruleno==295); +{ yymsp[1].minor.yy64 = NULL; } break; - case 98: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy440 = yymsp[-1].minor.yy440; } + case 109: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy64 = yymsp[-1].minor.yy64; } break; - case 99: /* full_table_name ::= table_name */ -{ yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 110: /* full_table_name ::= table_name */ +{ yylhsminor.yy26 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy353, NULL); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 100: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, NULL); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 111: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy26 = createRealTableNode(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy353, NULL); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 102: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 143: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==143); - case 146: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==146); - case 155: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==155); - case 250: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==250); - case 297: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==297); -{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, yymsp[0].minor.yy168); } - yymsp[-2].minor.yy440 = yylhsminor.yy440; + case 113: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 154: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==154); + case 157: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==157); + case 166: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==166); + case 261: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==261); + case 308: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==308); +{ yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, yymsp[0].minor.yy26); } + yymsp[-2].minor.yy64 = yylhsminor.yy64; break; - case 103: /* column_def ::= column_name type_name */ -{ yylhsminor.yy168 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy208, NULL); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 114: /* column_def ::= column_name type_name */ +{ yylhsminor.yy26 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370, NULL); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 104: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy168 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-2].minor.yy208, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 115: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy26 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy353, yymsp[-2].minor.yy370, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 105: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 116: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 106: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 117: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 107: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 118: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 108: /* type_name ::= INT */ - case 109: /* type_name ::= INTEGER */ yytestcase(yyruleno==109); -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_INT); } + case 119: /* type_name ::= INT */ + case 120: /* type_name ::= INTEGER */ yytestcase(yyruleno==120); +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 110: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 121: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 111: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 122: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 112: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 123: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 113: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 124: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy370 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 114: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 125: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 115: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 126: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy370 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 116: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 127: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy370 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 117: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 128: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy370 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 118: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UINT); } + case 129: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy370 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 119: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy208 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 130: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy370 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 120: /* type_name ::= JSON */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_JSON); } + case 131: /* type_name ::= JSON */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 121: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 132: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy370 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 122: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 133: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 123: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 134: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 124: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy208 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 135: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy370 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 125: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 136: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy370 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 126: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 137: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy370 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 127: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy208 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 138: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy370 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 129: /* tags_def_opt ::= tags_def */ - case 248: /* select_list ::= select_sublist */ yytestcase(yyruleno==248); -{ yylhsminor.yy440 = yymsp[0].minor.yy440; } - yymsp[0].minor.yy440 = yylhsminor.yy440; + case 140: /* tags_def_opt ::= tags_def */ + case 259: /* select_list ::= select_sublist */ yytestcase(yyruleno==259); +{ yylhsminor.yy64 = yymsp[0].minor.yy64; } + yymsp[0].minor.yy64 = yylhsminor.yy64; break; - case 130: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy440 = yymsp[-1].minor.yy440; } + case 141: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy64 = yymsp[-1].minor.yy64; } break; - case 131: /* table_options ::= */ -{ yymsp[1].minor.yy168 = createDefaultTableOptions(pCxt); } + case 142: /* table_options ::= */ +{ yymsp[1].minor.yy26 = createDefaultTableOptions(pCxt); } break; - case 132: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 143: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy26 = setTableOption(pCxt, yymsp[-2].minor.yy26, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 133: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 144: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy26 = setTableOption(pCxt, yymsp[-2].minor.yy26, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 134: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-2].minor.yy168, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 145: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy26 = setTableOption(pCxt, yymsp[-2].minor.yy26, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 135: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy168 = setTableSmaOption(pCxt, yymsp[-4].minor.yy168, yymsp[-1].minor.yy440); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; + case 146: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy26 = setTableSmaOption(pCxt, yymsp[-4].minor.yy26, yymsp[-1].minor.yy64); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; break; - case 136: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy168 = setTableRollupOption(pCxt, yymsp[-4].minor.yy168, yymsp[-1].minor.yy440); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; + case 147: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy26 = setTableRollupOption(pCxt, yymsp[-4].minor.yy26, yymsp[-1].minor.yy64); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; break; - case 137: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy168 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy168 = setTableOption(pCxt, yylhsminor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 148: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy26 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy26 = setTableOption(pCxt, yylhsminor.yy26, yymsp[0].minor.yy443.type, &yymsp[0].minor.yy443.val); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 138: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy168 = setTableOption(pCxt, yymsp[-1].minor.yy168, yymsp[0].minor.yy349.type, &yymsp[0].minor.yy349.val); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 149: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy26 = setTableOption(pCxt, yymsp[-1].minor.yy26, yymsp[0].minor.yy443.type, &yymsp[0].minor.yy443.val); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 139: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy349.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 150: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy443.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 140: /* alter_table_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 151: /* alter_table_option ::= KEEP NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 141: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy349.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy349.val = yymsp[0].minor.yy0; } + case 152: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy443.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy443.val = yymsp[0].minor.yy0; } break; - case 144: /* col_name ::= column_name */ -{ yylhsminor.yy168 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 155: /* col_name ::= column_name */ +{ yylhsminor.yy26 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy353); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 147: /* func_name ::= function_name */ -{ yylhsminor.yy168 = createFunctionNode(pCxt, &yymsp[0].minor.yy241, NULL); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 158: /* func_name ::= function_name */ +{ yylhsminor.yy26 = createFunctionNode(pCxt, &yymsp[0].minor.yy353, NULL); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 148: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, NULL, yymsp[0].minor.yy168); } + case 159: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy353, &yymsp[-1].minor.yy353, NULL, yymsp[0].minor.yy26); } break; - case 149: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy241, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440, NULL); } + case 160: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy353, &yymsp[-3].minor.yy353, yymsp[-1].minor.yy64, NULL); } break; - case 150: /* cmd ::= DROP INDEX index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } + case 161: /* cmd ::= DROP INDEX index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy353); } break; - case 151: /* index_options ::= */ - case 255: /* where_clause_opt ::= */ yytestcase(yyruleno==255); - case 259: /* twindow_clause_opt ::= */ yytestcase(yyruleno==259); - case 264: /* sliding_opt ::= */ yytestcase(yyruleno==264); - case 266: /* fill_opt ::= */ yytestcase(yyruleno==266); - case 278: /* having_clause_opt ::= */ yytestcase(yyruleno==278); - case 286: /* slimit_clause_opt ::= */ yytestcase(yyruleno==286); - case 290: /* limit_clause_opt ::= */ yytestcase(yyruleno==290); -{ yymsp[1].minor.yy168 = NULL; } + case 162: /* index_options ::= */ + case 266: /* where_clause_opt ::= */ yytestcase(yyruleno==266); + case 270: /* twindow_clause_opt ::= */ yytestcase(yyruleno==270); + case 275: /* sliding_opt ::= */ yytestcase(yyruleno==275); + case 277: /* fill_opt ::= */ yytestcase(yyruleno==277); + case 289: /* having_clause_opt ::= */ yytestcase(yyruleno==289); + case 297: /* slimit_clause_opt ::= */ yytestcase(yyruleno==297); + case 301: /* limit_clause_opt ::= */ yytestcase(yyruleno==301); +{ yymsp[1].minor.yy26 = NULL; } break; - case 152: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy168 = createIndexOption(pCxt, yymsp[-6].minor.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), NULL, yymsp[0].minor.yy168); } + case 163: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy26 = createIndexOption(pCxt, yymsp[-6].minor.yy64, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), NULL, yymsp[0].minor.yy26); } break; - case 153: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy168 = createIndexOption(pCxt, yymsp[-8].minor.yy440, releaseRawExprNode(pCxt, yymsp[-4].minor.yy168), releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[0].minor.yy168); } + case 164: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy26 = createIndexOption(pCxt, yymsp[-8].minor.yy64, releaseRawExprNode(pCxt, yymsp[-4].minor.yy26), releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), yymsp[0].minor.yy26); } break; - case 156: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy168 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 167: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy26 = createFunctionNode(pCxt, &yymsp[-3].minor.yy353, yymsp[-1].minor.yy64); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 157: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy457, &yymsp[-2].minor.yy241, yymsp[0].minor.yy168, NULL); } + case 168: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy107, &yymsp[-2].minor.yy353, yymsp[0].minor.yy26, NULL); } break; - case 158: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy457, &yymsp[-2].minor.yy241, NULL, &yymsp[0].minor.yy241); } + case 169: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy107, &yymsp[-2].minor.yy353, NULL, &yymsp[0].minor.yy353); } break; - case 159: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy457, &yymsp[0].minor.yy241); } + case 170: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy107, &yymsp[0].minor.yy353); } break; - case 160: /* cmd ::= SHOW VGROUPS */ + case 171: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 161: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy241); } + case 172: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy353); } break; - case 162: /* cmd ::= SHOW MNODES */ + case 173: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 164: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 175: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 165: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 176: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 166: /* literal ::= NK_STRING */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 177: /* literal ::= NK_STRING */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 167: /* literal ::= NK_BOOL */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 178: /* literal ::= NK_BOOL */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 168: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 179: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 169: /* literal ::= duration_literal */ - case 182: /* expression ::= literal */ yytestcase(yyruleno==182); - case 183: /* expression ::= column_reference */ yytestcase(yyruleno==183); - case 186: /* expression ::= subquery */ yytestcase(yyruleno==186); - case 218: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==218); - case 222: /* boolean_primary ::= predicate */ yytestcase(yyruleno==222); - case 224: /* common_expression ::= expression */ yytestcase(yyruleno==224); - case 225: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==225); - case 227: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==227); - case 229: /* table_reference ::= table_primary */ yytestcase(yyruleno==229); - case 230: /* table_reference ::= joined_table */ yytestcase(yyruleno==230); - case 234: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==234); - case 281: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==281); - case 283: /* query_primary ::= query_specification */ yytestcase(yyruleno==283); -{ yylhsminor.yy168 = yymsp[0].minor.yy168; } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 180: /* literal ::= duration_literal */ + case 193: /* expression ::= literal */ yytestcase(yyruleno==193); + case 194: /* expression ::= column_reference */ yytestcase(yyruleno==194); + case 197: /* expression ::= subquery */ yytestcase(yyruleno==197); + case 229: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==229); + case 233: /* boolean_primary ::= predicate */ yytestcase(yyruleno==233); + case 235: /* common_expression ::= expression */ yytestcase(yyruleno==235); + case 236: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==236); + case 238: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==238); + case 240: /* table_reference ::= table_primary */ yytestcase(yyruleno==240); + case 241: /* table_reference ::= joined_table */ yytestcase(yyruleno==241); + case 245: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==245); + case 292: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==292); + case 294: /* query_primary ::= query_specification */ yytestcase(yyruleno==294); +{ yylhsminor.yy26 = yymsp[0].minor.yy26; } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 170: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 181: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 171: /* literal_list ::= literal */ - case 195: /* expression_list ::= expression */ yytestcase(yyruleno==195); -{ yylhsminor.yy440 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[0].minor.yy440 = yylhsminor.yy440; + case 182: /* literal_list ::= literal */ + case 206: /* expression_list ::= expression */ yytestcase(yyruleno==206); +{ yylhsminor.yy64 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy26)); } + yymsp[0].minor.yy64 = yylhsminor.yy64; break; - case 172: /* literal_list ::= literal_list NK_COMMA literal */ - case 196: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==196); -{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-2].minor.yy440 = yylhsminor.yy440; + case 183: /* literal_list ::= literal_list NK_COMMA literal */ + case 207: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==207); +{ yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, releaseRawExprNode(pCxt, yymsp[0].minor.yy26)); } + yymsp[-2].minor.yy64 = yylhsminor.yy64; break; - case 184: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy440)); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 195: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy353, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy353, yymsp[-1].minor.yy64)); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 185: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 196: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy353, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy353, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 187: /* expression ::= NK_LP expression NK_RP */ - case 223: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==223); -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 198: /* expression ::= NK_LP expression NK_RP */ + case 234: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==234); +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy26)); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 188: /* expression ::= NK_PLUS expression */ + case 199: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy26)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 189: /* expression ::= NK_MINUS expression */ + case 200: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy26), NULL)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 190: /* expression ::= expression NK_PLUS expression */ + case 201: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 191: /* expression ::= expression NK_MINUS expression */ + case 202: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 192: /* expression ::= expression NK_STAR expression */ + case 203: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 193: /* expression ::= expression NK_SLASH expression */ + case 204: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 194: /* expression ::= expression NK_REM expression */ + case 205: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 197: /* column_reference ::= column_name */ -{ yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 208: /* column_reference ::= column_name */ +{ yylhsminor.yy26 = createRawExprNode(pCxt, &yymsp[0].minor.yy353, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy353)); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 198: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 209: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy353, createColumnNode(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy353)); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 199: /* predicate ::= expression compare_op expression */ - case 204: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==204); + case 210: /* predicate ::= expression compare_op expression */ + case 215: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==215); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy476, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy80, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 200: /* predicate ::= expression BETWEEN expression AND expression */ + case 211: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy168), releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy26), releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; + yymsp[-4].minor.yy26 = yylhsminor.yy26; break; - case 201: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 212: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[-5].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-5].minor.yy168 = yylhsminor.yy168; + yymsp[-5].minor.yy26 = yylhsminor.yy26; break; - case 202: /* predicate ::= expression IS NULL */ + case 213: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), NULL)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 203: /* predicate ::= expression IS NOT NULL */ + case 214: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy26), NULL)); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 205: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy476 = OP_TYPE_LOWER_THAN; } + case 216: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy80 = OP_TYPE_LOWER_THAN; } break; - case 206: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy476 = OP_TYPE_GREATER_THAN; } + case 217: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy80 = OP_TYPE_GREATER_THAN; } break; - case 207: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy476 = OP_TYPE_LOWER_EQUAL; } + case 218: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy80 = OP_TYPE_LOWER_EQUAL; } break; - case 208: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy476 = OP_TYPE_GREATER_EQUAL; } + case 219: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy80 = OP_TYPE_GREATER_EQUAL; } break; - case 209: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy476 = OP_TYPE_NOT_EQUAL; } + case 220: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy80 = OP_TYPE_NOT_EQUAL; } break; - case 210: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy476 = OP_TYPE_EQUAL; } + case 221: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy80 = OP_TYPE_EQUAL; } break; - case 211: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy476 = OP_TYPE_LIKE; } + case 222: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy80 = OP_TYPE_LIKE; } break; - case 212: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy476 = OP_TYPE_NOT_LIKE; } + case 223: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy80 = OP_TYPE_NOT_LIKE; } break; - case 213: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy476 = OP_TYPE_MATCH; } + case 224: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy80 = OP_TYPE_MATCH; } break; - case 214: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy476 = OP_TYPE_NMATCH; } + case 225: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy80 = OP_TYPE_NMATCH; } break; - case 215: /* in_op ::= IN */ -{ yymsp[0].minor.yy476 = OP_TYPE_IN; } + case 226: /* in_op ::= IN */ +{ yymsp[0].minor.yy80 = OP_TYPE_IN; } break; - case 216: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy476 = OP_TYPE_NOT_IN; } + case 227: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy80 = OP_TYPE_NOT_IN; } break; - case 217: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy440)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 228: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy64)); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 219: /* boolean_value_expression ::= NOT boolean_primary */ + case 230: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy26), NULL)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 220: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 231: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 221: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 232: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy26); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 226: /* from_clause ::= FROM table_reference_list */ - case 256: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==256); - case 279: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==279); -{ yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; } + case 237: /* from_clause ::= FROM table_reference_list */ + case 267: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==267); + case 290: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==290); +{ yymsp[-1].minor.yy26 = yymsp[0].minor.yy26; } break; - case 228: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 239: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy26 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy26, yymsp[0].minor.yy26, NULL); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 231: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 242: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy26 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 232: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 243: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy26 = createRealTableNode(pCxt, &yymsp[-3].minor.yy353, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 233: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy168 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 244: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy26 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy26), &yymsp[0].minor.yy353); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 235: /* alias_opt ::= */ -{ yymsp[1].minor.yy241 = nil_token; } + case 246: /* alias_opt ::= */ +{ yymsp[1].minor.yy353 = nil_token; } break; - case 236: /* alias_opt ::= table_alias */ -{ yylhsminor.yy241 = yymsp[0].minor.yy241; } - yymsp[0].minor.yy241 = yylhsminor.yy241; + case 247: /* alias_opt ::= table_alias */ +{ yylhsminor.yy353 = yymsp[0].minor.yy353; } + yymsp[0].minor.yy353 = yylhsminor.yy353; break; - case 237: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } + case 248: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy353 = yymsp[0].minor.yy353; } break; - case 238: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 239: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==239); -{ yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; } + case 249: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 250: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==250); +{ yymsp[-2].minor.yy26 = yymsp[-1].minor.yy26; } break; - case 240: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy228, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-5].minor.yy168 = yylhsminor.yy168; + case 251: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy26 = createJoinTableNode(pCxt, yymsp[-4].minor.yy372, yymsp[-5].minor.yy26, yymsp[-2].minor.yy26, yymsp[0].minor.yy26); } + yymsp[-5].minor.yy26 = yylhsminor.yy26; break; - case 241: /* join_type ::= */ -{ yymsp[1].minor.yy228 = JOIN_TYPE_INNER; } + case 252: /* join_type ::= */ +{ yymsp[1].minor.yy372 = JOIN_TYPE_INNER; } break; - case 242: /* join_type ::= INNER */ -{ yymsp[0].minor.yy228 = JOIN_TYPE_INNER; } + case 253: /* join_type ::= INNER */ +{ yymsp[0].minor.yy372 = JOIN_TYPE_INNER; } break; - case 243: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 254: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy457, yymsp[-6].minor.yy440, yymsp[-5].minor.yy168); - yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168); - yymsp[-8].minor.yy168 = addPartitionByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-3].minor.yy440); - yymsp[-8].minor.yy168 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy168, yymsp[-2].minor.yy168); - yymsp[-8].minor.yy168 = addGroupByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-1].minor.yy440); - yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168); + yymsp[-8].minor.yy26 = createSelectStmt(pCxt, yymsp[-7].minor.yy107, yymsp[-6].minor.yy64, yymsp[-5].minor.yy26); + yymsp[-8].minor.yy26 = addWhereClause(pCxt, yymsp[-8].minor.yy26, yymsp[-4].minor.yy26); + yymsp[-8].minor.yy26 = addPartitionByClause(pCxt, yymsp[-8].minor.yy26, yymsp[-3].minor.yy64); + yymsp[-8].minor.yy26 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy26, yymsp[-2].minor.yy26); + yymsp[-8].minor.yy26 = addGroupByClause(pCxt, yymsp[-8].minor.yy26, yymsp[-1].minor.yy64); + yymsp[-8].minor.yy26 = addHavingClause(pCxt, yymsp[-8].minor.yy26, yymsp[0].minor.yy26); } break; - case 245: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy457 = true; } + case 256: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy107 = true; } break; - case 246: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy457 = false; } + case 257: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy107 = false; } break; - case 247: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy440 = NULL; } + case 258: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy64 = NULL; } break; - case 251: /* select_item ::= common_expression */ + case 262: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy26); + yylhsminor.yy26 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy26), &t); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 252: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 263: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy26 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy26), &yymsp[0].minor.yy353); } + yymsp[-1].minor.yy26 = yylhsminor.yy26; break; - case 253: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 264: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy26 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), &yymsp[0].minor.yy353); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 254: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 265: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy26 = createColumnNode(pCxt, &yymsp[-2].minor.yy353, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 258: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 275: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==275); - case 285: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==285); -{ yymsp[-2].minor.yy440 = yymsp[0].minor.yy440; } + case 269: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 286: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==286); + case 296: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==296); +{ yymsp[-2].minor.yy64 = yymsp[0].minor.yy64; } break; - case 260: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy168 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), &yymsp[-1].minor.yy0); } + case 271: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy26 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy26), &yymsp[-1].minor.yy0); } break; - case 261: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy168 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } + case 272: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy26 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy26)); } break; - case 262: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), NULL, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } + case 273: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy26 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy26), NULL, yymsp[-1].minor.yy26, yymsp[0].minor.yy26); } break; - case 263: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy168 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } + case 274: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy26 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy26), releaseRawExprNode(pCxt, yymsp[-3].minor.yy26), yymsp[-1].minor.yy26, yymsp[0].minor.yy26); } break; - case 265: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy168 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy168); } + case 276: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy26 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy26); } break; - case 267: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy168 = createFillNode(pCxt, yymsp[-1].minor.yy262, NULL); } + case 278: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy26 = createFillNode(pCxt, yymsp[-1].minor.yy192, NULL); } break; - case 268: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy168 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy440)); } + case 279: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy26 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy64)); } break; - case 269: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy262 = FILL_MODE_NONE; } + case 280: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy192 = FILL_MODE_NONE; } break; - case 270: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy262 = FILL_MODE_PREV; } + case 281: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy192 = FILL_MODE_PREV; } break; - case 271: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy262 = FILL_MODE_NULL; } + case 282: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy192 = FILL_MODE_NULL; } break; - case 272: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy262 = FILL_MODE_LINEAR; } + case 283: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy192 = FILL_MODE_LINEAR; } break; - case 273: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy262 = FILL_MODE_NEXT; } + case 284: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy192 = FILL_MODE_NEXT; } break; - case 276: /* group_by_list ::= expression */ -{ yylhsminor.yy440 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[0].minor.yy440 = yylhsminor.yy440; + case 287: /* group_by_list ::= expression */ +{ yylhsminor.yy64 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } + yymsp[0].minor.yy64 = yylhsminor.yy64; break; - case 277: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy440 = addNodeToList(pCxt, yymsp[-2].minor.yy440, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); } - yymsp[-2].minor.yy440 = yylhsminor.yy440; + case 288: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy64 = addNodeToList(pCxt, yymsp[-2].minor.yy64, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy26))); } + yymsp[-2].minor.yy64 = yylhsminor.yy64; break; - case 280: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 291: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy440); - yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168); - yylhsminor.yy168 = addLimitClause(pCxt, yylhsminor.yy168, yymsp[0].minor.yy168); + yylhsminor.yy26 = addOrderByClause(pCxt, yymsp[-3].minor.yy26, yymsp[-2].minor.yy64); + yylhsminor.yy26 = addSlimitClause(pCxt, yylhsminor.yy26, yymsp[-1].minor.yy26); + yylhsminor.yy26 = addLimitClause(pCxt, yylhsminor.yy26, yymsp[0].minor.yy26); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 282: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 293: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy26 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy26, yymsp[0].minor.yy26); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; break; - case 287: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 291: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==291); -{ yymsp[-1].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 298: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 302: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==302); +{ yymsp[-1].minor.yy26 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 288: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 292: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==292); -{ yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 299: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 303: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==303); +{ yymsp[-3].minor.yy26 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 289: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 293: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==293); -{ yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 300: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 304: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==304); +{ yymsp[-3].minor.yy26 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 294: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy168); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 305: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy26 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy26); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 295: /* search_condition ::= common_expression */ -{ yylhsminor.yy168 = releaseRawExprNode(pCxt, yymsp[0].minor.yy168); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 306: /* search_condition ::= common_expression */ +{ yylhsminor.yy26 = releaseRawExprNode(pCxt, yymsp[0].minor.yy26); } + yymsp[0].minor.yy26 = yylhsminor.yy26; break; - case 298: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy168 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[-1].minor.yy258, yymsp[0].minor.yy425); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 309: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy26 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy26), yymsp[-1].minor.yy32, yymsp[0].minor.yy391); } + yymsp[-2].minor.yy26 = yylhsminor.yy26; break; - case 299: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy258 = ORDER_ASC; } + case 310: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy32 = ORDER_ASC; } break; - case 300: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy258 = ORDER_ASC; } + case 311: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy32 = ORDER_ASC; } break; - case 301: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy258 = ORDER_DESC; } + case 312: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy32 = ORDER_DESC; } break; - case 302: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy425 = NULL_ORDER_DEFAULT; } + case 313: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy391 = NULL_ORDER_DEFAULT; } break; - case 303: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy425 = NULL_ORDER_FIRST; } + case 314: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy391 = NULL_ORDER_FIRST; } break; - case 304: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy425 = NULL_ORDER_LAST; } + case 315: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy391 = NULL_ORDER_LAST; } break; default: break; From 91df290152424fd4fb1216d0886139bb66c33291 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 17 Mar 2022 11:46:34 +0800 Subject: [PATCH 25/60] add REF for SSmaStat in case of delete SSmaStatItem when drop sma index --- source/dnode/vnode/inc/tsdb.h | 6 +- source/dnode/vnode/src/meta/metaBDBImpl.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 146 ++++++++++++++-------- source/dnode/vnode/test/tsdbSmaTest.cpp | 2 +- 4 files changed, 95 insertions(+), 61 deletions(-) diff --git a/source/dnode/vnode/inc/tsdb.h b/source/dnode/vnode/inc/tsdb.h index 87edfb8dde..7b93f7580d 100644 --- a/source/dnode/vnode/inc/tsdb.h +++ b/source/dnode/vnode/inc/tsdb.h @@ -107,10 +107,8 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg); int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg); // TODO: This is the basic params, and should wrap the params to a queryHandle. -int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, - int32_t nMaxResult); - +int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, + tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult); // STsdbCfg int tsdbOptionsInit(STsdbCfg *); diff --git a/source/dnode/vnode/src/meta/metaBDBImpl.c b/source/dnode/vnode/src/meta/metaBDBImpl.c index a729288e34..df2d9604d2 100644 --- a/source/dnode/vnode/src/meta/metaBDBImpl.c +++ b/source/dnode/vnode/src/meta/metaBDBImpl.c @@ -636,7 +636,7 @@ STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) { } // Decode - pCfg = (STSma *)malloc(sizeof(STSma)); + pCfg = (STSma *)calloc(1, sizeof(STSma)); if (pCfg == NULL) { return NULL; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index cd8b60385f..7a5c9c5c1e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -20,7 +20,7 @@ static const char *TSDB_SMA_DNAME[] = { "tsma", // TSDB_SMA_TYPE_TIME_RANGE "rsma", // TSDB_SMA_TYPE_ROLLUP }; - +#define SMA_CHECK_HASH #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 @@ -72,35 +72,43 @@ typedef struct { struct SSmaStat { SHashObj *smaStatItems; // key: indexName, value: SSmaStatItem + T_REF_DECLARE() }; // declaration of static functions -static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg); -static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg); -// TODO: This is the basic params, and should wrap the params to a queryHandle. -static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, - int32_t nMaxResult); -static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg); - +// expired window +static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path); static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv); -static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, STSmaDataWrapper *pData); -static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH); -static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit); -static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit); -static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData); -static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen); +static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey); +static int32_t tsdbRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); +static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); +// read data +// TODO: This is the basic params, and should wrap the params to a queryHandle. +static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, + int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, + int32_t nMaxResult); + +// insert data +static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, STSmaDataWrapper *pData); +static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH); +static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit); +static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit); +static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData); +static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen); static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision); static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel); static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); +static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg); +static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg); +// implementation static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); } @@ -192,6 +200,21 @@ void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv) { return NULL; } +static int32_t tsdbRefSmaStat(STsdb *pTsdb, SSmaStat *pStat) { + if (pStat == NULL) return 0; + int ref = T_REF_INC(pStat); + tsdbDebug("vgId:%d ref sma stat %p ref %d", REPO_ID(pTsdb), pStat, ref); + return 0; +} + +static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat) { + if (pStat == NULL) return 0; + + int ref = T_REF_DEC(pStat); + tsdbDebug("vgId:%d unref sma stat %p ref %d", REPO_ID(pTsdb), pStat, ref); + return 0; +} + static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat) { ASSERT(pSmaStat != NULL); @@ -296,7 +319,7 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { * @param msg * @return int32_t */ -int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { +int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { if (!msg || !pTsdb->pMeta) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; @@ -307,27 +330,28 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { return TSDB_CODE_FAILED; } - SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, smaType); - - // TODO: decode the msg => start - int64_t indexUid = SMA_TEST_INDEX_UID; - // const char * indexName = SMA_TEST_INDEX_NAME; + // TODO: decode the msg from Stream Computing module => start + int64_t indexUid = SMA_TEST_INDEX_UID; const int32_t SMA_TEST_EXPIRED_WINDOW_SIZE = 10; TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE]; - int64_t now = taosGetTimestampMs(); + TSKEY skey1 = 1646987196 * 1e3; for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) { - expiredWindows[i] = now + i; + expiredWindows[i] = skey1 + i; } - // TODO: decode the msg <= end + + SSmaEnv * pEnv = REPO_SMA_ENV(pTsdb, smaType); + SSmaStat *pStat = SMA_ENV_STAT(pEnv); SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); + tsdbRefSmaStat(pTsdb, pStat); SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); if (pItem == NULL) { pItem = tsdbNewSmaStatItem(TSDB_SMA_STAT_EXPIRED); // TODO use the real state if (pItem == NULL) { // Response to stream computing: OOM - // For query, if the indexName not found, the TSDB should tell query module to query raw TS data. + // For query, if the indexUid not found, the TSDB should tell query module to query raw TS data. + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } @@ -337,6 +361,7 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META; taosHashCleanup(pItem->expiredWindows); free(pItem); + tsdbUnRefSmaStat(pTsdb, pStat); tsdbWarn("vgId:%d update expired window failed for smaIndex %" PRIi64 " since %s", REPO_ID(pTsdb), indexUid, tstrerror(terrno)); return TSDB_CODE_FAILED; @@ -347,18 +372,14 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { // If error occurs during put smaStatItem, free the resources of pItem taosHashCleanup(pItem->expiredWindows); free(pItem); + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } } -#if 0 - SSmaStatItem *pItem1 = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - int size1 = taosHashGetSize(pItem1->expiredWindows); - tsdbWarn("vgId:%d smaIndex %" PRIi64 " size is %d before hashPut", REPO_ID(pTsdb), indexUid, size1); -#endif int8_t state = TSDB_SMA_STAT_EXPIRED; for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) { - if (taosHashPut(pItem->expiredWindows, &expiredWindows[i], sizeof(TSKEY), &state, sizeof(state)) != 0) { + if (taosHashPut(pItem->expiredWindows, (void *)(expiredWindows + i), sizeof(TSKEY), &state, sizeof(state)) != 0) { // If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would // tell query module to query raw TS data. // N.B. @@ -368,37 +389,43 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { taosHashCleanup(pItem->expiredWindows); tfree(pItem->pSma); taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid)); + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } + tsdbDebug("vgId:%d smaIndex %" PRIi64 " tsKey %" PRIi64 " is put to hash", REPO_ID(pTsdb), indexUid, + expiredWindows[i]); } -#if 0 - SSmaStatItem *pItem2 = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - int size2 = taosHashGetSize(pItem1->expiredWindows); - tsdbWarn("vgId:%d smaIndex %" PRIi64 " size is %d after hashPut", REPO_ID(pTsdb), indexUid, size2); -#endif - + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_SUCCESS; } -static int32_t tsdbResetExpiredWindow(SSmaStat *pStat, int64_t indexUid, TSKEY skey) { +static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey) { SSmaStatItem *pItem = NULL; - // TODO: If HASH_ENTRY_LOCK used, whether rwlock needed to handle cases of removing hashNode? + tsdbRefSmaStat(pTsdb, pStat); + if (pStat && pStat->smaStatItems) { - pItem = (SSmaStatItem *)taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); + pItem = *(SSmaStatItem **)taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); } -#if 0 if (pItem != NULL) { - // TODO: reset time window for the sma data blocks + // pItem resides in hash buffer all the time unless drop sma index + // TODO: multithread protect if (taosHashRemove(pItem->expiredWindows, &skey, sizeof(TSKEY)) != 0) { // error handling + tsdbUnRefSmaStat(pTsdb, pStat); + tsdbWarn("vgId:%d remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " failed", REPO_ID(pTsdb), + skey, indexUid); + return TSDB_CODE_FAILED; } - } else { // error handling + tsdbUnRefSmaStat(pTsdb, pStat); + tsdbWarn("vgId:%d expired window %" PRIi64 " not exists for sma index %" PRIi64, REPO_ID(pTsdb), skey, indexUid); + return TSDB_CODE_FAILED; } -#endif + + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_SUCCESS; } @@ -705,7 +732,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { // TODO:tsdbEndTSmaCommit(); // Step 3: reset the SSmaStat - tsdbResetExpiredWindow(SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey); + tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey); tsdbDestroyTSmaWriteH(&tSmaH); return TSDB_CODE_SUCCESS; @@ -751,7 +778,7 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) { // TODO:tsdbEndTSmaCommit(); // reset the SSmaStat - tsdbResetExpiredWindow(SMA_ENV_STAT(pTsdb->pRSmaEnv), pData->indexUid, pData->skey); + tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pRSmaEnv), pData->indexUid, pData->skey); return TSDB_CODE_SUCCESS; } @@ -839,7 +866,7 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { * @return int32_t */ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, + int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { if (!pTsdb->pTSmaEnv) { terrno = TSDB_CODE_INVALID_PTR; @@ -847,12 +874,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ return TSDB_CODE_FAILED; } - SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); + tsdbRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); + SSmaStatItem *pItem = *(SSmaStatItem **)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); if (pItem == NULL) { // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if // it's NULL. + tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); terrno = TSDB_CODE_TDB_INVALID_ACTION; - tsdbWarn("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", REPO_ID(pTsdb), indexUid); + tsdbDebug("vgId:%d getTSmaDataImpl failed since no index %" PRIi64, REPO_ID(pTsdb), indexUid); return TSDB_CODE_FAILED; } @@ -866,16 +895,23 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ } #endif -#if 0 - if (taosHashGet(pItem->expiredWindows, &querySkey, sizeof(TSKEY)) != NULL) { +#if 1 + if (taosHashGet(pItem->expiredWindows, &querySKey, sizeof(TSKEY)) != NULL) { // TODO: mark this window as expired. + tsdbDebug("vgId:%d skey %" PRIi64 " of window exists in expired window for index %" PRIi64, REPO_ID(pTsdb), + querySKey, indexUid); + } else { + tsdbDebug("vgId:%d skey %" PRIi64 " of window not in expired window for index %" PRIi64, REPO_ID(pTsdb), querySKey, + indexUid); } + tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); + #endif STSmaReadH tReadH = {0}; tsdbInitTSmaReadH(&tReadH, pTsdb, interval, intervalUnit); tsdbCloseDBF(&tReadH.dFile); - tsdbInitTSmaFile(&tReadH, querySkey); + tsdbInitTSmaFile(&tReadH, querySKey); if (tsdbOpenDBF(SMA_ENV_ENV(pTsdb->pTSmaEnv), &tReadH.dFile) != 0) { tsdbWarn("vgId:%d open DBF %s failed since %s", REPO_ID(pTsdb), tReadH.dFile.path, tstrerror(terrno)); return TSDB_CODE_FAILED; @@ -883,7 +919,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ char smaKey[SMA_KEY_LEN] = {0}; void *pSmaKey = &smaKey; - tsdbEncodeTSmaKey(tableUid, colId, querySkey, (void **)&pSmaKey); + tsdbEncodeTSmaKey(tableUid, colId, querySKey, (void **)&pSmaKey); tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), @@ -1010,9 +1046,9 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) { } int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, - tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, int32_t nMaxResult) { + tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { int32_t code = TSDB_CODE_SUCCESS; - if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, interval, intervalUnit, tableUid, colId, querySkey, + if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, interval, intervalUnit, tableUid, colId, querySKey, nMaxResult)) < 0) { tsdbWarn("vgId:%d get tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno)); } diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 96fd35e700..ae4e9b0a75 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -301,7 +301,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { break; } - char *msg = (char *)calloc(100, 1); + char *msg = (char *)calloc(1, 100); assert(msg != NULL); ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); From 30c10ef8b3bcecd6545ec1b852271e8fdfa21745 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Thu, 17 Mar 2022 14:22:36 +0800 Subject: [PATCH 26/60] [TD-13063]: prepare for win compilation. --- contrib/CMakeLists.txt | 9 +++++++++ include/libs/nodes/plannodes.h | 6 +++--- include/os/os.h | 14 ++++++++------ include/os/osDef.h | 1 + include/os/osFile.h | 2 +- include/os/osSocket.h | 2 ++ include/os/osSysinfo.h | 1 - include/util/tencode.h | 2 +- include/util/tfreelist.h | 10 ++++++---- include/util/types.h | 2 +- source/common/src/tmsg.c | 2 +- source/common/src/tname.c | 2 +- source/libs/planner/src/planSpliter.c | 2 +- source/libs/sync/src/syncUtil.c | 7 ++----- source/libs/tdb/src/db/tdbBtree.c | 4 +++- source/libs/tdb/src/db/tdbEnv.c | 6 +----- source/libs/tdb/src/db/tdbPgCache.c | 6 +----- source/libs/tdb/src/inc/tdbPgFile.h | 4 +++- source/libs/transport/src/transCli.c | 8 ++++---- source/libs/transport/src/transSrv.c | 14 +++++++------- source/libs/wal/src/walMeta.c | 3 --- source/os/CMakeLists.txt | 7 ++++--- source/util/src/tcompare.c | 2 +- source/util/test/encodeTest.cpp | 8 ++++---- source/util/test/freelistTest.cpp | 3 ++- 25 files changed, 67 insertions(+), 60 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 575a0e6274..f87f660ab3 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -212,6 +212,11 @@ if(${BUILD_WITH_UV}) MESSAGE("Windows need set no-sign-compare") add_compile_options(-Wno-sign-compare) endif () + if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + file(READ "libuv/include/uv.h" CONTENTS) + string(REGEX REPLACE "/([\r]*)\nstruct uv_tcp_s {" "/\\1\ntypedef BOOL (PASCAL *LPFN_CONNECTEX) (SOCKET s, const struct sockaddr* name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength,LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped);\\1\nstruct uv_tcp_s {" CONTENTS_NEW "${CONTENTS}") + file(WRITE "libuv/include/uv.h" "${CONTENTS_NEW}") + endif () add_subdirectory(libuv) endif(${BUILD_WITH_UV}) @@ -243,6 +248,10 @@ if(${BUILD_WITH_SQLITE}) endif(${BUILD_WITH_SQLITE}) # pthread +if(${BUILD_PTHREAD}) + ADD_DEFINITIONS("-DPTW32_STATIC_LIB") + add_subdirectory(pthread-win32) +endif(${BUILD_PTHREAD}) # ================================================================================================ diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 8871bae4e9..1d89b07539 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -69,7 +69,7 @@ typedef struct SProjectLogicNode { } SProjectLogicNode; typedef struct SVnodeModifLogicNode { - SLogicNode node;; + SLogicNode node; int32_t msgType; SArray* pDataBlocks; SVgDataBlocks* pVgDataBlocks; @@ -124,7 +124,7 @@ typedef struct SSubLogicPlan { } SSubLogicPlan; typedef struct SQueryLogicPlan { - ENodeType type;; + ENodeType type; int32_t totalLevel; SNodeList* pTopSubplans; } SQueryLogicPlan; @@ -252,7 +252,7 @@ typedef struct SSubplan { } SSubplan; typedef struct SQueryPlan { - ENodeType type;; + ENodeType type; uint64_t queryId; int32_t numOfSubplans; SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0. diff --git a/include/os/os.h b/include/os/os.h index 12f4e733c2..9118a92e11 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -25,10 +25,11 @@ extern "C" { #include #include +#include + #if !defined(WINDOWS) #include #include -#include #include #include #include @@ -36,6 +37,12 @@ extern "C" { #include #include #include +#include +#include +#include +#include +#include +#include #if defined(DARWIN) #else @@ -61,12 +68,7 @@ extern "C" { #include #include #include -#include -#include -#include -#include #include -#include #include diff --git a/include/os/osDef.h b/include/os/osDef.h index fcc96c19b4..492df1047c 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -56,6 +56,7 @@ extern "C" { // specific typedef int (*__compar_fn_t)(const void *, const void *); #define ssize_t int + #define _SSIZE_T_ #define bzero(ptr, size) memset((ptr), 0, (size)) #define strcasecmp _stricmp #define strncasecmp _strnicmp diff --git a/include/os/osFile.h b/include/os/osFile.h index 58a9df2504..209cecedf8 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -24,7 +24,7 @@ extern "C" { #if defined(WINDOWS) typedef int32_t FileFd; -typedef SOCKET SocketFd; +typedef int32_t SocketFd; #else typedef int32_t FileFd; typedef int32_t SocketFd; diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 520d3af331..fb330a9e2f 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -25,6 +25,8 @@ #define epoll_create EPOLL_CREATE_FUNC_TAOS_FORBID #define epoll_ctl EPOLL_CTL_FUNC_TAOS_FORBID #define epoll_wait EPOLL_WAIT_FUNC_TAOS_FORBID + #define inet_addr INET_ADDR_FUNC_TAOS_FORBID + #define inet_ntoa INET_NTOA_FUNC_TAOS_FORBID #endif #if defined(WINDOWS) diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 7777466973..e1cc6f7829 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -16,7 +16,6 @@ #ifndef _TD_OS_SYSINFO_H_ #define _TD_OS_SYSINFO_H_ -#include #include "os.h" #ifdef __cplusplus diff --git a/include/util/tencode.h b/include/util/tencode.h index cbbd55c8a3..7e1b624dfb 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -75,7 +75,7 @@ typedef struct { #define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos) #define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE)) #define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE)) -#define TCODER_MALLOC(SIZE, CODER) TFL_MALLOC(SIZE, &((CODER)->fl)) +#define TCODER_MALLOC(PTR, TYPE, SIZE, CODER) TFL_MALLOC(PTR, TYPE, SIZE, &((CODER)->fl)) void tCoderInit(SCoder* pCoder, td_endian_t endian, uint8_t* data, int32_t size, td_coder_t type); void tCoderClear(SCoder* pCoder); diff --git a/include/util/tfreelist.h b/include/util/tfreelist.h index c1913ebaf9..0a507aeec9 100644 --- a/include/util/tfreelist.h +++ b/include/util/tfreelist.h @@ -29,15 +29,17 @@ struct SFreeListNode { typedef TD_SLIST(SFreeListNode) SFreeList; -#define TFL_MALLOC(SIZE, LIST) \ - ({ \ +#define TFL_MALLOC(PTR, TYPE, SIZE, LIST) \ + do { \ void *ptr = malloc((SIZE) + sizeof(struct SFreeListNode)); \ if (ptr) { \ TD_SLIST_PUSH((LIST), (struct SFreeListNode *)ptr); \ ptr = ((struct SFreeListNode *)ptr)->payload; \ + (PTR) = (TYPE)(ptr); \ + }else{ \ + (PTR) = NULL; \ } \ - ptr; \ - }) + }while(0); #define tFreeListInit(pFL) TD_SLIST_INIT(pFL) diff --git a/include/util/types.h b/include/util/types.h index f7a535c965..981c457fc1 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -82,7 +82,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 #define VARSTR_HEADER_SIZE sizeof(VarDataLenT) #define varDataLen(v) ((VarDataLenT *)(v))[0] -#define varDataVal(v) ((void *)((char *)v + VARSTR_HEADER_SIZE)) +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) typedef int32_t VarDataOffsetT; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 794e5a8542..d9242cf0ac 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2467,7 +2467,7 @@ int32_t tEncodeSMqCMCommitOffsetReq(SCoder *encoder, const SMqCMCommitOffsetReq int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq) { if (tStartDecode(decoder) < 0) return -1; if (tDecodeI32(decoder, &pReq->num) < 0) return -1; - pReq->offsets = TCODER_MALLOC(pReq->num * sizeof(SMqOffset), decoder); + TCODER_MALLOC(pReq->offsets, SMqOffset*, pReq->num * sizeof(SMqOffset), decoder); if (pReq->offsets == NULL) return -1; for (int32_t i = 0; i < pReq->num; i++) { tDecodeSMqOffset(decoder, &pReq->offsets[i]); diff --git a/source/common/src/tname.c b/source/common/src/tname.c index a97792de66..370bf03969 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -217,7 +217,7 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name } int32_t tNameSetAcctId(SName* dst, int32_t acctId) { - assert(dst != NULL && acct != NULL); + assert(dst != NULL); dst->acctId = acctId; return 0; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 5a5e1d46c6..1d0cbf22df 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -89,7 +89,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pSubplan->id.groupId = pCxt->groupId; pSubplan->subplanType = SUBPLAN_TYPE_SCAN; pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan); - TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList, SVgroupsInfo); + TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList, SVgroupsInfo*); SPLIT_FLAG_SET_MASK(pSubplan->splitFlag, SPLIT_FLAG_STS); return pSubplan; } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 90889a7af0..9486405331 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -14,15 +14,12 @@ */ #include "syncUtil.h" -#include -#include -#include #include "syncEnv.h" // ---- encode / decode uint64_t syncUtilAddr2U64(const char* host, uint16_t port) { uint64_t u64; - uint32_t hostU32 = (uint32_t)inet_addr(host); + uint32_t hostU32 = (uint32_t)taosInetAddr(host); // assert(hostU32 != (uint32_t)-1); u64 = (((uint64_t)hostU32) << 32) | (((uint32_t)port) << 16); return u64; @@ -33,7 +30,7 @@ void syncUtilU642Addr(uint64_t u64, char* host, size_t len, uint16_t* port) { struct in_addr addr; addr.s_addr = hostU32; - snprintf(host, len, "%s", inet_ntoa(addr)); + snprintf(host, len, "%s", taosInetNtoa(addr)); *port = (uint16_t)((u64 & 0x00000000FFFF0000) >> 16); } diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 86e7980733..a2520babe5 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -27,7 +27,8 @@ typedef struct { } SBtIdx; // Btree page header definition -typedef struct __attribute__((__packed__)) { +#pragma pack (push,1) +typedef struct { uint8_t flag; // page flag int32_t vlen; // value length of current page, TDB_VARIANT_LEN for variant length uint16_t nPayloads; // number of total payloads @@ -36,6 +37,7 @@ typedef struct __attribute__((__packed__)) { pgoff_t offPayload; // payload offset pgno_t rChildPgno; // right most child page number } SBtPgHdr; +#pragma pack(pop) typedef int (*BtreeCmprFn)(const void *, const void *); diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index a415d6d60e..30e8fab039 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -30,11 +30,7 @@ struct STDbEnv { } pgfht; // page file hash table; }; -#define TDB_ENV_PGF_HASH(fileid) \ - ({ \ - uint8_t *tmp = (uint8_t *)(fileid); \ - tmp[0] + tmp[1] + tmp[2]; \ - }) +#define TDB_ENV_PGF_HASH(fileid) (((uint8_t *)(fileid))[0] + ((uint8_t *)(fileid))[1] + ((uint8_t *)(fileid))[2]) static int tdbEnvDestroy(TENV *pEnv); diff --git a/source/libs/tdb/src/db/tdbPgCache.c b/source/libs/tdb/src/db/tdbPgCache.c index 1b000aa6d6..ef3f79410a 100644 --- a/source/libs/tdb/src/db/tdbPgCache.c +++ b/source/libs/tdb/src/db/tdbPgCache.c @@ -106,11 +106,7 @@ int pgCacheClose(SPgCache *pPgCache) { return 0; } -#define PG_CACHE_HASH(fileid, pgno) \ - ({ \ - uint64_t *tmp = (uint64_t *)(fileid); \ - (tmp[0] + tmp[1] + tmp[2] + (pgno)); \ - }) +#define PG_CACHE_HASH(fileid, pgno) (((uint64_t *)(fileid))[0] + ((uint64_t *)(fileid))[1] + ((uint64_t *)(fileid))[2] + (pgno)) SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid) { SPage * pPage; diff --git a/source/libs/tdb/src/inc/tdbPgFile.h b/source/libs/tdb/src/inc/tdbPgFile.h index eaeebf6b9d..0a8c277479 100644 --- a/source/libs/tdb/src/inc/tdbPgFile.h +++ b/source/libs/tdb/src/inc/tdbPgFile.h @@ -20,13 +20,15 @@ extern "C" { #endif -typedef struct __attribute__((__packed__)) { +#pragma pack (push,1) +typedef struct { char hdrInfo[16]; // info string pgsz_t szPage; // page size of current file int32_t cno; // commit number counter pgno_t freePgno; // freelist page number uint8_t resv[100]; // reserved space } SPgFileHdr; +#pragma pack(pop) #define TDB_PG_FILE_HDR_SIZE 128 diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 31097a591f..df35b8d67b 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -207,8 +207,8 @@ void cliHandleResp(SCliConn* conn) { } tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn, - TMSG_INFO(pHead->msgType), inet_ntoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), - inet_ntoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); + TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), + taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); conn->secured = pHead->secured; @@ -519,8 +519,8 @@ void cliSend(SCliConn* pConn) { uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn, - TMSG_INFO(pHead->msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); pConn->writeReq.data = pConn; uv_write(&pConn->writeReq, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb); diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 2efdb109aa..73d836319f 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -202,7 +202,7 @@ static void uvHandleReq(SSrvConn* pConn) { STransMsgHead* pHead = (STransMsgHead*)p->msg; if (pHead->secured == 1) { - STransUserMsg* uMsg = (p->msg + p->msgLen - sizeof(STransUserMsg)); + STransUserMsg* uMsg = (STransUserMsg*)((char*)p->msg + p->msgLen - sizeof(STransUserMsg)); memcpy(pConn->user, uMsg->user, tListLen(uMsg->user)); memcpy(pConn->secret, uMsg->secret, tListLen(uMsg->secret)); } @@ -235,12 +235,12 @@ static void uvHandleReq(SSrvConn* pConn) { transRefSrvHandle(pConn); transMsg.handle = pConn; tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), - inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); } else { tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, no resp ", pConn, - TMSG_INFO(transMsg.msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), - inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); + TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); } STrans* pTransInst = (STrans*)p->shandle; @@ -347,7 +347,7 @@ static void uvPrepareSendData(SSrvMsg* smsg, uv_buf_t* wb) { // impl later } tDebug("server conn %p %s is sent to %s:%d, local info: %s:%d", pConn, TMSG_INFO(pHead->msgType), - inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), + taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); pHead->msgLen = htonl(len); @@ -374,8 +374,8 @@ static void uvStartSendResp(SSrvMsg* smsg) { transUnrefSrvHandle(pConn); if (taosArrayGetSize(pConn->srvMsgs) > 0) { - tDebug("server conn %p push data to client %s:%d, local info: %s:%d", pConn, inet_ntoa(pConn->addr.sin_addr), - ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + tDebug("server conn %p push data to client %s:%d, local info: %s:%d", pConn, taosInetNtoa(pConn->addr.sin_addr), + ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); taosArrayPush(pConn->srvMsgs, &smsg); return; } diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 248f758787..70ec7e0655 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -19,9 +19,6 @@ #include "tref.h" #include "walInt.h" -#include -#include - int64_t inline walGetFirstVer(SWal* pWal) { return pWal->vers.firstVer; } int64_t inline walGetSnaphostVer(SWal* pWal) { return pWal->vers.snapshotVer; } diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index 27906c2627..ed240015d4 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -3,9 +3,10 @@ add_library(os STATIC ${OS_SRC}) target_include_directories( os PUBLIC "${CMAKE_SOURCE_DIR}/include/os" - PRIVATE "${CMAKE_SOURCE_DIR}/include" - PRIVATE "${CMAKE_SOURCE_DIR}/include/util" - PRIVATE "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" + PUBLIC "${CMAKE_SOURCE_DIR}/include" + PUBLIC "${CMAKE_SOURCE_DIR}/include/util" + PUBLIC "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" + PUBLIC "${CMAKE_SOURCE_DIR}/contrib/gnuregex" ) target_link_libraries( os pthread dl rt m diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 062d144933..5e3cf1247c 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -427,7 +427,7 @@ int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); + int32_t ret = WCSPatternMatch(pattern, (const wchar_t *)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); free(pattern); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; diff --git a/source/util/test/encodeTest.cpp b/source/util/test/encodeTest.cpp index 25314842fb..b4da43dfb7 100644 --- a/source/util/test/encodeTest.cpp +++ b/source/util/test/encodeTest.cpp @@ -230,7 +230,7 @@ static int32_t tSStructA_v1_decode(SCoder *pCoder, SStructA_v1 *pSAV1) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV1->A_c = (char *)TCODER_MALLOC(len + 1, pCoder); + TCODER_MALLOC(pSAV1->A_c, char*, len + 1, pCoder); memcpy(pSAV1->A_c, tstr, len + 1); tEndDecode(pCoder); @@ -269,7 +269,7 @@ static int32_t tSStructA_v2_decode(SCoder *pCoder, SStructA_v2 *pSAV2) { const char *tstr; uint64_t len; if (tDecodeCStrAndLen(pCoder, &tstr, &len) < 0) return -1; - pSAV2->A_c = (char *)TCODER_MALLOC(len + 1, pCoder); + TCODER_MALLOC(pSAV2->A_c, char*, len + 1, pCoder); memcpy(pSAV2->A_c, tstr, len + 1); // ------------------------NEW FIELDS DECODE------------------------------- @@ -305,7 +305,7 @@ static int32_t tSFinalReq_v1_encode(SCoder *pCoder, const SFinalReq_v1 *ps1) { static int32_t tSFinalReq_v1_decode(SCoder *pCoder, SFinalReq_v1 *ps1) { if (tStartDecode(pCoder) < 0) return -1; - ps1->pA = (SStructA_v1 *)TCODER_MALLOC(sizeof(*(ps1->pA)), pCoder); + TCODER_MALLOC(ps1->pA, SStructA_v1*, sizeof(*(ps1->pA)), pCoder); if (tSStructA_v1_decode(pCoder, ps1->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps1->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps1->v_b) < 0) return -1; @@ -339,7 +339,7 @@ static int32_t tSFinalReq_v2_encode(SCoder *pCoder, const SFinalReq_v2 *ps2) { static int32_t tSFinalReq_v2_decode(SCoder *pCoder, SFinalReq_v2 *ps2) { if (tStartDecode(pCoder) < 0) return -1; - ps2->pA = (SStructA_v2 *)TCODER_MALLOC(sizeof(*(ps2->pA)), pCoder); + TCODER_MALLOC(ps2->pA, SStructA_v2*, sizeof(*(ps2->pA)), pCoder); if (tSStructA_v2_decode(pCoder, ps2->pA) < 0) return -1; if (tDecodeI32(pCoder, &ps2->v_a) < 0) return -1; if (tDecodeI8(pCoder, &ps2->v_b) < 0) return -1; diff --git a/source/util/test/freelistTest.cpp b/source/util/test/freelistTest.cpp index 7fd3d693fb..440e997042 100644 --- a/source/util/test/freelistTest.cpp +++ b/source/util/test/freelistTest.cpp @@ -8,7 +8,8 @@ TEST(TD_UTIL_FREELIST_TEST, simple_test) { tFreeListInit(&fl); for (size_t i = 0; i < 1000; i++) { - void *ptr = TFL_MALLOC(1024, &fl); + void *ptr = NULL; + TFL_MALLOC(ptr, void*, 1024, &fl); GTEST_ASSERT_NE(ptr, nullptr); } From a77239c1adb59baa8b3c912d77255ebd93d799d1 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 17 Mar 2022 14:58:53 +0800 Subject: [PATCH 27/60] [td-13039] refactor. --- include/common/tcommon.h | 72 +++++----------------------------- source/common/src/tdatablock.c | 69 ++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 66 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 3ca1209818..385c123fec 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -62,18 +62,17 @@ typedef struct SDataBlockInfo { union {int64_t uid; int64_t blockId;}; } SDataBlockInfo; -typedef struct SConstantItem { - SColumnInfo info; - int32_t startRow; // run-length-encoding to save the space for multiple rows - int32_t endRow; - SVariant value; -} SConstantItem; +//typedef struct SConstantItem { +// SColumnInfo info; +// int32_t startRow; // run-length-encoding to save the space for multiple rows +// int32_t endRow; +// SVariant value; +//} SConstantItem; // info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList); typedef struct SSDataBlock { SColumnDataAgg *pBlockAgg; SArray *pDataBlock; // SArray - SArray *pConstantList; // SArray, it is a constant/tags value of the corresponding result value. SDataBlockInfo info; } SSDataBlock; @@ -95,66 +94,15 @@ typedef struct SColumnInfoData { }; } SColumnInfoData; -static FORCE_INLINE int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { - int64_t tbUid = pBlock->info.uid; - int16_t numOfCols = pBlock->info.numOfCols; - int16_t hasVarCol = pBlock->info.hasVarCol; - int32_t rows = pBlock->info.rows; - int32_t sz = taosArrayGetSize(pBlock->pDataBlock); - - int32_t tlen = 0; - tlen += taosEncodeFixedI64(buf, tbUid); - tlen += taosEncodeFixedI16(buf, numOfCols); - tlen += taosEncodeFixedI16(buf, hasVarCol); - tlen += taosEncodeFixedI32(buf, rows); - tlen += taosEncodeFixedI32(buf, sz); - for (int32_t i = 0; i < sz; i++) { - SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); - tlen += taosEncodeFixedI16(buf, pColData->info.colId); - tlen += taosEncodeFixedI16(buf, pColData->info.type); - tlen += taosEncodeFixedI32(buf, pColData->info.bytes); - int32_t colSz = rows * pColData->info.bytes; - tlen += taosEncodeBinary(buf, pColData->pData, colSz); - } - return tlen; -} - -static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) { - int32_t sz; - - buf = taosDecodeFixedI64(buf, &pBlock->info.uid); - buf = taosDecodeFixedI16(buf, &pBlock->info.numOfCols); - buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol); - buf = taosDecodeFixedI32(buf, &pBlock->info.rows); - buf = taosDecodeFixedI32(buf, &sz); - pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData)); - for (int32_t i = 0; i < sz; i++) { - SColumnInfoData data = {0}; - buf = taosDecodeFixedI16(buf, &data.info.colId); - buf = taosDecodeFixedI16(buf, &data.info.type); - buf = taosDecodeFixedI32(buf, &data.info.bytes); - int32_t colSz = pBlock->info.rows * data.info.bytes; - buf = taosDecodeBinary(buf, (void**)&data.pData, colSz); - taosArrayPush(pBlock->pDataBlock, &data); - } - return (void*)buf; -} +void* blockDataDestroy(SSDataBlock* pBlock); +int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock); +void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock); static FORCE_INLINE void tDeleteSSDataBlock(SSDataBlock* pBlock) { if (pBlock == NULL) { return; } - - // int32_t numOfOutput = pBlock->info.numOfCols; - int32_t sz = taosArrayGetSize(pBlock->pDataBlock); - for (int32_t i = 0; i < sz; ++i) { - SColumnInfoData* pColInfoData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); - tfree(pColInfoData->pData); - } - - taosArrayDestroy(pBlock->pDataBlock); - tfree(pBlock->pBlockAgg); - // tfree(pBlock); + blockDataDestroy(pBlock); } static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp) { diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 0d1f762db6..4b649d5f62 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -240,10 +240,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co } size_t blockDataGetNumOfCols(const SSDataBlock* pBlock) { - ASSERT(pBlock); - - size_t constantCols = (pBlock->pConstantList != NULL)? taosArrayGetSize(pBlock->pConstantList):0; - ASSERT( pBlock->info.numOfCols == taosArrayGetSize(pBlock->pDataBlock) + constantCols); + ASSERT(pBlock && pBlock->info.numOfCols == taosArrayGetSize(pBlock->pDataBlock)); return pBlock->info.numOfCols; } @@ -1166,3 +1163,67 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) { size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { return pageSize / (blockDataGetSerialRowSize(pBlock) + blockDataGetSerialMetaSize(pBlock)); } + +int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { + int64_t tbUid = pBlock->info.uid; + int16_t numOfCols = pBlock->info.numOfCols; + int16_t hasVarCol = pBlock->info.hasVarCol; + int32_t rows = pBlock->info.rows; + int32_t sz = taosArrayGetSize(pBlock->pDataBlock); + + int32_t tlen = 0; + tlen += taosEncodeFixedI64(buf, tbUid); + tlen += taosEncodeFixedI16(buf, numOfCols); + tlen += taosEncodeFixedI16(buf, hasVarCol); + tlen += taosEncodeFixedI32(buf, rows); + tlen += taosEncodeFixedI32(buf, sz); + for (int32_t i = 0; i < sz; i++) { + SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); + tlen += taosEncodeFixedI16(buf, pColData->info.colId); + tlen += taosEncodeFixedI16(buf, pColData->info.type); + tlen += taosEncodeFixedI32(buf, pColData->info.bytes); + + if (IS_VAR_DATA_TYPE(pColData->info.type)) { + tlen += taosEncodeBinary(buf, pColData->varmeta.offset, sizeof(int32_t) * rows); + } else { + tlen += taosEncodeBinary(buf, pColData->nullbitmap, BitmapLen(rows)); + } + + int32_t len = colDataGetLength(pColData, rows); + taosEncodeFixedI32(buf, len); + + tlen += taosEncodeBinary(buf, pColData->pData, len); + } + return tlen; +} + +void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) { + int32_t sz; + + buf = taosDecodeFixedI64(buf, &pBlock->info.uid); + buf = taosDecodeFixedI16(buf, &pBlock->info.numOfCols); + buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol); + buf = taosDecodeFixedI32(buf, &pBlock->info.rows); + buf = taosDecodeFixedI32(buf, &sz); + pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData)); + for (int32_t i = 0; i < sz; i++) { + SColumnInfoData data = {0}; + buf = taosDecodeFixedI16(buf, &data.info.colId); + buf = taosDecodeFixedI16(buf, &data.info.type); + buf = taosDecodeFixedI32(buf, &data.info.bytes); + + if (IS_VAR_DATA_TYPE(data.info.type)) { + buf = taosDecodeBinary(buf, (void**)&data.varmeta.offset, pBlock->info.rows * sizeof(int32_t)); + data.varmeta.length = pBlock->info.rows * sizeof(int32_t); + data.varmeta.allocLen = data.varmeta.length; + } else { + buf = taosDecodeBinary(buf, (void**)&data.nullbitmap, BitmapLen(pBlock->info.rows)); + } + + int32_t len = 0; + buf = taosDecodeFixedI32(buf, &len); + buf = taosDecodeBinary(buf, (void**)&data.pData, len); + taosArrayPush(pBlock->pDataBlock, &data); + } + return (void*)buf; +} \ No newline at end of file From 9db880458197d131481eb1f0d07fce84ec68ab79 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Thu, 17 Mar 2022 15:53:28 +0800 Subject: [PATCH 28/60] sync refactor --- source/libs/sync/inc/syncMessage.h | 6 +- source/libs/sync/inc/syncRaftEntry.h | 7 +- source/libs/sync/src/syncMain.c | 5 + source/libs/sync/src/syncMessage.c | 5 +- source/libs/sync/src/syncRaftEntry.c | 12 ++ source/libs/sync/test/CMakeLists.txt | 14 ++ source/libs/sync/test/syncEncodeTest.cpp | 236 +++++++++++++++++++++++ 7 files changed, 278 insertions(+), 7 deletions(-) create mode 100644 source/libs/sync/test/syncEncodeTest.cpp diff --git a/source/libs/sync/inc/syncMessage.h b/source/libs/sync/inc/syncMessage.h index 5785089a20..ffb2ae3a26 100644 --- a/source/libs/sync/inc/syncMessage.h +++ b/source/libs/sync/inc/syncMessage.h @@ -163,15 +163,15 @@ typedef struct SyncClientRequest { } SyncClientRequest; SyncClientRequest* syncClientRequestBuild(uint32_t dataLen); -SyncClientRequest* syncClientRequestBuild2(const SRpcMsg* pOriginalRpcMsg, uint64_t seqNum, bool isWeak); +SyncClientRequest* syncClientRequestBuild2(const SRpcMsg* pOriginalRpcMsg, uint64_t seqNum, bool isWeak); // step 1 void syncClientRequestDestroy(SyncClientRequest* pMsg); void syncClientRequestSerialize(const SyncClientRequest* pMsg, char* buf, uint32_t bufLen); void syncClientRequestDeserialize(const char* buf, uint32_t len, SyncClientRequest* pMsg); char* syncClientRequestSerialize2(const SyncClientRequest* pMsg, uint32_t* len); SyncClientRequest* syncClientRequestDeserialize2(const char* buf, uint32_t len); -void syncClientRequest2RpcMsg(const SyncClientRequest* pMsg, SRpcMsg* pRpcMsg); +void syncClientRequest2RpcMsg(const SyncClientRequest* pMsg, SRpcMsg* pRpcMsg); // step 2 void syncClientRequestFromRpcMsg(const SRpcMsg* pRpcMsg, SyncClientRequest* pMsg); -SyncClientRequest* syncClientRequestFromRpcMsg2(const SRpcMsg* pRpcMsg); +SyncClientRequest* syncClientRequestFromRpcMsg2(const SRpcMsg* pRpcMsg); // step 3 cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg); char* syncClientRequest2Str(const SyncClientRequest* pMsg); diff --git a/source/libs/sync/inc/syncRaftEntry.h b/source/libs/sync/inc/syncRaftEntry.h index 6ba27b0d8a..037a49f45c 100644 --- a/source/libs/sync/inc/syncRaftEntry.h +++ b/source/libs/sync/inc/syncRaftEntry.h @@ -40,12 +40,13 @@ typedef struct SSyncRaftEntry { } SSyncRaftEntry; SSyncRaftEntry* syncEntryBuild(uint32_t dataLen); -SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index); +SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index); // step 4 void syncEntryDestory(SSyncRaftEntry* pEntry); -char* syncEntrySerialize(const SSyncRaftEntry* pEntry, uint32_t* len); -SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len); +char* syncEntrySerialize(const SSyncRaftEntry* pEntry, uint32_t* len); // step 5 +SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len); // step 6 cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry); char* syncEntry2Str(const SSyncRaftEntry* pEntry); +void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg); // step 7 // for debug ---------------------- void syncEntryPrint(const SSyncRaftEntry* pObj); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index bd1b4213c0..0fe6993f1d 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -734,7 +734,12 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg if (ths->state == TAOS_SYNC_STATE_LEADER) { SSyncRaftEntry* pEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); ths->pLogStore->appendEntry(ths->pLogStore, pEntry); + + // ths->pFsm->FpPreCommitCb(0) + + // start replicate right now! syncNodeReplicate(ths); + syncEntryDestory(pEntry); } else { // ths->pFsm->FpCommitCb(-1) diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 453ac13ce3..3ac4a7a1c0 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -76,7 +76,7 @@ cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg) { free(s); } else { - pRoot = syncRpcUnknownMsg2Json(); + pRoot = cJSON_CreateObject(); char* s; s = syncUtilprintBin((char*)(pRpcMsg->pCont), pRpcMsg->contLen); cJSON_AddStringToObject(pRoot, "pCont", s); @@ -608,6 +608,7 @@ SyncClientRequest* syncClientRequestBuild(uint32_t dataLen) { return pMsg; } +// step 1. original SRpcMsg => SyncClientRequest, add seqNum, isWeak SyncClientRequest* syncClientRequestBuild2(const SRpcMsg* pOriginalRpcMsg, uint64_t seqNum, bool isWeak) { SyncClientRequest* pMsg = syncClientRequestBuild(pOriginalRpcMsg->contLen); pMsg->originalRpcType = pOriginalRpcMsg->msgType; @@ -652,6 +653,7 @@ SyncClientRequest* syncClientRequestDeserialize2(const char* buf, uint32_t len) return pMsg; } +// step 2. SyncClientRequest => RpcMsg, to queue void syncClientRequest2RpcMsg(const SyncClientRequest* pMsg, SRpcMsg* pRpcMsg) { memset(pRpcMsg, 0, sizeof(*pRpcMsg)); pRpcMsg->msgType = pMsg->msgType; @@ -664,6 +666,7 @@ void syncClientRequestFromRpcMsg(const SRpcMsg* pRpcMsg, SyncClientRequest* pMsg syncClientRequestDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg); } +// step 3. RpcMsg => SyncClientRequest, from queue SyncClientRequest* syncClientRequestFromRpcMsg2(const SRpcMsg* pRpcMsg) { SyncClientRequest* pMsg = syncClientRequestDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen); return pMsg; diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index 2589c3a5e7..e4c5882e98 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -26,6 +26,7 @@ SSyncRaftEntry* syncEntryBuild(uint32_t dataLen) { return pEntry; } +// step 4. SyncClientRequest => SSyncRaftEntry, add term, index SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index) { SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->dataLen); assert(pEntry != NULL); @@ -48,6 +49,7 @@ void syncEntryDestory(SSyncRaftEntry* pEntry) { } } +// step 5. SSyncRaftEntry => bin, to raft log char* syncEntrySerialize(const SSyncRaftEntry* pEntry, uint32_t* len) { char* buf = malloc(pEntry->bytes); assert(buf != NULL); @@ -58,6 +60,7 @@ char* syncEntrySerialize(const SSyncRaftEntry* pEntry, uint32_t* len) { return buf; } +// step 6. bin => SSyncRaftEntry, from raft log SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len) { uint32_t bytes = *((uint32_t*)buf); SSyncRaftEntry* pEntry = malloc(bytes); @@ -106,6 +109,15 @@ char* syncEntry2Str(const SSyncRaftEntry* pEntry) { return serialized; } +// step 7. SSyncRaftEntry => original SRpcMsg, commit to user, delete seqNum, isWeak, term, index +void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg) { + memset(pRpcMsg, 0, sizeof(*pRpcMsg)); + pRpcMsg->msgType = pEntry->originalRpcType; + pRpcMsg->contLen = pEntry->dataLen; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + memcpy(pRpcMsg->pCont, pEntry->data, pRpcMsg->contLen); +} + // for debug ---------------------- void syncEntryPrint(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 2583deb32f..5fa0e975d8 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -28,6 +28,7 @@ add_executable(syncRpcMsgTest "") add_executable(syncPingTimerTest2 "") add_executable(syncPingSelfTest "") add_executable(syncElectTest "") +add_executable(syncEncodeTest "") target_sources(syncTest @@ -150,6 +151,10 @@ target_sources(syncElectTest PRIVATE "syncElectTest.cpp" ) +target_sources(syncEncodeTest + PRIVATE + "syncEncodeTest.cpp" +) target_include_directories(syncTest @@ -307,6 +312,11 @@ target_include_directories(syncElectTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncEncodeTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -429,6 +439,10 @@ target_link_libraries(syncElectTest sync gtest_main ) +target_link_libraries(syncEncodeTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncEncodeTest.cpp b/source/libs/sync/test/syncEncodeTest.cpp new file mode 100644 index 0000000000..f615c1d237 --- /dev/null +++ b/source/libs/sync/test/syncEncodeTest.cpp @@ -0,0 +1,236 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncMessage.h" +#include "syncRaftEntry.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" +#include "syncRaftLog.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 1; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; +SWal* pWal; +SSyncNode* pSyncNode; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./"); + + int code = walInit(); + assert(code == 0); + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = syncInfo.vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + pWal = walOpen("./wal_test", &walCfg); + assert(pWal != NULL); + + syncInfo.pWal = pWal; + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void logStoreTest() { + logStorePrint2((char*)"logStoreTest", pSyncNode->pLogStore); + + assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_INVALID); + + for (int i = 0; i < 5; ++i) { + int32_t dataLen = 10; + SSyncRaftEntry* pEntry = syncEntryBuild(dataLen); + assert(pEntry != NULL); + pEntry->msgType = 1; + pEntry->originalRpcType = 2; + pEntry->seqNum = 3; + pEntry->isWeak = true; + pEntry->term = 100; + pEntry->index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1; + snprintf(pEntry->data, dataLen, "value%d", i); + + // syncEntryPrint2((char*)"write entry:", pEntry); + pSyncNode->pLogStore->appendEntry(pSyncNode->pLogStore, pEntry); + syncEntryDestory(pEntry); + + if (i == 0) { + assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_BEGIN); + } + } + logStorePrint2((char*)"after appendEntry", pSyncNode->pLogStore); + + pSyncNode->pLogStore->truncate(pSyncNode->pLogStore, 3); + logStorePrint2((char*)"after truncate 3", pSyncNode->pLogStore); +} + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +SRpcMsg *step0() { + SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); + memset(pMsg, 0, sizeof(SRpcMsg)); + pMsg->msgType = 9999; + pMsg->contLen = 32; + pMsg->pCont = malloc(pMsg->contLen); + snprintf((char *)(pMsg->pCont), pMsg->contLen, "hello, world"); + return pMsg; +} + +SyncClientRequest *step1(const SRpcMsg *pMsg) { + SyncClientRequest *pRetMsg = syncClientRequestBuild2(pMsg, 123, true); + return pRetMsg; +} + +SRpcMsg *step2(const SyncClientRequest *pMsg) { + SRpcMsg *pRetMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); + syncClientRequest2RpcMsg(pMsg, pRetMsg); + return pRetMsg; +} + +SyncClientRequest *step3(const SRpcMsg *pMsg) { + SyncClientRequest *pRetMsg = syncClientRequestFromRpcMsg2(pMsg); + return pRetMsg; +} + +SSyncRaftEntry *step4(const SyncClientRequest *pMsg) { + SSyncRaftEntry *pRetMsg = syncEntryBuild2((SyncClientRequest *)pMsg, 100, 0); + return pRetMsg; +} + +char *step5(const SSyncRaftEntry *pMsg, uint32_t *len) { + char *pRetMsg = syncEntrySerialize(pMsg, len); + return pRetMsg; +} + +SSyncRaftEntry *step6(const char *pMsg, uint32_t len) { + SSyncRaftEntry *pRetMsg = syncEntryDeserialize(pMsg, len); + return pRetMsg; +} + +SRpcMsg *step7(const SSyncRaftEntry *pMsg) { + SRpcMsg *pRetMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); + syncEntry2OriginalRpc(pMsg, pRetMsg); + return pRetMsg; +} + +int main(int argc, char **argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + void logTest(); + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + taosRemoveDir("./wal_test"); + + // step0 + SRpcMsg *pMsg0 = step0(); + syncRpcMsgPrint2((char *)"==step0==", pMsg0); + + // step1 + SyncClientRequest *pMsg1 = step1(pMsg0); + syncClientRequestPrint2((char *)"==step1==", pMsg1); + + // step2 + SRpcMsg *pMsg2 = step2(pMsg1); + syncRpcMsgPrint2((char *)"==step2==", pMsg2); + + // step3 + SyncClientRequest *pMsg3 = step3(pMsg2); + syncClientRequestPrint2((char *)"==step3==", pMsg3); + + // step4 + SSyncRaftEntry *pMsg4 = step4(pMsg3); + syncEntryPrint2((char *)"==step4==", pMsg4); + + // log, relog + SSyncNode* pSyncNode = syncNodeInit(); + assert(pSyncNode != NULL); + SSyncRaftEntry *pEntry = pMsg4; + pSyncNode->pLogStore->appendEntry(pSyncNode->pLogStore, pEntry); + SSyncRaftEntry *pEntry2 = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, pEntry->index); + syncEntryPrint2((char *)"==pEntry2==", pEntry2); + + // step5 + uint32_t len; + char * pMsg5 = step5(pMsg4, &len); + char * s = syncUtilprintBin(pMsg5, len); + printf("==step5== [%s] \n", s); + free(s); + + // step6 + SSyncRaftEntry *pMsg6 = step6(pMsg5, len); + syncEntryPrint2((char *)"==step6==", pMsg6); + + // step7 + SRpcMsg *pMsg7 = step7(pMsg6); + syncRpcMsgPrint2((char *)"==step7==", pMsg7); + + return 0; +} From 13aa59409d47b2d39ee316b9a7737e0fdddc333f Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Thu, 17 Mar 2022 16:22:51 +0800 Subject: [PATCH 29/60] sync refactor --- source/libs/sync/src/syncMain.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 0fe6993f1d..c716a17df8 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -731,19 +731,42 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg int32_t ret = 0; syncClientRequestLog2("==syncNodeOnClientRequestCb==", pMsg); + SyncIndex index = ths->pLogStore->getLastIndex(ths->pLogStore) + 1; + SyncTerm term = ths->pRaftStore->currentTerm; + SSyncRaftEntry* pEntry = syncEntryBuild2((SyncClientRequest*)pMsg, term, index); + assert(pEntry != NULL); + if (ths->state == TAOS_SYNC_STATE_LEADER) { - SSyncRaftEntry* pEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); ths->pLogStore->appendEntry(ths->pLogStore, pEntry); - // ths->pFsm->FpPreCommitCb(0) + // only myself, maybe commit + syncNodeMaybeAdvanceCommitIndex(ths); // start replicate right now! syncNodeReplicate(ths); - syncEntryDestory(pEntry); + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + assert(ths->pFsm != NULL); + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } + rpcFreeCont(rpcMsg.pCont); + } else { - // ths->pFsm->FpCommitCb(-1) + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + assert(ths->pFsm != NULL); + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, -1); + } + rpcFreeCont(rpcMsg.pCont); } + syncEntryDestory(pEntry); return ret; } From e5b0e1465d47e783a7a0a22a05ba78d98cf9acac Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Thu, 17 Mar 2022 16:33:10 +0800 Subject: [PATCH 30/60] sync refactor --- source/libs/sync/src/syncCommit.c | 22 ++++++++++++++++++++++ source/libs/sync/src/syncMain.c | 14 ++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 850468f393..25835edc92 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -15,6 +15,7 @@ #include "syncIndexMgr.h" #include "syncInt.h" +#include "syncRaftLog.h" // \* Leader i advances its commitIndex. // \* This is done as a separate step from handling AppendEntries responses, @@ -42,4 +43,25 @@ void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pNextIndex", pSyncNode->pNextIndex); syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pMatchIndex", pSyncNode->pMatchIndex); + + // update commit index + + if (pSyncNode->pFsm != NULL) { + SyncIndex beginIndex = SYNC_INDEX_INVALID; + SyncIndex endIndex = SYNC_INDEX_INVALID; + for (SyncIndex i = beginIndex; i <= endIndex; ++i) { + SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, i); + assert(pEntry != NULL); + + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + if (pSyncNode->pFsm->FpCommitCb != NULL) { + pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } + + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pEntry); + } + } } \ No newline at end of file diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index c716a17df8..1f3e709a27 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -749,9 +749,10 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); - assert(ths->pFsm != NULL); - if (ths->pFsm->FpPreCommitCb != NULL) { - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + if (ths->pFsm != NULL) { + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } } rpcFreeCont(rpcMsg.pCont); @@ -760,9 +761,10 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg SRpcMsg rpcMsg; syncEntry2OriginalRpc(pEntry, &rpcMsg); - assert(ths->pFsm != NULL); - if (ths->pFsm->FpPreCommitCb != NULL) { - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, -1); + if (ths->pFsm != NULL) { + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, -1); + } } rpcFreeCont(rpcMsg.pCont); } From 1c40afc67c31676694dd1ec9c9550ec641ec4c6d Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Thu, 17 Mar 2022 17:48:21 +0800 Subject: [PATCH 31/60] add tmq_get_row --- include/client/taos.h | 50 ++++++++------ include/common/tdatablock.h | 23 +++++-- include/common/tmsg.h | 27 +++++++- include/common/tmsgdef.h | 1 + source/client/src/tmq.c | 36 +++++++++- source/dnode/mnode/impl/src/mndDef.c | 34 ++++++++++ source/dnode/mnode/impl/src/mndScheduler.c | 78 ++++++++++++++++++++++ source/dnode/mnode/impl/src/mndStream.c | 12 ++-- source/dnode/vnode/inc/tq.h | 1 + source/dnode/vnode/src/inc/tqInt.h | 1 + source/dnode/vnode/src/tq/tq.c | 17 +++++ source/dnode/vnode/src/vnd/vnodeWrite.c | 11 ++- 12 files changed, 252 insertions(+), 39 deletions(-) diff --git a/include/client/taos.h b/include/client/taos.h index 66e3c491c7..a102629efa 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -31,27 +31,27 @@ typedef void TAOS_SUB; typedef void **TAOS_ROW; // Data type definition -#define TSDB_DATA_TYPE_NULL 0 // 1 bytes -#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes -#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte -#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes -#define TSDB_DATA_TYPE_INT 4 // 4 bytes -#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes -#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes -#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes -#define TSDB_DATA_TYPE_VARCHAR 8 // string, alias for varchar -#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes -#define TSDB_DATA_TYPE_NCHAR 10 // unicode string -#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte -#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes -#define TSDB_DATA_TYPE_UINT 13 // 4 bytes -#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes -#define TSDB_DATA_TYPE_JSON 15 // json string -#define TSDB_DATA_TYPE_VARBINARY 16 // binary -#define TSDB_DATA_TYPE_DECIMAL 17 // decimal -#define TSDB_DATA_TYPE_BLOB 18 // binary +#define TSDB_DATA_TYPE_NULL 0 // 1 bytes +#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes +#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte +#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes +#define TSDB_DATA_TYPE_INT 4 // 4 bytes +#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes +#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes +#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes +#define TSDB_DATA_TYPE_VARCHAR 8 // string, alias for varchar +#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes +#define TSDB_DATA_TYPE_NCHAR 10 // unicode string +#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte +#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes +#define TSDB_DATA_TYPE_UINT 13 // 4 bytes +#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes +#define TSDB_DATA_TYPE_JSON 15 // json string +#define TSDB_DATA_TYPE_VARBINARY 16 // binary +#define TSDB_DATA_TYPE_DECIMAL 17 // decimal +#define TSDB_DATA_TYPE_BLOB 18 // binary #define TSDB_DATA_TYPE_MEDIUMBLOB 19 -#define TSDB_DATA_TYPE_BINARY TSDB_DATA_TYPE_VARCHAR // string +#define TSDB_DATA_TYPE_BINARY TSDB_DATA_TYPE_VARCHAR // string typedef enum { TSDB_OPTION_LOCALE, @@ -257,9 +257,15 @@ DLL_EXPORT void tmq_conf_set_offset_commit_cb(tmq_conf_t *conf, tmq_co void tmqShowMsg(tmq_message_t *tmq_message); int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message); -typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code); +/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */ -DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT* stmt); +DLL_EXPORT TAOS_ROW tmq_get_row(tmq_message_t *message); +DLL_EXPORT char *tmq_get_topic_name(tmq_message_t *message); + +/* ---------------------- OTHER ---------------------------- */ +typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB *tsub, TAOS_RES *res, void *param, int code); + +DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt); #ifdef __cplusplus } diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 7e60013aa1..17e019d977 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -52,6 +52,21 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet); BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \ } while (0) +static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData, uint32_t row) { + if (!pColumnInfoData->hasNull) { + return false; + } + if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { + return pColumnInfoData->varmeta.offset[row] == -1; + } else { + if (pColumnInfoData->nullbitmap == NULL) { + return false; + } + + return colDataIsNull_f(pColumnInfoData->nullbitmap, row); + } +} + static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, uint32_t totalRows, uint32_t row, SColumnDataAgg* pColAgg) { if (!pColumnInfoData->hasNull) { @@ -79,10 +94,10 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u } } -#define BitmapLen(_n) (((_n) + ((1<> NBIT) +#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) - -#define colDataGetData(p1_, r_) \ +// SColumnInfoData, rowNumber +#define colDataGetData(p1_, r_) \ ((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \ : ((p1_)->pData + ((r_) * (p1_)->info.bytes))) @@ -126,4 +141,4 @@ void* blockDataDestroy(SSDataBlock* pBlock); } #endif -#endif /*_TD_COMMON_EP_H_*/ +#endif /*_TD_COMMON_EP_H_*/ diff --git a/include/common/tmsg.h b/include/common/tmsg.h index b449cad2a1..551035a065 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -419,7 +419,7 @@ typedef struct { }; } SColumnFilterList; /* - * for client side struct, we only need the column id, type, bytes are not necessary + * for client side struct, only column id, type, bytes are necessary * But for data in vnode side, we need all the following information. */ typedef struct { @@ -2173,13 +2173,36 @@ typedef struct { SArray* topics; // SArray } SMqCMGetSubEpRsp; -struct tmq_message_t { +typedef struct { SMqRspHead head; union { SMqPollRsp consumeRsp; SMqCMGetSubEpRsp getEpRsp; }; void* extra; +} SMqMsgWrapper; + +typedef struct { + int32_t curBlock; + int32_t curRow; + void** uData; +} SMqRowIter; + +struct tmq_message_t_v1 { + SMqPollRsp rsp; + SMqRowIter iter; +}; + +struct tmq_message_t { + SMqRspHead head; + union { + SMqPollRsp consumeRsp; + SMqCMGetSubEpRsp getEpRsp; + }; + void* extra; + int32_t curBlock; + int32_t curRow; + void** uData; }; static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { taosArrayDestroy(pSubTopicEp->vgs); } diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 6a07887721..a596794b3d 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -189,6 +189,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_SUBSCRIBE, "vnode-subscribe", SMVSubscribeReq, SMVSubscribeRsp) TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqCVConsumeReq, SMqCVConsumeRsp) + TD_DEF_MSG_TYPE(TDMT_VND_TASK_DEPLOY, "vnode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL) diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 0ddd53be08..ee13527b96 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -700,6 +700,10 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { } memcpy(pRsp, pMsg->pData, sizeof(SMqRspHead)); tDecodeSMqPollRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRsp->consumeRsp); + pRsp->curBlock = 0; + pRsp->curRow = 0; + // TODO: alloc mem + /*pRsp->*/ /*printf("rsp commit off:%ld rsp off:%ld has data:%d\n", pRsp->committedOffset, pRsp->rspOffset, pRsp->numOfTopics);*/ if (pRsp->consumeRsp.numOfTopics == 0) { /*printf("no data\n");*/ @@ -758,9 +762,9 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) { goto END; } - // tmq's epoch is monotomically increase, + // tmq's epoch is monotonically increase, // so it's safe to discard any old epoch msg. - // epoch will only increase when received newer epoch ep msg + // Epoch will only increase when received newer epoch ep msg SMqRspHead* head = pMsg->pData; int32_t epoch = atomic_load_32(&tmq->epoch); if (head->epoch <= epoch) { @@ -1282,6 +1286,34 @@ const char* tmq_err2str(tmq_resp_err_t err) { return "fail"; } +TAOS_ROW tmq_get_row(tmq_message_t* message) { + SMqPollRsp* rsp = &message->consumeRsp; + while (1) { + if (message->curBlock < taosArrayGetSize(rsp->pBlockData)) { + SSDataBlock* pBlock = taosArrayGet(rsp->pBlockData, message->curBlock); + if (message->curRow < pBlock->info.rows) { + for (int i = 0; i < pBlock->info.numOfCols; i++) { + SColumnInfoData* pData = taosArrayGet(pBlock->pDataBlock, i); + if (colDataIsNull_s(pData, message->curRow)) + message->uData[i] = NULL; + else { + message->uData[i] = colDataGetData(pData, message->curRow); + } + } + message->curRow++; + return message->uData; + } else { + message->curBlock++; + message->curRow = 0; + continue; + } + } + return NULL; + } +} + +char* tmq_get_topic_name(tmq_message_t* message) { return "not implemented yet"; } + #if 0 tmq_t* tmqCreateConsumerImpl(TAOS* conn, tmq_conf_t* conf) { tmq_t* pTmq = malloc(sizeof(tmq_t)); diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index cc5bf843ce..f81dead325 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -27,6 +27,22 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) { if (tEncodeCStr(pEncoder, pObj->sql) < 0) return -1; if (tEncodeCStr(pEncoder, pObj->logicalPlan) < 0) return -1; if (tEncodeCStr(pEncoder, pObj->physicalPlan) < 0) return -1; + // TODO encode tasks + if (pObj->tasks) { + int32_t sz = taosArrayGetSize(pObj->tasks); + tEncodeI32(pEncoder, sz); + for (int32_t i = 0; i < sz; i++) { + SArray *pArray = taosArrayGet(pObj->tasks, i); + int32_t innerSz = taosArrayGetSize(pArray); + tEncodeI32(pEncoder, innerSz); + for (int32_t j = 0; j < innerSz; j++) { + SStreamTask *pTask = taosArrayGet(pArray, j); + tEncodeSStreamTask(pEncoder, pTask); + } + } + } else { + tEncodeI32(pEncoder, 0); + } return pEncoder->pos; } @@ -42,5 +58,23 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) { if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1; if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1; if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1; + int32_t sz; + if (tDecodeI32(pDecoder, &sz) < 0) return -1; + if (sz != 0) { + pObj->tasks = taosArrayInit(sz, sizeof(SArray)); + for (int32_t i = 0; i < sz; i++) { + int32_t innerSz; + if (tDecodeI32(pDecoder, &innerSz) < 0) return -1; + SArray *pArray = taosArrayInit(innerSz, sizeof(SStreamTask)); + for (int32_t j = 0; j < innerSz; j++) { + SStreamTask task; + if (tDecodeSStreamTask(pDecoder, &task) < 0) return -1; + taosArrayPush(pArray, &task); + } + taosArrayPush(pObj->tasks, pArray); + } + } else { + pObj->tasks = NULL; + } return 0; } diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 16b1ba8a5c..faef757e76 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -77,6 +77,32 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { return -1; } taosArrayPush(taskOneLevel, pTask); + + SCoder encoder; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + int32_t tlen = sizeof(SMsgHead) + encoder.pos; + tCoderClear(&encoder); + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + ((SMsgHead*)buf)->streamTaskId = pTask->taskId; + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + tCoderInit(&encoder, TD_LITTLE_ENDIAN, abuf, tlen, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + tCoderClear(&encoder); + + STransAction action = {0}; + action.epSet = plan->execNode.epSet; + action.pCont = buf; + action.contLen = tlen; + action.msgType = TDMT_VND_TASK_DEPLOY; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + rpcFreeCont(buf); + return -1; + } } } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { // duplicatable @@ -101,6 +127,32 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { } taosArrayPush(taskOneLevel, pTask); + + SCoder encoder; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + int32_t tlen = sizeof(SMsgHead) + encoder.pos; + tCoderClear(&encoder); + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + ((SMsgHead*)buf)->streamTaskId = pTask->taskId; + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + tCoderInit(&encoder, TD_LITTLE_ENDIAN, abuf, tlen, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + tCoderClear(&encoder); + + STransAction action = {0}; + action.epSet = plan->execNode.epSet; + action.pCont = buf; + action.contLen = tlen; + action.msgType = TDMT_SND_TASK_DEPLOY; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + rpcFreeCont(buf); + return -1; + } } } else { // not duplicatable @@ -117,6 +169,32 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { return -1; } taosArrayPush(taskOneLevel, pTask); + + SCoder encoder; + tCoderInit(&encoder, TD_LITTLE_ENDIAN, NULL, 0, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + int32_t tlen = sizeof(SMsgHead) + encoder.pos; + tCoderClear(&encoder); + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + ((SMsgHead*)buf)->streamTaskId = pTask->taskId; + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + tCoderInit(&encoder, TD_LITTLE_ENDIAN, abuf, tlen, TD_ENCODER); + tEncodeSStreamTask(&encoder, pTask); + tCoderClear(&encoder); + + STransAction action = {0}; + action.epSet = plan->execNode.epSet; + action.pCont = buf; + action.contLen = tlen; + action.msgType = TDMT_SND_TASK_DEPLOY; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + rpcFreeCont(buf); + return -1; + } } taosArrayPush(pStream->tasks, taskOneLevel); } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 67011dfe8a..af0f354c11 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -230,6 +230,12 @@ static int32_t mndCreateStream(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateStreamR } mDebug("trans:%d, used to create stream:%s", pTrans->id, pCreate->name); + if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { + mError("stream:%ld, schedule stream since %s", streamObj.uid, terrstr()); + mndTransDrop(pTrans); + return -1; + } + SSdbRaw *pRedoRaw = mndStreamActionEncode(&streamObj); if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); @@ -238,12 +244,6 @@ static int32_t mndCreateStream(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateStreamR } sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); - if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { - mError("stream:%ld, schedule stream since %s", streamObj.uid, terrstr()); - mndTransDrop(pTrans); - return -1; - } - if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mndTransDrop(pTrans); diff --git a/source/dnode/vnode/inc/tq.h b/source/dnode/vnode/inc/tq.h index b4d45e83fb..8d8ed2e427 100644 --- a/source/dnode/vnode/inc/tq.h +++ b/source/dnode/vnode/inc/tq.h @@ -55,6 +55,7 @@ int tqCommit(STQ*); int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessSetConnReq(STQ* pTq, char* msg); int32_t tqProcessRebReq(STQ* pTq, char* msg); +int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen); #ifdef __cplusplus } diff --git a/source/dnode/vnode/src/inc/tqInt.h b/source/dnode/vnode/src/inc/tqInt.h index fc6a3699d5..9b21cf92ce 100644 --- a/source/dnode/vnode/src/inc/tqInt.h +++ b/source/dnode/vnode/src/inc/tqInt.h @@ -161,6 +161,7 @@ struct STQ { STqMemRef tqMemRef; STqMetaStore* tqMeta; STqPushMgr* tqPushMgr; + SHashObj* pStreamTasks; SWal* pWal; SMeta* pVnodeMeta; }; diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index d15481b4aa..8cdc250e8d 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -55,6 +55,8 @@ STQ* tqOpen(const char* path, SWal* pWal, SMeta* pVnodeMeta, STqCfg* tqConfig, S return NULL; } + pTq->pStreamTasks = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + return pTq; } @@ -416,3 +418,18 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) { terrno = TSDB_CODE_SUCCESS; return 0; } + +int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) { + SStreamTask* pTask = malloc(sizeof(SStreamTask)); + if (pTask == NULL) { + return -1; + } + SCoder decoder; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, (uint8_t*)msg, msgLen, TD_DECODER); + tDecodeSStreamTask(&decoder, pTask); + tCoderClear(&decoder); + + taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), pTask, sizeof(SStreamTask)); + + return 0; +} diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index aba8100478..218b53c2ab 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -41,7 +41,7 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { return 0; } -int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { +int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { void *ptr = NULL; if (pVnode->config.streamMode == 0) { @@ -63,7 +63,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { switch (pMsg->msgType) { case TDMT_VND_CREATE_STB: { - SVCreateTbReq vCreateTbReq = {0}; + SVCreateTbReq vCreateTbReq = {0}; tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbReq); if (metaCreateTable(pVnode->pMeta, &(vCreateTbReq)) < 0) { // TODO: handle error @@ -100,7 +100,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { break; } case TDMT_VND_ALTER_STB: { - SVCreateTbReq vAlterTbReq = {0}; + SVCreateTbReq vAlterTbReq = {0}; vTrace("vgId:%d, process alter stb req", pVnode->vgId); tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vAlterTbReq); free(vAlterTbReq.stbCfg.pSchema); @@ -132,6 +132,11 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { if (tqProcessRebReq(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) { } } break; + case TDMT_VND_TASK_DEPLOY: { + if (tqProcessTaskDeploy(pVnode->pTq, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), + pMsg->contLen - sizeof(SMsgHead)) < 0) { + } + } break; case TDMT_VND_CREATE_SMA: { // timeRangeSMA SSmaCfg vCreateSmaReq = {0}; if (tDeserializeSVCreateTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateSmaReq) == NULL) { From b44ef3c81ea29155c27175474a60174a2f145d64 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 17 Mar 2022 18:16:57 +0800 Subject: [PATCH 32/60] use dataDir to init sma env --- include/libs/tfs/tfs.h | 10 +++ source/dnode/mgmt/daemon/src/dmnMain.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 79 ++++++++++++++--------- source/dnode/vnode/test/tsdbSmaTest.cpp | 8 ++- source/libs/tfs/src/tfs.c | 5 ++ tests/pytest/crash_gen/service_manager.py | 2 +- 6 files changed, 71 insertions(+), 35 deletions(-) diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h index 1b41da33bb..1dc154ce48 100644 --- a/include/libs/tfs/tfs.h +++ b/include/libs/tfs/tfs.h @@ -198,6 +198,16 @@ void tfsBasename(const STfsFile *pFile, char *dest); */ void tfsDirname(const STfsFile *pFile, char *dest); +/** + * @brief Get the absolute file name of rname. + * + * @param pTfs + * @param diskId + * @param rname relative file name + * @param aname absolute file name + */ +void tfsAbsoluteName(STfs *pTfs, SDiskID diskId, const char *rname, char *aname); + /** * @brief Remove file in tfs. * diff --git a/source/dnode/mgmt/daemon/src/dmnMain.c b/source/dnode/mgmt/daemon/src/dmnMain.c index 7ba272453c..3d4de18dcb 100644 --- a/source/dnode/mgmt/daemon/src/dmnMain.c +++ b/source/dnode/mgmt/daemon/src/dmnMain.c @@ -27,7 +27,7 @@ static struct { } dmn = {0}; static void dmnSigintHandle(int signum, void *info, void *ctx) { - uInfo("singal:%d is received", signum); + uInfo("signal:%d is received", signum); dmn.stop = true; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7a5c9c5c1e..f3135c690e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -20,8 +20,7 @@ static const char *TSDB_SMA_DNAME[] = { "tsma", // TSDB_SMA_TYPE_TIME_RANGE "rsma", // TSDB_SMA_TYPE_ROLLUP }; -#define SMA_CHECK_HASH -#undef SMA_PRINT_DEBUG_LOG +#undef _TEST_SMA_PRINT_DEBUG_LOG_ #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 #define SMA_STORAGE_SPLIT_HOURS 24 @@ -33,8 +32,8 @@ static const char *TSDB_SMA_DNAME[] = { #define SMA_TEST_INDEX_NAME "smaTestIndexName" // TODO: just for test #define SMA_TEST_INDEX_UID 2000000001 // TODO: just for test typedef enum { - SMA_STORAGE_LEVEL_TSDB = 0, // use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2t200.dat - SMA_STORAGE_LEVEL_DFILESET = 1 // use days of TS data e.g. vnode${N}/tsdb/rsma/sma_index_uid/v2r200.dat + SMA_STORAGE_LEVEL_TSDB = 0, // use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f200.tsma + SMA_STORAGE_LEVEL_DFILESET = 1 // use days of TS data e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2f1906.tsma } ESmaStorageLevel; typedef struct { @@ -47,6 +46,7 @@ typedef struct { int32_t iter; int32_t fid; } SmaFsIter; + typedef struct { STsdb * pTsdb; SDBFile dFile; @@ -71,11 +71,12 @@ typedef struct { } SSmaStatItem; struct SSmaStat { - SHashObj *smaStatItems; // key: indexName, value: SSmaStatItem + SHashObj *smaStatItems; // key: indexUid, value: SSmaStatItem T_REF_DECLARE() }; // declaration of static functions + // expired window static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); @@ -159,22 +160,12 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_SUCCESS; } - if (tsdbLockRepo(pTsdb) != 0) { - return TSDB_CODE_FAILED; - } - - if (*pEnv == NULL) { // 2nd phase check + if (*pEnv == NULL) { if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { - tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } } - if (tsdbUnlockRepo(pTsdb) != 0) { - *pEnv = tsdbFreeSmaEnv(*pEnv); - return TSDB_CODE_FAILED; - } - return TSDB_CODE_SUCCESS; } @@ -279,6 +270,7 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { + // return if already init switch (smaType) { case TSDB_SMA_TYPE_TIME_RANGE: if (pTsdb->pTSmaEnv) { @@ -295,18 +287,39 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_FAILED; } - // SDiskID did = {0}; - SSmaEnv *pEnv = NULL; - char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; - if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_FAILED; - } + // init sma env + tsdbLockRepo(pTsdb); + if (pTsdb->pTSmaEnv == NULL) { + char rname[TSDB_FILENAME_LEN] = {0}; + char aname[TSDB_FILENAME_LEN * 2 + 32] = {0}; // TODO: make TMPNAME_LEN public as TSDB_FILENAME_LEN? - if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - pTsdb->pTSmaEnv = pEnv; - } else { - pTsdb->pRSmaEnv = pEnv; + SDiskID did = {0}; + tfsAllocDisk(pTsdb->pTfs, TFS_PRIMARY_LEVEL, &did); + if (did.level < 0 || did.id < 0) { + tsdbUnlockRepo(pTsdb); + return TSDB_CODE_FAILED; + } + tsdbGetSmaDir(REPO_ID(pTsdb), smaType, rname); + tfsAbsoluteName(pTsdb->pTfs, did, rname, aname); + + if (tfsMkdirRecurAt(pTsdb->pTfs, rname, did) != TSDB_CODE_SUCCESS) { + tsdbUnlockRepo(pTsdb); + return TSDB_CODE_FAILED; + } + + SSmaEnv *pEnv = NULL; + if (tsdbInitSmaEnv(pTsdb, aname, &pEnv) != TSDB_CODE_SUCCESS) { + tsdbUnlockRepo(pTsdb); + return TSDB_CODE_FAILED; + } + + if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { + pTsdb->pTSmaEnv = pEnv; + } else { + pTsdb->pRSmaEnv = pEnv; + } } + tsdbUnlockRepo(pTsdb); return TSDB_CODE_SUCCESS; }; @@ -379,7 +392,7 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { int8_t state = TSDB_SMA_STAT_EXPIRED; for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) { - if (taosHashPut(pItem->expiredWindows, (void *)(expiredWindows + i), sizeof(TSKEY), &state, sizeof(state)) != 0) { + if (taosHashPut(pItem->expiredWindows, expiredWindows + i, sizeof(TSKEY), &state, sizeof(state)) != 0) { // If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would // tell query module to query raw TS data. // N.B. @@ -497,12 +510,12 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k return TSDB_CODE_FAILED; } -#ifdef SMA_PRINT_DEBUG_LOG +#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ uint32_t valueSize = 0; void * data = tsdbGetSmaDataByKey(pDBFile, smaKey, keyLen, &valueSize); ASSERT(data != NULL); for (uint32_t v = 0; v < valueSize; v += 8) { - tsdbWarn("vgId:%d sma data - val[%d] is %" PRIi64, REPO_ID(pSmaH->pTsdb), v, *(int64_t *)POINTER_SHIFT(data, v)); + tsdbWarn("vgId:%d insert sma data val[%d] %" PRIi64, REPO_ID(pSmaH->pTsdb), v, *(int64_t *)POINTER_SHIFT(data, v)); } #endif return TSDB_CODE_SUCCESS; @@ -935,12 +948,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ tsdbCloseDBF(&tReadH.dFile); return TSDB_CODE_FAILED; } - tfree(result); -#ifdef SMA_PRINT_DEBUG_LOG + +#ifdef _TEST_SMA_PRINT_DEBUG_LOG_ for (uint32_t v = 0; v < valueSize; v += 8) { - tsdbWarn("vgId:%d v[%d]=%" PRIi64, REPO_ID(pTsdb), v, *(int64_t *)POINTER_SHIFT(result, v)); + tsdbWarn("vgId:%d get sma data v[%d]=%" PRIi64, REPO_ID(pTsdb), v, *(int64_t *)POINTER_SHIFT(result, v)); } #endif + tfree(result); // TODO: fill the result to output + #if 0 int32_t nResult = 0; int64_t lastKey = 0; diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index ae4e9b0a75..86958da406 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -301,8 +301,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { break; } + SDiskCfg pDisks = {.level = 0, .primary = 1}; + strncpy(pDisks.dir, "/var/lib/taos", TSDB_FILENAME_LEN); + int32_t numOfDisks = 1; + tsdb.pTfs = tfsOpen(&pDisks, numOfDisks); + ASSERT_NE(tsdb.pTfs, nullptr); + char *msg = (char *)calloc(1, 100); - assert(msg != NULL); + ASSERT_NE(msg, nullptr); ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); // init diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index 01e9808aa6..97b8912b60 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -202,6 +202,11 @@ void tfsDirname(const STfsFile *pFile, char *dest) { tstrncpy(dest, taosDirName(tname), TSDB_FILENAME_LEN); } +void tfsAbsoluteName(STfs *pTfs, SDiskID diskId, const char *rname, char *aname) { + STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId); + snprintf(aname, TMPNAME_LEN, "%s%s%s", pDisk->path, TD_DIRSEP, rname); +} + int32_t tfsRemoveFile(const STfsFile *pFile) { return taosRemoveFile(pFile->aname); } int32_t tfsCopyFile(const STfsFile *pFile1, const STfsFile *pFile2) { diff --git a/tests/pytest/crash_gen/service_manager.py b/tests/pytest/crash_gen/service_manager.py index c6685ec469..c0cfd33123 100644 --- a/tests/pytest/crash_gen/service_manager.py +++ b/tests/pytest/crash_gen/service_manager.py @@ -378,7 +378,7 @@ class TdeSubProcess: @classmethod def _stopForSure(cls, proc: Popen, sig: int): ''' - Stop a process and all sub processes with a singal, and SIGKILL if necessary + Stop a process and all sub processes with a signal, and SIGKILL if necessary ''' def doKillTdService(proc: Popen, sig: int): Logging.info("Killing sub-sub process {} with signal {}".format(proc.pid, sig)) From d49adcd4f57074382c1934a6959fda9732b6e1ad Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 17 Mar 2022 06:44:45 -0400 Subject: [PATCH 33/60] TD-13675 rollup, alter db, alter table syntax definition --- include/common/tmsg.h | 11 +- include/libs/nodes/cmdnodes.h | 7 +- include/libs/nodes/nodes.h | 1 + source/libs/nodes/src/nodesUtilFuncs.c | 13 +- source/libs/parser/inc/sql.y | 14 +- source/libs/parser/src/parAstCreater.c | 33 +- source/libs/parser/src/parTranslater.c | 58 +++ source/libs/planner/src/planLogicCreater.c | 521 +++++++++++++-------- 8 files changed, 433 insertions(+), 225 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a837dd9708..d19193d764 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -111,15 +111,16 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_MAX, } EShowType; -#define TSDB_ALTER_TABLE_ADD_TAG 1 -#define TSDB_ALTER_TABLE_DROP_TAG 2 -#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3 -#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4 - +#define TSDB_ALTER_TABLE_ADD_TAG 1 +#define TSDB_ALTER_TABLE_DROP_TAG 2 +#define TSDB_ALTER_TABLE_UPDATE_TAG_NAME 3 +#define TSDB_ALTER_TABLE_UPDATE_TAG_VAL 4 #define TSDB_ALTER_TABLE_ADD_COLUMN 5 #define TSDB_ALTER_TABLE_DROP_COLUMN 6 #define TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES 7 #define TSDB_ALTER_TABLE_UPDATE_TAG_BYTES 8 +#define TSDB_ALTER_TABLE_UPDATE_OPTIONS 9 +#define TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME 10 #define TSDB_FILL_NONE 0 #define TSDB_FILL_NULL 1 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 7508b71785..5dbfd6c2c2 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -131,7 +131,12 @@ typedef struct SAlterTableStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; char tableName[TSDB_TABLE_NAME_LEN]; - // todo + int8_t alterType; + char colName[TSDB_COL_NAME_LEN]; + char newColName[TSDB_COL_NAME_LEN]; + STableOptions* pOptions; + SDataType dataType; + SValueNode* pVal; } SAlterTableStmt; typedef struct SCreateUserStmt { diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 6825fe470a..d7e67be9e0 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -166,6 +166,7 @@ SNodeList* nodesMakeList(); int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode); int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode); int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); +int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); SNodeptr nodesListGetNode(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 0fabb00040..48b9c3e094 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -359,6 +359,17 @@ int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc) { return TSDB_CODE_SUCCESS; } +int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) { + if (NULL == pSrc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + int32_t code = nodesListAppendList(pTarget, pSrc); + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyList(pSrc); + } + return code; +} + SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) { if (NULL == pCell->pPrev) { pList->pHead = pCell->pNext; @@ -573,7 +584,7 @@ typedef struct SCollectFuncsCxt { static EDealRes collectFuncs(SNode* pNode, void* pContext) { SCollectFuncsCxt* pCxt = (SCollectFuncsCxt*)pContext; if (QUERY_NODE_FUNCTION == nodeType(pNode) && pCxt->classifier(((SFunctionNode*)pNode)->funcId)) { - pCxt->errCode = nodesListAppend(pCxt->pFuncs, pNode); + pCxt->errCode = nodesListStrictAppend(pCxt->pFuncs, nodesCloneNode(pNode)); return (TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_IGNORE_CHILD : DEAL_RES_ERROR); } return DEAL_RES_CONTINUE; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index aa8ced8d7e..2298ae0761 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -181,18 +181,18 @@ cmd ::= ALTER STABLE alter_table_clause(A). alter_table_clause(A) ::= full_table_name(B) alter_table_options(C). { A = createAlterTableOption(pCxt, B, C); } alter_table_clause(A) ::= full_table_name(B) ADD COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } -alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C); } +alter_table_clause(A) ::= full_table_name(B) DROP COLUMN column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_COLUMN, &C); } alter_table_clause(A) ::= - full_table_name(B) MODIFY COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } + full_table_name(B) MODIFY COLUMN column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &C, D); } alter_table_clause(A) ::= - full_table_name(B) RENAME COLUMN column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, &D); } + full_table_name(B) RENAME COLUMN column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &C, &D); } alter_table_clause(A) ::= - full_table_name(B) ADD TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } -alter_table_clause(A) ::= full_table_name(B) DROP TAG column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C); } + full_table_name(B) ADD TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_TAG, &C, D); } +alter_table_clause(A) ::= full_table_name(B) DROP TAG column_name(C). { A = createAlterTableDropCol(pCxt, B, TSDB_ALTER_TABLE_DROP_TAG, &C); } alter_table_clause(A) ::= - full_table_name(B) MODIFY TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, D); } + full_table_name(B) MODIFY TAG column_name(C) type_name(D). { A = createAlterTableAddModifyCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &C, D); } alter_table_clause(A) ::= - full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_ADD_COLUMN, &C, &D); } + full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); } alter_table_clause(A) ::= full_table_name(B) SET TAG column_name(C) NK_EQ literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 764f545ce3..eed6391d5c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -961,23 +961,46 @@ SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, S } SNode* createAlterTableOption(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { - + SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS; + pStmt->pOptions = (STableOptions*)pOptions; + return (SNode*)pStmt; } SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName, SDataType dataType) { - + SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->alterType = alterType; + strncpy(pStmt->colName, pColName->z, pColName->n); + pStmt->dataType = dataType; + return (SNode*)pStmt; } SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName) { - + SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->alterType = alterType; + strncpy(pStmt->colName, pColName->z, pColName->n); + return (SNode*)pStmt; } SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pOldColName, const SToken* pNewColName) { - + SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->alterType = alterType; + strncpy(pStmt->colName, pOldColName->z, pOldColName->n); + strncpy(pStmt->newColName, pNewColName->z, pNewColName->n); + return (SNode*)pStmt; } SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal) { - + SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_TAG_VAL; + strncpy(pStmt->colName, pTagName->z, pTagName->n); + pStmt->pVal = (SValueNode*)pVal; + return (SNode*)pStmt; } SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index e852a21c4e..03206e89cb 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -962,8 +962,56 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS return doTranslateDropSuperTable(pCxt, &tableName, pStmt->ignoreNotExists); } +static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterReq) { + pAlterReq->pFields = taosArrayInit(2, sizeof(TAOS_FIELD)); + if (NULL == pAlterReq->pFields) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + switch (pStmt->alterType) { + case TSDB_ALTER_TABLE_ADD_TAG: + case TSDB_ALTER_TABLE_DROP_TAG: + case TSDB_ALTER_TABLE_ADD_COLUMN: + case TSDB_ALTER_TABLE_DROP_COLUMN: + case TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES: + case TSDB_ALTER_TABLE_UPDATE_TAG_BYTES: { + TAOS_FIELD field = { .type = pStmt->dataType.type, .bytes = pStmt->dataType.bytes }; + strcpy(field.name, pStmt->colName); + taosArrayPush(pAlterReq->pFields, &field); + break; + } + case TSDB_ALTER_TABLE_UPDATE_TAG_NAME: + case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: { + TAOS_FIELD oldField = {0}; + strcpy(oldField.name, pStmt->colName); + taosArrayPush(pAlterReq->pFields, &oldField); + TAOS_FIELD newField = {0}; + strcpy(oldField.name, pStmt->newColName); + taosArrayPush(pAlterReq->pFields, &newField); + break; + } + default: + break; + } + + return TSDB_CODE_SUCCESS; +} + static int32_t translateAlterTable(STranslateContext* pCxt, SAlterTableStmt* pStmt) { SMAltertbReq alterReq = {0}; + SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(tableName.dbname, pStmt->dbName); + strcpy(tableName.tname, pStmt->tableName); + tNameExtractFullName(&tableName, alterReq.name); + alterReq.alterType = pStmt->alterType; + alterReq.numOfFields = 1; + if (TSDB_ALTER_TABLE_UPDATE_OPTIONS == pStmt->alterType) { + // todo + } else { + if (TSDB_CODE_SUCCESS != setAlterTableField(pStmt, &alterReq)) { + return TSDB_CODE_OUT_OF_MEMORY; + } + } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); if (NULL == pCxt->pCmdMsg) { @@ -1910,6 +1958,11 @@ static int32_t rewriteCreateMultiTable(STranslateContext* pCxt, SQuery* pQuery) return rewriteToVnodeModifOpStmt(pQuery, pBufArray); } +static int32_t rewriteAlterTable(STranslateContext* pCxt, SQuery* pQuery) { + // todo + return TSDB_CODE_SUCCESS; +} + static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pQuery->pRoot)) { @@ -1921,6 +1974,11 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_CREATE_MULTI_TABLE_STMT: code = rewriteCreateMultiTable(pCxt, pQuery); break; + case QUERY_NODE_ALTER_TABLE_STMT: + if (TSDB_ALTER_TABLE_UPDATE_TAG_VAL == ((SAlterTableStmt*)pQuery->pRoot)->alterType) { + code = rewriteAlterTable(pCxt, pQuery); + } + break; default: break; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index cd9857c7f6..285413c24e 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -18,13 +18,13 @@ #include "functionMgt.h" typedef struct SLogicPlanContext { + SPlanContext* pPlanCxt; int32_t errCode; int32_t planNodeId; - int32_t acctId; } SLogicPlanContext; -static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt); -static SLogicNode* createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable); +static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode); +static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode); typedef struct SRewriteExprCxt { int32_t errCode; @@ -94,123 +94,75 @@ static int32_t rewriteExpr(int32_t planNodeId, int32_t rewriteId, SNodeList* pEx return cxt.errCode; } -static SLogicNode* pushLogicNode(SLogicPlanContext* pCxt, SLogicNode* pRoot, SLogicNode* pNode) { - if (TSDB_CODE_SUCCESS != pCxt->errCode) { - goto error; - } - - if (NULL == pRoot) { - return pNode; - } - - if (NULL == pNode) { - return pRoot; - } - - if (NULL == pNode->pChildren) { - pNode->pChildren = nodesMakeList(); - if (NULL == pNode->pChildren) { - goto error; +static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLogicNode* pNewRoot) { + if (NULL == pNewRoot->pChildren) { + pNewRoot->pChildren = nodesMakeList(); + if (NULL == pNewRoot->pChildren) { + return TSDB_CODE_OUT_OF_MEMORY; } } - if (TSDB_CODE_SUCCESS != nodesListAppend(pNode->pChildren, (SNode*)pRoot)) { - goto error; + if (TSDB_CODE_SUCCESS != nodesListAppend(pNewRoot->pChildren, (SNode*)*pOldRoot)) { + return TSDB_CODE_OUT_OF_MEMORY; } - pRoot->pParent = pNode; - return pNode; -error: - nodesDestroyNode((SNode*)pNode); - return pRoot; + + (*pOldRoot)->pParent = pNewRoot; + *pOldRoot = pNewRoot; + + return TSDB_CODE_SUCCESS; } -static SLogicNode* createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable) { - SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); - CHECK_ALLOC(pScan, NULL); - pScan->node.id = pCxt->planNodeId++; - - TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); - TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); - - // set columns to scan - SNodeList* pCols = NULL; - CHECK_CODE(nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, &pCols), (SLogicNode*)pScan); - if (NULL != pCols) { - pScan->pScanCols = nodesCloneList(pCols); - CHECK_ALLOC(pScan->pScanCols, (SLogicNode*)pScan); +static SColumnNode* createColumnByExpr(SExprNode* pExpr) { + SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + return NULL; } - - // set output - if (NULL != pCols) { - pScan->node.pTargets = nodesCloneList(pCols); - CHECK_ALLOC(pScan->node.pTargets, (SLogicNode*)pScan); - } - - pScan->scanType = SCAN_TYPE_TABLE; - pScan->scanFlag = MAIN_SCAN; - pScan->scanRange = TSWINDOW_INITIALIZER; - pScan->tableName.type = TSDB_TABLE_NAME_T; - pScan->tableName.acctId = pCxt->acctId; - strcpy(pScan->tableName.dbname, pRealTable->table.dbName); - strcpy(pScan->tableName.tname, pRealTable->table.tableName); - - return (SLogicNode*)pScan; + pCol->node.resType = pExpr->resType; + strcpy(pCol->colName, pExpr->aliasName); + return pCol; } -static SLogicNode* createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable) { - SLogicNode* pRoot = createQueryLogicNode(pCxt, pTable->pSubquery); - CHECK_ALLOC(pRoot, NULL); +static int32_t createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pCols) { + SNodeList* pList = nodesMakeList(); + if (NULL == pList) { + return TSDB_CODE_OUT_OF_MEMORY; + } + SNode* pNode; - FOREACH(pNode, pRoot->pTargets) { - strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); + FOREACH(pNode, pExprs) { + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr((SExprNode*)pNode))) { + nodesDestroyList(pList); + return TSDB_CODE_OUT_OF_MEMORY; + } } - return pRoot; + + *pCols = pList; + return TSDB_CODE_SUCCESS; } -static SLogicNode* createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable) { - SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN); - CHECK_ALLOC(pJoin, NULL); - pJoin->node.id = pCxt->planNodeId++; - - pJoin->joinType = pJoinTable->joinType; - - // set left and right node - pJoin->node.pChildren = nodesMakeList(); - CHECK_ALLOC(pJoin->node.pChildren, (SLogicNode*)pJoin); - SLogicNode* pLeft = createLogicNodeByTable(pCxt, pSelect, pJoinTable->pLeft); - CHECK_ALLOC(pLeft, (SLogicNode*)pJoin); - CHECK_CODE(nodesListAppend(pJoin->node.pChildren, (SNode*)pLeft), (SLogicNode*)pJoin); - SLogicNode* pRight = createLogicNodeByTable(pCxt, pSelect, pJoinTable->pRight); - CHECK_ALLOC(pRight, (SLogicNode*)pJoin); - CHECK_CODE(nodesListAppend(pJoin->node.pChildren, (SNode*)pRight), (SLogicNode*)pJoin); - - // set on conditions - if (NULL != pJoinTable->pOnCond) { - pJoin->pOnConditions = nodesCloneNode(pJoinTable->pOnCond); - CHECK_ALLOC(pJoin->pOnConditions, (SLogicNode*)pJoin); +static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { + SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); + if (NULL == pProject) { + return TSDB_CODE_OUT_OF_MEMORY; } - // set the output - pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); - CHECK_ALLOC(pJoin->node.pTargets, (SLogicNode*)pJoin); - SNodeList* pTargets = nodesCloneList(pRight->pTargets); - CHECK_ALLOC(pTargets, (SLogicNode*)pJoin); - nodesListAppendList(pJoin->node.pTargets, pTargets); + int32_t code = TSDB_CODE_SUCCESS; - return (SLogicNode*)pJoin; -} - -static SLogicNode* createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable) { - switch (nodeType(pTable)) { - case QUERY_NODE_REAL_TABLE: - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable); - case QUERY_NODE_TEMP_TABLE: - return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable); - case QUERY_NODE_JOIN_TABLE: - return createJoinLogicNode(pCxt, pSelect, (SJoinTableNode*)pTable); - default: - break; + pProject->pProjections = nodesCloneList(pSelect->pProjectionList); + if (NULL == pProject->pProjections) { + code = TSDB_CODE_OUT_OF_MEMORY; } - return NULL; + + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByProjections(pCxt,pSelect->pProjectionList, &pProject->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pProject; + } else { + nodesDestroyNode(pProject); + } + + return code; } typedef struct SCreateColumnCxt { @@ -245,196 +197,353 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static SNodeList* createColumnByRewriteExps(SLogicPlanContext* pCxt, SNodeList* pExprs) { - SCreateColumnCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pList = nodesMakeList() }; - CHECK_ALLOC(cxt.pList, NULL); +static int32_t createColumnByRewriteExps(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pList) { + SCreateColumnCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pList = (NULL == *pList ? nodesMakeList() : *pList) }; + if (NULL == cxt.pList) { + return TSDB_CODE_OUT_OF_MEMORY; + } nodesWalkList(pExprs, doCreateColumn, &cxt); if (TSDB_CODE_SUCCESS != cxt.errCode) { nodesDestroyList(cxt.pList); - return NULL; + return cxt.errCode; } - return cxt.pList; + if (NULL == *pList) { + *pList = cxt.pList; + } + return cxt.errCode; } -static SLogicNode* createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect) { +static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { SNodeList* pAggFuncs = NULL; - CHECK_CODE(nodesCollectFuncs(pSelect, fmIsAggFunc, &pAggFuncs), NULL); + int32_t code = nodesCollectFuncs(pSelect, fmIsAggFunc, &pAggFuncs); + if (TSDB_CODE_SUCCESS != code) { + return code; + } if (NULL == pAggFuncs && NULL == pSelect->pGroupByList) { - return NULL; + return TSDB_CODE_SUCCESS; } SAggLogicNode* pAgg = (SAggLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG); - CHECK_ALLOC(pAgg, NULL); - pAgg->node.id = pCxt->planNodeId++; + if (NULL == pAgg) { + return TSDB_CODE_OUT_OF_MEMORY; + } // set grouyp keys, agg funcs and having conditions if (NULL != pSelect->pGroupByList) { pAgg->pGroupKeys = nodesCloneList(pSelect->pGroupByList); - CHECK_ALLOC(pAgg->pGroupKeys, (SLogicNode*)pAgg); + if (NULL == pAgg->pGroupKeys) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } - if (NULL != pAggFuncs) { + + if (TSDB_CODE_SUCCESS == code && NULL != pAggFuncs) { pAgg->pAggFuncs = nodesCloneList(pAggFuncs); - CHECK_ALLOC(pAgg->pAggFuncs, (SLogicNode*)pAgg); + if (NULL == pAgg->pAggFuncs) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } // rewrite the expression in subsequent clauses - CHECK_CODE(rewriteExpr(pAgg->node.id, 1, pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY), (SLogicNode*)pAgg); - CHECK_CODE(rewriteExpr(pAgg->node.id, 1 + LIST_LENGTH(pAgg->pGroupKeys), pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY), (SLogicNode*)pAgg); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteExpr(pAgg->node.id, 1, pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY); + } + if (TSDB_CODE_SUCCESS == code) { + code = rewriteExpr(pAgg->node.id, 1 + LIST_LENGTH(pAgg->pGroupKeys), pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); + } - if (NULL != pSelect->pHaving) { + if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pHaving) { pAgg->node.pConditions = nodesCloneNode(pSelect->pHaving); - CHECK_ALLOC(pAgg->node.pConditions, (SLogicNode*)pAgg); + if (NULL == pAgg->node.pConditions) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } // set the output - pAgg->node.pTargets = nodesMakeList(); - CHECK_ALLOC(pAgg->node.pTargets, (SLogicNode*)pAgg); - if (NULL != pAgg->pGroupKeys) { - SNodeList* pTargets = createColumnByRewriteExps(pCxt, pAgg->pGroupKeys); - CHECK_ALLOC(pAgg->node.pTargets, (SLogicNode*)pAgg); - nodesListAppendList(pAgg->node.pTargets, pTargets); + if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pGroupKeys) { + code = createColumnByRewriteExps(pCxt, pAgg->pGroupKeys, &pAgg->node.pTargets); } - if (NULL != pAgg->pAggFuncs) { - SNodeList* pTargets = createColumnByRewriteExps(pCxt, pAgg->pAggFuncs); - CHECK_ALLOC(pTargets, (SLogicNode*)pAgg); - nodesListAppendList(pAgg->node.pTargets, pTargets); + if (TSDB_CODE_SUCCESS == code && NULL != pAgg->pAggFuncs) { + code = createColumnByRewriteExps(pCxt, pAgg->pAggFuncs, &pAgg->node.pTargets); } - - return (SLogicNode*)pAgg; + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pAgg; + } else { + nodesDestroyNode(pAgg); + } + + return code; } -static SLogicNode* createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect) { +static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SIntervalWindowNode* pInterval, SSelectStmt* pSelect, SLogicNode** pLogicNode) { SWindowLogicNode* pWindow = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); - CHECK_ALLOC(pWindow, NULL); - pWindow->node.id = pCxt->planNodeId++; + if (NULL == pWindow) { + return TSDB_CODE_OUT_OF_MEMORY; + } - pWindow->winType = WINDOW_TYPE_INTERVAL; SValueNode* pIntervalNode = (SValueNode*)((SRawExprNode*)(pInterval->pInterval))->pNode; + pWindow->winType = WINDOW_TYPE_INTERVAL; pWindow->interval = pIntervalNode->datum.i; pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0); pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval); + int32_t code = TSDB_CODE_SUCCESS; + if (NULL != pInterval->pFill) { pWindow->pFill = nodesCloneNode(pInterval->pFill); - CHECK_ALLOC(pWindow->pFill, (SLogicNode*)pWindow); + if (NULL == pWindow->pFill) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } - SNodeList* pFuncs = NULL; - CHECK_CODE(nodesCollectFuncs(pSelect, fmIsAggFunc, &pFuncs), NULL); - if (NULL != pFuncs) { - pWindow->pFuncs = nodesCloneList(pFuncs); - CHECK_ALLOC(pWindow->pFuncs, (SLogicNode*)pWindow); + if (TSDB_CODE_SUCCESS == code) { + code = nodesCollectFuncs(pSelect, fmIsAggFunc, &pWindow->pFuncs); } - CHECK_CODE(rewriteExpr(pWindow->node.id, 1, pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW), (SLogicNode*)pWindow); + if (TSDB_CODE_SUCCESS == code) { + code = rewriteExpr(pWindow->node.id, 1, pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW); + } - pWindow->node.pTargets = createColumnByRewriteExps(pCxt, pWindow->pFuncs); - CHECK_ALLOC(pWindow->node.pTargets, (SLogicNode*)pWindow); + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExps(pCxt, pWindow->pFuncs, &pWindow->node.pTargets); + } - return (SLogicNode*)pWindow; + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pWindow; + } else { + nodesDestroyNode(pWindow); + } + + return code; } -static SLogicNode* createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect) { +static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { if (NULL == pSelect->pWindow) { - return NULL; + return TSDB_CODE_SUCCESS; } switch (nodeType(pSelect->pWindow)) { case QUERY_NODE_INTERVAL_WINDOW: - return createWindowLogicNodeByInterval(pCxt, (SIntervalWindowNode*)pSelect->pWindow, pSelect); + return createWindowLogicNodeByInterval(pCxt, (SIntervalWindowNode*)pSelect->pWindow, pSelect, pLogicNode); default: break; } - return NULL; + return TSDB_CODE_FAILED; } -static SNodeList* createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs) { - SNodeList* pList = nodesMakeList(); - CHECK_ALLOC(pList, NULL); - SNode* pNode; - FOREACH(pNode, pExprs) { - SExprNode* pExpr = (SExprNode*)pNode; - SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); - if (NULL == pCol) { - goto error; - } - pCol->node.resType = pExpr->resType; - strcpy(pCol->colName, pExpr->aliasName); - if (TSDB_CODE_SUCCESS != nodesListAppend(pList, (SNode*)pCol)) { - goto error; +static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable, SLogicNode** pLogicNode) { + SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN); + if (NULL == pJoin) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pJoin->joinType = pJoinTable->joinType; + + int32_t code = TSDB_CODE_SUCCESS; + + // set left and right node + pJoin->node.pChildren = nodesMakeList(); + if (NULL == pJoin->node.pChildren) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + + SLogicNode* pLeft = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pLeft, &pLeft); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pLeft); } } - return pList; -error: - nodesDestroyList(pList); - return NULL; + + SLogicNode* pRight = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pRight, &pRight); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pRight); + } + } + + // set on conditions + if (TSDB_CODE_SUCCESS == code && NULL != pJoinTable->pOnCond) { + pJoin->pOnConditions = nodesCloneNode(pJoinTable->pOnCond); + if (NULL == pJoin->pOnConditions) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + // set the output + if (TSDB_CODE_SUCCESS == code) { + pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); + if (NULL == pJoin->pOnConditions) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppendList(pJoin->node.pTargets, nodesCloneList(pRight->pTargets)); + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pJoin; + } else { + nodesDestroyNode(pJoin); + } + + return code; } -static SLogicNode* createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect) { - SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); - CHECK_ALLOC(pProject, NULL); - pProject->node.id = pCxt->planNodeId++; - - pProject->pProjections = nodesCloneList(pSelect->pProjectionList); - - pProject->node.pTargets = createColumnByProjections(pCxt,pSelect->pProjectionList); - CHECK_ALLOC(pProject->node.pTargets, (SLogicNode*)pProject); - - return (SLogicNode*)pProject; +static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { + int32_t code = createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); + if (TSDB_CODE_SUCCESS == code) { + SNode* pNode; + FOREACH(pNode, (*pLogicNode)->pTargets) { + strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); + } + } + return code; } -static SLogicNode* createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect) { - SLogicNode* pRoot = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable); - if (TSDB_CODE_SUCCESS == pCxt->errCode && NULL != pSelect->pWhere) { - pRoot->pConditions = nodesCloneNode(pSelect->pWhere); - CHECK_ALLOC(pRoot->pConditions, pRoot); +static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) { + SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); + if (NULL == pScan) { + return TSDB_CODE_OUT_OF_MEMORY; } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pRoot = pushLogicNode(pCxt, pRoot, createWindowLogicNode(pCxt, pSelect)); + + TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); + TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); + pScan->scanType = SCAN_TYPE_TABLE; + pScan->scanFlag = MAIN_SCAN; + pScan->scanRange = TSWINDOW_INITIALIZER; + pScan->tableName.type = TSDB_TABLE_NAME_T; + pScan->tableName.acctId = pCxt->pPlanCxt->acctId; + strcpy(pScan->tableName.dbname, pRealTable->table.dbName); + strcpy(pScan->tableName.tname, pRealTable->table.tableName); + + // set columns to scan + SNodeList* pCols = NULL; + int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, &pCols); + if (TSDB_CODE_SUCCESS == code && NULL != pCols) { + pScan->pScanCols = nodesCloneList(pCols); + if (NULL == pScan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pRoot = pushLogicNode(pCxt, pRoot, createAggLogicNode(pCxt, pSelect)); + + // set output + if (TSDB_CODE_SUCCESS == code && NULL != pCols) { + pScan->node.pTargets = nodesCloneList(pCols); + if (NULL == pScan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } } - if (TSDB_CODE_SUCCESS == pCxt->errCode) { - pRoot = pushLogicNode(pCxt, pRoot, createProjectLogicNode(pCxt, pSelect)); + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pScan; + } else { + nodesDestroyNode(pScan); } - return pRoot; + + return code; +} + +static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { + switch (nodeType(pTable)) { + case QUERY_NODE_REAL_TABLE: + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + case QUERY_NODE_TEMP_TABLE: + return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); + case QUERY_NODE_JOIN_TABLE: + return createJoinLogicNode(pCxt, pSelect, (SJoinTableNode*)pTable, pLogicNode); + default: + break; + } + return TSDB_CODE_FAILED; +} + +static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { + SLogicNode* pNode = NULL; + int32_t code = doCreateLogicNodeByTable(pCxt, pSelect, pTable, &pNode); + if (TSDB_CODE_SUCCESS == code) { + pNode->pConditions = nodesCloneNode(pSelect->pWhere); + if (NULL != pSelect->pWhere && NULL == pNode->pConditions) { + nodesDestroyNode(pNode); + return TSDB_CODE_OUT_OF_MEMORY; + } + *pLogicNode = pNode; + } + return code; +} + +typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**); + +static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func, SLogicNode** pRoot) { + SLogicNode* pNode = NULL; + int32_t code = func(pCxt, pSelect, &pNode); + if (TSDB_CODE_SUCCESS == code) { + code = pushLogicNode(pCxt, pRoot, pNode); + } + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode(pNode); + } + return code; +} + +static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { + SLogicNode* pRoot = NULL; + int32_t code = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable, &pRoot); + if (TSDB_CODE_SUCCESS == code) { + code = createChildLogicNode(pCxt, pSelect, createWindowLogicNode, &pRoot); + } + if (TSDB_CODE_SUCCESS == code) { + code = createChildLogicNode(pCxt, pSelect, createAggLogicNode, &pRoot); + } + if (TSDB_CODE_SUCCESS == code) { + code = createChildLogicNode(pCxt, pSelect, createProjectLogicNode, &pRoot); + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = pRoot; + } else { + nodesDestroyNode(pRoot); + } + + return code; } static int32_t getMsgType(ENodeType sqlType) { return (QUERY_NODE_CREATE_TABLE_STMT == sqlType || QUERY_NODE_CREATE_MULTI_TABLE_STMT == sqlType) ? TDMT_VND_CREATE_TABLE : TDMT_VND_SUBMIT; } -static SLogicNode* createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt) { - SVnodeModifLogicNode* pModif = (SVnodeModifLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIF); - CHECK_ALLOC(pModif, NULL); +static int32_t createVnodeModifLogicNode(SLogicPlanContext* pCxt, SVnodeModifOpStmt* pStmt, SLogicNode** pLogicNode) { + SVnodeModifLogicNode* pModif = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_VNODE_MODIF); + if (NULL == pModif) { + return TSDB_CODE_OUT_OF_MEMORY; + } pModif->pDataBlocks = pStmt->pDataBlocks; pModif->msgType = getMsgType(pStmt->sqlNodeType); - return (SLogicNode*)pModif; + *pLogicNode = (SLogicNode*)pModif; + return TSDB_CODE_SUCCESS; } -static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) { +static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode) { switch (nodeType(pStmt)) { case QUERY_NODE_SELECT_STMT: - return createSelectLogicNode(pCxt, (SSelectStmt*)pStmt); + return createSelectLogicNode(pCxt, (SSelectStmt*)pStmt, pLogicNode); case QUERY_NODE_VNODE_MODIF_STMT: - return createVnodeModifLogicNode(pCxt, (SVnodeModifOpStmt*)pStmt); + return createVnodeModifLogicNode(pCxt, (SVnodeModifOpStmt*)pStmt, pLogicNode); default: break; } - return NULL; // to avoid compiler error + return TSDB_CODE_FAILED; } int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { - SLogicPlanContext cxt = { .errCode = TSDB_CODE_SUCCESS, .planNodeId = 1, .acctId = pCxt->acctId }; - SLogicNode* pRoot = createQueryLogicNode(&cxt, pCxt->pAstRoot); - if (TSDB_CODE_SUCCESS != cxt.errCode) { - nodesDestroyNode((SNode*)pRoot); - return cxt.errCode; + SLogicPlanContext cxt = { .pPlanCxt = pCxt, .errCode = TSDB_CODE_SUCCESS, .planNodeId = 1 }; + int32_t code = createQueryLogicNode(&cxt, pCxt->pAstRoot, pLogicNode); + if (TSDB_CODE_SUCCESS != code) { + return code; } - *pLogicNode = pRoot; return TSDB_CODE_SUCCESS; } From 11c8ac91da93010293df487bc350c610de93e156 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Thu, 17 Mar 2022 18:55:26 +0800 Subject: [PATCH 34/60] sync refactor --- source/libs/sync/src/syncCommit.c | 20 +-- source/libs/sync/test/CMakeLists.txt | 14 ++ source/libs/sync/test/syncEncodeTest.cpp | 52 ++----- source/libs/sync/test/syncWriteTest.cpp | 180 +++++++++++++++++++++++ 4 files changed, 215 insertions(+), 51 deletions(-) create mode 100644 source/libs/sync/test/syncWriteTest.cpp diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 25835edc92..bc2a39aa89 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -50,18 +50,20 @@ void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex beginIndex = SYNC_INDEX_INVALID; SyncIndex endIndex = SYNC_INDEX_INVALID; for (SyncIndex i = beginIndex; i <= endIndex; ++i) { - SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, i); - assert(pEntry != NULL); + if (i != SYNC_INDEX_INVALID) { + SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, i); + assert(pEntry != NULL); - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pEntry, &rpcMsg); + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); - if (pSyncNode->pFsm->FpCommitCb != NULL) { - pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + if (pSyncNode->pFsm->FpCommitCb != NULL) { + pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } + + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pEntry); } - - rpcFreeCont(rpcMsg.pCont); - syncEntryDestory(pEntry); } } } \ No newline at end of file diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 5fa0e975d8..2821764448 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -29,6 +29,7 @@ add_executable(syncPingTimerTest2 "") add_executable(syncPingSelfTest "") add_executable(syncElectTest "") add_executable(syncEncodeTest "") +add_executable(syncWriteTest "") target_sources(syncTest @@ -155,6 +156,10 @@ target_sources(syncEncodeTest PRIVATE "syncEncodeTest.cpp" ) +target_sources(syncWriteTest + PRIVATE + "syncWriteTest.cpp" +) target_include_directories(syncTest @@ -317,6 +322,11 @@ target_include_directories(syncEncodeTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncWriteTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -443,6 +453,10 @@ target_link_libraries(syncEncodeTest sync gtest_main ) +target_link_libraries(syncWriteTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncEncodeTest.cpp b/source/libs/sync/test/syncEncodeTest.cpp index f615c1d237..e554858072 100644 --- a/source/libs/sync/test/syncEncodeTest.cpp +++ b/source/libs/sync/test/syncEncodeTest.cpp @@ -8,7 +8,6 @@ #include "syncRaftLog.h" #include "syncRaftStore.h" #include "syncUtil.h" -#include "syncRaftLog.h" void logTest() { sTrace("--- sync log test: trace"); @@ -25,11 +24,11 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM* pFsm; -SWal* pWal; -SSyncNode* pSyncNode; +SSyncFSM * pFsm; +SWal * pWal; +SSyncNode *pSyncNode; -SSyncNode* syncNodeInit() { +SSyncNode *syncNodeInit() { syncInfo.vgId = 1234; syncInfo.rpcClient = gSyncIO->clientRpc; syncInfo.FpSendMsg = syncIOSendMsg; @@ -54,7 +53,7 @@ SSyncNode* syncNodeInit() { syncInfo.pWal = pWal; - SSyncCfg* pCfg = &syncInfo.syncCfg; + SSyncCfg *pCfg = &syncInfo.syncCfg; pCfg->myIndex = myIndex; pCfg->replicaNum = replicaNum; @@ -81,43 +80,12 @@ SSyncNode* syncNodeInit() { return pSyncNode; } -SSyncNode* syncInitTest() { return syncNodeInit(); } +SSyncNode *syncInitTest() { return syncNodeInit(); } -void logStoreTest() { - logStorePrint2((char*)"logStoreTest", pSyncNode->pLogStore); - - assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_INVALID); - - for (int i = 0; i < 5; ++i) { - int32_t dataLen = 10; - SSyncRaftEntry* pEntry = syncEntryBuild(dataLen); - assert(pEntry != NULL); - pEntry->msgType = 1; - pEntry->originalRpcType = 2; - pEntry->seqNum = 3; - pEntry->isWeak = true; - pEntry->term = 100; - pEntry->index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1; - snprintf(pEntry->data, dataLen, "value%d", i); - - // syncEntryPrint2((char*)"write entry:", pEntry); - pSyncNode->pLogStore->appendEntry(pSyncNode->pLogStore, pEntry); - syncEntryDestory(pEntry); - - if (i == 0) { - assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_BEGIN); - } - } - logStorePrint2((char*)"after appendEntry", pSyncNode->pLogStore); - - pSyncNode->pLogStore->truncate(pSyncNode->pLogStore, 3); - logStorePrint2((char*)"after truncate 3", pSyncNode->pLogStore); -} - -void initRaftId(SSyncNode* pSyncNode) { +void initRaftId(SSyncNode *pSyncNode) { for (int i = 0; i < replicaNum; ++i) { ids[i] = pSyncNode->replicasId[i]; - char* s = syncUtilRaftId2Str(&ids[i]); + char *s = syncUtilRaftId2Str(&ids[i]); printf("raftId[%d] : %s\n", i, s); free(s); } @@ -181,7 +149,7 @@ int main(int argc, char **argv) { myIndex = atoi(argv[1]); } - int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + int32_t ret = syncIOStart((char *)"127.0.0.1", ports[myIndex]); assert(ret == 0); ret = syncEnvStart(); @@ -210,7 +178,7 @@ int main(int argc, char **argv) { syncEntryPrint2((char *)"==step4==", pMsg4); // log, relog - SSyncNode* pSyncNode = syncNodeInit(); + SSyncNode *pSyncNode = syncNodeInit(); assert(pSyncNode != NULL); SSyncRaftEntry *pEntry = pMsg4; pSyncNode->pLogStore->appendEntry(pSyncNode->pLogStore, pEntry); diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp new file mode 100644 index 0000000000..d4c2dde6d0 --- /dev/null +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -0,0 +1,180 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncMessage.h" +#include "syncRaftEntry.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 1; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM * pFsm; +SWal * pWal; +SSyncNode *gSyncNode; + +void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==CommitCb==", (SRpcMsg *)pBuf); +} + +void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==PreCommitCb==", (SRpcMsg *)pBuf); +} + +void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==RollBackCb==", (SRpcMsg *)pBuf); +} + +void initFsm() { + pFsm = (SSyncFSM *)malloc(sizeof(SSyncFSM)); + pFsm->FpCommitCb = CommitCb; + pFsm->FpPreCommitCb = PreCommitCb; + pFsm->FpRollBackCb = RollBackCb; +} + +SSyncNode *syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./write_test"); + + int code = walInit(); + assert(code == 0); + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = syncInfo.vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + pWal = walOpen("./write_test_wal", &walCfg); + assert(pWal != NULL); + + syncInfo.pWal = pWal; + + SSyncCfg *pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode *pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode *syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode *pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char *s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +SRpcMsg *step0() { + SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); + memset(pMsg, 0, sizeof(SRpcMsg)); + pMsg->msgType = 9999; + pMsg->contLen = 32; + pMsg->pCont = malloc(pMsg->contLen); + snprintf((char *)(pMsg->pCont), pMsg->contLen, "hello, world"); + return pMsg; +} + +SyncClientRequest *step1(const SRpcMsg *pMsg) { + SyncClientRequest *pRetMsg = syncClientRequestBuild2(pMsg, 123, true); + return pRetMsg; +} + +int main(int argc, char **argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + void logTest(); + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char *)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + taosRemoveDir("./wal_test"); + + initFsm(); + + gSyncNode = syncInitTest(); + assert(gSyncNode != NULL); + syncNodePrint2((char *)"", gSyncNode); + + initRaftId(gSyncNode); + + // step0 + SRpcMsg *pMsg0 = step0(); + syncRpcMsgPrint2((char *)"==step0==", pMsg0); + + // step1 + SyncClientRequest *pMsg1 = step1(pMsg0); + syncClientRequestPrint2((char *)"==step1==", pMsg1); + + for (int i = 0; i < 5; ++i) { + SyncClientRequest *pSyncClientRequest = pMsg1; + SRpcMsg rpcMsg; + syncClientRequest2RpcMsg(pSyncClientRequest, &rpcMsg); + gSyncNode->FpEqMsg(gSyncNode->queue, &rpcMsg); + + taosMsleep(1000); + } + + while (1) { + sTrace("while 1 sleep"); + taosMsleep(1000); + } + + return 0; +} From 22d93248f3e8b4de2f8238076274bc891f37c131 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 17 Mar 2022 19:35:17 +0800 Subject: [PATCH 35/60] add multithread protection when init SSmaEnv/SSmaStat --- source/dnode/vnode/src/tsdb/tsdbSma.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index f3135c690e..42bfebc77b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -213,11 +213,14 @@ static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat) { return TSDB_CODE_SUCCESS; } - // TODO: lock. lazy mode when update expired window, or hungry mode during tsdbNew. + /** + * 1. Lazy mode utilized when init SSmaStat to update expired window(or hungry mode when tsdbNew). + * 2. Currently, there is mutex lock when init SSmaEnv, thus no need add lock on SSmaStat, and please add lock if + * tsdbInitSmaStat invoked in other multithread environment later. + */ if (*pSmaStat == NULL) { *pSmaStat = (SSmaStat *)calloc(1, sizeof(SSmaStat)); if (*pSmaStat == NULL) { - // TODO: unlock terrno = TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_FAILED; } @@ -227,11 +230,9 @@ static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat) { if ((*pSmaStat)->smaStatItems == NULL) { tfree(*pSmaStat); - // TODO: unlock return TSDB_CODE_FAILED; } } - // TODO: unlock return TSDB_CODE_SUCCESS; } @@ -270,15 +271,17 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { + SSmaEnv *pEnv = NULL; + // return if already init switch (smaType) { case TSDB_SMA_TYPE_TIME_RANGE: - if (pTsdb->pTSmaEnv) { + if ((pEnv = (SSmaEnv *)atomic_load_ptr(&pTsdb->pTSmaEnv)) != NULL) { return TSDB_CODE_SUCCESS; } break; case TSDB_SMA_TYPE_ROLLUP: - if (pTsdb->pRSmaEnv) { + if ((pEnv = (SSmaEnv *)atomic_load_ptr(&pTsdb->pRSmaEnv)) != NULL) { return TSDB_CODE_SUCCESS; } break; @@ -307,16 +310,15 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_FAILED; } - SSmaEnv *pEnv = NULL; if (tsdbInitSmaEnv(pTsdb, aname, &pEnv) != TSDB_CODE_SUCCESS) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - pTsdb->pTSmaEnv = pEnv; + atomic_store_ptr(&pTsdb->pTSmaEnv, pEnv); } else { - pTsdb->pRSmaEnv = pEnv; + atomic_store_ptr(&pTsdb->pRSmaEnv, pEnv); } } tsdbUnlockRepo(pTsdb); From 0db2e65d6aa8cf911dc3b8f54265569f9efd7860 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 17 Mar 2022 07:47:12 -0400 Subject: [PATCH 36/60] logic plan code reorganize --- include/libs/nodes/plannodes.h | 1 - source/libs/nodes/src/nodesCloneFuncs.c | 1 - source/libs/nodes/src/nodesCodeFuncs.c | 6 +- source/libs/planner/src/planLogicCreater.c | 380 ++++++++++----------- 4 files changed, 190 insertions(+), 198 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 1d89b07539..39ecd89619 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -26,7 +26,6 @@ extern "C" { typedef struct SLogicNode { ENodeType type; - int32_t id; SNodeList* pTargets; // SColumnNode SNode* pConditions; SNodeList* pChildren; diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 34c211561b..d1dc2dec58 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -190,7 +190,6 @@ static SNode* fillNodeCopy(const SFillNode* pSrc, SFillNode* pDst) { } static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { - COPY_SCALAR_FIELD(id); CLONE_NODE_LIST_FIELD(pTargets); CLONE_NODE_FIELD(pConditions); CLONE_NODE_LIST_FIELD(pChildren); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index a2fd32d238..44f2318cc4 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -193,7 +193,6 @@ static int32_t tableMetaToJson(const void* pObj, SJson* pJson) { return code; } -static const char* jkLogicPlanId = "Id"; static const char* jkLogicPlanTargets = "Targets"; static const char* jkLogicPlanConditions = "Conditions"; static const char* jkLogicPlanChildren = "Children"; @@ -201,10 +200,7 @@ static const char* jkLogicPlanChildren = "Children"; static int32_t logicPlanNodeToJson(const void* pObj, SJson* pJson) { const SLogicNode* pNode = (const SLogicNode*)pObj; - int32_t code = tjsonAddIntegerToObject(pJson, jkLogicPlanId, pNode->id); - if (TSDB_CODE_SUCCESS == code) { - code = nodeListToJson(pJson, jkLogicPlanTargets, pNode->pTargets); - } + int32_t code = nodeListToJson(pJson, jkLogicPlanTargets, pNode->pTargets); if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkLogicPlanConditions, nodeToJson, pNode->pConditions); } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 285413c24e..0d263e4484 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -19,10 +19,10 @@ typedef struct SLogicPlanContext { SPlanContext* pPlanCxt; - int32_t errCode; - int32_t planNodeId; } SLogicPlanContext; +typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**); + static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode); static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogicNode** pLogicNode); @@ -66,7 +66,6 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) { } typedef struct SNameExprCxt { - int32_t planNodeId; int32_t rewriteId; } SNameExprCxt; @@ -76,7 +75,7 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) { case QUERY_NODE_LOGIC_CONDITION: case QUERY_NODE_FUNCTION: { SNameExprCxt* pCxt = (SNameExprCxt*)pContext; - sprintf(((SExprNode*)pNode)->aliasName, "#expr_%d_%d", pCxt->planNodeId, pCxt->rewriteId++); + sprintf(((SExprNode*)pNode)->aliasName, "#expr_%d", pCxt->rewriteId++); return DEAL_RES_IGNORE_CHILD; } default: @@ -86,8 +85,9 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } -static int32_t rewriteExpr(int32_t planNodeId, int32_t rewriteId, SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) { - SNameExprCxt nameCxt = { .planNodeId = planNodeId, .rewriteId = rewriteId }; +static int32_t rewriteExpr(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) { + static int32_t rewriteId = 1; + SNameExprCxt nameCxt = { .rewriteId = rewriteId }; nodesWalkList(pExprs, doNameExpr, &nameCxt); SRewriteExprCxt cxt = { .errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs }; nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt); @@ -111,6 +111,160 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo return TSDB_CODE_SUCCESS; } +static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func, SLogicNode** pRoot) { + SLogicNode* pNode = NULL; + int32_t code = func(pCxt, pSelect, &pNode); + if (TSDB_CODE_SUCCESS == code) { + code = pushLogicNode(pCxt, pRoot, pNode); + } + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyNode(pNode); + } + return code; +} + +static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) { + SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); + if (NULL == pScan) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); + TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); + pScan->scanType = SCAN_TYPE_TABLE; + pScan->scanFlag = MAIN_SCAN; + pScan->scanRange = TSWINDOW_INITIALIZER; + pScan->tableName.type = TSDB_TABLE_NAME_T; + pScan->tableName.acctId = pCxt->pPlanCxt->acctId; + strcpy(pScan->tableName.dbname, pRealTable->table.dbName); + strcpy(pScan->tableName.tname, pRealTable->table.tableName); + + // set columns to scan + SNodeList* pCols = NULL; + int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, &pCols); + if (TSDB_CODE_SUCCESS == code && NULL != pCols) { + pScan->pScanCols = nodesCloneList(pCols); + if (NULL == pScan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + // set output + if (TSDB_CODE_SUCCESS == code && NULL != pCols) { + pScan->node.pTargets = nodesCloneList(pCols); + if (NULL == pScan) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pScan; + } else { + nodesDestroyNode(pScan); + } + + return code; +} + +static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { + int32_t code = createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); + if (TSDB_CODE_SUCCESS == code) { + SNode* pNode; + FOREACH(pNode, (*pLogicNode)->pTargets) { + strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); + } + } + return code; +} + +static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable, SLogicNode** pLogicNode) { + SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN); + if (NULL == pJoin) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pJoin->joinType = pJoinTable->joinType; + + int32_t code = TSDB_CODE_SUCCESS; + + // set left and right node + pJoin->node.pChildren = nodesMakeList(); + if (NULL == pJoin->node.pChildren) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + + SLogicNode* pLeft = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pLeft, &pLeft); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pLeft); + } + } + + SLogicNode* pRight = NULL; + if (TSDB_CODE_SUCCESS == code) { + code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pRight, &pRight); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pRight); + } + } + + // set on conditions + if (TSDB_CODE_SUCCESS == code && NULL != pJoinTable->pOnCond) { + pJoin->pOnConditions = nodesCloneNode(pJoinTable->pOnCond); + if (NULL == pJoin->pOnConditions) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + // set the output + if (TSDB_CODE_SUCCESS == code) { + pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); + if (NULL == pJoin->pOnConditions) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListStrictAppendList(pJoin->node.pTargets, nodesCloneList(pRight->pTargets)); + } + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pJoin; + } else { + nodesDestroyNode(pJoin); + } + + return code; +} + +static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { + switch (nodeType(pTable)) { + case QUERY_NODE_REAL_TABLE: + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + case QUERY_NODE_TEMP_TABLE: + return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); + case QUERY_NODE_JOIN_TABLE: + return createJoinLogicNode(pCxt, pSelect, (SJoinTableNode*)pTable, pLogicNode); + default: + break; + } + return TSDB_CODE_FAILED; +} + +static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { + SLogicNode* pNode = NULL; + int32_t code = doCreateLogicNodeByTable(pCxt, pSelect, pTable, &pNode); + if (TSDB_CODE_SUCCESS == code) { + pNode->pConditions = nodesCloneNode(pSelect->pWhere); + if (NULL != pSelect->pWhere && NULL == pNode->pConditions) { + nodesDestroyNode(pNode); + return TSDB_CODE_OUT_OF_MEMORY; + } + *pLogicNode = pNode; + } + return code; +} + static SColumnNode* createColumnByExpr(SExprNode* pExpr) { SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -121,50 +275,6 @@ static SColumnNode* createColumnByExpr(SExprNode* pExpr) { return pCol; } -static int32_t createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pCols) { - SNodeList* pList = nodesMakeList(); - if (NULL == pList) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - SNode* pNode; - FOREACH(pNode, pExprs) { - if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr((SExprNode*)pNode))) { - nodesDestroyList(pList); - return TSDB_CODE_OUT_OF_MEMORY; - } - } - - *pCols = pList; - return TSDB_CODE_SUCCESS; -} - -static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); - if (NULL == pProject) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - int32_t code = TSDB_CODE_SUCCESS; - - pProject->pProjections = nodesCloneList(pSelect->pProjectionList); - if (NULL == pProject->pProjections) { - code = TSDB_CODE_OUT_OF_MEMORY; - } - - if (TSDB_CODE_SUCCESS == code) { - code = createColumnByProjections(pCxt,pSelect->pProjectionList, &pProject->node.pTargets); - } - - if (TSDB_CODE_SUCCESS == code) { - *pLogicNode = (SLogicNode*)pProject; - } else { - nodesDestroyNode(pProject); - } - - return code; -} - typedef struct SCreateColumnCxt { int32_t errCode; SNodeList* pList; @@ -246,10 +356,10 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, // rewrite the expression in subsequent clauses if (TSDB_CODE_SUCCESS == code) { - code = rewriteExpr(pAgg->node.id, 1, pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY); + code = rewriteExpr(pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY); } if (TSDB_CODE_SUCCESS == code) { - code = rewriteExpr(pAgg->node.id, 1 + LIST_LENGTH(pAgg->pGroupKeys), pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); + code = rewriteExpr(pAgg->pAggFuncs, pSelect, SQL_CLAUSE_GROUP_BY); } if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pHaving) { @@ -303,7 +413,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva } if (TSDB_CODE_SUCCESS == code) { - code = rewriteExpr(pWindow->node.id, 1, pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW); + code = rewriteExpr(pWindow->pFuncs, pSelect, SQL_CLAUSE_WINDOW); } if (TSDB_CODE_SUCCESS == code) { @@ -334,162 +444,50 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele return TSDB_CODE_FAILED; } -static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SJoinTableNode* pJoinTable, SLogicNode** pLogicNode) { - SJoinLogicNode* pJoin = (SJoinLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_JOIN); - if (NULL == pJoin) { +static int32_t createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pExprs, SNodeList** pCols) { + SNodeList* pList = nodesMakeList(); + if (NULL == pList) { return TSDB_CODE_OUT_OF_MEMORY; } - pJoin->joinType = pJoinTable->joinType; + SNode* pNode; + FOREACH(pNode, pExprs) { + if (TSDB_CODE_SUCCESS != nodesListAppend(pList, createColumnByExpr((SExprNode*)pNode))) { + nodesDestroyList(pList); + return TSDB_CODE_OUT_OF_MEMORY; + } + } + + *pCols = pList; + return TSDB_CODE_SUCCESS; +} + +static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { + SProjectLogicNode* pProject = (SProjectLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_PROJECT); + if (NULL == pProject) { + return TSDB_CODE_OUT_OF_MEMORY; + } int32_t code = TSDB_CODE_SUCCESS; - // set left and right node - pJoin->node.pChildren = nodesMakeList(); - if (NULL == pJoin->node.pChildren) { + pProject->pProjections = nodesCloneList(pSelect->pProjectionList); + if (NULL == pProject->pProjections) { code = TSDB_CODE_OUT_OF_MEMORY; } - SLogicNode* pLeft = NULL; if (TSDB_CODE_SUCCESS == code) { - code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pLeft, &pLeft); - if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pLeft); - } - } - - SLogicNode* pRight = NULL; - if (TSDB_CODE_SUCCESS == code) { - code = doCreateLogicNodeByTable(pCxt, pSelect, pJoinTable->pRight, &pRight); - if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pRight); - } - } - - // set on conditions - if (TSDB_CODE_SUCCESS == code && NULL != pJoinTable->pOnCond) { - pJoin->pOnConditions = nodesCloneNode(pJoinTable->pOnCond); - if (NULL == pJoin->pOnConditions) { - code = TSDB_CODE_OUT_OF_MEMORY; - } - } - - // set the output - if (TSDB_CODE_SUCCESS == code) { - pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); - if (NULL == pJoin->pOnConditions) { - code = TSDB_CODE_OUT_OF_MEMORY; - } - if (TSDB_CODE_SUCCESS == code) { - code = nodesListStrictAppendList(pJoin->node.pTargets, nodesCloneList(pRight->pTargets)); - } + code = createColumnByProjections(pCxt,pSelect->pProjectionList, &pProject->node.pTargets); } if (TSDB_CODE_SUCCESS == code) { - *pLogicNode = (SLogicNode*)pJoin; + *pLogicNode = (SLogicNode*)pProject; } else { - nodesDestroyNode(pJoin); + nodesDestroyNode(pProject); } return code; } -static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { - int32_t code = createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); - if (TSDB_CODE_SUCCESS == code) { - SNode* pNode; - FOREACH(pNode, (*pLogicNode)->pTargets) { - strcpy(((SColumnNode*)pNode)->tableAlias, pTable->table.tableAlias); - } - } - return code; -} - -static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) { - SScanLogicNode* pScan = (SScanLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SCAN); - if (NULL == pScan) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); - TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); - pScan->scanType = SCAN_TYPE_TABLE; - pScan->scanFlag = MAIN_SCAN; - pScan->scanRange = TSWINDOW_INITIALIZER; - pScan->tableName.type = TSDB_TABLE_NAME_T; - pScan->tableName.acctId = pCxt->pPlanCxt->acctId; - strcpy(pScan->tableName.dbname, pRealTable->table.dbName); - strcpy(pScan->tableName.tname, pRealTable->table.tableName); - - // set columns to scan - SNodeList* pCols = NULL; - int32_t code = nodesCollectColumns(pSelect, SQL_CLAUSE_FROM, pRealTable->table.tableAlias, &pCols); - if (TSDB_CODE_SUCCESS == code && NULL != pCols) { - pScan->pScanCols = nodesCloneList(pCols); - if (NULL == pScan) { - code = TSDB_CODE_OUT_OF_MEMORY; - } - } - - // set output - if (TSDB_CODE_SUCCESS == code && NULL != pCols) { - pScan->node.pTargets = nodesCloneList(pCols); - if (NULL == pScan) { - code = TSDB_CODE_OUT_OF_MEMORY; - } - } - - if (TSDB_CODE_SUCCESS == code) { - *pLogicNode = (SLogicNode*)pScan; - } else { - nodesDestroyNode(pScan); - } - - return code; -} - -static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { - switch (nodeType(pTable)) { - case QUERY_NODE_REAL_TABLE: - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); - case QUERY_NODE_TEMP_TABLE: - return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); - case QUERY_NODE_JOIN_TABLE: - return createJoinLogicNode(pCxt, pSelect, (SJoinTableNode*)pTable, pLogicNode); - default: - break; - } - return TSDB_CODE_FAILED; -} - -static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SNode* pTable, SLogicNode** pLogicNode) { - SLogicNode* pNode = NULL; - int32_t code = doCreateLogicNodeByTable(pCxt, pSelect, pTable, &pNode); - if (TSDB_CODE_SUCCESS == code) { - pNode->pConditions = nodesCloneNode(pSelect->pWhere); - if (NULL != pSelect->pWhere && NULL == pNode->pConditions) { - nodesDestroyNode(pNode); - return TSDB_CODE_OUT_OF_MEMORY; - } - *pLogicNode = pNode; - } - return code; -} - -typedef int32_t (*FCreateLogicNode)(SLogicPlanContext*, SSelectStmt*, SLogicNode**); - -static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func, SLogicNode** pRoot) { - SLogicNode* pNode = NULL; - int32_t code = func(pCxt, pSelect, &pNode); - if (TSDB_CODE_SUCCESS == code) { - code = pushLogicNode(pCxt, pRoot, pNode); - } - if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode(pNode); - } - return code; -} - static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { SLogicNode* pRoot = NULL; int32_t code = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable, &pRoot); @@ -540,7 +538,7 @@ static int32_t createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt, SLogi } int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { - SLogicPlanContext cxt = { .pPlanCxt = pCxt, .errCode = TSDB_CODE_SUCCESS, .planNodeId = 1 }; + SLogicPlanContext cxt = { .pPlanCxt = pCxt }; int32_t code = createQueryLogicNode(&cxt, pCxt->pAstRoot, pLogicNode); if (TSDB_CODE_SUCCESS != code) { return code; From c393fa19b385179cd387c2c931df77e4cd413960 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 18 Mar 2022 09:10:32 +0800 Subject: [PATCH 37/60] feature/qnode --- include/libs/qcom/query.h | 4 ++++ source/libs/catalog/src/catalog.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index c8df40aedc..b6f42eeee0 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -49,6 +49,10 @@ typedef struct STableComInfo { int32_t rowSize; // row size of the schema } STableComInfo; +typedef struct SIndexMeta { + +} SIndexMeta; + /* * ASSERT(sizeof(SCTableMeta) == 24) * ASSERT(tableType == TSDB_CHILD_TABLE) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 80a0b3554c..08e0ac55d7 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -2349,6 +2349,9 @@ _return: CTG_API_LEAVE(code); } +int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet) { + +} int32_t catalogRemoveDB(SCatalog* pCtg, const char* dbFName, uint64_t dbId) { CTG_API_ENTER(); @@ -2394,6 +2397,9 @@ _return: CTG_API_LEAVE(code); } +int32_t catalogGetIndexMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, const char *pIndexName, SIndexMeta** pIndexMeta) { + +} int32_t catalogGetTableMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { CTG_API_ENTER(); @@ -2662,12 +2668,15 @@ _return: int32_t catalogGetQnodeList(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, SArray* pQnodeList) { CTG_API_ENTER(); - + + int32_t code = 0; if (NULL == pCtg || NULL == pRpc || NULL == pMgmtEps || NULL == pQnodeList) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - //TODO + CTG_ERR_JRET(ctgGetQnodeListFromMnode(pCtg, pRpc, pMgmtEps, &pQnodeList)); + +_return: CTG_API_LEAVE(TSDB_CODE_SUCCESS); } From 1ee1691ae19355862a2960cf5a3fb6acf94a12d3 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Thu, 17 Mar 2022 22:28:21 -0400 Subject: [PATCH 38/60] logic plan code reorganize --- include/common/ttokendef.h | 26 +++++++++---------- source/libs/parser/src/sql.c | 29 ++++++++++++++++------ source/libs/planner/src/planLogicCreater.c | 2 +- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index e89df62b8e..27d509e931 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -33,22 +33,22 @@ #define TK_NK_SLASH 15 #define TK_NK_REM 16 #define TK_NK_CONCAT 17 -#define TK_ALTER 18 +#define TK_CREATE 18 #define TK_ACCOUNT 19 #define TK_NK_ID 20 #define TK_PASS 21 -#define TK_PPS 22 -#define TK_TSERIES 23 -#define TK_STORAGE 24 -#define TK_STREAMS 25 -#define TK_QTIME 26 -#define TK_DBS 27 -#define TK_USERS 28 -#define TK_CONNS 29 -#define TK_STATE 30 -#define TK_CREATE 31 -#define TK_USER 32 -#define TK_NK_STRING 33 +#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_USER 33 #define TK_PRIVILEGE 34 #define TK_DROP 35 #define TK_SHOW 36 diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index fa7eb6bc89..3d88eb5336 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -2499,20 +2499,35 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy26 = yylhsminor.yy26; break; case 93: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - case 95: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ yytestcase(yyruleno==95); - case 97: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ yytestcase(yyruleno==97); - case 99: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ yytestcase(yyruleno==99); { yylhsminor.yy26 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370); } yymsp[-4].minor.yy26 = yylhsminor.yy26; break; case 94: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ - case 98: /* alter_table_clause ::= full_table_name DROP TAG column_name */ yytestcase(yyruleno==98); -{ yylhsminor.yy26 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[0].minor.yy353); } +{ yylhsminor.yy26 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy26, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy353); } yymsp[-3].minor.yy26 = yylhsminor.yy26; break; + case 95: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy26 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; + break; case 96: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - case 100: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ yytestcase(yyruleno==100); -{ yylhsminor.yy26 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } +{ yylhsminor.yy26 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; + break; + case 97: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy26 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; + break; + case 98: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy26 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy26, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy353); } + yymsp[-3].minor.yy26 = yylhsminor.yy26; + break; + case 99: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy26 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy353, yymsp[0].minor.yy370); } + yymsp[-4].minor.yy26 = yylhsminor.yy26; + break; + case 100: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy26 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy26, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy353, &yymsp[0].minor.yy353); } yymsp[-4].minor.yy26 = yylhsminor.yy26; break; case 101: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 0d263e4484..fd03eacf3f 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -114,7 +114,7 @@ static int32_t pushLogicNode(SLogicPlanContext* pCxt, SLogicNode** pOldRoot, SLo static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, FCreateLogicNode func, SLogicNode** pRoot) { SLogicNode* pNode = NULL; int32_t code = func(pCxt, pSelect, &pNode); - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && NULL != pNode) { code = pushLogicNode(pCxt, pRoot, pNode); } if (TSDB_CODE_SUCCESS != code) { From 6a7f5c5fd267c5a8c835f726a9848ac1f9088215 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 11:29:03 +0800 Subject: [PATCH 39/60] sync refactor --- source/libs/sync/inc/syncCommit.h | 35 +++++++++++++++++++ source/libs/sync/inc/syncInt.h | 1 - source/libs/sync/src/syncAppendEntriesReply.c | 3 +- source/libs/sync/src/syncCommit.c | 3 +- source/libs/sync/src/syncMain.c | 3 +- source/libs/sync/test/syncWriteTest.cpp | 2 +- 6 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 source/libs/sync/inc/syncCommit.h diff --git a/source/libs/sync/inc/syncCommit.h b/source/libs/sync/inc/syncCommit.h new file mode 100644 index 0000000000..4b327935c0 --- /dev/null +++ b/source/libs/sync/inc/syncCommit.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_LIBS_SYNC_COMMIT_H +#define _TD_LIBS_SYNC_COMMIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "syncInt.h" +#include "taosdef.h" + +void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_LIBS_SYNC_COMMIT_H*/ diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 5a9af83827..8e36424f19 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -236,7 +236,6 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode); // raft vote -------------- void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId); void syncNodeVoteForSelf(SSyncNode* pSyncNode); -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode); // for debug -------------- void syncNodePrint(SSyncNode* pObj); diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 93539db938..9db9a3e8ac 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -14,6 +14,7 @@ */ #include "syncAppendEntriesReply.h" +#include "syncCommit.h" #include "syncIndexMgr.h" #include "syncInt.h" #include "syncRaftLog.h" @@ -59,7 +60,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); // maybe commit - syncNodeMaybeAdvanceCommitIndex(ths); + syncMaybeAdvanceCommitIndex(ths); } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index bc2a39aa89..0b27f35220 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "syncCommit.h" #include "syncIndexMgr.h" #include "syncInt.h" #include "syncRaftLog.h" @@ -40,7 +41,7 @@ // IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] // /\ UNCHANGED <> // -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { +void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pNextIndex", pSyncNode->pNextIndex); syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pMatchIndex", pSyncNode->pMatchIndex); diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 1f3e709a27..7845490a84 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -17,6 +17,7 @@ #include "sync.h" #include "syncAppendEntries.h" #include "syncAppendEntriesReply.h" +#include "syncCommit.h" #include "syncElection.h" #include "syncEnv.h" #include "syncIndexMgr.h" @@ -740,7 +741,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg ths->pLogStore->appendEntry(ths->pLogStore, pEntry); // only myself, maybe commit - syncNodeMaybeAdvanceCommitIndex(ths); + syncMaybeAdvanceCommitIndex(ths); // start replicate right now! syncNodeReplicate(ths); diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp index d4c2dde6d0..2598abbddd 100644 --- a/source/libs/sync/test/syncWriteTest.cpp +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -162,7 +162,7 @@ int main(int argc, char **argv) { SyncClientRequest *pMsg1 = step1(pMsg0); syncClientRequestPrint2((char *)"==step1==", pMsg1); - for (int i = 0; i < 5; ++i) { + for (int i = 0; i < 10; ++i) { SyncClientRequest *pSyncClientRequest = pMsg1; SRpcMsg rpcMsg; syncClientRequest2RpcMsg(pSyncClientRequest, &rpcMsg); From ef61d3ee947d6609c43fcadcada24554e8b8df63 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 11:47:46 +0800 Subject: [PATCH 40/60] sync refactor --- source/libs/sync/inc/syncCommit.h | 25 ++++++++++++ source/libs/sync/src/syncCommit.c | 64 ++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 14 deletions(-) diff --git a/source/libs/sync/inc/syncCommit.h b/source/libs/sync/inc/syncCommit.h index 4b327935c0..c76236d5bf 100644 --- a/source/libs/sync/inc/syncCommit.h +++ b/source/libs/sync/inc/syncCommit.h @@ -26,7 +26,32 @@ extern "C" { #include "syncInt.h" #include "taosdef.h" +// \* Leader i advances its commitIndex. +// \* This is done as a separate step from handling AppendEntries responses, +// \* in part to minimize atomic regions, and in part so that leaders of +// \* single-server clusters are able to mark entries committed. +// AdvanceCommitIndex(i) == +// /\ state[i] = Leader +// /\ LET \* The set of servers that agree up through index. +// Agree(index) == {i} \cup {k \in Server : +// matchIndex[i][k] >= index} +// \* The maximum indexes for which a quorum agrees +// agreeIndexes == {index \in 1..Len(log[i]) : +// Agree(index) \in Quorum} +// \* New value for commitIndex'[i] +// newCommitIndex == +// IF /\ agreeIndexes /= {} +// /\ log[i][Max(agreeIndexes)].term = currentTerm[i] +// THEN +// Max(agreeIndexes) +// ELSE +// commitIndex[i] +// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] +// /\ UNCHANGED <> +// void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode); +bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index); +bool syncAgree(SSyncNode* pSyncNode, SyncIndex index); #ifdef __cplusplus } diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 0b27f35220..539bb21b71 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -46,25 +46,61 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pMatchIndex", pSyncNode->pMatchIndex); // update commit index + SyncIndex newCommitIndex = pSyncNode->commitIndex; + for (SyncIndex index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore); index > pSyncNode->commitIndex; + ++index) { + if (syncAgree(pSyncNode, index)) { + newCommitIndex = index; + break; + } + } - if (pSyncNode->pFsm != NULL) { - SyncIndex beginIndex = SYNC_INDEX_INVALID; - SyncIndex endIndex = SYNC_INDEX_INVALID; - for (SyncIndex i = beginIndex; i <= endIndex; ++i) { - if (i != SYNC_INDEX_INVALID) { - SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, i); - assert(pEntry != NULL); + if (newCommitIndex > pSyncNode->commitIndex) { + SyncIndex beginIndex = pSyncNode->commitIndex + 1; + SyncIndex endIndex = newCommitIndex; + pSyncNode->commitIndex = newCommitIndex; - SRpcMsg rpcMsg; - syncEntry2OriginalRpc(pEntry, &rpcMsg); + if (pSyncNode->pFsm != NULL) { + for (SyncIndex i = beginIndex; i <= endIndex; ++i) { + if (i != SYNC_INDEX_INVALID) { + SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, i); + assert(pEntry != NULL); - if (pSyncNode->pFsm->FpCommitCb != NULL) { - pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + if (pSyncNode->pFsm->FpCommitCb != NULL) { + pSyncNode->pFsm->FpCommitCb(pSyncNode->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } + + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pEntry); } - - rpcFreeCont(rpcMsg.pCont); - syncEntryDestory(pEntry); } } } +} + +bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index) { + SyncIndex matchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, pRaftId); + + // b for debug + bool b = false; + if (matchIndex >= index) { + b = true; + } + return b; +} + +bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) { + int agreeCount = 0; + for (int i = 0; i < pSyncNode->replicaNum; ++i) { + if (syncAgreeIndex(pSyncNode, &(pSyncNode->replicasId[i]), index)) { + ++agreeCount; + } + if (agreeCount >= pSyncNode->quorum) { + return true; + } + } + return false; } \ No newline at end of file From 394178da688da9bdaa61274abc4da4e25a2178d8 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 18 Mar 2022 13:23:48 +0800 Subject: [PATCH 41/60] [TD-13767]: only use iconv. --- cmake/cmake.options | 7 + cmake/iconv_CMakeLists.txt.in | 12 + contrib/CMakeLists.txt | 25 +- include/os/osFile.h | 31 +- include/os/osString.h | 23 +- include/util/tdef.h | 2 +- source/common/src/tvariant.c | 10 +- source/libs/parser/src/parInsert.c | 4 +- source/libs/scalar/src/filter.c | 8 +- source/libs/scalar/src/sclvector.c | 2 +- source/os/CMakeLists.txt | 7 +- source/os/src/osFile.c | 17 + source/os/src/osLocale.c | 2 +- source/os/src/osString.c | 714 +++++++++++++++++------------ 14 files changed, 502 insertions(+), 362 deletions(-) create mode 100644 cmake/iconv_CMakeLists.txt.in diff --git a/cmake/cmake.options b/cmake/cmake.options index 1a1a5b5d78..946eb5d258 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -18,6 +18,13 @@ IF(${TD_WINDOWS}) ON ) + MESSAGE("build iconv Win32") + option( + BUILD_WITH_ICONV + "If build iconv on Windows" + ON + ) + ENDIF () IF(${TD_LINUX} MATCHES TRUE) diff --git a/cmake/iconv_CMakeLists.txt.in b/cmake/iconv_CMakeLists.txt.in new file mode 100644 index 0000000000..31dfd829fc --- /dev/null +++ b/cmake/iconv_CMakeLists.txt.in @@ -0,0 +1,12 @@ + +# iconv +ExternalProject_Add(iconv + GIT_REPOSITORY https://github.com/win-iconv/win-iconv.git + GIT_TAG v0.0.8 + SOURCE_DIR "${CMAKE_CONTRIB_DIR}/iconv" + BINARY_DIR "" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) \ No newline at end of file diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index f87f660ab3..9cf68b87f9 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -83,6 +83,11 @@ if(${BUILD_WITH_NURAFT}) cat("${CMAKE_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) endif(${BUILD_WITH_NURAFT}) +# iconv +if(${BUILD_WITH_ICONV}) + cat("${CMAKE_SUPPORT_DIR}/iconv_CMakeLists.txt.in" ${CONTRIB_TMP_FILE}) +endif(${BUILD_WITH_ICONV}) + # download dependencies configure_file(${CONTRIB_TMP_FILE} "${CMAKE_CONTRIB_DIR}/deps-download/CMakeLists.txt") execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . @@ -208,14 +213,10 @@ endif(${BUILD_WITH_TRAFT}) # LIBUV if(${BUILD_WITH_UV}) - if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") - MESSAGE("Windows need set no-sign-compare") - add_compile_options(-Wno-sign-compare) - endif () - if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - file(READ "libuv/include/uv.h" CONTENTS) - string(REGEX REPLACE "/([\r]*)\nstruct uv_tcp_s {" "/\\1\ntypedef BOOL (PASCAL *LPFN_CONNECTEX) (SOCKET s, const struct sockaddr* name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength,LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped);\\1\nstruct uv_tcp_s {" CONTENTS_NEW "${CONTENTS}") - file(WRITE "libuv/include/uv.h" "${CONTENTS_NEW}") + if (${TD_WINDOWS}) + file(READ "libuv/include/uv.h" CONTENTS) + string(REGEX REPLACE "/([\r]*)\nstruct uv_tcp_s {" "/\\1\ntypedef BOOL (PASCAL *LPFN_CONNECTEX) (SOCKET s, const struct sockaddr* name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength,LPDWORD lpdwBytesSent, LPOVERLAPPED lpOverlapped);\\1\nstruct uv_tcp_s {" CONTENTS_NEW "${CONTENTS}") + file(WRITE "libuv/include/uv.h" "${CONTENTS_NEW}") endif () add_subdirectory(libuv) endif(${BUILD_WITH_UV}) @@ -249,10 +250,14 @@ endif(${BUILD_WITH_SQLITE}) # pthread if(${BUILD_PTHREAD}) - ADD_DEFINITIONS("-DPTW32_STATIC_LIB") - add_subdirectory(pthread-win32) + add_definitions(-DPTW32_STATIC_LIB) + add_subdirectory(pthread) endif(${BUILD_PTHREAD}) +# iconv +if(${BUILD_WITH_ICONV}) + add_subdirectory(iconv) +endif(${BUILD_WITH_ICONV}) # ================================================================================================ # Build test diff --git a/include/os/osFile.h b/include/os/osFile.h index 209cecedf8..508a522679 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -22,15 +22,6 @@ extern "C" { #include "osSocket.h" -#if defined(WINDOWS) -typedef int32_t FileFd; -typedef int32_t SocketFd; -#else -typedef int32_t FileFd; -typedef int32_t SocketFd; -#endif - -int64_t taosRead(FileFd fd, void *buf, int64_t count); // If the error is in a third-party library, place this header file under the third-party library header file. #ifndef ALLOW_FORBID_FUNC #define open OPEN_FUNC_TAOS_FORBID @@ -42,6 +33,7 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count); #define close CLOSE_FUNC_TAOS_FORBID #define fclose FCLOSE_FUNC_TAOS_FORBID #define fsync FSYNC_FUNC_TAOS_FORBID + #define getline GETLINE_FUNC_TAOS_FORBID // #define fflush FFLUSH_FUNC_TAOS_FORBID #endif @@ -49,15 +41,6 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count); #define PATH_MAX 256 #endif -typedef int32_t FileFd; - -typedef struct TdFile { - pthread_rwlock_t rwlock; - int refId; - FileFd fd; - FILE *fp; -} * TdFilePtr, TdFile; - typedef struct TdFile *TdFilePtr; #define TD_FILE_CTEATE 0x0001 @@ -95,10 +78,6 @@ int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset) int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count); void taosFprintfFile(TdFilePtr pFile, const char *format, ...); -#if defined(WINDOWS) -#define __restrict__ -#endif // WINDOWS - int64_t taosGetLineFile(TdFilePtr pFile, char ** __restrict__ ptrBuf); int32_t taosEOFFile(TdFilePtr pFile); @@ -111,15 +90,7 @@ int32_t taosRemoveFile(const char *path); void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); -#if defined(_TD_DARWIN_64) -typedef int32_t SocketFd; - -int64_t taosSendFile(SocketFd fdDst, FileFd pFileSrc, int64_t *offset, int64_t size); -int64_t taosFSendFile(FILE *pFileOut, FILE *pFileIn, int64_t *offset, int64_t size); -#else -int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size); int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size); -#endif void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length); bool taosValidFile(TdFilePtr pFile); diff --git a/include/os/osString.h b/include/os/osString.h index 88160dd69e..80e925e18d 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -20,16 +20,19 @@ extern "C" { #endif +// If the error is in a third-party library, place this header file under the third-party library header file. +#ifndef ALLOW_FORBID_FUNC + #define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID + #define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID + #define iconv ICONV_FUNC_TAOS_FORBID +#endif + +typedef int32_t TdUcs4; + #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #define tstrdup(str) _strdup(str) - #define tstrndup(str, size) _strndup(str, size) - int32_t tgetline(char **lineptr, size_t *n, FILE *stream); - int32_t twcslen(const wchar_t *wcs); #else #define tstrdup(str) strdup(str) - #define tstrndup(str, size) strndup(str, size) - #define tgetline(lineptr, n, stream) getline(lineptr, n, stream) - #define twcslen wcslen #endif #define tstrncpy(dst, src, size) \ @@ -38,12 +41,12 @@ extern "C" { (dst)[(size)-1] = 0; \ } while (0) +int32_t taosUcs4len(TdUcs4 *ucs4); int64_t taosStr2int64(const char *str); -// USE_LIBICONV -int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs); -bool taosMbsToUcs4(const char *mbs, size_t mbs_len, char *ucs4, int32_t ucs4_max_len, int32_t *len); -int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize); +int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); +bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); +int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes); bool taosValidateEncodec(const char *encodec); #ifdef __cplusplus diff --git a/include/util/tdef.h b/include/util/tdef.h index 41a61ceb55..a59a23b5d0 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -41,7 +41,7 @@ extern const int32_t TYPE_BYTES[15]; #define DOUBLE_BYTES sizeof(double) #define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*) #define TSDB_KEYSIZE sizeof(TSKEY) -#define TSDB_NCHAR_SIZE sizeof(int32_t) +#define TSDB_NCHAR_SIZE sizeof(TdUcs4) // NULL definition #define TSDB_DATA_BOOL_NULL 0x02 diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index af6152d3f4..703f4402ef 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -343,7 +343,7 @@ int32_t taosVariantToString(SVariant *pVar, char *dst) { case TSDB_DATA_TYPE_NCHAR: { dst[0] = '\''; - taosUcs4ToMbs(pVar->wpz, (twcslen(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); + taosUcs4ToMbs(pVar->wpz, (taosUcs4len(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); int32_t len = (int32_t)strlen(dst); dst[len] = '\''; dst[len + 1] = 0; @@ -460,8 +460,8 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { } if (*pDest == pVariant->pz) { - wchar_t *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE); - bool ret = taosMbsToUcs4(pDst, nLen, (char *)pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); + TdUcs4 *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE); + bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); if (!ret) { tfree(pWStr); return -1; @@ -473,7 +473,7 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { } pVariant->wpz = pWStr; - *pDestSize = twcslen(pVariant->wpz); + *pDestSize = taosUcs4len(pVariant->wpz); // shrink the allocate memory, no need to check here. char *tmp = realloc(pVariant->wpz, (*pDestSize + 1) * TSDB_NCHAR_SIZE); @@ -483,7 +483,7 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { } else { int32_t output = 0; - bool ret = taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); + bool ret = taosMbsToUcs4(pDst, nLen, (TdUcs4*)*pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output); if (!ret) { return -1; } diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 6db3abb9d6..a37820634f 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -622,7 +622,7 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; const char* rowEnd = tdRowEnd(rb->pBuf); - if (!taosMbsToUcs4(value, len, (char*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { + if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } varDataSetLen(rowEnd, output); @@ -725,7 +725,7 @@ static int32_t KvRowAppend(const void *value, int32_t len, void *param) { } else if (TSDB_DATA_TYPE_NCHAR == type) { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; - if (!taosMbsToUcs4(value, len, varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { + if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 33ec8ab6ef..58b5c8340a 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1813,7 +1813,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { if(type == TSDB_DATA_TYPE_NCHAR && (unit->compare.optr == OP_TYPE_MATCH || unit->compare.optr == OP_TYPE_NMATCH)){ char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; - int32_t len = taosUcs4ToMbs(varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); + int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); if (len < 0){ qError("filterInitValFieldData taosUcs4ToMbs error 1"); return TSDB_CODE_QRY_APP_ERROR; @@ -2992,7 +2992,7 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)){ char *newColData = calloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int32_t len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0){ qError("castConvert1 taosUcs4ToMbs error"); }else{ @@ -3052,7 +3052,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDataAg } else { if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)){ char *newColData = calloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int32_t len = taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); if (len < 0){ qError("castConvert1 taosUcs4ToMbs error"); }else{ @@ -3433,7 +3433,7 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar varDataCopy(dst, src); continue; } - bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len); + bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), (TdUcs4*)varDataVal(dst), bufSize, &len); if(!ret) { qError("filterConverNcharColumns taosMbsToUcs4 error"); return TSDB_CODE_FAILED; diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 0fe7bf6e36..17ac9b19fd 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -316,7 +316,7 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t tmp = realloc(tmp, bufSize); } - int len = taosUcs4ToMbs(varDataVal(pIn->data), varDataLen(pIn->data), tmp); + int len = taosUcs4ToMbs((TdUcs4*)varDataVal(pIn->data), varDataLen(pIn->data), tmp); if (len < 0){ sclError("castConvert taosUcs4ToMbs error 1"); tfree(tmp); diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index ed240015d4..eea3903911 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -5,9 +5,14 @@ target_include_directories( PUBLIC "${CMAKE_SOURCE_DIR}/include/os" PUBLIC "${CMAKE_SOURCE_DIR}/include" PUBLIC "${CMAKE_SOURCE_DIR}/include/util" - PUBLIC "${CMAKE_SOURCE_DIR}/contrib/pthread-win32" + PUBLIC "${CMAKE_SOURCE_DIR}/contrib/pthread" PUBLIC "${CMAKE_SOURCE_DIR}/contrib/gnuregex" ) +# iconv +find_path(IconvApiIncludes iconv.h PATHS) +if(NOT IconvApiIncludes) + add_definitions(-DDISALLOW_NCHAR_WITHOUT_ICONV) +endif () target_link_libraries( os pthread dl rt m ) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index bcbd95e160..5e859de5d6 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -46,6 +46,23 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */ #define O_TEXT LINUX_FILE_NO_TEXT_OPTION #endif +#if defined(WINDOWS) +typedef int32_t FileFd; +typedef int32_t SocketFd; +#else +typedef int32_t FileFd; +typedef int32_t SocketFd; +#endif + +typedef int32_t FileFd; + +typedef struct TdFile { + pthread_rwlock_t rwlock; + int refId; + FileFd fd; + FILE *fp; +} * TdFilePtr, TdFile; + #define FILE_WITH_LOCK 1 void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { diff --git a/source/os/src/osLocale.c b/source/os/src/osLocale.c index e9d6ed7c54..5f12f9cd3d 100644 --- a/source/os/src/osLocale.c +++ b/source/os/src/osLocale.c @@ -81,7 +81,7 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) { } if (!taosValidateEncodec(inCharSet)) { - printf("Invalid charset:%s, please set the valid charset in config file", inCharSet); + printf("Invalid charset:%s, please set the valid charset in config file\n", inCharSet); exit(-1); } } diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 1052d108af..18f6ceb5a0 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -13,287 +13,32 @@ * along with this program. If not, see . */ +#define ALLOW_FORBID_FUNC #define _DEFAULT_SOURCE #include "os.h" -#include "tdef.h" -#include -#include +// #include "tdef.h" +// #include +// #include +#ifndef DISALLOW_NCHAR_WITHOUT_ICONV +#include "iconv.h" +#endif int64_t taosStr2int64(const char *str) { char *endptr = NULL; return strtoll(str, &endptr, 10); } -#ifdef USE_LIBICONV -#include "iconv.h" - -int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { - iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC); - size_t ucs4_input_len = ucs4_max_len; - size_t outLen = ucs4_max_len; - if (iconv(cd, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) { - iconv_close(cd); - return -1; - } - - iconv_close(cd); - return (int32_t)(ucs4_max_len - outLen); -} - -bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { - memset(ucs4, 0, ucs4_max_len); - iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); - size_t ucs4_input_len = mbsLength; - size_t outLeft = ucs4_max_len; - if (iconv(cd, &mbs, &ucs4_input_len, &ucs4, &outLeft) == -1) { - iconv_close(cd); - return false; - } - - iconv_close(cd); - if (len != NULL) { - *len = (int32_t)(ucs4_max_len - outLeft); - if (*len < 0) { - return false; - } - } - - return true; -} - -bool taosValidateEncodec(const char *encodec) { - iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); - if (cd == (iconv_t)(-1)) { - return false; - } - - iconv_close(cd); - return true; -} - +bool taosCheckNcharValid(void) { +#ifdef DISALLOW_NCHAR_WITHOUT_ICONV + return false; #else - -int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { - mbstate_t state = {0}; - int32_t len = (int32_t)wcsnrtombs(NULL, (const wchar_t **)&ucs4, ucs4_max_len / 4, 0, &state); - if (len < 0) { - return -1; - } - - memset(&state, 0, sizeof(state)); - len = wcsnrtombs(mbs, (const wchar_t **)&ucs4, ucs4_max_len / 4, (size_t)len, &state); - if (len < 0) { - return -1; - } - - return len; -} - -bool taosMbsToUcs4(const char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { - memset(ucs4, 0, ucs4_max_len); - mbstate_t state = {0}; - int32_t retlen = mbsnrtowcs((wchar_t *)ucs4, (const char **)&mbs, mbsLength, ucs4_max_len / 4, &state); - *len = retlen; - - return retlen >= 0; -} - -bool taosValidateEncodec(const char *encodec) { return true; -} - #endif - -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) - -/* - * windows implementation - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#if STDC_HEADERS -#include -#else -char *malloc(), *realloc(); -#endif - -/* Always add at least this many bytes when extending the buffer. */ -#define MIN_CHUNK 64 - -/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR -+ OFFSET (and null-terminate it). *LINEPTR is a pointer returned from -malloc (or NULL), pointing to *N characters of space. It is realloc'd -as necessary. Return the number of characters read (not including the -null terminator), or -1 on error or EOF. On a -1 return, the caller -should check feof(), if not then errno has been set to indicate -the error. */ - -int32_t getstr(char **lineptr, size_t *n, FILE *stream, char terminator, int32_t offset) { - int32_t nchars_avail; /* Allocated but unused chars in *LINEPTR. */ - char * read_pos; /* Where we're reading into *LINEPTR. */ - int32_t ret; - - if (!lineptr || !n || !stream) { - errno = EINVAL; - return -1; - } - - if (!*lineptr) { - *n = MIN_CHUNK; - *lineptr = malloc(*n); - if (!*lineptr) { - errno = ENOMEM; - return -1; - } - } - - nchars_avail = (int32_t)(*n - offset); - read_pos = *lineptr + offset; - - for (;;) { - int32_t save_errno; - register int32_t c = getc(stream); - - save_errno = errno; - - /* We always want at least one char left in the buffer, since we - always (unless we get an error while reading the first char) - NUL-terminate the line buffer. */ - - assert((*lineptr + *n) == (read_pos + nchars_avail)); - if (nchars_avail < 2) { - if (*n > MIN_CHUNK) - *n *= 2; - else - *n += MIN_CHUNK; - - nchars_avail = (int32_t)(*n + *lineptr - read_pos); - char* lineptr1 = realloc(*lineptr, *n); - if (!lineptr1) { - errno = ENOMEM; - return -1; - } - *lineptr = lineptr1; - - read_pos = *n - nchars_avail + *lineptr; - assert((*lineptr + *n) == (read_pos + nchars_avail)); - } - - if (ferror(stream)) { - /* Might like to return partial line, but there is no - place for us to store errno. And we don't want to just - lose errno. */ - errno = save_errno; - return -1; - } - - if (c == EOF) { - /* Return partial line, if any. */ - if (read_pos == *lineptr) - return -1; - else - break; - } - - *read_pos++ = c; - nchars_avail--; - - if (c == terminator) /* Return the line. */ - break; - } - - /* Done - NUL terminate and return the number of chars read. */ - *read_pos = '\0'; - - ret = (int32_t)(read_pos - (*lineptr + offset)); - return ret; } -int32_t tgetline(char **lineptr, size_t *n, FILE *stream) { return getstr(lineptr, n, stream, '\n', 0); } - - -/* - * Get next token from string *stringp, where tokens are possibly-empty - * strings separated by characters from delim. - * - * Writes NULs into the string at *stringp to end tokens. - * delim need not remain constant from call to call. - * On return, *stringp points past the last NUL written (if there might - * be further tokens), or is NULL (if there are definitely no moretokens). - * - * If *stringp is NULL, strsep returns NULL. - */ -char *strsep(char **stringp, const char *delim) { - char * s; - const char *spanp; - int32_t c, sc; - char *tok; - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} - -char *getpass(const char *prefix) { - static char passwd[TSDB_PASSWORD_LEN] = {0}; - memset(passwd, 0, TSDB_PASSWORD_LEN); - //printf("%s", prefix); - - int32_t index = 0; - char ch; - while (index < TSDB_PASSWORD_LEN) { - ch = getch(); - if (ch == '\n' || ch == '\r') { - break; - } else { - passwd[index++] = ch; - } - } - - return passwd; -} - -int32_t twcslen(const wchar_t *wcs) { - int32_t *wstr = (int32_t *)wcs; - if (NULL == wstr) { - return 0; - } - - int32_t n = 0; - while (1) { - if (0 == *wstr++) { - break; - } - n++; - } - - return n; -} -int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) { - for (int32_t i = 0; i < bytes; i += TSDB_NCHAR_SIZE) { +int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) { + for (int32_t i = 0; i < bytes; i += sizeof(TdUcs4)) { int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i); int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i); @@ -327,38 +72,413 @@ int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) { #endif } -/* Copy memory to memory until the specified number of bytes -has been copied, return pointer to following byte. -Overlap is NOT handled correctly. */ -void *mempcpy(void *dest, const void *src, size_t len) { - return (char*)memcpy(dest, src, len) + len; -} - -/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -char *stpcpy (char *dest, const char *src) { - size_t len = strlen (src); - return (char*)memcpy(dest, src, len + 1) + len; -} - -/* Copy no more than N characters of SRC to DEST, returning the address of - the terminating '\0' in DEST, if any, or else DEST + N. */ -char *stpncpy (char *dest, const char *src, size_t n) { - size_t size = strnlen (src, n); - memcpy (dest, src, size); - dest += size; - if (size == n) - return dest; - return memset (dest, '\0', n - size); -} - +int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { +#ifdef DISALLOW_NCHAR_WITHOUT_ICONV + return -1; #else + iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC); + size_t ucs4_input_len = ucs4_max_len; + size_t outLen = ucs4_max_len; + if (iconv(cd, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) { + iconv_close(cd); + return -1; + } -/* - * linux and darwin implementation - */ - -int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize) { - return wcsncmp((wchar_t *)f1_ucs4, (wchar_t *)f2_ucs4, bytes / ncharSize); + iconv_close(cd); + return (int32_t)(ucs4_max_len - outLen); +#endif } +bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) { +#ifdef DISALLOW_NCHAR_WITHOUT_ICONV + return -1; +#else + memset(ucs4, 0, ucs4_max_len); + iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); + size_t ucs4_input_len = mbsLength; + size_t outLeft = ucs4_max_len; + if (iconv(cd, (char**)&mbs, &ucs4_input_len, (char**)&ucs4, &outLeft) == -1) { + iconv_close(cd); + return false; + } + + iconv_close(cd); + if (len != NULL) { + *len = (int32_t)(ucs4_max_len - outLeft); + if (*len < 0) { + return false; + } + } + + return true; #endif +} + +bool taosValidateEncodec(const char *encodec) { +#ifdef DISALLOW_NCHAR_WITHOUT_ICONV + return false; +#else + iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); + if (cd == (iconv_t)(-1)) { + return false; + } + + iconv_close(cd); + return true; +#endif +} + +int32_t taosUcs4len(TdUcs4 *ucs4) { + TdUcs4 *wstr = (TdUcs4 *)ucs4; + if (NULL == wstr) { + return 0; + } + + int32_t n = 0; + while (1) { + if (0 == *wstr++) { + break; + } + n++; + } + + return n; +} + +// #ifdef USE_LIBICONV +// #include "iconv.h" + +// int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { +// iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC); +// size_t ucs4_input_len = ucs4_max_len; +// size_t outLen = ucs4_max_len; +// if (iconv(cd, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) { +// iconv_close(cd); +// return -1; +// } + +// iconv_close(cd); +// return (int32_t)(ucs4_max_len - outLen); +// } + +// bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { +// memset(ucs4, 0, ucs4_max_len); +// iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); +// size_t ucs4_input_len = mbsLength; +// size_t outLeft = ucs4_max_len; +// if (iconv(cd, &mbs, &ucs4_input_len, &ucs4, &outLeft) == -1) { +// iconv_close(cd); +// return false; +// } + +// iconv_close(cd); +// if (len != NULL) { +// *len = (int32_t)(ucs4_max_len - outLeft); +// if (*len < 0) { +// return false; +// } +// } + +// return true; +// } + +// bool taosValidateEncodec(const char *encodec) { +// iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); +// if (cd == (iconv_t)(-1)) { +// return false; +// } + +// iconv_close(cd); +// return true; +// } + +// #else + +// int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { +// mbstate_t state = {0}; +// int32_t len = (int32_t)wcsnrtombs(NULL, (const wchar_t **)&ucs4, ucs4_max_len / 4, 0, &state); +// if (len < 0) { +// return -1; +// } + +// memset(&state, 0, sizeof(state)); +// len = wcsnrtombs(mbs, (const wchar_t **)&ucs4, ucs4_max_len / 4, (size_t)len, &state); +// if (len < 0) { +// return -1; +// } + +// return len; +// } + +// bool taosMbsToUcs4(const char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { +// memset(ucs4, 0, ucs4_max_len); +// mbstate_t state = {0}; +// int32_t retlen = mbsnrtowcs((wchar_t *)ucs4, (const char **)&mbs, mbsLength, ucs4_max_len / 4, &state); +// *len = retlen; + +// return retlen >= 0; +// } + +// bool taosValidateEncodec(const char *encodec) { +// return true; +// } + +// #endif + +// #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) + +// /* +// * windows implementation +// */ + +// #ifdef HAVE_CONFIG_H +// #include +// #endif + +// #include +// #include +// #include +// #include +// #include + +// #if STDC_HEADERS +// #include +// #else +// char *malloc(), *realloc(); +// #endif + +// /* Always add at least this many bytes when extending the buffer. */ +// #define MIN_CHUNK 64 + +// /* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR +// + OFFSET (and null-terminate it). *LINEPTR is a pointer returned from +// malloc (or NULL), pointing to *N characters of space. It is realloc'd +// as necessary. Return the number of characters read (not including the +// null terminator), or -1 on error or EOF. On a -1 return, the caller +// should check feof(), if not then errno has been set to indicate +// the error. */ + +// int32_t getstr(char **lineptr, size_t *n, FILE *stream, char terminator, int32_t offset) { +// int32_t nchars_avail; /* Allocated but unused chars in *LINEPTR. */ +// char * read_pos; /* Where we're reading into *LINEPTR. */ +// int32_t ret; + +// if (!lineptr || !n || !stream) { +// errno = EINVAL; +// return -1; +// } + +// if (!*lineptr) { +// *n = MIN_CHUNK; +// *lineptr = malloc(*n); +// if (!*lineptr) { +// errno = ENOMEM; +// return -1; +// } +// } + +// nchars_avail = (int32_t)(*n - offset); +// read_pos = *lineptr + offset; + +// for (;;) { +// int32_t save_errno; +// register int32_t c = getc(stream); + +// save_errno = errno; + +// /* We always want at least one char left in the buffer, since we +// always (unless we get an error while reading the first char) +// NUL-terminate the line buffer. */ + +// assert((*lineptr + *n) == (read_pos + nchars_avail)); +// if (nchars_avail < 2) { +// if (*n > MIN_CHUNK) +// *n *= 2; +// else +// *n += MIN_CHUNK; + +// nchars_avail = (int32_t)(*n + *lineptr - read_pos); +// char* lineptr1 = realloc(*lineptr, *n); +// if (!lineptr1) { +// errno = ENOMEM; +// return -1; +// } +// *lineptr = lineptr1; + +// read_pos = *n - nchars_avail + *lineptr; +// assert((*lineptr + *n) == (read_pos + nchars_avail)); +// } + +// if (ferror(stream)) { +// /* Might like to return partial line, but there is no +// place for us to store errno. And we don't want to just +// lose errno. */ +// errno = save_errno; +// return -1; +// } + +// if (c == EOF) { +// /* Return partial line, if any. */ +// if (read_pos == *lineptr) +// return -1; +// else +// break; +// } + +// *read_pos++ = c; +// nchars_avail--; + +// if (c == terminator) /* Return the line. */ +// break; +// } + +// /* Done - NUL terminate and return the number of chars read. */ +// *read_pos = '\0'; + +// ret = (int32_t)(read_pos - (*lineptr + offset)); +// return ret; +// } + +// int32_t tgetline(char **lineptr, size_t *n, FILE *stream) { return getstr(lineptr, n, stream, '\n', 0); } + + +// /* +// * Get next token from string *stringp, where tokens are possibly-empty +// * strings separated by characters from delim. +// * +// * Writes NULs into the string at *stringp to end tokens. +// * delim need not remain constant from call to call. +// * On return, *stringp points past the last NUL written (if there might +// * be further tokens), or is NULL (if there are definitely no moretokens). +// * +// * If *stringp is NULL, strsep returns NULL. +// */ +// char *strsep(char **stringp, const char *delim) { +// char * s; +// const char *spanp; +// int32_t c, sc; +// char *tok; +// if ((s = *stringp) == NULL) +// return (NULL); +// for (tok = s;;) { +// c = *s++; +// spanp = delim; +// do { +// if ((sc = *spanp++) == c) { +// if (c == 0) +// s = NULL; +// else +// s[-1] = 0; +// *stringp = s; +// return (tok); +// } +// } while (sc != 0); +// } +// /* NOTREACHED */ +// } + +// char *getpass(const char *prefix) { +// static char passwd[TSDB_PASSWORD_LEN] = {0}; +// memset(passwd, 0, TSDB_PASSWORD_LEN); +// //printf("%s", prefix); + +// int32_t index = 0; +// char ch; +// while (index < TSDB_PASSWORD_LEN) { +// ch = getch(); +// if (ch == '\n' || ch == '\r') { +// break; +// } else { +// passwd[index++] = ch; +// } +// } + +// return passwd; +// } + +// int32_t twcslen(const wchar_t *wcs) { +// int32_t *wstr = (int32_t *)wcs; +// if (NULL == wstr) { +// return 0; +// } + +// int32_t n = 0; +// while (1) { +// if (0 == *wstr++) { +// break; +// } +// n++; +// } + +// return n; +// } +// int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) { +// for (int32_t i = 0; i < bytes; i += TSDB_NCHAR_SIZE) { +// int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i); +// int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i); + +// if ((f1 == 0 && f2 != 0) || (f1 != 0 && f2 == 0)) { +// return f1 - f2; +// } else if (f1 == 0 && f2 == 0) { +// return 0; +// } + +// if (f1 != f2) { +// return f1 - f2; +// } +// } + +// return 0; + +// #if 0 +// int32_t ucs4_max_len = bytes + 4; +// char *f1_mbs = calloc(bytes, 1); +// char *f2_mbs = calloc(bytes, 1); +// if (taosUcs4ToMbs(f1_ucs4, ucs4_max_len, f1_mbs) < 0) { +// return -1; +// } +// if (taosUcs4ToMbs(f2_ucs4, ucs4_max_len, f2_mbs) < 0) { +// return -1; +// } +// int32_t ret = strcmp(f1_mbs, f2_mbs); +// free(f1_mbs); +// free(f2_mbs); +// return ret; +// #endif +// } + +// /* Copy memory to memory until the specified number of bytes +// has been copied, return pointer to following byte. +// Overlap is NOT handled correctly. */ +// void *mempcpy(void *dest, const void *src, size_t len) { +// return (char*)memcpy(dest, src, len) + len; +// } + +// /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +// char *stpcpy (char *dest, const char *src) { +// size_t len = strlen (src); +// return (char*)memcpy(dest, src, len + 1) + len; +// } + +// /* Copy no more than N characters of SRC to DEST, returning the address of +// the terminating '\0' in DEST, if any, or else DEST + N. */ +// char *stpncpy (char *dest, const char *src, size_t n) { +// size_t size = strnlen (src, n); +// memcpy (dest, src, size); +// dest += size; +// if (size == n) +// return dest; +// return memset (dest, '\0', n - size); +// } + +// #else + +// /* +// * linux and darwin implementation +// */ + +// int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize) { +// return wcsncmp((wchar_t *)f1_ucs4, (wchar_t *)f2_ucs4, bytes / ncharSize); +// } + +// #endif From a3795f4017a2e7e38a902733b8afb3c0ad248a90 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 18 Mar 2022 14:44:10 +0800 Subject: [PATCH 42/60] [TD-14099] --- source/libs/planner/src/planLogicCreater.c | 3 +- tests/script/tsim/query/interval.sim | 254 ++++++++++----------- 2 files changed, 117 insertions(+), 140 deletions(-) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index cd9857c7f6..76a8fc3bd6 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -310,7 +310,8 @@ static SLogicNode* createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInt pWindow->node.id = pCxt->planNodeId++; pWindow->winType = WINDOW_TYPE_INTERVAL; - SValueNode* pIntervalNode = (SValueNode*)((SRawExprNode*)(pInterval->pInterval))->pNode; + //SValueNode* pIntervalNode = (SValueNode*)((SRawExprNode*)(pInterval->pInterval))->pNode; + SValueNode* pIntervalNode = (SValueNode*)(pInterval->pInterval); pWindow->interval = pIntervalNode->datum.i; pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0); diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim index 35e7c938d8..47be71bdc6 100644 --- a/tests/script/tsim/query/interval.sim +++ b/tests/script/tsim/query/interval.sim @@ -47,161 +47,137 @@ $i = 1 $tb = $tbPrefix . $i sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) -print ===> $rows -if $rows < $rowNum then +print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows $data01 $data05 +if $rows != $rowNum then return -1 endi -if $data01 != 1 then +if $data00 != 1 then return -1 endi -if $data05 != 1 then +if $data04 != 1 then return -1 endi -print =============== step3 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) -print ===> $rows -if $rows > 10 then - return -1 -endi -if $rows < 3 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data05 != 1 then - return -1 -endi +#print =============== step3 +#$cc = 4 * 60000 +#$ms = 1601481600000 + $cc +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +#print ===> $rows $data01 $data05 +#if $rows != 5 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi -print =============== step4 -$cc = 40 * 60000 -$ms = 1601481600000 + $cc +#print =============== step4 +#$cc = 40 * 60000 +#$ms = 1601481600000 + $cc -$cc = 1 * 60000 -$ms2 = 1601481600000 - $cc +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data01 != 1 then - return -1 -endi -if $data05 != 1 then - return -1 -endi +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +#print ===> $rows $data01 $data05 +#if $rows != 20 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi -print =============== step5 -$cc = 40 * 60000 -$ms = 1601481600000 + $cc +#print =============== step5 +#$cc = 40 * 60000 +#$ms = 1601481600000 + $cc -$cc = 1 * 60000 -$ms2 = 1601481600000 - $cc +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) -print ===> $rows -if $rows < 30 then - return -1 -endi -if $rows > 50 then - return -1 -endi -if $data21 != 1 then - return -1 -endi -if $data25 != 1 then - return -1 -endi +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +#print ===> $rows $data21 $data25 +#if $rows != 42 then +# return -1 +#endi +#if $data20 != 1 then +# return -1 +#endi +#if $data24 != 1 then +# return -1 +#endi -print =============== step6 -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi +#print =============== step6 +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +#print ===> $rows $data11 +#if $rows != 20 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi -print =============== step7 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) -print ===> $rows -if $rows < 3 then - return -1 -endi -if $rows > 7 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi +#print =============== step7 +#$cc = 4 * 60000 +#$ms = 1601481600000 + $cc +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +#print ===> $rows $data11 +#if $rows != 5 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi -print =============== step8 -$cc = 40 * 60000 -$ms1 = 1601481600000 + $cc - -$cc = 1 * 60000 -$ms2 = 1601481600000 - $cc - -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) -print ===> $rows -if $rows < 18 then - return -1 -endi -if $rows > 22 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi - -print =============== step9 -$cc = 40 * 60000 -$ms1 = 1601481600000 + $cc - -$cc = 1 * 60000 -$ms2 = 1601481600000 - $cc - -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) -if $rows < 30 then - return -1 -endi -if $rows > 50 then - return -1 -endi -if $data11 > 15 then - return -1 -endi -if $data11 < 5 then - return -1 -endi +#print =============== step8 +#$cc = 40 * 60000 +#$ms1 = 1601481600000 + $cc +# +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc +# +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +#print ===> $rows $data11 +#if $rows != 20 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi +# +#print =============== step9 +#$cc = 40 * 60000 +#$ms1 = 1601481600000 + $cc +# +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc +# +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +#print ===> $rows $data11 +#if $rows != 42 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi print =============== clear -sql drop database $db -sql show databases -if $rows != 0 then - return -1 -endi +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +#system sh/exec.sh -n dnode1 -s stop -x SIGINT From b5547c7a3daf34a5d4124460c0200b5bb9a40c5f Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 15:05:56 +0800 Subject: [PATCH 43/60] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 141 ++++++++++++++++++++--- source/libs/sync/src/syncCommit.c | 19 ++- 2 files changed, 141 insertions(+), 19 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 7013d281e3..c490b82d68 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -94,6 +94,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { } assert(pMsg->term <= ths->pRaftStore->currentTerm); + // reset elect timer if (pMsg->term == ths->pRaftStore->currentTerm) { ths->leaderCache = pMsg->srcId; syncNodeResetElectTimer(ths); @@ -135,38 +136,117 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE) { syncNodeBecomeFollower(ths); - // need ret? + // ret or reply? return ret; } // accept request if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_FOLLOWER && logOK) { - bool matchSuccess = false; + bool preMatch = false; if (pMsg->prevLogIndex == SYNC_INDEX_INVALID && ths->pLogStore->getLastIndex(ths->pLogStore) == SYNC_INDEX_INVALID) { - matchSuccess = true; + preMatch = true; } if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { SSyncRaftEntry* pPreEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); assert(pPreEntry != NULL); if (pMsg->prevLogTerm == pPreEntry->term) { - matchSuccess = true; + preMatch = true; } syncEntryDestory(pPreEntry); } - if (matchSuccess) { - // delete conflict entries - if (pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore)) { - SyncIndex fromIndex = pMsg->prevLogIndex + 1; - ths->pLogStore->truncate(ths->pLogStore, fromIndex); - } + if (preMatch) { + // must has preIndex in local log + assert(pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)); - // append one entry - if (pMsg->dataLen > 0) { - SSyncRaftEntry* pEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); - ths->pLogStore->appendEntry(ths->pLogStore, pEntry); - syncEntryDestory(pEntry); + bool hasExtraEntries = pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore); + bool hasAppendEntries = pMsg->dataLen > 0; + + if (hasExtraEntries && hasAppendEntries) { + // conflict + bool conflict = false; + + SyncIndex extraIndex = pMsg->prevLogIndex + 1; + SSyncRaftEntry* pExtraEntry = logStoreGetEntry(ths->pLogStore, extraIndex); + assert(pExtraEntry != NULL); + + SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); + assert(pAppendEntry != NULL); + + assert(extraIndex == pAppendEntry->index); + if (pExtraEntry->term == pAppendEntry->term) { + conflict = true; + } + + if (conflict) { + // roll back + SyncIndex delBegin = ths->pLogStore->getLastIndex(ths->pLogStore); + SyncIndex delEnd = extraIndex; + + // notice! reverse roll back! + for (SyncIndex index = delEnd; index >= delBegin; --index) { + if (ths->pFsm->FpRollBackCb != NULL) { + SSyncRaftEntry* pRollBackEntry = logStoreGetEntry(ths->pLogStore, index); + assert(pRollBackEntry != NULL); + + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pRollBackEntry, &rpcMsg); + ths->pFsm->FpRollBackCb(ths->pFsm, &rpcMsg, pRollBackEntry->index, pRollBackEntry->isWeak, 0); + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pRollBackEntry); + } + } + + // delete confict entries + ths->pLogStore->truncate(ths->pLogStore, extraIndex); + + // append new entries + ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); + + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); + if (ths->pFsm != NULL) { + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pAppendEntry->index, pAppendEntry->isWeak, 0); + } + } + rpcFreeCont(rpcMsg.pCont); + } + + // free memory + syncEntryDestory(pExtraEntry); + syncEntryDestory(pAppendEntry); + + } else if (hasExtraEntries && !hasAppendEntries) { + // do nothing + + } else if (!hasExtraEntries && hasAppendEntries) { + SSyncRaftEntry* pAppendEntry = syncEntryDeserialize(pMsg->data, pMsg->dataLen); + assert(pAppendEntry != NULL); + + // append new entries + ths->pLogStore->appendEntry(ths->pLogStore, pAppendEntry); + + // pre commit + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pAppendEntry, &rpcMsg); + if (ths->pFsm != NULL) { + if (ths->pFsm->FpPreCommitCb != NULL) { + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pAppendEntry->index, pAppendEntry->isWeak, 0); + } + } + rpcFreeCont(rpcMsg.pCont); + + // free memory + syncEntryDestory(pAppendEntry); + + } else if (!hasExtraEntries && !hasAppendEntries) { + // do nothing + + } else { + assert(0); } SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(); @@ -175,7 +255,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { pReply->term = ths->pRaftStore->currentTerm; pReply->success = true; - if (pMsg->dataLen > 0) { + if (hasAppendEntries > 0) { pReply->matchIndex = pMsg->prevLogIndex + 1; } else { pReply->matchIndex = pMsg->prevLogIndex; @@ -201,11 +281,38 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { syncAppendEntriesReplyDestroy(pReply); } + // maybe update commit index from leader if (pMsg->commitIndex > ths->commitIndex) { + // has commit entry in local if (pMsg->commitIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - // commit + SyncIndex beginIndex = ths->commitIndex + 1; + SyncIndex endIndex = pMsg->commitIndex; + + // update commit index ths->commitIndex = pMsg->commitIndex; + + // call back Wal ths->pLogStore->updateCommitIndex(ths->pLogStore, ths->commitIndex); + + // execute fsm + if (ths->pFsm != NULL) { + for (SyncIndex i = beginIndex; i <= endIndex; ++i) { + if (i != SYNC_INDEX_INVALID) { + SSyncRaftEntry* pEntry = ths->pLogStore->getEntry(ths->pLogStore, i); + assert(pEntry != NULL); + + SRpcMsg rpcMsg; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + if (ths->pFsm->FpCommitCb != NULL) { + ths->pFsm->FpCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, 0); + } + + rpcFreeCont(rpcMsg.pCont); + syncEntryDestory(pEntry); + } + } + } } } } diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 539bb21b71..c75d23d96d 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -17,6 +17,7 @@ #include "syncIndexMgr.h" #include "syncInt.h" #include "syncRaftLog.h" +#include "syncRaftStore.h" // \* Leader i advances its commitIndex. // \* This is done as a separate step from handling AppendEntries responses, @@ -50,16 +51,30 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { for (SyncIndex index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore); index > pSyncNode->commitIndex; ++index) { if (syncAgree(pSyncNode, index)) { - newCommitIndex = index; - break; + // term + SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); + assert(pEntry != NULL); + + // cannot commit, even if quorum agree. need check term! + if (pEntry->term == pSyncNode->pRaftStore->currentTerm) { + // update commit index + newCommitIndex = index; + break; + } } } if (newCommitIndex > pSyncNode->commitIndex) { SyncIndex beginIndex = pSyncNode->commitIndex + 1; SyncIndex endIndex = newCommitIndex; + + // update commit index pSyncNode->commitIndex = newCommitIndex; + // call back Wal + pSyncNode->pLogStore->updateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex); + + // execute fsm if (pSyncNode->pFsm != NULL) { for (SyncIndex i = beginIndex; i <= endIndex; ++i) { if (i != SYNC_INDEX_INVALID) { From aa28fd87e6ec74545a752ef1e44e1f6ca64b7d64 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 18 Mar 2022 15:08:20 +0800 Subject: [PATCH 44/60] [add cases] --- tests/script/tsim/insert/basic1.sim | 94 +++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/script/tsim/insert/basic1.sim diff --git a/tests/script/tsim/insert/basic1.sim b/tests/script/tsim/insert/basic1.sim new file mode 100644 index 0000000000..3fc635532a --- /dev/null +++ b/tests/script/tsim/insert/basic1.sim @@ -0,0 +1,94 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print =============== create database +sql create database d1 +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +sql use d1 + +print =============== create super table, include all type +sql create table if not exists stb (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(16), c9 nchar(16), c10 timestamp, c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned) tags (t1 bool, t2 tinyint, t3 smallint, t4 int, t5 bigint, t6 float, t7 double, t8 binary(16), t9 nchar(16), t10 timestamp, t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned) + +sql create stable if not exists stb_1 (ts timestamp, i int) tags (j int) +sql create table stb_2 (ts timestamp, i int) tags (j int) +sql create stable stb_3 (ts timestamp, i int) tags (j int) + +sql show stables +if $rows != 4 then + return -1 +endi + +print =============== create child table +sql create table c1 using stb tags(true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql create table c2 using stb tags(false, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 2', 'child tbl 2', '2022-02-25 18:00:00.000', 10, 20, 30, 40) + +sql show tables +if $rows != 2 then + return -1 +endi + + +print =============== insert data, mode1: one row one table in sql +print =============== insert data, mode1: mulit rows one table in sql +print =============== insert data, mode1: one rows mulit table in sql +print =============== insert data, mode1: mulit rows mulit table in sql +sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) +sql insert into c1 values(now+0s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+1s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) (now+2s, true, -1, -2, -3, -4, -6.0, -7.0, 'child tbl 1', 'child tbl 1', '2022-02-25 18:00:00.000', 10, 20, 30, 40) + +print =============== query data +sql select * from c1 +if $rows != 4 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +if $data02 != -1 then + return -1 +endi + +if $data03 != -2 then + return -1 +endi + +print =============== query data from st +sql select * from st +if $rows != 4 then + return -1 +endi + +print =============== stop and restart taosd +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +print =============== query data +sql select * from c1 +if $rows != 4 then + return -1 +endi + +if $data01 != true then + return -1 +endi + +if $data02 != -1 then + return -1 +endi + +if $data03 != -2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT From 5de67d425669ae13ee3e1d7db9667ccb774456a4 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 15:21:40 +0800 Subject: [PATCH 45/60] sync refactor --- source/libs/sync/inc/syncOnMessage.h | 40 ++++++++++++++++++++++++++++ source/libs/sync/src/syncMain.c | 34 +++++++++++++++++++++++ source/libs/sync/src/syncOnMessage.c | 40 ++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/source/libs/sync/inc/syncOnMessage.h b/source/libs/sync/inc/syncOnMessage.h index 7cb186a812..2f8856e652 100644 --- a/source/libs/sync/inc/syncOnMessage.h +++ b/source/libs/sync/inc/syncOnMessage.h @@ -25,6 +25,46 @@ extern "C" { #include #include "taosdef.h" +// TLA+ Spec +// Receive(m) == +// LET i == m.mdest +// j == m.msource +// IN \* Any RPC with a newer term causes the recipient to advance +// \* its term first. Responses with stale terms are ignored. +// \/ UpdateTerm(i, j, m) +// \/ /\ m.mtype = RequestVoteRequest +// /\ HandleRequestVoteRequest(i, j, m) +// \/ /\ m.mtype = RequestVoteResponse +// /\ \/ DropStaleResponse(i, j, m) +// \/ HandleRequestVoteResponse(i, j, m) +// \/ /\ m.mtype = AppendEntriesRequest +// /\ HandleAppendEntriesRequest(i, j, m) +// \/ /\ m.mtype = AppendEntriesResponse +// /\ \/ DropStaleResponse(i, j, m) +// \/ HandleAppendEntriesResponse(i, j, m) + +// DuplicateMessage(m) == +// /\ Send(m) +// /\ UNCHANGED <> + +// DropMessage(m) == +// /\ Discard(m) +// /\ UNCHANGED <> + +// Next == /\ \/ \E i \in Server : Restart(i) +// \/ \E i \in Server : Timeout(i) +// \/ \E i,j \in Server : RequestVote(i, j) +// \/ \E i \in Server : BecomeLeader(i) +// \/ \E i \in Server, v \in Value : ClientRequest(i, v) +// \/ \E i \in Server : AdvanceCommitIndex(i) +// \/ \E i,j \in Server : AppendEntries(i, j) +// \/ \E m \in DOMAIN messages : Receive(m) +// \/ \E m \in DOMAIN messages : DuplicateMessage(m) +// \/ \E m \in DOMAIN messages : DropMessage(m) +// \* History variable that tracks every log ever: +// /\ allLogs' = allLogs \cup {log[i] : i \in Server} +// + #ifdef __cplusplus } #endif diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 7845490a84..6c2ef0c85b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -151,6 +151,30 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { // init life cycle + // TLA+ Spec + // InitHistoryVars == /\ elections = {} + // /\ allLogs = {} + // /\ voterLog = [i \in Server |-> [j \in {} |-> <<>>]] + // InitServerVars == /\ currentTerm = [i \in Server |-> 1] + // /\ state = [i \in Server |-> Follower] + // /\ votedFor = [i \in Server |-> Nil] + // InitCandidateVars == /\ votesResponded = [i \in Server |-> {}] + // /\ votesGranted = [i \in Server |-> {}] + // \* The values nextIndex[i][i] and matchIndex[i][i] are never read, since the + // \* leader does not send itself messages. It's still easier to include these + // \* in the functions. + // InitLeaderVars == /\ nextIndex = [i \in Server |-> [j \in Server |-> 1]] + // /\ matchIndex = [i \in Server |-> [j \in Server |-> 0]] + // InitLogVars == /\ log = [i \in Server |-> << >>] + // /\ commitIndex = [i \in Server |-> 0] + // Init == /\ messages = [m \in {} |-> 0] + // /\ InitHistoryVars + // /\ InitServerVars + // /\ InitCandidateVars + // /\ InitLeaderVars + // /\ InitLogVars + // + // init TLA+ server vars pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->pRaftStore = raftStoreOpen(pSyncNode->raftStorePath); @@ -728,6 +752,16 @@ static int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) { return ret; } +// TLA+ Spec +// ClientRequest(i, v) == +// /\ state[i] = Leader +// /\ LET entry == [term |-> currentTerm[i], +// value |-> v] +// newLog == Append(log[i], entry) +// IN log' = [log EXCEPT ![i] = newLog] +// /\ UNCHANGED <> +// static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) { int32_t ret = 0; syncClientRequestLog2("==syncNodeOnClientRequestCb==", pMsg); diff --git a/source/libs/sync/src/syncOnMessage.c b/source/libs/sync/src/syncOnMessage.c index 19a97ee156..ce8bed9cd3 100644 --- a/source/libs/sync/src/syncOnMessage.c +++ b/source/libs/sync/src/syncOnMessage.c @@ -14,3 +14,43 @@ */ #include "syncOnMessage.h" + +// TLA+ Spec +// Receive(m) == +// LET i == m.mdest +// j == m.msource +// IN \* Any RPC with a newer term causes the recipient to advance +// \* its term first. Responses with stale terms are ignored. +// \/ UpdateTerm(i, j, m) +// \/ /\ m.mtype = RequestVoteRequest +// /\ HandleRequestVoteRequest(i, j, m) +// \/ /\ m.mtype = RequestVoteResponse +// /\ \/ DropStaleResponse(i, j, m) +// \/ HandleRequestVoteResponse(i, j, m) +// \/ /\ m.mtype = AppendEntriesRequest +// /\ HandleAppendEntriesRequest(i, j, m) +// \/ /\ m.mtype = AppendEntriesResponse +// /\ \/ DropStaleResponse(i, j, m) +// \/ HandleAppendEntriesResponse(i, j, m) + +// DuplicateMessage(m) == +// /\ Send(m) +// /\ UNCHANGED <> + +// DropMessage(m) == +// /\ Discard(m) +// /\ UNCHANGED <> + +// Next == /\ \/ \E i \in Server : Restart(i) +// \/ \E i \in Server : Timeout(i) +// \/ \E i,j \in Server : RequestVote(i, j) +// \/ \E i \in Server : BecomeLeader(i) +// \/ \E i \in Server, v \in Value : ClientRequest(i, v) +// \/ \E i \in Server : AdvanceCommitIndex(i) +// \/ \E i,j \in Server : AppendEntries(i, j) +// \/ \E m \in DOMAIN messages : Receive(m) +// \/ \E m \in DOMAIN messages : DuplicateMessage(m) +// \/ \E m \in DOMAIN messages : DropMessage(m) +// \* History variable that tracks every log ever: +// /\ allLogs' = allLogs \cup {log[i] : i \in Server} +// \ No newline at end of file From 59ae887e30464de5e836cfda2ad5218991a63604 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 15:24:38 +0800 Subject: [PATCH 46/60] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index c490b82d68..270180e347 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -255,7 +255,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { pReply->term = ths->pRaftStore->currentTerm; pReply->success = true; - if (hasAppendEntries > 0) { + if (hasAppendEntries) { pReply->matchIndex = pMsg->prevLogIndex + 1; } else { pReply->matchIndex = pMsg->prevLogIndex; From 019bc6aab001124737e589eaf021978f64997020 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 18 Mar 2022 15:24:57 +0800 Subject: [PATCH 47/60] [add interval cases] --- tests/script/jenkins/basic.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index cafca76761..0c2b4fe1f4 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -18,4 +18,7 @@ # ---- insert ./test.sh -f tsim/insert/basic0.sim + +# ---- query +./test.sh -f tsim/query/interval.sim #======================b1-end=============== From d4d1c0a9f80ff232e819d92929854570c45ef5f3 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Fri, 18 Mar 2022 16:26:32 +0800 Subject: [PATCH 48/60] add stream exec head --- include/common/tmsg.h | 15 ++++++++++----- include/util/tdef.h | 5 +++++ source/dnode/mgmt/impl/inc/dndSnode.h | 9 +++++++-- source/dnode/mgmt/impl/src/dndSnode.c | 18 ++++++++++++++++++ source/dnode/mgmt/impl/src/dndTransport.c | 15 ++++++++++----- 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index bb03e96df4..1621b175dd 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -197,6 +197,11 @@ typedef struct { }; } SMsgHead; +typedef struct { + int32_t workerType; + int32_t streamTaskId; +} SStreamExecMsgHead; + // Submit message for one table typedef struct SSubmitBlk { int64_t uid; // table unique id @@ -1891,9 +1896,9 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) return buf; } typedef struct { - int8_t version; // for compatibility(default 0) - int8_t intervalUnit; // MACRO: TIME_UNIT_XXX - int8_t slidingUnit; // MACRO: TIME_UNIT_XXX + int8_t version; // for compatibility(default 0) + int8_t intervalUnit; // MACRO: TIME_UNIT_XXX + int8_t slidingUnit; // MACRO: TIME_UNIT_XXX char indexName[TSDB_INDEX_NAME_LEN]; char timezone[TD_TIMEZONE_LEN]; // sma data expired if timezone changes. int32_t exprLen; @@ -1901,7 +1906,7 @@ typedef struct { int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; - int64_t offset; // use unit by precision of DB + int64_t offset; // use unit by precision of DB int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -2310,7 +2315,7 @@ typedef struct { } SStreamTaskDeployRsp; typedef struct { - SMsgHead head; + SStreamExecMsgHead head; // TODO: other info needed by task } SStreamTaskExecReq; diff --git a/include/util/tdef.h b/include/util/tdef.h index 41a61ceb55..f6c4ae8d42 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -448,6 +448,11 @@ typedef struct { #define SND_UNIQUE_THREAD_NUM 2 #define SND_SHARED_THREAD_NUM 2 +enum { + SND_WORKER_TYPE__SHARED = 1, + SND_WORKER_TYPE__UNIQUE, +}; + #ifdef __cplusplus } #endif diff --git a/source/dnode/mgmt/impl/inc/dndSnode.h b/source/dnode/mgmt/impl/inc/dndSnode.h index b21e9191e8..f72d2a137a 100644 --- a/source/dnode/mgmt/impl/inc/dndSnode.h +++ b/source/dnode/mgmt/impl/inc/dndSnode.h @@ -24,12 +24,17 @@ extern "C" { int32_t dndInitSnode(SDnode *pDnode); void dndCleanupSnode(SDnode *pDnode); -void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +// void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); +void dndProcessSnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +void dndProcessSnodeUniqueMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +void dndProcessSnodeSharedMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +void dndProcessSnodeExecMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); + #ifdef __cplusplus } #endif -#endif /*_TD_DND_SNODE_H_*/ \ No newline at end of file +#endif /*_TD_DND_SNODE_H_*/ diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index 8667952f2c..ea06c8c751 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -382,6 +382,12 @@ static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) { taosFreeQitem(pMsg); } +static FORCE_INLINE int32_t dndGetSWTypeFromMsg(SRpcMsg *pMsg) { + SStreamExecMsgHead *pHead = pMsg->pCont; + pHead->workerType = htonl(pHead->workerType); + return pHead->workerType; +} + static FORCE_INLINE int32_t dndGetSWIdFromMsg(SRpcMsg *pMsg) { SMsgHead *pHead = pMsg->pCont; pHead->streamTaskId = htonl(pHead->streamTaskId); @@ -450,6 +456,18 @@ void dndProcessSnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { dndWriteSnodeMsgToMgmtWorker(pDnode, pMsg); } +void dndProcessSnodeExecMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { + SSnode *pSnode = dndAcquireSnode(pDnode); + if (pSnode != NULL) { + int32_t workerType = dndGetSWTypeFromMsg(pMsg); + if (workerType == SND_WORKER_TYPE__SHARED) { + dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.sharedWorker, pMsg); + } else { + dndWriteSnodeMsgToWorkerByMsg(pDnode, pMsg); + } + } +} + void dndProcessSnodeUniqueMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { dndWriteSnodeMsgToWorkerByMsg(pDnode, pMsg); } diff --git a/source/dnode/mgmt/impl/src/dndTransport.c b/source/dnode/mgmt/impl/src/dndTransport.c index 15db36477d..617b6c0fc3 100644 --- a/source/dnode/mgmt/impl/src/dndTransport.c +++ b/source/dnode/mgmt/impl/src/dndTransport.c @@ -23,10 +23,11 @@ #include "dndTransport.h" #include "dndMgmt.h" #include "dndMnode.h" +#include "dndSnode.h" #include "dndVnodes.h" -#define INTERNAL_USER "_dnd" -#define INTERNAL_CKEY "_key" +#define INTERNAL_USER "_dnd" +#define INTERNAL_CKEY "_key" #define INTERNAL_SECRET "_pwd" static void dndInitMsgFp(STransMgmt *pMgmt) { @@ -153,10 +154,14 @@ static void dndInitMsgFp(STransMgmt *pMgmt) { pMgmt->msgFp[TMSG_INDEX(TDMT_VND_MQ_SET_CUR)] = dndProcessVnodeFetchMsg; pMgmt->msgFp[TMSG_INDEX(TDMT_VND_CONSUME)] = dndProcessVnodeFetchMsg; pMgmt->msgFp[TMSG_INDEX(TDMT_VND_QUERY_HEARTBEAT)] = dndProcessVnodeFetchMsg; + + // Requests handled by SNODE + pMgmt->msgFp[TMSG_INDEX(TDMT_SND_TASK_DEPLOY)] = dndProcessSnodeMgmtMsg; + pMgmt->msgFp[TMSG_INDEX(TDMT_SND_TASK_EXEC)] = dndProcessSnodeExecMsg; } static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) { - SDnode * pDnode = parent; + SDnode *pDnode = parent; STransMgmt *pMgmt = &pDnode->tmgmt; tmsg_t msgType = pRsp->msgType; @@ -219,7 +224,7 @@ static void dndCleanupClient(SDnode *pDnode) { } static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) { - SDnode * pDnode = param; + SDnode *pDnode = param; STransMgmt *pMgmt = &pDnode->tmgmt; tmsg_t msgType = pReq->msgType; @@ -313,7 +318,7 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char SAuthReq authReq = {0}; tstrncpy(authReq.user, user, TSDB_USER_LEN); int32_t contLen = tSerializeSAuthReq(NULL, 0, &authReq); - void * pReq = rpcMallocCont(contLen); + void *pReq = rpcMallocCont(contLen); tSerializeSAuthReq(pReq, contLen, &authReq); SRpcMsg rpcMsg = {.pCont = pReq, .contLen = contLen, .msgType = TDMT_MND_AUTH, .ahandle = (void *)9528}; From 36751ea53f954e9c426cbbf770160f3736e8021e Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 18 Mar 2022 16:33:53 +0800 Subject: [PATCH 49/60] logic optimization and resource release --- include/common/tmsg.h | 12 +--- source/dnode/vnode/src/inc/tsdbDBDef.h | 5 +- source/dnode/vnode/src/meta/metaBDBImpl.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 68 ++++++++++++----------- source/dnode/vnode/src/vnd/vnodeWrite.c | 3 + source/dnode/vnode/test/tsdbSmaTest.cpp | 46 ++++++++------- source/libs/tfs/src/tfs.c | 3 +- 7 files changed, 72 insertions(+), 67 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index bb03e96df4..0106a74519 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2047,27 +2047,19 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI64(buf, &pSma->sliding); if (pSma->exprLen > 0) { - pSma->expr = (char*)calloc(pSma->exprLen, 1); - if (pSma->expr != NULL) { - buf = taosDecodeStringTo(buf, pSma->expr); - } else { + if ((buf = taosDecodeString(buf, &pSma->expr)) == NULL) { tdDestroyTSma(pSma); return NULL; } - } else { pSma->expr = NULL; } if (pSma->tagsFilterLen > 0) { - pSma->tagsFilter = (char*)calloc(pSma->tagsFilterLen, 1); - if (pSma->tagsFilter != NULL) { - buf = taosDecodeStringTo(buf, pSma->tagsFilter); - } else { + if ((buf = taosDecodeString(buf, &pSma->tagsFilter)) == NULL) { tdDestroyTSma(pSma); return NULL; } - } else { pSma->tagsFilter = NULL; } diff --git a/source/dnode/vnode/src/inc/tsdbDBDef.h b/source/dnode/vnode/src/inc/tsdbDBDef.h index 2e37b0ba45..ca9b60049e 100644 --- a/source/dnode/vnode/src/inc/tsdbDBDef.h +++ b/source/dnode/vnode/src/inc/tsdbDBDef.h @@ -26,8 +26,9 @@ typedef struct SDBFile SDBFile; typedef DB_ENV* TDBEnv; struct SDBFile { - DB* pDB; - char* path; + int32_t fid; + DB* pDB; + char* path; }; int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile* pDBF); diff --git a/source/dnode/vnode/src/meta/metaBDBImpl.c b/source/dnode/vnode/src/meta/metaBDBImpl.c index df2d9604d2..99a2b272ed 100644 --- a/source/dnode/vnode/src/meta/metaBDBImpl.c +++ b/source/dnode/vnode/src/meta/metaBDBImpl.c @@ -884,7 +884,7 @@ const char *metaSmaCursorNext(SMSmaCursor *pCur) { STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) { STSmaWrapper *pSW = NULL; - pSW = calloc(sizeof(*pSW), 1); + pSW = calloc(1, sizeof(*pSW)); if (pSW == NULL) { return NULL; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 42bfebc77b..02a0b587d5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -156,10 +156,6 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (*pEnv) { - return TSDB_CODE_SUCCESS; - } - if (*pEnv == NULL) { if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { return TSDB_CODE_FAILED; @@ -260,10 +256,15 @@ static SSmaStatItem *tsdbNewSmaStatItem(int8_t state) { int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { if (pSmaStat) { // TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready. - SSmaStatItem *item = taosHashIterate(pSmaStat->smaStatItems, NULL); + void *item = taosHashIterate(pSmaStat->smaStatItems, NULL); while (item != NULL) { - tfree(item->pSma); - taosHashCleanup(item->expiredWindows); + SSmaStatItem *pItem = *(SSmaStatItem **)item; + if (pItem != NULL) { + tdDestroyTSma(pItem->pSma); + tfree(pItem->pSma); + taosHashCleanup(pItem->expiredWindows); + tfree(pItem); + } item = taosHashIterate(pSmaStat->smaStatItems, item); } taosHashCleanup(pSmaStat->smaStatItems); @@ -292,9 +293,10 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { // init sma env tsdbLockRepo(pTsdb); - if (pTsdb->pTSmaEnv == NULL) { + pEnv = (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_load_ptr(&pTsdb->pTSmaEnv) : atomic_load_ptr(&pTsdb->pRSmaEnv); + if (pEnv == NULL) { char rname[TSDB_FILENAME_LEN] = {0}; - char aname[TSDB_FILENAME_LEN * 2 + 32] = {0}; // TODO: make TMPNAME_LEN public as TSDB_FILENAME_LEN? + char aname[TSDB_FILENAME_LEN] = {0}; // use TSDB_FILENAME_LEN currently SDiskID did = {0}; tfsAllocDisk(pTsdb->pTfs, TFS_PRIMARY_LEVEL, &did); @@ -315,11 +317,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_FAILED; } - if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - atomic_store_ptr(&pTsdb->pTSmaEnv, pEnv); - } else { - atomic_store_ptr(&pTsdb->pRSmaEnv, pEnv); - } + (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&pTsdb->pTSmaEnv, pEnv) + : atomic_store_ptr(&pTsdb->pRSmaEnv, pEnv); } tsdbUnlockRepo(pTsdb); @@ -359,8 +358,10 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { SSmaStat *pStat = SMA_ENV_STAT(pEnv); SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); + TASSERT(pEnv != NULL && pStat != NULL && pItemsHash != NULL); + tsdbRefSmaStat(pTsdb, pStat); - SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); + SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); if (pItem == NULL) { pItem = tsdbNewSmaStatItem(TSDB_SMA_STAT_EXPIRED); // TODO use the real state if (pItem == NULL) { @@ -421,9 +422,9 @@ static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t ind tsdbRefSmaStat(pTsdb, pStat); if (pStat && pStat->smaStatItems) { - pItem = *(SSmaStatItem **)taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); + pItem = taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); } - if (pItem != NULL) { + if ((pItem != NULL) && ((pItem = *(SSmaStatItem **)pItem) != NULL)) { // pItem resides in hash buffer all the time unless drop sma index // TODO: multithread protect if (taosHashRemove(pItem->expiredWindows, &skey, sizeof(TSKEY)) != 0) { @@ -494,7 +495,7 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { * @brief Insert TSma data blocks to DB File build by B+Tree * * @param pSmaH - * @param smaKey + * @param smaKey tableUid-colId-skeyOfWindow(8-2-8) * @param keyLen * @param pData * @param dataLen @@ -502,12 +503,11 @@ static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { */ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen) { SDBFile *pDBFile = &pSmaH->dFile; - - // TODO: insert sma data blocks into B+Tree tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d", REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); + // TODO: insert sma data blocks into B+Tree(TDB) if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) { return TSDB_CODE_FAILED; } @@ -564,34 +564,34 @@ static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit return interval / 1e3; } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; - } else { + } else { // ms return interval; } break; case TSDB_TIME_PRECISION_MICRO: if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns return interval / 1e3; - } else { + } else { // ms return interval * 1e3; } break; case TSDB_TIME_PRECISION_NANO: - if (TIME_UNIT_MICROSECOND == intervalUnit) { + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval * 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns return interval; - } else { + } else { // ms return interval * 1e6; } break; default: // ms if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // ns return interval / 1e6; - } else { + } else { // ms return interval; } break; @@ -663,9 +663,13 @@ static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH) { static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid) { STsdb *pTsdb = pSmaH->pTsdb; ASSERT(pSmaH->dFile.path == NULL && pSmaH->dFile.pDB == NULL); + + pSmaH->dFile.fid = fid; + char tSmaFile[TSDB_FILENAME_LEN] = {0}; snprintf(tSmaFile, TSDB_FILENAME_LEN, "v%df%d.tsma", REPO_ID(pTsdb), fid); pSmaH->dFile.path = strdup(tSmaFile); + return TSDB_CODE_SUCCESS; } @@ -705,7 +709,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { STsdbCfg * pCfg = REPO_CFG(pTsdb); STSmaDataWrapper *pData = (STSmaDataWrapper *)msg; - if (!pTsdb->pTSmaEnv) { + if (!atomic_load_ptr(&pTsdb->pTSmaEnv)) { terrno = TSDB_CODE_INVALID_PTR; tsdbWarn("vgId:%d insert tSma data failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); return terrno; @@ -883,15 +887,15 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { - if (!pTsdb->pTSmaEnv) { + if (!atomic_load_ptr(&pTsdb->pTSmaEnv)) { terrno = TSDB_CODE_INVALID_PTR; tsdbWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); return TSDB_CODE_FAILED; } tsdbRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); - SSmaStatItem *pItem = *(SSmaStatItem **)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); - if (pItem == NULL) { + SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); + if ((pItem == NULL) || ((pItem = *(SSmaStatItem **)pItem) == NULL)) { // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if // it's NULL. tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index 218b53c2ab..8285020e14 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -144,6 +144,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { return -1; } + // record current timezone of server side + tstrncpy(vCreateSmaReq.tSma.timezone, tsTimezone, TD_TIMEZONE_LEN); + if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) { // TODO: handle error tdDestroyTSma(&vCreateSmaReq.tSma); diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 86958da406..5a87c180b6 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -49,7 +49,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { STSmaWrapper tSmaWrapper = {.number = 1, .tSma = &tSma}; uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper); - void *buf = calloc(bufLen, 1); + void *buf = calloc(1, bufLen); ASSERT_NE(buf, nullptr); STSmaWrapper *pSW = (STSmaWrapper *)buf; @@ -84,6 +84,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { } // resource release + tfree(pSW); tdDestroyTSma(&tSma); tdDestroyTSmaWrapper(&dstTSmaWrapper); } @@ -113,7 +114,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { tSma.tableUid = tbUid; tSma.exprLen = strlen(expr); - tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + tSma.expr = (char *)calloc(1, tSma.exprLen + 1); ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); @@ -251,12 +252,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tSma.tableUid = tbUid; tSma.exprLen = strlen(expr); - tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + tSma.expr = (char *)calloc(1, tSma.exprLen + 1); ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); - tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + tSma.tagsFilter = (char *)calloc(1, tSma.tagsFilterLen + 1); ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); @@ -273,20 +274,20 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { // step 2: insert data STSmaDataWrapper *pSmaData = NULL; - STsdb tsdb = {0}; - STsdbCfg * pCfg = &tsdb.config; + STsdb * pTsdb = (STsdb *)calloc(1, sizeof(STsdb)); + STsdbCfg * pCfg = &pTsdb->config; - tsdb.pMeta = pMeta; - tsdb.vgId = 2; - tsdb.config.daysPerFile = 10; // default days is 10 - tsdb.config.keep1 = 30; - tsdb.config.keep2 = 90; - tsdb.config.keep = 365; - tsdb.config.precision = TSDB_TIME_PRECISION_MILLI; - tsdb.config.update = TD_ROW_OVERWRITE_UPDATE; - tsdb.config.compression = TWO_STAGE_COMP; + pTsdb->pMeta = pMeta; + pTsdb->vgId = 2; + pTsdb->config.daysPerFile = 10; // default days is 10 + pTsdb->config.keep1 = 30; + pTsdb->config.keep2 = 90; + pTsdb->config.keep = 365; + pTsdb->config.precision = TSDB_TIME_PRECISION_MILLI; + pTsdb->config.update = TD_ROW_OVERWRITE_UPDATE; + pTsdb->config.compression = TWO_STAGE_COMP; - switch (tsdb.config.precision) { + switch (pTsdb->config.precision) { case TSDB_TIME_PRECISION_MILLI: skey1 *= 1e3; break; @@ -304,12 +305,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { SDiskCfg pDisks = {.level = 0, .primary = 1}; strncpy(pDisks.dir, "/var/lib/taos", TSDB_FILENAME_LEN); int32_t numOfDisks = 1; - tsdb.pTfs = tfsOpen(&pDisks, numOfDisks); - ASSERT_NE(tsdb.pTfs, nullptr); + pTsdb->pTfs = tfsOpen(&pDisks, numOfDisks); + ASSERT_NE(pTsdb->pTfs, nullptr); char *msg = (char *)calloc(1, 100); ASSERT_NE(msg, nullptr); - ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); + ASSERT_EQ(tsdbUpdateSmaWindow(pTsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); // init int32_t allocCnt = 0; @@ -367,13 +368,13 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { ASSERT_GE(bufSize, pSmaData->dataLen); // execute - ASSERT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); + ASSERT_EQ(tsdbInsertTSmaData(pTsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); // step 3: query uint32_t checkDataCnt = 0; for (int32_t t = 0; t < numOfTables; ++t) { for (col_id_t c = 0; c < numOfCols; ++c) { - ASSERT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, + ASSERT_EQ(tsdbGetTSmaData(pTsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1), TSDB_CODE_SUCCESS); ++checkDataCnt; @@ -383,9 +384,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt); // release data + tfree(msg); taosTZfree(buf); // release meta tdDestroyTSma(&tSma); + tfsClose(pTsdb->pTfs); + tsdbClose(pTsdb); metaClose(pMeta); } #endif diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index 97b8912b60..aee7376491 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -204,7 +204,8 @@ void tfsDirname(const STfsFile *pFile, char *dest) { void tfsAbsoluteName(STfs *pTfs, SDiskID diskId, const char *rname, char *aname) { STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId); - snprintf(aname, TMPNAME_LEN, "%s%s%s", pDisk->path, TD_DIRSEP, rname); + + snprintf(aname, TSDB_FILENAME_LEN, "%s%s%s", pDisk->path, TD_DIRSEP, rname); } int32_t tfsRemoveFile(const STfsFile *pFile) { return taosRemoveFile(pFile->aname); } From 159c2671a2034a53816f9b097b3808ca55f7938c Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 18 Mar 2022 16:48:12 +0800 Subject: [PATCH 50/60] [TD-13767]: forbid wchar_t. --- include/common/tvariant.h | 2 +- include/os/osString.h | 21 +++++++++- include/util/tcompare.h | 2 +- source/common/src/tvariant.c | 38 +++++++++---------- source/dnode/vnode/src/tsdb/tsdbRead.c | 2 +- .../libs/parser/test/mockCatalogService.cpp | 3 +- source/os/src/osString.c | 20 ++++++++++ source/util/src/tcompare.c | 18 ++++----- tools/shell/src/backup/shellDarwin.c | 7 ++-- tools/shell/src/shellCommand.c | 28 +++++++------- tools/shell/src/shellEngine.c | 8 ++-- tools/shell/src/shellLinux.c | 7 ++-- 12 files changed, 94 insertions(+), 62 deletions(-) diff --git a/include/common/tvariant.h b/include/common/tvariant.h index 995015fe63..63f305ab2d 100644 --- a/include/common/tvariant.h +++ b/include/common/tvariant.h @@ -31,7 +31,7 @@ typedef struct SVariant { uint64_t u; double d; char *pz; - wchar_t *wpz; + TdUcs4 *ucs4; SArray *arr; // only for 'in' query to hold value list, not value for a field }; } SVariant; diff --git a/include/os/osString.h b/include/os/osString.h index 80e925e18d..9c6d523ab2 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -20,15 +20,24 @@ extern "C" { #endif +typedef wchar_t TdWchar; +typedef int32_t TdUcs4; + // If the error is in a third-party library, place this header file under the third-party library header file. #ifndef ALLOW_FORBID_FUNC #define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID #define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID #define iconv ICONV_FUNC_TAOS_FORBID + #define wcwidth WCWIDTH_FUNC_TAOS_FORBID + #define wcswidth WCSWIDTH_FUNC_TAOS_FORBID + #define mbtowc MBTOWC_FUNC_TAOS_FORBID + #define mbstowcs MBSTOWCS_FUNC_TAOS_FORBID + #define wctomb WCTOMB_FUNC_TAOS_FORBID + #define wcstombs WCSTOMBS_FUNC_TAOS_FORBID + #define wcsncpy WCSNCPY_FUNC_TAOS_FORBID + #define wchar_t WCHAR_T_FUNC_TAOS_FORBID #endif -typedef int32_t TdUcs4; - #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #define tstrdup(str) _strdup(str) #else @@ -47,8 +56,16 @@ int64_t taosStr2int64(const char *str); int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes); +TdUcs4* tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4); bool taosValidateEncodec(const char *encodec); +int32_t taosWcharWidth(TdWchar wchar); +int32_t taosWcharsWidth(TdWchar *pWchar, int32_t size); +int32_t taosMbToWchar(TdWchar *pWchar, const char *pStr, int32_t size); +int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size); +int32_t taosWcharToMb(char *pStr, TdWchar wchar); +int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size); + #ifdef __cplusplus } #endif diff --git a/include/util/tcompare.h b/include/util/tcompare.h index 4c80eeb4f6..cc9e8ae464 100644 --- a/include/util/tcompare.h +++ b/include/util/tcompare.h @@ -46,7 +46,7 @@ typedef struct SPatternCompareInfo { int32_t patternMatch(const char *pattern, const char *str, size_t size, const SPatternCompareInfo *pInfo); -int32_t WCSPatternMatch(const wchar_t *pattern, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo); +int32_t WCSPatternMatch(const TdUcs4 *pattern, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo); int32_t taosArrayCompareString(const void *a, const void *b); diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 703f4402ef..c6aa1cb81d 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -199,8 +199,8 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length size_t lenInwchar = len / TSDB_NCHAR_SIZE; - pVar->wpz = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); - memcpy(pVar->wpz, pz, lenInwchar * TSDB_NCHAR_SIZE); + pVar->ucs4 = calloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); + memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE); pVar->nLen = (int32_t)len; break; @@ -343,7 +343,7 @@ int32_t taosVariantToString(SVariant *pVar, char *dst) { case TSDB_DATA_TYPE_NCHAR: { dst[0] = '\''; - taosUcs4ToMbs(pVar->wpz, (taosUcs4len(pVar->wpz) + 1) * TSDB_NCHAR_SIZE, dst + 1); + taosUcs4ToMbs(pVar->ucs4, (taosUcs4len(pVar->ucs4) + 1) * TSDB_NCHAR_SIZE, dst + 1); int32_t len = (int32_t)strlen(dst); dst[len] = '\''; dst[len + 1] = 0; @@ -384,7 +384,7 @@ static FORCE_INLINE int32_t convertToBoolImpl(char *pStr, int32_t len) { } } -static FORCE_INLINE int32_t wcsconvertToBoolImpl(wchar_t *pstr, int32_t len) { +static FORCE_INLINE int32_t wcsconvertToBoolImpl(TdUcs4 *pstr, int32_t len) { if ((wcsncasecmp(pstr, L"true", len) == 0) && (len == 4)) { return TSDB_TRUE; } else if (wcsncasecmp(pstr, L"false", len) == 0 && (len == 5)) { @@ -412,11 +412,11 @@ static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) { pBuf = realloc(pBuf, newSize + 1); } - taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, pBuf); - free(pVariant->wpz); + taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf); + free(pVariant->ucs4); pBuf[newSize] = 0; } else { - taosUcs4ToMbs(pVariant->wpz, (int32_t)newSize, *pDest); + taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest); } } else { @@ -469,17 +469,17 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) { // free the binary buffer in the first place if (pVariant->nType == TSDB_DATA_TYPE_BINARY) { - free(pVariant->wpz); + free(pVariant->ucs4); } - pVariant->wpz = pWStr; - *pDestSize = taosUcs4len(pVariant->wpz); + pVariant->ucs4 = pWStr; + *pDestSize = taosUcs4len(pVariant->ucs4); // shrink the allocate memory, no need to check here. - char *tmp = realloc(pVariant->wpz, (*pDestSize + 1) * TSDB_NCHAR_SIZE); + char *tmp = realloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE); assert(tmp != NULL); - pVariant->wpz = (wchar_t *)tmp; + pVariant->ucs4 = (TdUcs4 *)tmp; } else { int32_t output = 0; @@ -554,7 +554,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result *result = res; } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { errno = 0; - wchar_t *endPtr = NULL; + TdUcs4 *endPtr = NULL; SToken token = {0}; token.n = tGetToken(pVariant->pz, &token.type); @@ -564,7 +564,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result } if (token.type == TK_FLOAT) { - double v = wcstod(pVariant->wpz, &endPtr); + double v = wcstod(pVariant->ucs4, &endPtr); if (releaseVariantPtr) { free(pVariant->pz); pVariant->nLen = 0; @@ -583,7 +583,7 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result setNull((char *)result, type, tDataTypes[type].bytes); return 0; } else { - int64_t val = wcstoll(pVariant->wpz, &endPtr, 10); + int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10); if (releaseVariantPtr) { free(pVariant->pz); pVariant->nLen = 0; @@ -649,7 +649,7 @@ static int32_t convertToBool(SVariant *pVariant, int64_t *pDest) { *pDest = ret; } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { int32_t ret = 0; - if ((ret = wcsconvertToBoolImpl(pVariant->wpz, pVariant->nLen)) < 0) { + if ((ret = wcsconvertToBoolImpl(pVariant->ucs4, pVariant->nLen)) < 0) { return ret; } *pDest = ret; @@ -899,7 +899,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc return -1; } } else { - wcsncpy((wchar_t *)payload, pVariant->wpz, pVariant->nLen); + tasoUcs4Copy((TdUcs4*)payload, pVariant->ucs4, pVariant->nLen); } } } else { @@ -913,7 +913,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc return -1; } } else { - memcpy(p, pVariant->wpz, pVariant->nLen); + memcpy(p, pVariant->ucs4, pVariant->nLen); newlen = pVariant->nLen; } @@ -979,7 +979,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) { pVariant->d = v; } else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) { errno = 0; - double v = wcstod(pVariant->wpz, NULL); + double v = wcstod(pVariant->ucs4, NULL); if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) { free(pVariant->pz); return -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 97c52f44eb..6b2857c411 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -3386,7 +3386,7 @@ void filterPrepare(void* expr, void* param) { if (size < (uint32_t)pSchema->bytes) { size = pSchema->bytes; } - // to make sure tonchar does not cause invalid write, since the '\0' needs at least sizeof(wchar_t) space. + // to make sure tonchar does not cause invalid write, since the '\0' needs at least sizeof(TdUcs4) space. pInfo->q = calloc(1, size + TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(pCond, pInfo->q, pSchema->type, true); } diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 65d3f51dde..1f333e49e7 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -13,12 +13,11 @@ * along with this program. If not, see . */ -#include "mockCatalogService.h" - #include #include #include #include "tdatablock.h" +#include "mockCatalogService.h" #include "tname.h" #include "ttypes.h" diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 18f6ceb5a0..07108ce34f 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -24,6 +24,9 @@ #include "iconv.h" #endif +extern int wcwidth(wchar_t c); +extern int wcswidth(const wchar_t *s, size_t n); + int64_t taosStr2int64(const char *str) { char *endptr = NULL; return strtoll(str, &endptr, 10); @@ -72,6 +75,11 @@ int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) { #endif } + +TdUcs4* tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4) { + memcpy(target_ucs4, source_ucs4, len_ucs4*sizeof(TdUcs4)); +} + int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { #ifdef DISALLOW_NCHAR_WITHOUT_ICONV return -1; @@ -145,6 +153,18 @@ int32_t taosUcs4len(TdUcs4 *ucs4) { return n; } +int32_t taosWcharWidth(TdWchar wchar) { return wcwidth(wchar); } + +int32_t taosWcharsWidth(TdWchar *pWchar, int32_t size) { return wcswidth(pWchar, size); } + +int32_t taosMbToWchar(TdWchar *pWchar, const char *pStr, int32_t size) { return mbtowc(pWchar, pStr, size); } + +int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) { return mbstowcs(pWchars, pStrs, size); } + +int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); } + +int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); } + // #ifdef USE_LIBICONV // #include "iconv.h" diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 5e3cf1247c..ff7d2cf733 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -208,7 +208,7 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { if (len1 != len2) { return len1 > len2 ? 1 : -1; } else { - int32_t ret = memcmp((wchar_t *)pLeft, (wchar_t *)pRight, len1); + int32_t ret = memcmp((TdUcs4 *)pLeft, (TdUcs4 *)pRight, len1); if (ret == 0) { return 0; } else { @@ -295,10 +295,10 @@ int32_t patternMatch(const char *patterStr, const char *str, size_t size, const return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int32_t WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, const SPatternCompareInfo *pInfo) { - wchar_t c, c1; - wchar_t matchOne = L'_'; // "_" - wchar_t matchAll = L'%'; // "%" +int32_t WCSPatternMatch(const TdUcs4 *patterStr, const TdUcs4 *str, size_t size, const SPatternCompareInfo *pInfo) { + TdUcs4 c, c1; + TdUcs4 matchOne = L'_'; // "_" + TdUcs4 matchAll = L'%'; // "%" int32_t i = 0; int32_t j = 0; @@ -315,7 +315,7 @@ int32_t WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t siz return TSDB_PATTERN_MATCH; } - wchar_t accept[3] = {towupper(c), towlower(c), 0}; + TdUcs4 accept[3] = {towupper(c), towlower(c), 0}; while (1) { size_t n = wcscspn(str, accept); @@ -424,10 +424,10 @@ int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); - wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); + char *pattern = calloc(varDataLen(pRight) + TSDB_NCHAR_SIZE, 1); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - int32_t ret = WCSPatternMatch(pattern, (const wchar_t *)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); + int32_t ret = WCSPatternMatch((TdUcs4*)pattern, (TdUcs4*)varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); free(pattern); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; @@ -647,7 +647,7 @@ int32_t doCompare(const char *f1, const char *f2, int32_t type, size_t size) { if (t1->len != t2->len) { return t1->len > t2->len ? 1 : -1; } - int32_t ret = memcmp((wchar_t *)t1, (wchar_t *)t2, t2->len); + int32_t ret = memcmp((TdUcs4 *)t1, (TdUcs4 *)t2, t2->len); if (ret == 0) { return ret; } diff --git a/tools/shell/src/backup/shellDarwin.c b/tools/shell/src/backup/shellDarwin.c index e4cf09358b..d7a976d52c 100644 --- a/tools/shell/src/backup/shellDarwin.c +++ b/tools/shell/src/backup/shellDarwin.c @@ -28,7 +28,6 @@ int indicator = 1; struct termios oldtio; -extern int wcwidth(wchar_t c); void insertChar(Command *cmd, char *c, int size); @@ -426,7 +425,7 @@ void showOnScreen(Command *cmd) { w.ws_row = 30; } - wchar_t wc; + TdWchar wc; int size = 0; // Print out the command. @@ -441,11 +440,11 @@ void showOnScreen(Command *cmd) { int remain_column = w.ws_col; /* size = cmd->commandSize + prompt_size; */ for (char *str = total_string; size < cmd->commandSize + prompt_size;) { - int ret = mbtowc(&wc, str, MB_CUR_MAX); + int ret = taosMbToWchar(&wc, str, MB_CUR_MAX); if (ret < 0) break; size += ret; /* assert(size >= 0); */ - int width = wcwidth(wc); + int width = taosWcharWidth(wc); if (remain_column > width) { printf("%lc", wc); remain_column -= width; diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index cf0ceded38..fd993998b8 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -21,8 +21,6 @@ #include -extern int wcwidth(wchar_t c); -extern int wcswidth(const wchar_t *s, size_t n); typedef struct { char widthInString; char widthOnScreen; @@ -43,7 +41,7 @@ int countPrefixOnes(unsigned char c) { void getPrevCharSize(const char *str, int pos, int *size, int *width) { assert(pos > 0); - wchar_t wc; + TdWchar wc; *size = 0; *width = 0; @@ -53,25 +51,25 @@ void getPrevCharSize(const char *str, int pos, int *size, int *width) { if (str[pos] > 0 || countPrefixOnes((unsigned char )str[pos]) > 1) break; } - int rc = mbtowc(&wc, str + pos, MB_CUR_MAX); + int rc = taosMbToWchar(&wc, str + pos, MB_CUR_MAX); assert(rc == *size); - *width = wcwidth(wc); + *width = taosWcharWidth(wc); } void getNextCharSize(const char *str, int pos, int *size, int *width) { assert(pos >= 0); - wchar_t wc; - *size = mbtowc(&wc, str + pos, MB_CUR_MAX); - *width = wcwidth(wc); + TdWchar wc; + *size = taosMbToWchar(&wc, str + pos, MB_CUR_MAX); + *width = taosWcharWidth(wc); } void insertChar(Command *cmd, char *c, int size) { assert(cmd->cursorOffset <= cmd->commandSize && cmd->endOffset >= cmd->screenOffset); - wchar_t wc; - if (mbtowc(&wc, c, size) < 0) return; + TdWchar wc; + if (taosMbToWchar(&wc, c, size) < 0) return; clearScreen(cmd->endOffset + prompt_size, cmd->screenOffset + prompt_size); /* update the buffer */ @@ -81,8 +79,8 @@ void insertChar(Command *cmd, char *c, int size) { /* update the values */ cmd->commandSize += size; cmd->cursorOffset += size; - cmd->screenOffset += wcwidth(wc); - cmd->endOffset += wcwidth(wc); + cmd->screenOffset += taosWcharWidth(wc); + cmd->endOffset += taosWcharWidth(wc); showOnScreen(cmd); } @@ -249,10 +247,10 @@ int isReadyGo(Command *cmd) { } void getMbSizeInfo(const char *str, int *size, int *width) { - wchar_t *wc = (wchar_t *)calloc(sizeof(wchar_t), MAX_COMMAND_SIZE); + TdWchar *wc = (TdWchar *)calloc(sizeof(TdWchar), MAX_COMMAND_SIZE); *size = strlen(str); - mbstowcs(wc, str, MAX_COMMAND_SIZE); - *width = wcswidth(wc, MAX_COMMAND_SIZE); + taosMbsToWchars(wc, str, MAX_COMMAND_SIZE); + *width = taosWcharsWidth(wc, MAX_COMMAND_SIZE); free(wc); } diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 5a989937d8..1b35afb57d 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -560,12 +560,12 @@ static int dumpResultToFile(const char *fname, TAOS_RES *tres) { } static void shellPrintNChar(const char *str, int length, int width) { - wchar_t tail[3]; + TdWchar tail[3]; int pos = 0, cols = 0, totalCols = 0, tailLen = 0; while (pos < length) { - wchar_t wc; - int bytes = mbtowc(&wc, str + pos, MB_CUR_MAX); + TdWchar wc; + int bytes = taosMbToWchar(&wc, str + pos, MB_CUR_MAX); if (bytes == 0) { break; } @@ -577,7 +577,7 @@ static void shellPrintNChar(const char *str, int length, int width) { #ifdef WINDOWS int w = bytes; #else - int w = wcwidth(wc); + int w = taosWcharWidth(wc); #endif if (w <= 0) { continue; diff --git a/tools/shell/src/shellLinux.c b/tools/shell/src/shellLinux.c index cc497688d1..6da05f28df 100644 --- a/tools/shell/src/shellLinux.c +++ b/tools/shell/src/shellLinux.c @@ -31,7 +31,6 @@ int indicator = 1; struct termios oldtio; -extern int wcwidth(wchar_t c); void insertChar(Command *cmd, char *c, int size); const char *argp_program_version = version; const char *argp_program_bug_address = ""; @@ -456,7 +455,7 @@ void showOnScreen(Command *cmd) { w.ws_row = 30; } - wchar_t wc; + TdWchar wc; int size = 0; // Print out the command. @@ -471,11 +470,11 @@ void showOnScreen(Command *cmd) { int remain_column = w.ws_col; /* size = cmd->commandSize + prompt_size; */ for (char *str = total_string; size < cmd->commandSize + prompt_size;) { - int ret = mbtowc(&wc, str, MB_CUR_MAX); + int ret = taosMbToWchar(&wc, str, MB_CUR_MAX); if (ret < 0) break; size += ret; /* assert(size >= 0); */ - int width = wcwidth(wc); + int width = taosWcharWidth(wc); if (remain_column > width) { printf("%lc", wc); remain_column -= width; From 21feed915f26f9cb5c30a3f7dc34e77cb0ad2302 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 17:23:48 +0800 Subject: [PATCH 51/60] sync refactor --- source/libs/sync/src/syncCommit.c | 22 ++++++++++++++-------- source/libs/sync/src/syncMain.c | 8 ++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index c75d23d96d..8f0b8e5a79 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -18,6 +18,7 @@ #include "syncInt.h" #include "syncRaftLog.h" #include "syncRaftStore.h" +#include "syncUtil.h" // \* Leader i advances its commitIndex. // \* This is done as a separate step from handling AppendEntries responses, @@ -50,7 +51,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex newCommitIndex = pSyncNode->commitIndex; for (SyncIndex index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore); index > pSyncNode->commitIndex; ++index) { - if (syncAgree(pSyncNode, index)) { + bool agree = syncAgree(pSyncNode, index); + if (agree) { // term SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); assert(pEntry != NULL); @@ -97,14 +99,18 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { } bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index) { - SyncIndex matchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, pRaftId); - - // b for debug - bool b = false; - if (matchIndex >= index) { - b = true; + // I am leader, I agree + if (syncUtilSameId(pRaftId, &(pSyncNode->myRaftId)) && pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + return true; } - return b; + + // follower agree + SyncIndex matchIndex = syncIndexMgrGetIndex(pSyncNode->pMatchIndex, pRaftId); + if (matchIndex >= index) { + return true; + } + + return false; } bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 6c2ef0c85b..de108086bc 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -195,7 +195,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { // init TLA+ log vars pSyncNode->pLogStore = logStoreCreate(pSyncNode); assert(pSyncNode->pLogStore != NULL); - pSyncNode->commitIndex = 0; + pSyncNode->commitIndex = SYNC_INDEX_INVALID; // init ping timer pSyncNode->pPingTimer = NULL; @@ -774,9 +774,6 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg if (ths->state == TAOS_SYNC_STATE_LEADER) { ths->pLogStore->appendEntry(ths->pLogStore, pEntry); - // only myself, maybe commit - syncMaybeAdvanceCommitIndex(ths); - // start replicate right now! syncNodeReplicate(ths); @@ -791,6 +788,9 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg } rpcFreeCont(rpcMsg.pCont); + // only myself, maybe commit + syncMaybeAdvanceCommitIndex(ths); + } else { // pre commit SRpcMsg rpcMsg; From 8b896578536372188a15c20751ebe70a88d6d838 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 18 Mar 2022 17:33:17 +0800 Subject: [PATCH 52/60] [TD-13767]: forbid nchar without iconv. --- source/os/src/osString.c | 358 +-------------------------------------- 1 file changed, 7 insertions(+), 351 deletions(-) diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 07108ce34f..d3d1ab5dda 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -15,10 +15,8 @@ #define ALLOW_FORBID_FUNC #define _DEFAULT_SOURCE +#include #include "os.h" -// #include "tdef.h" -// #include -// #include #ifndef DISALLOW_NCHAR_WITHOUT_ICONV #include "iconv.h" @@ -32,14 +30,6 @@ int64_t taosStr2int64(const char *str) { return strtoll(str, &endptr, 10); } -bool taosCheckNcharValid(void) { -#ifdef DISALLOW_NCHAR_WITHOUT_ICONV - return false; -#else - return true; -#endif -} - int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) { for (int32_t i = 0; i < bytes; i += sizeof(TdUcs4)) { int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i); @@ -77,11 +67,13 @@ int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes) { TdUcs4* tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4) { - memcpy(target_ucs4, source_ucs4, len_ucs4*sizeof(TdUcs4)); + assert(malloc_usable_size(target_ucs4)>=len_ucs4*sizeof(TdUcs4)); + return memcpy(target_ucs4, source_ucs4, len_ucs4*sizeof(TdUcs4)); } int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { #ifdef DISALLOW_NCHAR_WITHOUT_ICONV + printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); return -1; #else iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC); @@ -99,6 +91,7 @@ int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs) { bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len) { #ifdef DISALLOW_NCHAR_WITHOUT_ICONV + printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); return -1; #else memset(ucs4, 0, ucs4_max_len); @@ -124,7 +117,8 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4 bool taosValidateEncodec(const char *encodec) { #ifdef DISALLOW_NCHAR_WITHOUT_ICONV - return false; + printf("Nchar cannot be read and written without iconv, please install iconv library and recompile TDengine.\n"); + return true; #else iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); if (cd == (iconv_t)(-1)) { @@ -164,341 +158,3 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) { ret int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); } int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); } - -// #ifdef USE_LIBICONV -// #include "iconv.h" - -// int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { -// iconv_t cd = iconv_open(tsCharset, DEFAULT_UNICODE_ENCODEC); -// size_t ucs4_input_len = ucs4_max_len; -// size_t outLen = ucs4_max_len; -// if (iconv(cd, (char **)&ucs4, &ucs4_input_len, &mbs, &outLen) == -1) { -// iconv_close(cd); -// return -1; -// } - -// iconv_close(cd); -// return (int32_t)(ucs4_max_len - outLen); -// } - -// bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { -// memset(ucs4, 0, ucs4_max_len); -// iconv_t cd = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); -// size_t ucs4_input_len = mbsLength; -// size_t outLeft = ucs4_max_len; -// if (iconv(cd, &mbs, &ucs4_input_len, &ucs4, &outLeft) == -1) { -// iconv_close(cd); -// return false; -// } - -// iconv_close(cd); -// if (len != NULL) { -// *len = (int32_t)(ucs4_max_len - outLeft); -// if (*len < 0) { -// return false; -// } -// } - -// return true; -// } - -// bool taosValidateEncodec(const char *encodec) { -// iconv_t cd = iconv_open(encodec, DEFAULT_UNICODE_ENCODEC); -// if (cd == (iconv_t)(-1)) { -// return false; -// } - -// iconv_close(cd); -// return true; -// } - -// #else - -// int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) { -// mbstate_t state = {0}; -// int32_t len = (int32_t)wcsnrtombs(NULL, (const wchar_t **)&ucs4, ucs4_max_len / 4, 0, &state); -// if (len < 0) { -// return -1; -// } - -// memset(&state, 0, sizeof(state)); -// len = wcsnrtombs(mbs, (const wchar_t **)&ucs4, ucs4_max_len / 4, (size_t)len, &state); -// if (len < 0) { -// return -1; -// } - -// return len; -// } - -// bool taosMbsToUcs4(const char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len, int32_t *len) { -// memset(ucs4, 0, ucs4_max_len); -// mbstate_t state = {0}; -// int32_t retlen = mbsnrtowcs((wchar_t *)ucs4, (const char **)&mbs, mbsLength, ucs4_max_len / 4, &state); -// *len = retlen; - -// return retlen >= 0; -// } - -// bool taosValidateEncodec(const char *encodec) { -// return true; -// } - -// #endif - -// #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) - -// /* -// * windows implementation -// */ - -// #ifdef HAVE_CONFIG_H -// #include -// #endif - -// #include -// #include -// #include -// #include -// #include - -// #if STDC_HEADERS -// #include -// #else -// char *malloc(), *realloc(); -// #endif - -// /* Always add at least this many bytes when extending the buffer. */ -// #define MIN_CHUNK 64 - -// /* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR -// + OFFSET (and null-terminate it). *LINEPTR is a pointer returned from -// malloc (or NULL), pointing to *N characters of space. It is realloc'd -// as necessary. Return the number of characters read (not including the -// null terminator), or -1 on error or EOF. On a -1 return, the caller -// should check feof(), if not then errno has been set to indicate -// the error. */ - -// int32_t getstr(char **lineptr, size_t *n, FILE *stream, char terminator, int32_t offset) { -// int32_t nchars_avail; /* Allocated but unused chars in *LINEPTR. */ -// char * read_pos; /* Where we're reading into *LINEPTR. */ -// int32_t ret; - -// if (!lineptr || !n || !stream) { -// errno = EINVAL; -// return -1; -// } - -// if (!*lineptr) { -// *n = MIN_CHUNK; -// *lineptr = malloc(*n); -// if (!*lineptr) { -// errno = ENOMEM; -// return -1; -// } -// } - -// nchars_avail = (int32_t)(*n - offset); -// read_pos = *lineptr + offset; - -// for (;;) { -// int32_t save_errno; -// register int32_t c = getc(stream); - -// save_errno = errno; - -// /* We always want at least one char left in the buffer, since we -// always (unless we get an error while reading the first char) -// NUL-terminate the line buffer. */ - -// assert((*lineptr + *n) == (read_pos + nchars_avail)); -// if (nchars_avail < 2) { -// if (*n > MIN_CHUNK) -// *n *= 2; -// else -// *n += MIN_CHUNK; - -// nchars_avail = (int32_t)(*n + *lineptr - read_pos); -// char* lineptr1 = realloc(*lineptr, *n); -// if (!lineptr1) { -// errno = ENOMEM; -// return -1; -// } -// *lineptr = lineptr1; - -// read_pos = *n - nchars_avail + *lineptr; -// assert((*lineptr + *n) == (read_pos + nchars_avail)); -// } - -// if (ferror(stream)) { -// /* Might like to return partial line, but there is no -// place for us to store errno. And we don't want to just -// lose errno. */ -// errno = save_errno; -// return -1; -// } - -// if (c == EOF) { -// /* Return partial line, if any. */ -// if (read_pos == *lineptr) -// return -1; -// else -// break; -// } - -// *read_pos++ = c; -// nchars_avail--; - -// if (c == terminator) /* Return the line. */ -// break; -// } - -// /* Done - NUL terminate and return the number of chars read. */ -// *read_pos = '\0'; - -// ret = (int32_t)(read_pos - (*lineptr + offset)); -// return ret; -// } - -// int32_t tgetline(char **lineptr, size_t *n, FILE *stream) { return getstr(lineptr, n, stream, '\n', 0); } - - -// /* -// * Get next token from string *stringp, where tokens are possibly-empty -// * strings separated by characters from delim. -// * -// * Writes NULs into the string at *stringp to end tokens. -// * delim need not remain constant from call to call. -// * On return, *stringp points past the last NUL written (if there might -// * be further tokens), or is NULL (if there are definitely no moretokens). -// * -// * If *stringp is NULL, strsep returns NULL. -// */ -// char *strsep(char **stringp, const char *delim) { -// char * s; -// const char *spanp; -// int32_t c, sc; -// char *tok; -// if ((s = *stringp) == NULL) -// return (NULL); -// for (tok = s;;) { -// c = *s++; -// spanp = delim; -// do { -// if ((sc = *spanp++) == c) { -// if (c == 0) -// s = NULL; -// else -// s[-1] = 0; -// *stringp = s; -// return (tok); -// } -// } while (sc != 0); -// } -// /* NOTREACHED */ -// } - -// char *getpass(const char *prefix) { -// static char passwd[TSDB_PASSWORD_LEN] = {0}; -// memset(passwd, 0, TSDB_PASSWORD_LEN); -// //printf("%s", prefix); - -// int32_t index = 0; -// char ch; -// while (index < TSDB_PASSWORD_LEN) { -// ch = getch(); -// if (ch == '\n' || ch == '\r') { -// break; -// } else { -// passwd[index++] = ch; -// } -// } - -// return passwd; -// } - -// int32_t twcslen(const wchar_t *wcs) { -// int32_t *wstr = (int32_t *)wcs; -// if (NULL == wstr) { -// return 0; -// } - -// int32_t n = 0; -// while (1) { -// if (0 == *wstr++) { -// break; -// } -// n++; -// } - -// return n; -// } -// int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes) { -// for (int32_t i = 0; i < bytes; i += TSDB_NCHAR_SIZE) { -// int32_t f1 = *(int32_t *)((char *)f1_ucs4 + i); -// int32_t f2 = *(int32_t *)((char *)f2_ucs4 + i); - -// if ((f1 == 0 && f2 != 0) || (f1 != 0 && f2 == 0)) { -// return f1 - f2; -// } else if (f1 == 0 && f2 == 0) { -// return 0; -// } - -// if (f1 != f2) { -// return f1 - f2; -// } -// } - -// return 0; - -// #if 0 -// int32_t ucs4_max_len = bytes + 4; -// char *f1_mbs = calloc(bytes, 1); -// char *f2_mbs = calloc(bytes, 1); -// if (taosUcs4ToMbs(f1_ucs4, ucs4_max_len, f1_mbs) < 0) { -// return -1; -// } -// if (taosUcs4ToMbs(f2_ucs4, ucs4_max_len, f2_mbs) < 0) { -// return -1; -// } -// int32_t ret = strcmp(f1_mbs, f2_mbs); -// free(f1_mbs); -// free(f2_mbs); -// return ret; -// #endif -// } - -// /* Copy memory to memory until the specified number of bytes -// has been copied, return pointer to following byte. -// Overlap is NOT handled correctly. */ -// void *mempcpy(void *dest, const void *src, size_t len) { -// return (char*)memcpy(dest, src, len) + len; -// } - -// /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ -// char *stpcpy (char *dest, const char *src) { -// size_t len = strlen (src); -// return (char*)memcpy(dest, src, len + 1) + len; -// } - -// /* Copy no more than N characters of SRC to DEST, returning the address of -// the terminating '\0' in DEST, if any, or else DEST + N. */ -// char *stpncpy (char *dest, const char *src, size_t n) { -// size_t size = strnlen (src, n); -// memcpy (dest, src, size); -// dest += size; -// if (size == n) -// return dest; -// return memset (dest, '\0', n - size); -// } - -// #else - -// /* -// * linux and darwin implementation -// */ - -// int32_t tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int32_t bytes, int8_t ncharSize) { -// return wcsncmp((wchar_t *)f1_ucs4, (wchar_t *)f2_ucs4, bytes / ncharSize); -// } - -// #endif From c2b4ec91ffc066cfa5f421988932247c0325793d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 18 Mar 2022 05:44:08 -0400 Subject: [PATCH 53/60] tmq plan implement --- include/common/ttypes.h | 2 +- include/libs/nodes/plannodes.h | 1 + include/libs/nodes/querynodes.h | 3 + include/libs/parser/parser.h | 1 + include/util/tjson.h | 2 + source/client/inc/clientInt.h | 3 +- source/client/src/clientEnv.c | 2 + source/client/src/clientImpl.c | 9 +- source/client/src/tmq.c | 30 +-- source/common/src/tdatablock.c | 10 +- source/dnode/vnode/src/tq/tqRead.c | 8 +- source/libs/nodes/src/nodesCloneFuncs.c | 4 +- source/libs/nodes/src/nodesCodeFuncs.c | 261 ++++++++++++++++++++- source/libs/nodes/src/nodesUtilFuncs.c | 2 +- source/libs/parser/src/parTranslater.c | 7 +- source/libs/planner/src/planLogicCreater.c | 2 +- source/libs/planner/src/planPhysiCreater.c | 10 +- source/util/src/tjson.c | 25 +- 18 files changed, 335 insertions(+), 47 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 5aa22bdcad..a936ea3b54 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -27,7 +27,7 @@ extern "C" { typedef int32_t VarDataOffsetT; typedef uint32_t TDRowLenT; typedef uint8_t TDRowValT; -typedef uint16_t col_id_t; +typedef int16_t col_id_t; typedef int8_t col_type_t; #pragma pack(push, 1) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 39ecd89619..18417cb608 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -166,6 +166,7 @@ typedef struct SScanPhysiNode { typedef SScanPhysiNode SSystemTableScanPhysiNode; typedef SScanPhysiNode STagScanPhysiNode; +typedef SScanPhysiNode SStreamScanPhysiNode; typedef struct STableScanPhysiNode { SScanPhysiNode scan; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index fe44d8666b..a55a0e218d 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -23,6 +23,9 @@ extern "C" { #include "nodes.h" #include "tmsg.h" +#define TABLE_META_SIZE(pMeta) (NULL == (pMeta) ? 0 : (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfColumns + (pMeta)->tableInfo.numOfTags) * sizeof(SSchema))) +#define VGROUPS_INFO_SIZE(pInfo) (NULL == (pInfo) ? 0 : (sizeof(SVgroupsInfo) + (pInfo)->numOfVgroups * sizeof(SVgroupInfo))) + typedef struct SRawExprNode { ENodeType nodeType; char* p; diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 77838c705f..23bcdabb1b 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -26,6 +26,7 @@ typedef struct SParseContext { uint64_t requestId; int32_t acctId; const char *db; + bool streamQuery; void *pTransporter; SEpSet mgmtEpSet; const char *pSql; // sql string diff --git a/include/util/tjson.h b/include/util/tjson.h index 1218caae35..b27f3b93ac 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -44,6 +44,7 @@ int32_t tjsonGetIntValue(const SJson* pJson, const char* pName, int32_t* pVal); int32_t tjsonGetSmallIntValue(const SJson* pJson, const char* pName, int16_t* pVal); int32_t tjsonGetTinyIntValue(const SJson* pJson, const char* pName, int8_t* pVal); int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pVal); +int32_t tjsonGetUIntValue(const SJson* pJson, const char* pName, uint32_t* pVal); int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal); int32_t tjsonGetBoolValue(const SJson* pJson, const char* pName, bool* pVal); int32_t tjsonGetDoubleValue(const SJson* pJson, const char* pName, double* pVal); @@ -60,6 +61,7 @@ int32_t tjsonAddArray(SJson* pJson, const char* pName, FToJson func, const void* typedef int32_t (*FToObject)(const SJson* pJson, void* pObj); int32_t tjsonToObject(const SJson* pJson, const char* pName, FToObject func, void* pObj); +int32_t tjsonMakeObject(const SJson* pJson, const char* pName, FToObject func, void** pObj, int32_t objSize); int32_t tjsonToArray(const SJson* pJson, const char* pName, FToObject func, void* pArray, int32_t itemSize); char* tjsonToString(const SJson* pJson); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index b672c9bb47..e341729a8f 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -179,6 +179,7 @@ typedef struct SRequestObj { uint64_t requestId; int32_t type; // request type STscObj* pTscObj; + char* pDb; char* sqlstr; // sql string int32_t sqlLen; int64_t self; @@ -229,7 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); -int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery); +int32_t parseSql(SRequestObj* pRequest, bool streamQuery, SQuery** pQuery); int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); // --- heartbeat diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 525c5f9fb8..2233742625 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -150,6 +150,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty return NULL; } + pRequest->pDb = getDbOfConnection(pObj); pRequest->requestId = generateRequestId(); pRequest->metric.start = taosGetTimestampMs(); @@ -180,6 +181,7 @@ static void doDestroyRequest(void *p) { tfree(pRequest->msgBuf); tfree(pRequest->sqlstr); tfree(pRequest->pInfo); + tfree(pRequest->pDb); doFreeReqResultInfo(&pRequest->body.resInfo); qDestroyQueryPlan(pRequest->body.pDag); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index fc97f4113c..aa94ed42fd 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -137,13 +137,14 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* return TSDB_CODE_SUCCESS; } -int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) { +int32_t parseSql(SRequestObj* pRequest, bool streamQuery, SQuery** pQuery) { STscObj* pTscObj = pRequest->pTscObj; SParseContext cxt = { .requestId = pRequest->requestId, .acctId = pTscObj->acctId, - .db = getDbOfConnection(pTscObj), + .db = pRequest->pDb, + .streamQuery = streamQuery, .pSql = pRequest->sqlstr, .sqlLen = pRequest->sqlLen, .pMsg = pRequest->msgBuf, @@ -154,7 +155,6 @@ int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) { cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog); if (code != TSDB_CODE_SUCCESS) { - tfree(cxt.db); return code; } @@ -163,7 +163,6 @@ int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) { setResSchemaInfo(&pRequest->body.resInfo, (*pQuery)->pResSchema, (*pQuery)->numOfResCols); } - tfree(cxt.db); return code; } @@ -249,7 +248,7 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) { terrno = TSDB_CODE_SUCCESS; CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); - CHECK_CODE_GOTO(parseSql(pRequest, &pQuery), _return); + CHECK_CODE_GOTO(parseSql(pRequest, false, &pQuery), _return); if (pQuery->directRpc) { CHECK_CODE_GOTO(execDdlQuery(pRequest, pQuery), _return); diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index ee13527b96..2aebd67c56 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,38 +482,24 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); -#if 0 - CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); - CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); - pQueryNode->streamQuery = true; + CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); + CHECK_CODE_GOTO(parseSql(pRequest, true, &pQueryNode), _return); // todo check for invalid sql statement and return with error code - SSchema* schema = NULL; - int32_t numOfCols = 0; - CHECK_CODE_GOTO(getPlan(pRequest, pQueryNode, &pRequest->body.pDag, NULL), _return); - - pStr = qQueryPlanToString(pRequest->body.pDag); - if (pStr == NULL) { - goto _return; - } + CHECK_CODE_GOTO(nodesNodeToString(pQueryNode->pRoot, false, &pStr, NULL), _return); /*printf("%s\n", pStr);*/ - // The topic should be related to a database that the queried table is belonged to. - SName name = {0}; - char dbName[TSDB_DB_FNAME_LEN] = {0}; - // tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName); - - tNameFromString(&name, dbName, T_NAME_ACCT | T_NAME_DB); - tNameFromString(&name, topicName, T_NAME_TABLE); + SName name = { .acctId = pTscObj->acctId, .type = TSDB_TABLE_NAME_T }; + strcpy(name.dbname, pRequest->pDb); + strcpy(name.tname, topicName); SCMCreateTopicReq req = { .igExists = 1, - .physicalPlan = (char*)pStr, + .ast = (char*)pStr, .sql = (char*)sql, - .logicalPlan = (char*)"no logic plan", }; tNameExtractFullName(&name, req.name); @@ -536,7 +522,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); -#endif + _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 4b649d5f62..31328cc4b2 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1072,6 +1072,10 @@ void blockDataClearup(SSDataBlock* pDataBlock) { } int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows) { + if (0 == numOfRows) { + return TSDB_CODE_SUCCESS; + } + if (IS_VAR_DATA_TYPE(pColumn->info.type)) { char* tmp = realloc(pColumn->varmeta.offset, sizeof(int32_t) * numOfRows); if (tmp == NULL) { @@ -1092,7 +1096,7 @@ int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRo pColumn->nullbitmap = tmp; memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows)); - + assert(pColumn->info.bytes); tmp = realloc(pColumn->pData, numOfRows * pColumn->info.bytes); if (tmp == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -1137,7 +1141,7 @@ void* blockDataDestroy(SSDataBlock* pBlock) { taosArrayDestroy(pBlock->pDataBlock); tfree(pBlock->pBlockAgg); - tfree(pBlock); + // tfree(pBlock); return NULL; } @@ -1190,7 +1194,7 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { } int32_t len = colDataGetLength(pColData, rows); - taosEncodeFixedI32(buf, len); + tlen += taosEncodeFixedI32(buf, len); tlen += taosEncodeBinary(buf, pColData->pData, len); } diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index a2342ec85a..0c4b933c19 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "tdatablock.h" #include "vnode.h" STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta) { @@ -128,10 +129,13 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) { int j = 0; for (int32_t i = 0; i < colNumNeed; i++) { - int32_t colId = *(int32_t*)taosArrayGet(pHandle->pColIdList, i); + int16_t colId = *(int16_t*)taosArrayGet(pHandle->pColIdList, i); while (j < pSchemaWrapper->nCols && pSchemaWrapper->pSchema[j].colId < colId) { j++; } + if (j >= pSchemaWrapper->nCols) { + continue; + } SSchema* pColSchema = &pSchemaWrapper->pSchema[j]; SColumnInfoData colInfo = {0}; int sz = numOfRows * pColSchema->bytes; @@ -145,6 +149,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) { taosArrayDestroy(pArray); return NULL; } + + blockDataEnsureColumnCapacity(&colInfo, numOfRows); taosArrayPush(pArray, &colInfo); } diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index d1dc2dec58..d66203eb40 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -197,7 +197,7 @@ static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) { } static STableMeta* tableMetaClone(const STableMeta* pSrc) { - int32_t len = sizeof(STableMeta) + (pSrc->tableInfo.numOfTags + pSrc->tableInfo.numOfColumns) * sizeof(SSchema); + int32_t len = TABLE_META_SIZE(pSrc); STableMeta* pDst = malloc(len); if (NULL == pDst) { return NULL; @@ -207,7 +207,7 @@ static STableMeta* tableMetaClone(const STableMeta* pSrc) { } static SVgroupsInfo* vgroupsInfoClone(const SVgroupsInfo* pSrc) { - int32_t len = sizeof(SVgroupsInfo) + pSrc->numOfVgroups * sizeof(SVgroupInfo); + int32_t len = VGROUPS_INFO_SIZE(pSrc); SVgroupsInfo* pDst = malloc(len); if (NULL == pDst) { return NULL; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 44f2318cc4..c61a2d71fb 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -193,6 +193,17 @@ static int32_t tableMetaToJson(const void* pObj, SJson* pJson) { return code; } +static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) { + STableMeta* pNode = (STableMeta*)pObj; + + int32_t code = tjsonGetUBigIntValue(pJson, jkTableMetaUid, &pNode->uid); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetUBigIntValue(pJson, jkTableMetaSuid, &pNode->suid); + } + + return code; +} + static const char* jkLogicPlanTargets = "Targets"; static const char* jkLogicPlanConditions = "Conditions"; static const char* jkLogicPlanChildren = "Children"; @@ -441,6 +452,14 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) { return code; } +static int32_t physiStreamScanNodeToJson(const void* pObj, SJson* pJson) { + return physiScanNodeToJson(pObj, pJson); +} + +static int32_t jsonToPhysiStreamScanNode(const SJson* pJson, void* pObj) { + return jsonToPhysiScanNode(pJson, pObj); +} + static const char* jkProjectPhysiPlanProjections = "Projections"; static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) { @@ -1269,6 +1288,193 @@ static int32_t jsonToFunctionNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkTableDbName = "DbName"; +static const char* jkTableTableName = "tableName"; +static const char* jkTableTableAlias = "tableAlias"; + +static int32_t tableNodeToJson(const void* pObj, SJson* pJson) { + const STableNode* pNode = (const STableNode*)pObj; + + int32_t code = exprNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkTableDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkTableTableName, pNode->tableName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkTableTableAlias, pNode->tableAlias); + } + + return code; +} + +static int32_t jsonToTableNode(const SJson* pJson, void* pObj) { + STableNode* pNode = (STableNode*)pObj; + + int32_t code = jsonToExprNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkTableDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkTableTableName, pNode->tableName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkTableTableAlias, pNode->tableAlias); + } + + return code; +} + +static const char* jkEpSetInUse = "InUse"; +static const char* jkEpSetNumOfEps = "NumOfEps"; +static const char* jkEpSetEps = "Eps"; + +static int32_t epSetToJson(const void* pObj, SJson* pJson) { + const SEpSet* pNode = (const SEpSet*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkEpSetInUse, pNode->inUse); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkEpSetNumOfEps, pNode->numOfEps); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddArray(pJson, jkEpSetEps, epToJson, pNode->eps, sizeof(SEp), pNode->numOfEps); + } + + return code; +} + +static int32_t jsonToEpSet(const SJson* pJson, void* pObj) { + SEpSet* pNode = (SEpSet*)pObj; + + int32_t code = tjsonGetTinyIntValue(pJson, jkEpSetInUse, &pNode->inUse); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetTinyIntValue(pJson, jkEpSetNumOfEps, &pNode->numOfEps); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonToArray(pJson, jkEpSetEps, jsonToEp, pNode->eps, sizeof(SEp)); + } + + return code; +} + +static const char* jkVgroupInfoVgId = "VgId"; +static const char* jkVgroupInfoHashBegin = "HashBegin"; +static const char* jkVgroupInfoHashEnd = "HashEnd"; +static const char* jkVgroupInfoEpSet = "EpSet"; +static const char* jkVgroupInfoNumOfTable = "NumOfTable"; + +static int32_t vgroupInfoToJson(const void* pObj, SJson* pJson) { + const SVgroupInfo* pNode = (const SVgroupInfo*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupInfoVgId, pNode->vgId); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashBegin, pNode->hashBegin); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkVgroupInfoHashEnd, pNode->hashEnd); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkVgroupInfoEpSet, epSetToJson, &pNode->epSet); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkVgroupInfoNumOfTable, pNode->numOfTable); + } + + return code; +} + +static int32_t jsonToVgroupInfo(const SJson* pJson, void* pObj) { + SVgroupInfo* pNode = (SVgroupInfo*)pObj; + + int32_t code = tjsonGetIntValue(pJson, jkVgroupInfoVgId, &pNode->vgId); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetUIntValue(pJson, jkVgroupInfoHashBegin, &pNode->hashBegin); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetUIntValue(pJson, jkVgroupInfoHashEnd, &pNode->hashEnd); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonToObject(pJson, jkVgroupInfoEpSet, jsonToEpSet, &pNode->epSet); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkVgroupInfoNumOfTable, &pNode->numOfTable); + } + + return code; +} + +static const char* jkVgroupsInfoNum = "Num"; +static const char* jkVgroupsInfoVgroups = "Vgroups"; + +static int32_t vgroupsInfoToJson(const void* pObj, SJson* pJson) { + const SVgroupsInfo* pNode = (const SVgroupsInfo*)pObj; + + int32_t code = tjsonAddIntegerToObject(pJson, jkVgroupsInfoNum, pNode->numOfVgroups); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddArray(pJson, jkVgroupsInfoVgroups, vgroupInfoToJson, pNode->vgroups, sizeof(SVgroupInfo), pNode->numOfVgroups); + } + + return code; +} + +static int32_t jsonToVgroupsInfo(const SJson* pJson, void* pObj) { + SVgroupsInfo* pNode = (SVgroupsInfo*)pObj; + + int32_t code = tjsonGetIntValue(pJson, jkVgroupsInfoNum, &pNode->numOfVgroups); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonToArray(pJson, jkVgroupsInfoVgroups, jsonToVgroupInfo, pNode->vgroups, sizeof(SVgroupInfo)); + } + + return code; +} + +static const char* jkRealTableMetaSize = "MetaSize"; +static const char* jkRealTableMeta = "Meta"; +static const char* jkRealTableVgroupsInfoSize = "VgroupsInfoSize"; +static const char* jkRealTableVgroupsInfo = "VgroupsInfo"; + +static int32_t realTableNodeToJson(const void* pObj, SJson* pJson) { + const SRealTableNode* pNode = (const SRealTableNode*)pObj; + + int32_t code = tableNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkRealTableMetaSize, TABLE_META_SIZE(pNode->pMeta)); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkRealTableMeta, tableMetaToJson, pNode->pMeta); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkRealTableVgroupsInfoSize, VGROUPS_INFO_SIZE(pNode->pVgroupList)); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkRealTableVgroupsInfo, vgroupsInfoToJson, pNode->pVgroupList); + } + + return code; +} + +static int32_t jsonToRealTableNode(const SJson* pJson, void* pObj) { + SRealTableNode* pNode = (SRealTableNode*)pObj; + + int32_t objSize = 0; + int32_t code = jsonToTableNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkRealTableMetaSize, &objSize); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonMakeObject(pJson, jkRealTableMeta, jsonToTableMeta, (void**)&pNode->pMeta, objSize); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkRealTableVgroupsInfoSize, &objSize); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonMakeObject(pJson, jkRealTableVgroupsInfo, jsonToVgroupsInfo, (void**)&pNode->pVgroupList, objSize); + } + + return code; +} + static const char* jkGroupingSetType = "GroupingSetType"; static const char* jkGroupingSetParameter = "Parameters"; @@ -1460,7 +1666,7 @@ static const char* jkSelectStmtSlimit = "Slimit"; static int32_t selectStmtTojson(const void* pObj, SJson* pJson) { const SSelectStmt* pNode = (const SSelectStmt*)pObj; - int32_t code = tjsonAddIntegerToObject(pJson, jkSelectStmtDistinct, pNode->isDistinct); + int32_t code = tjsonAddBoolToObject(pJson, jkSelectStmtDistinct, pNode->isDistinct); if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkSelectStmtProjections, pNode->pProjectionList); } @@ -1495,6 +1701,44 @@ static int32_t selectStmtTojson(const void* pObj, SJson* pJson) { return code; } +static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) { + SSelectStmt* pNode = (SSelectStmt*)pObj; + + int32_t code = tjsonGetBoolValue(pJson, jkSelectStmtDistinct, &pNode->isDistinct); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkSelectStmtProjections, &pNode->pProjectionList); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtFrom, &pNode->pFromTable); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtWhere, &pNode->pWhere); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkSelectStmtPartitionBy, &pNode->pPartitionByList); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtWindow, &pNode->pWindow); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkSelectStmtGroupBy, &pNode->pGroupByList); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtHaving, &pNode->pHaving); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeList(pJson, jkSelectStmtOrderBy, &pNode->pOrderByList); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtLimit, &pNode->pLimit); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkSelectStmtSlimit, &pNode->pSlimit); + } + + return code; +} + static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { switch (nodeType(pObj)) { case QUERY_NODE_COLUMN: @@ -1508,6 +1752,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_FUNCTION: return functionNodeToJson(pObj, pJson); case QUERY_NODE_REAL_TABLE: + return realTableNodeToJson(pObj, pJson); case QUERY_NODE_TEMP_TABLE: case QUERY_NODE_JOIN_TABLE: break; @@ -1561,9 +1806,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return physiTagScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: return physiTableScanNodeToJson(pObj, pJson); - case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - break; + return physiStreamScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return physiProjectNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_JOIN: @@ -1585,6 +1829,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN: return planToJson(pObj, pJson); default: + assert(0); break; } nodesWarn("specificNodeToJson unknown node = %s", nodesNodeName(nodeType(pObj))); @@ -1603,7 +1848,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToLogicConditionNode(pJson, pObj); case QUERY_NODE_FUNCTION: return jsonToFunctionNode(pJson, pObj); - // case QUERY_NODE_REAL_TABLE: + case QUERY_NODE_REAL_TABLE: + return jsonToRealTableNode(pJson, pObj); // case QUERY_NODE_TEMP_TABLE: // case QUERY_NODE_JOIN_TABLE: // break; @@ -1629,8 +1875,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToDownstreamSourceNode(pJson, pObj); // case QUERY_NODE_SET_OPERATOR: // break; - // case QUERY_NODE_SELECT_STMT: - // return jsonToSelectStmt(pJson, pObj); + case QUERY_NODE_SELECT_STMT: + return jsonToSelectStmt(pJson, pObj); // case QUERY_NODE_LOGIC_PLAN_SCAN: // return jsonToLogicScanNode(pJson, pObj); // case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -1643,6 +1889,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToPhysiTagScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: return jsonToPhysiTableScanNode(pJson, pObj); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: + return jsonToPhysiStreamScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return jsonToPhysiProjectNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_JOIN: @@ -1764,6 +2012,7 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) { int32_t code = makeNodeByJson(pJson, pNode); if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode(*pNode); + *pNode = NULL; terrno = code; return code; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 48b9c3e094..0d48202f73 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -170,7 +170,7 @@ SNodeptr nodesMakeNode(ENodeType type) { case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: return makeNode(type, sizeof(STableSeqScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - return makeNode(type, sizeof(SNode)); + return makeNode(type, sizeof(SStreamScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return makeNode(type, sizeof(SProjectPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_JOIN: diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 03206e89cb..171ec81ca2 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -126,7 +126,7 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol static int32_t createColumnNodeByTable(STranslateContext* pCxt, const STableNode* pTable, SNodeList* pList) { if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; - int32_t nums = pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType)? pMeta->tableInfo.numOfTags:0); + int32_t nums = pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0); for (int32_t i = 0; i < nums; ++i) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -499,6 +499,10 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) } static int32_t setTableVgroupList(SParseContext* pCxt, SName* name, SRealTableNode* pRealTable) { + if (pCxt->streamQuery) { + return TSDB_CODE_SUCCESS; + } + if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) { SArray* vgroupList = NULL; int32_t code = catalogGetTableDistVgInfo(pCxt->pCatalog, pCxt->pTransporter, &pCxt->mgmtEpSet, name, &vgroupList); @@ -1389,6 +1393,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p SCMCreateTopicReq createReq = {0}; if (NULL != pStmt->pQuery) { + pCxt->pParseCxt->streamQuery = true; int32_t code = translateQuery(pCxt, pStmt->pQuery); if (TSDB_CODE_SUCCESS == code) { code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index fd03eacf3f..93615b0565 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -131,7 +131,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect TSWAP(pScan->pMeta, pRealTable->pMeta, STableMeta*); TSWAP(pScan->pVgroupList, pRealTable->pVgroupList, SVgroupsInfo*); - pScan->scanType = SCAN_TYPE_TABLE; + pScan->scanType = pCxt->pPlanCxt->streamQuery ? SCAN_TYPE_STREAM : SCAN_TYPE_TABLE; pScan->scanFlag = MAIN_SCAN; pScan->scanRange = TSWINDOW_INITIALIZER; pScan->tableName.type = TSDB_TABLE_NAME_T; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 0affd93f4d..9bd926b676 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -259,15 +259,21 @@ static SPhysiNode* createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* p return (SPhysiNode*)pTableScan; } +static SPhysiNode* createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode) { + SStreamScanPhysiNode* pTableScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); + CHECK_ALLOC(pTableScan, NULL); + CHECK_CODE(initScanPhysiNode(pCxt, pScanLogicNode, (SScanPhysiNode*)pTableScan), (SPhysiNode*)pTableScan); + return (SPhysiNode*)pTableScan; +} + static SPhysiNode* createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode) { switch (pScanLogicNode->scanType) { case SCAN_TYPE_TAG: return createTagScanPhysiNode(pCxt, pScanLogicNode); case SCAN_TYPE_TABLE: return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode); - case SCAN_TYPE_STABLE: case SCAN_TYPE_STREAM: - break; + return createStreamScanPhysiNode(pCxt, pSubplan, pScanLogicNode); default: break; } diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 0a4a1a07a6..a85da8cbbf 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -202,9 +202,16 @@ int32_t tjsonGetUBigIntValue(const SJson* pJson, const char* pName, uint64_t* pV return (errno == ERANGE||errno == EINVAL) ? TSDB_CODE_FAILED:TSDB_CODE_SUCCESS; } +int32_t tjsonGetUIntValue(const SJson* pJson, const char* pName, uint32_t* pVal) { + uint64_t val = 0; + int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); + *pVal = val; + return code; +} + int32_t tjsonGetUTinyIntValue(const SJson* pJson, const char* pName, uint8_t* pVal) { uint64_t val = 0; - int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); + int32_t code = tjsonGetUBigIntValue(pJson, pName, &val); *pVal = val; return code; } @@ -239,6 +246,22 @@ int32_t tjsonToObject(const SJson* pJson, const char* pName, FToObject func, voi return func(pJsonObj, pObj); } +int32_t tjsonMakeObject(const SJson* pJson, const char* pName, FToObject func, void** pObj, int32_t objSize) { + if (objSize <= 0) { + return TSDB_CODE_SUCCESS; + } + + SJson* pJsonObj = tjsonGetObjectItem(pJson, pName); + if (NULL == pJsonObj) { + return TSDB_CODE_FAILED; + } + *pObj = calloc(1, objSize); + if (NULL == *pObj) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return func(pJsonObj, *pObj); +} + int32_t tjsonToArray(const SJson* pJson, const char* pName, FToObject func, void* pArray, int32_t itemSize) { const cJSON* jArray = tjsonGetObjectItem(pJson, pName); int32_t size = (NULL == jArray ? 0 : tjsonGetArraySize(jArray)); From 736dfaf064a45673a112fb85024c6170a6e31a69 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 17:46:40 +0800 Subject: [PATCH 54/60] sync refactor --- source/libs/sync/src/syncCommit.c | 1 + source/libs/sync/src/syncMain.c | 16 ++- source/libs/sync/test/CMakeLists.txt | 14 +++ source/libs/sync/test/syncReplicateTest.cpp | 126 ++++++++++++++++++++ 4 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 source/libs/sync/test/syncReplicateTest.cpp diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 8f0b8e5a79..38b39e04cf 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -110,6 +110,7 @@ bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index) { return true; } + // not agree return false; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index de108086bc..6ed9229625 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -60,11 +60,14 @@ int64_t syncStart(const SSyncInfo* pSyncInfo) { int32_t ret = 0; SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); assert(pSyncNode != NULL); + + // todo : return ref id return ret; } void syncStop(int64_t rid) { - SSyncNode* pSyncNode = NULL; // get pointer from rid + // todo : get pointer from rid + SSyncNode* pSyncNode = NULL; syncNodeClose(pSyncNode); } @@ -74,8 +77,10 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg* pSyncCfg) { } int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { - int32_t ret = 0; - SSyncNode* pSyncNode = NULL; // get pointer from rid + int32_t ret = 0; + + // todo : get pointer from rid + SSyncNode* pSyncNode = NULL; if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { SyncClientRequest* pSyncMsg = syncClientRequestBuild2(pMsg, 0, isWeak); SRpcMsg rpcMsg; @@ -86,13 +91,14 @@ int32_t syncForwardToPeer(int64_t rid, const SRpcMsg* pMsg, bool isWeak) { } else { sTrace("syncForwardToPeer not leader, %s", syncUtilState2String(pSyncNode->state)); - ret = -1; // need define err code !! + ret = -1; // todo : need define err code !! } return ret; } ESyncState syncGetMyRole(int64_t rid) { - SSyncNode* pSyncNode = NULL; // get pointer from rid + // todo : get pointer from rid + SSyncNode* pSyncNode = NULL; return pSyncNode->state; } diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 2821764448..0c7608f902 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -30,6 +30,7 @@ add_executable(syncPingSelfTest "") add_executable(syncElectTest "") add_executable(syncEncodeTest "") add_executable(syncWriteTest "") +add_executable(syncReplicateTest "") target_sources(syncTest @@ -160,6 +161,10 @@ target_sources(syncWriteTest PRIVATE "syncWriteTest.cpp" ) +target_sources(syncReplicateTest + PRIVATE + "syncReplicateTest.cpp" +) target_include_directories(syncTest @@ -327,6 +332,11 @@ target_include_directories(syncWriteTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncReplicateTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -457,6 +467,10 @@ target_link_libraries(syncWriteTest sync gtest_main ) +target_link_libraries(syncReplicateTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncReplicateTest.cpp b/source/libs/sync/test/syncReplicateTest.cpp new file mode 100644 index 0000000000..502263cfbf --- /dev/null +++ b/source/libs/sync/test/syncReplicateTest.cpp @@ -0,0 +1,126 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 3; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; +SWal* pWal; +SSyncNode* gSyncNode; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "./elect_test_%d", myIndex); + + int code = walInit(); + assert(code == 0); + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = syncInfo.vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + + char tmpdir[128]; + snprintf(tmpdir, sizeof(tmpdir), "./elect_test_wal_%d", myIndex); + pWal = walOpen(tmpdir, &walCfg); + assert(pWal != NULL); + + syncInfo.pWal = pWal; + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + gSyncNode = syncInitTest(); + assert(gSyncNode != NULL); + syncNodePrint2((char*)"", gSyncNode); + + initRaftId(gSyncNode); + + //--------------------------- + while (1) { + sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); + taosMsleep(1000); + } + + return 0; +} From 78bf3913e74079ed99477ec3c6a4535259adba1c Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 18 Mar 2022 17:48:04 +0800 Subject: [PATCH 55/60] [add cases] --- tests/script/tsim/query/interval-offset.sim | 292 ++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 tests/script/tsim/query/interval-offset.sim diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim new file mode 100644 index 0000000000..8034a27b9f --- /dev/null +++ b/tests/script/tsim/query/interval-offset.sim @@ -0,0 +1,292 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print =============== create database +sql create database d0 +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +sql use d0 + + +sql create table vehicle (ts timestamp, s int) tags (t1 int) +sql show stables +if $rows != 1 then + return -1 +endi + +sql create table car using vehicle tags(1000) +#sql create table ct1 using vehicle tags (1000) +sql show tables; +if $rows != 1 then + print rows: $rows + return -1 +endi + +sql insert into ct1 values('2019-01-01 00:00:00', 1) +sql insert into car values('2019-05-13 12:00:00', 1) +sql insert into car values('2019-12-31 23:59:59', 1) +sql insert into car values('2020-01-01 12:00:00', 1) +sql insert into car values('2020-01-02 12:00:00', 1) +sql insert into car values('2020-01-03 12:00:00', 1) +sql insert into car values('2020-01-04 12:00:00', 1) +sql insert into car values('2020-01-05 12:00:00', 1) +sql insert into car values('2020-01-31 12:00:00', 1) +sql insert into car values('2020-02-01 12:00:00', 1) +sql insert into car values('2020-02-02 12:00:00', 1) +sql insert into car values('2020-02-29 12:00:00', 1) +sql insert into car values('2020-03-01 12:00:00', 1) +sql insert into car values('2020-03-02 12:00:00', 1) +sql insert into car values('2020-03-15 12:00:00', 1) +sql insert into car values('2020-03-31 12:00:00', 1) +sql insert into car values('2020-05-01 12:00:00', 1) + +sql select count(*) from car interval(1n, 10d) +# tdSql.checkData(0, 1, 1) +# tdSql.checkData(1, 1, 1) +# tdSql.checkData(2, 1, 6) +# tdSql.checkData(3, 1, 3) +# tdSql.checkData(4, 1, 3) +# tdSql.checkData(5, 1, 2) +# tdSql.checkData(6, 1, 1) +if $rows != 17 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 6 then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 3 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 1 then + return -1 +endi + +return + +sql select count(*) from car interval(1n, 10d) order by ts desc +# tdSql.checkData(0, 1, 1) +# tdSql.checkData(1, 1, 2) +# tdSql.checkData(2, 1, 3) +# tdSql.checkData(3, 1, 3) +# tdSql.checkData(4, 1, 6) +# tdSql.checkData(5, 1, 1) +# tdSql.checkData(6, 1, 1) +# +sql select count(*) from car interval(2n, 5d) +# tdSql.checkData(0, 1, 1) +# tdSql.checkData(1, 1, 1) +# tdSql.checkData(2, 1, 6) +# tdSql.checkData(3, 1, 6) +# tdSql.checkData(4, 1, 3) + +sql select count(*) from car interval(2n) order by ts desc +# tdSql.checkData(0, 1, 3) +# tdSql.checkData(1, 1, 6) +# tdSql.checkData(2, 1, 6) +# tdSql.checkData(3, 1, 1) +# tdSql.checkData(4, 1, 1) +# +sql select count(*) from car interval(1y, 1n) +# tdSql.checkData(0, 1, 1) +# tdSql.checkData(1, 1, 8) +# tdSql.checkData(2, 1, 8) +# +sql select count(*) from car interval(1y, 2n) +# tdSql.checkData(0, 1, 1) +# tdSql.checkData(1, 1, 11) +# tdSql.checkData(2, 1, 5) + +sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d) +# tdSql.checkData(0, 1, 6) +# tdSql.checkData(1, 1, 9) + + + + + + + + + + + + +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +print ====== start create child tables and insert data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows $data01 $data05 +if $rows != $rowNum then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data04 != 1 then + return -1 +endi + +#print =============== step3 +#$cc = 4 * 60000 +#$ms = 1601481600000 + $cc +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +#print ===> $rows $data01 $data05 +#if $rows != 5 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi + +#print =============== step4 +#$cc = 40 * 60000 +#$ms = 1601481600000 + $cc + +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc + +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +#print ===> $rows $data01 $data05 +#if $rows != 20 then +# return -1 +#endi +#if $data00 != 1 then +# return -1 +#endi +#if $data04 != 1 then +# return -1 +#endi + +#print =============== step5 +#$cc = 40 * 60000 +#$ms = 1601481600000 + $cc + +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc + +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +#print ===> $rows $data21 $data25 +#if $rows != 42 then +# return -1 +#endi +#if $data20 != 1 then +# return -1 +#endi +#if $data24 != 1 then +# return -1 +#endi + +#print =============== step6 +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +#print ===> $rows $data11 +#if $rows != 20 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi + +#print =============== step7 +#$cc = 4 * 60000 +#$ms = 1601481600000 + $cc +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +#print ===> $rows $data11 +#if $rows != 5 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi + +#print =============== step8 +#$cc = 40 * 60000 +#$ms1 = 1601481600000 + $cc +# +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc +# +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +#print ===> $rows $data11 +#if $rows != 20 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi +# +#print =============== step9 +#$cc = 40 * 60000 +#$ms1 = 1601481600000 + $cc +# +#$cc = 1 * 60000 +#$ms2 = 1601481600000 - $cc +# +#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +#print ===> $rows $data11 +#if $rows != 42 then +# return -1 +#endi +#if $data11 != 10 then +# return -1 +#endi + +print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From d65edaadf74667103c3e87f68b83dd7aa8238704 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 18 Mar 2022 18:17:49 +0800 Subject: [PATCH 56/60] [TD-13772]: redefine timezone api. --- source/os/src/osTimezone.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 864a60b706..dd34d77b23 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -48,16 +48,11 @@ void taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight) { if (inTimezone == NULL || inTimezone[0] == 0) return; -#ifdef WINDOWS +#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) char winStr[TD_LOCALE_LEN * 2]; sprintf(winStr, "TZ=%s", inTimezone); putenv(winStr); -#else - setenv("TZ", inTimezone, 1); -#endif tzset(); - - /* * get CURRENT time zone. * system current time zone is affected by daylight saving time(DST) * @@ -75,15 +70,34 @@ void taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *ou int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); tz += daylight; - /* * format: * (CST, +0800) * (BST, +0100) */ + sprintf(outTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); + *outDaylight = daylight; + +#elif defined(_TD_DARWIN_64) + + setenv("TZ", inTimezone, 1); + tzset(); + int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); + tz += daylight; sprintf(outTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); *outDaylight = daylight; + +#else + setenv("TZ", inTimezone, 1); + tzset(); + int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); + tz += daylight; + sprintf(outTimezone, "(%s, %s%02d00)", tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); + *outDaylight = daylight; + +#endif + } void taosGetSystemTimezone(char *outTimezone) { From e554bb4856101bb055758258412f6a3be626a39b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 18 Mar 2022 06:31:44 -0400 Subject: [PATCH 57/60] insert bugfix --- source/libs/parser/src/parInsert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index a37820634f..803d8e00d8 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -391,7 +391,7 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, cha } // Remove quotation marks - if (TSDB_DATA_TYPE_BINARY == type) { + if (TK_NK_STRING == pToken->type) { if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) { return buildSyntaxErrMsg(pMsgBuf, "too long string", pToken->z); } From 3ce39eec1cdf0d0305666f5af8cd29081e5f9aba Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 18:42:49 +0800 Subject: [PATCH 58/60] sync refactor --- source/libs/sync/src/syncCommit.c | 3 + source/libs/sync/src/syncMain.c | 2 +- source/libs/sync/test/syncReplicateTest.cpp | 96 +++++++++++++++++---- 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 38b39e04cf..8c6071c621 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -52,6 +52,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { for (SyncIndex index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore); index > pSyncNode->commitIndex; ++index) { bool agree = syncAgree(pSyncNode, index); + sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%ld", agree, index); if (agree) { // term SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); @@ -70,6 +71,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { SyncIndex beginIndex = pSyncNode->commitIndex + 1; SyncIndex endIndex = newCommitIndex; + sTrace("syncMaybeAdvanceCommitIndex sync commit %ld", newCommitIndex); + // update commit index pSyncNode->commitIndex = newCommitIndex; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 6ed9229625..829526512b 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -804,7 +804,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg if (ths->pFsm != NULL) { if (ths->pFsm->FpPreCommitCb != NULL) { - ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, -1); + ths->pFsm->FpPreCommitCb(ths->pFsm, &rpcMsg, pEntry->index, pEntry->isWeak, -2); } } rpcFreeCont(rpcMsg.pCont); diff --git a/source/libs/sync/test/syncReplicateTest.cpp b/source/libs/sync/test/syncReplicateTest.cpp index 502263cfbf..a9a3942d69 100644 --- a/source/libs/sync/test/syncReplicateTest.cpp +++ b/source/libs/sync/test/syncReplicateTest.cpp @@ -3,6 +3,8 @@ #include "syncEnv.h" #include "syncIO.h" #include "syncInt.h" +#include "syncMessage.h" +#include "syncRaftEntry.h" #include "syncRaftLog.h" #include "syncRaftStore.h" #include "syncUtil.h" @@ -22,18 +24,40 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM* pFsm; -SWal* pWal; -SSyncNode* gSyncNode; +SSyncFSM * pFsm; +SWal * pWal; +SSyncNode *gSyncNode; -SSyncNode* syncNodeInit() { +void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==CommitCb==", (SRpcMsg *)pBuf); +} + +void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==PreCommitCb==", (SRpcMsg *)pBuf); +} + +void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pBuf, SyncIndex index, bool isWeak, int32_t code) { + printf("==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d \n", pFsm, index, isWeak, code); + syncRpcMsgPrint2((char *)"==RollBackCb==", (SRpcMsg *)pBuf); +} + +void initFsm() { + pFsm = (SSyncFSM *)malloc(sizeof(SSyncFSM)); + pFsm->FpCommitCb = CommitCb; + pFsm->FpPreCommitCb = PreCommitCb; + pFsm->FpRollBackCb = RollBackCb; +} + +SSyncNode *syncNodeInit() { syncInfo.vgId = 1234; syncInfo.rpcClient = gSyncIO->clientRpc; syncInfo.FpSendMsg = syncIOSendMsg; syncInfo.queue = gSyncIO->pMsgQ; syncInfo.FpEqMsg = syncIOEqMsg; syncInfo.pFsm = pFsm; - snprintf(syncInfo.path, sizeof(syncInfo.path), "./elect_test_%d", myIndex); + snprintf(syncInfo.path, sizeof(syncInfo.path), "./replicate_test_%d", myIndex); int code = walInit(); assert(code == 0); @@ -48,13 +72,13 @@ SSyncNode* syncNodeInit() { walCfg.level = TAOS_WAL_FSYNC; char tmpdir[128]; - snprintf(tmpdir, sizeof(tmpdir), "./elect_test_wal_%d", myIndex); + snprintf(tmpdir, sizeof(tmpdir), "./replicate_test_wal_%d", myIndex); pWal = walOpen(tmpdir, &walCfg); assert(pWal != NULL); syncInfo.pWal = pWal; - SSyncCfg* pCfg = &syncInfo.syncCfg; + SSyncCfg *pCfg = &syncInfo.syncCfg; pCfg->myIndex = myIndex; pCfg->replicaNum = replicaNum; @@ -64,57 +88,95 @@ SSyncNode* syncNodeInit() { // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); } - SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + SSyncNode *pSyncNode = syncNodeOpen(&syncInfo); assert(pSyncNode != NULL); gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; - gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; - gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; gSyncIO->pSyncNode = pSyncNode; return pSyncNode; } -SSyncNode* syncInitTest() { return syncNodeInit(); } +SSyncNode *syncInitTest() { return syncNodeInit(); } -void initRaftId(SSyncNode* pSyncNode) { +void initRaftId(SSyncNode *pSyncNode) { for (int i = 0; i < replicaNum; ++i) { ids[i] = pSyncNode->replicasId[i]; - char* s = syncUtilRaftId2Str(&ids[i]); + char *s = syncUtilRaftId2Str(&ids[i]); printf("raftId[%d] : %s\n", i, s); free(s); } } -int main(int argc, char** argv) { +SRpcMsg *step0(int i) { + SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); + memset(pMsg, 0, sizeof(SRpcMsg)); + pMsg->msgType = 9999; + pMsg->contLen = 32; + pMsg->pCont = malloc(pMsg->contLen); + snprintf((char *)(pMsg->pCont), pMsg->contLen, "value-%u-%d", ports[myIndex], i); + return pMsg; +} + +SyncClientRequest *step1(const SRpcMsg *pMsg) { + SyncClientRequest *pRetMsg = syncClientRequestBuild2(pMsg, 123, true); + return pRetMsg; +} + +int main(int argc, char **argv) { // taosInitLog((char *)"syncTest.log", 100000, 10); tsAsyncLog = 0; sDebugFlag = 143 + 64; + void logTest(); myIndex = 0; if (argc >= 2) { myIndex = atoi(argv[1]); } - int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + int32_t ret = syncIOStart((char *)"127.0.0.1", ports[myIndex]); assert(ret == 0); ret = syncEnvStart(); assert(ret == 0); + taosRemoveDir("./wal_test"); + + initFsm(); + gSyncNode = syncInitTest(); assert(gSyncNode != NULL); - syncNodePrint2((char*)"", gSyncNode); + syncNodePrint2((char *)"", gSyncNode); initRaftId(gSyncNode); - //--------------------------- + for (int i = 0; i < 30; ++i) { + // step0 + SRpcMsg *pMsg0 = step0(i); + syncRpcMsgPrint2((char *)"==step0==", pMsg0); + + // step1 + SyncClientRequest *pMsg1 = step1(pMsg0); + syncClientRequestPrint2((char *)"==step1==", pMsg1); + + SyncClientRequest *pSyncClientRequest = pMsg1; + SRpcMsg rpcMsg; + syncClientRequest2RpcMsg(pSyncClientRequest, &rpcMsg); + gSyncNode->FpEqMsg(gSyncNode->queue, &rpcMsg); + + taosMsleep(1000); + sTrace("replicate sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); + } + while (1) { sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, From aea4e0f4722ebe43e703e2f820944a75b766f1b1 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 18 Mar 2022 19:09:22 +0800 Subject: [PATCH 59/60] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 5 ++++- source/libs/sync/src/syncAppendEntriesReply.c | 5 ++++- source/libs/sync/src/syncCommit.c | 5 +++-- source/libs/sync/src/syncRequestVote.c | 5 ++++- source/libs/sync/src/syncRequestVoteReply.c | 5 ++++- source/libs/sync/test/syncElectTest.cpp | 5 ++--- source/libs/sync/test/syncReplicateTest.cpp | 10 +++++----- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 270180e347..e4df93ca47 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -87,7 +87,10 @@ // int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { int32_t ret = 0; - syncAppendEntriesLog2("==syncNodeOnAppendEntriesCb==", pMsg); + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesCb== term:%lu", ths->pRaftStore->currentTerm); + syncAppendEntriesLog2(logBuf, pMsg); if (pMsg->term > ths->pRaftStore->currentTerm) { syncNodeUpdateTerm(ths, pMsg->term); diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 9db9a3e8ac..817974fd26 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -37,7 +37,10 @@ // int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* pMsg) { int32_t ret = 0; - syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplyCb==", pMsg); + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnAppendEntriesReplyCb== term:%lu", ths->pRaftStore->currentTerm); + syncAppendEntriesReplyLog2(logBuf, pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 8c6071c621..0d4df8e6cf 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -50,9 +50,10 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { // update commit index SyncIndex newCommitIndex = pSyncNode->commitIndex; for (SyncIndex index = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore); index > pSyncNode->commitIndex; - ++index) { + --index) { bool agree = syncAgree(pSyncNode, index); - sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%ld", agree, index); + sTrace("syncMaybeAdvanceCommitIndex syncAgree:%d, index:%ld, pSyncNode->commitIndex:%ld", agree, index, + pSyncNode->commitIndex); if (agree) { // term SSyncRaftEntry* pEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, index); diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 062b0244bd..e23748a81e 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -43,7 +43,10 @@ // int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t ret = 0; - syncRequestVoteLog2("==syncNodeOnRequestVoteCb==", pMsg); + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteCb== term:%lu", ths->pRaftStore->currentTerm); + syncRequestVoteLog2(logBuf, pMsg); if (pMsg->term > ths->pRaftStore->currentTerm) { syncNodeUpdateTerm(ths, pMsg->term); diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 12603bb337..1531f701ff 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -38,7 +38,10 @@ // int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) { int32_t ret = 0; - syncRequestVoteReplyLog2("==syncNodeOnRequestVoteReplyCb==", pMsg); + + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "==syncNodeOnRequestVoteReplyCb== term:%lu", ths->pRaftStore->currentTerm); + syncRequestVoteReplyLog2(logBuf, pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp index 502263cfbf..0e0b57a025 100644 --- a/source/libs/sync/test/syncElectTest.cpp +++ b/source/libs/sync/test/syncElectTest.cpp @@ -116,10 +116,9 @@ int main(int argc, char** argv) { //--------------------------- while (1) { - sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", - gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + sTrace("elect sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->pRaftStore->currentTerm, gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); - taosMsleep(1000); } return 0; diff --git a/source/libs/sync/test/syncReplicateTest.cpp b/source/libs/sync/test/syncReplicateTest.cpp index a9a3942d69..6c4fab2425 100644 --- a/source/libs/sync/test/syncReplicateTest.cpp +++ b/source/libs/sync/test/syncReplicateTest.cpp @@ -119,7 +119,7 @@ SRpcMsg *step0(int i) { SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg)); memset(pMsg, 0, sizeof(SRpcMsg)); pMsg->msgType = 9999; - pMsg->contLen = 32; + pMsg->contLen = 128; pMsg->pCont = malloc(pMsg->contLen); snprintf((char *)(pMsg->pCont), pMsg->contLen, "value-%u-%d", ports[myIndex], i); return pMsg; @@ -172,14 +172,14 @@ int main(int argc, char **argv) { gSyncNode->FpEqMsg(gSyncNode->queue, &rpcMsg); taosMsleep(1000); - sTrace("replicate sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", - gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + sTrace("replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->pRaftStore->currentTerm, gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); } while (1) { - sTrace("while 1 sleep, state: %d, %s, electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", - gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->electTimerLogicClock, + sTrace("replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, electTimerMS:%d", + gSyncNode->state, syncUtilState2String(gSyncNode->state), gSyncNode->pRaftStore->currentTerm, gSyncNode->electTimerLogicClock, gSyncNode->electTimerLogicClockUser, gSyncNode->electTimerMS); taosMsleep(1000); } From 8a709fdbf3ddd848756b8459b3283dfd5fa82fb2 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Fri, 18 Mar 2022 20:11:33 +0800 Subject: [PATCH 60/60] refactor and put sma file in smaUid dir --- source/dnode/vnode/src/inc/tsdbDef.h | 1 + source/dnode/vnode/src/inc/tsdbFS.h | 24 ++++---- source/dnode/vnode/src/inc/tsdbSma.h | 6 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 80 +++++++++++++++---------- source/dnode/vnode/test/tsdbSmaTest.cpp | 2 + 5 files changed, 69 insertions(+), 44 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdbDef.h b/source/dnode/vnode/src/inc/tsdbDef.h index 5e4c852621..69bd1ccea5 100644 --- a/source/dnode/vnode/src/inc/tsdbDef.h +++ b/source/dnode/vnode/src/inc/tsdbDef.h @@ -63,6 +63,7 @@ struct STsdb { #define REPO_ID(r) ((r)->vgId) #define REPO_CFG(r) (&(r)->config) #define REPO_FS(r) (r)->fs +#define REPO_TFS(r) (r)->pTfs #define IS_REPO_LOCKED(r) (r)->repoLocked #define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv) diff --git a/source/dnode/vnode/src/inc/tsdbFS.h b/source/dnode/vnode/src/inc/tsdbFS.h index 96c5f8468f..21b445755f 100644 --- a/source/dnode/vnode/src/inc/tsdbFS.h +++ b/source/dnode/vnode/src/inc/tsdbFS.h @@ -42,23 +42,23 @@ typedef struct { typedef struct { STsdbFSMeta meta; // FS meta SArray * df; // data file array - SArray * sf; // sma data file array v2(t|r)1900.index_name_1 + SArray * sf; // sma data file array v2f1900.index_name_1 } SFSStatus; /** * @brief Directory structure of .tsma data files. * - * /vnode2/tsdb $ tree .sma/ - * .sma/ - * ├── v2t100.index_name_1 - * ├── v2t101.index_name_1 - * ├── v2t102.index_name_1 - * ├── v2t1900.index_name_3 - * ├── v2t1901.index_name_3 - * ├── v2t1902.index_name_3 - * ├── v2t200.index_name_2 - * ├── v2t201.index_name_2 - * └── v2t202.index_name_2 + * /vnode2/tsdb $ tree tsma/ + * tsma/ + * ├── v2f100.index_name_1 + * ├── v2f101.index_name_1 + * ├── v2f102.index_name_1 + * ├── v2f1900.index_name_3 + * ├── v2f1901.index_name_3 + * ├── v2f1902.index_name_3 + * ├── v2f200.index_name_2 + * ├── v2f201.index_name_2 + * └── v2f202.index_name_2 * * 0 directories, 9 files */ diff --git a/source/dnode/vnode/src/inc/tsdbSma.h b/source/dnode/vnode/src/inc/tsdbSma.h index 649b5a2d47..b94f0b1b83 100644 --- a/source/dnode/vnode/src/inc/tsdbSma.h +++ b/source/dnode/vnode/src/inc/tsdbSma.h @@ -21,12 +21,14 @@ typedef struct SSmaEnv SSmaEnv; struct SSmaEnv { pthread_rwlock_t lock; - TDBEnv dbEnv; - char * path; + SDiskID did; + TDBEnv dbEnv; // TODO: If it's better to put it in smaIndex level? + char * path; // relative path SSmaStat * pStat; }; #define SMA_ENV_LOCK(env) ((env)->lock) +#define SMA_ENV_DID(env) ((env)->did) #define SMA_ENV_ENV(env) ((env)->dbEnv) #define SMA_ENV_PATH(env) ((env)->path) #define SMA_ENV_STAT(env) ((env)->pStat) diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 02a0b587d5..512ea9fa25 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -67,7 +67,7 @@ typedef struct { */ int8_t state; // ETsdbSmaStat SHashObj *expiredWindows; // key: skey of time window, value: N/A - STSma * pSma; + STSma * pSma; // cache schema } SSmaStatItem; struct SSmaStat { @@ -81,8 +81,8 @@ struct SSmaStat { static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); -static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path); -static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv); +static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did); +static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SDiskID did, SSmaEnv **pEnv); static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey); static int32_t tsdbRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); @@ -102,8 +102,8 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen); static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision); static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel); -static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); -static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); +static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int64_t indexUid, int32_t fid); +static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg); @@ -111,10 +111,11 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg); // implementation static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { - snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); + snprintf(dirName, TSDB_FILENAME_LEN, "vnode%svnode%d%stsdb%s%s", TD_DIRSEP, vgId, TD_DIRSEP, TD_DIRSEP, + TSDB_SMA_DNAME[smaType]); } -static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { +static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did) { SSmaEnv *pEnv = NULL; pEnv = (SSmaEnv *)calloc(1, sizeof(SSmaEnv)); @@ -137,12 +138,16 @@ static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { return NULL; } + pEnv->did = did; + if (tsdbInitSmaStat(&pEnv->pStat) != TSDB_CODE_SUCCESS) { tsdbFreeSmaEnv(pEnv); return NULL; } - if (tsdbOpenBDBEnv(&pEnv->dbEnv, pEnv->path) != TSDB_CODE_SUCCESS) { + char aname[TSDB_FILENAME_LEN] = {0}; + tfsAbsoluteName(pTsdb->pTfs, did, path, aname); + if (tsdbOpenBDBEnv(&pEnv->dbEnv, aname) != TSDB_CODE_SUCCESS) { tsdbFreeSmaEnv(pEnv); return NULL; } @@ -150,14 +155,14 @@ static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { return pEnv; } -static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { +static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SDiskID did, SSmaEnv **pEnv) { if (!pEnv) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } if (*pEnv == NULL) { - if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { + if ((*pEnv = tsdbNewSmaEnv(pTsdb, path, did)) == NULL) { return TSDB_CODE_FAILED; } } @@ -296,7 +301,6 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { pEnv = (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_load_ptr(&pTsdb->pTSmaEnv) : atomic_load_ptr(&pTsdb->pRSmaEnv); if (pEnv == NULL) { char rname[TSDB_FILENAME_LEN] = {0}; - char aname[TSDB_FILENAME_LEN] = {0}; // use TSDB_FILENAME_LEN currently SDiskID did = {0}; tfsAllocDisk(pTsdb->pTfs, TFS_PRIMARY_LEVEL, &did); @@ -305,14 +309,13 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_FAILED; } tsdbGetSmaDir(REPO_ID(pTsdb), smaType, rname); - tfsAbsoluteName(pTsdb->pTfs, did, rname, aname); if (tfsMkdirRecurAt(pTsdb->pTfs, rname, did) != TSDB_CODE_SUCCESS) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } - if (tsdbInitSmaEnv(pTsdb, aname, &pEnv) != TSDB_CODE_SUCCESS) { + if (tsdbInitSmaEnv(pTsdb, rname, did, &pEnv) != TSDB_CODE_SUCCESS) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; } @@ -339,11 +342,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { return TSDB_CODE_FAILED; } - if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) { - terrno = TSDB_CODE_TDB_INIT_FAILED; - return TSDB_CODE_FAILED; - } - // TODO: decode the msg from Stream Computing module => start int64_t indexUid = SMA_TEST_INDEX_UID; const int32_t SMA_TEST_EXPIRED_WINDOW_SIZE = 10; @@ -354,6 +352,11 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { } // TODO: decode the msg <= end + if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INIT_FAILED; + return TSDB_CODE_FAILED; + } + SSmaEnv * pEnv = REPO_SMA_ENV(pTsdb, smaType); SSmaStat *pStat = SMA_ENV_STAT(pEnv); SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); @@ -660,14 +663,13 @@ static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH) { } } -static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid) { +static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int64_t indexUid, int32_t fid) { STsdb *pTsdb = pSmaH->pTsdb; ASSERT(pSmaH->dFile.path == NULL && pSmaH->dFile.pDB == NULL); pSmaH->dFile.fid = fid; - char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "v%df%d.tsma", REPO_ID(pTsdb), fid); + snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, REPO_ID(pTsdb), fid); pSmaH->dFile.path = strdup(tSmaFile); return TSDB_CODE_SUCCESS; @@ -708,8 +710,9 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { STsdbCfg * pCfg = REPO_CFG(pTsdb); STSmaDataWrapper *pData = (STSmaDataWrapper *)msg; + SSmaEnv * pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv); - if (!atomic_load_ptr(&pTsdb->pTSmaEnv)) { + if (pEnv == NULL) { terrno = TSDB_CODE_INVALID_PTR; tsdbWarn("vgId:%d insert tSma data failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); return terrno; @@ -727,6 +730,17 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { return TSDB_CODE_FAILED; } + int64_t indexUid = SMA_TEST_INDEX_UID; + char rPath[TSDB_FILENAME_LEN] = {0}; + char aPath[TSDB_FILENAME_LEN] = {0}; + snprintf(rPath, TSDB_FILENAME_LEN, "%s%s%" PRIi64, SMA_ENV_PATH(pEnv), TD_DIRSEP, indexUid); + tfsAbsoluteName(REPO_TFS(pTsdb), SMA_ENV_DID(pEnv), rPath, aPath); + if (!taosCheckExistFile(aPath)) { + if (tfsMkdirRecurAt(REPO_TFS(pTsdb), rPath, SMA_ENV_DID(pEnv)) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_FAILED; + } + } + // Step 1: Judge the storage level and days int32_t storageLevel = tsdbGetSmaStorageLevel(pData->interval, pData->intervalUnit); int32_t daysPerFile = tsdbGetTSmaDays(pTsdb, tSmaH.interval, storageLevel); @@ -735,7 +749,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { // Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file // - Set and open the DFile or the B+Tree file // TODO: tsdbStartTSmaCommit(); - tsdbSetTSmaDataFile(&tSmaH, pData, storageLevel, fid); + tsdbSetTSmaDataFile(&tSmaH, pData, indexUid, fid); if (tsdbOpenDBF(pTsdb->pTSmaEnv->dbEnv, &tSmaH.dFile) != 0) { tsdbWarn("vgId:%d open DB file %s failed since %s", REPO_ID(pTsdb), tSmaH.dFile.path ? tSmaH.dFile.path : "path is NULL", tstrerror(terrno)); @@ -822,13 +836,16 @@ static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interv * @brief Init of tSma FS * * @param pReadH + * @param indexUid * @param skey * @return int32_t */ -static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey) { - int32_t fid = (int32_t)(TSDB_KEY_FID(skey, pSmaH->days, REPO_CFG(pSmaH->pTsdb)->precision)); +static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, int64_t indexUid, TSKEY skey) { + STsdb *pTsdb = pSmaH->pTsdb; + + int32_t fid = (int32_t)(TSDB_KEY_FID(skey, pSmaH->days, REPO_CFG(pTsdb)->precision)); char tSmaFile[TSDB_FILENAME_LEN] = {0}; - snprintf(tSmaFile, TSDB_FILENAME_LEN, "v%df%d.tsma", REPO_ID(pSmaH->pTsdb), fid); + snprintf(tSmaFile, TSDB_FILENAME_LEN, "%" PRIi64 "%sv%df%d.tsma", indexUid, TD_DIRSEP, REPO_ID(pTsdb), fid); pSmaH->dFile.path = strdup(tSmaFile); pSmaH->smaFsIter.iter = 0; pSmaH->smaFsIter.fid = fid; @@ -887,14 +904,16 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { - if (!atomic_load_ptr(&pTsdb->pTSmaEnv)) { + SSmaEnv *pEnv = atomic_load_ptr(&pTsdb->pTSmaEnv); + + if (!pEnv) { terrno = TSDB_CODE_INVALID_PTR; tsdbWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); return TSDB_CODE_FAILED; } - tsdbRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); - SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); + tsdbRefSmaStat(pTsdb, SMA_ENV_STAT(pEnv)); + SSmaStatItem *pItem = taosHashGet(SMA_ENV_STAT_ITEMS(pEnv), &indexUid, sizeof(indexUid)); if ((pItem == NULL) || ((pItem = *(SSmaStatItem **)pItem) == NULL)) { // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if // it's NULL. @@ -926,11 +945,12 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); #endif + STSmaReadH tReadH = {0}; tsdbInitTSmaReadH(&tReadH, pTsdb, interval, intervalUnit); tsdbCloseDBF(&tReadH.dFile); - tsdbInitTSmaFile(&tReadH, querySKey); + tsdbInitTSmaFile(&tReadH, indexUid, querySKey); if (tsdbOpenDBF(SMA_ENV_ENV(pTsdb->pTSmaEnv), &tReadH.dFile) != 0) { tsdbWarn("vgId:%d open DBF %s failed since %s", REPO_ID(pTsdb), tReadH.dFile.path, tstrerror(terrno)); return TSDB_CODE_FAILED; diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 5a87c180b6..bdeb51c018 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -33,6 +33,7 @@ int main(int argc, char **argv) { return RUN_ALL_TESTS(); } +#if 1 TEST(testCase, tSma_Meta_Encode_Decode_Test) { // encode STSma tSma = {0}; @@ -88,6 +89,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { tdDestroyTSma(&tSma); tdDestroyTSmaWrapper(&dstTSmaWrapper); } +#endif #if 1 TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {