From 6c0c1b222fa8fdedd36f504632dea8766dda7b35 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Dec 2021 15:32:51 +0800 Subject: [PATCH 01/55] more --- contrib/test/tdev/src/main.c | 27 +++- include/os/osEndian.h | 3 + include/util/tcoding.h | 158 ++++++++++++++++++++++ source/dnode/vnode/meta/src/metaBDBImpl.c | 4 +- 4 files changed, 189 insertions(+), 3 deletions(-) diff --git a/contrib/test/tdev/src/main.c b/contrib/test/tdev/src/main.c index 687b175a62..baae604992 100644 --- a/contrib/test/tdev/src/main.c +++ b/contrib/test/tdev/src/main.c @@ -14,6 +14,10 @@ #define tPutB(buf, val) \ ({ \ + ((uint8_t *)buf)[7] = ((val) >> 56) & 0xff; \ + ((uint8_t *)buf)[6] = ((val) >> 48) & 0xff; \ + ((uint8_t *)buf)[5] = ((val) >> 40) & 0xff; \ + ((uint8_t *)buf)[4] = ((val) >> 32) & 0xff; \ ((uint8_t *)buf)[3] = ((val) >> 24) & 0xff; \ ((uint8_t *)buf)[2] = ((val) >> 16) & 0xff; \ ((uint8_t *)buf)[1] = ((val) >> 8) & 0xff; \ @@ -27,7 +31,17 @@ POINTER_SHIFT(buf, sizeof(val)); \ }) -typedef enum { A, B, C } T; +#define tPutD(buf, val) \ + ({ \ + uint64_t tmp = val; \ + for (size_t i = 0; i < sizeof(val); i++) { \ + ((uint8_t *)buf)[i] = tmp & 0xff; \ + tmp >>= 8; \ + } \ + POINTER_SHIFT(buf, sizeof(val)); \ + }) + +typedef enum { A, B, C, D } T; static void func(T t) { uint64_t val = 198; @@ -59,6 +73,14 @@ static void func(T t) { } } break; + case D: + for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) { + pBuf = tPutD(pBuf, val); + if (POINTER_DISTANCE(buf, pBuf) == 1024) { + pBuf = buf; + } + } + break; default: break; @@ -83,5 +105,8 @@ int main(int argc, char const *argv[]) { func(C); uint64_t t4 = now(); printf("C: %ld\n", t4 - t3); + func(D); + uint64_t t5 = now(); + printf("D: %ld\n", t5 - t4); return 0; } diff --git a/include/os/osEndian.h b/include/os/osEndian.h index 496012cf28..e573ba0a75 100644 --- a/include/os/osEndian.h +++ b/include/os/osEndian.h @@ -20,8 +20,11 @@ extern "C" { #endif +typedef enum { TD_LITTLE_ENDIAN = 0, TD_BIG_ENDIAN } td_endian_t; + static const int32_t endian_test_var = 1; #define IS_LITTLE_ENDIAN() (*(uint8_t *)(&endian_test_var) != 0) +#define TD_RT_ENDIAN() (IS_LITTLE_ENDIAN() ? TD_LITTLE_ENDIAN : TD_BIG_ENDIAN) #ifdef __cplusplus } diff --git a/include/util/tcoding.h b/include/util/tcoding.h index 6e6a91130c..86812463b7 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -25,6 +25,162 @@ extern "C" { #define ZIGZAGE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode #define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode +/* ------------------------ FIXED-LENGTH ENCODING ------------------------ */ +#define tPut(T, b, v) \ + ({ \ + *(T *)(b) = (v); \ + sizeof(T); \ + }) + +#define tGet(T, b, v) \ + ({ \ + (v) = (*(T *)(b)); \ + sizeof(T); \ + }) + +// 16 +#define tPut16b(b, v) \ + ({ \ + ((uint8_t *)(b))[1] = (v)&0xff; \ + ((uint8_t *)(b))[0] = ((v) >> 8) & 0xff; \ + 2; \ + }) + +#define tGet16b(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[0]; \ + (v) = (v) << 8; \ + (v) |= ((uint8_t *)(b))[1]; \ + 2; \ + }) + +#define tPut16l(b, v) \ + ({ \ + ((uint8_t *)(b))[0] = (v)&0xff; \ + ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ + 2; \ + }) + +#define tGet16l(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[1]; \ + (v) <<= 8; \ + (v) |= ((uint8_t *)(b))[0]; \ + 2; \ + }) + +// 32 +#define tPut32b(b, v) \ + ({ \ + ((uint8_t *)(b))[3] = (v)&0xff; \ + ((uint8_t *)(b))[2] = ((v) >> 8) & 0xff; \ + ((uint8_t *)(b))[1] = ((v) >> 16) & 0xff; \ + ((uint8_t *)(b))[0] = ((v) >> 24) & 0xff; \ + 4; \ + }) + +#define tGet32b(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[0]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[1]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[2]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[3]; \ + 4; \ + }) + +#define tPut32l(b, v) \ + ({ \ + ((uint8_t *)(b))[0] = (v)&0xff; \ + ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ + ((uint8_t *)(b))[2] = ((v) >> 16) & 0xff; \ + ((uint8_t *)(b))[3] = ((v) >> 24) & 0xff; \ + 4; \ + }) + +#define tGet32l(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[3]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[2]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[1]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[0]; \ + 4; \ + }) + +// 64 +#define tPut64b(b, v) \ + ({ \ + ((uint8_t *)(b))[7] = (v)&0xff; \ + ((uint8_t *)(b))[6] = ((v) >> 8) & 0xff; \ + ((uint8_t *)(b))[5] = ((v) >> 16) & 0xff; \ + ((uint8_t *)(b))[4] = ((v) >> 24) & 0xff; \ + ((uint8_t *)(b))[3] = ((v) >> 32) & 0xff; \ + ((uint8_t *)(b))[2] = ((v) >> 40) & 0xff; \ + ((uint8_t *)(b))[1] = ((v) >> 48) & 0xff; \ + ((uint8_t *)(b))[0] = ((v) >> 56) & 0xff; \ + 8; \ + }) + +#define tGet64b(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[0]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[1]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[2]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[3]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[4]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[5]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[6]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[7]; \ + 8; \ + }) + +#define tPut64l(b, v) \ + ({ \ + ((uint8_t *)(b))[0] = (v)&0xff; \ + ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ + ((uint8_t *)(b))[2] = ((v) >> 16) & 0xff; \ + ((uint8_t *)(b))[3] = ((v) >> 24) & 0xff; \ + ((uint8_t *)(b))[4] = ((v) >> 32) & 0xff; \ + ((uint8_t *)(b))[5] = ((v) >> 40) & 0xff; \ + ((uint8_t *)(b))[6] = ((v) >> 48) & 0xff; \ + ((uint8_t *)(b))[7] = ((v) >> 56) & 0xff; \ + 8; \ + }) + +#define tGet64l(b, v) \ + ({ \ + (v) = ((uint8_t *)(b))[7]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[6]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[5]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[4]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[3]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[2]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[1]; \ + (v) <<= 8; \ + (v) = ((uint8_t *)(b))[0]; \ + 8; \ + }) + +/* ------------------------ LEGACY CODES ------------------------ */ +#if 1 // ---- Fixed U8 static FORCE_INLINE int taosEncodeFixedU8(void **buf, uint8_t value) { if (buf != NULL) { @@ -368,6 +524,8 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) { return POINTER_SHIFT(buf, size); } +#endif + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/meta/src/metaBDBImpl.c b/source/dnode/vnode/meta/src/metaBDBImpl.c index 735d33ac15..dba6a7e403 100644 --- a/source/dnode/vnode/meta/src/metaBDBImpl.c +++ b/source/dnode/vnode/meta/src/metaBDBImpl.c @@ -403,10 +403,10 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) { buf = taosDecodeFixedU8(buf, &(pTbCfg->type)); if (pTbCfg->type == META_SUPER_TABLE) { - buf = taosDecodeVariantU32(buf, pTbCfg->stbCfg.nTagCols); + buf = taosDecodeVariantU32(buf, &(pTbCfg->stbCfg.nTagCols)); pTbCfg->stbCfg.pTagSchema = (SSchema *)malloc(sizeof(SSchema) * pTbCfg->stbCfg.nTagCols); for (uint32_t i = 0; i < pTbCfg->stbCfg.nTagCols; i++) { - buf = taosDecodeFixedI8(buf, &pTbCfg->stbCfg.pSchema[i].type); + buf = taosDecodeFixedI8(buf, &(pTbCfg->stbCfg.pSchema[i].type)); buf = taosDecodeFixedI32(buf, &pTbCfg->stbCfg.pSchema[i].colId); buf = taosDecodeFixedI32(buf, &pTbCfg->stbCfg.pSchema[i].bytes); buf = taosDecodeStringTo(buf, pTbCfg->stbCfg.pSchema[i].name); From 221c8254cfc14956207d071c3da2e0cf3215a957 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Dec 2021 17:17:07 +0800 Subject: [PATCH 02/55] more --- include/common/tmsg.h | 13 +- include/util/tcoding.h | 316 +++++++++++++++++++++++++---------------- 2 files changed, 202 insertions(+), 127 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 92b453bc1f..8bcf5c68cb 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1126,7 +1126,18 @@ typedef struct SVCreateTbReq { } SVCreateTbReq; static FORCE_INLINE int tSerializeSVCreateTbReq(void** buf, const SVCreateTbReq* pReq) { - int tlen = 0; + int tlen = 0; + uint8_t* pBuf = (uint8_t*)(*buf); + + if (TD_RT_ENDIAN() == TD_LITTLE_ENDIAN) { + pBuf += tPut(pBuf, pReq->ver, uint64_t); + pBuf += tPut(pBuf, pReq->ttl, uint32_t); + pBuf += tPut(pBuf, pReq->keep, uint32_t); + } else { + pBuf += tPutl(pBuf, pReq->ver, uint64_t); + pBuf += tPutl(pBuf, pReq->ttl, uint32_t); + pBuf += tPutl(pBuf, pReq->keep, uint32_t); + } tlen += taosEncodeFixedU64(buf, pReq->ver); tlen += taosEncodeString(buf, pReq->name); diff --git a/include/util/tcoding.h b/include/util/tcoding.h index 86812463b7..074a064201 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -26,159 +26,223 @@ extern "C" { #define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode /* ------------------------ FIXED-LENGTH ENCODING ------------------------ */ -#define tPut(T, b, v) \ - ({ \ - *(T *)(b) = (v); \ - sizeof(T); \ - }) - -#define tGet(T, b, v) \ - ({ \ - (v) = (*(T *)(b)); \ - sizeof(T); \ - }) - // 16 -#define tPut16b(b, v) \ - ({ \ - ((uint8_t *)(b))[1] = (v)&0xff; \ - ((uint8_t *)(b))[0] = ((v) >> 8) & 0xff; \ - 2; \ +#define tPut16b(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[1] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[0] = ((VAL) >> 8) & 0xff; \ + 2; \ }) -#define tGet16b(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[0]; \ - (v) = (v) << 8; \ - (v) |= ((uint8_t *)(b))[1]; \ - 2; \ +#define tGet16b(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[0]; \ + (VAL) = (VAL) << 8; \ + (VAL) |= ((uint8_t *)(BUF))[1]; \ + 2; \ }) -#define tPut16l(b, v) \ - ({ \ - ((uint8_t *)(b))[0] = (v)&0xff; \ - ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ - 2; \ +#define tPut16l(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ + 2; \ }) -#define tGet16l(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[1]; \ - (v) <<= 8; \ - (v) |= ((uint8_t *)(b))[0]; \ - 2; \ +#define tGet16l(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[1]; \ + (VAL) <<= 8; \ + (VAL) |= ((uint8_t *)(BUF))[0]; \ + 2; \ }) // 32 -#define tPut32b(b, v) \ - ({ \ - ((uint8_t *)(b))[3] = (v)&0xff; \ - ((uint8_t *)(b))[2] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(b))[1] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(b))[0] = ((v) >> 24) & 0xff; \ - 4; \ +#define tPut32b(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[3] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[2] = ((VAL) >> 8) & 0xff; \ + ((uint8_t *)(BUF))[1] = ((VAL) >> 16) & 0xff; \ + ((uint8_t *)(BUF))[0] = ((VAL) >> 24) & 0xff; \ + 4; \ }) -#define tGet32b(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[0]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[1]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[2]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[3]; \ - 4; \ +#define tGet32b(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[0]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[1]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[2]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[3]; \ + 4; \ }) -#define tPut32l(b, v) \ - ({ \ - ((uint8_t *)(b))[0] = (v)&0xff; \ - ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(b))[2] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(b))[3] = ((v) >> 24) & 0xff; \ - 4; \ +#define tPut32l(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ + ((uint8_t *)(BUF))[2] = ((VAL) >> 16) & 0xff; \ + ((uint8_t *)(BUF))[3] = ((VAL) >> 24) & 0xff; \ + 4; \ }) -#define tGet32l(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[3]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[2]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[1]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[0]; \ - 4; \ +#define tGet32l(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[3]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[2]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[1]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[0]; \ + 4; \ }) // 64 -#define tPut64b(b, v) \ - ({ \ - ((uint8_t *)(b))[7] = (v)&0xff; \ - ((uint8_t *)(b))[6] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(b))[5] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(b))[4] = ((v) >> 24) & 0xff; \ - ((uint8_t *)(b))[3] = ((v) >> 32) & 0xff; \ - ((uint8_t *)(b))[2] = ((v) >> 40) & 0xff; \ - ((uint8_t *)(b))[1] = ((v) >> 48) & 0xff; \ - ((uint8_t *)(b))[0] = ((v) >> 56) & 0xff; \ - 8; \ +#define tPut64b(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[7] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[6] = ((VAL) >> 8) & 0xff; \ + ((uint8_t *)(BUF))[5] = ((VAL) >> 16) & 0xff; \ + ((uint8_t *)(BUF))[4] = ((VAL) >> 24) & 0xff; \ + ((uint8_t *)(BUF))[3] = ((VAL) >> 32) & 0xff; \ + ((uint8_t *)(BUF))[2] = ((VAL) >> 40) & 0xff; \ + ((uint8_t *)(BUF))[1] = ((VAL) >> 48) & 0xff; \ + ((uint8_t *)(BUF))[0] = ((VAL) >> 56) & 0xff; \ + 8; \ }) -#define tGet64b(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[0]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[1]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[2]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[3]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[4]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[5]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[6]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[7]; \ - 8; \ +#define tGet64b(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[0]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[1]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[2]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[3]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[4]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[5]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[6]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[7]; \ + 8; \ }) -#define tPut64l(b, v) \ - ({ \ - ((uint8_t *)(b))[0] = (v)&0xff; \ - ((uint8_t *)(b))[1] = ((v) >> 8) & 0xff; \ - ((uint8_t *)(b))[2] = ((v) >> 16) & 0xff; \ - ((uint8_t *)(b))[3] = ((v) >> 24) & 0xff; \ - ((uint8_t *)(b))[4] = ((v) >> 32) & 0xff; \ - ((uint8_t *)(b))[5] = ((v) >> 40) & 0xff; \ - ((uint8_t *)(b))[6] = ((v) >> 48) & 0xff; \ - ((uint8_t *)(b))[7] = ((v) >> 56) & 0xff; \ - 8; \ +#define tPut64l(BUF, VAL) \ + ({ \ + ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ + ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ + ((uint8_t *)(BUF))[2] = ((VAL) >> 16) & 0xff; \ + ((uint8_t *)(BUF))[3] = ((VAL) >> 24) & 0xff; \ + ((uint8_t *)(BUF))[4] = ((VAL) >> 32) & 0xff; \ + ((uint8_t *)(BUF))[5] = ((VAL) >> 40) & 0xff; \ + ((uint8_t *)(BUF))[6] = ((VAL) >> 48) & 0xff; \ + ((uint8_t *)(BUF))[7] = ((VAL) >> 56) & 0xff; \ + 8; \ }) -#define tGet64l(b, v) \ - ({ \ - (v) = ((uint8_t *)(b))[7]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[6]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[5]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[4]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[3]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[2]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[1]; \ - (v) <<= 8; \ - (v) = ((uint8_t *)(b))[0]; \ - 8; \ +#define tGet64l(BUF, VAL) \ + ({ \ + (VAL) = ((uint8_t *)(BUF))[7]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[6]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[5]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[4]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[3]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[2]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[1]; \ + (VAL) <<= 8; \ + (VAL) = ((uint8_t *)(BUF))[0]; \ + 8; \ }) +#define tPut(BUF, VAL, TYPE) \ + ({ \ + *(TYPE *)(BUF) = (VAL); \ + sizeof(TYPE); \ + }) + +#define tGet(BUF, VAL, TYPE) \ + ({ \ + (VAL) = (*(TYPE *)(BUF)); \ + sizeof(TYPE); \ + }) + +#define tPut_uint16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) +#define tGet_uint16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL) +#define tPut_int16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) +#define tGet_int16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL) + +#define tPut_uint32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL) +#define tGet_uint32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL) +#define tPut_int32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL) +#define tGet_int32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL) + +#define tPut_uint64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL) +#define tGet_uint64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL) +#define tPut_int64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL) +#define tGet_int64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL) + +#define tPut_uint16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) +#define tGet_uint16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL) +#define tPut_int16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) +#define tGet_int16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL) + +#define tPut_uint32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL) +#define tGet_uint32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL) +#define tPut_int32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL) +#define tGet_int32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL) + +#define tPut_uint64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL) +#define tGet_uint64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL) +#define tPut_int64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL) +#define tGet_int64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL) + +#define tPutl(BUF, VAL, TYPE) tPut_##TYPE##_l(BUF, VAL, TYPE) + +#define tGetl(BUF, VAL, TYPE) tGet_##TYPE##_l(BUF, VAL, TYPE) + +#define tPutb(BUF, VAL, TYPE) tPut_##TYPE##_b(BUF, VAL, TYPE) + +#define tGetb(BUF, VAL, TYPE) tGet_##TYPE##_b(BUF, VAL, TYPE) + +/* ------------------------ VARIANT-LENGTH ENCODING ------------------------ */ +#define vPutU(BUF, VAL) \ + ({ \ + uint64_t tmp = (VAL); \ + int i = 0; \ + while ((VAL) >= ENCODE_LIMIT) { \ + ((uint8_t *)(BUF))[i] = (uint8_t)((tmp) | ENCODE_LIMIT); \ + (tmp) >>= 7; \ + i++; \ + } \ + ((uint8_t *)(BUF))[i] = (uint8_t)(tmp); \ + i + 1; \ + }) + +#define vGetU(BUF, VAL) + +#define vPutI(BUF, VAL, TYPE) \ + ({ \ + uint64_t tmp = ZIGZAGE(TYPE, VAL); \ + vPutU(BUF, tmp); \ + }) + +#define vGetI(BUF, VAL, TYPE) + +/* ------------------------ OTHER TYPE ENCODING ------------------------ */ + /* ------------------------ LEGACY CODES ------------------------ */ #if 1 // ---- Fixed U8 From b898fc0e1ce6cda0755fba71f0e9bbea21154e1a Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Dec 2021 18:03:26 +0800 Subject: [PATCH 03/55] more --- include/common/tmsg.h | 20 ++++++++++---------- include/util/tcoding.h | 31 +++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 8bcf5c68cb..6961b73e86 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1127,17 +1127,17 @@ typedef struct SVCreateTbReq { static FORCE_INLINE int tSerializeSVCreateTbReq(void** buf, const SVCreateTbReq* pReq) { int tlen = 0; - uint8_t* pBuf = (uint8_t*)(*buf); + // uint8_t* pBuf = (uint8_t*)(*buf); - if (TD_RT_ENDIAN() == TD_LITTLE_ENDIAN) { - pBuf += tPut(pBuf, pReq->ver, uint64_t); - pBuf += tPut(pBuf, pReq->ttl, uint32_t); - pBuf += tPut(pBuf, pReq->keep, uint32_t); - } else { - pBuf += tPutl(pBuf, pReq->ver, uint64_t); - pBuf += tPutl(pBuf, pReq->ttl, uint32_t); - pBuf += tPutl(pBuf, pReq->keep, uint32_t); - } + // if (TD_RT_ENDIAN() == TD_LITTLE_ENDIAN) { + // pBuf += tPut(pBuf, pReq->ver, uint64_t); + // pBuf += tPut(pBuf, pReq->ttl, uint32_t); + // pBuf += tPut(pBuf, pReq->keep, uint32_t); + // } else { + // pBuf += tPutl(pBuf, pReq->ver, uint64_t); + // pBuf += tPutl(pBuf, pReq->ttl, uint32_t); + // pBuf += tPutl(pBuf, pReq->keep, uint32_t); + // } tlen += taosEncodeFixedU64(buf, pReq->ver); tlen += taosEncodeString(buf, pReq->name); diff --git a/include/util/tcoding.h b/include/util/tcoding.h index 074a064201..ae5ae15b07 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -218,9 +218,9 @@ extern "C" { #define tGetb(BUF, VAL, TYPE) tGet_##TYPE##_b(BUF, VAL, TYPE) /* ------------------------ VARIANT-LENGTH ENCODING ------------------------ */ -#define vPutU(BUF, VAL) \ +#define vPut(BUF, VAL, SIGN) \ ({ \ - uint64_t tmp = (VAL); \ + uint64_t tmp = (SIGN) ? ZIGZAGE(int64_t, VAL) : (VAL); \ int i = 0; \ while ((VAL) >= ENCODE_LIMIT) { \ ((uint8_t *)(BUF))[i] = (uint8_t)((tmp) | ENCODE_LIMIT); \ @@ -231,16 +231,27 @@ extern "C" { i + 1; \ }) -#define vGetU(BUF, VAL) - -#define vPutI(BUF, VAL, TYPE) \ - ({ \ - uint64_t tmp = ZIGZAGE(TYPE, VAL); \ - vPutU(BUF, tmp); \ +#define vGet(BUF, VAL, SIGN) \ + ({ \ + uint64_t tmp; \ + uint64_t tval = 0; \ + int i = 0; \ + while (true) { \ + tmp = (uint64_t)(((uint8_t *)(BUF))[i]); \ + if (tmp < ENCODE_LIMIT) { \ + tval |= (tval << (7 * i)); \ + break; \ + } else { \ + tval |= ((tval & (ENCODE_LIMIT - 1)) << (7 * i)); \ + i++; \ + } \ + } \ + if (SIGN) { \ + (VAL) = ZIGZAGD(int64_t, tmp); \ + } \ + i; \ }) -#define vGetI(BUF, VAL, TYPE) - /* ------------------------ OTHER TYPE ENCODING ------------------------ */ /* ------------------------ LEGACY CODES ------------------------ */ From d5539259b6dd831e45e7b18719394c36e67892b8 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 27 Dec 2021 18:13:40 +0800 Subject: [PATCH 04/55] more --- include/util/tcoding.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/util/tcoding.h b/include/util/tcoding.h index ae5ae15b07..a227b9415a 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -248,6 +248,8 @@ extern "C" { } \ if (SIGN) { \ (VAL) = ZIGZAGD(int64_t, tmp); \ + } else { \ + (VAL) = tmp; \ } \ i; \ }) From 29e4a61baae6204cbb0b47002d1dbe7a6b1214f7 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 09:48:12 +0800 Subject: [PATCH 05/55] more --- include/util/tcoding.h | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/util/tcoding.h b/include/util/tcoding.h index a227b9415a..001e5fcb8d 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -179,6 +179,11 @@ extern "C" { sizeof(TYPE); \ }) +#define tPut_uint8_t_l(BUF, VAL, TYPE) tPut(BUF, VAL, TYPE) +#define tGet_uint8_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) +#define tPut_int8_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL, TYPE) +#define tGet_int8_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) + #define tPut_uint16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) #define tGet_uint16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL) #define tPut_int16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) @@ -194,6 +199,11 @@ extern "C" { #define tPut_int64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL) #define tGet_int64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL) +#define tPut_uint8_t_b(BUF, VAL, TYPE) tPut(BUF, VAL, TYPE) +#define tGet_uint8_t_b(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) +#define tPut_int8_t_b(BUF, VAL, TYPE) tPut16l(BUF, VAL, TYPE) +#define tGet_int8_t_b(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) + #define tPut_uint16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) #define tGet_uint16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL) #define tPut_int16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) @@ -217,6 +227,41 @@ extern "C" { #define tGetb(BUF, VAL, TYPE) tGet_##TYPE##_b(BUF, VAL, TYPE) +#define tPutVal(BUF, VAL, TYPE, ENDIAN) \ + ({ \ + int len; \ + if (TD_RT_ENDIAN() == (ENDIAN)) { \ + len = tPut(BUF, VAL, TYPE); \ + } else { \ + if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ + len = tPutl(BUF, VAL, TYPE); \ + } else if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ + len = tPutb(BUF, VAL, TYPE); \ + } else { \ + ASSERT(0); \ + } \ + } \ + if (BUF) BUF = BUF + len; \ + len; \ + }) + +#define tGetVal(BUF, VAL, TYPE, ENDIAN) \ + ({ \ + int len; \ + if (TD_RT_ENDIAN() == (ENDIAN)) { \ + len = tGet(BUF, VAL, TYPE); \ + } else { \ + if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ + len = tGetl(BUF, VAL, TYPE); \ + } else if ((ENDIAN) == TD_BIG_ENDIAN) { \ + len = tGetb(BUF, VAL, TYPE); \ + } else { \ + } \ + } \ + BUF = BUF + len; \ + len; \ + }) + /* ------------------------ VARIANT-LENGTH ENCODING ------------------------ */ #define vPut(BUF, VAL, SIGN) \ ({ \ From fd9feb1ac5afcf4edbd74df518f58ddfdb81d72f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 13:35:21 +0800 Subject: [PATCH 06/55] more --- contrib/test/tdev/src/main.c | 31 ++++++++++++++++++++---- include/common/tmsg.h | 14 +++++------ source/dnode/vnode/impl/src/vnodeQuery.c | 12 +++++---- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/contrib/test/tdev/src/main.c b/contrib/test/tdev/src/main.c index baae604992..5e1de83e88 100644 --- a/contrib/test/tdev/src/main.c +++ b/contrib/test/tdev/src/main.c @@ -25,10 +25,13 @@ POINTER_SHIFT(buf, sizeof(val)); \ }) -#define tPutC(buf, val) \ - ({ \ - ((uint64_t *)buf)[0] = (val); \ - POINTER_SHIFT(buf, sizeof(val)); \ +#define tPutC(buf, val) \ + ({ \ + if (buf) { \ + ((uint64_t *)buf)[0] = (val); \ + POINTER_SHIFT(buf, sizeof(val)); \ + } \ + NULL; \ }) #define tPutD(buf, val) \ @@ -41,7 +44,14 @@ POINTER_SHIFT(buf, sizeof(val)); \ }) -typedef enum { A, B, C, D } T; +static inline void tPutE(void **buf, uint64_t val) { + if (buf) { + ((uint64_t *)(*buf))[0] = val; + *buf = POINTER_SHIFT(*buf, sizeof(val)); + } +} + +typedef enum { A, B, C, D, E } T; static void func(T t) { uint64_t val = 198; @@ -81,6 +91,14 @@ static void func(T t) { } } break; + case E: + for (size_t i = 0; i < 10 * 1024l * 1024l * 1024l; i++) { + tPutE(&pBuf, val); + if (POINTER_DISTANCE(buf, pBuf) == 1024) { + pBuf = buf; + } + } + break; default: break; @@ -108,5 +126,8 @@ int main(int argc, char const *argv[]) { func(D); uint64_t t5 = now(); printf("D: %ld\n", t5 - t4); + func(E); + uint64_t t6 = now(); + printf("E: %ld\n", t6 - t5); return 0; } diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5d2b699ea9..775011ad40 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -319,12 +319,12 @@ typedef struct SEpSet { } SEpSet; typedef struct { - int32_t acctId; - int64_t clusterId; - int32_t connId; - int8_t superUser; - int8_t reserved[5]; - SEpSet epSet; + int32_t acctId; + int64_t clusterId; + int32_t connId; + int8_t superUser; + int8_t reserved[5]; + SEpSet epSet; } SConnectRsp; typedef struct { @@ -1129,7 +1129,7 @@ typedef struct SVCreateTbReq { } SVCreateTbReq; static FORCE_INLINE int tSerializeSVCreateTbReq(void** buf, const SVCreateTbReq* pReq) { - int tlen = 0; + int tlen = 0; // uint8_t* pBuf = (uint8_t*)(*buf); // if (TD_RT_ENDIAN() == TD_LITTLE_ENDIAN) { diff --git a/source/dnode/vnode/impl/src/vnodeQuery.c b/source/dnode/vnode/impl/src/vnodeQuery.c index 31481bf7c4..85a2de9dfa 100644 --- a/source/dnode/vnode/impl/src/vnodeQuery.c +++ b/source/dnode/vnode/impl/src/vnodeQuery.c @@ -13,12 +13,10 @@ * along with this program. If not, see . */ -#include "vnodeDef.h" #include "vnodeQuery.h" +#include "vnodeDef.h" -int vnodeQueryOpen(SVnode *pVnode) { - return qWorkerInit(NULL, &pVnode->pQuery); -} +int vnodeQueryOpen(SVnode *pVnode) { return qWorkerInit(NULL, &pVnode->pQuery); } int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { vInfo("query message is processed"); @@ -32,4 +30,8 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { return 0; } - +static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { + STableInfoMsg *pReq = (STableInfoMsg *)(pMsg->pCont); + // TODO + return 0; +} \ No newline at end of file From 8f9329eaca2a15983d059bb64d99fc6977d40df1 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 13:42:07 +0800 Subject: [PATCH 07/55] refact --- include/dnode/vnode/meta/meta.h | 25 ------------ source/dnode/vnode/meta/src/metaTbCfg.c | 54 ------------------------- 2 files changed, 79 deletions(-) diff --git a/include/dnode/vnode/meta/meta.h b/include/dnode/vnode/meta/meta.h index d9f5a3ff09..fd6a6b7a40 100644 --- a/include/dnode/vnode/meta/meta.h +++ b/include/dnode/vnode/meta/meta.h @@ -51,31 +51,6 @@ int metaCommit(SMeta *pMeta); void metaOptionsInit(SMetaCfg *pMetaCfg); void metaOptionsClear(SMetaCfg *pMetaCfg); -// STbCfg -#define META_INIT_STB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA, PTAGSCHEMA) \ - { \ - .name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_SUPER_TABLE, .stbCfg = { \ - .suid = (SUID), \ - .pSchema = (PSCHEMA), \ - .pTagSchema = (PTAGSCHEMA) \ - } \ - } - -#define META_INIT_CTB_CFG(NAME, TTL, KEEP, SUID, PTAG) \ - { \ - .name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_CHILD_TABLE, .ctbCfg = {.suid = (SUID), .pTag = PTAG } \ - } - -#define META_INIT_NTB_CFG(NAME, TTL, KEEP, SUID, PSCHEMA) \ - { \ - .name = (NAME), .ttl = (TTL), .keep = (KEEP), .type = META_NORMAL_TABLE, .ntbCfg = {.pSchema = (PSCHEMA) } \ - } - -#define META_CLEAR_TB_CFG(pTbCfg) - -int metaEncodeTbCfg(void **pBuf, STbCfg *pTbCfg); -void *metaDecodeTbCfg(void *pBuf, STbCfg *pTbCfg); - #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/meta/src/metaTbCfg.c b/source/dnode/vnode/meta/src/metaTbCfg.c index 6f8a537966..4e02b64ce0 100644 --- a/source/dnode/vnode/meta/src/metaTbCfg.c +++ b/source/dnode/vnode/meta/src/metaTbCfg.c @@ -46,58 +46,4 @@ size_t metaEncodeTbObjFromTbOptions(const STbCfg *pTbOptions, void *pBuf, size_t } return tlen; -} - -int metaEncodeTbCfg(void **pBuf, STbCfg *pTbCfg) { - int tsize = 0; - - tsize += taosEncodeString(pBuf, pTbCfg->name); - tsize += taosEncodeFixedU32(pBuf, pTbCfg->ttl); - tsize += taosEncodeFixedU32(pBuf, pTbCfg->keep); - tsize += taosEncodeFixedU8(pBuf, pTbCfg->type); - - switch (pTbCfg->type) { - case META_SUPER_TABLE: - tsize += taosEncodeFixedU64(pBuf, pTbCfg->stbCfg.suid); - tsize += tdEncodeSchema(pBuf, pTbCfg->stbCfg.pSchema); - tsize += tdEncodeSchema(pBuf, pTbCfg->stbCfg.pTagSchema); - break; - case META_CHILD_TABLE: - tsize += taosEncodeFixedU64(pBuf, pTbCfg->ctbCfg.suid); - tsize += tdEncodeKVRow(pBuf, pTbCfg->ctbCfg.pTag); - break; - case META_NORMAL_TABLE: - tsize += tdEncodeSchema(pBuf, pTbCfg->ntbCfg.pSchema); - break; - default: - break; - } - - return tsize; -} - -void *metaDecodeTbCfg(void *pBuf, STbCfg *pTbCfg) { - pBuf = taosDecodeString(pBuf, &(pTbCfg->name)); - pBuf = taosDecodeFixedU32(pBuf, &(pTbCfg->ttl)); - pBuf = taosDecodeFixedU32(pBuf, &(pTbCfg->keep)); - pBuf = taosDecodeFixedU8(pBuf, &(pTbCfg->type)); - - switch (pTbCfg->type) { - case META_SUPER_TABLE: - pBuf = taosDecodeFixedU64(pBuf, &(pTbCfg->stbCfg.suid)); - pBuf = tdDecodeSchema(pBuf, &(pTbCfg->stbCfg.pSchema)); - pBuf = tdDecodeSchema(pBuf, &(pTbCfg->stbCfg.pTagSchema)); - break; - case META_CHILD_TABLE: - pBuf = taosDecodeFixedU64(pBuf, &(pTbCfg->ctbCfg.suid)); - pBuf = tdDecodeKVRow(pBuf, &(pTbCfg->ctbCfg.pTag)); - break; - case META_NORMAL_TABLE: - pBuf = tdDecodeSchema(pBuf, &(pTbCfg->ntbCfg.pSchema)); - break; - default: - break; - } - - return pBuf; } \ No newline at end of file From 483809b3e8eee76e8a2aeefc85023582fbdc3c85 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 13:58:53 +0800 Subject: [PATCH 08/55] more --- include/dnode/vnode/meta/meta.h | 5 ++++- include/util/tmacro.h | 2 ++ source/dnode/vnode/impl/src/vnodeQuery.c | 16 ++++++++++++++++ source/dnode/vnode/meta/src/metaBDBImpl.c | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/dnode/vnode/meta/meta.h b/include/dnode/vnode/meta/meta.h index fd6a6b7a40..067682af1a 100644 --- a/include/dnode/vnode/meta/meta.h +++ b/include/dnode/vnode/meta/meta.h @@ -18,8 +18,8 @@ #include "mallocator.h" #include "os.h" -#include "trow.h" #include "tmsg.h" +#include "trow.h" #ifdef __cplusplus extern "C" { @@ -47,6 +47,9 @@ int metaCreateTable(SMeta *pMeta, STbCfg *pTbCfg); int metaDropTable(SMeta *pMeta, tb_uid_t uid); int metaCommit(SMeta *pMeta); +// For Query +int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg); + // Options void metaOptionsInit(SMetaCfg *pMetaCfg); void metaOptionsClear(SMetaCfg *pMetaCfg); diff --git a/include/util/tmacro.h b/include/util/tmacro.h index 5cca8a1062..5ed051c021 100644 --- a/include/util/tmacro.h +++ b/include/util/tmacro.h @@ -35,6 +35,8 @@ typedef int8_t td_mode_flag_t; #define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNCLEARD, TD_MOD_CLEARD) +#define TD_IS_NULL(PTR) ((PTR) == NULL) + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/impl/src/vnodeQuery.c b/source/dnode/vnode/impl/src/vnodeQuery.c index 85a2de9dfa..4f6bcfce6b 100644 --- a/source/dnode/vnode/impl/src/vnodeQuery.c +++ b/source/dnode/vnode/impl/src/vnodeQuery.c @@ -32,6 +32,22 @@ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { STableInfoMsg *pReq = (STableInfoMsg *)(pMsg->pCont); + STableMetaMsg *pRspMsg; + int ret; + + if (metaGetTableInfo(pVnode->pMeta, pReq->tableFname, &pRspMsg) < 0) { + return -1; + } + + *pRsp = malloc(sizeof(SRpcMsg)); + if (TD_IS_NULL(*pRsp)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + free(pMsg); + return -1; + } + // TODO + (*pRsp)->pCont = pRspMsg; + return 0; } \ No newline at end of file diff --git a/source/dnode/vnode/meta/src/metaBDBImpl.c b/source/dnode/vnode/meta/src/metaBDBImpl.c index dba6a7e403..e2137ebbdf 100644 --- a/source/dnode/vnode/meta/src/metaBDBImpl.c +++ b/source/dnode/vnode/meta/src/metaBDBImpl.c @@ -428,4 +428,20 @@ static void metaClearTbCfg(STbCfg *pTbCfg) { } else if (pTbCfg->type == META_CHILD_TABLE) { tfree(pTbCfg->ctbCfg.pTag); } +} + +/* ------------------------ FOR QUERY ------------------------ */ +int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg) { + DBT key = {0}; + DBT value = {0}; + SMetaDB *pMetaDB = pMeta->pDB; + + key.data = tbname; + key.size = strlen(tbname) + 1; + + pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0); + + // TODO: construct the message body + + return 0; } \ No newline at end of file From 7c56458122933a211e9f4842e0ba9f21fa694611 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 14:04:24 +0800 Subject: [PATCH 09/55] refact --- include/dnode/vnode/vnode.h | 62 ------------------------------------- 1 file changed, 62 deletions(-) diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 812f313e71..b5d0c11cf4 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -187,68 +187,6 @@ void vnodeOptionsInit(SVnodeCfg *pOptions); */ void vnodeOptionsClear(SVnodeCfg *pOptions); -/* ------------------------ REQUESTS ------------------------ */ -typedef STbCfg SVCreateTableReq; -typedef struct { - tb_uid_t uid; -} SVDropTableReq; - -typedef struct { - // TODO -} SVSubmitReq; - -typedef struct { - uint64_t ver; - union { - SVCreateTableReq ctReq; - SVDropTableReq dtReq; - }; -} SVnodeReq; - -typedef struct { - int err; - char info[]; -} SVnodeRsp; - -static FORCE_INLINE void vnodeSetCreateStbReq(SVnodeReq *pReq, char *name, uint32_t ttl, uint32_t keep, tb_uid_t suid, - STSchema *pSchema, STSchema *pTagSchema) { - pReq->ver = 0; - - pReq->ctReq.name = name; - pReq->ctReq.ttl = ttl; - pReq->ctReq.keep = keep; - pReq->ctReq.type = META_SUPER_TABLE; - pReq->ctReq.stbCfg.suid = suid; - pReq->ctReq.stbCfg.pSchema = pSchema; - pReq->ctReq.stbCfg.pTagSchema = pTagSchema; -} - -static FORCE_INLINE void vnodeSetCreateCtbReq(SVnodeReq *pReq, char *name, uint32_t ttl, uint32_t keep, tb_uid_t suid, - SKVRow pTag) { - pReq->ver = 0; - - pReq->ctReq.name = name; - pReq->ctReq.ttl = ttl; - pReq->ctReq.keep = keep; - pReq->ctReq.type = META_CHILD_TABLE; - pReq->ctReq.ctbCfg.suid = suid; - pReq->ctReq.ctbCfg.pTag = pTag; -} - -static FORCE_INLINE void vnodeSetCreateNtbReq(SVnodeReq *pReq, char *name, uint32_t ttl, uint32_t keep, - STSchema *pSchema) { - pReq->ver = 0; - - pReq->ctReq.name = name; - pReq->ctReq.ttl = ttl; - pReq->ctReq.keep = keep; - pReq->ctReq.type = META_NORMAL_TABLE; - pReq->ctReq.ntbCfg.pSchema = pSchema; -} - -int vnodeBuildReq(void **buf, const SVnodeReq *pReq, tmsg_t type); -void *vnodeParseReq(void *buf, SVnodeReq *pReq, tmsg_t type); - /* ------------------------ FOR COMPILE ------------------------ */ int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg); From 3311fec1b3fa050c6d0cc7531669c1fb84847dd2 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 14:23:45 +0800 Subject: [PATCH 10/55] refact --- include/util/tbuffer.h | 126 ++++++------- source/util/src/tbuffer.c | 368 ++++++++++++++++++-------------------- 2 files changed, 238 insertions(+), 256 deletions(-) diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h index d1d403e996..009d7bf23b 100644 --- a/include/util/tbuffer.h +++ b/include/util/tbuffer.h @@ -71,102 +71,102 @@ int main( int argc, char** argv ) { */ typedef struct SBufferReader { - bool endian; + bool endian; const char* data; - size_t pos; - size_t size; + size_t pos; + size_t size; } SBufferReader; typedef struct SBufferWriter { - bool endian; - char* data; + bool endian; + char* data; size_t pos; size_t size; - void* (*allocator)( void*, size_t ); + void* (*allocator)(void*, size_t); } SBufferWriter; //////////////////////////////////////////////////////////////////////////////// // common functions & macros for both reader & writer -#define tbufTell( buf ) ((buf)->pos) - +#define tbufTell(buf) ((buf)->pos) //////////////////////////////////////////////////////////////////////////////// // reader functions & macros // *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically -#define tbufInitReader( Data, Size, Endian ) {.endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 :(Size))} +#define tbufInitReader(Data, Size, Endian) \ + { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } -size_t tbufSkip( SBufferReader* buf, size_t size ); +size_t tbufSkip(SBufferReader* buf, size_t size); -const char* tbufRead( SBufferReader* buf, size_t size ); -void tbufReadToBuffer( SBufferReader* buf, void* dst, size_t size ); -const char* tbufReadString( SBufferReader* buf, size_t* len ); -size_t tbufReadToString( SBufferReader* buf, char* dst, size_t size ); -const char* tbufReadBinary( SBufferReader* buf, size_t *len ); -size_t tbufReadToBinary( SBufferReader* buf, void* dst, size_t size ); - -bool tbufReadBool( SBufferReader* buf ); -char tbufReadChar( SBufferReader* buf ); -int8_t tbufReadInt8( SBufferReader* buf ); -uint8_t tbufReadUint8( SBufferReader* buf ); -int16_t tbufReadInt16( SBufferReader* buf ); -uint16_t tbufReadUint16( SBufferReader* buf ); -int32_t tbufReadInt32( SBufferReader* buf ); -uint32_t tbufReadUint32( SBufferReader* buf ); -int64_t tbufReadInt64( SBufferReader* buf ); -uint64_t tbufReadUint64( SBufferReader* buf ); -float tbufReadFloat( SBufferReader* buf ); -double tbufReadDouble( SBufferReader* buf ); +const char* tbufRead(SBufferReader* buf, size_t size); +void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); +const char* tbufReadString(SBufferReader* buf, size_t* len); +size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); +const char* tbufReadBinary(SBufferReader* buf, size_t* len); +size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); +bool tbufReadBool(SBufferReader* buf); +char tbufReadChar(SBufferReader* buf); +int8_t tbufReadInt8(SBufferReader* buf); +uint8_t tbufReadUint8(SBufferReader* buf); +int16_t tbufReadInt16(SBufferReader* buf); +uint16_t tbufReadUint16(SBufferReader* buf); +int32_t tbufReadInt32(SBufferReader* buf); +uint32_t tbufReadUint32(SBufferReader* buf); +int64_t tbufReadInt64(SBufferReader* buf); +uint64_t tbufReadUint64(SBufferReader* buf); +float tbufReadFloat(SBufferReader* buf); +double tbufReadDouble(SBufferReader* buf); //////////////////////////////////////////////////////////////////////////////// // writer functions & macros // *Allocator*, function to allocate memory, will use 'realloc' if NULL // *Endian*, if true, writer functions of primitive types will do 'hton' automatically -#define tbufInitWriter( Allocator, Endian ) {.endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator))} -void tbufCloseWriter( SBufferWriter* buf ); +#define tbufInitWriter(Allocator, Endian) \ + { .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) } +void tbufCloseWriter(SBufferWriter* buf); -void tbufEnsureCapacity( SBufferWriter* buf, size_t size ); -size_t tbufReserve( SBufferWriter* buf, size_t size ); -char* tbufGetData( SBufferWriter* buf, bool takeOver ); +void tbufEnsureCapacity(SBufferWriter* buf, size_t size); +size_t tbufReserve(SBufferWriter* buf, size_t size); +char* tbufGetData(SBufferWriter* buf, bool takeOver); -void tbufWrite( SBufferWriter* buf, const void* data, size_t size ); -void tbufWriteAt( SBufferWriter* buf, size_t pos, const void* data, size_t size ); -void tbufWriteStringLen( SBufferWriter* buf, const char* str, size_t len ); -void tbufWriteString( SBufferWriter* buf, const char* str ); +void tbufWrite(SBufferWriter* buf, const void* data, size_t size); +void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); +void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); +void tbufWriteString(SBufferWriter* buf, const char* str); // the prototype of tbufWriteBinary and tbufWrite are identical // the difference is: tbufWriteBinary writes the length of the data to the buffer // first, then the actual data, which means the reader don't need to know data // size before read. Write only write the data itself, which means the reader // need to know data size before read. -void tbufWriteBinary( SBufferWriter* buf, const void* data, size_t len ); +void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len); -void tbufWriteBool( SBufferWriter* buf, bool data ); -void tbufWriteBoolAt( SBufferWriter* buf, size_t pos, bool data ); -void tbufWriteChar( SBufferWriter* buf, char data ); -void tbufWriteCharAt( SBufferWriter* buf, size_t pos, char data ); -void tbufWriteInt8( SBufferWriter* buf, int8_t data ); -void tbufWriteInt8At( SBufferWriter* buf, size_t pos, int8_t data ); -void tbufWriteUint8( SBufferWriter* buf, uint8_t data ); -void tbufWriteUint8At( SBufferWriter* buf, size_t pos, uint8_t data ); -void tbufWriteInt16( SBufferWriter* buf, int16_t data ); -void tbufWriteInt16At( SBufferWriter* buf, size_t pos, int16_t data ); -void tbufWriteUint16( SBufferWriter* buf, uint16_t data ); -void tbufWriteUint16At( SBufferWriter* buf, size_t pos, uint16_t data ); -void tbufWriteInt32( SBufferWriter* buf, int32_t data ); -void tbufWriteInt32At( SBufferWriter* buf, size_t pos, int32_t data ); -void tbufWriteUint32( SBufferWriter* buf, uint32_t data ); -void tbufWriteUint32At( SBufferWriter* buf, size_t pos, uint32_t data ); -void tbufWriteInt64( SBufferWriter* buf, int64_t data ); -void tbufWriteInt64At( SBufferWriter* buf, size_t pos, int64_t data ); -void tbufWriteUint64( SBufferWriter* buf, uint64_t data ); -void tbufWriteUint64At( SBufferWriter* buf, size_t pos, uint64_t data ); -void tbufWriteFloat( SBufferWriter* buf, float data ); -void tbufWriteFloatAt( SBufferWriter* buf, size_t pos, float data ); -void tbufWriteDouble( SBufferWriter* buf, double data ); -void tbufWriteDoubleAt( SBufferWriter* buf, size_t pos, double data ); +void tbufWriteBool(SBufferWriter* buf, bool data); +void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data); +void tbufWriteChar(SBufferWriter* buf, char data); +void tbufWriteCharAt(SBufferWriter* buf, size_t pos, char data); +void tbufWriteInt8(SBufferWriter* buf, int8_t data); +void tbufWriteInt8At(SBufferWriter* buf, size_t pos, int8_t data); +void tbufWriteUint8(SBufferWriter* buf, uint8_t data); +void tbufWriteUint8At(SBufferWriter* buf, size_t pos, uint8_t data); +void tbufWriteInt16(SBufferWriter* buf, int16_t data); +void tbufWriteInt16At(SBufferWriter* buf, size_t pos, int16_t data); +void tbufWriteUint16(SBufferWriter* buf, uint16_t data); +void tbufWriteUint16At(SBufferWriter* buf, size_t pos, uint16_t data); +void tbufWriteInt32(SBufferWriter* buf, int32_t data); +void tbufWriteInt32At(SBufferWriter* buf, size_t pos, int32_t data); +void tbufWriteUint32(SBufferWriter* buf, uint32_t data); +void tbufWriteUint32At(SBufferWriter* buf, size_t pos, uint32_t data); +void tbufWriteInt64(SBufferWriter* buf, int64_t data); +void tbufWriteInt64At(SBufferWriter* buf, size_t pos, int64_t data); +void tbufWriteUint64(SBufferWriter* buf, uint64_t data); +void tbufWriteUint64At(SBufferWriter* buf, size_t pos, uint64_t data); +void tbufWriteFloat(SBufferWriter* buf, float data); +void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data); +void tbufWriteDouble(SBufferWriter* buf, double data); +void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data); #ifdef __cplusplus } diff --git a/source/util/src/tbuffer.c b/source/util/src/tbuffer.c index 7c1eeaaf4f..ddd283ae0f 100644 --- a/source/util/src/tbuffer.c +++ b/source/util/src/tbuffer.c @@ -13,14 +13,14 @@ * along with this program. If not, see . */ -#include "os.h" #include "tbuffer.h" #include "exception.h" +#include "os.h" //#include "taoserror.h" typedef union Un4B { uint32_t ui; - float f; + float f; } Un4B; #if __STDC_VERSION__ >= 201112L static_assert(sizeof(Un4B) == sizeof(uint32_t), "sizeof(Un4B) must equal to sizeof(uint32_t)"); @@ -29,7 +29,7 @@ static_assert(sizeof(Un4B) == sizeof(float), "sizeof(Un4B) must equal to sizeof( typedef union Un8B { uint64_t ull; - double d; + double d; } Un8B; #if __STDC_VERSION__ >= 201112L static_assert(sizeof(Un8B) == sizeof(uint64_t), "sizeof(Un8B) must equal to sizeof(uint64_t)"); @@ -40,172 +40,172 @@ static_assert(sizeof(Un8B) == sizeof(double), "sizeof(Un8B) must equal to sizeof // reader functions size_t tbufSkip(SBufferReader* buf, size_t size) { - if( (buf->pos + size) > buf->size ) { - THROW( -1 ); + if ((buf->pos + size) > buf->size) { + THROW(-1); } size_t old = buf->pos; buf->pos += size; return old; } -const char* tbufRead( SBufferReader* buf, size_t size ) { +const char* tbufRead(SBufferReader* buf, size_t size) { const char* ret = buf->data + buf->pos; - tbufSkip( buf, size ); + tbufSkip(buf, size); return ret; } -void tbufReadToBuffer( SBufferReader* buf, void* dst, size_t size ) { - assert( dst != NULL ); +void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size) { + assert(dst != NULL); // always using memcpy, leave optimization to compiler - memcpy( dst, tbufRead(buf, size), size ); + memcpy(dst, tbufRead(buf, size), size); } -static size_t tbufReadLength( SBufferReader* buf ) { +static size_t tbufReadLength(SBufferReader* buf) { // maximum length is 65535, if larger length is required // this function and the corresponding write function need to be // revised. - uint16_t l = tbufReadUint16( buf ); + uint16_t l = tbufReadUint16(buf); return l; } -const char* tbufReadString( SBufferReader* buf, size_t* len ) { - size_t l = tbufReadLength( buf ); +const char* tbufReadString(SBufferReader* buf, size_t* len) { + size_t l = tbufReadLength(buf); const char* ret = buf->data + buf->pos; - tbufSkip( buf, l + 1 ); - if( ret[l] != 0 ) { - THROW( -1 ); + tbufSkip(buf, l + 1); + if (ret[l] != 0) { + THROW(-1); } - if( len != NULL ) { + if (len != NULL) { *len = l; } return ret; } -size_t tbufReadToString( SBufferReader* buf, char* dst, size_t size ) { - assert( dst != NULL ); - size_t len; - const char* str = tbufReadString( buf, &len ); +size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size) { + assert(dst != NULL); + size_t len; + const char* str = tbufReadString(buf, &len); if (len >= size) { len = size - 1; } - memcpy( dst, str, len ); + memcpy(dst, str, len); dst[len] = 0; return len; } -const char* tbufReadBinary( SBufferReader* buf, size_t *len ) { - size_t l = tbufReadLength( buf ); +const char* tbufReadBinary(SBufferReader* buf, size_t* len) { + size_t l = tbufReadLength(buf); const char* ret = buf->data + buf->pos; - tbufSkip( buf, l ); - if( len != NULL ) { + tbufSkip(buf, l); + if (len != NULL) { *len = l; } return ret; } -size_t tbufReadToBinary( SBufferReader* buf, void* dst, size_t size ) { - assert( dst != NULL ); - size_t len; - const char* data = tbufReadBinary( buf, &len ); - if( len >= size ) { +size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size) { + assert(dst != NULL); + size_t len; + const char* data = tbufReadBinary(buf, &len); + if (len >= size) { len = size; } - memcpy( dst, data, len ); + memcpy(dst, data, len); return len; } -bool tbufReadBool( SBufferReader* buf ) { +bool tbufReadBool(SBufferReader* buf) { bool ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); return ret; } -char tbufReadChar( SBufferReader* buf ) { +char tbufReadChar(SBufferReader* buf) { char ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); return ret; } -int8_t tbufReadInt8( SBufferReader* buf ) { +int8_t tbufReadInt8(SBufferReader* buf) { int8_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); return ret; } -uint8_t tbufReadUint8( SBufferReader* buf ) { +uint8_t tbufReadUint8(SBufferReader* buf) { uint8_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); return ret; } -int16_t tbufReadInt16( SBufferReader* buf ) { +int16_t tbufReadInt16(SBufferReader* buf) { int16_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return (int16_t)ntohs( ret ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return (int16_t)ntohs(ret); } return ret; } -uint16_t tbufReadUint16( SBufferReader* buf ) { +uint16_t tbufReadUint16(SBufferReader* buf) { uint16_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return ntohs( ret ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return ntohs(ret); } return ret; } -int32_t tbufReadInt32( SBufferReader* buf ) { +int32_t tbufReadInt32(SBufferReader* buf) { int32_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return (int32_t)ntohl( ret ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return (int32_t)ntohl(ret); } return ret; } -uint32_t tbufReadUint32( SBufferReader* buf ) { +uint32_t tbufReadUint32(SBufferReader* buf) { uint32_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return ntohl( ret ); + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return ntohl(ret); } return ret; } -int64_t tbufReadInt64( SBufferReader* buf ) { +int64_t tbufReadInt64(SBufferReader* buf) { int64_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return (int64_t)htobe64( ret ); // TODO: ntohll + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return (int64_t)htobe64(ret); // TODO: ntohll } return ret; } -uint64_t tbufReadUint64( SBufferReader* buf ) { +uint64_t tbufReadUint64(SBufferReader* buf) { uint64_t ret; - tbufReadToBuffer( buf, &ret, sizeof(ret) ); - if( buf->endian ) { - return htobe64( ret ); // TODO: ntohll + tbufReadToBuffer(buf, &ret, sizeof(ret)); + if (buf->endian) { + return htobe64(ret); // TODO: ntohll } return ret; } -float tbufReadFloat( SBufferReader* buf ) { +float tbufReadFloat(SBufferReader* buf) { Un4B _un; - tbufReadToBuffer( buf, &_un, sizeof(_un) ); - if( buf->endian ) { - _un.ui = ntohl( _un.ui ); + tbufReadToBuffer(buf, &_un, sizeof(_un)); + if (buf->endian) { + _un.ui = ntohl(_un.ui); } return _un.f; } double tbufReadDouble(SBufferReader* buf) { Un8B _un; - tbufReadToBuffer( buf, &_un, sizeof(_un) ); - if( buf->endian ) { - _un.ull = htobe64( _un.ull ); + tbufReadToBuffer(buf, &_un, sizeof(_un)); + if (buf->endian) { + _un.ull = htobe64(_un.ull); } return _un.d; } @@ -213,38 +213,38 @@ double tbufReadDouble(SBufferReader* buf) { //////////////////////////////////////////////////////////////////////////////// // writer functions -void tbufCloseWriter( SBufferWriter* buf ) { +void tbufCloseWriter(SBufferWriter* buf) { tfree(buf->data); -// (*buf->allocator)( buf->data, 0 ); // potential memory leak. + // (*buf->allocator)( buf->data, 0 ); // potential memory leak. buf->data = NULL; buf->pos = 0; buf->size = 0; } -void tbufEnsureCapacity( SBufferWriter* buf, size_t size ) { +void tbufEnsureCapacity(SBufferWriter* buf, size_t size) { size += buf->pos; - if( size > buf->size ) { + if (size > buf->size) { size_t nsize = size + buf->size; - char* data = (*buf->allocator)( buf->data, nsize ); + char* data = (*buf->allocator)(buf->data, nsize); // TODO: the exception should be thrown by the allocator function - if( data == NULL ) { - THROW( -1 ); + if (data == NULL) { + THROW(-1); } buf->data = data; buf->size = nsize; } } -size_t tbufReserve( SBufferWriter* buf, size_t size ) { - tbufEnsureCapacity( buf, size ); +size_t tbufReserve(SBufferWriter* buf, size_t size) { + tbufEnsureCapacity(buf, size); size_t old = buf->pos; buf->pos += size; return old; } -char* tbufGetData( SBufferWriter* buf, bool takeOver ) { +char* tbufGetData(SBufferWriter* buf, bool takeOver) { char* ret = buf->data; - if( takeOver ) { + if (takeOver) { buf->pos = 0; buf->size = 0; buf->data = NULL; @@ -252,192 +252,174 @@ char* tbufGetData( SBufferWriter* buf, bool takeOver ) { return ret; } -void tbufWrite( SBufferWriter* buf, const void* data, size_t size ) { - assert( data != NULL ); - tbufEnsureCapacity( buf, size ); - memcpy( buf->data + buf->pos, data, size ); +void tbufWrite(SBufferWriter* buf, const void* data, size_t size) { + assert(data != NULL); + tbufEnsureCapacity(buf, size); + memcpy(buf->data + buf->pos, data, size); buf->pos += size; } -void tbufWriteAt( SBufferWriter* buf, size_t pos, const void* data, size_t size ) { - assert( data != NULL ); +void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size) { + assert(data != NULL); // this function can only be called to fill the gap on previous writes, // so 'pos + size <= buf->pos' must be true - assert( pos + size <= buf->pos ); - memcpy( buf->data + pos, data, size ); + assert(pos + size <= buf->pos); + memcpy(buf->data + pos, data, size); } -static void tbufWriteLength( SBufferWriter* buf, size_t len ) { +static void tbufWriteLength(SBufferWriter* buf, size_t len) { // maximum length is 65535, if larger length is required // this function and the corresponding read function need to be // revised. - assert( len <= 0xffff ); - tbufWriteUint16( buf, (uint16_t)len ); + assert(len <= 0xffff); + tbufWriteUint16(buf, (uint16_t)len); } -void tbufWriteStringLen( SBufferWriter* buf, const char* str, size_t len ) { - tbufWriteLength( buf, len ); - tbufWrite( buf, str, len ); - tbufWriteChar( buf, '\0' ); +void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len) { + tbufWriteLength(buf, len); + tbufWrite(buf, str, len); + tbufWriteChar(buf, '\0'); } -void tbufWriteString( SBufferWriter* buf, const char* str ) { - tbufWriteStringLen( buf, str, strlen(str) ); +void tbufWriteString(SBufferWriter* buf, const char* str) { tbufWriteStringLen(buf, str, strlen(str)); } + +void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len) { + tbufWriteLength(buf, len); + tbufWrite(buf, data, len); } -void tbufWriteBinary( SBufferWriter* buf, const void* data, size_t len ) { - tbufWriteLength( buf, len ); - tbufWrite( buf, data, len ); -} +void tbufWriteBool(SBufferWriter* buf, bool data) { tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteBool( SBufferWriter* buf, bool data ) { - tbufWrite( buf, &data, sizeof(data) ); -} +void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteBoolAt( SBufferWriter* buf, size_t pos, bool data ) { - tbufWriteAt( buf, pos, &data, sizeof(data) ); -} +void tbufWriteChar(SBufferWriter* buf, char data) { tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteChar( SBufferWriter* buf, char data ) { - tbufWrite( buf, &data, sizeof(data) ); -} +void tbufWriteCharAt(SBufferWriter* buf, size_t pos, char data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteCharAt( SBufferWriter* buf, size_t pos, char data ) { - tbufWriteAt( buf, pos, &data, sizeof(data) ); -} +void tbufWriteInt8(SBufferWriter* buf, int8_t data) { tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteInt8( SBufferWriter* buf, int8_t data ) { - tbufWrite( buf, &data, sizeof(data) ); -} +void tbufWriteInt8At(SBufferWriter* buf, size_t pos, int8_t data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteInt8At( SBufferWriter* buf, size_t pos, int8_t data ) { - tbufWriteAt( buf, pos, &data, sizeof(data) ); -} +void tbufWriteUint8(SBufferWriter* buf, uint8_t data) { tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteUint8( SBufferWriter* buf, uint8_t data ) { - tbufWrite( buf, &data, sizeof(data) ); -} +void tbufWriteUint8At(SBufferWriter* buf, size_t pos, uint8_t data) { tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteUint8At( SBufferWriter* buf, size_t pos, uint8_t data ) { - tbufWriteAt( buf, pos, &data, sizeof(data) ); -} - -void tbufWriteInt16( SBufferWriter* buf, int16_t data ) { - if( buf->endian ) { - data = (int16_t)htons( data ); +void tbufWriteInt16(SBufferWriter* buf, int16_t data) { + if (buf->endian) { + data = (int16_t)htons(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteInt16At( SBufferWriter* buf, size_t pos, int16_t data ) { - if( buf->endian ) { - data = (int16_t)htons( data ); +void tbufWriteInt16At(SBufferWriter* buf, size_t pos, int16_t data) { + if (buf->endian) { + data = (int16_t)htons(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteUint16( SBufferWriter* buf, uint16_t data ) { - if( buf->endian ) { - data = htons( data ); +void tbufWriteUint16(SBufferWriter* buf, uint16_t data) { + if (buf->endian) { + data = htons(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteUint16At( SBufferWriter* buf, size_t pos, uint16_t data ) { - if( buf->endian ) { - data = htons( data ); +void tbufWriteUint16At(SBufferWriter* buf, size_t pos, uint16_t data) { + if (buf->endian) { + data = htons(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteInt32( SBufferWriter* buf, int32_t data ) { - if( buf->endian ) { - data = (int32_t)htonl( data ); +void tbufWriteInt32(SBufferWriter* buf, int32_t data) { + if (buf->endian) { + data = (int32_t)htonl(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteInt32At( SBufferWriter* buf, size_t pos, int32_t data ) { - if( buf->endian ) { - data = (int32_t)htonl( data ); +void tbufWriteInt32At(SBufferWriter* buf, size_t pos, int32_t data) { + if (buf->endian) { + data = (int32_t)htonl(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteUint32( SBufferWriter* buf, uint32_t data ) { - if( buf->endian ) { - data = htonl( data ); +void tbufWriteUint32(SBufferWriter* buf, uint32_t data) { + if (buf->endian) { + data = htonl(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteUint32At( SBufferWriter* buf, size_t pos, uint32_t data ) { - if( buf->endian ) { - data = htonl( data ); +void tbufWriteUint32At(SBufferWriter* buf, size_t pos, uint32_t data) { + if (buf->endian) { + data = htonl(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteInt64( SBufferWriter* buf, int64_t data ) { - if( buf->endian ) { - data = (int64_t)htobe64( data ); +void tbufWriteInt64(SBufferWriter* buf, int64_t data) { + if (buf->endian) { + data = (int64_t)htobe64(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteInt64At( SBufferWriter* buf, size_t pos, int64_t data ) { - if( buf->endian ) { - data = (int64_t)htobe64( data ); +void tbufWriteInt64At(SBufferWriter* buf, size_t pos, int64_t data) { + if (buf->endian) { + data = (int64_t)htobe64(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteUint64( SBufferWriter* buf, uint64_t data ) { - if( buf->endian ) { - data = htobe64( data ); +void tbufWriteUint64(SBufferWriter* buf, uint64_t data) { + if (buf->endian) { + data = htobe64(data); } - tbufWrite( buf, &data, sizeof(data) ); + tbufWrite(buf, &data, sizeof(data)); } -void tbufWriteUint64At( SBufferWriter* buf, size_t pos, uint64_t data ) { - if( buf->endian ) { - data = htobe64( data ); +void tbufWriteUint64At(SBufferWriter* buf, size_t pos, uint64_t data) { + if (buf->endian) { + data = htobe64(data); } - tbufWriteAt( buf, pos, &data, sizeof(data) ); + tbufWriteAt(buf, pos, &data, sizeof(data)); } -void tbufWriteFloat( SBufferWriter* buf, float data ) { +void tbufWriteFloat(SBufferWriter* buf, float data) { Un4B _un; _un.f = data; - if( buf->endian ) { - _un.ui = htonl( _un.ui ); + if (buf->endian) { + _un.ui = htonl(_un.ui); } - tbufWrite( buf, &_un, sizeof(_un) ); + tbufWrite(buf, &_un, sizeof(_un)); } -void tbufWriteFloatAt( SBufferWriter* buf, size_t pos, float data ) { +void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data) { Un4B _un; _un.f = data; - if( buf->endian ) { - _un.ui = htonl( _un.ui ); + if (buf->endian) { + _un.ui = htonl(_un.ui); } - tbufWriteAt( buf, pos, &_un, sizeof(_un) ); + tbufWriteAt(buf, pos, &_un, sizeof(_un)); } -void tbufWriteDouble( SBufferWriter* buf, double data ) { +void tbufWriteDouble(SBufferWriter* buf, double data) { Un8B _un; _un.d = data; - if( buf->endian ) { - _un.ull = htobe64( _un.ull ); + if (buf->endian) { + _un.ull = htobe64(_un.ull); } - tbufWrite( buf, &_un, sizeof(_un) ); + tbufWrite(buf, &_un, sizeof(_un)); } -void tbufWriteDoubleAt( SBufferWriter* buf, size_t pos, double data ) { +void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data) { Un8B _un; _un.d = data; - if( buf->endian ) { - _un.ull = htobe64( _un.ull ); + if (buf->endian) { + _un.ull = htobe64(_un.ull); } - tbufWriteAt( buf, pos, &_un, sizeof(_un) ); + tbufWriteAt(buf, pos, &_un, sizeof(_un)); } From 28ef73890d79622a3a24ec40cd015701aec5a71b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 14:27:36 +0800 Subject: [PATCH 11/55] more --- include/util/tbuffer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h index 009d7bf23b..e2b9f192a7 100644 --- a/include/util/tbuffer.h +++ b/include/util/tbuffer.h @@ -16,6 +16,8 @@ #ifndef _TD_UTIL_BUFFER_H #define _TD_UTIL_BUFFER_H +#include "os.h" + #ifdef __cplusplus extern "C" { #endif From db7df3e817d2709dbd93e46565cc356efbcaa737 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 14:40:56 +0800 Subject: [PATCH 12/55] refact --- include/util/tbuffer.h | 69 ++++++++++------------ source/dnode/vnode/impl/inc/vnodeRequest.h | 4 +- source/dnode/vnode/impl/src/vnodeRequest.c | 5 +- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h index e2b9f192a7..6bb7f67e3d 100644 --- a/include/util/tbuffer.h +++ b/include/util/tbuffer.h @@ -93,58 +93,26 @@ typedef struct SBufferWriter { #define tbufTell(buf) ((buf)->pos) //////////////////////////////////////////////////////////////////////////////// -// reader functions & macros - -// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically -#define tbufInitReader(Data, Size, Endian) \ - { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } - -size_t tbufSkip(SBufferReader* buf, size_t size); - -const char* tbufRead(SBufferReader* buf, size_t size); -void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); -const char* tbufReadString(SBufferReader* buf, size_t* len); -size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); -const char* tbufReadBinary(SBufferReader* buf, size_t* len); -size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); - -bool tbufReadBool(SBufferReader* buf); -char tbufReadChar(SBufferReader* buf); -int8_t tbufReadInt8(SBufferReader* buf); -uint8_t tbufReadUint8(SBufferReader* buf); -int16_t tbufReadInt16(SBufferReader* buf); -uint16_t tbufReadUint16(SBufferReader* buf); -int32_t tbufReadInt32(SBufferReader* buf); -uint32_t tbufReadUint32(SBufferReader* buf); -int64_t tbufReadInt64(SBufferReader* buf); -uint64_t tbufReadUint64(SBufferReader* buf); -float tbufReadFloat(SBufferReader* buf); -double tbufReadDouble(SBufferReader* buf); - -//////////////////////////////////////////////////////////////////////////////// -// writer functions & macros - +/* ------------------------ BUFFER WRITER FUNCTIONS AND MACROS ------------------------ */ // *Allocator*, function to allocate memory, will use 'realloc' if NULL // *Endian*, if true, writer functions of primitive types will do 'hton' automatically #define tbufInitWriter(Allocator, Endian) \ { .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) } -void tbufCloseWriter(SBufferWriter* buf); +void tbufCloseWriter(SBufferWriter* buf); void tbufEnsureCapacity(SBufferWriter* buf, size_t size); size_t tbufReserve(SBufferWriter* buf, size_t size); char* tbufGetData(SBufferWriter* buf, bool takeOver); - -void tbufWrite(SBufferWriter* buf, const void* data, size_t size); -void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); -void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); -void tbufWriteString(SBufferWriter* buf, const char* str); +void tbufWrite(SBufferWriter* buf, const void* data, size_t size); +void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); +void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); +void tbufWriteString(SBufferWriter* buf, const char* str); // the prototype of tbufWriteBinary and tbufWrite are identical // the difference is: tbufWriteBinary writes the length of the data to the buffer // first, then the actual data, which means the reader don't need to know data // size before read. Write only write the data itself, which means the reader // need to know data size before read. void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len); - void tbufWriteBool(SBufferWriter* buf, bool data); void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data); void tbufWriteChar(SBufferWriter* buf, char data); @@ -170,6 +138,31 @@ void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data); void tbufWriteDouble(SBufferWriter* buf, double data); void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data); +/* ------------------------ BUFFER READER FUNCTIONS AND MACROS ------------------------ */ +// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically +#define tbufInitReader(Data, Size, Endian) \ + { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } + +size_t tbufSkip(SBufferReader* buf, size_t size); +const char* tbufRead(SBufferReader* buf, size_t size); +void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); +const char* tbufReadString(SBufferReader* buf, size_t* len); +size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); +const char* tbufReadBinary(SBufferReader* buf, size_t* len); +size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); +bool tbufReadBool(SBufferReader* buf); +char tbufReadChar(SBufferReader* buf); +int8_t tbufReadInt8(SBufferReader* buf); +uint8_t tbufReadUint8(SBufferReader* buf); +int16_t tbufReadInt16(SBufferReader* buf); +uint16_t tbufReadUint16(SBufferReader* buf); +int32_t tbufReadInt32(SBufferReader* buf); +uint32_t tbufReadUint32(SBufferReader* buf); +int64_t tbufReadInt64(SBufferReader* buf); +uint64_t tbufReadUint64(SBufferReader* buf); +float tbufReadFloat(SBufferReader* buf); +double tbufReadDouble(SBufferReader* buf); + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/impl/inc/vnodeRequest.h b/source/dnode/vnode/impl/inc/vnodeRequest.h index d70fc84cab..93b4589bad 100644 --- a/source/dnode/vnode/impl/inc/vnodeRequest.h +++ b/source/dnode/vnode/impl/inc/vnodeRequest.h @@ -23,8 +23,8 @@ extern "C" { #endif // SVDropTableReq -int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq); -void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq); +// int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq); +// void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq); #ifdef __cplusplus } diff --git a/source/dnode/vnode/impl/src/vnodeRequest.c b/source/dnode/vnode/impl/src/vnodeRequest.c index afc43602d8..4b481bf399 100644 --- a/source/dnode/vnode/impl/src/vnodeRequest.c +++ b/source/dnode/vnode/impl/src/vnodeRequest.c @@ -15,6 +15,8 @@ #include "vnodeDef.h" +#if 0 + static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq); static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq); @@ -113,4 +115,5 @@ int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq) { void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq) { // TODO -} \ No newline at end of file +} +#endif \ No newline at end of file From 846acadf04b1dd35f0b59f661cbac014a845619b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 15:01:58 +0800 Subject: [PATCH 13/55] make compile --- source/dnode/vnode/impl/src/vnodeWrite.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index ef35c81e06..1c39f0fbb7 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -28,7 +28,6 @@ int vnodeProcessNoWalWMsgs(SVnode *pVnode, SRpcMsg *pMsg) { int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { SRpcMsg * pMsg; - SVnodeReq *pVnodeReq; for (int i = 0; i < taosArrayGetSize(pMsgs); i++) { pMsg = *(SRpcMsg **)taosArrayGet(pMsgs, i); @@ -51,7 +50,6 @@ int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { } int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - SVnodeReq vReq; SVCreateTbReq vCreateTbReq; void * ptr = vnodeMalloc(pVnode, pMsg->contLen); if (ptr == NULL) { @@ -79,9 +77,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { break; case TDMT_VND_DROP_STB: case TDMT_VND_DROP_TABLE: - if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) { - // TODO: handle error - } + // if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) { + // // TODO: handle error + // } break; case TDMT_VND_SUBMIT: if (tsdbInsertData(pVnode->pTsdb, (SSubmitMsg *)ptr) < 0) { From cce557bd3ea816fb0f5e61d32d227ae9e91d532b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 28 Dec 2021 16:11:48 +0800 Subject: [PATCH 14/55] handle cache write/reade concurrent problem --- source/libs/index/inc/index_cache.h | 16 ++- source/libs/index/src/index_cache.c | 212 ++++++++++++++++++---------- 2 files changed, 149 insertions(+), 79 deletions(-) diff --git a/source/libs/index/inc/index_cache.h b/source/libs/index/inc/index_cache.h index 0e7405869a..679de3c0a5 100644 --- a/source/libs/index/inc/index_cache.h +++ b/source/libs/index/inc/index_cache.h @@ -30,14 +30,18 @@ extern "C" { #endif +typedef struct MemTable { + T_REF_DECLARE() + SSkipList* mem; +} MemTable; typedef struct IndexCache { T_REF_DECLARE() - SSkipList *mem, *imm; - SIndex* index; - char* colName; - int32_t version; - int32_t nTerm; - int8_t type; + MemTable *mem, *imm; + SIndex* index; + char* colName; + int32_t version; + int32_t nTerm; + int8_t type; pthread_mutex_t mtx; } IndexCache; diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index 3f99d04bc9..f610ff9a11 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -25,44 +25,20 @@ //#define CACHE_KEY_LEN(p) \ // (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + sizeof(p->operType)) -static void cacheTermDestroy(CacheTerm* ct) { - if (ct == NULL) { return; } +void indexMemRef(MemTable* tbl); +void indexMemUnRef(MemTable* tbl); - free(ct->colVal); - free(ct); -} -static char* getIndexKey(const void* pData) { - CacheTerm* p = (CacheTerm*)pData; - return (char*)p; -} +void indexCacheRef(IndexCache* cache); +void indexCacheUnRef(IndexCache* cache); -static int32_t compareKey(const void* l, const void* r) { - CacheTerm* lt = (CacheTerm*)l; - CacheTerm* rt = (CacheTerm*)r; +static void cacheTermDestroy(CacheTerm* ct); +static char* getIndexKey(const void* pData); +static int32_t compareKey(const void* l, const void* r); +static MemTable* indexInternalCacheCreate(int8_t type); - // compare colVal - int i, j; - for (i = 0, j = 0; i < lt->nColVal && j < rt->nColVal; i++, j++) { - if (lt->colVal[i] == rt->colVal[j]) { - continue; - } else { - return lt->colVal[i] < rt->colVal[j] ? -1 : 1; - } - } - if (i < lt->nColVal) { - return 1; - } else if (j < rt->nColVal) { - return -1; - } - // compare version - return rt->version - lt->version; -} - -static SSkipList* indexInternalCacheCreate(int8_t type) { - if (type == TSDB_DATA_TYPE_BINARY) { - return tSkipListCreate(MAX_SKIP_LIST_LEVEL, type, MAX_INDEX_KEY_LEN, compareKey, SL_ALLOW_DUP_KEY, getIndexKey); - } -} +static void doMergeWork(SSchedMsg* msg); +static bool indexCacheIteratorNext(Iterate* itera); +static IterateValue* indexCacheIteratorGetValue(Iterate* iter); IndexCache* indexCacheCreate(SIndex* idx, const char* colName, int8_t type) { IndexCache* cache = calloc(1, sizeof(IndexCache)); @@ -83,7 +59,15 @@ IndexCache* indexCacheCreate(SIndex* idx, const char* colName, int8_t type) { return cache; } void indexCacheDebug(IndexCache* cache) { - SSkipListIterator* iter = tSkipListCreateIter(cache->mem); + MemTable* tbl = NULL; + + pthread_mutex_lock(&cache->mtx); + tbl = cache->mem; + indexMemRef(tbl); + pthread_mutex_unlock(&cache->mtx); + + SSkipList* slt = tbl->mem; + SSkipListIterator* iter = tSkipListCreateIter(slt); while (tSkipListIterNext(iter)) { SSkipListNode* node = tSkipListIterGet(iter); CacheTerm* ct = (CacheTerm*)SL_GET_NODE_DATA(node); @@ -93,6 +77,8 @@ void indexCacheDebug(IndexCache* cache) { } } tSkipListDestroyIter(iter); + + indexMemUnRef(tbl); } void indexCacheDestroySkiplist(SSkipList* slt) { @@ -103,60 +89,33 @@ void indexCacheDestroySkiplist(SSkipList* slt) { if (ct != NULL) {} } tSkipListDestroyIter(iter); + tSkipListDestroy(slt); } void indexCacheDestroyImm(IndexCache* cache) { + MemTable* tbl = NULL; pthread_mutex_lock(&cache->mtx); - SSkipList* timm = (SSkipList*)cache->imm; + tbl = cache->imm; cache->imm = NULL; // or throw int bg thread pthread_mutex_unlock(&cache->mtx); - - indexCacheDestroySkiplist(timm); + indexMemUnRef(tbl); } void indexCacheDestroy(void* cache) { IndexCache* pCache = cache; if (pCache == NULL) { return; } - tSkipListDestroy(pCache->mem); - tSkipListDestroy(pCache->imm); + indexMemUnRef(pCache->mem); + indexMemUnRef(pCache->imm); free(pCache->colName); free(pCache); } -static void doMergeWork(SSchedMsg* msg) { - IndexCache* pCache = msg->ahandle; - SIndex* sidx = (SIndex*)pCache->index; - indexFlushCacheTFile(sidx, pCache); -} -static bool indexCacheIteratorNext(Iterate* itera) { - SSkipListIterator* iter = itera->iter; - if (iter == NULL) { return false; } - - IterateValue* iv = &itera->val; - iterateValueDestroy(iv, false); - - bool next = tSkipListIterNext(iter); - if (next) { - SSkipListNode* node = tSkipListIterGet(iter); - CacheTerm* ct = (CacheTerm*)SL_GET_NODE_DATA(node); - - iv->type = ct->operaType; - iv->colVal = ct->colVal; - - taosArrayPush(iv->val, &ct->uid); - } - - return next; -} - -static IterateValue* indexCacheIteratorGetValue(Iterate* iter) { - return &iter->val; -} Iterate* indexCacheIteratorCreate(IndexCache* cache) { Iterate* iiter = calloc(1, sizeof(Iterate)); if (iiter == NULL) { return NULL; } + MemTable* tbl = cache->imm; iiter->val.val = taosArrayInit(1, sizeof(uint64_t)); - iiter->iter = cache->imm != NULL ? tSkipListCreateIter(cache->imm) : NULL; + iiter->iter = tbl != NULL ? tSkipListCreateIter(tbl->mem) : NULL; iiter->next = indexCacheIteratorNext; iiter->getValue = indexCacheIteratorGetValue; @@ -220,8 +179,13 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // ugly code, refactor later pthread_mutex_lock(&pCache->mtx); + indexCacheMakeRoomForWrite(pCache); - tSkipListPut(pCache->mem, (char*)ct); + MemTable* tbl = pCache->mem; + indexMemRef(tbl); + tSkipListPut(tbl->mem, (char*)ct); + indexMemUnRef(tbl); + pthread_mutex_unlock(&pCache->mtx); indexCacheUnRef(pCache); @@ -238,6 +202,14 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV SIndexTerm* term = query->term; EIndexQueryType qtype = query->qType; + MemTable *mem = NULL, *imm = NULL; + pthread_mutex_lock(&pCache->mtx); + mem = pCache->mem; + imm = pCache->imm; + indexMemRef(mem); + indexMemRef(imm); + pthread_mutex_unlock(&pCache->mtx); + CacheTerm* ct = calloc(1, sizeof(CacheTerm)); if (ct == NULL) { return -1; } ct->nColVal = term->nColVal; @@ -247,7 +219,7 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV char* key = getIndexKey(ct); // TODO handle multi situation later, and refactor - SSkipListIterator* iter = tSkipListCreateIterFromVal(pCache->mem, key, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC); + SSkipListIterator* iter = tSkipListCreateIterFromVal(mem->mem, key, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC); while (tSkipListIterNext(iter)) { SSkipListNode* node = tSkipListIterGet(iter); if (node != NULL) { @@ -279,14 +251,108 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV } else if (qtype == QUERY_REGEX) { // } + indexMemUnRef(mem); + indexMemUnRef(imm); return 0; } void indexCacheRef(IndexCache* cache) { + if (cache == NULL) { return; } + int ref = T_REF_INC(cache); UNUSED(ref); } void indexCacheUnRef(IndexCache* cache) { + if (cache == NULL) { return; } + int ref = T_REF_DEC(cache); if (ref == 0) { indexCacheDestroy(cache); } } + +void indexMemRef(MemTable* tbl) { + if (tbl == NULL) { return; } + int ref = T_REF_INC(tbl); + UNUSED(ref); +} +void indexMemUnRef(MemTable* tbl) { + if (tbl == NULL) { return; } + + int ref = T_REF_DEC(tbl); + if (ref == 0) { + SSkipList* slt = tbl->mem; + indexCacheDestroySkiplist(slt); + free(tbl); + } +} + +static void cacheTermDestroy(CacheTerm* ct) { + if (ct == NULL) { return; } + + free(ct->colVal); + free(ct); +} +static char* getIndexKey(const void* pData) { + CacheTerm* p = (CacheTerm*)pData; + return (char*)p; +} + +static int32_t compareKey(const void* l, const void* r) { + CacheTerm* lt = (CacheTerm*)l; + CacheTerm* rt = (CacheTerm*)r; + + // compare colVal + int i, j; + for (i = 0, j = 0; i < lt->nColVal && j < rt->nColVal; i++, j++) { + if (lt->colVal[i] == rt->colVal[j]) { + continue; + } else { + return lt->colVal[i] < rt->colVal[j] ? -1 : 1; + } + } + if (i < lt->nColVal) { + return 1; + } else if (j < rt->nColVal) { + return -1; + } + // compare version + return rt->version - lt->version; +} + +static MemTable* indexInternalCacheCreate(int8_t type) { + MemTable* tbl = calloc(1, sizeof(MemTable)); + indexMemRef(tbl); + if (type == TSDB_DATA_TYPE_BINARY) { + tbl->mem = tSkipListCreate(MAX_SKIP_LIST_LEVEL, type, MAX_INDEX_KEY_LEN, compareKey, SL_ALLOW_DUP_KEY, getIndexKey); + } + return tbl; +} + +static void doMergeWork(SSchedMsg* msg) { + IndexCache* pCache = msg->ahandle; + SIndex* sidx = (SIndex*)pCache->index; + indexFlushCacheTFile(sidx, pCache); +} +static bool indexCacheIteratorNext(Iterate* itera) { + SSkipListIterator* iter = itera->iter; + if (iter == NULL) { return false; } + + IterateValue* iv = &itera->val; + iterateValueDestroy(iv, false); + + bool next = tSkipListIterNext(iter); + if (next) { + SSkipListNode* node = tSkipListIterGet(iter); + CacheTerm* ct = (CacheTerm*)SL_GET_NODE_DATA(node); + + iv->type = ct->operaType; + iv->colVal = ct->colVal; + + taosArrayPush(iv->val, &ct->uid); + } + + return next; +} + +static IterateValue* indexCacheIteratorGetValue(Iterate* iter) { + return &iter->val; +} From d60941d4e3a74e94f1f0f0fce44e5b06761aa879 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 00:20:48 -0800 Subject: [PATCH 15/55] add bnode --- include/dnode/bnode/bnode.h | 10 +- include/dnode/snode/snode.h | 10 +- source/dnode/bnode/src/bnode.c | 4 +- source/dnode/mgmt/impl/inc/dndBnode.h | 2 +- source/dnode/mgmt/impl/inc/dndInt.h | 25 +- source/dnode/mgmt/impl/inc/dndWorker.h | 4 +- source/dnode/mgmt/impl/src/dndBnode.c | 369 +++++++++++++++++++++++++ source/dnode/mgmt/impl/src/dndQnode.c | 1 - source/dnode/mgmt/impl/src/dndSnode.c | 344 +++++++++++++++++++++++ source/dnode/mgmt/impl/src/dndWorker.c | 36 ++- source/dnode/snode/src/snode.c | 4 +- 11 files changed, 778 insertions(+), 31 deletions(-) create mode 100644 source/dnode/mgmt/impl/src/dndBnode.c create mode 100644 source/dnode/mgmt/impl/src/dndSnode.c diff --git a/include/dnode/bnode/bnode.h b/include/dnode/bnode/bnode.h index 74574f5462..23cc3ca617 100644 --- a/include/dnode/bnode/bnode.h +++ b/include/dnode/bnode/bnode.h @@ -49,10 +49,11 @@ typedef struct { /** * @brief Start one Bnode in Dnode. * + * @param path Path of the bnode. * @param pOption Option of the bnode. * @return SBnode* The bnode object. */ -SBnode *bndOpen(const SBnodeOpt *pOption); +SBnode *bndOpen(const char *path, const SBnodeOpt *pOption); /** * @brief Stop Bnode in Dnode. @@ -79,6 +80,13 @@ int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad); */ int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs); +/** + * @brief Drop a bnode. + * + * @param path Path of the bnode. + */ +void bndDestroy(const char *path); + #ifdef __cplusplus } #endif diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 1d30bd1e43..97069437f2 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -49,10 +49,11 @@ typedef struct { /** * @brief Start one Snode in Dnode. * + * @param path Path of the snode. * @param pOption Option of the snode. * @return SSnode* The snode object. */ -SSnode *sndOpen(const SSnodeOpt *pOption); +SSnode *sndOpen(const char *path, const SSnodeOpt *pOption); /** * @brief Stop Snode in Dnode. @@ -80,6 +81,13 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); */ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +/** + * @brief Drop a snode. + * + * @param path Path of the snode. + */ +void sndDestroy(const char *path); + #ifdef __cplusplus } #endif diff --git a/source/dnode/bnode/src/bnode.c b/source/dnode/bnode/src/bnode.c index 40b22dd58d..9570bc72a0 100644 --- a/source/dnode/bnode/src/bnode.c +++ b/source/dnode/bnode/src/bnode.c @@ -15,7 +15,7 @@ #include "bndInt.h" -SBnode *bndOpen(const SBnodeOpt *pOption) { +SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) { SBnode *pBnode = calloc(1, sizeof(SBnode)); return pBnode; } @@ -25,3 +25,5 @@ void bndClose(SBnode *pBnode) { free(pBnode); } int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; } int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; } + +void bndDestroy(const char *path) {} diff --git a/source/dnode/mgmt/impl/inc/dndBnode.h b/source/dnode/mgmt/impl/inc/dndBnode.h index a350eae2d4..853b54ff69 100644 --- a/source/dnode/mgmt/impl/inc/dndBnode.h +++ b/source/dnode/mgmt/impl/inc/dndBnode.h @@ -24,7 +24,7 @@ extern "C" { int32_t dndInitBnode(SDnode *pDnode); void dndCleanupBnode(SDnode *pDnode); -ioid dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); +void dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg); diff --git a/source/dnode/mgmt/impl/inc/dndInt.h b/source/dnode/mgmt/impl/inc/dndInt.h index 0d37828ecd..ff96b7cfdf 100644 --- a/source/dnode/mgmt/impl/inc/dndInt.h +++ b/source/dnode/mgmt/impl/inc/dndInt.h @@ -54,18 +54,19 @@ extern int32_t dDebugFlag; #define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }} typedef enum { DND_STAT_INIT, DND_STAT_RUNNING, DND_STAT_STOPPED } EStat; -typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EDndWorkerType; +typedef enum { DND_WORKER_SINGLE, DND_WORKER_MULTI } EWorkerType; typedef void (*DndMsgFp)(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEps); typedef struct { - EDndWorkerType type; + EWorkerType type; const char *name; int32_t minNum; int32_t maxNum; - FProcessItem fp; + void *queueFp; SDnode *pDnode; taos_queue queue; SWorkerPool pool; + SMWorkerPool mpool; } SDnodeWorker; typedef struct { @@ -122,25 +123,21 @@ typedef struct { } SQnodeMgmt; typedef struct { - int32_t refCount; - int8_t deployed; - int8_t dropped; - char *file; - SSnode *pSnode; - SRWLatch latch; - taos_queue pWriteQ; - SWorkerPool writePool; + int32_t refCount; + int8_t deployed; + int8_t dropped; + SSnode *pSnode; + SRWLatch latch; + SDnodeWorker writeWorker; } SSnodeMgmt; typedef struct { int32_t refCount; int8_t deployed; int8_t dropped; - char *file; SBnode *pBnode; SRWLatch latch; - taos_queue pWriteQ; - SMWorkerPool writePool; + SDnodeWorker writeWorker; } SBnodeMgmt; typedef struct { diff --git a/source/dnode/mgmt/impl/inc/dndWorker.h b/source/dnode/mgmt/impl/inc/dndWorker.h index 237c0518e8..49ef88e67d 100644 --- a/source/dnode/mgmt/impl/inc/dndWorker.h +++ b/source/dnode/mgmt/impl/inc/dndWorker.h @@ -21,8 +21,8 @@ extern "C" { #endif #include "dndInt.h" -int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type, const char *name, int32_t minNum, - int32_t maxNum, FProcessItem fp); +int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EWorkerType type, const char *name, int32_t minNum, + int32_t maxNum, void *queueFp); void dndCleanupWorker(SDnodeWorker *pWorker); int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen); diff --git a/source/dnode/mgmt/impl/src/dndBnode.c b/source/dnode/mgmt/impl/src/dndBnode.c new file mode 100644 index 0000000000..b978c1102f --- /dev/null +++ b/source/dnode/mgmt/impl/src/dndBnode.c @@ -0,0 +1,369 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "dndBnode.h" +#include "dndDnode.h" +#include "dndTransport.h" +#include "dndWorker.h" + +static void dndProcessBnodeQueue(SDnode *pDnode, taos_qall qall, int32_t numOfMsgs); + +static SBnode *dndAcquireBnode(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + SBnode *pBnode = NULL; + int32_t refCount = 0; + + taosRLockLatch(&pMgmt->latch); + if (pMgmt->deployed && !pMgmt->dropped) { + refCount = atomic_add_fetch_32(&pMgmt->refCount, 1); + pBnode = pMgmt->pBnode; + } else { + terrno = TSDB_CODE_DND_BNODE_NOT_DEPLOYED; + } + taosRUnLockLatch(&pMgmt->latch); + + if (pBnode != NULL) { + dTrace("acquire bnode, refCount:%d", refCount); + } + return pBnode; +} + +static void dndReleaseBnode(SDnode *pDnode, SBnode *pBnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + int32_t refCount = 0; + + taosRLockLatch(&pMgmt->latch); + if (pBnode != NULL) { + refCount = atomic_sub_fetch_32(&pMgmt->refCount, 1); + } + taosRUnLockLatch(&pMgmt->latch); + + if (pBnode != NULL) { + dTrace("release bnode, refCount:%d", refCount); + } +} + +static int32_t dndReadBnodeFile(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + int32_t code = TSDB_CODE_DND_BNODE_READ_FILE_ERROR; + int32_t len = 0; + int32_t maxLen = 4096; + char *content = calloc(1, maxLen + 1); + cJSON *root = NULL; + + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode); + + FILE *fp = fopen(file, "r"); + if (fp == NULL) { + dDebug("file %s not exist", file); + code = 0; + goto PRASE_BNODE_OVER; + } + + len = (int32_t)fread(content, 1, maxLen, fp); + if (len <= 0) { + dError("failed to read %s since content is null", file); + goto PRASE_BNODE_OVER; + } + + content[len] = 0; + root = cJSON_Parse(content); + if (root == NULL) { + dError("failed to read %s since invalid json format", file); + goto PRASE_BNODE_OVER; + } + + cJSON *deployed = cJSON_GetObjectItem(root, "deployed"); + if (!deployed || deployed->type != cJSON_Number) { + dError("failed to read %s since deployed not found", file); + goto PRASE_BNODE_OVER; + } + pMgmt->deployed = deployed->valueint; + + cJSON *dropped = cJSON_GetObjectItem(root, "dropped"); + if (!dropped || dropped->type != cJSON_Number) { + dError("failed to read %s since dropped not found", file); + goto PRASE_BNODE_OVER; + } + pMgmt->dropped = dropped->valueint; + + code = 0; + dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + +PRASE_BNODE_OVER: + if (content != NULL) free(content); + if (root != NULL) cJSON_Delete(root); + if (fp != NULL) fclose(fp); + + terrno = code; + return code; +} + +static int32_t dndWriteBnodeFile(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode); + + FILE *fp = fopen(file, "w"); + if (fp == NULL) { + terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR; + dError("failed to write %s since %s", file, terrstr()); + return -1; + } + + int32_t len = 0; + int32_t maxLen = 4096; + char *content = calloc(1, maxLen + 1); + + len += snprintf(content + len, maxLen - len, "{\n"); + len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", pMgmt->deployed); + len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped); + len += snprintf(content + len, maxLen - len, "}\n"); + + fwrite(content, 1, len, fp); + taosFsyncFile(fileno(fp)); + fclose(fp); + free(content); + + if (taosRenameFile(file, file) != 0) { + terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR; + dError("failed to rename %s since %s", file, terrstr()); + return -1; + } + + dInfo("successed to write %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + return 0; +} + +static int32_t dndStartBnodeWorker(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "bnode-write", 0, 1, + (FProcessItem)dndProcessBnodeQueue) != 0) { + dError("failed to start bnode write worker since %s", terrstr()); + return -1; + } + + return 0; +} + +static void dndStopBnodeWorker(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + + taosWLockLatch(&pMgmt->latch); + pMgmt->deployed = 0; + taosWUnLockLatch(&pMgmt->latch); + + while (pMgmt->refCount > 1) { + taosMsleep(10); + } + + dndCleanupWorker(&pMgmt->writeWorker); +} + +static void dndBuildBnodeOption(SDnode *pDnode, SBnodeOpt *pOption) { + pOption->pDnode = pDnode; + pOption->sendMsgToDnodeFp = dndSendMsgToDnode; + pOption->sendMsgToMnodeFp = dndSendMsgToMnode; + pOption->sendRedirectMsgFp = dndSendRedirectMsg; + pOption->dnodeId = dndGetDnodeId(pDnode); + pOption->clusterId = dndGetClusterId(pDnode); + pOption->cfg.sver = pDnode->opt.sver; +} + +static int32_t dndOpenBnode(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + SBnodeOpt option = {0}; + dndBuildBnodeOption(pDnode, &option); + + SBnode *pBnode = bndOpen(pDnode->dir.bnode, &option); + if (pBnode == NULL) { + dError("failed to open bnode since %s", terrstr()); + return -1; + } + + if (dndStartBnodeWorker(pDnode) != 0) { + dError("failed to start bnode worker since %s", terrstr()); + bndClose(pBnode); + return -1; + } + + if (dndWriteBnodeFile(pDnode) != 0) { + dError("failed to write bnode file since %s", terrstr()); + dndStopBnodeWorker(pDnode); + bndClose(pBnode); + return -1; + } + + taosWLockLatch(&pMgmt->latch); + pMgmt->pBnode = pBnode; + pMgmt->deployed = 1; + taosWUnLockLatch(&pMgmt->latch); + + dInfo("bnode open successfully"); + return 0; +} + +static int32_t dndDropBnode(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + + SBnode *pBnode = dndAcquireBnode(pDnode); + if (pBnode == NULL) { + dError("failed to drop bnode since %s", terrstr()); + return -1; + } + + taosRLockLatch(&pMgmt->latch); + pMgmt->dropped = 1; + taosRUnLockLatch(&pMgmt->latch); + + if (dndWriteBnodeFile(pDnode) != 0) { + taosRLockLatch(&pMgmt->latch); + pMgmt->dropped = 0; + taosRUnLockLatch(&pMgmt->latch); + + dndReleaseBnode(pDnode, pBnode); + dError("failed to drop bnode since %s", terrstr()); + return -1; + } + + dndReleaseBnode(pDnode, pBnode); + dndStopBnodeWorker(pDnode); + bndClose(pBnode); + pMgmt->pBnode = NULL; + bndDestroy(pDnode->dir.bnode); + + return 0; +} + +int32_t dndProcessCreateBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { + SCreateBnodeInMsg *pMsg = pRpcMsg->pCont; + pMsg->dnodeId = htonl(pMsg->dnodeId); + + if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { + terrno = TSDB_CODE_DND_BNODE_ID_INVALID; + return -1; + } else { + return dndOpenBnode(pDnode); + } +} + +int32_t dndProcessDropBnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { + SDropBnodeInMsg *pMsg = pRpcMsg->pCont; + pMsg->dnodeId = htonl(pMsg->dnodeId); + + if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { + terrno = TSDB_CODE_DND_BNODE_ID_INVALID; + return -1; + } else { + return dndDropBnode(pDnode); + } +} + +static void dndSendBnodeErrorRsp(SRpcMsg *pMsg, int32_t code) { + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); +} + +static void dndSendBnodeErrorRsps(taos_qall qall, int32_t numOfMsgs, int32_t code) { + for (int32_t i = 0; i < numOfMsgs; ++i) { + SRpcMsg *pMsg = NULL; + taosGetQitem(qall, (void **)&pMsg); + dndSendBnodeErrorRsp(pMsg, code); + } +} + +static void dndProcessBnodeQueue(SDnode *pDnode, taos_qall qall, int32_t numOfMsgs) { + SBnode *pBnode = dndAcquireBnode(pDnode); + if (pBnode == NULL) { + dndSendBnodeErrorRsps(qall, numOfMsgs, TSDB_CODE_OUT_OF_MEMORY); + return; + } + + SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *)); + if (pArray == NULL) { + dndReleaseBnode(pDnode, pBnode); + dndSendBnodeErrorRsps(qall, numOfMsgs, TSDB_CODE_OUT_OF_MEMORY); + return; + } + + for (int32_t i = 0; i < numOfMsgs; ++i) { + SRpcMsg *pMsg = NULL; + taosGetQitem(qall, (void **)&pMsg); + void *ptr = taosArrayPush(pArray, &pMsg); + if (ptr == NULL) { + dndSendBnodeErrorRsp(pMsg, TSDB_CODE_OUT_OF_MEMORY); + } + } + + bndProcessWMsgs(pBnode, pArray); + + for (size_t i = 0; i < numOfMsgs; i++) { + SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + taosArrayDestroy(pArray); + dndReleaseBnode(pDnode, pBnode); +} + +static void dndWriteBnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) { + int32_t code = TSDB_CODE_DND_BNODE_NOT_DEPLOYED; + + SBnode *pBnode = dndAcquireBnode(pDnode); + if (pBnode != NULL) { + code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg)); + } + dndReleaseBnode(pDnode, pBnode); + + if (code != 0) { + if (pMsg->msgType & 1u) { + SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rsp); + } + rpcFreeCont(pMsg->pCont); + } +} + +void dndProcessBnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { + dndWriteBnodeMsgToWorker(pDnode, &pDnode->bmgmt.writeWorker, pMsg); +} + +int32_t dndInitBnode(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + taosInitRWLatch(&pMgmt->latch); + + if (dndReadBnodeFile(pDnode) != 0) { + return -1; + } + + if (pMgmt->dropped) return 0; + if (!pMgmt->deployed) return 0; + + return dndOpenBnode(pDnode); +} + +void dndCleanupBnode(SDnode *pDnode) { + SBnodeMgmt *pMgmt = &pDnode->bmgmt; + if (pMgmt->pBnode) { + dndStopBnodeWorker(pDnode); + bndClose(pMgmt->pBnode); + pMgmt->pBnode = NULL; + } +} diff --git a/source/dnode/mgmt/impl/src/dndQnode.c b/source/dnode/mgmt/impl/src/dndQnode.c index 8c76bf95a6..0b92de81c1 100644 --- a/source/dnode/mgmt/impl/src/dndQnode.c +++ b/source/dnode/mgmt/impl/src/dndQnode.c @@ -252,7 +252,6 @@ static int32_t dndDropQnode(SDnode *pDnode) { dndStopQnodeWorker(pDnode); qndClose(pQnode); pMgmt->pQnode = NULL; - // qndDestroy(pDnode->dir.qnode); return 0; } diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c new file mode 100644 index 0000000000..c1eb347350 --- /dev/null +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -0,0 +1,344 @@ +/* + * 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 . + */ + +#define _DEFAULT_SOURCE +#include "dndSnode.h" +#include "dndDnode.h" +#include "dndTransport.h" +#include "dndWorker.h" + +static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg); + +static SSnode *dndAcquireSnode(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + SSnode *pSnode = NULL; + int32_t refCount = 0; + + taosRLockLatch(&pMgmt->latch); + if (pMgmt->deployed && !pMgmt->dropped) { + refCount = atomic_add_fetch_32(&pMgmt->refCount, 1); + pSnode = pMgmt->pSnode; + } else { + terrno = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + } + taosRUnLockLatch(&pMgmt->latch); + + if (pSnode != NULL) { + dTrace("acquire snode, refCount:%d", refCount); + } + return pSnode; +} + +static void dndReleaseSnode(SDnode *pDnode, SSnode *pSnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + int32_t refCount = 0; + + taosRLockLatch(&pMgmt->latch); + if (pSnode != NULL) { + refCount = atomic_sub_fetch_32(&pMgmt->refCount, 1); + } + taosRUnLockLatch(&pMgmt->latch); + + if (pSnode != NULL) { + dTrace("release snode, refCount:%d", refCount); + } +} + +static int32_t dndReadSnodeFile(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + int32_t code = TSDB_CODE_DND_SNODE_READ_FILE_ERROR; + int32_t len = 0; + int32_t maxLen = 4096; + char *content = calloc(1, maxLen + 1); + cJSON *root = NULL; + + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode); + + FILE *fp = fopen(file, "r"); + if (fp == NULL) { + dDebug("file %s not exist", file); + code = 0; + goto PRASE_SNODE_OVER; + } + + len = (int32_t)fread(content, 1, maxLen, fp); + if (len <= 0) { + dError("failed to read %s since content is null", file); + goto PRASE_SNODE_OVER; + } + + content[len] = 0; + root = cJSON_Parse(content); + if (root == NULL) { + dError("failed to read %s since invalid json format", file); + goto PRASE_SNODE_OVER; + } + + cJSON *deployed = cJSON_GetObjectItem(root, "deployed"); + if (!deployed || deployed->type != cJSON_Number) { + dError("failed to read %s since deployed not found", file); + goto PRASE_SNODE_OVER; + } + pMgmt->deployed = deployed->valueint; + + cJSON *dropped = cJSON_GetObjectItem(root, "dropped"); + if (!dropped || dropped->type != cJSON_Number) { + dError("failed to read %s since dropped not found", file); + goto PRASE_SNODE_OVER; + } + pMgmt->dropped = dropped->valueint; + + code = 0; + dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + +PRASE_SNODE_OVER: + if (content != NULL) free(content); + if (root != NULL) cJSON_Delete(root); + if (fp != NULL) fclose(fp); + + terrno = code; + return code; +} + +static int32_t dndWriteSnodeFile(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode); + + FILE *fp = fopen(file, "w"); + if (fp == NULL) { + terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR; + dError("failed to write %s since %s", file, terrstr()); + return -1; + } + + int32_t len = 0; + int32_t maxLen = 4096; + char *content = calloc(1, maxLen + 1); + + len += snprintf(content + len, maxLen - len, "{\n"); + len += snprintf(content + len, maxLen - len, " \"deployed\": %d,\n", pMgmt->deployed); + len += snprintf(content + len, maxLen - len, " \"dropped\": %d\n", pMgmt->dropped); + len += snprintf(content + len, maxLen - len, "}\n"); + + fwrite(content, 1, len, fp); + taosFsyncFile(fileno(fp)); + fclose(fp); + free(content); + + if (taosRenameFile(file, file) != 0) { + terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR; + dError("failed to rename %s since %s", file, terrstr()); + return -1; + } + + dInfo("successed to write %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + return 0; +} + +static int32_t dndStartSnodeWorker(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, + (FProcessItem)dndProcessSnodeQueue) != 0) { + dError("failed to start snode write worker since %s", terrstr()); + return -1; + } + + return 0; +} + +static void dndStopSnodeWorker(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + + taosWLockLatch(&pMgmt->latch); + pMgmt->deployed = 0; + taosWUnLockLatch(&pMgmt->latch); + + while (pMgmt->refCount > 1) { + taosMsleep(10); + } + + dndCleanupWorker(&pMgmt->writeWorker); +} + +static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) { + pOption->pDnode = pDnode; + pOption->sendMsgToDnodeFp = dndSendMsgToDnode; + pOption->sendMsgToMnodeFp = dndSendMsgToMnode; + pOption->sendRedirectMsgFp = dndSendRedirectMsg; + pOption->dnodeId = dndGetDnodeId(pDnode); + pOption->clusterId = dndGetClusterId(pDnode); + pOption->cfg.sver = pDnode->opt.sver; +} + +static int32_t dndOpenSnode(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + SSnodeOpt option = {0}; + dndBuildSnodeOption(pDnode, &option); + + SSnode *pSnode = sndOpen(pDnode->dir.snode, &option); + if (pSnode == NULL) { + dError("failed to open snode since %s", terrstr()); + return -1; + } + + if (dndStartSnodeWorker(pDnode) != 0) { + dError("failed to start snode worker since %s", terrstr()); + sndClose(pSnode); + return -1; + } + + if (dndWriteSnodeFile(pDnode) != 0) { + dError("failed to write snode file since %s", terrstr()); + dndStopSnodeWorker(pDnode); + sndClose(pSnode); + return -1; + } + + taosWLockLatch(&pMgmt->latch); + pMgmt->pSnode = pSnode; + pMgmt->deployed = 1; + taosWUnLockLatch(&pMgmt->latch); + + dInfo("snode open successfully"); + return 0; +} + +static int32_t dndDropSnode(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + + SSnode *pSnode = dndAcquireSnode(pDnode); + if (pSnode == NULL) { + dError("failed to drop snode since %s", terrstr()); + return -1; + } + + taosRLockLatch(&pMgmt->latch); + pMgmt->dropped = 1; + taosRUnLockLatch(&pMgmt->latch); + + if (dndWriteSnodeFile(pDnode) != 0) { + taosRLockLatch(&pMgmt->latch); + pMgmt->dropped = 0; + taosRUnLockLatch(&pMgmt->latch); + + dndReleaseSnode(pDnode, pSnode); + dError("failed to drop snode since %s", terrstr()); + return -1; + } + + dndReleaseSnode(pDnode, pSnode); + dndStopSnodeWorker(pDnode); + sndClose(pSnode); + pMgmt->pSnode = NULL; + sndDestroy(pDnode->dir.snode); + + return 0; +} + +int32_t dndProcessCreateSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { + SCreateSnodeInMsg *pMsg = pRpcMsg->pCont; + pMsg->dnodeId = htonl(pMsg->dnodeId); + + if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { + terrno = TSDB_CODE_DND_SNODE_ID_INVALID; + return -1; + } else { + return dndOpenSnode(pDnode); + } +} + +int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { + SDropSnodeInMsg *pMsg = pRpcMsg->pCont; + pMsg->dnodeId = htonl(pMsg->dnodeId); + + if (pMsg->dnodeId != dndGetDnodeId(pDnode)) { + terrno = TSDB_CODE_DND_SNODE_ID_INVALID; + return -1; + } else { + return dndDropSnode(pDnode); + } +} + +static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + SRpcMsg *pRsp = NULL; + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + + SSnode *pSnode = dndAcquireSnode(pDnode); + if (pSnode != NULL) { + code = sndProcessMsg(pSnode, pMsg, &pRsp); + } + + if (pRsp != NULL) { + pRsp->ahandle = pMsg->ahandle; + rpcSendResponse(pRsp); + free(pRsp); + } else { + if (code != 0) code = terrno; + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); + } + + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); +} + +static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) { + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + + SSnode *pSnode = dndAcquireSnode(pDnode); + if (pSnode != NULL) { + code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg)); + } + dndReleaseSnode(pDnode, pSnode); + + if (code != 0) { + if (pMsg->msgType & 1u) { + SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rsp); + } + rpcFreeCont(pMsg->pCont); + } +} + +void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { + dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.writeWorker, pMsg); +} + +int32_t dndInitSnode(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + taosInitRWLatch(&pMgmt->latch); + + if (dndReadSnodeFile(pDnode) != 0) { + return -1; + } + + if (pMgmt->dropped) return 0; + if (!pMgmt->deployed) return 0; + + return dndOpenSnode(pDnode); +} + +void dndCleanupSnode(SDnode *pDnode) { + SSnodeMgmt *pMgmt = &pDnode->smgmt; + if (pMgmt->pSnode) { + dndStopSnodeWorker(pDnode); + sndClose(pMgmt->pSnode); + pMgmt->pSnode = NULL; + } +} diff --git a/source/dnode/mgmt/impl/src/dndWorker.c b/source/dnode/mgmt/impl/src/dndWorker.c index da0e3a9319..c421437e4d 100644 --- a/source/dnode/mgmt/impl/src/dndWorker.c +++ b/source/dnode/mgmt/impl/src/dndWorker.c @@ -16,9 +16,9 @@ #define _DEFAULT_SOURCE #include "dndWorker.h" -int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type, const char *name, int32_t minNum, - int32_t maxNum, FProcessItem fp) { - if (pDnode == NULL || pWorker == NULL || name == NULL || minNum < 0 || maxNum <= 0 || fp == NULL) { +int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EWorkerType type, const char *name, int32_t minNum, + int32_t maxNum, void *queueFp) { + if (pDnode == NULL || pWorker == NULL || name == NULL || minNum < 0 || maxNum <= 0 || queueFp == NULL) { terrno = TSDB_CODE_INVALID_PARA; return -1; } @@ -27,19 +27,32 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type pWorker->name = name; pWorker->minNum = minNum; pWorker->maxNum = maxNum; - pWorker->fp = fp; + pWorker->queueFp = queueFp; pWorker->pDnode = pDnode; if (pWorker->type == DND_WORKER_SINGLE) { SWorkerPool *pPool = &pWorker->pool; + pPool->name = name; pPool->min = minNum; pPool->max = maxNum; if (tWorkerInit(pPool) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - - pWorker->queue = tWorkerAllocQueue(&pPool, pDnode, fp); + pWorker->queue = tWorkerAllocQueue(pPool, pDnode, (FProcessItem)queueFp); + if (pWorker->queue == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } else if (pWorker->type == DND_WORKER_MULTI) { + SMWorkerPool *pPool = &pWorker->mpool; + pPool->name = name; + pPool->max = maxNum; + if (tMWorkerInit(pPool) != 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + pWorker->queue = tMWorkerAllocQueue(pPool, pDnode, (FProcessItems)queueFp); if (pWorker->queue == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -52,12 +65,17 @@ int32_t dndInitWorker(SDnode *pDnode, SDnodeWorker *pWorker, EDndWorkerType type } void dndCleanupWorker(SDnodeWorker *pWorker) { + while (!taosQueueEmpty(pWorker->queue)) { + taosMsleep(10); + } + if (pWorker->type == DND_WORKER_SINGLE) { - while (!taosQueueEmpty(pWorker->queue)) { - taosMsleep(10); - } tWorkerCleanup(&pWorker->pool); tWorkerFreeQueue(&pWorker->pool, pWorker->queue); + } else if (pWorker->type == DND_WORKER_MULTI) { + tWorkerCleanup(&pWorker->mpool); + tMWorkerFreeQueue(&pWorker->mpool, pWorker->queue); + } else { } } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 3423ce41e2..7ae4d49059 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -15,7 +15,7 @@ #include "sndInt.h" -SSnode *sndOpen(const SSnodeOpt *pOption) { +SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *pSnode = calloc(1, sizeof(SSnode)); return pSnode; } @@ -28,3 +28,5 @@ int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { *pRsp = NULL; return 0; } + +void sndDestroy(const char *path) {} \ No newline at end of file From 74900ff04e876d2bf596d9781816915e82a367cc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 16:22:35 +0800 Subject: [PATCH 16/55] more work --- include/dnode/vnode/meta/meta.h | 2 +- source/dnode/vnode/meta/src/metaBDBImpl.c | 74 +++++++++++++++++++++-- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/include/dnode/vnode/meta/meta.h b/include/dnode/vnode/meta/meta.h index 067682af1a..cc5eabf3bf 100644 --- a/include/dnode/vnode/meta/meta.h +++ b/include/dnode/vnode/meta/meta.h @@ -48,7 +48,7 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid); int metaCommit(SMeta *pMeta); // For Query -int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg); +int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg); // Options void metaOptionsInit(SMetaCfg *pMetaCfg); diff --git a/source/dnode/vnode/meta/src/metaBDBImpl.c b/source/dnode/vnode/meta/src/metaBDBImpl.c index e2137ebbdf..a8d8b67fd4 100644 --- a/source/dnode/vnode/meta/src/metaBDBImpl.c +++ b/source/dnode/vnode/meta/src/metaBDBImpl.c @@ -431,17 +431,79 @@ static void metaClearTbCfg(STbCfg *pTbCfg) { } /* ------------------------ FOR QUERY ------------------------ */ -int metaGetTableInfo(SMeta *pMeta, const char *tbname, STableMetaMsg **ppMsg) { - DBT key = {0}; - DBT value = {0}; - SMetaDB *pMetaDB = pMeta->pDB; +int metaGetTableInfo(SMeta *pMeta, char *tbname, STableMetaMsg **ppMsg) { + DBT key = {0}; + DBT value = {0}; + SMetaDB * pMetaDB = pMeta->pDB; + int ret; + STbCfg tbCfg; + SSchemaKey schemaKey; + DBT key1 = {0}; + DBT value1 = {0}; + uint32_t ncols; + void * pBuf; + int tlen; + STableMetaMsg *pMsg; key.data = tbname; key.size = strlen(tbname) + 1; - pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0); + ret = pMetaDB->pNameIdx->get(pMetaDB->pNameIdx, NULL, &key, &value, 0); + if (ret != 0) { + // TODO + return -1; + } - // TODO: construct the message body + metaDecodeTbInfo(value.data, &tbCfg); + + switch (tbCfg.type) { + case META_SUPER_TABLE: + schemaKey.uid = tbCfg.stbCfg.suid; + schemaKey.sver = 0; + + key1.data = &schemaKey; + key1.size = sizeof(schemaKey); + + ret = pMetaDB->pSchemaDB->get(pMetaDB->pSchemaDB, &key1, &value1, NULL, 0); + if (ret != 0) { + // TODO + return -1; + } + pBuf = value1.data; + pBuf = taosDecodeFixedU32(pBuf, &ncols); + + tlen = sizeof(STableMetaMsg) + (tbCfg.stbCfg.nTagCols + ncols) * sizeof(SSchema); + pMsg = calloc(1, tlen); + if (pMsg == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + strcpy(pMsg->tbFname, tbCfg.name); + pMsg->numOfTags = tbCfg.stbCfg.nTagCols; + pMsg->numOfColumns = ncols; + pMsg->tableType = tbCfg.type; + pMsg->sversion = 0; + pMsg->tversion = 0; + pMsg->suid = tbCfg.stbCfg.suid; + pMsg->tuid = tbCfg.stbCfg.suid; + for (size_t i = 0; i < tbCfg.stbCfg.nTagCols; i++) { + + } + + break; + case META_CHILD_TABLE: + ASSERT(0); + break; + case META_NORMAL_TABLE: + ASSERT(0); + break; + default: + ASSERT(0); + break; + } + + *ppMsg = pMsg; return 0; } \ No newline at end of file From 4fc5fe028cd8434187d5cff4a02821be3f082558 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 16:30:51 +0800 Subject: [PATCH 17/55] refact --- include/util/tcoding.h | 276 ----------------------------------------- 1 file changed, 276 deletions(-) diff --git a/include/util/tcoding.h b/include/util/tcoding.h index 001e5fcb8d..e1edf0d792 100644 --- a/include/util/tcoding.h +++ b/include/util/tcoding.h @@ -25,282 +25,6 @@ extern "C" { #define ZIGZAGE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode #define ZIGZAGD(T, v) ((v) >> 1) ^ -((T)((v)&1)) // zigzag decode -/* ------------------------ FIXED-LENGTH ENCODING ------------------------ */ -// 16 -#define tPut16b(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[1] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[0] = ((VAL) >> 8) & 0xff; \ - 2; \ - }) - -#define tGet16b(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[0]; \ - (VAL) = (VAL) << 8; \ - (VAL) |= ((uint8_t *)(BUF))[1]; \ - 2; \ - }) - -#define tPut16l(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ - 2; \ - }) - -#define tGet16l(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[1]; \ - (VAL) <<= 8; \ - (VAL) |= ((uint8_t *)(BUF))[0]; \ - 2; \ - }) - -// 32 -#define tPut32b(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[3] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[2] = ((VAL) >> 8) & 0xff; \ - ((uint8_t *)(BUF))[1] = ((VAL) >> 16) & 0xff; \ - ((uint8_t *)(BUF))[0] = ((VAL) >> 24) & 0xff; \ - 4; \ - }) - -#define tGet32b(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[0]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[1]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[2]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[3]; \ - 4; \ - }) - -#define tPut32l(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ - ((uint8_t *)(BUF))[2] = ((VAL) >> 16) & 0xff; \ - ((uint8_t *)(BUF))[3] = ((VAL) >> 24) & 0xff; \ - 4; \ - }) - -#define tGet32l(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[3]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[2]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[1]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[0]; \ - 4; \ - }) - -// 64 -#define tPut64b(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[7] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[6] = ((VAL) >> 8) & 0xff; \ - ((uint8_t *)(BUF))[5] = ((VAL) >> 16) & 0xff; \ - ((uint8_t *)(BUF))[4] = ((VAL) >> 24) & 0xff; \ - ((uint8_t *)(BUF))[3] = ((VAL) >> 32) & 0xff; \ - ((uint8_t *)(BUF))[2] = ((VAL) >> 40) & 0xff; \ - ((uint8_t *)(BUF))[1] = ((VAL) >> 48) & 0xff; \ - ((uint8_t *)(BUF))[0] = ((VAL) >> 56) & 0xff; \ - 8; \ - }) - -#define tGet64b(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[0]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[1]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[2]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[3]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[4]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[5]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[6]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[7]; \ - 8; \ - }) - -#define tPut64l(BUF, VAL) \ - ({ \ - ((uint8_t *)(BUF))[0] = (VAL)&0xff; \ - ((uint8_t *)(BUF))[1] = ((VAL) >> 8) & 0xff; \ - ((uint8_t *)(BUF))[2] = ((VAL) >> 16) & 0xff; \ - ((uint8_t *)(BUF))[3] = ((VAL) >> 24) & 0xff; \ - ((uint8_t *)(BUF))[4] = ((VAL) >> 32) & 0xff; \ - ((uint8_t *)(BUF))[5] = ((VAL) >> 40) & 0xff; \ - ((uint8_t *)(BUF))[6] = ((VAL) >> 48) & 0xff; \ - ((uint8_t *)(BUF))[7] = ((VAL) >> 56) & 0xff; \ - 8; \ - }) - -#define tGet64l(BUF, VAL) \ - ({ \ - (VAL) = ((uint8_t *)(BUF))[7]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[6]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[5]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[4]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[3]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[2]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[1]; \ - (VAL) <<= 8; \ - (VAL) = ((uint8_t *)(BUF))[0]; \ - 8; \ - }) - -#define tPut(BUF, VAL, TYPE) \ - ({ \ - *(TYPE *)(BUF) = (VAL); \ - sizeof(TYPE); \ - }) - -#define tGet(BUF, VAL, TYPE) \ - ({ \ - (VAL) = (*(TYPE *)(BUF)); \ - sizeof(TYPE); \ - }) - -#define tPut_uint8_t_l(BUF, VAL, TYPE) tPut(BUF, VAL, TYPE) -#define tGet_uint8_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) -#define tPut_int8_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL, TYPE) -#define tGet_int8_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) - -#define tPut_uint16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) -#define tGet_uint16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL) -#define tPut_int16_t_l(BUF, VAL, TYPE) tPut16l(BUF, VAL) -#define tGet_int16_t_l(BUF, VAL, TYPE) tGet16l(BUF, VAL) - -#define tPut_uint32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL) -#define tGet_uint32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL) -#define tPut_int32_t_l(BUF, VAL, TYPE) tPut32l(BUF, VAL) -#define tGet_int32_t_l(BUF, VAL, TYPE) tGet32l(BUF, VAL) - -#define tPut_uint64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL) -#define tGet_uint64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL) -#define tPut_int64_t_l(BUF, VAL, TYPE) tPut64l(BUF, VAL) -#define tGet_int64_t_l(BUF, VAL, TYPE) tGet64l(BUF, VAL) - -#define tPut_uint8_t_b(BUF, VAL, TYPE) tPut(BUF, VAL, TYPE) -#define tGet_uint8_t_b(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) -#define tPut_int8_t_b(BUF, VAL, TYPE) tPut16l(BUF, VAL, TYPE) -#define tGet_int8_t_b(BUF, VAL, TYPE) tGet16l(BUF, VAL, TYPE) - -#define tPut_uint16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) -#define tGet_uint16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL) -#define tPut_int16_t_b(BUF, VAL, TYPE) tPut16b(BUF, VAL) -#define tGet_int16_t_b(BUF, VAL, TYPE) tGet16b(BUF, VAL) - -#define tPut_uint32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL) -#define tGet_uint32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL) -#define tPut_int32_t_b(BUF, VAL, TYPE) tPut32b(BUF, VAL) -#define tGet_int32_t_b(BUF, VAL, TYPE) tGet32b(BUF, VAL) - -#define tPut_uint64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL) -#define tGet_uint64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL) -#define tPut_int64_t_b(BUF, VAL, TYPE) tPut64b(BUF, VAL) -#define tGet_int64_t_b(BUF, VAL, TYPE) tGet64b(BUF, VAL) - -#define tPutl(BUF, VAL, TYPE) tPut_##TYPE##_l(BUF, VAL, TYPE) - -#define tGetl(BUF, VAL, TYPE) tGet_##TYPE##_l(BUF, VAL, TYPE) - -#define tPutb(BUF, VAL, TYPE) tPut_##TYPE##_b(BUF, VAL, TYPE) - -#define tGetb(BUF, VAL, TYPE) tGet_##TYPE##_b(BUF, VAL, TYPE) - -#define tPutVal(BUF, VAL, TYPE, ENDIAN) \ - ({ \ - int len; \ - if (TD_RT_ENDIAN() == (ENDIAN)) { \ - len = tPut(BUF, VAL, TYPE); \ - } else { \ - if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ - len = tPutl(BUF, VAL, TYPE); \ - } else if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ - len = tPutb(BUF, VAL, TYPE); \ - } else { \ - ASSERT(0); \ - } \ - } \ - if (BUF) BUF = BUF + len; \ - len; \ - }) - -#define tGetVal(BUF, VAL, TYPE, ENDIAN) \ - ({ \ - int len; \ - if (TD_RT_ENDIAN() == (ENDIAN)) { \ - len = tGet(BUF, VAL, TYPE); \ - } else { \ - if ((ENDIAN) == TD_LITTLE_ENDIAN) { \ - len = tGetl(BUF, VAL, TYPE); \ - } else if ((ENDIAN) == TD_BIG_ENDIAN) { \ - len = tGetb(BUF, VAL, TYPE); \ - } else { \ - } \ - } \ - BUF = BUF + len; \ - len; \ - }) - -/* ------------------------ VARIANT-LENGTH ENCODING ------------------------ */ -#define vPut(BUF, VAL, SIGN) \ - ({ \ - uint64_t tmp = (SIGN) ? ZIGZAGE(int64_t, VAL) : (VAL); \ - int i = 0; \ - while ((VAL) >= ENCODE_LIMIT) { \ - ((uint8_t *)(BUF))[i] = (uint8_t)((tmp) | ENCODE_LIMIT); \ - (tmp) >>= 7; \ - i++; \ - } \ - ((uint8_t *)(BUF))[i] = (uint8_t)(tmp); \ - i + 1; \ - }) - -#define vGet(BUF, VAL, SIGN) \ - ({ \ - uint64_t tmp; \ - uint64_t tval = 0; \ - int i = 0; \ - while (true) { \ - tmp = (uint64_t)(((uint8_t *)(BUF))[i]); \ - if (tmp < ENCODE_LIMIT) { \ - tval |= (tval << (7 * i)); \ - break; \ - } else { \ - tval |= ((tval & (ENCODE_LIMIT - 1)) << (7 * i)); \ - i++; \ - } \ - } \ - if (SIGN) { \ - (VAL) = ZIGZAGD(int64_t, tmp); \ - } else { \ - (VAL) = tmp; \ - } \ - i; \ - }) - -/* ------------------------ OTHER TYPE ENCODING ------------------------ */ - /* ------------------------ LEGACY CODES ------------------------ */ #if 1 // ---- Fixed U8 From 041e6716010b2e641e076c2ed2b566200392bc38 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 01:38:15 -0800 Subject: [PATCH 18/55] refact mnode queue --- include/dnode/mnode/mnode.h | 20 +- include/dnode/snode/snode.h | 2 +- source/dnode/mgmt/impl/inc/dndInt.h | 32 +- source/dnode/mgmt/impl/src/dndBnode.c | 22 +- source/dnode/mgmt/impl/src/dndMnode.c | 368 ++++---------------- source/dnode/mgmt/impl/src/dndQnode.c | 18 +- source/dnode/mgmt/impl/src/dndSnode.c | 22 +- source/dnode/mgmt/impl/src/dndWorker.c | 19 +- source/dnode/mgmt/impl/test/dnode/dnode.cpp | 2 +- source/dnode/mnode/impl/src/mndDnode.c | 2 +- source/dnode/mnode/impl/src/mnode.c | 8 +- source/libs/parser/src/astToMsg.c | 1 + tests/script/unique/dnode/basic1.sim | 11 + 13 files changed, 160 insertions(+), 367 deletions(-) diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index e0619b2133..a288e3e630 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -147,28 +147,12 @@ void mndCleanupMsg(SMnodeMsg *pMsg); void mndSendRsp(SMnodeMsg *pMsg, int32_t code); /** - * @brief Process the read request. + * @brief Process the read, write, sync request. * * @param pMsg The request msg. * @return int32_t 0 for success, -1 for failure. */ -void mndProcessReadMsg(SMnodeMsg *pMsg); - -/** - * @brief Process the write request. - * - * @param pMsg The request msg. - * @return int32_t 0 for success, -1 for failure. - */ -void mndProcessWriteMsg(SMnodeMsg *pMsg); - -/** - * @brief Process the sync request. - * - * @param pMsg The request msg. - * @return int32_t 0 for success, -1 for failure. - */ -void mndProcessSyncMsg(SMnodeMsg *pMsg); +void mndProcessMsg(SMnodeMsg *pMsg); #ifdef __cplusplus } diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 97069437f2..4913d2572f 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -79,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 sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); /** * @brief Drop a snode. diff --git a/source/dnode/mgmt/impl/inc/dndInt.h b/source/dnode/mgmt/impl/inc/dndInt.h index ff96b7cfdf..954e21aefa 100644 --- a/source/dnode/mgmt/impl/inc/dndInt.h +++ b/source/dnode/mgmt/impl/inc/dndInt.h @@ -65,8 +65,10 @@ typedef struct { void *queueFp; SDnode *pDnode; taos_queue queue; - SWorkerPool pool; - SMWorkerPool mpool; + union { + SWorkerPool pool; + SMWorkerPool mpool; + }; } SDnodeWorker; typedef struct { @@ -95,21 +97,17 @@ typedef struct { } SDnodeMgmt; typedef struct { - int32_t refCount; - int8_t deployed; - int8_t dropped; - int8_t replica; - int8_t selfIndex; - SReplica replicas[TSDB_MAX_REPLICA]; - char *file; - SMnode *pMnode; - SRWLatch latch; - taos_queue pReadQ; - taos_queue pWriteQ; - taos_queue pSyncQ; - SWorkerPool readPool; - SWorkerPool writePool; - SWorkerPool syncPool; + int32_t refCount; + int8_t deployed; + int8_t dropped; + SMnode *pMnode; + SRWLatch latch; + SDnodeWorker readWorker; + SDnodeWorker writeWorker; + SDnodeWorker syncWorker; + int8_t replica; + int8_t selfIndex; + SReplica replicas[TSDB_MAX_REPLICA]; } SMnodeMgmt; typedef struct { diff --git a/source/dnode/mgmt/impl/src/dndBnode.c b/source/dnode/mgmt/impl/src/dndBnode.c index b978c1102f..992f6ac0a1 100644 --- a/source/dnode/mgmt/impl/src/dndBnode.c +++ b/source/dnode/mgmt/impl/src/dndBnode.c @@ -140,20 +140,22 @@ static int32_t dndWriteBnodeFile(SDnode *pDnode) { fclose(fp); free(content); - if (taosRenameFile(file, file) != 0) { + char realfile[PATH_MAX + 20]; + snprintf(realfile, PATH_MAX + 20, "%s/bnode.json", pDnode->dir.dnode); + + if (taosRenameFile(file, realfile) != 0) { terrno = TSDB_CODE_DND_BNODE_WRITE_FILE_ERROR; dError("failed to rename %s since %s", file, terrstr()); return -1; } - dInfo("successed to write %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped); return 0; } static int32_t dndStartBnodeWorker(SDnode *pDnode) { SBnodeMgmt *pMgmt = &pDnode->bmgmt; - if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "bnode-write", 0, 1, - (FProcessItem)dndProcessBnodeQueue) != 0) { + if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_MULTI, "bnode-write", 0, 1, dndProcessBnodeQueue) != 0) { dError("failed to start bnode write worker since %s", terrstr()); return -1; } @@ -202,7 +204,9 @@ static int32_t dndOpenBnode(SDnode *pDnode) { return -1; } + pMgmt->deployed = 1; if (dndWriteBnodeFile(pDnode) != 0) { + pMgmt->deployed = 0; dError("failed to write bnode file since %s", terrstr()); dndStopBnodeWorker(pDnode); bndClose(pBnode); @@ -211,7 +215,6 @@ static int32_t dndOpenBnode(SDnode *pDnode) { taosWLockLatch(&pMgmt->latch); pMgmt->pBnode = pBnode; - pMgmt->deployed = 1; taosWUnLockLatch(&pMgmt->latch); dInfo("bnode open successfully"); @@ -243,6 +246,8 @@ static int32_t dndDropBnode(SDnode *pDnode) { dndReleaseBnode(pDnode, pBnode); dndStopBnodeWorker(pDnode); + pMgmt->deployed = 0; + dndWriteBnodeFile(pDnode); bndClose(pBnode); pMgmt->pBnode = NULL; bndDestroy(pDnode->dir.bnode); @@ -353,7 +358,12 @@ int32_t dndInitBnode(SDnode *pDnode) { return -1; } - if (pMgmt->dropped) return 0; + if (pMgmt->dropped) { + dInfo("bnode has been deployed and needs to be deleted"); + bndDestroy(pDnode->dir.bnode); + return 0; + } + if (!pMgmt->deployed) return 0; return dndOpenBnode(pDnode); diff --git a/source/dnode/mgmt/impl/src/dndMnode.c b/source/dnode/mgmt/impl/src/dndMnode.c index 59f809489e..8fb95c0b75 100644 --- a/source/dnode/mgmt/impl/src/dndMnode.c +++ b/source/dnode/mgmt/impl/src/dndMnode.c @@ -17,42 +17,9 @@ #include "dndMnode.h" #include "dndDnode.h" #include "dndTransport.h" +#include "dndWorker.h" -static int32_t dndInitMnodeReadWorker(SDnode *pDnode); -static int32_t dndInitMnodeWriteWorker(SDnode *pDnode); -static int32_t dndInitMnodeSyncWorker(SDnode *pDnode); -static void dndCleanupMnodeReadWorker(SDnode *pDnode); -static void dndCleanupMnodeWriteWorker(SDnode *pDnode); -static void dndCleanupMnodeSyncWorker(SDnode *pDnode); -static void dndCleanupMnodeMgmtWorker(SDnode *pDnode); -static int32_t dndAllocMnodeReadQueue(SDnode *pDnode); -static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode); -static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode); -static void dndFreeMnodeReadQueue(SDnode *pDnode); -static void dndFreeMnodeWriteQueue(SDnode *pDnode); -static void dndFreeMnodeSyncQueue(SDnode *pDnode); -static void dndFreeMnodeMgmtQueue(SDnode *pDnode); - -static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg); -static void dndProcessMnodeWriteQueue(SDnode *pDnode, SMnodeMsg *pMsg); -static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg); -static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg); -void dndProcessMnodeReadMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); -void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); -void dndProcessMnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet); - -static int32_t dndStartMnodeWorker(SDnode *pDnode); -static void dndStopMnodeWorker(SDnode *pDnode); - -static SMnode *dndAcquireMnode(SDnode *pDnode); -static void dndReleaseMnode(SDnode *pDnode, SMnode *pMnode); - -static int32_t dndReadMnodeFile(SDnode *pDnode); -static int32_t dndWriteMnodeFile(SDnode *pDnode); - -static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption); -static int32_t dndAlterMnode(SDnode *pDnode, SMnodeOpt *pOption); -static int32_t dndDropMnode(SDnode *pDnode); +static void dndProcessMnodeQueue(SDnode *pDnode, SMnodeMsg *pMsg); static SMnode *dndAcquireMnode(SDnode *pDnode) { SMnodeMgmt *pMgmt = &pDnode->mmgmt; @@ -97,49 +64,52 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) { char *content = calloc(1, maxLen + 1); cJSON *root = NULL; - FILE *fp = fopen(pMgmt->file, "r"); + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/mnode.json", pDnode->dir.dnode); + + FILE *fp = fopen(file, "r"); if (fp == NULL) { - dDebug("file %s not exist", pMgmt->file); + dDebug("file %s not exist", file); code = 0; goto PRASE_MNODE_OVER; } len = (int32_t)fread(content, 1, maxLen, fp); if (len <= 0) { - dError("failed to read %s since content is null", pMgmt->file); + dError("failed to read %s since content is null", file); goto PRASE_MNODE_OVER; } content[len] = 0; root = cJSON_Parse(content); if (root == NULL) { - dError("failed to read %s since invalid json format", pMgmt->file); + dError("failed to read %s since invalid json format", file); goto PRASE_MNODE_OVER; } cJSON *deployed = cJSON_GetObjectItem(root, "deployed"); if (!deployed || deployed->type != cJSON_Number) { - dError("failed to read %s since deployed not found", pMgmt->file); + dError("failed to read %s since deployed not found", file); goto PRASE_MNODE_OVER; } pMgmt->deployed = deployed->valueint; cJSON *dropped = cJSON_GetObjectItem(root, "dropped"); if (!dropped || dropped->type != cJSON_Number) { - dError("failed to read %s since dropped not found", pMgmt->file); + dError("failed to read %s since dropped not found", file); goto PRASE_MNODE_OVER; } pMgmt->dropped = dropped->valueint; cJSON *mnodes = cJSON_GetObjectItem(root, "mnodes"); if (!mnodes || mnodes->type != cJSON_Array) { - dError("failed to read %s since nodes not found", pMgmt->file); + dError("failed to read %s since nodes not found", file); goto PRASE_MNODE_OVER; } pMgmt->replica = cJSON_GetArraySize(mnodes); if (pMgmt->replica <= 0 || pMgmt->replica > TSDB_MAX_REPLICA) { - dError("failed to read %s since mnodes size %d invalid", pMgmt->file, pMgmt->replica); + dError("failed to read %s since mnodes size %d invalid", file, pMgmt->replica); goto PRASE_MNODE_OVER; } @@ -151,28 +121,28 @@ static int32_t dndReadMnodeFile(SDnode *pDnode) { cJSON *id = cJSON_GetObjectItem(node, "id"); if (!id || id->type != cJSON_Number) { - dError("failed to read %s since id not found", pMgmt->file); + dError("failed to read %s since id not found", file); goto PRASE_MNODE_OVER; } pReplica->id = id->valueint; cJSON *fqdn = cJSON_GetObjectItem(node, "fqdn"); if (!fqdn || fqdn->type != cJSON_String || fqdn->valuestring == NULL) { - dError("failed to read %s since fqdn not found", pMgmt->file); + dError("failed to read %s since fqdn not found", file); goto PRASE_MNODE_OVER; } tstrncpy(pReplica->fqdn, fqdn->valuestring, TSDB_FQDN_LEN); cJSON *port = cJSON_GetObjectItem(node, "port"); if (!port || port->type != cJSON_Number) { - dError("failed to read %s since port not found", pMgmt->file); + dError("failed to read %s since port not found", file); goto PRASE_MNODE_OVER; } pReplica->port = port->valueint; } code = 0; - dDebug("succcessed to read file %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); + dDebug("succcessed to read file %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); PRASE_MNODE_OVER: if (content != NULL) free(content); @@ -186,8 +156,8 @@ PRASE_MNODE_OVER: static int32_t dndWriteMnodeFile(SDnode *pDnode) { SMnodeMgmt *pMgmt = &pDnode->mmgmt; - char file[PATH_MAX + 20] = {0}; - snprintf(file, sizeof(file), "%s.bak", pMgmt->file); + char file[PATH_MAX + 20]; + snprintf(file, PATH_MAX + 20, "%s/mnode.json.bak", pDnode->dir.dnode); FILE *fp = fopen(file, "w"); if (fp == NULL) { @@ -223,47 +193,36 @@ static int32_t dndWriteMnodeFile(SDnode *pDnode) { fclose(fp); free(content); - if (taosRenameFile(file, pMgmt->file) != 0) { + char realfile[PATH_MAX + 20]; + snprintf(realfile, PATH_MAX + 20, "%s/mnode.json", pDnode->dir.dnode); + + if (taosRenameFile(file, realfile) != 0) { terrno = TSDB_CODE_DND_MNODE_WRITE_FILE_ERROR; - dError("failed to rename %s since %s", pMgmt->file, terrstr()); + dError("failed to rename %s since %s", file, terrstr()); return -1; } - dInfo("successed to write %s, deployed:%d dropped:%d", pMgmt->file, pMgmt->deployed, pMgmt->dropped); + dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped); return 0; } static int32_t dndStartMnodeWorker(SDnode *pDnode) { - if (dndInitMnodeReadWorker(pDnode) != 0) { + SMnodeMgmt *pMgmt = &pDnode->mmgmt; + if (dndInitWorker(pDnode, &pMgmt->readWorker, DND_WORKER_SINGLE, "mnode-read", 0, 1, dndProcessMnodeQueue) != 0) { dError("failed to start mnode read worker since %s", terrstr()); return -1; } - if (dndInitMnodeWriteWorker(pDnode) != 0) { + if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "mnode-write", 0, 1, dndProcessMnodeQueue) != 0) { dError("failed to start mnode write worker since %s", terrstr()); return -1; } - if (dndInitMnodeSyncWorker(pDnode) != 0) { + if (dndInitWorker(pDnode, &pMgmt->syncWorker, DND_WORKER_SINGLE, "mnode-sync", 0, 1, dndProcessMnodeQueue) != 0) { dError("failed to start mnode sync worker since %s", terrstr()); return -1; } - if (dndAllocMnodeReadQueue(pDnode) != 0) { - dError("failed to alloc mnode read queue since %s", terrstr()); - return -1; - } - - if (dndAllocMnodeWriteQueue(pDnode) != 0) { - dError("failed to alloc mnode write queue since %s", terrstr()); - return -1; - } - - if (dndAllocMnodeSyncQueue(pDnode) != 0) { - dError("failed to alloc mnode sync queue since %s", terrstr()); - return -1; - } - return 0; } @@ -274,18 +233,13 @@ static void dndStopMnodeWorker(SDnode *pDnode) { pMgmt->deployed = 0; taosWUnLockLatch(&pMgmt->latch); - while (pMgmt->refCount > 1) taosMsleep(10); - while (!taosQueueEmpty(pMgmt->pReadQ)) taosMsleep(10); - while (!taosQueueEmpty(pMgmt->pWriteQ)) taosMsleep(10); - while (!taosQueueEmpty(pMgmt->pSyncQ)) taosMsleep(10); + while (pMgmt->refCount > 1) { + taosMsleep(10); + } - dndCleanupMnodeReadWorker(pDnode); - dndCleanupMnodeWriteWorker(pDnode); - dndCleanupMnodeSyncWorker(pDnode); - - dndFreeMnodeReadQueue(pDnode); - dndFreeMnodeWriteQueue(pDnode); - dndFreeMnodeSyncQueue(pDnode); + dndCleanupWorker(&pMgmt->readWorker); + dndCleanupWorker(&pMgmt->writeWorker); + dndCleanupWorker(&pMgmt->syncWorker); } static bool dndNeedDeployMnode(SDnode *pDnode) { @@ -383,28 +337,21 @@ static int32_t dndOpenMnode(SDnode *pDnode, SMnodeOpt *pOption) { dError("failed to open mnode since %s", terrstr()); return -1; } - pMgmt->deployed = 1; - int32_t code = dndWriteMnodeFile(pDnode); - if (code != 0) { - dError("failed to write mnode file since %s", terrstr()); - code = terrno; - pMgmt->deployed = 0; + if (dndStartMnodeWorker(pDnode) != 0) { + dError("failed to start mnode worker since %s", terrstr()); mndClose(pMnode); mndDestroy(pDnode->dir.mnode); - terrno = code; return -1; } - code = dndStartMnodeWorker(pDnode); - if (code != 0) { - dError("failed to start mnode worker since %s", terrstr()); - code = terrno; + pMgmt->deployed = 1; + if (dndWriteMnodeFile(pDnode) != 0) { + dError("failed to write mnode file since %s", terrstr()); pMgmt->deployed = 0; dndStopMnodeWorker(pDnode); mndClose(pMnode); mndDestroy(pDnode->dir.mnode); - terrno = code; return -1; } @@ -461,6 +408,7 @@ static int32_t dndDropMnode(SDnode *pDnode) { dndReleaseMnode(pDnode, pMnode); dndStopMnodeWorker(pDnode); + pMgmt->deployed = 0; dndWriteMnodeFile(pDnode); mndClose(pMnode); pMgmt->pMnode = NULL; @@ -528,13 +476,12 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg) { } } - -static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) { +static void dndProcessMnodeQueue(SDnode *pDnode, SMnodeMsg *pMsg) { SMnodeMgmt *pMgmt = &pDnode->mmgmt; SMnode *pMnode = dndAcquireMnode(pDnode); if (pMnode != NULL) { - mndProcessReadMsg(pMsg); + mndProcessMsg(pMsg); dndReleaseMnode(pDnode, pMnode); } else { mndSendRsp(pMsg, terrno); @@ -543,208 +490,43 @@ static void dndProcessMnodeReadQueue(SDnode *pDnode, SMnodeMsg *pMsg) { mndCleanupMsg(pMsg); } -static void dndProcessMnodeWriteQueue(SDnode *pDnode, SMnodeMsg *pMsg) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; +static void dndWriteMnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pRpcMsg) { + int32_t code = TSDB_CODE_DND_MNODE_NOT_DEPLOYED; SMnode *pMnode = dndAcquireMnode(pDnode); if (pMnode != NULL) { - mndProcessWriteMsg(pMsg); - dndReleaseMnode(pDnode, pMnode); - } else { - mndSendRsp(pMsg, terrno); + SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg); + if (pMsg == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + } else { + code = dndWriteMsgToWorker(pWorker, pMsg, 0); + } + + if (code != 0) { + mndCleanupMsg(pMsg); + } } + dndReleaseMnode(pDnode, pMnode); - mndCleanupMsg(pMsg); -} - -static void dndProcessMnodeSyncQueue(SDnode *pDnode, SMnodeMsg *pMsg) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - - SMnode *pMnode = dndAcquireMnode(pDnode); - if (pMnode != NULL) { - mndProcessSyncMsg(pMsg); - dndReleaseMnode(pDnode, pMnode); - } else { - mndSendRsp(pMsg, terrno); + if (code != 0) { + if (pRpcMsg->msgType & 1u) { + SRpcMsg rsp = {.handle = pRpcMsg->handle, .ahandle = pRpcMsg->ahandle, .code = code}; + rpcSendResponse(&rsp); + } + rpcFreeCont(pRpcMsg->pCont); } - - mndCleanupMsg(pMsg); -} - -static int32_t dndWriteMnodeMsgToQueue(SMnode *pMnode, taos_queue pQueue, SRpcMsg *pRpcMsg) { - SMnodeMsg *pMsg = mndInitMsg(pMnode, pRpcMsg); - if (pMsg == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - if (taosWriteQitem(pQueue, pMsg) != 0) { - mndCleanupMsg(pMsg); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - return 0; } void dndProcessMnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SMnode *pMnode = dndAcquireMnode(pDnode); - if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pWriteQ, pMsg) != 0) { - if (pMsg->msgType & 1u) { - SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno}; - rpcSendResponse(&rsp); - } - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; - } - - dndReleaseMnode(pDnode, pMnode); + dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.writeWorker, pMsg); } void dndProcessMnodeSyncMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SMnode *pMnode = dndAcquireMnode(pDnode); - if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pSyncQ, pMsg) != 0) { - if (pMsg->msgType & 1u) { - SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno}; - rpcSendResponse(&rsp); - } - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; - } - - dndReleaseMnode(pDnode, pMnode); + dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.syncWorker, pMsg); } void dndProcessMnodeReadMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SMnode *pMnode = dndAcquireMnode(pDnode); - if (pMnode == NULL || dndWriteMnodeMsgToQueue(pMnode, pMgmt->pReadQ, pMsg) != 0) { - if (pMsg->msgType & 1u) { - SRpcMsg rsp = {.handle = pMsg->handle, .code = terrno}; - rpcSendResponse(&rsp); - } - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; - } - - dndReleaseMnode(pDnode, pMnode); -} - - -static int32_t dndAllocMnodeReadQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - pMgmt->pReadQ = tWorkerAllocQueue(&pMgmt->readPool, pDnode, (FProcessItem)dndProcessMnodeReadQueue); - if (pMgmt->pReadQ == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - return 0; -} - -static void dndFreeMnodeReadQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerFreeQueue(&pMgmt->readPool, pMgmt->pReadQ); - pMgmt->pReadQ = NULL; -} - -static int32_t dndInitMnodeReadWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SWorkerPool *pPool = &pMgmt->readPool; - pPool->name = "mnode-read"; - pPool->min = 0; - pPool->max = 1; - if (tWorkerInit(pPool) != 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - dDebug("mnode read worker is initialized"); - return 0; -} - -static void dndCleanupMnodeReadWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerCleanup(&pMgmt->readPool); - dDebug("mnode read worker is closed"); -} - -static int32_t dndAllocMnodeWriteQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - pMgmt->pWriteQ = tWorkerAllocQueue(&pMgmt->writePool, pDnode, (FProcessItem)dndProcessMnodeWriteQueue); - if (pMgmt->pWriteQ == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - return 0; -} - -static void dndFreeMnodeWriteQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerFreeQueue(&pMgmt->writePool, pMgmt->pWriteQ); - pMgmt->pWriteQ = NULL; -} - -static int32_t dndInitMnodeWriteWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SWorkerPool *pPool = &pMgmt->writePool; - pPool->name = "mnode-write"; - pPool->min = 0; - pPool->max = 1; - if (tWorkerInit(pPool) != 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - dDebug("mnode write worker is initialized"); - return 0; -} - -static void dndCleanupMnodeWriteWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerCleanup(&pMgmt->writePool); - dDebug("mnode write worker is closed"); -} - -static int32_t dndAllocMnodeSyncQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - pMgmt->pSyncQ = tWorkerAllocQueue(&pMgmt->syncPool, pDnode, (FProcessItem)dndProcessMnodeSyncQueue); - if (pMgmt->pSyncQ == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - return 0; -} - -static void dndFreeMnodeSyncQueue(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerFreeQueue(&pMgmt->syncPool, pMgmt->pSyncQ); - pMgmt->pSyncQ = NULL; -} - -static int32_t dndInitMnodeSyncWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - SWorkerPool *pPool = &pMgmt->syncPool; - pPool->name = "mnode-sync"; - pPool->min = 0; - pPool->max = 1; - if (tWorkerInit(pPool) != 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - dDebug("mnode sync worker is initialized"); - return 0; -} - -static void dndCleanupMnodeSyncWorker(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - tWorkerCleanup(&pMgmt->syncPool); - dDebug("mnode sync worker is closed"); + dndWriteMnodeMsgToWorker(pDnode, &pDnode->mmgmt.readWorker, pMsg); } int32_t dndInitMnode(SDnode *pDnode) { @@ -752,14 +534,6 @@ int32_t dndInitMnode(SDnode *pDnode) { SMnodeMgmt *pMgmt = &pDnode->mmgmt; taosInitRWLatch(&pMgmt->latch); - char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/mnode.json", pDnode->dir.dnode); - pMgmt->file = strdup(path); - if (pMgmt->file == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - if (dndReadMnodeFile(pDnode) != 0) { return -1; } @@ -790,13 +564,13 @@ int32_t dndInitMnode(SDnode *pDnode) { } void dndCleanupMnode(SDnode *pDnode) { - SMnodeMgmt *pMgmt = &pDnode->mmgmt; - dInfo("dnode-mnode start to clean up"); - if (pMgmt->pMnode) dndStopMnodeWorker(pDnode); - tfree(pMgmt->file); - mndClose(pMgmt->pMnode); - pMgmt->pMnode = NULL; + SMnodeMgmt *pMgmt = &pDnode->mmgmt; + if (pMgmt->pMnode) { + dndStopMnodeWorker(pDnode); + mndClose(pMgmt->pMnode); + pMgmt->pMnode = NULL; + } dInfo("dnode-mnode is cleaned up"); } diff --git a/source/dnode/mgmt/impl/src/dndQnode.c b/source/dnode/mgmt/impl/src/dndQnode.c index 0b92de81c1..5d04a4f449 100644 --- a/source/dnode/mgmt/impl/src/dndQnode.c +++ b/source/dnode/mgmt/impl/src/dndQnode.c @@ -140,26 +140,27 @@ static int32_t dndWriteQnodeFile(SDnode *pDnode) { fclose(fp); free(content); - if (taosRenameFile(file, file) != 0) { + char realfile[PATH_MAX + 20]; + snprintf(realfile, PATH_MAX + 20, "%s/qnode.json", pDnode->dir.dnode); + + if (taosRenameFile(file, realfile) != 0) { terrno = TSDB_CODE_DND_QNODE_WRITE_FILE_ERROR; dError("failed to rename %s since %s", file, terrstr()); return -1; } - dInfo("successed to write %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped); return 0; } static int32_t dndStartQnodeWorker(SDnode *pDnode) { SQnodeMgmt *pMgmt = &pDnode->qmgmt; - if (dndInitWorker(pDnode, &pMgmt->queryWorker, DND_WORKER_SINGLE, "qnode-query", 0, 1, - (FProcessItem)dndProcessQnodeQueue) != 0) { + if (dndInitWorker(pDnode, &pMgmt->queryWorker, DND_WORKER_SINGLE, "qnode-query", 0, 1, dndProcessQnodeQueue) != 0) { dError("failed to start qnode query worker since %s", terrstr()); return -1; } - if (dndInitWorker(pDnode, &pMgmt->fetchWorker, DND_WORKER_SINGLE, "qnode-fetch", 0, 1, - (FProcessItem)dndProcessQnodeQueue) != 0) { + if (dndInitWorker(pDnode, &pMgmt->fetchWorker, DND_WORKER_SINGLE, "qnode-fetch", 0, 1, dndProcessQnodeQueue) != 0) { dError("failed to start qnode fetch worker since %s", terrstr()); return -1; } @@ -209,7 +210,9 @@ static int32_t dndOpenQnode(SDnode *pDnode) { return -1; } + pMgmt->deployed = 1; if (dndWriteQnodeFile(pDnode) != 0) { + pMgmt->deployed = 0; dError("failed to write qnode file since %s", terrstr()); dndStopQnodeWorker(pDnode); qndClose(pQnode); @@ -218,7 +221,6 @@ static int32_t dndOpenQnode(SDnode *pDnode) { taosWLockLatch(&pMgmt->latch); pMgmt->pQnode = pQnode; - pMgmt->deployed = 1; taosWUnLockLatch(&pMgmt->latch); dInfo("qnode open successfully"); @@ -250,6 +252,8 @@ static int32_t dndDropQnode(SDnode *pDnode) { dndReleaseQnode(pDnode, pQnode); dndStopQnodeWorker(pDnode); + pMgmt->deployed = 0; + dndWriteQnodeFile(pDnode); qndClose(pQnode); pMgmt->pQnode = NULL; diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index c1eb347350..151fc7e6a1 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -140,20 +140,22 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) { fclose(fp); free(content); - if (taosRenameFile(file, file) != 0) { + char realfile[PATH_MAX + 20]; + snprintf(realfile, PATH_MAX + 20, "%s/snode.json", pDnode->dir.dnode); + + if (taosRenameFile(file, realfile) != 0) { terrno = TSDB_CODE_DND_SNODE_WRITE_FILE_ERROR; dError("failed to rename %s since %s", file, terrstr()); return -1; } - dInfo("successed to write %s, deployed:%d dropped:%d", file, pMgmt->deployed, pMgmt->dropped); + dInfo("successed to write %s, deployed:%d dropped:%d", realfile, pMgmt->deployed, pMgmt->dropped); return 0; } static int32_t dndStartSnodeWorker(SDnode *pDnode) { SSnodeMgmt *pMgmt = &pDnode->smgmt; - if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, - (FProcessItem)dndProcessSnodeQueue) != 0) { + if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, dndProcessSnodeQueue) != 0) { dError("failed to start snode write worker since %s", terrstr()); return -1; } @@ -202,7 +204,9 @@ static int32_t dndOpenSnode(SDnode *pDnode) { return -1; } + pMgmt->deployed = 1; if (dndWriteSnodeFile(pDnode) != 0) { + pMgmt->deployed = 0; dError("failed to write snode file since %s", terrstr()); dndStopSnodeWorker(pDnode); sndClose(pSnode); @@ -211,7 +215,6 @@ static int32_t dndOpenSnode(SDnode *pDnode) { taosWLockLatch(&pMgmt->latch); pMgmt->pSnode = pSnode; - pMgmt->deployed = 1; taosWUnLockLatch(&pMgmt->latch); dInfo("snode open successfully"); @@ -243,6 +246,8 @@ static int32_t dndDropSnode(SDnode *pDnode) { dndReleaseSnode(pDnode, pSnode); dndStopSnodeWorker(pDnode); + pMgmt->deployed = 0; + dndWriteSnodeFile(pDnode); sndClose(pSnode); pMgmt->pSnode = NULL; sndDestroy(pDnode->dir.snode); @@ -328,7 +333,12 @@ int32_t dndInitSnode(SDnode *pDnode) { return -1; } - if (pMgmt->dropped) return 0; + if (pMgmt->dropped) { + dInfo("snode has been deployed and needs to be deleted"); + sndDestroy(pDnode->dir.snode); + return 0; + } + if (!pMgmt->deployed) return 0; return dndOpenSnode(pDnode); diff --git a/source/dnode/mgmt/impl/src/dndWorker.c b/source/dnode/mgmt/impl/src/dndWorker.c index c421437e4d..b1107fd185 100644 --- a/source/dnode/mgmt/impl/src/dndWorker.c +++ b/source/dnode/mgmt/impl/src/dndWorker.c @@ -73,7 +73,7 @@ void dndCleanupWorker(SDnodeWorker *pWorker) { tWorkerCleanup(&pWorker->pool); tWorkerFreeQueue(&pWorker->pool, pWorker->queue); } else if (pWorker->type == DND_WORKER_MULTI) { - tWorkerCleanup(&pWorker->mpool); + tMWorkerCleanup(&pWorker->mpool); tMWorkerFreeQueue(&pWorker->mpool, pWorker->queue); } else { } @@ -85,16 +85,23 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen) return -1; } - void *pMsg = taosAllocateQitem(contLen); + void *pMsg = NULL; + if (contLen != 0) { + pMsg = taosAllocateQitem(contLen); + if (pMsg != NULL) { + memcpy(pMsg, pCont, contLen); + } + } else { + pMsg = pCont; + } + if (pMsg == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - memcpy(pMsg, pCont, contLen); - - if (taosWriteQitem(pWorker, pMsg) != 0) { - taosFreeItem(pMsg); + if (taosWriteQitem(pWorker->queue, pMsg) != 0) { + taosFreeQitem(pMsg); terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } diff --git a/source/dnode/mgmt/impl/test/dnode/dnode.cpp b/source/dnode/mgmt/impl/test/dnode/dnode.cpp index dc352c5a3f..ec2c2d9a44 100644 --- a/source/dnode/mgmt/impl/test/dnode/dnode.cpp +++ b/source/dnode/mgmt/impl/test/dnode/dnode.cpp @@ -162,7 +162,7 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) { SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen); strcpy(pReq->fqdn, "localhost"); - pReq->port = htonl(904); + pReq->port = htonl(9044); SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen); ASSERT_NE(pMsg, nullptr); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 56559cbea1..2d236906e1 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -388,7 +388,7 @@ static int32_t mndCreateDnode(SMnode *pMnode, SMnodeMsg *pMsg, SCreateDnodeMsg * dnodeObj.updateTime = dnodeObj.createdTime; dnodeObj.port = pCreate->port; memcpy(dnodeObj.fqdn, pCreate->fqdn, TSDB_FQDN_LEN); - snprintf(dnodeObj.ep, "%s:%u", dnodeObj.fqdn, dnodeObj.port); + snprintf(dnodeObj.ep, TSDB_EP_LEN, "%s:%u", dnodeObj.fqdn, dnodeObj.port); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); if (pTrans == NULL) { diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 64ea85044a..9281e46f4f 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -390,7 +390,7 @@ void mndSendRsp(SMnodeMsg *pMsg, int32_t code) { rpcSendResponse(&rpcRsp); } -static void mndProcessRpcMsg(SMnodeMsg *pMsg) { +void mndProcessMsg(SMnodeMsg *pMsg) { SMnode *pMnode = pMsg->pMnode; int32_t code = 0; tmsg_t msgType = pMsg->rpcMsg.msgType; @@ -451,12 +451,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { } } -void mndProcessReadMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); } - -void mndProcessWriteMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); } - -void mndProcessSyncMsg(SMnodeMsg *pMsg) { mndProcessRpcMsg(pMsg); } - uint64_t mndGenerateUid(char *name, int32_t len) { int64_t us = taosGetTimestampUs(); int32_t hashval = MurmurHash3_32(name, len); diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 2f80af225a..6c99411b71 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -428,6 +428,7 @@ SDropDnodeMsg *buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf char* end = NULL; SDropDnodeMsg * pDrop = (SDropDnodeMsg *)calloc(1, sizeof(SDropDnodeMsg)); pDrop->dnodeId = strtoll(pzName->z, &end, 10); + pDrop->dnodeId = htonl(pDrop->dnodeId); *len = sizeof(SDropDnodeMsg); if (end - pzName->z != pzName->n) { diff --git a/tests/script/unique/dnode/basic1.sim b/tests/script/unique/dnode/basic1.sim index 730864ef26..49b29a4ac8 100644 --- a/tests/script/unique/dnode/basic1.sim +++ b/tests/script/unique/dnode/basic1.sim @@ -94,5 +94,16 @@ if $rows != 2 then return -1 endi +print =============== drop dnode +sql drop dnode 2; +sql show dnodes; +if $rows != 1 then + return -1 +endi + +if $data00 != 1 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT \ No newline at end of file From a07462211586880e252a4b09cd35a663162ba154 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 18:02:15 +0800 Subject: [PATCH 19/55] more --- include/util/encode.h | 281 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 include/util/encode.h diff --git a/include/util/encode.h b/include/util/encode.h new file mode 100644 index 0000000000..5a13f80a7d --- /dev/null +++ b/include/util/encode.h @@ -0,0 +1,281 @@ +/* + * 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_UTIL_ENCODE_H_ +#define _TD_UTIL_ENCODE_H_ + +#include "os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + td_endian_t endian; + uint8_t* data; + int64_t size; + int64_t pos; +} SEncoder; + +typedef struct { + td_endian_t endian; + const uint8_t* data; + int64_t size; + int16_t pos; +} SDecoder; + +#define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL) +#define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0] + +#define tRPut16(PDEST, PSRC) \ + ((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[1]; \ + ((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[0]; + +#define tRPut32(PDEST, PSRC) \ + ((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[3]; \ + ((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[2]; \ + ((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[1]; \ + ((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[0]; + +#define tRPut64(PDEST, PSRC) \ + ((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[7]; \ + ((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[6]; \ + ((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[5]; \ + ((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[4]; \ + ((uint8_t*)(PDEST))[4] = ((uint8_t*)(PSRC))[3]; \ + ((uint8_t*)(PDEST))[5] = ((uint8_t*)(PSRC))[2]; \ + ((uint8_t*)(PDEST))[6] = ((uint8_t*)(PSRC))[1]; \ + ((uint8_t*)(PDEST))[7] = ((uint8_t*)(PSRC))[0]; + +#define tRGet16 tRPut16 +#define tRGet32 tRPut32 +#define tRGet64 tRPut64 + +#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos) +#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE)) +#define TD_CHECK_CODER_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE)) + +/* ------------------------ FOR ENCODER ------------------------ */ +static FORCE_INLINE void tInitEncoder(SEncoder* pEncoder, td_endian_t endian, uint8_t* data, int64_t size) { + pEncoder->endian = endian; + pEncoder->data = data; + pEncoder->size = (data) ? size : 0; + pEncoder->pos = 0; +} + +// 8 +static FORCE_INLINE int tEncodeU8(SEncoder* pEncoder, uint8_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + tPut(uint8_t, TD_CODER_CURRENT(pEncoder), val); + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +static FORCE_INLINE int tEncodeI8(SEncoder* pEncoder, int8_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + tPut(int8_t, TD_CODER_CURRENT(pEncoder), val); + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +// 16 +static FORCE_INLINE int tEncodeU16(SEncoder* pEncoder, uint16_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(uint16_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut16(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +static FORCE_INLINE void tEncodeI16(SEncoder* pEncoder, int16_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(int16_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut16(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +// 32 +static FORCE_INLINE void tEncodeU32(SEncoder* pEncoder, uint32_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(uint32_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut32(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +static FORCE_INLINE void tEncodeI32(SEncoder* pEncoder, int32_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(int32_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut32(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +// 64 +static FORCE_INLINE void tEncodeU64(SEncoder* pEncoder, uint64_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(uint64_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut64(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +static FORCE_INLINE void tEncodeI32(SEncoder* pEncoder, int32_t val) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; + if (TD_RT_ENDIAN() == pEncoder->endian) { + tPut(int32_t, TD_CODER_CURRENT(pEncoder), val); + } else { + tRPut64(TD_CODER_CURRENT(pEncoder), &val); + } + } + TD_CODER_MOVE_POS(pEncoder, sizeof(val)); + return 0; +} + +/* ------------------------ FOR DECODER ------------------------ */ +static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, const uint8_t* data, int64_t size) { + ASSERT(!TD_IS_NULL(data)); + pDecoder->endian = endian; + pDecoder->data = data; + pDecoder->size = size; + pDecoder->pos = 0; +} + +// 8 +static FORCER_INLINE int tDecodeU8(SDecoder* pDecoder, uint8_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + tGet(uint8_t, TD_CODER_CURRENT(pDecoder), *val); + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +static FORCER_INLINE int tDecodeI8(SDecoder* pDecoder, int8_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + tGet(int8_t, TD_CODER_CURRENT(pDecoder), *val); + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +// 16 +static FORCER_INLINE int tDecodeU16(SDecoder* pDecoder, uint16_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(uint16_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet16(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +static FORCER_INLINE int tDecodeI16(SDecoder* pDecoder, int16_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(int16_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet16(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +// 32 +static FORCER_INLINE int tDecodeU32(SDecoder* pDecoder, uint32_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(uint32_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet32(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +static FORCER_INLINE int tDecodeI32(SDecoder* pDecoder, int32_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(int32_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet32(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +// 64 +static FORCER_INLINE int tDecodeU64(SDecoder* pDecoder, uint64_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(uint64_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet64(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +static FORCER_INLINE int tDecodeI64(SDecoder* pDecoder, int64_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; + if (TD_RT_ENDIAN() == pDecoder->endian) { + tGet(int64_t, TD_CODER_CURRENT(pDecoder), *val); + } else { + tRGet64(val, TD_CODER_CURRENT(pDecoder)); + } + + TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_UTIL_ENCODE_H_*/ \ No newline at end of file From 16b5db3ee439731f05be2f3968ba77d62f048e6c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 28 Dec 2021 18:02:36 +0800 Subject: [PATCH 20/55] add index write test --- source/libs/index/test/indexTests.cc | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc index 17733dd284..c75177b884 100644 --- a/source/libs/index/test/indexTests.cc +++ b/source/libs/index/test/indexTests.cc @@ -592,3 +592,91 @@ TEST_F(IndexCacheEnv, cache_test) { assert(taosArrayGetSize(ret) == 1); } } +class IndexObj { + public: + IndexObj() { + // opt + numOfWrite = 0; + numOfRead = 0; + indexInit(); + } + int Init(const std::string& dir) { + taosRemoveDir(dir.c_str()); + taosMkDir(dir.c_str()); + int ret = indexOpen(&opts, dir.c_str(), &idx); + if (ret != 0) { + // opt + std::cout << "failed to open index: %s" << dir << std::endl; + } + return ret; + } + int Put(SIndexMultiTerm* fvs, uint64_t uid) { + numOfWrite += taosArrayGetSize(fvs); + return indexPut(idx, fvs, uid); + } + int Search(SIndexMultiTermQuery* multiQ, SArray* result) { + SArray* query = multiQ->query; + numOfRead = taosArrayGetSize(query); + return indexSearch(idx, multiQ, result); + } + + void Debug() { + std::cout << "numOfWrite:" << numOfWrite << std::endl; + std::cout << "numOfRead:" << numOfRead << std::endl; + } + + ~IndexObj() { + indexClose(idx); + indexCleanUp(); + } + + private: + SIndexOpts opts; + SIndex* idx; + int numOfWrite; + int numOfRead; +}; + +class IndexEnv2 : public ::testing::Test { + protected: + virtual void SetUp() { + index = new IndexObj(); + // + } + virtual void TearDown() { + // r + delete index; + } + IndexObj* index; +}; +TEST_F(IndexEnv2, testIndexOpen) { + std::string path = "/tmp"; + if (index->Init(path) != 0) {} + std::string colName("tag1"), colVal("Hello world"); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexMultiTerm* terms = indexMultiTermCreate(); + indexMultiTermAdd(terms, term); + for (size_t i = 0; i < 100; i++) { + int tableId = i; + int ret = index->Put(terms, tableId); + assert(ret == 0); + } + indexMultiTermDestroy(terms); +} +TEST_F(IndexEnv2, testIndex_CachePut) { + std::string path = "/tmp"; + if (index->Init(path) != 0) {} +} + +TEST_F(IndexEnv2, testIndexr_TFilePut) { + std::string path = "/tmp"; + if (index->Init(path) != 0) {} +} +TEST_F(IndexEnv2, testIndex_CacheSearch) { + std::string path = "/tmp"; + if (index->Init(path) != 0) {} +} +TEST_F(IndexEnv2, testIndex_TFileSearch) { + std::string path = "/tmp"; + if (index->Init(path) != 0) {} +} From 070562ae57c26df4bb8b3c218d96d130c2ccd7e9 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 18:12:39 +0800 Subject: [PATCH 21/55] refact --- include/util/encode.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index 5a13f80a7d..aaeab8dc38 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -108,7 +108,7 @@ static FORCE_INLINE int tEncodeU16(SEncoder* pEncoder, uint16_t val) { return 0; } -static FORCE_INLINE void tEncodeI16(SEncoder* pEncoder, int16_t val) { +static FORCE_INLINE int tEncodeI16(SEncoder* pEncoder, int16_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { @@ -122,7 +122,7 @@ static FORCE_INLINE void tEncodeI16(SEncoder* pEncoder, int16_t val) { } // 32 -static FORCE_INLINE void tEncodeU32(SEncoder* pEncoder, uint32_t val) { +static FORCE_INLINE int tEncodeU32(SEncoder* pEncoder, uint32_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { @@ -135,7 +135,7 @@ static FORCE_INLINE void tEncodeU32(SEncoder* pEncoder, uint32_t val) { return 0; } -static FORCE_INLINE void tEncodeI32(SEncoder* pEncoder, int32_t val) { +static FORCE_INLINE int tEncodeI32(SEncoder* pEncoder, int32_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { @@ -149,7 +149,7 @@ static FORCE_INLINE void tEncodeI32(SEncoder* pEncoder, int32_t val) { } // 64 -static FORCE_INLINE void tEncodeU64(SEncoder* pEncoder, uint64_t val) { +static FORCE_INLINE int tEncodeU64(SEncoder* pEncoder, uint64_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { @@ -162,7 +162,7 @@ static FORCE_INLINE void tEncodeU64(SEncoder* pEncoder, uint64_t val) { return 0; } -static FORCE_INLINE void tEncodeI32(SEncoder* pEncoder, int32_t val) { +static FORCE_INLINE int tEncodeI32(SEncoder* pEncoder, int32_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { From 6ab7c7e87806d8cb322b134bbbe8ad6f382b36e7 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 28 Dec 2021 18:17:13 +0800 Subject: [PATCH 22/55] [td-11818]support ip as the dnode name. --- source/client/test/clientTests.cpp | 14 +- source/libs/parser/inc/sql.y | 3 +- source/libs/parser/inc/ttokendef.h | 197 +-- source/libs/parser/src/astToMsg.c | 2 +- source/libs/parser/src/dCDAstProcess.c | 8 +- source/libs/parser/src/sql.c | 2176 ++++++++++++------------ 6 files changed, 1201 insertions(+), 1199 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 83d0e61eb3..cbd128f4da 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -177,14 +177,14 @@ TEST(testCase, create_dnode_Test) { if (taos_errno(pRes) != 0) { printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); } - - TAOS_FIELD* pFields = taos_fetch_fields(pRes); - ASSERT_TRUE(pFields == NULL); - - int32_t numOfFields = taos_num_fields(pRes); - ASSERT_EQ(numOfFields, 0); - taos_free_result(pRes); + + pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000"); + if (taos_errno(pRes) != 0) { + printf("failed to create dnode, reason:%s\n", taos_errstr(pRes)); + } + taos_free_result(pRes); + taos_close(pConn); } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index ed4ad1c0b7..7f23577060 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -200,7 +200,8 @@ ifnotexists(X) ::= . { X.n = 0;} /////////////////////////////////THE CREATE STATEMENT/////////////////////////////////////// //create option for dnode/db/user/account -cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);} +cmd ::= CREATE DNODE ids(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);} +cmd ::= CREATE DNODE IPTOKEN(X) PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y);} cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);} cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);} diff --git a/source/libs/parser/inc/ttokendef.h b/source/libs/parser/inc/ttokendef.h index f998262a96..d6adda5d45 100644 --- a/source/libs/parser/inc/ttokendef.h +++ b/source/libs/parser/inc/ttokendef.h @@ -104,104 +104,104 @@ #define TK_IF 86 #define TK_EXISTS 87 #define TK_PORT 88 -#define TK_AS 89 -#define TK_OUTPUTTYPE 90 -#define TK_AGGREGATE 91 -#define TK_BUFSIZE 92 -#define TK_PPS 93 -#define TK_TSERIES 94 -#define TK_DBS 95 -#define TK_STORAGE 96 -#define TK_QTIME 97 -#define TK_CONNS 98 -#define TK_STATE 99 -#define TK_COMMA 100 -#define TK_KEEP 101 -#define TK_CACHE 102 -#define TK_REPLICA 103 -#define TK_QUORUM 104 -#define TK_DAYS 105 -#define TK_MINROWS 106 -#define TK_MAXROWS 107 -#define TK_BLOCKS 108 -#define TK_CTIME 109 -#define TK_WAL 110 -#define TK_FSYNC 111 -#define TK_COMP 112 -#define TK_PRECISION 113 -#define TK_UPDATE 114 -#define TK_CACHELAST 115 -#define TK_UNSIGNED 116 -#define TK_TAGS 117 -#define TK_USING 118 -#define TK_NULL 119 -#define TK_NOW 120 -#define TK_SELECT 121 -#define TK_UNION 122 -#define TK_ALL 123 -#define TK_DISTINCT 124 -#define TK_FROM 125 -#define TK_VARIABLE 126 -#define TK_INTERVAL 127 -#define TK_EVERY 128 -#define TK_SESSION 129 -#define TK_STATE_WINDOW 130 -#define TK_FILL 131 -#define TK_SLIDING 132 -#define TK_ORDER 133 -#define TK_BY 134 -#define TK_ASC 135 -#define TK_GROUP 136 -#define TK_HAVING 137 -#define TK_LIMIT 138 -#define TK_OFFSET 139 -#define TK_SLIMIT 140 -#define TK_SOFFSET 141 -#define TK_WHERE 142 -#define TK_RESET 143 -#define TK_QUERY 144 -#define TK_SYNCDB 145 -#define TK_ADD 146 -#define TK_COLUMN 147 -#define TK_MODIFY 148 -#define TK_TAG 149 -#define TK_CHANGE 150 -#define TK_SET 151 -#define TK_KILL 152 -#define TK_CONNECTION 153 -#define TK_STREAM 154 -#define TK_COLON 155 -#define TK_ABORT 156 -#define TK_AFTER 157 -#define TK_ATTACH 158 -#define TK_BEFORE 159 -#define TK_BEGIN 160 -#define TK_CASCADE 161 -#define TK_CLUSTER 162 -#define TK_CONFLICT 163 -#define TK_COPY 164 -#define TK_DEFERRED 165 -#define TK_DELIMITERS 166 -#define TK_DETACH 167 -#define TK_EACH 168 -#define TK_END 169 -#define TK_EXPLAIN 170 -#define TK_FAIL 171 -#define TK_FOR 172 -#define TK_IGNORE 173 -#define TK_IMMEDIATE 174 -#define TK_INITIALLY 175 -#define TK_INSTEAD 176 -#define TK_KEY 177 -#define TK_OF 178 -#define TK_RAISE 179 -#define TK_REPLACE 180 -#define TK_RESTRICT 181 -#define TK_ROW 182 -#define TK_STATEMENT 183 -#define TK_TRIGGER 184 -#define TK_VIEW 185 -#define TK_IPTOKEN 186 +#define TK_IPTOKEN 89 +#define TK_AS 90 +#define TK_OUTPUTTYPE 91 +#define TK_AGGREGATE 92 +#define TK_BUFSIZE 93 +#define TK_PPS 94 +#define TK_TSERIES 95 +#define TK_DBS 96 +#define TK_STORAGE 97 +#define TK_QTIME 98 +#define TK_CONNS 99 +#define TK_STATE 100 +#define TK_COMMA 101 +#define TK_KEEP 102 +#define TK_CACHE 103 +#define TK_REPLICA 104 +#define TK_QUORUM 105 +#define TK_DAYS 106 +#define TK_MINROWS 107 +#define TK_MAXROWS 108 +#define TK_BLOCKS 109 +#define TK_CTIME 110 +#define TK_WAL 111 +#define TK_FSYNC 112 +#define TK_COMP 113 +#define TK_PRECISION 114 +#define TK_UPDATE 115 +#define TK_CACHELAST 116 +#define TK_UNSIGNED 117 +#define TK_TAGS 118 +#define TK_USING 119 +#define TK_NULL 120 +#define TK_NOW 121 +#define TK_SELECT 122 +#define TK_UNION 123 +#define TK_ALL 124 +#define TK_DISTINCT 125 +#define TK_FROM 126 +#define TK_VARIABLE 127 +#define TK_INTERVAL 128 +#define TK_EVERY 129 +#define TK_SESSION 130 +#define TK_STATE_WINDOW 131 +#define TK_FILL 132 +#define TK_SLIDING 133 +#define TK_ORDER 134 +#define TK_BY 135 +#define TK_ASC 136 +#define TK_GROUP 137 +#define TK_HAVING 138 +#define TK_LIMIT 139 +#define TK_OFFSET 140 +#define TK_SLIMIT 141 +#define TK_SOFFSET 142 +#define TK_WHERE 143 +#define TK_RESET 144 +#define TK_QUERY 145 +#define TK_SYNCDB 146 +#define TK_ADD 147 +#define TK_COLUMN 148 +#define TK_MODIFY 149 +#define TK_TAG 150 +#define TK_CHANGE 151 +#define TK_SET 152 +#define TK_KILL 153 +#define TK_CONNECTION 154 +#define TK_STREAM 155 +#define TK_COLON 156 +#define TK_ABORT 157 +#define TK_AFTER 158 +#define TK_ATTACH 159 +#define TK_BEFORE 160 +#define TK_BEGIN 161 +#define TK_CASCADE 162 +#define TK_CLUSTER 163 +#define TK_CONFLICT 164 +#define TK_COPY 165 +#define TK_DEFERRED 166 +#define TK_DELIMITERS 167 +#define TK_DETACH 168 +#define TK_EACH 169 +#define TK_END 170 +#define TK_EXPLAIN 171 +#define TK_FAIL 172 +#define TK_FOR 173 +#define TK_IGNORE 174 +#define TK_IMMEDIATE 175 +#define TK_INITIALLY 176 +#define TK_INSTEAD 177 +#define TK_KEY 178 +#define TK_OF 179 +#define TK_RAISE 180 +#define TK_REPLACE 181 +#define TK_RESTRICT 182 +#define TK_ROW 183 +#define TK_STATEMENT 184 +#define TK_TRIGGER 185 +#define TK_VIEW 186 #define TK_SEMI 187 #define TK_NONE 188 #define TK_PREV 189 @@ -216,6 +216,7 @@ + #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 48bdf8d3e4..69694fbe08 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -388,7 +388,7 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs } SToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0); - if (id->type != TK_ID) { + if (id->type != TK_ID && id->type != TK_IPTOKEN) { buildInvalidOperationMsg(pMsgBuf, msg2); return NULL; } diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 7ff9596045..7d733bbeca 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -313,12 +313,8 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p return code; } - code = tNameGetTableName(&name, pCreateTableInfo->tagdata.name); - + const char* pStableName = tNameGetTableName(&name); SArray* pValList = pCreateTableInfo->pTagVals; - if (code != TSDB_CODE_SUCCESS) { - return code; - } size_t valSize = taosArrayGetSize(pValList); STableMeta* pSuperTableMeta = NULL; @@ -326,7 +322,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p char dbName[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(&name, dbName); - catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pCreateTableInfo->tagdata.name, &pSuperTableMeta); + catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pStableName, &pSuperTableMeta); // too long tag values will return invalid sql, not be truncated automatically SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index dd34b042fb..ac90b3b34a 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -130,17 +130,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 363 -#define YYNRULE 300 +#define YYNSTATE 365 +#define YYNRULE 301 #define YYNTOKEN 197 -#define YY_MAX_SHIFT 362 -#define YY_MIN_SHIFTREDUCE 581 -#define YY_MAX_SHIFTREDUCE 880 -#define YY_ERROR_ACTION 881 -#define YY_ACCEPT_ACTION 882 -#define YY_NO_ACTION 883 -#define YY_MIN_REDUCE 884 -#define YY_MAX_REDUCE 1183 +#define YY_MAX_SHIFT 364 +#define YY_MIN_SHIFTREDUCE 584 +#define YY_MAX_SHIFTREDUCE 884 +#define YY_ERROR_ACTION 885 +#define YY_ACCEPT_ACTION 886 +#define YY_NO_ACTION 887 +#define YY_MIN_REDUCE 888 +#define YY_MAX_REDUCE 1188 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -206,167 +206,168 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (778) +#define YY_ACTTAB_COUNT (783) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 95, 632, 36, 1027, 632, 21, 248, 710, 205, 633, - /* 10 */ 361, 229, 633, 55, 56, 1019, 59, 60, 161, 1159, - /* 20 */ 251, 49, 48, 47, 1068, 58, 320, 63, 61, 64, - /* 30 */ 62, 1016, 1017, 33, 1020, 54, 53, 340, 339, 52, - /* 40 */ 51, 50, 55, 56, 231, 59, 60, 242, 1030, 251, - /* 50 */ 49, 48, 47, 667, 58, 320, 63, 61, 64, 62, - /* 60 */ 202, 247, 882, 362, 54, 53, 205, 260, 52, 51, - /* 70 */ 50, 55, 56, 203, 59, 60, 175, 1160, 251, 49, - /* 80 */ 48, 47, 632, 58, 320, 63, 61, 64, 62, 80, - /* 90 */ 633, 1065, 1106, 54, 53, 235, 1045, 52, 51, 50, - /* 100 */ 632, 317, 317, 55, 57, 161, 59, 60, 633, 1058, - /* 110 */ 251, 49, 48, 47, 817, 58, 320, 63, 61, 64, - /* 120 */ 62, 205, 208, 154, 241, 54, 53, 273, 1033, 52, - /* 130 */ 51, 50, 1160, 196, 194, 192, 161, 52, 51, 50, - /* 140 */ 191, 140, 139, 138, 137, 350, 582, 583, 584, 585, - /* 150 */ 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, - /* 160 */ 152, 56, 230, 59, 60, 27, 93, 251, 49, 48, - /* 170 */ 47, 98, 58, 320, 63, 61, 64, 62, 32, 1107, - /* 180 */ 81, 291, 54, 53, 161, 36, 52, 51, 50, 59, - /* 190 */ 60, 279, 278, 251, 49, 48, 47, 265, 58, 320, - /* 200 */ 63, 61, 64, 62, 252, 1021, 269, 268, 54, 53, - /* 210 */ 92, 299, 52, 51, 50, 42, 315, 356, 355, 314, - /* 220 */ 313, 312, 354, 311, 310, 309, 353, 308, 352, 351, - /* 230 */ 22, 1029, 999, 987, 988, 989, 990, 991, 992, 993, - /* 240 */ 994, 995, 996, 997, 998, 1000, 1001, 214, 245, 250, - /* 250 */ 832, 1060, 1033, 821, 215, 824, 293, 827, 91, 254, - /* 260 */ 136, 135, 134, 216, 205, 250, 832, 325, 86, 821, - /* 270 */ 209, 824, 36, 827, 170, 1160, 12, 63, 61, 64, - /* 280 */ 62, 94, 1044, 227, 228, 54, 53, 321, 36, 52, - /* 290 */ 51, 50, 281, 3, 39, 177, 782, 783, 210, 227, - /* 300 */ 228, 104, 109, 100, 107, 43, 86, 823, 746, 826, - /* 310 */ 97, 743, 123, 744, 239, 745, 738, 1154, 1030, 735, - /* 320 */ 304, 736, 86, 737, 259, 350, 822, 272, 825, 78, - /* 330 */ 240, 733, 65, 734, 1030, 255, 223, 253, 1032, 328, - /* 340 */ 327, 256, 257, 43, 42, 85, 356, 355, 65, 243, - /* 350 */ 244, 354, 121, 115, 125, 353, 763, 352, 351, 43, - /* 360 */ 74, 130, 133, 124, 36, 36, 36, 833, 828, 1058, - /* 370 */ 127, 36, 357, 969, 829, 1005, 36, 1003, 1004, 360, - /* 380 */ 359, 145, 1006, 833, 828, 36, 1007, 232, 1008, 1009, - /* 390 */ 829, 54, 53, 36, 36, 52, 51, 50, 322, 75, - /* 400 */ 261, 1058, 258, 932, 335, 334, 329, 330, 331, 187, - /* 410 */ 1030, 1030, 1030, 332, 151, 149, 148, 1030, 336, 233, - /* 420 */ 260, 260, 1030, 79, 799, 747, 748, 337, 830, 176, - /* 430 */ 1031, 1030, 942, 739, 740, 338, 342, 760, 187, 1030, - /* 440 */ 1030, 767, 933, 274, 779, 83, 720, 831, 187, 84, - /* 450 */ 789, 790, 71, 296, 722, 1018, 298, 819, 37, 156, - /* 460 */ 721, 37, 7, 855, 834, 66, 24, 249, 37, 67, - /* 470 */ 631, 96, 731, 77, 732, 67, 132, 131, 23, 23, - /* 480 */ 1153, 798, 70, 1152, 225, 23, 70, 1099, 14, 4, - /* 490 */ 13, 226, 114, 72, 113, 820, 16, 206, 15, 751, - /* 500 */ 207, 752, 836, 1117, 749, 709, 750, 211, 204, 18, - /* 510 */ 120, 17, 119, 212, 20, 213, 19, 218, 1179, 219, - /* 520 */ 1171, 220, 217, 201, 1116, 270, 237, 1113, 1112, 238, - /* 530 */ 341, 153, 1067, 44, 1078, 1075, 1076, 1098, 1080, 1059, - /* 540 */ 276, 150, 155, 160, 287, 1028, 280, 171, 172, 275, - /* 550 */ 234, 1026, 282, 173, 174, 946, 284, 301, 162, 778, - /* 560 */ 1056, 163, 164, 165, 166, 167, 168, 169, 286, 294, - /* 570 */ 302, 290, 303, 306, 307, 76, 199, 40, 73, 46, - /* 580 */ 318, 941, 319, 292, 326, 288, 1178, 111, 1177, 283, - /* 590 */ 1174, 178, 333, 1170, 117, 1169, 45, 1166, 179, 966, - /* 600 */ 41, 38, 200, 930, 126, 305, 928, 128, 129, 926, - /* 610 */ 925, 262, 189, 190, 922, 921, 920, 919, 918, 917, - /* 620 */ 916, 193, 195, 913, 911, 909, 907, 197, 904, 198, - /* 630 */ 900, 122, 343, 82, 87, 344, 285, 1100, 345, 346, - /* 640 */ 347, 348, 349, 358, 880, 224, 246, 300, 263, 264, - /* 650 */ 879, 221, 266, 222, 267, 878, 945, 105, 944, 861, - /* 660 */ 860, 271, 70, 295, 8, 28, 924, 923, 277, 141, - /* 670 */ 181, 967, 182, 142, 184, 915, 180, 183, 185, 143, - /* 680 */ 186, 144, 914, 968, 906, 905, 754, 88, 2, 1, - /* 690 */ 780, 157, 158, 31, 791, 785, 159, 89, 236, 787, - /* 700 */ 90, 289, 29, 9, 30, 10, 11, 25, 297, 26, - /* 710 */ 97, 99, 102, 645, 34, 101, 680, 35, 103, 678, - /* 720 */ 677, 676, 674, 673, 672, 669, 316, 106, 636, 323, - /* 730 */ 108, 835, 5, 324, 837, 6, 37, 68, 110, 112, - /* 740 */ 69, 712, 116, 118, 711, 708, 661, 659, 651, 657, - /* 750 */ 653, 655, 649, 647, 682, 681, 679, 675, 671, 670, - /* 760 */ 634, 188, 599, 884, 883, 883, 883, 883, 883, 883, - /* 770 */ 883, 883, 883, 883, 883, 883, 146, 147, + /* 0 */ 96, 635, 249, 21, 635, 203, 248, 714, 206, 636, + /* 10 */ 363, 230, 636, 55, 56, 1073, 59, 60, 1024, 1164, + /* 20 */ 252, 49, 48, 47, 671, 58, 322, 63, 61, 64, + /* 30 */ 62, 1021, 1022, 33, 1025, 54, 53, 342, 341, 52, + /* 40 */ 51, 50, 55, 56, 261, 59, 60, 236, 1050, 252, + /* 50 */ 49, 48, 47, 176, 58, 322, 63, 61, 64, 62, + /* 60 */ 155, 827, 206, 830, 54, 53, 206, 204, 52, 51, + /* 70 */ 50, 55, 56, 1165, 59, 60, 99, 1165, 252, 49, + /* 80 */ 48, 47, 1070, 58, 322, 63, 61, 64, 62, 162, + /* 90 */ 81, 36, 635, 54, 53, 318, 162, 52, 51, 50, + /* 100 */ 636, 54, 53, 162, 318, 52, 51, 50, 55, 57, + /* 110 */ 1026, 59, 60, 253, 821, 252, 49, 48, 47, 635, + /* 120 */ 58, 322, 63, 61, 64, 62, 936, 636, 280, 279, + /* 130 */ 54, 53, 188, 232, 52, 51, 50, 1035, 585, 586, + /* 140 */ 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, + /* 150 */ 597, 598, 153, 56, 231, 59, 60, 162, 74, 252, + /* 160 */ 49, 48, 47, 1111, 58, 322, 63, 61, 64, 62, + /* 170 */ 1112, 1063, 292, 206, 54, 53, 255, 93, 52, 51, + /* 180 */ 50, 59, 60, 834, 1165, 252, 49, 48, 47, 233, + /* 190 */ 58, 322, 63, 61, 64, 62, 42, 75, 358, 357, + /* 200 */ 54, 53, 27, 356, 52, 51, 50, 355, 250, 354, + /* 210 */ 353, 42, 316, 358, 357, 315, 314, 313, 356, 312, + /* 220 */ 311, 310, 355, 309, 354, 353, 886, 364, 352, 294, + /* 230 */ 4, 92, 1004, 992, 993, 994, 995, 996, 997, 998, + /* 240 */ 999, 1000, 1001, 1002, 1003, 1005, 1006, 22, 251, 836, + /* 250 */ 87, 260, 825, 256, 828, 254, 831, 330, 329, 947, + /* 260 */ 635, 52, 51, 50, 215, 188, 251, 836, 636, 36, + /* 270 */ 825, 216, 828, 1063, 831, 786, 787, 137, 136, 135, + /* 280 */ 217, 209, 228, 229, 327, 87, 323, 1063, 43, 210, + /* 290 */ 86, 274, 36, 36, 63, 61, 64, 62, 36, 87, + /* 300 */ 228, 229, 54, 53, 211, 234, 52, 51, 50, 750, + /* 310 */ 36, 240, 747, 36, 748, 1035, 749, 742, 1159, 826, + /* 320 */ 739, 829, 740, 43, 741, 362, 361, 146, 262, 1032, + /* 330 */ 259, 65, 337, 336, 241, 331, 36, 43, 1035, 1035, + /* 340 */ 332, 36, 257, 258, 1035, 273, 1158, 79, 320, 65, + /* 350 */ 244, 245, 333, 36, 224, 334, 1035, 1049, 12, 1035, + /* 360 */ 1184, 3, 39, 178, 95, 1157, 266, 837, 832, 105, + /* 370 */ 77, 101, 108, 243, 833, 270, 269, 1010, 338, 1008, + /* 380 */ 1009, 767, 1035, 339, 1011, 837, 832, 1035, 1012, 305, + /* 390 */ 1013, 1014, 833, 98, 803, 340, 197, 195, 193, 1035, + /* 400 */ 36, 226, 36, 192, 141, 140, 139, 138, 122, 116, + /* 410 */ 126, 242, 152, 150, 149, 1038, 246, 131, 134, 125, + /* 420 */ 1038, 80, 171, 261, 261, 124, 128, 751, 752, 94, + /* 430 */ 764, 937, 177, 1036, 84, 743, 744, 188, 275, 352, + /* 440 */ 282, 835, 344, 82, 85, 783, 1035, 793, 1034, 794, + /* 450 */ 359, 974, 802, 1023, 37, 7, 71, 724, 297, 726, + /* 460 */ 299, 157, 737, 66, 738, 24, 735, 771, 736, 725, + /* 470 */ 32, 823, 70, 37, 37, 67, 97, 859, 838, 324, + /* 480 */ 634, 14, 70, 13, 115, 67, 114, 16, 755, 15, + /* 490 */ 756, 78, 1037, 23, 23, 227, 23, 72, 18, 753, + /* 500 */ 17, 754, 133, 132, 300, 121, 207, 120, 208, 824, + /* 510 */ 212, 20, 205, 19, 213, 214, 219, 220, 221, 218, + /* 520 */ 202, 1176, 1065, 1122, 713, 1121, 238, 1118, 1117, 239, + /* 530 */ 321, 343, 1064, 44, 271, 154, 1104, 1072, 1083, 1103, + /* 540 */ 1080, 1081, 151, 277, 172, 1033, 1085, 156, 281, 235, + /* 550 */ 283, 161, 288, 285, 173, 165, 1031, 1061, 174, 164, + /* 560 */ 782, 175, 163, 166, 168, 951, 302, 303, 304, 307, + /* 570 */ 308, 200, 295, 291, 293, 76, 40, 319, 946, 945, + /* 580 */ 328, 1183, 112, 1182, 840, 1179, 73, 179, 335, 1175, + /* 590 */ 118, 1174, 46, 289, 1171, 287, 180, 971, 41, 38, + /* 600 */ 201, 934, 127, 932, 129, 130, 930, 284, 929, 263, + /* 610 */ 190, 191, 926, 925, 924, 923, 922, 921, 920, 194, + /* 620 */ 196, 917, 45, 915, 913, 911, 198, 908, 199, 904, + /* 630 */ 306, 123, 276, 83, 88, 345, 286, 1105, 346, 347, + /* 640 */ 348, 349, 350, 351, 360, 884, 225, 264, 247, 301, + /* 650 */ 265, 883, 267, 222, 223, 268, 882, 106, 950, 949, + /* 660 */ 865, 272, 864, 70, 296, 8, 278, 758, 89, 183, + /* 670 */ 928, 927, 972, 181, 186, 182, 184, 185, 187, 142, + /* 680 */ 143, 144, 28, 919, 918, 784, 158, 145, 973, 910, + /* 690 */ 909, 795, 159, 1, 31, 169, 167, 170, 789, 2, + /* 700 */ 160, 90, 237, 791, 91, 290, 29, 9, 30, 10, + /* 710 */ 11, 25, 298, 26, 98, 100, 34, 649, 102, 103, + /* 720 */ 684, 35, 104, 682, 681, 680, 678, 677, 676, 673, + /* 730 */ 639, 317, 107, 325, 841, 326, 109, 110, 5, 111, + /* 740 */ 839, 6, 68, 113, 69, 37, 117, 119, 716, 715, + /* 750 */ 712, 665, 663, 655, 661, 657, 659, 653, 651, 686, + /* 760 */ 685, 683, 679, 675, 674, 189, 637, 602, 888, 887, + /* 770 */ 887, 887, 887, 887, 887, 887, 887, 887, 887, 887, + /* 780 */ 887, 147, 148, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 207, 1, 200, 200, 1, 266, 206, 5, 266, 9, - /* 10 */ 200, 201, 9, 13, 14, 0, 16, 17, 200, 277, - /* 20 */ 20, 21, 22, 23, 200, 25, 26, 27, 28, 29, + /* 0 */ 207, 1, 206, 266, 1, 266, 206, 5, 266, 9, + /* 10 */ 200, 201, 9, 13, 14, 200, 16, 17, 0, 277, + /* 20 */ 20, 21, 22, 23, 5, 25, 26, 27, 28, 29, /* 30 */ 30, 238, 239, 240, 241, 35, 36, 35, 36, 39, - /* 40 */ 40, 41, 13, 14, 242, 16, 17, 244, 246, 20, - /* 50 */ 21, 22, 23, 5, 25, 26, 27, 28, 29, 30, - /* 60 */ 266, 206, 198, 199, 35, 36, 266, 200, 39, 40, - /* 70 */ 41, 13, 14, 266, 16, 17, 209, 277, 20, 21, - /* 80 */ 22, 23, 1, 25, 26, 27, 28, 29, 30, 89, - /* 90 */ 9, 267, 274, 35, 36, 248, 249, 39, 40, 41, - /* 100 */ 1, 86, 86, 13, 14, 200, 16, 17, 9, 245, - /* 110 */ 20, 21, 22, 23, 85, 25, 26, 27, 28, 29, - /* 120 */ 30, 266, 266, 200, 243, 35, 36, 263, 247, 39, - /* 130 */ 40, 41, 277, 64, 65, 66, 200, 39, 40, 41, - /* 140 */ 71, 72, 73, 74, 75, 93, 47, 48, 49, 50, - /* 150 */ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - /* 160 */ 61, 14, 63, 16, 17, 84, 250, 20, 21, 22, - /* 170 */ 23, 207, 25, 26, 27, 28, 29, 30, 84, 274, - /* 180 */ 264, 276, 35, 36, 200, 200, 39, 40, 41, 16, - /* 190 */ 17, 268, 269, 20, 21, 22, 23, 144, 25, 26, - /* 200 */ 27, 28, 29, 30, 206, 241, 153, 154, 35, 36, - /* 210 */ 274, 117, 39, 40, 41, 101, 102, 103, 104, 105, - /* 220 */ 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - /* 230 */ 46, 246, 222, 223, 224, 225, 226, 227, 228, 229, - /* 240 */ 230, 231, 232, 233, 234, 235, 236, 63, 243, 1, - /* 250 */ 2, 245, 247, 5, 70, 7, 272, 9, 274, 70, - /* 260 */ 76, 77, 78, 79, 266, 1, 2, 83, 84, 5, - /* 270 */ 266, 7, 200, 9, 253, 277, 84, 27, 28, 29, - /* 280 */ 30, 89, 249, 35, 36, 35, 36, 39, 200, 39, - /* 290 */ 40, 41, 271, 64, 65, 66, 127, 128, 266, 35, - /* 300 */ 36, 72, 73, 74, 75, 121, 84, 5, 2, 7, - /* 310 */ 118, 5, 80, 7, 242, 9, 2, 266, 246, 5, - /* 320 */ 91, 7, 84, 9, 70, 93, 5, 143, 7, 145, - /* 330 */ 242, 5, 84, 7, 246, 146, 152, 148, 247, 150, - /* 340 */ 151, 35, 36, 121, 101, 123, 103, 104, 84, 35, - /* 350 */ 36, 108, 64, 65, 66, 112, 39, 114, 115, 121, - /* 360 */ 100, 73, 74, 75, 200, 200, 200, 119, 120, 245, - /* 370 */ 82, 200, 220, 221, 126, 222, 200, 224, 225, 67, - /* 380 */ 68, 69, 229, 119, 120, 200, 233, 263, 235, 236, - /* 390 */ 126, 35, 36, 200, 200, 39, 40, 41, 15, 139, - /* 400 */ 146, 245, 148, 205, 150, 151, 242, 242, 242, 211, - /* 410 */ 246, 246, 246, 242, 64, 65, 66, 246, 242, 263, - /* 420 */ 200, 200, 246, 207, 78, 119, 120, 242, 126, 209, - /* 430 */ 209, 246, 205, 119, 120, 242, 242, 100, 211, 246, - /* 440 */ 246, 124, 205, 85, 85, 85, 85, 126, 211, 85, - /* 450 */ 85, 85, 100, 85, 85, 239, 85, 1, 100, 100, - /* 460 */ 85, 100, 125, 85, 85, 100, 100, 62, 100, 100, - /* 470 */ 85, 100, 5, 84, 7, 100, 80, 81, 100, 100, - /* 480 */ 266, 135, 122, 266, 266, 100, 122, 275, 147, 84, - /* 490 */ 149, 266, 147, 141, 149, 39, 147, 266, 149, 5, - /* 500 */ 266, 7, 119, 237, 5, 116, 7, 266, 266, 147, - /* 510 */ 147, 149, 149, 266, 147, 266, 149, 266, 249, 266, - /* 520 */ 249, 266, 266, 266, 237, 200, 237, 237, 237, 237, - /* 530 */ 237, 200, 200, 265, 200, 200, 200, 275, 200, 245, - /* 540 */ 245, 62, 200, 200, 200, 245, 270, 251, 200, 202, - /* 550 */ 270, 200, 270, 200, 200, 200, 270, 200, 261, 126, - /* 560 */ 262, 260, 259, 258, 257, 256, 255, 254, 129, 133, - /* 570 */ 200, 131, 200, 200, 200, 138, 200, 200, 140, 137, - /* 580 */ 200, 200, 200, 136, 200, 130, 200, 200, 200, 132, - /* 590 */ 200, 200, 200, 200, 200, 200, 142, 200, 200, 200, - /* 600 */ 200, 200, 200, 200, 200, 92, 200, 200, 200, 200, + /* 40 */ 40, 41, 13, 14, 200, 16, 17, 248, 249, 20, + /* 50 */ 21, 22, 23, 209, 25, 26, 27, 28, 29, 30, + /* 60 */ 200, 5, 266, 7, 35, 36, 266, 266, 39, 40, + /* 70 */ 41, 13, 14, 277, 16, 17, 207, 277, 20, 21, + /* 80 */ 22, 23, 267, 25, 26, 27, 28, 29, 30, 200, + /* 90 */ 90, 200, 1, 35, 36, 86, 200, 39, 40, 41, + /* 100 */ 9, 35, 36, 200, 86, 39, 40, 41, 13, 14, + /* 110 */ 241, 16, 17, 206, 85, 20, 21, 22, 23, 1, + /* 120 */ 25, 26, 27, 28, 29, 30, 205, 9, 268, 269, + /* 130 */ 35, 36, 211, 242, 39, 40, 41, 246, 47, 48, + /* 140 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + /* 150 */ 59, 60, 61, 14, 63, 16, 17, 200, 101, 20, + /* 160 */ 21, 22, 23, 274, 25, 26, 27, 28, 29, 30, + /* 170 */ 274, 245, 276, 266, 35, 36, 70, 274, 39, 40, + /* 180 */ 41, 16, 17, 127, 277, 20, 21, 22, 23, 263, + /* 190 */ 25, 26, 27, 28, 29, 30, 102, 140, 104, 105, + /* 200 */ 35, 36, 84, 109, 39, 40, 41, 113, 62, 115, + /* 210 */ 116, 102, 103, 104, 105, 106, 107, 108, 109, 110, + /* 220 */ 111, 112, 113, 114, 115, 116, 198, 199, 94, 272, + /* 230 */ 84, 274, 222, 223, 224, 225, 226, 227, 228, 229, + /* 240 */ 230, 231, 232, 233, 234, 235, 236, 46, 1, 2, + /* 250 */ 84, 70, 5, 147, 7, 149, 9, 151, 152, 205, + /* 260 */ 1, 39, 40, 41, 63, 211, 1, 2, 9, 200, + /* 270 */ 5, 70, 7, 245, 9, 128, 129, 76, 77, 78, + /* 280 */ 79, 266, 35, 36, 83, 84, 39, 245, 122, 266, + /* 290 */ 124, 263, 200, 200, 27, 28, 29, 30, 200, 84, + /* 300 */ 35, 36, 35, 36, 266, 263, 39, 40, 41, 2, + /* 310 */ 200, 242, 5, 200, 7, 246, 9, 2, 266, 5, + /* 320 */ 5, 7, 7, 122, 9, 67, 68, 69, 147, 200, + /* 330 */ 149, 84, 151, 152, 242, 242, 200, 122, 246, 246, + /* 340 */ 242, 200, 35, 36, 246, 144, 266, 146, 89, 84, + /* 350 */ 35, 36, 242, 200, 153, 242, 246, 249, 84, 246, + /* 360 */ 249, 64, 65, 66, 90, 266, 145, 120, 121, 72, + /* 370 */ 73, 74, 75, 244, 127, 154, 155, 222, 242, 224, + /* 380 */ 225, 39, 246, 242, 229, 120, 121, 246, 233, 92, + /* 390 */ 235, 236, 127, 119, 78, 242, 64, 65, 66, 246, + /* 400 */ 200, 266, 200, 71, 72, 73, 74, 75, 64, 65, + /* 410 */ 66, 243, 64, 65, 66, 247, 243, 73, 74, 75, + /* 420 */ 247, 207, 253, 200, 200, 80, 82, 120, 121, 250, + /* 430 */ 101, 205, 209, 209, 85, 120, 121, 211, 85, 94, + /* 440 */ 271, 127, 242, 264, 85, 85, 246, 85, 246, 85, + /* 450 */ 220, 221, 136, 239, 101, 126, 101, 85, 85, 85, + /* 460 */ 85, 101, 5, 101, 7, 101, 5, 125, 7, 85, + /* 470 */ 84, 1, 123, 101, 101, 101, 101, 85, 85, 15, + /* 480 */ 85, 148, 123, 150, 148, 101, 150, 148, 5, 150, + /* 490 */ 7, 84, 247, 101, 101, 266, 101, 142, 148, 5, + /* 500 */ 150, 7, 80, 81, 118, 148, 266, 150, 266, 39, + /* 510 */ 266, 148, 266, 150, 266, 266, 266, 266, 266, 266, + /* 520 */ 266, 249, 245, 237, 117, 237, 237, 237, 237, 237, + /* 530 */ 200, 237, 245, 265, 200, 200, 275, 200, 200, 275, + /* 540 */ 200, 200, 62, 245, 251, 245, 200, 200, 270, 270, + /* 550 */ 270, 200, 200, 270, 200, 259, 200, 262, 200, 260, + /* 560 */ 127, 200, 261, 258, 256, 200, 200, 200, 200, 200, + /* 570 */ 200, 200, 134, 132, 137, 139, 200, 200, 200, 200, + /* 580 */ 200, 200, 200, 200, 120, 200, 141, 200, 200, 200, + /* 590 */ 200, 200, 138, 131, 200, 130, 200, 200, 200, 200, + /* 600 */ 200, 200, 200, 200, 200, 200, 200, 133, 200, 200, /* 610 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - /* 620 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - /* 630 */ 200, 99, 98, 202, 202, 53, 202, 202, 95, 97, - /* 640 */ 57, 96, 94, 86, 5, 202, 202, 202, 155, 5, - /* 650 */ 5, 202, 155, 202, 5, 5, 210, 207, 210, 103, - /* 660 */ 102, 144, 122, 117, 84, 84, 202, 202, 100, 203, - /* 670 */ 217, 219, 213, 203, 214, 202, 218, 216, 215, 203, - /* 680 */ 212, 203, 202, 221, 202, 202, 85, 100, 204, 208, - /* 690 */ 85, 84, 84, 252, 85, 85, 100, 84, 1, 85, - /* 700 */ 84, 84, 100, 134, 100, 134, 84, 84, 117, 84, - /* 710 */ 118, 80, 72, 5, 90, 89, 9, 90, 89, 5, - /* 720 */ 5, 5, 5, 5, 5, 5, 15, 80, 87, 26, - /* 730 */ 88, 85, 84, 61, 119, 84, 100, 16, 149, 149, - /* 740 */ 16, 5, 149, 149, 5, 85, 5, 5, 5, 5, - /* 750 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 760 */ 87, 100, 62, 0, 278, 278, 278, 278, 278, 278, - /* 770 */ 278, 278, 278, 278, 278, 278, 21, 21, 278, 278, - /* 780 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 620 */ 200, 200, 143, 200, 200, 200, 200, 200, 200, 200, + /* 630 */ 93, 100, 202, 202, 202, 99, 202, 202, 53, 96, + /* 640 */ 98, 57, 97, 95, 86, 5, 202, 156, 202, 202, + /* 650 */ 5, 5, 156, 202, 202, 5, 5, 207, 210, 210, + /* 660 */ 104, 145, 103, 123, 118, 84, 101, 85, 101, 213, + /* 670 */ 202, 202, 219, 218, 215, 217, 216, 214, 212, 203, + /* 680 */ 203, 203, 84, 202, 202, 85, 84, 203, 221, 202, + /* 690 */ 202, 85, 84, 208, 252, 255, 257, 254, 85, 204, + /* 700 */ 101, 84, 1, 85, 84, 84, 101, 135, 101, 135, + /* 710 */ 84, 84, 118, 84, 119, 80, 91, 5, 90, 72, + /* 720 */ 9, 91, 90, 5, 5, 5, 5, 5, 5, 5, + /* 730 */ 87, 15, 80, 26, 120, 61, 88, 88, 84, 150, + /* 740 */ 85, 84, 16, 150, 16, 101, 150, 150, 5, 5, + /* 750 */ 85, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 760 */ 5, 5, 5, 5, 5, 101, 87, 62, 0, 278, + /* 770 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 780 */ 278, 21, 21, 278, 278, 278, 278, 278, 278, 278, /* 790 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 800 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 810 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, @@ -385,114 +386,114 @@ static const YYCODETYPE yy_lookahead[] = { /* 940 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 950 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, /* 960 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 970 */ 278, 278, 278, 278, 278, + /* 970 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, }; -#define YY_SHIFT_COUNT (362) +#define YY_SHIFT_COUNT (364) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (763) +#define YY_SHIFT_MAX (768) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 184, 114, 243, 16, 248, 264, 264, 81, 3, 3, + /* 0 */ 201, 109, 94, 9, 247, 265, 265, 118, 3, 3, /* 10 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 20 */ 3, 0, 99, 264, 306, 314, 314, 238, 238, 3, - /* 30 */ 3, 169, 3, 15, 3, 3, 3, 3, 232, 16, - /* 40 */ 52, 52, 48, 778, 264, 264, 264, 264, 264, 264, - /* 50 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 60 */ 264, 264, 264, 264, 264, 264, 306, 314, 306, 306, - /* 70 */ 222, 2, 2, 2, 2, 2, 2, 2, 3, 3, - /* 80 */ 3, 317, 3, 3, 3, 238, 238, 3, 3, 3, - /* 90 */ 3, 346, 346, 337, 238, 3, 3, 3, 3, 3, + /* 20 */ 3, 0, 91, 265, 307, 315, 315, 215, 215, 3, + /* 30 */ 3, 147, 3, 18, 3, 3, 3, 3, 345, 9, + /* 40 */ 134, 134, 19, 783, 265, 265, 265, 265, 265, 265, + /* 50 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, + /* 60 */ 265, 265, 265, 265, 265, 265, 307, 315, 307, 307, + /* 70 */ 166, 2, 2, 2, 2, 2, 2, 259, 2, 3, + /* 80 */ 3, 3, 342, 3, 3, 3, 215, 215, 3, 3, + /* 90 */ 3, 3, 316, 316, 329, 215, 3, 3, 3, 3, /* 100 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 110 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 120 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 130 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 140 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 150 */ 3, 3, 3, 479, 479, 479, 433, 433, 433, 433, - /* 160 */ 479, 479, 437, 438, 436, 442, 447, 440, 455, 439, - /* 170 */ 457, 454, 479, 479, 479, 513, 513, 16, 479, 479, - /* 180 */ 532, 534, 582, 543, 542, 583, 545, 548, 48, 479, - /* 190 */ 479, 557, 557, 479, 557, 479, 557, 479, 479, 778, - /* 200 */ 778, 29, 58, 58, 90, 58, 147, 173, 250, 250, - /* 210 */ 250, 250, 250, 250, 229, 69, 288, 356, 356, 356, - /* 220 */ 356, 189, 254, 53, 192, 98, 98, 302, 321, 312, - /* 230 */ 350, 358, 360, 364, 359, 365, 366, 352, 260, 361, - /* 240 */ 368, 369, 371, 326, 467, 375, 94, 378, 379, 456, - /* 250 */ 405, 383, 385, 341, 345, 349, 494, 499, 362, 363, - /* 260 */ 389, 367, 396, 639, 493, 644, 645, 497, 649, 650, - /* 270 */ 556, 558, 517, 540, 546, 580, 601, 581, 568, 587, - /* 280 */ 605, 607, 609, 608, 610, 596, 613, 614, 616, 697, - /* 290 */ 617, 602, 569, 604, 571, 622, 546, 623, 591, 625, - /* 300 */ 592, 631, 624, 626, 640, 708, 627, 629, 707, 714, - /* 310 */ 715, 716, 717, 718, 719, 720, 641, 711, 647, 642, - /* 320 */ 648, 646, 615, 651, 703, 672, 721, 589, 590, 636, - /* 330 */ 636, 636, 636, 724, 593, 594, 636, 636, 636, 736, - /* 340 */ 739, 660, 636, 741, 742, 743, 744, 745, 746, 747, - /* 350 */ 748, 749, 750, 751, 752, 753, 754, 661, 673, 755, - /* 360 */ 756, 700, 763, + /* 150 */ 3, 3, 3, 3, 480, 480, 480, 433, 433, 433, + /* 160 */ 433, 480, 480, 436, 445, 438, 454, 437, 441, 462, + /* 170 */ 465, 474, 479, 480, 480, 480, 537, 537, 9, 480, + /* 180 */ 480, 531, 536, 585, 543, 542, 584, 545, 548, 19, + /* 190 */ 480, 480, 558, 558, 480, 558, 480, 558, 480, 480, + /* 200 */ 783, 783, 29, 58, 58, 95, 58, 139, 165, 267, + /* 210 */ 267, 267, 267, 267, 267, 297, 332, 344, 66, 66, + /* 220 */ 66, 66, 106, 181, 221, 274, 222, 222, 56, 314, + /* 230 */ 258, 348, 353, 349, 359, 360, 362, 364, 355, 57, + /* 240 */ 372, 373, 374, 375, 457, 461, 384, 386, 392, 393, + /* 250 */ 470, 146, 464, 395, 333, 336, 339, 483, 494, 350, + /* 260 */ 357, 407, 363, 422, 640, 491, 645, 646, 496, 650, + /* 270 */ 651, 556, 559, 516, 540, 546, 581, 582, 598, 565, + /* 280 */ 567, 600, 602, 606, 608, 613, 599, 617, 618, 620, + /* 290 */ 701, 621, 605, 572, 607, 574, 626, 546, 627, 594, + /* 300 */ 629, 595, 635, 625, 628, 647, 712, 630, 632, 711, + /* 310 */ 718, 719, 720, 721, 722, 723, 724, 643, 716, 652, + /* 320 */ 648, 649, 654, 655, 614, 657, 707, 674, 726, 589, + /* 330 */ 593, 644, 644, 644, 644, 728, 596, 597, 644, 644, + /* 340 */ 644, 743, 744, 665, 644, 746, 747, 748, 749, 750, + /* 350 */ 751, 752, 753, 754, 755, 756, 757, 758, 759, 664, + /* 360 */ 679, 760, 761, 705, 768, }; -#define YY_REDUCE_COUNT (200) -#define YY_REDUCE_MIN (-261) -#define YY_REDUCE_MAX (484) +#define YY_REDUCE_COUNT (201) +#define YY_REDUCE_MIN (-263) +#define YY_REDUCE_MAX (495) static const short yy_reduce_ofst[] = { - /* 0 */ -136, 10, 153, -207, -200, -145, -2, -77, -198, -95, - /* 10 */ -16, 72, 88, 164, 165, 166, 171, 176, 185, 193, - /* 20 */ 194, -176, -190, -258, -153, -119, 5, 124, 156, -182, - /* 30 */ -64, 21, -197, -36, -133, 220, 221, -15, 198, 216, - /* 40 */ 227, 237, 152, -84, -261, -206, -193, -144, 4, 32, - /* 50 */ 51, 214, 217, 218, 225, 231, 234, 241, 242, 247, - /* 60 */ 249, 251, 253, 255, 256, 257, 33, 91, 269, 271, - /* 70 */ 6, 266, 287, 289, 290, 291, 292, 293, 325, 331, - /* 80 */ 332, 268, 334, 335, 336, 294, 295, 338, 342, 343, - /* 90 */ 344, 212, 262, 296, 300, 348, 351, 353, 354, 355, - /* 100 */ 357, 370, 372, 373, 374, 376, 377, 380, 381, 382, - /* 110 */ 384, 386, 387, 388, 390, 391, 392, 393, 394, 395, - /* 120 */ 397, 398, 399, 400, 401, 402, 403, 404, 406, 407, - /* 130 */ 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, - /* 140 */ 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, - /* 150 */ 428, 429, 430, 347, 431, 432, 276, 280, 282, 286, - /* 160 */ 434, 435, 298, 297, 301, 303, 305, 307, 309, 311, - /* 170 */ 313, 441, 443, 444, 445, 446, 448, 450, 449, 451, - /* 180 */ 452, 458, 453, 459, 461, 460, 463, 468, 462, 464, - /* 190 */ 465, 466, 470, 473, 476, 480, 478, 482, 483, 481, - /* 200 */ 484, + /* 0 */ 28, 10, 155, -207, -204, -200, -93, -140, -109, -104, + /* 10 */ -43, 69, 92, 93, 98, 110, 113, 136, 141, 153, + /* 20 */ 200, -185, -190, -258, -201, 168, 173, -74, 42, -111, + /* 30 */ -97, 169, 129, -131, -156, 223, 224, 202, -79, 214, + /* 40 */ 54, 226, 230, 179, -263, -261, -199, 15, 23, 38, + /* 50 */ 52, 80, 99, 135, 229, 240, 242, 244, 246, 248, + /* 60 */ 249, 250, 251, 252, 253, 254, 108, 245, 111, 272, + /* 70 */ 277, 286, 288, 289, 290, 291, 292, 330, 294, 334, + /* 80 */ 335, 337, 268, 338, 340, 341, 287, 298, 346, 347, + /* 90 */ 351, 352, 261, 264, 293, 300, 354, 356, 358, 361, + /* 100 */ 365, 366, 367, 368, 369, 370, 371, 376, 377, 378, + /* 110 */ 379, 380, 381, 382, 383, 385, 387, 388, 389, 390, + /* 120 */ 391, 394, 396, 397, 398, 399, 400, 401, 402, 403, + /* 130 */ 404, 405, 406, 408, 409, 410, 411, 412, 413, 414, + /* 140 */ 415, 416, 417, 418, 419, 420, 421, 423, 424, 425, + /* 150 */ 426, 427, 428, 429, 430, 431, 432, 278, 279, 280, + /* 160 */ 283, 434, 435, 295, 301, 299, 296, 305, 439, 308, + /* 170 */ 440, 443, 442, 444, 446, 447, 448, 449, 450, 451, + /* 180 */ 452, 453, 455, 458, 456, 460, 463, 459, 466, 467, + /* 190 */ 468, 469, 476, 477, 481, 478, 482, 484, 487, 488, + /* 200 */ 485, 495, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 881, 943, 931, 940, 1162, 1162, 1162, 881, 881, 881, - /* 10 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 20 */ 881, 1069, 901, 1162, 881, 881, 881, 881, 881, 881, - /* 30 */ 881, 1084, 881, 940, 881, 881, 881, 881, 949, 940, - /* 40 */ 949, 949, 881, 1064, 881, 881, 881, 881, 881, 881, - /* 50 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 60 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 70 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 80 */ 881, 1071, 1077, 1074, 881, 881, 881, 1079, 881, 881, - /* 90 */ 881, 1103, 1103, 1062, 881, 881, 881, 881, 881, 881, - /* 100 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 110 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 120 */ 881, 881, 881, 881, 881, 881, 929, 881, 927, 881, - /* 130 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 140 */ 881, 881, 881, 881, 881, 912, 881, 881, 881, 881, - /* 150 */ 881, 881, 899, 903, 903, 903, 881, 881, 881, 881, - /* 160 */ 903, 903, 1110, 1114, 1096, 1108, 1104, 1091, 1089, 1087, - /* 170 */ 1095, 1118, 903, 903, 903, 947, 947, 940, 903, 903, - /* 180 */ 965, 963, 961, 953, 959, 955, 957, 951, 881, 903, - /* 190 */ 903, 938, 938, 903, 938, 903, 938, 903, 903, 986, - /* 200 */ 1002, 881, 1119, 1109, 881, 1161, 1149, 1148, 1157, 1156, - /* 210 */ 1155, 1147, 1146, 1145, 881, 881, 881, 1141, 1144, 1143, - /* 220 */ 1142, 881, 881, 881, 881, 1151, 1150, 881, 881, 881, - /* 230 */ 881, 881, 881, 881, 881, 881, 881, 1115, 1111, 881, - /* 240 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 250 */ 1121, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 260 */ 1010, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 270 */ 881, 881, 881, 1061, 881, 881, 881, 881, 1073, 1072, - /* 280 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 290 */ 881, 1105, 881, 1097, 881, 881, 1022, 881, 881, 881, - /* 300 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 310 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, - /* 320 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 1180, - /* 330 */ 1175, 1176, 1173, 881, 881, 881, 1172, 1167, 1168, 881, - /* 340 */ 881, 881, 1165, 881, 881, 881, 881, 881, 881, 881, - /* 350 */ 881, 881, 881, 881, 881, 881, 881, 971, 881, 910, - /* 360 */ 908, 881, 881, + /* 0 */ 885, 948, 935, 944, 1167, 1167, 1167, 885, 885, 885, + /* 10 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 20 */ 885, 1074, 905, 1167, 885, 885, 885, 885, 885, 885, + /* 30 */ 885, 1089, 885, 944, 885, 885, 885, 885, 954, 944, + /* 40 */ 954, 954, 885, 1069, 885, 885, 885, 885, 885, 885, + /* 50 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 60 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 70 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 80 */ 885, 885, 1076, 1082, 1079, 885, 885, 885, 1084, 885, + /* 90 */ 885, 885, 1108, 1108, 1067, 885, 885, 885, 885, 885, + /* 100 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 110 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 120 */ 885, 885, 885, 885, 885, 885, 885, 933, 885, 931, + /* 130 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 140 */ 885, 885, 885, 885, 885, 885, 916, 885, 885, 885, + /* 150 */ 885, 885, 885, 903, 907, 907, 907, 885, 885, 885, + /* 160 */ 885, 907, 907, 1115, 1119, 1101, 1113, 1109, 1096, 1094, + /* 170 */ 1092, 1100, 1123, 907, 907, 907, 952, 952, 944, 907, + /* 180 */ 907, 970, 968, 966, 958, 964, 960, 962, 956, 885, + /* 190 */ 907, 907, 942, 942, 907, 942, 907, 942, 907, 907, + /* 200 */ 991, 1007, 885, 1124, 1114, 885, 1166, 1154, 1153, 1162, + /* 210 */ 1161, 1160, 1152, 1151, 1150, 885, 885, 885, 1146, 1149, + /* 220 */ 1148, 1147, 885, 885, 885, 885, 1156, 1155, 885, 885, + /* 230 */ 885, 885, 885, 885, 885, 885, 885, 885, 1120, 1116, + /* 240 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 250 */ 885, 1126, 885, 885, 885, 885, 885, 885, 885, 885, + /* 260 */ 885, 1015, 885, 885, 885, 885, 885, 885, 885, 885, + /* 270 */ 885, 885, 885, 885, 1066, 885, 885, 885, 885, 1078, + /* 280 */ 1077, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 290 */ 885, 885, 1110, 885, 1102, 885, 885, 1027, 885, 885, + /* 300 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 310 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 320 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, + /* 330 */ 885, 1185, 1180, 1181, 1178, 885, 885, 885, 1177, 1172, + /* 340 */ 1173, 885, 885, 885, 1170, 885, 885, 885, 885, 885, + /* 350 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 976, + /* 360 */ 885, 914, 912, 885, 885, }; /********** End of lemon-generated parsing tables *****************************/ @@ -601,6 +602,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* IF => nothing */ 0, /* EXISTS => nothing */ 0, /* PORT => nothing */ + 1, /* IPTOKEN => ID */ 0, /* AS => nothing */ 0, /* OUTPUTTYPE => nothing */ 0, /* AGGREGATE => nothing */ @@ -698,7 +700,6 @@ static const YYCODETYPE yyFallback[] = { 1, /* STATEMENT => ID */ 1, /* TRIGGER => ID */ 1, /* VIEW => ID */ - 1, /* IPTOKEN => ID */ 1, /* SEMI => ID */ 1, /* NONE => ID */ 1, /* PREV => ID */ @@ -884,104 +885,104 @@ static const char *const yyTokenName[] = { /* 86 */ "IF", /* 87 */ "EXISTS", /* 88 */ "PORT", - /* 89 */ "AS", - /* 90 */ "OUTPUTTYPE", - /* 91 */ "AGGREGATE", - /* 92 */ "BUFSIZE", - /* 93 */ "PPS", - /* 94 */ "TSERIES", - /* 95 */ "DBS", - /* 96 */ "STORAGE", - /* 97 */ "QTIME", - /* 98 */ "CONNS", - /* 99 */ "STATE", - /* 100 */ "COMMA", - /* 101 */ "KEEP", - /* 102 */ "CACHE", - /* 103 */ "REPLICA", - /* 104 */ "QUORUM", - /* 105 */ "DAYS", - /* 106 */ "MINROWS", - /* 107 */ "MAXROWS", - /* 108 */ "BLOCKS", - /* 109 */ "CTIME", - /* 110 */ "WAL", - /* 111 */ "FSYNC", - /* 112 */ "COMP", - /* 113 */ "PRECISION", - /* 114 */ "UPDATE", - /* 115 */ "CACHELAST", - /* 116 */ "UNSIGNED", - /* 117 */ "TAGS", - /* 118 */ "USING", - /* 119 */ "NULL", - /* 120 */ "NOW", - /* 121 */ "SELECT", - /* 122 */ "UNION", - /* 123 */ "ALL", - /* 124 */ "DISTINCT", - /* 125 */ "FROM", - /* 126 */ "VARIABLE", - /* 127 */ "INTERVAL", - /* 128 */ "EVERY", - /* 129 */ "SESSION", - /* 130 */ "STATE_WINDOW", - /* 131 */ "FILL", - /* 132 */ "SLIDING", - /* 133 */ "ORDER", - /* 134 */ "BY", - /* 135 */ "ASC", - /* 136 */ "GROUP", - /* 137 */ "HAVING", - /* 138 */ "LIMIT", - /* 139 */ "OFFSET", - /* 140 */ "SLIMIT", - /* 141 */ "SOFFSET", - /* 142 */ "WHERE", - /* 143 */ "RESET", - /* 144 */ "QUERY", - /* 145 */ "SYNCDB", - /* 146 */ "ADD", - /* 147 */ "COLUMN", - /* 148 */ "MODIFY", - /* 149 */ "TAG", - /* 150 */ "CHANGE", - /* 151 */ "SET", - /* 152 */ "KILL", - /* 153 */ "CONNECTION", - /* 154 */ "STREAM", - /* 155 */ "COLON", - /* 156 */ "ABORT", - /* 157 */ "AFTER", - /* 158 */ "ATTACH", - /* 159 */ "BEFORE", - /* 160 */ "BEGIN", - /* 161 */ "CASCADE", - /* 162 */ "CLUSTER", - /* 163 */ "CONFLICT", - /* 164 */ "COPY", - /* 165 */ "DEFERRED", - /* 166 */ "DELIMITERS", - /* 167 */ "DETACH", - /* 168 */ "EACH", - /* 169 */ "END", - /* 170 */ "EXPLAIN", - /* 171 */ "FAIL", - /* 172 */ "FOR", - /* 173 */ "IGNORE", - /* 174 */ "IMMEDIATE", - /* 175 */ "INITIALLY", - /* 176 */ "INSTEAD", - /* 177 */ "KEY", - /* 178 */ "OF", - /* 179 */ "RAISE", - /* 180 */ "REPLACE", - /* 181 */ "RESTRICT", - /* 182 */ "ROW", - /* 183 */ "STATEMENT", - /* 184 */ "TRIGGER", - /* 185 */ "VIEW", - /* 186 */ "IPTOKEN", + /* 89 */ "IPTOKEN", + /* 90 */ "AS", + /* 91 */ "OUTPUTTYPE", + /* 92 */ "AGGREGATE", + /* 93 */ "BUFSIZE", + /* 94 */ "PPS", + /* 95 */ "TSERIES", + /* 96 */ "DBS", + /* 97 */ "STORAGE", + /* 98 */ "QTIME", + /* 99 */ "CONNS", + /* 100 */ "STATE", + /* 101 */ "COMMA", + /* 102 */ "KEEP", + /* 103 */ "CACHE", + /* 104 */ "REPLICA", + /* 105 */ "QUORUM", + /* 106 */ "DAYS", + /* 107 */ "MINROWS", + /* 108 */ "MAXROWS", + /* 109 */ "BLOCKS", + /* 110 */ "CTIME", + /* 111 */ "WAL", + /* 112 */ "FSYNC", + /* 113 */ "COMP", + /* 114 */ "PRECISION", + /* 115 */ "UPDATE", + /* 116 */ "CACHELAST", + /* 117 */ "UNSIGNED", + /* 118 */ "TAGS", + /* 119 */ "USING", + /* 120 */ "NULL", + /* 121 */ "NOW", + /* 122 */ "SELECT", + /* 123 */ "UNION", + /* 124 */ "ALL", + /* 125 */ "DISTINCT", + /* 126 */ "FROM", + /* 127 */ "VARIABLE", + /* 128 */ "INTERVAL", + /* 129 */ "EVERY", + /* 130 */ "SESSION", + /* 131 */ "STATE_WINDOW", + /* 132 */ "FILL", + /* 133 */ "SLIDING", + /* 134 */ "ORDER", + /* 135 */ "BY", + /* 136 */ "ASC", + /* 137 */ "GROUP", + /* 138 */ "HAVING", + /* 139 */ "LIMIT", + /* 140 */ "OFFSET", + /* 141 */ "SLIMIT", + /* 142 */ "SOFFSET", + /* 143 */ "WHERE", + /* 144 */ "RESET", + /* 145 */ "QUERY", + /* 146 */ "SYNCDB", + /* 147 */ "ADD", + /* 148 */ "COLUMN", + /* 149 */ "MODIFY", + /* 150 */ "TAG", + /* 151 */ "CHANGE", + /* 152 */ "SET", + /* 153 */ "KILL", + /* 154 */ "CONNECTION", + /* 155 */ "STREAM", + /* 156 */ "COLON", + /* 157 */ "ABORT", + /* 158 */ "AFTER", + /* 159 */ "ATTACH", + /* 160 */ "BEFORE", + /* 161 */ "BEGIN", + /* 162 */ "CASCADE", + /* 163 */ "CLUSTER", + /* 164 */ "CONFLICT", + /* 165 */ "COPY", + /* 166 */ "DEFERRED", + /* 167 */ "DELIMITERS", + /* 168 */ "DETACH", + /* 169 */ "EACH", + /* 170 */ "END", + /* 171 */ "EXPLAIN", + /* 172 */ "FAIL", + /* 173 */ "FOR", + /* 174 */ "IGNORE", + /* 175 */ "IMMEDIATE", + /* 176 */ "INITIALLY", + /* 177 */ "INSTEAD", + /* 178 */ "KEY", + /* 179 */ "OF", + /* 180 */ "RAISE", + /* 181 */ "REPLACE", + /* 182 */ "RESTRICT", + /* 183 */ "ROW", + /* 184 */ "STATEMENT", + /* 185 */ "TRIGGER", + /* 186 */ "VIEW", /* 187 */ "SEMI", /* 188 */ "NONE", /* 189 */ "PREV", @@ -1138,248 +1139,249 @@ static const char *const yyRuleName[] = { /* 55 */ "ifnotexists ::= IF NOT EXISTS", /* 56 */ "ifnotexists ::=", /* 57 */ "cmd ::= CREATE DNODE ids PORT ids", - /* 58 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", - /* 59 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", - /* 60 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", - /* 61 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", - /* 62 */ "cmd ::= CREATE USER ids PASS ids", - /* 63 */ "bufsize ::=", - /* 64 */ "bufsize ::= BUFSIZE INTEGER", - /* 65 */ "pps ::=", - /* 66 */ "pps ::= PPS INTEGER", - /* 67 */ "tseries ::=", - /* 68 */ "tseries ::= TSERIES INTEGER", - /* 69 */ "dbs ::=", - /* 70 */ "dbs ::= DBS INTEGER", - /* 71 */ "streams ::=", - /* 72 */ "streams ::= STREAMS INTEGER", - /* 73 */ "storage ::=", - /* 74 */ "storage ::= STORAGE INTEGER", - /* 75 */ "qtime ::=", - /* 76 */ "qtime ::= QTIME INTEGER", - /* 77 */ "users ::=", - /* 78 */ "users ::= USERS INTEGER", - /* 79 */ "conns ::=", - /* 80 */ "conns ::= CONNS INTEGER", - /* 81 */ "state ::=", - /* 82 */ "state ::= STATE ids", - /* 83 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", - /* 84 */ "intitemlist ::= intitemlist COMMA intitem", - /* 85 */ "intitemlist ::= intitem", - /* 86 */ "intitem ::= INTEGER", - /* 87 */ "keep ::= KEEP intitemlist", - /* 88 */ "cache ::= CACHE INTEGER", - /* 89 */ "replica ::= REPLICA INTEGER", - /* 90 */ "quorum ::= QUORUM INTEGER", - /* 91 */ "days ::= DAYS INTEGER", - /* 92 */ "minrows ::= MINROWS INTEGER", - /* 93 */ "maxrows ::= MAXROWS INTEGER", - /* 94 */ "blocks ::= BLOCKS INTEGER", - /* 95 */ "ctime ::= CTIME INTEGER", - /* 96 */ "wal ::= WAL INTEGER", - /* 97 */ "fsync ::= FSYNC INTEGER", - /* 98 */ "comp ::= COMP INTEGER", - /* 99 */ "prec ::= PRECISION STRING", - /* 100 */ "update ::= UPDATE INTEGER", - /* 101 */ "cachelast ::= CACHELAST INTEGER", - /* 102 */ "db_optr ::=", - /* 103 */ "db_optr ::= db_optr cache", - /* 104 */ "db_optr ::= db_optr replica", - /* 105 */ "db_optr ::= db_optr quorum", - /* 106 */ "db_optr ::= db_optr days", - /* 107 */ "db_optr ::= db_optr minrows", - /* 108 */ "db_optr ::= db_optr maxrows", - /* 109 */ "db_optr ::= db_optr blocks", - /* 110 */ "db_optr ::= db_optr ctime", - /* 111 */ "db_optr ::= db_optr wal", - /* 112 */ "db_optr ::= db_optr fsync", - /* 113 */ "db_optr ::= db_optr comp", - /* 114 */ "db_optr ::= db_optr prec", - /* 115 */ "db_optr ::= db_optr keep", - /* 116 */ "db_optr ::= db_optr update", - /* 117 */ "db_optr ::= db_optr cachelast", - /* 118 */ "alter_db_optr ::=", - /* 119 */ "alter_db_optr ::= alter_db_optr replica", - /* 120 */ "alter_db_optr ::= alter_db_optr quorum", - /* 121 */ "alter_db_optr ::= alter_db_optr keep", - /* 122 */ "alter_db_optr ::= alter_db_optr blocks", - /* 123 */ "alter_db_optr ::= alter_db_optr comp", - /* 124 */ "alter_db_optr ::= alter_db_optr update", - /* 125 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 126 */ "typename ::= ids", - /* 127 */ "typename ::= ids LP signed RP", - /* 128 */ "typename ::= ids UNSIGNED", - /* 129 */ "signed ::= INTEGER", - /* 130 */ "signed ::= PLUS INTEGER", - /* 131 */ "signed ::= MINUS INTEGER", - /* 132 */ "cmd ::= CREATE TABLE create_table_args", - /* 133 */ "cmd ::= CREATE TABLE create_stable_args", - /* 134 */ "cmd ::= CREATE STABLE create_stable_args", - /* 135 */ "cmd ::= CREATE TABLE create_table_list", - /* 136 */ "create_table_list ::= create_from_stable", - /* 137 */ "create_table_list ::= create_table_list create_from_stable", - /* 138 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 139 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 140 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", - /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", - /* 142 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 143 */ "tagNamelist ::= ids", - /* 144 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 145 */ "columnlist ::= columnlist COMMA column", - /* 146 */ "columnlist ::= column", - /* 147 */ "column ::= ids typename", - /* 148 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", - /* 149 */ "tagitemlist1 ::= tagitem1", - /* 150 */ "tagitem1 ::= MINUS INTEGER", - /* 151 */ "tagitem1 ::= MINUS FLOAT", - /* 152 */ "tagitem1 ::= PLUS INTEGER", - /* 153 */ "tagitem1 ::= PLUS FLOAT", - /* 154 */ "tagitem1 ::= INTEGER", - /* 155 */ "tagitem1 ::= FLOAT", - /* 156 */ "tagitem1 ::= STRING", - /* 157 */ "tagitem1 ::= BOOL", - /* 158 */ "tagitem1 ::= NULL", - /* 159 */ "tagitem1 ::= NOW", - /* 160 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 161 */ "tagitemlist ::= tagitem", - /* 162 */ "tagitem ::= INTEGER", - /* 163 */ "tagitem ::= FLOAT", - /* 164 */ "tagitem ::= STRING", - /* 165 */ "tagitem ::= BOOL", - /* 166 */ "tagitem ::= NULL", - /* 167 */ "tagitem ::= NOW", - /* 168 */ "tagitem ::= MINUS INTEGER", - /* 169 */ "tagitem ::= MINUS FLOAT", - /* 170 */ "tagitem ::= PLUS INTEGER", - /* 171 */ "tagitem ::= PLUS FLOAT", - /* 172 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 173 */ "select ::= LP select RP", - /* 174 */ "union ::= select", - /* 175 */ "union ::= union UNION ALL select", - /* 176 */ "union ::= union UNION select", - /* 177 */ "cmd ::= union", - /* 178 */ "select ::= SELECT selcollist", - /* 179 */ "sclp ::= selcollist COMMA", - /* 180 */ "sclp ::=", - /* 181 */ "selcollist ::= sclp distinct expr as", - /* 182 */ "selcollist ::= sclp STAR", - /* 183 */ "as ::= AS ids", - /* 184 */ "as ::= ids", - /* 185 */ "as ::=", - /* 186 */ "distinct ::= DISTINCT", - /* 187 */ "distinct ::=", - /* 188 */ "from ::= FROM tablelist", - /* 189 */ "from ::= FROM sub", - /* 190 */ "sub ::= LP union RP", - /* 191 */ "sub ::= LP union RP ids", - /* 192 */ "sub ::= sub COMMA LP union RP ids", - /* 193 */ "tablelist ::= ids cpxName", - /* 194 */ "tablelist ::= ids cpxName ids", - /* 195 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 196 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 197 */ "tmvar ::= VARIABLE", - /* 198 */ "interval_option ::= intervalKey LP tmvar RP", - /* 199 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", - /* 200 */ "interval_option ::=", - /* 201 */ "intervalKey ::= INTERVAL", - /* 202 */ "intervalKey ::= EVERY", - /* 203 */ "session_option ::=", - /* 204 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 205 */ "windowstate_option ::=", - /* 206 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 207 */ "fill_opt ::=", - /* 208 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 209 */ "fill_opt ::= FILL LP ID RP", - /* 210 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 211 */ "sliding_opt ::=", - /* 212 */ "orderby_opt ::=", - /* 213 */ "orderby_opt ::= ORDER BY sortlist", - /* 214 */ "sortlist ::= sortlist COMMA item sortorder", - /* 215 */ "sortlist ::= item sortorder", - /* 216 */ "item ::= ids cpxName", - /* 217 */ "sortorder ::= ASC", - /* 218 */ "sortorder ::= DESC", - /* 219 */ "sortorder ::=", - /* 220 */ "groupby_opt ::=", - /* 221 */ "groupby_opt ::= GROUP BY grouplist", - /* 222 */ "grouplist ::= grouplist COMMA item", - /* 223 */ "grouplist ::= item", - /* 224 */ "having_opt ::=", - /* 225 */ "having_opt ::= HAVING expr", - /* 226 */ "limit_opt ::=", - /* 227 */ "limit_opt ::= LIMIT signed", - /* 228 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 229 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 230 */ "slimit_opt ::=", - /* 231 */ "slimit_opt ::= SLIMIT signed", - /* 232 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 233 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 234 */ "where_opt ::=", - /* 235 */ "where_opt ::= WHERE expr", - /* 236 */ "expr ::= LP expr RP", - /* 237 */ "expr ::= ID", - /* 238 */ "expr ::= ID DOT ID", - /* 239 */ "expr ::= ID DOT STAR", - /* 240 */ "expr ::= INTEGER", - /* 241 */ "expr ::= MINUS INTEGER", - /* 242 */ "expr ::= PLUS INTEGER", - /* 243 */ "expr ::= FLOAT", - /* 244 */ "expr ::= MINUS FLOAT", - /* 245 */ "expr ::= PLUS FLOAT", - /* 246 */ "expr ::= STRING", - /* 247 */ "expr ::= NOW", - /* 248 */ "expr ::= VARIABLE", - /* 249 */ "expr ::= PLUS VARIABLE", - /* 250 */ "expr ::= MINUS VARIABLE", - /* 251 */ "expr ::= BOOL", - /* 252 */ "expr ::= NULL", - /* 253 */ "expr ::= ID LP exprlist RP", - /* 254 */ "expr ::= ID LP STAR RP", - /* 255 */ "expr ::= expr IS NULL", - /* 256 */ "expr ::= expr IS NOT NULL", - /* 257 */ "expr ::= expr LT expr", - /* 258 */ "expr ::= expr GT expr", - /* 259 */ "expr ::= expr LE expr", - /* 260 */ "expr ::= expr GE expr", - /* 261 */ "expr ::= expr NE expr", - /* 262 */ "expr ::= expr EQ expr", - /* 263 */ "expr ::= expr BETWEEN expr AND expr", - /* 264 */ "expr ::= expr AND expr", - /* 265 */ "expr ::= expr OR expr", - /* 266 */ "expr ::= expr PLUS expr", - /* 267 */ "expr ::= expr MINUS expr", - /* 268 */ "expr ::= expr STAR expr", - /* 269 */ "expr ::= expr SLASH expr", - /* 270 */ "expr ::= expr REM expr", - /* 271 */ "expr ::= expr LIKE expr", - /* 272 */ "expr ::= expr MATCH expr", - /* 273 */ "expr ::= expr NMATCH expr", - /* 274 */ "expr ::= expr IN LP exprlist RP", - /* 275 */ "exprlist ::= exprlist COMMA expritem", - /* 276 */ "exprlist ::= expritem", - /* 277 */ "expritem ::= expr", - /* 278 */ "expritem ::=", - /* 279 */ "cmd ::= RESET QUERY CACHE", - /* 280 */ "cmd ::= SYNCDB ids REPLICA", - /* 281 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 282 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 283 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 284 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 285 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 286 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 287 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 288 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 289 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 290 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 291 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 292 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 293 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 294 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 295 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 296 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 297 */ "cmd ::= KILL CONNECTION INTEGER", - /* 298 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 299 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 58 */ "cmd ::= CREATE DNODE IPTOKEN PORT ids", + /* 59 */ "cmd ::= CREATE ACCOUNT ids PASS ids acct_optr", + /* 60 */ "cmd ::= CREATE DATABASE ifnotexists ids db_optr", + /* 61 */ "cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", + /* 62 */ "cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize", + /* 63 */ "cmd ::= CREATE USER ids PASS ids", + /* 64 */ "bufsize ::=", + /* 65 */ "bufsize ::= BUFSIZE INTEGER", + /* 66 */ "pps ::=", + /* 67 */ "pps ::= PPS INTEGER", + /* 68 */ "tseries ::=", + /* 69 */ "tseries ::= TSERIES INTEGER", + /* 70 */ "dbs ::=", + /* 71 */ "dbs ::= DBS INTEGER", + /* 72 */ "streams ::=", + /* 73 */ "streams ::= STREAMS INTEGER", + /* 74 */ "storage ::=", + /* 75 */ "storage ::= STORAGE INTEGER", + /* 76 */ "qtime ::=", + /* 77 */ "qtime ::= QTIME INTEGER", + /* 78 */ "users ::=", + /* 79 */ "users ::= USERS INTEGER", + /* 80 */ "conns ::=", + /* 81 */ "conns ::= CONNS INTEGER", + /* 82 */ "state ::=", + /* 83 */ "state ::= STATE ids", + /* 84 */ "acct_optr ::= pps tseries storage streams qtime dbs users conns state", + /* 85 */ "intitemlist ::= intitemlist COMMA intitem", + /* 86 */ "intitemlist ::= intitem", + /* 87 */ "intitem ::= INTEGER", + /* 88 */ "keep ::= KEEP intitemlist", + /* 89 */ "cache ::= CACHE INTEGER", + /* 90 */ "replica ::= REPLICA INTEGER", + /* 91 */ "quorum ::= QUORUM INTEGER", + /* 92 */ "days ::= DAYS INTEGER", + /* 93 */ "minrows ::= MINROWS INTEGER", + /* 94 */ "maxrows ::= MAXROWS INTEGER", + /* 95 */ "blocks ::= BLOCKS INTEGER", + /* 96 */ "ctime ::= CTIME INTEGER", + /* 97 */ "wal ::= WAL INTEGER", + /* 98 */ "fsync ::= FSYNC INTEGER", + /* 99 */ "comp ::= COMP INTEGER", + /* 100 */ "prec ::= PRECISION STRING", + /* 101 */ "update ::= UPDATE INTEGER", + /* 102 */ "cachelast ::= CACHELAST INTEGER", + /* 103 */ "db_optr ::=", + /* 104 */ "db_optr ::= db_optr cache", + /* 105 */ "db_optr ::= db_optr replica", + /* 106 */ "db_optr ::= db_optr quorum", + /* 107 */ "db_optr ::= db_optr days", + /* 108 */ "db_optr ::= db_optr minrows", + /* 109 */ "db_optr ::= db_optr maxrows", + /* 110 */ "db_optr ::= db_optr blocks", + /* 111 */ "db_optr ::= db_optr ctime", + /* 112 */ "db_optr ::= db_optr wal", + /* 113 */ "db_optr ::= db_optr fsync", + /* 114 */ "db_optr ::= db_optr comp", + /* 115 */ "db_optr ::= db_optr prec", + /* 116 */ "db_optr ::= db_optr keep", + /* 117 */ "db_optr ::= db_optr update", + /* 118 */ "db_optr ::= db_optr cachelast", + /* 119 */ "alter_db_optr ::=", + /* 120 */ "alter_db_optr ::= alter_db_optr replica", + /* 121 */ "alter_db_optr ::= alter_db_optr quorum", + /* 122 */ "alter_db_optr ::= alter_db_optr keep", + /* 123 */ "alter_db_optr ::= alter_db_optr blocks", + /* 124 */ "alter_db_optr ::= alter_db_optr comp", + /* 125 */ "alter_db_optr ::= alter_db_optr update", + /* 126 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 127 */ "typename ::= ids", + /* 128 */ "typename ::= ids LP signed RP", + /* 129 */ "typename ::= ids UNSIGNED", + /* 130 */ "signed ::= INTEGER", + /* 131 */ "signed ::= PLUS INTEGER", + /* 132 */ "signed ::= MINUS INTEGER", + /* 133 */ "cmd ::= CREATE TABLE create_table_args", + /* 134 */ "cmd ::= CREATE TABLE create_stable_args", + /* 135 */ "cmd ::= CREATE STABLE create_stable_args", + /* 136 */ "cmd ::= CREATE TABLE create_table_list", + /* 137 */ "create_table_list ::= create_from_stable", + /* 138 */ "create_table_list ::= create_table_list create_from_stable", + /* 139 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 140 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", + /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", + /* 143 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 144 */ "tagNamelist ::= ids", + /* 145 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 146 */ "columnlist ::= columnlist COMMA column", + /* 147 */ "columnlist ::= column", + /* 148 */ "column ::= ids typename", + /* 149 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", + /* 150 */ "tagitemlist1 ::= tagitem1", + /* 151 */ "tagitem1 ::= MINUS INTEGER", + /* 152 */ "tagitem1 ::= MINUS FLOAT", + /* 153 */ "tagitem1 ::= PLUS INTEGER", + /* 154 */ "tagitem1 ::= PLUS FLOAT", + /* 155 */ "tagitem1 ::= INTEGER", + /* 156 */ "tagitem1 ::= FLOAT", + /* 157 */ "tagitem1 ::= STRING", + /* 158 */ "tagitem1 ::= BOOL", + /* 159 */ "tagitem1 ::= NULL", + /* 160 */ "tagitem1 ::= NOW", + /* 161 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 162 */ "tagitemlist ::= tagitem", + /* 163 */ "tagitem ::= INTEGER", + /* 164 */ "tagitem ::= FLOAT", + /* 165 */ "tagitem ::= STRING", + /* 166 */ "tagitem ::= BOOL", + /* 167 */ "tagitem ::= NULL", + /* 168 */ "tagitem ::= NOW", + /* 169 */ "tagitem ::= MINUS INTEGER", + /* 170 */ "tagitem ::= MINUS FLOAT", + /* 171 */ "tagitem ::= PLUS INTEGER", + /* 172 */ "tagitem ::= PLUS FLOAT", + /* 173 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 174 */ "select ::= LP select RP", + /* 175 */ "union ::= select", + /* 176 */ "union ::= union UNION ALL select", + /* 177 */ "union ::= union UNION select", + /* 178 */ "cmd ::= union", + /* 179 */ "select ::= SELECT selcollist", + /* 180 */ "sclp ::= selcollist COMMA", + /* 181 */ "sclp ::=", + /* 182 */ "selcollist ::= sclp distinct expr as", + /* 183 */ "selcollist ::= sclp STAR", + /* 184 */ "as ::= AS ids", + /* 185 */ "as ::= ids", + /* 186 */ "as ::=", + /* 187 */ "distinct ::= DISTINCT", + /* 188 */ "distinct ::=", + /* 189 */ "from ::= FROM tablelist", + /* 190 */ "from ::= FROM sub", + /* 191 */ "sub ::= LP union RP", + /* 192 */ "sub ::= LP union RP ids", + /* 193 */ "sub ::= sub COMMA LP union RP ids", + /* 194 */ "tablelist ::= ids cpxName", + /* 195 */ "tablelist ::= ids cpxName ids", + /* 196 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 197 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 198 */ "tmvar ::= VARIABLE", + /* 199 */ "interval_option ::= intervalKey LP tmvar RP", + /* 200 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", + /* 201 */ "interval_option ::=", + /* 202 */ "intervalKey ::= INTERVAL", + /* 203 */ "intervalKey ::= EVERY", + /* 204 */ "session_option ::=", + /* 205 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 206 */ "windowstate_option ::=", + /* 207 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 208 */ "fill_opt ::=", + /* 209 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 210 */ "fill_opt ::= FILL LP ID RP", + /* 211 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 212 */ "sliding_opt ::=", + /* 213 */ "orderby_opt ::=", + /* 214 */ "orderby_opt ::= ORDER BY sortlist", + /* 215 */ "sortlist ::= sortlist COMMA item sortorder", + /* 216 */ "sortlist ::= item sortorder", + /* 217 */ "item ::= ids cpxName", + /* 218 */ "sortorder ::= ASC", + /* 219 */ "sortorder ::= DESC", + /* 220 */ "sortorder ::=", + /* 221 */ "groupby_opt ::=", + /* 222 */ "groupby_opt ::= GROUP BY grouplist", + /* 223 */ "grouplist ::= grouplist COMMA item", + /* 224 */ "grouplist ::= item", + /* 225 */ "having_opt ::=", + /* 226 */ "having_opt ::= HAVING expr", + /* 227 */ "limit_opt ::=", + /* 228 */ "limit_opt ::= LIMIT signed", + /* 229 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 230 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 231 */ "slimit_opt ::=", + /* 232 */ "slimit_opt ::= SLIMIT signed", + /* 233 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 234 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 235 */ "where_opt ::=", + /* 236 */ "where_opt ::= WHERE expr", + /* 237 */ "expr ::= LP expr RP", + /* 238 */ "expr ::= ID", + /* 239 */ "expr ::= ID DOT ID", + /* 240 */ "expr ::= ID DOT STAR", + /* 241 */ "expr ::= INTEGER", + /* 242 */ "expr ::= MINUS INTEGER", + /* 243 */ "expr ::= PLUS INTEGER", + /* 244 */ "expr ::= FLOAT", + /* 245 */ "expr ::= MINUS FLOAT", + /* 246 */ "expr ::= PLUS FLOAT", + /* 247 */ "expr ::= STRING", + /* 248 */ "expr ::= NOW", + /* 249 */ "expr ::= VARIABLE", + /* 250 */ "expr ::= PLUS VARIABLE", + /* 251 */ "expr ::= MINUS VARIABLE", + /* 252 */ "expr ::= BOOL", + /* 253 */ "expr ::= NULL", + /* 254 */ "expr ::= ID LP exprlist RP", + /* 255 */ "expr ::= ID LP STAR RP", + /* 256 */ "expr ::= expr IS NULL", + /* 257 */ "expr ::= expr IS NOT NULL", + /* 258 */ "expr ::= expr LT expr", + /* 259 */ "expr ::= expr GT expr", + /* 260 */ "expr ::= expr LE expr", + /* 261 */ "expr ::= expr GE expr", + /* 262 */ "expr ::= expr NE expr", + /* 263 */ "expr ::= expr EQ expr", + /* 264 */ "expr ::= expr BETWEEN expr AND expr", + /* 265 */ "expr ::= expr AND expr", + /* 266 */ "expr ::= expr OR expr", + /* 267 */ "expr ::= expr PLUS expr", + /* 268 */ "expr ::= expr MINUS expr", + /* 269 */ "expr ::= expr STAR expr", + /* 270 */ "expr ::= expr SLASH expr", + /* 271 */ "expr ::= expr REM expr", + /* 272 */ "expr ::= expr LIKE expr", + /* 273 */ "expr ::= expr MATCH expr", + /* 274 */ "expr ::= expr NMATCH expr", + /* 275 */ "expr ::= expr IN LP exprlist RP", + /* 276 */ "exprlist ::= exprlist COMMA expritem", + /* 277 */ "exprlist ::= expritem", + /* 278 */ "expritem ::= expr", + /* 279 */ "expritem ::=", + /* 280 */ "cmd ::= RESET QUERY CACHE", + /* 281 */ "cmd ::= SYNCDB ids REPLICA", + /* 282 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 283 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 284 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 285 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 286 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 287 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 288 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 289 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 290 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 291 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 292 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 293 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 294 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 295 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 296 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 297 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 298 */ "cmd ::= KILL CONNECTION INTEGER", + /* 299 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 300 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1906,248 +1908,249 @@ static const struct { { 207, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */ { 207, 0 }, /* (56) ifnotexists ::= */ { 199, -5 }, /* (57) cmd ::= CREATE DNODE ids PORT ids */ - { 199, -6 }, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 199, -5 }, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 199, -8 }, /* (60) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 199, -9 }, /* (61) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 199, -5 }, /* (62) cmd ::= CREATE USER ids PASS ids */ - { 210, 0 }, /* (63) bufsize ::= */ - { 210, -2 }, /* (64) bufsize ::= BUFSIZE INTEGER */ - { 211, 0 }, /* (65) pps ::= */ - { 211, -2 }, /* (66) pps ::= PPS INTEGER */ - { 212, 0 }, /* (67) tseries ::= */ - { 212, -2 }, /* (68) tseries ::= TSERIES INTEGER */ - { 213, 0 }, /* (69) dbs ::= */ - { 213, -2 }, /* (70) dbs ::= DBS INTEGER */ - { 214, 0 }, /* (71) streams ::= */ - { 214, -2 }, /* (72) streams ::= STREAMS INTEGER */ - { 215, 0 }, /* (73) storage ::= */ - { 215, -2 }, /* (74) storage ::= STORAGE INTEGER */ - { 216, 0 }, /* (75) qtime ::= */ - { 216, -2 }, /* (76) qtime ::= QTIME INTEGER */ - { 217, 0 }, /* (77) users ::= */ - { 217, -2 }, /* (78) users ::= USERS INTEGER */ - { 218, 0 }, /* (79) conns ::= */ - { 218, -2 }, /* (80) conns ::= CONNS INTEGER */ - { 219, 0 }, /* (81) state ::= */ - { 219, -2 }, /* (82) state ::= STATE ids */ - { 205, -9 }, /* (83) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 220, -3 }, /* (84) intitemlist ::= intitemlist COMMA intitem */ - { 220, -1 }, /* (85) intitemlist ::= intitem */ - { 221, -1 }, /* (86) intitem ::= INTEGER */ - { 222, -2 }, /* (87) keep ::= KEEP intitemlist */ - { 223, -2 }, /* (88) cache ::= CACHE INTEGER */ - { 224, -2 }, /* (89) replica ::= REPLICA INTEGER */ - { 225, -2 }, /* (90) quorum ::= QUORUM INTEGER */ - { 226, -2 }, /* (91) days ::= DAYS INTEGER */ - { 227, -2 }, /* (92) minrows ::= MINROWS INTEGER */ - { 228, -2 }, /* (93) maxrows ::= MAXROWS INTEGER */ - { 229, -2 }, /* (94) blocks ::= BLOCKS INTEGER */ - { 230, -2 }, /* (95) ctime ::= CTIME INTEGER */ - { 231, -2 }, /* (96) wal ::= WAL INTEGER */ - { 232, -2 }, /* (97) fsync ::= FSYNC INTEGER */ - { 233, -2 }, /* (98) comp ::= COMP INTEGER */ - { 234, -2 }, /* (99) prec ::= PRECISION STRING */ - { 235, -2 }, /* (100) update ::= UPDATE INTEGER */ - { 236, -2 }, /* (101) cachelast ::= CACHELAST INTEGER */ - { 208, 0 }, /* (102) db_optr ::= */ - { 208, -2 }, /* (103) db_optr ::= db_optr cache */ - { 208, -2 }, /* (104) db_optr ::= db_optr replica */ - { 208, -2 }, /* (105) db_optr ::= db_optr quorum */ - { 208, -2 }, /* (106) db_optr ::= db_optr days */ - { 208, -2 }, /* (107) db_optr ::= db_optr minrows */ - { 208, -2 }, /* (108) db_optr ::= db_optr maxrows */ - { 208, -2 }, /* (109) db_optr ::= db_optr blocks */ - { 208, -2 }, /* (110) db_optr ::= db_optr ctime */ - { 208, -2 }, /* (111) db_optr ::= db_optr wal */ - { 208, -2 }, /* (112) db_optr ::= db_optr fsync */ - { 208, -2 }, /* (113) db_optr ::= db_optr comp */ - { 208, -2 }, /* (114) db_optr ::= db_optr prec */ - { 208, -2 }, /* (115) db_optr ::= db_optr keep */ - { 208, -2 }, /* (116) db_optr ::= db_optr update */ - { 208, -2 }, /* (117) db_optr ::= db_optr cachelast */ - { 204, 0 }, /* (118) alter_db_optr ::= */ - { 204, -2 }, /* (119) alter_db_optr ::= alter_db_optr replica */ - { 204, -2 }, /* (120) alter_db_optr ::= alter_db_optr quorum */ - { 204, -2 }, /* (121) alter_db_optr ::= alter_db_optr keep */ - { 204, -2 }, /* (122) alter_db_optr ::= alter_db_optr blocks */ - { 204, -2 }, /* (123) alter_db_optr ::= alter_db_optr comp */ - { 204, -2 }, /* (124) alter_db_optr ::= alter_db_optr update */ - { 204, -2 }, /* (125) alter_db_optr ::= alter_db_optr cachelast */ - { 209, -1 }, /* (126) typename ::= ids */ - { 209, -4 }, /* (127) typename ::= ids LP signed RP */ - { 209, -2 }, /* (128) typename ::= ids UNSIGNED */ - { 237, -1 }, /* (129) signed ::= INTEGER */ - { 237, -2 }, /* (130) signed ::= PLUS INTEGER */ - { 237, -2 }, /* (131) signed ::= MINUS INTEGER */ - { 199, -3 }, /* (132) cmd ::= CREATE TABLE create_table_args */ - { 199, -3 }, /* (133) cmd ::= CREATE TABLE create_stable_args */ - { 199, -3 }, /* (134) cmd ::= CREATE STABLE create_stable_args */ - { 199, -3 }, /* (135) cmd ::= CREATE TABLE create_table_list */ - { 240, -1 }, /* (136) create_table_list ::= create_from_stable */ - { 240, -2 }, /* (137) create_table_list ::= create_table_list create_from_stable */ - { 238, -6 }, /* (138) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 239, -10 }, /* (139) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 241, -10 }, /* (140) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ - { 241, -13 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ - { 244, -3 }, /* (142) tagNamelist ::= tagNamelist COMMA ids */ - { 244, -1 }, /* (143) tagNamelist ::= ids */ - { 238, -5 }, /* (144) create_table_args ::= ifnotexists ids cpxName AS select */ - { 242, -3 }, /* (145) columnlist ::= columnlist COMMA column */ - { 242, -1 }, /* (146) columnlist ::= column */ - { 246, -2 }, /* (147) column ::= ids typename */ - { 243, -3 }, /* (148) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ - { 243, -1 }, /* (149) tagitemlist1 ::= tagitem1 */ - { 247, -2 }, /* (150) tagitem1 ::= MINUS INTEGER */ - { 247, -2 }, /* (151) tagitem1 ::= MINUS FLOAT */ - { 247, -2 }, /* (152) tagitem1 ::= PLUS INTEGER */ - { 247, -2 }, /* (153) tagitem1 ::= PLUS FLOAT */ - { 247, -1 }, /* (154) tagitem1 ::= INTEGER */ - { 247, -1 }, /* (155) tagitem1 ::= FLOAT */ - { 247, -1 }, /* (156) tagitem1 ::= STRING */ - { 247, -1 }, /* (157) tagitem1 ::= BOOL */ - { 247, -1 }, /* (158) tagitem1 ::= NULL */ - { 247, -1 }, /* (159) tagitem1 ::= NOW */ - { 248, -3 }, /* (160) tagitemlist ::= tagitemlist COMMA tagitem */ - { 248, -1 }, /* (161) tagitemlist ::= tagitem */ - { 249, -1 }, /* (162) tagitem ::= INTEGER */ - { 249, -1 }, /* (163) tagitem ::= FLOAT */ - { 249, -1 }, /* (164) tagitem ::= STRING */ - { 249, -1 }, /* (165) tagitem ::= BOOL */ - { 249, -1 }, /* (166) tagitem ::= NULL */ - { 249, -1 }, /* (167) tagitem ::= NOW */ - { 249, -2 }, /* (168) tagitem ::= MINUS INTEGER */ - { 249, -2 }, /* (169) tagitem ::= MINUS FLOAT */ - { 249, -2 }, /* (170) tagitem ::= PLUS INTEGER */ - { 249, -2 }, /* (171) tagitem ::= PLUS FLOAT */ - { 245, -14 }, /* (172) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 245, -3 }, /* (173) select ::= LP select RP */ - { 263, -1 }, /* (174) union ::= select */ - { 263, -4 }, /* (175) union ::= union UNION ALL select */ - { 263, -3 }, /* (176) union ::= union UNION select */ - { 199, -1 }, /* (177) cmd ::= union */ - { 245, -2 }, /* (178) select ::= SELECT selcollist */ - { 264, -2 }, /* (179) sclp ::= selcollist COMMA */ - { 264, 0 }, /* (180) sclp ::= */ - { 250, -4 }, /* (181) selcollist ::= sclp distinct expr as */ - { 250, -2 }, /* (182) selcollist ::= sclp STAR */ - { 267, -2 }, /* (183) as ::= AS ids */ - { 267, -1 }, /* (184) as ::= ids */ - { 267, 0 }, /* (185) as ::= */ - { 265, -1 }, /* (186) distinct ::= DISTINCT */ - { 265, 0 }, /* (187) distinct ::= */ - { 251, -2 }, /* (188) from ::= FROM tablelist */ - { 251, -2 }, /* (189) from ::= FROM sub */ - { 269, -3 }, /* (190) sub ::= LP union RP */ - { 269, -4 }, /* (191) sub ::= LP union RP ids */ - { 269, -6 }, /* (192) sub ::= sub COMMA LP union RP ids */ - { 268, -2 }, /* (193) tablelist ::= ids cpxName */ - { 268, -3 }, /* (194) tablelist ::= ids cpxName ids */ - { 268, -4 }, /* (195) tablelist ::= tablelist COMMA ids cpxName */ - { 268, -5 }, /* (196) tablelist ::= tablelist COMMA ids cpxName ids */ - { 270, -1 }, /* (197) tmvar ::= VARIABLE */ - { 253, -4 }, /* (198) interval_option ::= intervalKey LP tmvar RP */ - { 253, -6 }, /* (199) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - { 253, 0 }, /* (200) interval_option ::= */ - { 271, -1 }, /* (201) intervalKey ::= INTERVAL */ - { 271, -1 }, /* (202) intervalKey ::= EVERY */ - { 255, 0 }, /* (203) session_option ::= */ - { 255, -7 }, /* (204) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 256, 0 }, /* (205) windowstate_option ::= */ - { 256, -4 }, /* (206) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 257, 0 }, /* (207) fill_opt ::= */ - { 257, -6 }, /* (208) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 257, -4 }, /* (209) fill_opt ::= FILL LP ID RP */ - { 254, -4 }, /* (210) sliding_opt ::= SLIDING LP tmvar RP */ - { 254, 0 }, /* (211) sliding_opt ::= */ - { 260, 0 }, /* (212) orderby_opt ::= */ - { 260, -3 }, /* (213) orderby_opt ::= ORDER BY sortlist */ - { 272, -4 }, /* (214) sortlist ::= sortlist COMMA item sortorder */ - { 272, -2 }, /* (215) sortlist ::= item sortorder */ - { 274, -2 }, /* (216) item ::= ids cpxName */ - { 275, -1 }, /* (217) sortorder ::= ASC */ - { 275, -1 }, /* (218) sortorder ::= DESC */ - { 275, 0 }, /* (219) sortorder ::= */ - { 258, 0 }, /* (220) groupby_opt ::= */ - { 258, -3 }, /* (221) groupby_opt ::= GROUP BY grouplist */ - { 276, -3 }, /* (222) grouplist ::= grouplist COMMA item */ - { 276, -1 }, /* (223) grouplist ::= item */ - { 259, 0 }, /* (224) having_opt ::= */ - { 259, -2 }, /* (225) having_opt ::= HAVING expr */ - { 262, 0 }, /* (226) limit_opt ::= */ - { 262, -2 }, /* (227) limit_opt ::= LIMIT signed */ - { 262, -4 }, /* (228) limit_opt ::= LIMIT signed OFFSET signed */ - { 262, -4 }, /* (229) limit_opt ::= LIMIT signed COMMA signed */ - { 261, 0 }, /* (230) slimit_opt ::= */ - { 261, -2 }, /* (231) slimit_opt ::= SLIMIT signed */ - { 261, -4 }, /* (232) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 261, -4 }, /* (233) slimit_opt ::= SLIMIT signed COMMA signed */ - { 252, 0 }, /* (234) where_opt ::= */ - { 252, -2 }, /* (235) where_opt ::= WHERE expr */ - { 266, -3 }, /* (236) expr ::= LP expr RP */ - { 266, -1 }, /* (237) expr ::= ID */ - { 266, -3 }, /* (238) expr ::= ID DOT ID */ - { 266, -3 }, /* (239) expr ::= ID DOT STAR */ - { 266, -1 }, /* (240) expr ::= INTEGER */ - { 266, -2 }, /* (241) expr ::= MINUS INTEGER */ - { 266, -2 }, /* (242) expr ::= PLUS INTEGER */ - { 266, -1 }, /* (243) expr ::= FLOAT */ - { 266, -2 }, /* (244) expr ::= MINUS FLOAT */ - { 266, -2 }, /* (245) expr ::= PLUS FLOAT */ - { 266, -1 }, /* (246) expr ::= STRING */ - { 266, -1 }, /* (247) expr ::= NOW */ - { 266, -1 }, /* (248) expr ::= VARIABLE */ - { 266, -2 }, /* (249) expr ::= PLUS VARIABLE */ - { 266, -2 }, /* (250) expr ::= MINUS VARIABLE */ - { 266, -1 }, /* (251) expr ::= BOOL */ - { 266, -1 }, /* (252) expr ::= NULL */ - { 266, -4 }, /* (253) expr ::= ID LP exprlist RP */ - { 266, -4 }, /* (254) expr ::= ID LP STAR RP */ - { 266, -3 }, /* (255) expr ::= expr IS NULL */ - { 266, -4 }, /* (256) expr ::= expr IS NOT NULL */ - { 266, -3 }, /* (257) expr ::= expr LT expr */ - { 266, -3 }, /* (258) expr ::= expr GT expr */ - { 266, -3 }, /* (259) expr ::= expr LE expr */ - { 266, -3 }, /* (260) expr ::= expr GE expr */ - { 266, -3 }, /* (261) expr ::= expr NE expr */ - { 266, -3 }, /* (262) expr ::= expr EQ expr */ - { 266, -5 }, /* (263) expr ::= expr BETWEEN expr AND expr */ - { 266, -3 }, /* (264) expr ::= expr AND expr */ - { 266, -3 }, /* (265) expr ::= expr OR expr */ - { 266, -3 }, /* (266) expr ::= expr PLUS expr */ - { 266, -3 }, /* (267) expr ::= expr MINUS expr */ - { 266, -3 }, /* (268) expr ::= expr STAR expr */ - { 266, -3 }, /* (269) expr ::= expr SLASH expr */ - { 266, -3 }, /* (270) expr ::= expr REM expr */ - { 266, -3 }, /* (271) expr ::= expr LIKE expr */ - { 266, -3 }, /* (272) expr ::= expr MATCH expr */ - { 266, -3 }, /* (273) expr ::= expr NMATCH expr */ - { 266, -5 }, /* (274) expr ::= expr IN LP exprlist RP */ - { 206, -3 }, /* (275) exprlist ::= exprlist COMMA expritem */ - { 206, -1 }, /* (276) exprlist ::= expritem */ - { 277, -1 }, /* (277) expritem ::= expr */ - { 277, 0 }, /* (278) expritem ::= */ - { 199, -3 }, /* (279) cmd ::= RESET QUERY CACHE */ - { 199, -3 }, /* (280) cmd ::= SYNCDB ids REPLICA */ - { 199, -7 }, /* (281) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 199, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 199, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 199, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 199, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 199, -8 }, /* (286) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 199, -9 }, /* (287) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 199, -7 }, /* (288) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 199, -7 }, /* (289) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 199, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 199, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 199, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 199, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 199, -8 }, /* (294) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 199, -9 }, /* (295) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 199, -7 }, /* (296) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 199, -3 }, /* (297) cmd ::= KILL CONNECTION INTEGER */ - { 199, -5 }, /* (298) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 199, -5 }, /* (299) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 199, -5 }, /* (58) cmd ::= CREATE DNODE IPTOKEN PORT ids */ + { 199, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 199, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 199, -8 }, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 199, -9 }, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 199, -5 }, /* (63) cmd ::= CREATE USER ids PASS ids */ + { 210, 0 }, /* (64) bufsize ::= */ + { 210, -2 }, /* (65) bufsize ::= BUFSIZE INTEGER */ + { 211, 0 }, /* (66) pps ::= */ + { 211, -2 }, /* (67) pps ::= PPS INTEGER */ + { 212, 0 }, /* (68) tseries ::= */ + { 212, -2 }, /* (69) tseries ::= TSERIES INTEGER */ + { 213, 0 }, /* (70) dbs ::= */ + { 213, -2 }, /* (71) dbs ::= DBS INTEGER */ + { 214, 0 }, /* (72) streams ::= */ + { 214, -2 }, /* (73) streams ::= STREAMS INTEGER */ + { 215, 0 }, /* (74) storage ::= */ + { 215, -2 }, /* (75) storage ::= STORAGE INTEGER */ + { 216, 0 }, /* (76) qtime ::= */ + { 216, -2 }, /* (77) qtime ::= QTIME INTEGER */ + { 217, 0 }, /* (78) users ::= */ + { 217, -2 }, /* (79) users ::= USERS INTEGER */ + { 218, 0 }, /* (80) conns ::= */ + { 218, -2 }, /* (81) conns ::= CONNS INTEGER */ + { 219, 0 }, /* (82) state ::= */ + { 219, -2 }, /* (83) state ::= STATE ids */ + { 205, -9 }, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 220, -3 }, /* (85) intitemlist ::= intitemlist COMMA intitem */ + { 220, -1 }, /* (86) intitemlist ::= intitem */ + { 221, -1 }, /* (87) intitem ::= INTEGER */ + { 222, -2 }, /* (88) keep ::= KEEP intitemlist */ + { 223, -2 }, /* (89) cache ::= CACHE INTEGER */ + { 224, -2 }, /* (90) replica ::= REPLICA INTEGER */ + { 225, -2 }, /* (91) quorum ::= QUORUM INTEGER */ + { 226, -2 }, /* (92) days ::= DAYS INTEGER */ + { 227, -2 }, /* (93) minrows ::= MINROWS INTEGER */ + { 228, -2 }, /* (94) maxrows ::= MAXROWS INTEGER */ + { 229, -2 }, /* (95) blocks ::= BLOCKS INTEGER */ + { 230, -2 }, /* (96) ctime ::= CTIME INTEGER */ + { 231, -2 }, /* (97) wal ::= WAL INTEGER */ + { 232, -2 }, /* (98) fsync ::= FSYNC INTEGER */ + { 233, -2 }, /* (99) comp ::= COMP INTEGER */ + { 234, -2 }, /* (100) prec ::= PRECISION STRING */ + { 235, -2 }, /* (101) update ::= UPDATE INTEGER */ + { 236, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */ + { 208, 0 }, /* (103) db_optr ::= */ + { 208, -2 }, /* (104) db_optr ::= db_optr cache */ + { 208, -2 }, /* (105) db_optr ::= db_optr replica */ + { 208, -2 }, /* (106) db_optr ::= db_optr quorum */ + { 208, -2 }, /* (107) db_optr ::= db_optr days */ + { 208, -2 }, /* (108) db_optr ::= db_optr minrows */ + { 208, -2 }, /* (109) db_optr ::= db_optr maxrows */ + { 208, -2 }, /* (110) db_optr ::= db_optr blocks */ + { 208, -2 }, /* (111) db_optr ::= db_optr ctime */ + { 208, -2 }, /* (112) db_optr ::= db_optr wal */ + { 208, -2 }, /* (113) db_optr ::= db_optr fsync */ + { 208, -2 }, /* (114) db_optr ::= db_optr comp */ + { 208, -2 }, /* (115) db_optr ::= db_optr prec */ + { 208, -2 }, /* (116) db_optr ::= db_optr keep */ + { 208, -2 }, /* (117) db_optr ::= db_optr update */ + { 208, -2 }, /* (118) db_optr ::= db_optr cachelast */ + { 204, 0 }, /* (119) alter_db_optr ::= */ + { 204, -2 }, /* (120) alter_db_optr ::= alter_db_optr replica */ + { 204, -2 }, /* (121) alter_db_optr ::= alter_db_optr quorum */ + { 204, -2 }, /* (122) alter_db_optr ::= alter_db_optr keep */ + { 204, -2 }, /* (123) alter_db_optr ::= alter_db_optr blocks */ + { 204, -2 }, /* (124) alter_db_optr ::= alter_db_optr comp */ + { 204, -2 }, /* (125) alter_db_optr ::= alter_db_optr update */ + { 204, -2 }, /* (126) alter_db_optr ::= alter_db_optr cachelast */ + { 209, -1 }, /* (127) typename ::= ids */ + { 209, -4 }, /* (128) typename ::= ids LP signed RP */ + { 209, -2 }, /* (129) typename ::= ids UNSIGNED */ + { 237, -1 }, /* (130) signed ::= INTEGER */ + { 237, -2 }, /* (131) signed ::= PLUS INTEGER */ + { 237, -2 }, /* (132) signed ::= MINUS INTEGER */ + { 199, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ + { 199, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ + { 199, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ + { 199, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ + { 240, -1 }, /* (137) create_table_list ::= create_from_stable */ + { 240, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ + { 238, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 239, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 241, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + { 241, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + { 244, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ + { 244, -1 }, /* (144) tagNamelist ::= ids */ + { 238, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ + { 242, -3 }, /* (146) columnlist ::= columnlist COMMA column */ + { 242, -1 }, /* (147) columnlist ::= column */ + { 246, -2 }, /* (148) column ::= ids typename */ + { 243, -3 }, /* (149) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ + { 243, -1 }, /* (150) tagitemlist1 ::= tagitem1 */ + { 247, -2 }, /* (151) tagitem1 ::= MINUS INTEGER */ + { 247, -2 }, /* (152) tagitem1 ::= MINUS FLOAT */ + { 247, -2 }, /* (153) tagitem1 ::= PLUS INTEGER */ + { 247, -2 }, /* (154) tagitem1 ::= PLUS FLOAT */ + { 247, -1 }, /* (155) tagitem1 ::= INTEGER */ + { 247, -1 }, /* (156) tagitem1 ::= FLOAT */ + { 247, -1 }, /* (157) tagitem1 ::= STRING */ + { 247, -1 }, /* (158) tagitem1 ::= BOOL */ + { 247, -1 }, /* (159) tagitem1 ::= NULL */ + { 247, -1 }, /* (160) tagitem1 ::= NOW */ + { 248, -3 }, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ + { 248, -1 }, /* (162) tagitemlist ::= tagitem */ + { 249, -1 }, /* (163) tagitem ::= INTEGER */ + { 249, -1 }, /* (164) tagitem ::= FLOAT */ + { 249, -1 }, /* (165) tagitem ::= STRING */ + { 249, -1 }, /* (166) tagitem ::= BOOL */ + { 249, -1 }, /* (167) tagitem ::= NULL */ + { 249, -1 }, /* (168) tagitem ::= NOW */ + { 249, -2 }, /* (169) tagitem ::= MINUS INTEGER */ + { 249, -2 }, /* (170) tagitem ::= MINUS FLOAT */ + { 249, -2 }, /* (171) tagitem ::= PLUS INTEGER */ + { 249, -2 }, /* (172) tagitem ::= PLUS FLOAT */ + { 245, -14 }, /* (173) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 245, -3 }, /* (174) select ::= LP select RP */ + { 263, -1 }, /* (175) union ::= select */ + { 263, -4 }, /* (176) union ::= union UNION ALL select */ + { 263, -3 }, /* (177) union ::= union UNION select */ + { 199, -1 }, /* (178) cmd ::= union */ + { 245, -2 }, /* (179) select ::= SELECT selcollist */ + { 264, -2 }, /* (180) sclp ::= selcollist COMMA */ + { 264, 0 }, /* (181) sclp ::= */ + { 250, -4 }, /* (182) selcollist ::= sclp distinct expr as */ + { 250, -2 }, /* (183) selcollist ::= sclp STAR */ + { 267, -2 }, /* (184) as ::= AS ids */ + { 267, -1 }, /* (185) as ::= ids */ + { 267, 0 }, /* (186) as ::= */ + { 265, -1 }, /* (187) distinct ::= DISTINCT */ + { 265, 0 }, /* (188) distinct ::= */ + { 251, -2 }, /* (189) from ::= FROM tablelist */ + { 251, -2 }, /* (190) from ::= FROM sub */ + { 269, -3 }, /* (191) sub ::= LP union RP */ + { 269, -4 }, /* (192) sub ::= LP union RP ids */ + { 269, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */ + { 268, -2 }, /* (194) tablelist ::= ids cpxName */ + { 268, -3 }, /* (195) tablelist ::= ids cpxName ids */ + { 268, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */ + { 268, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */ + { 270, -1 }, /* (198) tmvar ::= VARIABLE */ + { 253, -4 }, /* (199) interval_option ::= intervalKey LP tmvar RP */ + { 253, -6 }, /* (200) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 253, 0 }, /* (201) interval_option ::= */ + { 271, -1 }, /* (202) intervalKey ::= INTERVAL */ + { 271, -1 }, /* (203) intervalKey ::= EVERY */ + { 255, 0 }, /* (204) session_option ::= */ + { 255, -7 }, /* (205) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 256, 0 }, /* (206) windowstate_option ::= */ + { 256, -4 }, /* (207) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 257, 0 }, /* (208) fill_opt ::= */ + { 257, -6 }, /* (209) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 257, -4 }, /* (210) fill_opt ::= FILL LP ID RP */ + { 254, -4 }, /* (211) sliding_opt ::= SLIDING LP tmvar RP */ + { 254, 0 }, /* (212) sliding_opt ::= */ + { 260, 0 }, /* (213) orderby_opt ::= */ + { 260, -3 }, /* (214) orderby_opt ::= ORDER BY sortlist */ + { 272, -4 }, /* (215) sortlist ::= sortlist COMMA item sortorder */ + { 272, -2 }, /* (216) sortlist ::= item sortorder */ + { 274, -2 }, /* (217) item ::= ids cpxName */ + { 275, -1 }, /* (218) sortorder ::= ASC */ + { 275, -1 }, /* (219) sortorder ::= DESC */ + { 275, 0 }, /* (220) sortorder ::= */ + { 258, 0 }, /* (221) groupby_opt ::= */ + { 258, -3 }, /* (222) groupby_opt ::= GROUP BY grouplist */ + { 276, -3 }, /* (223) grouplist ::= grouplist COMMA item */ + { 276, -1 }, /* (224) grouplist ::= item */ + { 259, 0 }, /* (225) having_opt ::= */ + { 259, -2 }, /* (226) having_opt ::= HAVING expr */ + { 262, 0 }, /* (227) limit_opt ::= */ + { 262, -2 }, /* (228) limit_opt ::= LIMIT signed */ + { 262, -4 }, /* (229) limit_opt ::= LIMIT signed OFFSET signed */ + { 262, -4 }, /* (230) limit_opt ::= LIMIT signed COMMA signed */ + { 261, 0 }, /* (231) slimit_opt ::= */ + { 261, -2 }, /* (232) slimit_opt ::= SLIMIT signed */ + { 261, -4 }, /* (233) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 261, -4 }, /* (234) slimit_opt ::= SLIMIT signed COMMA signed */ + { 252, 0 }, /* (235) where_opt ::= */ + { 252, -2 }, /* (236) where_opt ::= WHERE expr */ + { 266, -3 }, /* (237) expr ::= LP expr RP */ + { 266, -1 }, /* (238) expr ::= ID */ + { 266, -3 }, /* (239) expr ::= ID DOT ID */ + { 266, -3 }, /* (240) expr ::= ID DOT STAR */ + { 266, -1 }, /* (241) expr ::= INTEGER */ + { 266, -2 }, /* (242) expr ::= MINUS INTEGER */ + { 266, -2 }, /* (243) expr ::= PLUS INTEGER */ + { 266, -1 }, /* (244) expr ::= FLOAT */ + { 266, -2 }, /* (245) expr ::= MINUS FLOAT */ + { 266, -2 }, /* (246) expr ::= PLUS FLOAT */ + { 266, -1 }, /* (247) expr ::= STRING */ + { 266, -1 }, /* (248) expr ::= NOW */ + { 266, -1 }, /* (249) expr ::= VARIABLE */ + { 266, -2 }, /* (250) expr ::= PLUS VARIABLE */ + { 266, -2 }, /* (251) expr ::= MINUS VARIABLE */ + { 266, -1 }, /* (252) expr ::= BOOL */ + { 266, -1 }, /* (253) expr ::= NULL */ + { 266, -4 }, /* (254) expr ::= ID LP exprlist RP */ + { 266, -4 }, /* (255) expr ::= ID LP STAR RP */ + { 266, -3 }, /* (256) expr ::= expr IS NULL */ + { 266, -4 }, /* (257) expr ::= expr IS NOT NULL */ + { 266, -3 }, /* (258) expr ::= expr LT expr */ + { 266, -3 }, /* (259) expr ::= expr GT expr */ + { 266, -3 }, /* (260) expr ::= expr LE expr */ + { 266, -3 }, /* (261) expr ::= expr GE expr */ + { 266, -3 }, /* (262) expr ::= expr NE expr */ + { 266, -3 }, /* (263) expr ::= expr EQ expr */ + { 266, -5 }, /* (264) expr ::= expr BETWEEN expr AND expr */ + { 266, -3 }, /* (265) expr ::= expr AND expr */ + { 266, -3 }, /* (266) expr ::= expr OR expr */ + { 266, -3 }, /* (267) expr ::= expr PLUS expr */ + { 266, -3 }, /* (268) expr ::= expr MINUS expr */ + { 266, -3 }, /* (269) expr ::= expr STAR expr */ + { 266, -3 }, /* (270) expr ::= expr SLASH expr */ + { 266, -3 }, /* (271) expr ::= expr REM expr */ + { 266, -3 }, /* (272) expr ::= expr LIKE expr */ + { 266, -3 }, /* (273) expr ::= expr MATCH expr */ + { 266, -3 }, /* (274) expr ::= expr NMATCH expr */ + { 266, -5 }, /* (275) expr ::= expr IN LP exprlist RP */ + { 206, -3 }, /* (276) exprlist ::= exprlist COMMA expritem */ + { 206, -1 }, /* (277) exprlist ::= expritem */ + { 277, -1 }, /* (278) expritem ::= expr */ + { 277, 0 }, /* (279) expritem ::= */ + { 199, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ + { 199, -3 }, /* (281) cmd ::= SYNCDB ids REPLICA */ + { 199, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 199, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 199, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 199, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 199, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 199, -8 }, /* (287) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 199, -9 }, /* (288) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 199, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 199, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 199, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 199, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 199, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 199, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 199, -8 }, /* (295) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 199, -9 }, /* (296) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 199, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 199, -3 }, /* (298) cmd ::= KILL CONNECTION INTEGER */ + { 199, -5 }, /* (299) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 199, -5 }, /* (300) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2228,9 +2231,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 132: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==132); - case 133: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==133); - case 134: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==134); + case 133: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==133); + case 134: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==134); + case 135: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==135); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2427,55 +2430,56 @@ static void yy_reduce( break; case 54: /* ifexists ::= */ case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56); - case 187: /* distinct ::= */ yytestcase(yyruleno==187); + case 188: /* distinct ::= */ yytestcase(yyruleno==188); { yymsp[1].minor.yy0.n = 0;} break; case 55: /* ifnotexists ::= IF NOT EXISTS */ { yymsp[-2].minor.yy0.n = 1;} break; case 57: /* cmd ::= CREATE DNODE ids PORT ids */ + case 58: /* cmd ::= CREATE DNODE IPTOKEN PORT ids */ yytestcase(yyruleno==58); { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + case 59: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} break; - case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &yymsp[-2].minor.yy0);} break; - case 60: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 1);} break; - case 61: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ { setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 2);} break; - case 62: /* cmd ::= CREATE USER ids PASS ids */ + case 63: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; - case 63: /* bufsize ::= */ - case 65: /* pps ::= */ yytestcase(yyruleno==65); - case 67: /* tseries ::= */ yytestcase(yyruleno==67); - case 69: /* dbs ::= */ yytestcase(yyruleno==69); - case 71: /* streams ::= */ yytestcase(yyruleno==71); - case 73: /* storage ::= */ yytestcase(yyruleno==73); - case 75: /* qtime ::= */ yytestcase(yyruleno==75); - case 77: /* users ::= */ yytestcase(yyruleno==77); - case 79: /* conns ::= */ yytestcase(yyruleno==79); - case 81: /* state ::= */ yytestcase(yyruleno==81); + case 64: /* bufsize ::= */ + case 66: /* pps ::= */ yytestcase(yyruleno==66); + case 68: /* tseries ::= */ yytestcase(yyruleno==68); + case 70: /* dbs ::= */ yytestcase(yyruleno==70); + case 72: /* streams ::= */ yytestcase(yyruleno==72); + case 74: /* storage ::= */ yytestcase(yyruleno==74); + case 76: /* qtime ::= */ yytestcase(yyruleno==76); + case 78: /* users ::= */ yytestcase(yyruleno==78); + case 80: /* conns ::= */ yytestcase(yyruleno==80); + case 82: /* state ::= */ yytestcase(yyruleno==82); { yymsp[1].minor.yy0.n = 0; } break; - case 64: /* bufsize ::= BUFSIZE INTEGER */ - case 66: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==66); - case 68: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==68); - case 70: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==70); - case 72: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==72); - case 74: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==74); - case 76: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==76); - case 78: /* users ::= USERS INTEGER */ yytestcase(yyruleno==78); - case 80: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==80); - case 82: /* state ::= STATE ids */ yytestcase(yyruleno==82); + case 65: /* bufsize ::= BUFSIZE INTEGER */ + case 67: /* pps ::= PPS INTEGER */ yytestcase(yyruleno==67); + case 69: /* tseries ::= TSERIES INTEGER */ yytestcase(yyruleno==69); + case 71: /* dbs ::= DBS INTEGER */ yytestcase(yyruleno==71); + case 73: /* streams ::= STREAMS INTEGER */ yytestcase(yyruleno==73); + case 75: /* storage ::= STORAGE INTEGER */ yytestcase(yyruleno==75); + case 77: /* qtime ::= QTIME INTEGER */ yytestcase(yyruleno==77); + case 79: /* users ::= USERS INTEGER */ yytestcase(yyruleno==79); + case 81: /* conns ::= CONNS INTEGER */ yytestcase(yyruleno==81); + case 83: /* state ::= STATE ids */ yytestcase(yyruleno==83); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 83: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { yylhsminor.yy171.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; yylhsminor.yy171.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; @@ -2489,124 +2493,124 @@ static void yy_reduce( } yymsp[-8].minor.yy171 = yylhsminor.yy171; break; - case 84: /* intitemlist ::= intitemlist COMMA intitem */ - case 160: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==160); + case 85: /* intitemlist ::= intitemlist COMMA intitem */ + case 161: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==161); { yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); } yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 85: /* intitemlist ::= intitem */ - case 161: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==161); + case 86: /* intitemlist ::= intitem */ + case 162: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==162); { yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); } yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 86: /* intitem ::= INTEGER */ - case 162: /* tagitem ::= INTEGER */ yytestcase(yyruleno==162); - case 163: /* tagitem ::= FLOAT */ yytestcase(yyruleno==163); - case 164: /* tagitem ::= STRING */ yytestcase(yyruleno==164); - case 165: /* tagitem ::= BOOL */ yytestcase(yyruleno==165); + case 87: /* intitem ::= INTEGER */ + case 163: /* tagitem ::= INTEGER */ yytestcase(yyruleno==163); + case 164: /* tagitem ::= FLOAT */ yytestcase(yyruleno==164); + case 165: /* tagitem ::= STRING */ yytestcase(yyruleno==165); + case 166: /* tagitem ::= BOOL */ yytestcase(yyruleno==166); { toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } yymsp[0].minor.yy69 = yylhsminor.yy69; break; - case 87: /* keep ::= KEEP intitemlist */ + case 88: /* keep ::= KEEP intitemlist */ { yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } break; - case 88: /* cache ::= CACHE INTEGER */ - case 89: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==89); - case 90: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==90); - case 91: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==91); - case 92: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==92); - case 93: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==93); - case 94: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==94); - case 95: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==95); - case 96: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==96); - case 97: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==97); - case 98: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==98); - case 99: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==99); - case 100: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==100); - case 101: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==101); + case 89: /* cache ::= CACHE INTEGER */ + case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); + case 91: /* quorum ::= QUORUM INTEGER */ yytestcase(yyruleno==91); + case 92: /* days ::= DAYS INTEGER */ yytestcase(yyruleno==92); + case 93: /* minrows ::= MINROWS INTEGER */ yytestcase(yyruleno==93); + case 94: /* maxrows ::= MAXROWS INTEGER */ yytestcase(yyruleno==94); + case 95: /* blocks ::= BLOCKS INTEGER */ yytestcase(yyruleno==95); + case 96: /* ctime ::= CTIME INTEGER */ yytestcase(yyruleno==96); + case 97: /* wal ::= WAL INTEGER */ yytestcase(yyruleno==97); + case 98: /* fsync ::= FSYNC INTEGER */ yytestcase(yyruleno==98); + case 99: /* comp ::= COMP INTEGER */ yytestcase(yyruleno==99); + case 100: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==100); + case 101: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==101); + case 102: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==102); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 102: /* db_optr ::= */ + case 103: /* db_optr ::= */ {setDefaultCreateDbOption(&yymsp[1].minor.yy90);} break; - case 103: /* db_optr ::= db_optr cache */ + case 104: /* db_optr ::= db_optr cache */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 104: /* db_optr ::= db_optr replica */ - case 119: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==119); + case 105: /* db_optr ::= db_optr replica */ + case 120: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==120); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 105: /* db_optr ::= db_optr quorum */ - case 120: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==120); + case 106: /* db_optr ::= db_optr quorum */ + case 121: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==121); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 106: /* db_optr ::= db_optr days */ + case 107: /* db_optr ::= db_optr days */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 107: /* db_optr ::= db_optr minrows */ + case 108: /* db_optr ::= db_optr minrows */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 108: /* db_optr ::= db_optr maxrows */ + case 109: /* db_optr ::= db_optr maxrows */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 109: /* db_optr ::= db_optr blocks */ - case 122: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==122); + case 110: /* db_optr ::= db_optr blocks */ + case 123: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==123); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 110: /* db_optr ::= db_optr ctime */ + case 111: /* db_optr ::= db_optr ctime */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 111: /* db_optr ::= db_optr wal */ + case 112: /* db_optr ::= db_optr wal */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 112: /* db_optr ::= db_optr fsync */ + case 113: /* db_optr ::= db_optr fsync */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 113: /* db_optr ::= db_optr comp */ - case 123: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==123); + case 114: /* db_optr ::= db_optr comp */ + case 124: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==124); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 114: /* db_optr ::= db_optr prec */ + case 115: /* db_optr ::= db_optr prec */ { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.precision = yymsp[0].minor.yy0; } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 115: /* db_optr ::= db_optr keep */ - case 121: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==121); + case 116: /* db_optr ::= db_optr keep */ + case 122: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==122); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.keep = yymsp[0].minor.yy421; } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 116: /* db_optr ::= db_optr update */ - case 124: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==124); + case 117: /* db_optr ::= db_optr update */ + case 125: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==125); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 117: /* db_optr ::= db_optr cachelast */ - case 125: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==125); + case 118: /* db_optr ::= db_optr cachelast */ + case 126: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==126); { yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy90 = yylhsminor.yy90; break; - case 118: /* alter_db_optr ::= */ + case 119: /* alter_db_optr ::= */ { setDefaultCreateDbOption(&yymsp[1].minor.yy90);} break; - case 126: /* typename ::= ids */ + case 127: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; tSetColumnType (&yylhsminor.yy100, &yymsp[0].minor.yy0); } yymsp[0].minor.yy100 = yylhsminor.yy100; break; - case 127: /* typename ::= ids LP signed RP */ + case 128: /* typename ::= ids LP signed RP */ { if (yymsp[-1].minor.yy325 <= 0) { yymsp[-3].minor.yy0.type = 0; @@ -2618,7 +2622,7 @@ static void yy_reduce( } yymsp[-3].minor.yy100 = yylhsminor.yy100; break; - case 128: /* typename ::= ids UNSIGNED */ + case 129: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); @@ -2626,20 +2630,20 @@ static void yy_reduce( } yymsp[-1].minor.yy100 = yylhsminor.yy100; break; - case 129: /* signed ::= INTEGER */ + case 130: /* signed ::= INTEGER */ { yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy325 = yylhsminor.yy325; break; - case 130: /* signed ::= PLUS INTEGER */ + case 131: /* signed ::= PLUS INTEGER */ { yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 131: /* signed ::= MINUS INTEGER */ + case 132: /* signed ::= MINUS INTEGER */ { yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 135: /* cmd ::= CREATE TABLE create_table_list */ + case 136: /* cmd ::= CREATE TABLE create_table_list */ { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;} break; - case 136: /* create_table_list ::= create_from_stable */ + case 137: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); @@ -2650,14 +2654,14 @@ static void yy_reduce( } yymsp[0].minor.yy438 = yylhsminor.yy438; break; - case 137: /* create_table_list ::= create_table_list create_from_stable */ + case 138: /* create_table_list ::= create_table_list create_from_stable */ { taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy152); yylhsminor.yy438 = yymsp[-1].minor.yy438; } yymsp[-1].minor.yy438 = yylhsminor.yy438; break; - case 138: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); @@ -2667,7 +2671,7 @@ static void yy_reduce( } yymsp[-5].minor.yy438 = yylhsminor.yy438; break; - case 139: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); @@ -2677,7 +2681,7 @@ static void yy_reduce( } yymsp[-9].minor.yy438 = yylhsminor.yy438; break; - case 140: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2685,7 +2689,7 @@ static void yy_reduce( } yymsp[-9].minor.yy152 = yylhsminor.yy152; break; - case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; @@ -2693,15 +2697,15 @@ static void yy_reduce( } yymsp[-12].minor.yy152 = yylhsminor.yy152; break; - case 142: /* tagNamelist ::= tagNamelist COMMA ids */ + case 143: /* tagNamelist ::= tagNamelist COMMA ids */ {taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421; } yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 143: /* tagNamelist ::= ids */ + case 144: /* tagNamelist ::= ids */ {yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0);} yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 144: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ { yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy56, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); @@ -2711,56 +2715,56 @@ static void yy_reduce( } yymsp[-4].minor.yy438 = yylhsminor.yy438; break; - case 145: /* columnlist ::= columnlist COMMA column */ + case 146: /* columnlist ::= columnlist COMMA column */ {taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy100); yylhsminor.yy421 = yymsp[-2].minor.yy421; } yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 146: /* columnlist ::= column */ + case 147: /* columnlist ::= column */ {yylhsminor.yy421 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy100);} yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 147: /* column ::= ids typename */ + case 148: /* column ::= ids typename */ { tSetColumnInfo(&yylhsminor.yy100, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy100); } yymsp[-1].minor.yy100 = yylhsminor.yy100; break; - case 148: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ + case 149: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ { taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421;} yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 149: /* tagitemlist1 ::= tagitem1 */ + case 150: /* tagitemlist1 ::= tagitem1 */ { yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0); } yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 150: /* tagitem1 ::= MINUS INTEGER */ - case 151: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==151); - case 152: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==152); - case 153: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==153); + case 151: /* tagitem1 ::= MINUS INTEGER */ + case 152: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==152); + case 153: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==153); + case 154: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==154); { yylhsminor.yy0.n = yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n; yylhsminor.yy0.type = yymsp[0].minor.yy0.type; } yymsp[-1].minor.yy0 = yylhsminor.yy0; break; - case 154: /* tagitem1 ::= INTEGER */ - case 155: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==155); - case 156: /* tagitem1 ::= STRING */ yytestcase(yyruleno==156); - case 157: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==157); - case 158: /* tagitem1 ::= NULL */ yytestcase(yyruleno==158); - case 159: /* tagitem1 ::= NOW */ yytestcase(yyruleno==159); + case 155: /* tagitem1 ::= INTEGER */ + case 156: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==156); + case 157: /* tagitem1 ::= STRING */ yytestcase(yyruleno==157); + case 158: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==158); + case 159: /* tagitem1 ::= NULL */ yytestcase(yyruleno==159); + case 160: /* tagitem1 ::= NOW */ yytestcase(yyruleno==160); { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 166: /* tagitem ::= NULL */ + case 167: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } yymsp[0].minor.yy69 = yylhsminor.yy69; break; - case 167: /* tagitem ::= NOW */ + case 168: /* tagitem ::= NOW */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} yymsp[0].minor.yy69 = yylhsminor.yy69; break; - case 168: /* tagitem ::= MINUS INTEGER */ - case 169: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==169); - case 170: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==170); - case 171: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==171); + case 169: /* tagitem ::= MINUS INTEGER */ + case 170: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==170); + case 171: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==171); + case 172: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==172); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2769,154 +2773,154 @@ static void yy_reduce( } yymsp[-1].minor.yy69 = yylhsminor.yy69; break; - case 172: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + case 173: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy421, yymsp[-11].minor.yy8, yymsp[-10].minor.yy439, yymsp[-4].minor.yy421, yymsp[-2].minor.yy421, &yymsp[-9].minor.yy400, &yymsp[-7].minor.yy147, &yymsp[-6].minor.yy40, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, &yymsp[0].minor.yy231, &yymsp[-1].minor.yy231, yymsp[-3].minor.yy439); } yymsp[-13].minor.yy56 = yylhsminor.yy56; break; - case 173: /* select ::= LP select RP */ + case 174: /* select ::= LP select RP */ {yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56;} break; - case 174: /* union ::= select */ + case 175: /* union ::= select */ { yylhsminor.yy149 = setSubclause(NULL, yymsp[0].minor.yy56); } yymsp[0].minor.yy149 = yylhsminor.yy149; break; - case 175: /* union ::= union UNION ALL select */ + case 176: /* union ::= union UNION ALL select */ { yylhsminor.yy149 = appendSelectClause(yymsp[-3].minor.yy149, SQL_TYPE_UNIONALL, yymsp[0].minor.yy56); } yymsp[-3].minor.yy149 = yylhsminor.yy149; break; - case 176: /* union ::= union UNION select */ + case 177: /* union ::= union UNION select */ { yylhsminor.yy149 = appendSelectClause(yymsp[-2].minor.yy149, SQL_TYPE_UNION, yymsp[0].minor.yy56); } yymsp[-2].minor.yy149 = yylhsminor.yy149; break; - case 177: /* cmd ::= union */ + case 178: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy149, NULL, TSDB_SQL_SELECT); } break; - case 178: /* select ::= SELECT selcollist */ + case 179: /* select ::= SELECT selcollist */ { yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy421, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy56 = yylhsminor.yy56; break; - case 179: /* sclp ::= selcollist COMMA */ + case 180: /* sclp ::= selcollist COMMA */ {yylhsminor.yy421 = yymsp[-1].minor.yy421;} yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 180: /* sclp ::= */ - case 212: /* orderby_opt ::= */ yytestcase(yyruleno==212); + case 181: /* sclp ::= */ + case 213: /* orderby_opt ::= */ yytestcase(yyruleno==213); {yymsp[1].minor.yy421 = 0;} break; - case 181: /* selcollist ::= sclp distinct expr as */ + case 182: /* selcollist ::= sclp distinct expr as */ { yylhsminor.yy421 = tSqlExprListAppend(yymsp[-3].minor.yy421, yymsp[-1].minor.yy439, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 182: /* selcollist ::= sclp STAR */ + case 183: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); yylhsminor.yy421 = tSqlExprListAppend(yymsp[-1].minor.yy421, pNode, 0, 0); } yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 183: /* as ::= AS ids */ + case 184: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 184: /* as ::= ids */ + case 185: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 185: /* as ::= */ + case 186: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 186: /* distinct ::= DISTINCT */ + case 187: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 188: /* from ::= FROM tablelist */ - case 189: /* from ::= FROM sub */ yytestcase(yyruleno==189); + case 189: /* from ::= FROM tablelist */ + case 190: /* from ::= FROM sub */ yytestcase(yyruleno==190); {yymsp[-1].minor.yy8 = yymsp[0].minor.yy8;} break; - case 190: /* sub ::= LP union RP */ + case 191: /* sub ::= LP union RP */ {yymsp[-2].minor.yy8 = addSubquery(NULL, yymsp[-1].minor.yy149, NULL);} break; - case 191: /* sub ::= LP union RP ids */ + case 192: /* sub ::= LP union RP ids */ {yymsp[-3].minor.yy8 = addSubquery(NULL, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} break; - case 192: /* sub ::= sub COMMA LP union RP ids */ + case 193: /* sub ::= sub COMMA LP union RP ids */ {yylhsminor.yy8 = addSubquery(yymsp[-5].minor.yy8, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} yymsp[-5].minor.yy8 = yylhsminor.yy8; break; - case 193: /* tablelist ::= ids cpxName */ + case 194: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } yymsp[-1].minor.yy8 = yylhsminor.yy8; break; - case 194: /* tablelist ::= ids cpxName ids */ + case 195: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy8 = yylhsminor.yy8; break; - case 195: /* tablelist ::= tablelist COMMA ids cpxName */ + case 196: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy8 = setTableNameList(yymsp[-3].minor.yy8, &yymsp[-1].minor.yy0, NULL); } yymsp[-3].minor.yy8 = yylhsminor.yy8; break; - case 196: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 197: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy8 = setTableNameList(yymsp[-4].minor.yy8, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-4].minor.yy8 = yylhsminor.yy8; break; - case 197: /* tmvar ::= VARIABLE */ + case 198: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 198: /* interval_option ::= intervalKey LP tmvar RP */ + case 199: /* interval_option ::= intervalKey LP tmvar RP */ {yylhsminor.yy400.interval = yymsp[-1].minor.yy0; yylhsminor.yy400.offset.n = 0; yylhsminor.yy400.token = yymsp[-3].minor.yy104;} yymsp[-3].minor.yy400 = yylhsminor.yy400; break; - case 199: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + case 200: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ {yylhsminor.yy400.interval = yymsp[-3].minor.yy0; yylhsminor.yy400.offset = yymsp[-1].minor.yy0; yylhsminor.yy400.token = yymsp[-5].minor.yy104;} yymsp[-5].minor.yy400 = yylhsminor.yy400; break; - case 200: /* interval_option ::= */ + case 201: /* interval_option ::= */ {memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} break; - case 201: /* intervalKey ::= INTERVAL */ + case 202: /* intervalKey ::= INTERVAL */ {yymsp[0].minor.yy104 = TK_INTERVAL;} break; - case 202: /* intervalKey ::= EVERY */ + case 203: /* intervalKey ::= EVERY */ {yymsp[0].minor.yy104 = TK_EVERY; } break; - case 203: /* session_option ::= */ + case 204: /* session_option ::= */ {yymsp[1].minor.yy147.col.n = 0; yymsp[1].minor.yy147.gap.n = 0;} break; - case 204: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 205: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-6].minor.yy147.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy147.gap = yymsp[-1].minor.yy0; } break; - case 205: /* windowstate_option ::= */ + case 206: /* windowstate_option ::= */ { yymsp[1].minor.yy40.col.n = 0; yymsp[1].minor.yy40.col.z = NULL;} break; - case 206: /* windowstate_option ::= STATE_WINDOW LP ids RP */ + case 207: /* windowstate_option ::= STATE_WINDOW LP ids RP */ { yymsp[-3].minor.yy40.col = yymsp[-1].minor.yy0; } break; - case 207: /* fill_opt ::= */ + case 208: /* fill_opt ::= */ { yymsp[1].minor.yy421 = 0; } break; - case 208: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 209: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { SVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2926,34 +2930,34 @@ static void yy_reduce( yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; } break; - case 209: /* fill_opt ::= FILL LP ID RP */ + case 210: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy421 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 210: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 211: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 211: /* sliding_opt ::= */ + case 212: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 213: /* orderby_opt ::= ORDER BY sortlist */ + case 214: /* orderby_opt ::= ORDER BY sortlist */ {yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} break; - case 214: /* sortlist ::= sortlist COMMA item sortorder */ + case 215: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy421 = tListItemAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); } yymsp[-3].minor.yy421 = yylhsminor.yy421; break; - case 215: /* sortlist ::= item sortorder */ + case 216: /* sortlist ::= item sortorder */ { yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); } yymsp[-1].minor.yy421 = yylhsminor.yy421; break; - case 216: /* item ::= ids cpxName */ + case 217: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2962,235 +2966,235 @@ static void yy_reduce( } yymsp[-1].minor.yy69 = yylhsminor.yy69; break; - case 217: /* sortorder ::= ASC */ + case 218: /* sortorder ::= ASC */ { yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } break; - case 218: /* sortorder ::= DESC */ + case 219: /* sortorder ::= DESC */ { yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} break; - case 219: /* sortorder ::= */ + case 220: /* sortorder ::= */ { yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } break; - case 220: /* groupby_opt ::= */ + case 221: /* groupby_opt ::= */ { yymsp[1].minor.yy421 = 0;} break; - case 221: /* groupby_opt ::= GROUP BY grouplist */ + case 222: /* groupby_opt ::= GROUP BY grouplist */ { yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} break; - case 222: /* grouplist ::= grouplist COMMA item */ + case 223: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); } yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 223: /* grouplist ::= item */ + case 224: /* grouplist ::= item */ { yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); } yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 224: /* having_opt ::= */ - case 234: /* where_opt ::= */ yytestcase(yyruleno==234); - case 278: /* expritem ::= */ yytestcase(yyruleno==278); + case 225: /* having_opt ::= */ + case 235: /* where_opt ::= */ yytestcase(yyruleno==235); + case 279: /* expritem ::= */ yytestcase(yyruleno==279); {yymsp[1].minor.yy439 = 0;} break; - case 225: /* having_opt ::= HAVING expr */ - case 235: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==235); + case 226: /* having_opt ::= HAVING expr */ + case 236: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==236); {yymsp[-1].minor.yy439 = yymsp[0].minor.yy439;} break; - case 226: /* limit_opt ::= */ - case 230: /* slimit_opt ::= */ yytestcase(yyruleno==230); + case 227: /* limit_opt ::= */ + case 231: /* slimit_opt ::= */ yytestcase(yyruleno==231); {yymsp[1].minor.yy231.limit = -1; yymsp[1].minor.yy231.offset = 0;} break; - case 227: /* limit_opt ::= LIMIT signed */ - case 231: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==231); + case 228: /* limit_opt ::= LIMIT signed */ + case 232: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==232); {yymsp[-1].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy231.offset = 0;} break; - case 228: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 229: /* limit_opt ::= LIMIT signed OFFSET signed */ { yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} break; - case 229: /* limit_opt ::= LIMIT signed COMMA signed */ + case 230: /* limit_opt ::= LIMIT signed COMMA signed */ { yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} break; - case 232: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ + case 233: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ {yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} break; - case 233: /* slimit_opt ::= SLIMIT signed COMMA signed */ + case 234: /* slimit_opt ::= SLIMIT signed COMMA signed */ {yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} break; - case 236: /* expr ::= LP expr RP */ + case 237: /* expr ::= LP expr RP */ {yylhsminor.yy439 = yymsp[-1].minor.yy439; yylhsminor.yy439->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy439->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 237: /* expr ::= ID */ + case 238: /* expr ::= ID */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 238: /* expr ::= ID DOT ID */ + case 239: /* expr ::= ID DOT ID */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 239: /* expr ::= ID DOT STAR */ + case 240: /* expr ::= ID DOT STAR */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 240: /* expr ::= INTEGER */ + case 241: /* expr ::= INTEGER */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 241: /* expr ::= MINUS INTEGER */ - case 242: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==242); + case 242: /* expr ::= MINUS INTEGER */ + case 243: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==243); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy439 = yylhsminor.yy439; break; - case 243: /* expr ::= FLOAT */ + case 244: /* expr ::= FLOAT */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 244: /* expr ::= MINUS FLOAT */ - case 245: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==245); + case 245: /* expr ::= MINUS FLOAT */ + case 246: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==246); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy439 = yylhsminor.yy439; break; - case 246: /* expr ::= STRING */ + case 247: /* expr ::= STRING */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 247: /* expr ::= NOW */ + case 248: /* expr ::= NOW */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 248: /* expr ::= VARIABLE */ + case 249: /* expr ::= VARIABLE */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 249: /* expr ::= PLUS VARIABLE */ - case 250: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==250); + case 250: /* expr ::= PLUS VARIABLE */ + case 251: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==251); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} yymsp[-1].minor.yy439 = yylhsminor.yy439; break; - case 251: /* expr ::= BOOL */ + case 252: /* expr ::= BOOL */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 252: /* expr ::= NULL */ + case 253: /* expr ::= NULL */ { yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 253: /* expr ::= ID LP exprlist RP */ + case 254: /* expr ::= ID LP exprlist RP */ { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(yymsp[-1].minor.yy421, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy439 = yylhsminor.yy439; break; - case 254: /* expr ::= ID LP STAR RP */ + case 255: /* expr ::= ID LP STAR RP */ { tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy439 = yylhsminor.yy439; break; - case 255: /* expr ::= expr IS NULL */ + case 256: /* expr ::= expr IS NULL */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, NULL, TK_ISNULL);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 256: /* expr ::= expr IS NOT NULL */ + case 257: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-3].minor.yy439, NULL, TK_NOTNULL);} yymsp[-3].minor.yy439 = yylhsminor.yy439; break; - case 257: /* expr ::= expr LT expr */ + case 258: /* expr ::= expr LT expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LT);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 258: /* expr ::= expr GT expr */ + case 259: /* expr ::= expr GT expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GT);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 259: /* expr ::= expr LE expr */ + case 260: /* expr ::= expr LE expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LE);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 260: /* expr ::= expr GE expr */ + case 261: /* expr ::= expr GE expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GE);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 261: /* expr ::= expr NE expr */ + case 262: /* expr ::= expr NE expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NE);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 262: /* expr ::= expr EQ expr */ + case 263: /* expr ::= expr EQ expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_EQ);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 263: /* expr ::= expr BETWEEN expr AND expr */ + case 264: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy439); yylhsminor.yy439 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy439, yymsp[-2].minor.yy439, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy439, TK_LE), TK_AND);} yymsp[-4].minor.yy439 = yylhsminor.yy439; break; - case 264: /* expr ::= expr AND expr */ + case 265: /* expr ::= expr AND expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_AND);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 265: /* expr ::= expr OR expr */ + case 266: /* expr ::= expr OR expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_OR); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 266: /* expr ::= expr PLUS expr */ + case 267: /* expr ::= expr PLUS expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_PLUS); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 267: /* expr ::= expr MINUS expr */ + case 268: /* expr ::= expr MINUS expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MINUS); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 268: /* expr ::= expr STAR expr */ + case 269: /* expr ::= expr STAR expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_STAR); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 269: /* expr ::= expr SLASH expr */ + case 270: /* expr ::= expr SLASH expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_DIVIDE);} yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 270: /* expr ::= expr REM expr */ + case 271: /* expr ::= expr REM expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_REM); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 271: /* expr ::= expr LIKE expr */ + case 272: /* expr ::= expr LIKE expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LIKE); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 272: /* expr ::= expr MATCH expr */ + case 273: /* expr ::= expr MATCH expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MATCH); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 273: /* expr ::= expr NMATCH expr */ + case 274: /* expr ::= expr NMATCH expr */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NMATCH); } yymsp[-2].minor.yy439 = yylhsminor.yy439; break; - case 274: /* expr ::= expr IN LP exprlist RP */ + case 275: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy439 = tSqlExprCreate(yymsp[-4].minor.yy439, (tSqlExpr*)yymsp[-1].minor.yy421, TK_IN); } yymsp[-4].minor.yy439 = yylhsminor.yy439; break; - case 275: /* exprlist ::= exprlist COMMA expritem */ + case 276: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy421 = tSqlExprListAppend(yymsp[-2].minor.yy421,yymsp[0].minor.yy439,0, 0);} yymsp[-2].minor.yy421 = yylhsminor.yy421; break; - case 276: /* exprlist ::= expritem */ + case 277: /* exprlist ::= expritem */ {yylhsminor.yy421 = tSqlExprListAppend(0,yymsp[0].minor.yy439,0, 0);} yymsp[0].minor.yy421 = yylhsminor.yy421; break; - case 277: /* expritem ::= expr */ + case 278: /* expritem ::= expr */ {yylhsminor.yy439 = yymsp[0].minor.yy439;} yymsp[0].minor.yy439 = yylhsminor.yy439; break; - case 279: /* cmd ::= RESET QUERY CACHE */ + case 280: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 280: /* cmd ::= SYNCDB ids REPLICA */ + case 281: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 281: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 282: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 282: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 283: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; toTSDBType(yymsp[0].minor.yy0.type); @@ -3199,21 +3203,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 283: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 284: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 284: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 285: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 285: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 286: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3224,7 +3228,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 286: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 287: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3238,7 +3242,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 287: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 288: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3250,21 +3254,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 288: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 289: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 289: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 290: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 290: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 291: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3275,21 +3279,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 291: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 292: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 292: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 293: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 293: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 294: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3300,7 +3304,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 294: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 295: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3314,7 +3318,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 295: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 296: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3326,20 +3330,20 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 297: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* cmd ::= KILL CONNECTION INTEGER */ + case 298: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 298: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 299: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 299: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 300: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: From c7728350d91fed52f6f2fcc34355debfd8655aba Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 28 Dec 2021 18:22:30 +0800 Subject: [PATCH 23/55] catalog --- source/client/src/clientImpl.c | 2 +- source/client/src/clientMsgHandler.c | 18 +++++++++--------- source/dnode/mnode/impl/src/mndStb.c | 2 +- source/libs/catalog/src/catalog.c | 25 +++++++------------------ source/libs/qcom/src/querymsg.c | 17 +++++++++-------- 5 files changed, 27 insertions(+), 37 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 7eadece728..a0dc75e513 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -349,7 +349,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj *pRequest) { pMsgSendInfo->msgInfo.len = sizeof(SConnectMsg); pMsgSendInfo->requestObjRefId = pRequest->self; pMsgSendInfo->requestId = pRequest->requestId; - pMsgSendInfo->fp = handleRequestRspFp[pMsgSendInfo->msgType]; + pMsgSendInfo->fp = handleRequestRspFp[TMSG_INDEX(pMsgSendInfo->msgType)]; pMsgSendInfo->param = pRequest; SConnectMsg *pConnect = calloc(1, sizeof(SConnectMsg)); diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 7ad1254215..e2fdf96385 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -79,7 +79,7 @@ static int32_t buildRetrieveMnodeMsg(SRequestObj *pRequest, SMsgSendInfo* pMsgSe pMsgSendInfo->msgInfo.len = sizeof(SRetrieveTableMsg); pMsgSendInfo->requestObjRefId = pRequest->self; pMsgSendInfo->param = pRequest; - pMsgSendInfo->fp = handleRequestRspFp[pMsgSendInfo->msgType]; + pMsgSendInfo->fp = handleRequestRspFp[TMSG_INDEX(pMsgSendInfo->msgType)]; SRetrieveTableMsg *pRetrieveMsg = calloc(1, sizeof(SRetrieveTableMsg)); if (pRetrieveMsg == NULL) { @@ -104,7 +104,7 @@ SMsgSendInfo* buildSendMsgInfoImpl(SRequestObj *pRequest) { pMsgSendInfo->requestId = pRequest->requestId; pMsgSendInfo->param = pRequest; - pMsgSendInfo->fp = (handleRequestRspFp[pRequest->type] == NULL)? genericRspCallback:handleRequestRspFp[pRequest->type]; + pMsgSendInfo->fp = (handleRequestRspFp[TMSG_INDEX(pRequest->type)] == NULL)? genericRspCallback:handleRequestRspFp[TMSG_INDEX(pRequest->type)]; } return pMsgSendInfo; @@ -290,11 +290,11 @@ void initMsgHandleFp() { tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; #endif - handleRequestRspFp[TDMT_MND_CONNECT] = processConnectRsp; - handleRequestRspFp[TDMT_MND_SHOW] = processShowRsp; - handleRequestRspFp[TDMT_MND_SHOW_RETRIEVE] = processRetrieveMnodeRsp; - handleRequestRspFp[TDMT_MND_CREATE_DB] = processCreateDbRsp; - handleRequestRspFp[TDMT_MND_USE_DB] = processUseDbRsp; - handleRequestRspFp[TDMT_MND_CREATE_STB] = processCreateTableRsp; - handleRequestRspFp[TDMT_MND_DROP_DB] = processDropDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_SHOW)] = processShowRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_SHOW_RETRIEVE)] = processRetrieveMnodeRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp; } \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 97e91af937..61f2d1e00a 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -767,7 +767,7 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) { return -1; } - memcpy(pMeta->stbFname, pStb->name, TSDB_TABLE_FNAME_LEN); + memcpy(pMeta->tbFname, pStb->name, TSDB_TABLE_FNAME_LEN); pMeta->numOfTags = htonl(pStb->numOfTags); pMeta->numOfColumns = htonl(pStb->numOfColumns); pMeta->precision = pDb->cfg.precision; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index a65f471cfd..edbe5f66ea 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -49,22 +49,11 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp SEpSet *pVnodeEpSet = NULL; int32_t msgLen = 0; - CTG_ERR_RET(queryBuildMsg[TDMT_MND_USE_DB](input, &msg, 0, &msgLen)); - - char *pMsg = rpcMallocCont(msgLen); - if (NULL == pMsg) { - ctgError("rpc malloc %d failed", msgLen); - tfree(msg); - CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); - } - - memcpy(pMsg, msg, msgLen); - - tfree(msg); + CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)](input, &msg, 0, &msgLen)); SRpcMsg rpcMsg = { .msgType = TDMT_MND_USE_DB, - .pCont = pMsg, + .pCont = msg, .contLen = msgLen, }; @@ -76,7 +65,7 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp CTG_ERR_RET(rpcRsp.code); } - CTG_ERR_RET(queryProcessMsgRsp[TDMT_MND_USE_DB](out, rpcRsp.pCont, rpcRsp.contLen)); + CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)](out, rpcRsp.pCont, rpcRsp.contLen)); return TSDB_CODE_SUCCESS; } @@ -160,7 +149,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE SEpSet *pVnodeEpSet = NULL; int32_t msgLen = 0; - CTG_ERR_RET(queryBuildMsg[TDMT_MND_STB_META](&bInput, &msg, 0, &msgLen)); + CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_MND_STB_META)](&bInput, &msg, 0, &msgLen)); SRpcMsg rpcMsg = { .msgType = TDMT_MND_STB_META, @@ -177,7 +166,7 @@ int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SE CTG_ERR_RET(rpcRsp.code); } - CTG_ERR_RET(queryProcessMsgRsp[TDMT_MND_STB_META](output, rpcRsp.pCont, rpcRsp.contLen)); + CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_STB_META)](output, rpcRsp.pCont, rpcRsp.contLen)); return TSDB_CODE_SUCCESS; } @@ -197,7 +186,7 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SE SEpSet *pVnodeEpSet = NULL; int32_t msgLen = 0; - CTG_ERR_RET(queryBuildMsg[TDMT_VND_TABLE_META](&bInput, &msg, 0, &msgLen)); + CTG_ERR_RET(queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)](&bInput, &msg, 0, &msgLen)); SRpcMsg rpcMsg = { .msgType = TDMT_VND_TABLE_META, @@ -217,7 +206,7 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SE CTG_ERR_RET(rpcRsp.code); } - CTG_ERR_RET(queryProcessMsgRsp[TDMT_VND_TABLE_META](output, rpcRsp.pCont, rpcRsp.contLen)); + CTG_ERR_RET(queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)](output, rpcRsp.pCont, rpcRsp.contLen)); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 8f753283c1..27ca406fc4 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -16,6 +16,7 @@ #include "tmsg.h" #include "queryInt.h" #include "query.h" +#include "trpc.h" int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char **msg, int32_t msgSize, int32_t *msgLen) = {0}; @@ -31,7 +32,7 @@ int32_t queryBuildTableMetaReqMsg(void* input, char **msg, int32_t msgSize, int3 int32_t estimateSize = sizeof(STableInfoMsg); if (NULL == *msg || msgSize < estimateSize) { tfree(*msg); - *msg = calloc(1, estimateSize); + *msg = rpcMallocCont(estimateSize); if (NULL == *msg) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -59,7 +60,7 @@ int32_t queryBuildUseDbMsg(void* input, char **msg, int32_t msgSize, int32_t *ms int32_t estimateSize = sizeof(SUseDbMsg); if (NULL == *msg || msgSize < estimateSize) { tfree(*msg); - *msg = calloc(1, estimateSize); + *msg = rpcMallocCont(estimateSize); if (NULL == *msg) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -265,13 +266,13 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) { void initQueryModuleMsgHandle() { - queryBuildMsg[TDMT_VND_TABLE_META] = queryBuildTableMetaReqMsg; - queryBuildMsg[TDMT_MND_STB_META] = queryBuildTableMetaReqMsg; - queryBuildMsg[TDMT_MND_USE_DB] = queryBuildUseDbMsg; + queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_STB_META)] = queryBuildTableMetaReqMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg; - queryProcessMsgRsp[TDMT_VND_TABLE_META] = queryProcessTableMetaRsp; - queryProcessMsgRsp[TDMT_MND_STB_META] = queryProcessTableMetaRsp; - queryProcessMsgRsp[TDMT_MND_USE_DB] = queryProcessUseDBRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_STB_META)] = queryProcessTableMetaRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp; } From 96289c47055abe1885f78ef47913fb65d43fff97 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 02:31:14 -0800 Subject: [PATCH 24/55] add colId for stb --- source/dnode/mgmt/impl/test/stb/stb.cpp | 39 +++++++++++++++++++++---- source/dnode/mnode/impl/src/mndStb.c | 9 +++--- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/source/dnode/mgmt/impl/test/stb/stb.cpp b/source/dnode/mgmt/impl/test/stb/stb.cpp index c55e952a89..ca168fb6d7 100644 --- a/source/dnode/mgmt/impl/test/stb/stb.cpp +++ b/source/dnode/mgmt/impl/test/stb/stb.cpp @@ -68,7 +68,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pReq->pSchema[0]; - pSchema->colId = htonl(0); pSchema->bytes = htonl(8); pSchema->type = TSDB_DATA_TYPE_TIMESTAMP; strcpy(pSchema->name, "ts"); @@ -76,7 +75,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pReq->pSchema[1]; - pSchema->colId = htonl(1); pSchema->bytes = htonl(4); pSchema->type = TSDB_DATA_TYPE_INT; strcpy(pSchema->name, "col1"); @@ -84,7 +82,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pReq->pSchema[2]; - pSchema->colId = htonl(2); pSchema->bytes = htonl(2); pSchema->type = TSDB_DATA_TYPE_TINYINT; strcpy(pSchema->name, "tag1"); @@ -92,7 +89,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pReq->pSchema[3]; - pSchema->colId = htonl(3); pSchema->bytes = htonl(8); pSchema->type = TSDB_DATA_TYPE_BIGINT; strcpy(pSchema->name, "tag2"); @@ -100,7 +96,6 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pReq->pSchema[4]; - pSchema->colId = htonl(4); pSchema->bytes = htonl(16); pSchema->type = TSDB_DATA_TYPE_BINARY; strcpy(pSchema->name, "tag3"); @@ -167,10 +162,42 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { { SSchema* pSchema = &pRsp->pSchema[0]; EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP); - EXPECT_EQ(pSchema->colId, 0); + EXPECT_EQ(pSchema->colId, 1); EXPECT_EQ(pSchema->bytes, 8); EXPECT_STREQ(pSchema->name, "ts"); } + + { + SSchema* pSchema = &pRsp->pSchema[1]; + EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_INT); + EXPECT_EQ(pSchema->colId, 2); + EXPECT_EQ(pSchema->bytes, 4); + EXPECT_STREQ(pSchema->name, "col1"); + } + + { + SSchema* pSchema = &pRsp->pSchema[2]; + EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TINYINT); + EXPECT_EQ(pSchema->colId, 3); + EXPECT_EQ(pSchema->bytes, 2); + EXPECT_STREQ(pSchema->name, "tag1"); + } + + { + SSchema* pSchema = &pRsp->pSchema[3]; + EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BIGINT); + EXPECT_EQ(pSchema->colId, 4); + EXPECT_EQ(pSchema->bytes, 8); + EXPECT_STREQ(pSchema->name, "tag2"); + } + + { + SSchema* pSchema = &pRsp->pSchema[4]; + EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY); + EXPECT_EQ(pSchema->colId, 5); + EXPECT_EQ(pSchema->bytes, 16); + EXPECT_STREQ(pSchema->name, "tag3"); + } } // restart diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 97e91af937..6785b25b5c 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -291,7 +291,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) { int32_t totalCols = pCreate->numOfColumns + pCreate->numOfTags; for (int32_t i = 0; i < totalCols; ++i) { SSchema *pSchema = &pCreate->pSchema[i]; - pSchema->colId = htonl(pSchema->colId); pSchema->bytes = htonl(pSchema->bytes); } @@ -317,10 +316,6 @@ static int32_t mndCheckCreateStbMsg(SCreateStbMsg *pCreate) { terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; } - if (pSchema->colId < 0 || pSchema->colId >= maxColId) { - terrno = TSDB_CODE_MND_INVALID_STB_OPTION; - return -1; - } if (pSchema->bytes <= 0) { terrno = TSDB_CODE_MND_INVALID_STB_OPTION; return -1; @@ -453,6 +448,10 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SCreateStbMsg *pCre } memcpy(stbObj.pSchema, pCreate->pSchema, totalSize); + for (int32_t i = 0; i < totalCols; ++i) { + stbObj.pSchema[i].colId = i + 1; + } + int32_t code = 0; STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, &pMsg->rpcMsg); if (pTrans == NULL) { From a32fa005a822c01d3b88a6446a0b24d914ff6f66 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 19:16:08 +0800 Subject: [PATCH 25/55] more --- include/util/encode.h | 44 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index aaeab8dc38..01865191bc 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -16,7 +16,7 @@ #ifndef _TD_UTIL_ENCODE_H_ #define _TD_UTIL_ENCODE_H_ -#include "os.h" +#include "tcoding.h" #ifdef __cplusplus extern "C" { @@ -162,11 +162,11 @@ static FORCE_INLINE int tEncodeU64(SEncoder* pEncoder, uint64_t val) { return 0; } -static FORCE_INLINE int tEncodeI32(SEncoder* pEncoder, int32_t val) { +static FORCE_INLINE int tEncodeI64(SEncoder* pEncoder, int64_t val) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(val))) return -1; if (TD_RT_ENDIAN() == pEncoder->endian) { - tPut(int32_t, TD_CODER_CURRENT(pEncoder), val); + tPut(int64_t, TD_CODER_CURRENT(pEncoder), val); } else { tRPut64(TD_CODER_CURRENT(pEncoder), &val); } @@ -175,6 +175,44 @@ static FORCE_INLINE int tEncodeI32(SEncoder* pEncoder, int32_t val) { return 0; } +static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { + int64_t i = 0; + while (val >= ENCODE_LIMIT) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (uint8_t)(val | ENCODE_LIMIT) + } + + val >>= 7; + i++; + } + + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (uint8_t)val; + } + + TD_CODER_MOVE_POS(pEncoder, i + 1); + + return 0; +} + +static FORCE_INLINE int tEncodeI16v(SEncoder* pEncoder, int16_t val) { return tEncodeU16v(pEncoder, ZIGZAGE(val)); } + +static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { + // TODO + return 0; +} + +static FORCE_INLINE int tEncodeI32v(SEncoder* pEncoder, int32_t val) { return tEncodeU32v(pEncoder, ZIGZAGE(val)); } + +static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { + // TODO + return 0; +} + +static FORCE_INLINE int tEncodeI64v(SEncoder* pEncoder, int64_t val) { return tEncodeU64v(pEncoder, ZIGZAGE(val)); } + /* ------------------------ FOR DECODER ------------------------ */ static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, const uint8_t* data, int64_t size) { ASSERT(!TD_IS_NULL(data)); From 9748f4be676edbb714f6229f6f059893ecc64bd8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 03:20:24 -0800 Subject: [PATCH 26/55] minor changes --- include/dnode/vnode/vnode.h | 10 ---------- source/dnode/vnode/impl/src/vnodeInt.c | 5 ----- tests/script/tmp/dnodes.sim | 23 +++++++++++------------ 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 812f313e71..0313c65acb 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -162,16 +162,6 @@ int vnodeProcessQueryReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); */ int vnodeProcessFetchReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); -/** - * @brief Process a consume message. - * - * @param pVnode The vnode object. - * @param pMsg The request message - * @param pRsp The response message - * @return int 0 for success, -1 for failure - */ -int vnodeProcessConsumeReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); - /* ------------------------ SVnodeCfg ------------------------ */ /** * @brief Initialize VNODE options. diff --git a/source/dnode/vnode/impl/src/vnodeInt.c b/source/dnode/vnode/impl/src/vnodeInt.c index 65185f4a16..0f33fa65cd 100644 --- a/source/dnode/vnode/impl/src/vnodeInt.c +++ b/source/dnode/vnode/impl/src/vnodeInt.c @@ -28,8 +28,3 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { vInfo("sync message is processed"); return 0; } - -int vnodeProcessConsumeReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - vInfo("consume message is processed"); - return 0; -} diff --git a/tests/script/tmp/dnodes.sim b/tests/script/tmp/dnodes.sim index f5146620c5..f13f6026f9 100644 --- a/tests/script/tmp/dnodes.sim +++ b/tests/script/tmp/dnodes.sim @@ -2,20 +2,19 @@ system sh/stop_dnodes.sh ############## config parameter ##################### -$node1 = 192.168.101.174 +$node1 = 192.168.0.201 $node2 = 192.168.0.202 -$node2 = 192.168.0.203 -$node3 = 192.168.0.204 +$node3 = 192.168.0.203 +$node4 = 192.168.0.204 -$first = 1 -$num = 5 $self = $node1 +$num = 25 ############### deploy firstEp ##################### $firstEp = $node1 . :7100 $firstPort = 7100 -if $first == 1 then +if $self == $node1 then system sh/deploy.sh -n dnode1 -i 1 system sh/cfg.sh -n dnode1 -c firstEp -v $firstEp system sh/cfg.sh -n dnode1 -c secondEp -v $firstEp @@ -28,7 +27,7 @@ if $first == 1 then $i = 0 while $i < $num $port = $i * 100 - $port = $port + 8000 + $port = $port + 8100 $i = $i + 1 sql create dnode $node1 port $port endw @@ -36,7 +35,7 @@ if $first == 1 then $i = 0 while $i < $num $port = $i * 100 - $port = $port + 8000 + $port = $port + 8100 $i = $i + 1 sql create dnode $node2 port $port endw @@ -44,7 +43,7 @@ if $first == 1 then $i = 0 while $i < $num $port = $i * 100 - $port = $port + 8000 + $port = $port + 8100 $i = $i + 1 sql create dnode $node3 port $port endw @@ -52,7 +51,7 @@ if $first == 1 then $i = 0 while $i < $num $port = $i * 100 - $port = $port + 8000 + $port = $port + 8100 $i = $i + 1 sql create dnode $node4 port $port endw @@ -64,7 +63,7 @@ $i = 0 while $i < $num $index = $i + 80 $port = $i * 100 - $port = $port + 8000 + $port = $port + 8100 $dnodename = dnode . $index $i = $i + 1 @@ -74,5 +73,5 @@ while $i < $num system sh/cfg.sh -n $dnodename -c fqdn -v $self system sh/cfg.sh -n $dnodename -c serverPort -v $port - #system sh/exec.sh -n $dnodename -s start + system sh/exec.sh -n $dnodename -s start endw From d71830ac6471442372f04e759bcba4248ab829bd Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 19:25:21 +0800 Subject: [PATCH 27/55] more --- include/util/encode.h | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index 01865191bc..8d21b6c358 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -180,7 +180,7 @@ static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { while (val >= ENCODE_LIMIT) { if (pEncoder->data) { if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; - TD_CODER_CURRENT(pEncoder)[i] = (uint8_t)(val | ENCODE_LIMIT) + TD_CODER_CURRENT(pEncoder)[i] = (val | ENCODE_LIMIT) & 0xff; } val >>= 7; @@ -200,14 +200,48 @@ static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { static FORCE_INLINE int tEncodeI16v(SEncoder* pEncoder, int16_t val) { return tEncodeU16v(pEncoder, ZIGZAGE(val)); } static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { - // TODO + int64_t i = 0; + while (val >= ENCODE_LIMIT) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (val | ENCODE_LIMIT) & 0xff; + } + + val >>= 7; + i++; + } + + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (uint8_t)val; + } + + TD_CODER_MOVE_POS(pEncoder, i + 1); + return 0; } static FORCE_INLINE int tEncodeI32v(SEncoder* pEncoder, int32_t val) { return tEncodeU32v(pEncoder, ZIGZAGE(val)); } static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { - // TODO + int64_t i = 0; + while (val >= ENCODE_LIMIT) { + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (val | ENCODE_LIMIT) & 0xff; + } + + val >>= 7; + i++; + } + + if (pEncoder->data) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, 1)) return -1; + TD_CODER_CURRENT(pEncoder)[i] = (uint8_t)val; + } + + TD_CODER_MOVE_POS(pEncoder, i + 1); + return 0; } From ab409503642503a2974b01b40fcab5e15c6e7840 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 19:37:15 +0800 Subject: [PATCH 28/55] more --- include/util/encode.h | 47 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index 8d21b6c358..29a300975e 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -27,14 +27,7 @@ typedef struct { uint8_t* data; int64_t size; int64_t pos; -} SEncoder; - -typedef struct { - td_endian_t endian; - const uint8_t* data; - int64_t size; - int16_t pos; -} SDecoder; +} SEncoder, SDecoder; #define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL) #define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0] @@ -175,6 +168,7 @@ static FORCE_INLINE int tEncodeI64(SEncoder* pEncoder, int64_t val) { return 0; } +// 16v static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { int64_t i = 0; while (val >= ENCODE_LIMIT) { @@ -199,6 +193,7 @@ static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { static FORCE_INLINE int tEncodeI16v(SEncoder* pEncoder, int16_t val) { return tEncodeU16v(pEncoder, ZIGZAGE(val)); } +// 32v static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { int64_t i = 0; while (val >= ENCODE_LIMIT) { @@ -223,6 +218,7 @@ static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { static FORCE_INLINE int tEncodeI32v(SEncoder* pEncoder, int32_t val) { return tEncodeU32v(pEncoder, ZIGZAGE(val)); } +// 64v static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { int64_t i = 0; while (val >= ENCODE_LIMIT) { @@ -248,7 +244,7 @@ static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { static FORCE_INLINE int tEncodeI64v(SEncoder* pEncoder, int64_t val) { return tEncodeU64v(pEncoder, ZIGZAGE(val)); } /* ------------------------ FOR DECODER ------------------------ */ -static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, const uint8_t* data, int64_t size) { +static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, uint8_t* data, int64_t size) { ASSERT(!TD_IS_NULL(data)); pDecoder->endian = endian; pDecoder->data = data; @@ -346,6 +342,39 @@ static FORCER_INLINE int tDecodeI64(SDecoder* pDecoder, int64_t* val) { return 0; } +// 16v +static FORCE_INLINE int tDecodeU16v(SDecoder* pDecoder, uint16_t* val) { + // TODO + return 0; +} + +static FORCE_INLINE int tDecodeI16v(SDecoder* pDecoder, int16_t* val) { + // TODO + return 0; +} + +// 32v +static FORCE_INLINE int tDecodeU32v(SDecoder* pDecoder, uint32_t* val) { + // TODO + return 0; +} + +static FORCE_INLINE int tDecodeI32v(SDecoder* pDecoder, int32_t* val) { + // TODO + return 0; +} + +// 64v +static FORCE_INLINE int tDecodeU64v(SDecoder* pDecoder, uint64_t* val) { + // TODO + return 0; +} + +static FORCE_INLINE int tDecodeI64v(SDecoder* pDecoder, int64_t* val) { + // TODO + return 0; +} + #ifdef __cplusplus } #endif From 8ec2dd7d5136b34a48e68aa06ea9f14230b4a325 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 19:41:02 +0800 Subject: [PATCH 29/55] more --- include/util/encode.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index 29a300975e..4dae140b81 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -191,7 +191,9 @@ static FORCE_INLINE int tEncodeU16v(SEncoder* pEncoder, uint16_t val) { return 0; } -static FORCE_INLINE int tEncodeI16v(SEncoder* pEncoder, int16_t val) { return tEncodeU16v(pEncoder, ZIGZAGE(val)); } +static FORCE_INLINE int tEncodeI16v(SEncoder* pEncoder, int16_t val) { + return tEncodeU16v(pEncoder, ZIGZAGE(int16_t, val)); +} // 32v static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { @@ -216,7 +218,9 @@ static FORCE_INLINE int tEncodeU32v(SEncoder* pEncoder, uint32_t val) { return 0; } -static FORCE_INLINE int tEncodeI32v(SEncoder* pEncoder, int32_t val) { return tEncodeU32v(pEncoder, ZIGZAGE(val)); } +static FORCE_INLINE int tEncodeI32v(SEncoder* pEncoder, int32_t val) { + return tEncodeU32v(pEncoder, ZIGZAGE(int32_t, val)); +} // 64v static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { @@ -241,7 +245,9 @@ static FORCE_INLINE int tEncodeU64v(SEncoder* pEncoder, uint64_t val) { return 0; } -static FORCE_INLINE int tEncodeI64v(SEncoder* pEncoder, int64_t val) { return tEncodeU64v(pEncoder, ZIGZAGE(val)); } +static FORCE_INLINE int tEncodeI64v(SEncoder* pEncoder, int64_t val) { + return tEncodeU64v(pEncoder, ZIGZAGE(int64_t, val)); +} /* ------------------------ FOR DECODER ------------------------ */ static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, uint8_t* data, int64_t size) { From 273607029e8b33353e96cabc214d04565c5a77ff Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 19:55:45 +0800 Subject: [PATCH 30/55] finish encoding --- include/util/encode.h | 69 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index 4dae140b81..03608e0a19 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -350,34 +350,91 @@ static FORCER_INLINE int tDecodeI64(SDecoder* pDecoder, int64_t* val) { // 16v static FORCE_INLINE int tDecodeU16v(SDecoder* pDecoder, uint16_t* val) { - // TODO + int64_t i = 0; + *val = 0; + for (;;) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, 1)) return -1; + uint16_t tval = TD_CODER_CURRENT(pDecoder)[i]; + if (tval < ENCODE_LIMIT) { + (*val) |= (tval << (7 * i)); + break; + } else { + (*val) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); + i++; + } + } + + TD_CODER_MOVE_POS(pDecoder, i); + return 0; } static FORCE_INLINE int tDecodeI16v(SDecoder* pDecoder, int16_t* val) { - // TODO + uint16_t tval; + if (tDecodeU16v(pDecoder, &tval) < 0) { + return -1; + } + *val = ZIGZAGD(int16_t, tval); return 0; } // 32v static FORCE_INLINE int tDecodeU32v(SDecoder* pDecoder, uint32_t* val) { - // TODO + int64_t i = 0; + *val = 0; + for (;;) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, 1)) return -1; + uint32_t tval = TD_CODER_CURRENT(pDecoder)[i]; + if (tval < ENCODE_LIMIT) { + (*val) |= (tval << (7 * i)); + break; + } else { + (*val) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); + i++; + } + } + + TD_CODER_MOVE_POS(pDecoder, i); + return 0; } static FORCE_INLINE int tDecodeI32v(SDecoder* pDecoder, int32_t* val) { - // TODO + uint32_t tval; + if (tDecodeU32v(pDecoder, &tval) < 0) { + return -1; + } + *val = ZIGZAGD(int32_t, tval); return 0; } // 64v static FORCE_INLINE int tDecodeU64v(SDecoder* pDecoder, uint64_t* val) { - // TODO + int64_t i = 0; + *val = 0; + for (;;) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, 1)) return -1; + uint64_t tval = TD_CODER_CURRENT(pDecoder)[i]; + if (tval < ENCODE_LIMIT) { + (*val) |= (tval << (7 * i)); + break; + } else { + (*val) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); + i++; + } + } + + TD_CODER_MOVE_POS(pDecoder, i); + return 0; } static FORCE_INLINE int tDecodeI64v(SDecoder* pDecoder, int64_t* val) { - // TODO + uint64_t tval; + if (tDecodeU64v(pDecoder, &tval) < 0) { + return -1; + } + *val = ZIGZAGD(int64_t, tval); return 0; } From c31dc877631eb90800d2ae7ac8e3dda1a7f1205c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 04:01:04 -0800 Subject: [PATCH 31/55] fix drop dnode errors --- include/common/tmsg.h | 2 -- source/dnode/mgmt/impl/src/dndDnode.c | 23 +++++++++++++---------- source/dnode/mnode/impl/src/mndDnode.c | 1 - 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index c644bfda9e..0b59131644 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -661,8 +661,6 @@ typedef struct { typedef struct { int32_t dnodeId; int64_t clusterId; - int8_t dropped; - char reserved[7]; } SDnodeCfg; typedef struct { diff --git a/source/dnode/mgmt/impl/src/dndDnode.c b/source/dnode/mgmt/impl/src/dndDnode.c index ca0552b8ad..98763fce30 100644 --- a/source/dnode/mgmt/impl/src/dndDnode.c +++ b/source/dnode/mgmt/impl/src/dndDnode.c @@ -393,13 +393,11 @@ void dndSendStatusMsg(SDnode *pDnode) { static void dndUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) { SDnodeMgmt *pMgmt = &pDnode->dmgmt; - if (pMgmt->dnodeId == 0 || pMgmt->dropped != pCfg->dropped) { - dInfo("set dnodeId:%d clusterId:% " PRId64 " dropped:%d", pCfg->dnodeId, pCfg->clusterId, pCfg->dropped); - + if (pMgmt->dnodeId == 0) { + dInfo("set dnodeId:%d clusterId:% " PRId64, pCfg->dnodeId, pCfg->clusterId); taosWLockLatch(&pMgmt->latch); pMgmt->dnodeId = pCfg->dnodeId; pMgmt->clusterId = pCfg->clusterId; - pMgmt->dropped = pCfg->dropped; dndWriteDnodes(pDnode); taosWUnLockLatch(&pMgmt->latch); } @@ -430,6 +428,11 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) { if (pMsg->code != TSDB_CODE_SUCCESS) { pMgmt->statusSent = 0; + if (pMsg->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->dropped && pMgmt->dnodeId > 0) { + dInfo("dnode:%d, set to dropped since not exist in mnode", pMgmt->dnodeId); + pMgmt->dropped = 1; + dndWriteDnodes(pDnode); + } return; } @@ -439,11 +442,6 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg) { pCfg->clusterId = htobe64(pCfg->clusterId); dndUpdateDnodeCfg(pDnode, pCfg); - if (pCfg->dropped) { - pMgmt->statusSent = 0; - return; - } - SDnodeEps *pDnodeEps = &pRsp->dnodeEps; pDnodeEps->num = htonl(pDnodeEps->num); for (int32_t i = 0; i < pDnodeEps->num; ++i) { @@ -487,7 +485,7 @@ static void *dnodeThreadRoutine(void *param) { pthread_testcancel(); taosMsleep(ms); - if (dndGetStat(pDnode) == DND_STAT_RUNNING && !pMgmt->statusSent) { + if (dndGetStat(pDnode) == DND_STAT_RUNNING && !pMgmt->statusSent && !pMgmt->dropped) { dndSendStatusMsg(pDnode); } } @@ -522,6 +520,11 @@ int32_t dndInitDnode(SDnode *pDnode) { return -1; } + if (pMgmt->dropped) { + dError("dnode will not start for its already dropped"); + return -1; + } + if (dndInitMgmtWorker(pDnode) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 2d236906e1..91d2a084af 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -370,7 +370,6 @@ static int32_t mndProcessStatusMsg(SMnodeMsg *pMsg) { } pRsp->dnodeCfg.dnodeId = htonl(pDnode->id); - pRsp->dnodeCfg.dropped = 0; pRsp->dnodeCfg.clusterId = htobe64(pMnode->clusterId); mndGetDnodeData(pMnode, &pRsp->dnodeEps, numOfEps); From c4bd887e63b956873895b9023598e79ab6df948d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 28 Dec 2021 20:03:41 +0800 Subject: [PATCH 32/55] [td-11818]support create child table. --- include/common/taosdef.h | 12 +- include/common/tmsg.h | 20 - include/common/ttokendef.h | 388 ++--- include/libs/parser/parsenodes.h | 1 + include/util/tdef.h | 6 +- source/client/src/clientImpl.c | 58 +- source/common/src/tvariant.c | 1 - source/libs/parser/inc/sql.y | 2 +- source/libs/parser/inc/ttokendef.h | 231 --- source/libs/parser/src/astGenerator.c | 2 +- source/libs/parser/src/dCDAstProcess.c | 86 +- source/libs/parser/src/queryInfoUtil.c | 2 +- source/libs/parser/src/sql.c | 2210 ++++++++++++------------ source/libs/parser/src/ttokenizer.c | 12 +- 14 files changed, 1385 insertions(+), 1646 deletions(-) delete mode 100644 source/libs/parser/inc/ttokendef.h diff --git a/include/common/taosdef.h b/include/common/taosdef.h index da58f98e4c..46c0c98ff0 100644 --- a/include/common/taosdef.h +++ b/include/common/taosdef.h @@ -38,12 +38,12 @@ typedef enum { } EQType; typedef enum { - TSDB_SUPER_TABLE = 1, // super table - TSDB_CHILD_TABLE = 2, // table created from super table - TSDB_NORMAL_TABLE = 3, // ordinary table - TSDB_STREAM_TABLE = 4, // table created from stream computing - TSDB_TEMP_TABLE = 5, // temp table created by nest query - TSDB_TABLE_MAX = 6 + TSDB_SUPER_TABLE = 1, // super table + TSDB_CHILD_TABLE = 2, // table created from super table + TSDB_NORMAL_TABLE = 3, // ordinary table + TSDB_STREAM_TABLE = 4, // table created from stream computing + TSDB_TEMP_TABLE = 5, // temp table created by nest query + TSDB_TABLE_MAX = 6 } ETableType; typedef enum { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index c644bfda9e..8a05ba9d02 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -218,26 +218,6 @@ typedef struct { char data[]; } SMDCreateTableMsg; -// typedef struct { -// int32_t len; // one create table message -// char tableName[TSDB_TABLE_FNAME_LEN]; -// int16_t numOfColumns; -// int16_t sqlLen; // the length of SQL, it starts after schema , sql is a null-terminated string -// int8_t igExists; -// int8_t rspMeta; -// int8_t reserved[16]; -// char schema[]; -//} SCreateTableMsg; - -typedef struct { - char tableName[TSDB_TABLE_FNAME_LEN]; - int16_t numOfColumns; - int16_t numOfTags; - int8_t igExists; - int8_t rspMeta; - char schema[]; -} SCreateCTableMsg; - typedef struct { char name[TSDB_TABLE_FNAME_LEN]; int8_t igExists; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 5f9fe5134b..90926da120 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -13,205 +13,199 @@ * along with this program. If not, see . */ -#ifndef _TD_COMMON_TOKEN_DEF_H_ -#define _TD_COMMON_TOKEN_DEF_H_ +#ifndef TDENGINE_TTOKENDEF_H +#define TDENGINE_TTOKENDEF_H #define TK_ID 1 #define TK_BOOL 2 -#define TK_TINYINT 3 -#define TK_SMALLINT 4 -#define TK_INTEGER 5 -#define TK_BIGINT 6 -#define TK_FLOAT 7 -#define TK_DOUBLE 8 -#define TK_STRING 9 -#define TK_TIMESTAMP 10 -#define TK_BINARY 11 -#define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_MATCH 22 -#define TK_NMATCH 23 -#define TK_GLOB 24 -#define TK_BETWEEN 25 -#define TK_IN 26 -#define TK_GT 27 -#define TK_GE 28 -#define TK_LT 29 -#define TK_LE 30 -#define TK_BITAND 31 -#define TK_BITOR 32 -#define TK_LSHIFT 33 -#define TK_RSHIFT 34 -#define TK_PLUS 35 -#define TK_MINUS 36 -#define TK_DIVIDE 37 -#define TK_TIMES 38 -#define TK_STAR 39 -#define TK_SLASH 40 -#define TK_REM 41 -#define TK_CONCAT 42 -#define TK_UMINUS 43 -#define TK_UPLUS 44 -#define TK_BITNOT 45 -#define TK_SHOW 46 -#define TK_DATABASES 47 -#define TK_TOPICS 48 -#define TK_FUNCTIONS 49 -#define TK_MNODES 50 -#define TK_DNODES 51 -#define TK_ACCOUNTS 52 -#define TK_USERS 53 -#define TK_MODULES 54 -#define TK_QUERIES 55 -#define TK_CONNECTIONS 56 -#define TK_STREAMS 57 -#define TK_VARIABLES 58 -#define TK_SCORES 59 -#define TK_GRANTS 60 -#define TK_VNODES 61 -#define TK_DOT 62 -#define TK_CREATE 63 -#define TK_TABLE 64 -#define TK_STABLE 65 -#define TK_DATABASE 66 -#define TK_TABLES 67 -#define TK_STABLES 68 -#define TK_VGROUPS 69 -#define TK_DROP 70 -#define TK_TOPIC 71 -#define TK_FUNCTION 72 -#define TK_DNODE 73 -#define TK_USER 74 -#define TK_ACCOUNT 75 -#define TK_USE 76 -#define TK_DESCRIBE 77 -#define TK_DESC 78 -#define TK_ALTER 79 -#define TK_PASS 80 -#define TK_PRIVILEGE 81 -#define TK_LOCAL 82 -#define TK_COMPACT 83 -#define TK_LP 84 -#define TK_RP 85 -#define TK_IF 86 -#define TK_EXISTS 87 -#define TK_AS 88 -#define TK_OUTPUTTYPE 89 -#define TK_AGGREGATE 90 -#define TK_BUFSIZE 91 -#define TK_PPS 92 -#define TK_TSERIES 93 -#define TK_DBS 94 -#define TK_STORAGE 95 -#define TK_QTIME 96 -#define TK_CONNS 97 -#define TK_STATE 98 -#define TK_COMMA 99 -#define TK_KEEP 100 -#define TK_CACHE 101 -#define TK_REPLICA 102 -#define TK_QUORUM 103 -#define TK_DAYS 104 -#define TK_MINROWS 105 -#define TK_MAXROWS 106 -#define TK_BLOCKS 107 -#define TK_CTIME 108 -#define TK_WAL 109 -#define TK_FSYNC 110 -#define TK_COMP 111 -#define TK_PRECISION 112 -#define TK_UPDATE 113 -#define TK_CACHELAST 114 -#define TK_PARTITIONS 115 -#define TK_UNSIGNED 116 -#define TK_TAGS 117 -#define TK_USING 118 -#define TK_NULL 119 -#define TK_NOW 120 -#define TK_SELECT 121 -#define TK_UNION 122 -#define TK_ALL 123 -#define TK_DISTINCT 124 -#define TK_FROM 125 -#define TK_VARIABLE 126 -#define TK_INTERVAL 127 -#define TK_EVERY 128 -#define TK_SESSION 129 -#define TK_STATE_WINDOW 130 -#define TK_FILL 131 -#define TK_SLIDING 132 -#define TK_ORDER 133 -#define TK_BY 134 -#define TK_ASC 135 -#define TK_GROUP 136 -#define TK_HAVING 137 -#define TK_LIMIT 138 -#define TK_OFFSET 139 -#define TK_SLIMIT 140 -#define TK_SOFFSET 141 -#define TK_WHERE 142 -#define TK_RESET 143 -#define TK_QUERY 144 -#define TK_SYNCDB 145 -#define TK_ADD 146 -#define TK_COLUMN 147 -#define TK_MODIFY 148 -#define TK_TAG 149 -#define TK_CHANGE 150 -#define TK_SET 151 -#define TK_KILL 152 -#define TK_CONNECTION 153 -#define TK_STREAM 154 -#define TK_COLON 155 -#define TK_ABORT 156 -#define TK_AFTER 157 -#define TK_ATTACH 158 -#define TK_BEFORE 159 -#define TK_BEGIN 160 -#define TK_CASCADE 161 -#define TK_CLUSTER 162 -#define TK_CONFLICT 163 -#define TK_COPY 164 -#define TK_DEFERRED 165 -#define TK_DELIMITERS 166 -#define TK_DETACH 167 -#define TK_EACH 168 -#define TK_END 169 -#define TK_EXPLAIN 170 -#define TK_FAIL 171 -#define TK_FOR 172 -#define TK_IGNORE 173 -#define TK_IMMEDIATE 174 -#define TK_INITIALLY 175 -#define TK_INSTEAD 176 -#define TK_KEY 177 -#define TK_OF 178 -#define TK_RAISE 179 -#define TK_REPLACE 180 -#define TK_RESTRICT 181 -#define TK_ROW 182 -#define TK_STATEMENT 183 -#define TK_TRIGGER 184 -#define TK_VIEW 185 -#define TK_IPTOKEN 186 -#define TK_SEMI 187 -#define TK_NONE 188 -#define TK_PREV 189 -#define TK_LINEAR 190 -#define TK_IMPORT 191 -#define TK_TBNAME 192 -#define TK_JOIN 193 -#define TK_INSERT 194 -#define TK_INTO 195 -#define TK_VALUES 196 +#define TK_INTEGER 3 +#define TK_FLOAT 4 +#define TK_STRING 5 +#define TK_TIMESTAMP 6 +#define TK_OR 7 +#define TK_AND 8 +#define TK_NOT 9 +#define TK_EQ 10 +#define TK_NE 11 +#define TK_ISNULL 12 +#define TK_NOTNULL 13 +#define TK_IS 14 +#define TK_LIKE 15 +#define TK_MATCH 16 +#define TK_NMATCH 17 +#define TK_GLOB 18 +#define TK_BETWEEN 19 +#define TK_IN 20 +#define TK_GT 21 +#define TK_GE 22 +#define TK_LT 23 +#define TK_LE 24 +#define TK_BITAND 25 +#define TK_BITOR 26 +#define TK_LSHIFT 27 +#define TK_RSHIFT 28 +#define TK_PLUS 29 +#define TK_MINUS 30 +#define TK_DIVIDE 31 +#define TK_TIMES 32 +#define TK_STAR 33 +#define TK_SLASH 34 +#define TK_REM 35 +#define TK_CONCAT 36 +#define TK_UMINUS 37 +#define TK_UPLUS 38 +#define TK_BITNOT 39 +#define TK_SHOW 40 +#define TK_DATABASES 41 +#define TK_TOPICS 42 +#define TK_FUNCTIONS 43 +#define TK_MNODES 44 +#define TK_DNODES 45 +#define TK_ACCOUNTS 46 +#define TK_USERS 47 +#define TK_MODULES 48 +#define TK_QUERIES 49 +#define TK_CONNECTIONS 50 +#define TK_STREAMS 51 +#define TK_VARIABLES 52 +#define TK_SCORES 53 +#define TK_GRANTS 54 +#define TK_VNODES 55 +#define TK_DOT 56 +#define TK_CREATE 57 +#define TK_TABLE 58 +#define TK_STABLE 59 +#define TK_DATABASE 60 +#define TK_TABLES 61 +#define TK_STABLES 62 +#define TK_VGROUPS 63 +#define TK_DROP 64 +#define TK_TOPIC 65 +#define TK_FUNCTION 66 +#define TK_DNODE 67 +#define TK_USER 68 +#define TK_ACCOUNT 69 +#define TK_USE 70 +#define TK_DESCRIBE 71 +#define TK_DESC 72 +#define TK_ALTER 73 +#define TK_PASS 74 +#define TK_PRIVILEGE 75 +#define TK_LOCAL 76 +#define TK_COMPACT 77 +#define TK_LP 78 +#define TK_RP 79 +#define TK_IF 80 +#define TK_EXISTS 81 +#define TK_PORT 82 +#define TK_IPTOKEN 83 +#define TK_AS 84 +#define TK_OUTPUTTYPE 85 +#define TK_AGGREGATE 86 +#define TK_BUFSIZE 87 +#define TK_PPS 88 +#define TK_TSERIES 89 +#define TK_DBS 90 +#define TK_STORAGE 91 +#define TK_QTIME 92 +#define TK_CONNS 93 +#define TK_STATE 94 +#define TK_COMMA 95 +#define TK_KEEP 96 +#define TK_CACHE 97 +#define TK_REPLICA 98 +#define TK_QUORUM 99 +#define TK_DAYS 100 +#define TK_MINROWS 101 +#define TK_MAXROWS 102 +#define TK_BLOCKS 103 +#define TK_CTIME 104 +#define TK_WAL 105 +#define TK_FSYNC 106 +#define TK_COMP 107 +#define TK_PRECISION 108 +#define TK_UPDATE 109 +#define TK_CACHELAST 110 +#define TK_UNSIGNED 111 +#define TK_TAGS 112 +#define TK_USING 113 +#define TK_NULL 114 +#define TK_NOW 115 +#define TK_SELECT 116 +#define TK_UNION 117 +#define TK_ALL 118 +#define TK_DISTINCT 119 +#define TK_FROM 120 +#define TK_VARIABLE 121 +#define TK_INTERVAL 122 +#define TK_EVERY 123 +#define TK_SESSION 124 +#define TK_STATE_WINDOW 125 +#define TK_FILL 126 +#define TK_SLIDING 127 +#define TK_ORDER 128 +#define TK_BY 129 +#define TK_ASC 130 +#define TK_GROUP 131 +#define TK_HAVING 132 +#define TK_LIMIT 133 +#define TK_OFFSET 134 +#define TK_SLIMIT 135 +#define TK_SOFFSET 136 +#define TK_WHERE 137 +#define TK_RESET 138 +#define TK_QUERY 139 +#define TK_SYNCDB 140 +#define TK_ADD 141 +#define TK_COLUMN 142 +#define TK_MODIFY 143 +#define TK_TAG 144 +#define TK_CHANGE 145 +#define TK_SET 146 +#define TK_KILL 147 +#define TK_CONNECTION 148 +#define TK_STREAM 149 +#define TK_COLON 150 +#define TK_ABORT 151 +#define TK_AFTER 152 +#define TK_ATTACH 153 +#define TK_BEFORE 154 +#define TK_BEGIN 155 +#define TK_CASCADE 156 +#define TK_CLUSTER 157 +#define TK_CONFLICT 158 +#define TK_COPY 159 +#define TK_DEFERRED 160 +#define TK_DELIMITERS 161 +#define TK_DETACH 162 +#define TK_EACH 163 +#define TK_END 164 +#define TK_EXPLAIN 165 +#define TK_FAIL 166 +#define TK_FOR 167 +#define TK_IGNORE 168 +#define TK_IMMEDIATE 169 +#define TK_INITIALLY 170 +#define TK_INSTEAD 171 +#define TK_KEY 172 +#define TK_OF 173 +#define TK_RAISE 174 +#define TK_REPLACE 175 +#define TK_RESTRICT 176 +#define TK_ROW 177 +#define TK_STATEMENT 178 +#define TK_TRIGGER 179 +#define TK_VIEW 180 +#define TK_SEMI 181 +#define TK_NONE 182 +#define TK_PREV 183 +#define TK_LINEAR 184 +#define TK_IMPORT 185 +#define TK_TBNAME 186 +#define TK_JOIN 187 +#define TK_INSERT 188 +#define TK_INTO 189 +#define TK_VALUES 190 #define TK_SPACE 300 @@ -223,6 +217,6 @@ #define TK_FILE 306 #define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query -#endif /*_TD_COMMON_TOKEN_DEF_H_*/ +#endif diff --git a/include/libs/parser/parsenodes.h b/include/libs/parser/parsenodes.h index 1a8e8ddd47..980219a4e9 100644 --- a/include/libs/parser/parsenodes.h +++ b/include/libs/parser/parsenodes.h @@ -166,6 +166,7 @@ typedef struct SInsertStmtInfo { typedef struct SDclStmtInfo { int16_t nodeType; int16_t msgType; + SEpSet epSet; char* pMsg; int32_t msgLen; } SDclStmtInfo; diff --git a/include/util/tdef.h b/include/util/tdef.h index 8b810b410c..233e9f0f55 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -317,12 +317,12 @@ do { \ #define TSDB_MAX_FIELD_LEN 16384 #define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 #define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 -#define PRIMARYKEY_TIMESTAMP_COL_ID 0 +#define PRIMARYKEY_TIMESTAMP_COL_ID 1 #define TSDB_MAX_RPC_THREADS 5 -#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type -#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode +#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type +#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode #define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 322a3b9d62..5885d10454 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -182,40 +182,40 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) { STscObj* pTscObj = pRequest->pTscObj; + SMsgSendInfo* pSendMsg = buildSendMsgInfoImpl(pRequest); SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet; if (pDcl->msgType == TDMT_VND_CREATE_TABLE) { - struct SCatalog* pCatalog = NULL; - - char buf[18] = {0}; - sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId); - int32_t code = catalogGetHandle(buf, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData; - - SName t = {0}; - tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE); - - char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0}; - tNameGetFullDbName(&t, db); - - SVgroupInfo info = {0}; - catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info); - +// struct SCatalog* pCatalog = NULL; +// +// char buf[18] = {0}; +// sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId); +// int32_t code = catalogGetHandle(buf, &pCatalog); +// if (code != TSDB_CODE_SUCCESS) { +// return code; +// } +// +// SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData; +// +// SName t = {0}; +// tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE); +// +// char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0}; +// tNameGetFullDbName(&t, db); +// +// SVgroupInfo info = {0}; +// catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info); +// int64_t transporterId = 0; - SEpSet ep = {0}; - ep.inUse = info.inUse; - ep.numOfEps = info.numOfEps; - for(int32_t i = 0; i < ep.numOfEps; ++i) { - ep.port[i] = info.epAddr[i].port; - tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i])); - } - - asyncSendMsgToServer(pTscObj->pTransporter, &ep, &transporterId, pSendMsg); +// SEpSet ep = {0}; +// ep.inUse = info.inUse; +// ep.numOfEps = info.numOfEps; +// for(int32_t i = 0; i < ep.numOfEps; ++i) { +// ep.port[i] = info.epAddr[i].port; +// tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i])); +// } + asyncSendMsgToServer(pTscObj->pTransporter, &pDcl->epSet, &transporterId, pSendMsg); } else { int64_t transporterId = 0; asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, pSendMsg); diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index 8a5a300fcf..27f1d4947d 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -16,7 +16,6 @@ #include "taos.h" #include "taosdef.h" -#include "thash.h" #include "ttime.h" #include "ttokendef.h" #include "ttypes.h" diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 7f23577060..e9f9c862e2 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -6,7 +6,7 @@ %default_type {SToken} %extra_argument {SSqlInfo* pInfo} -%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR. +%fallback ID BOOL INTEGER FLOAT STRING TIMESTAMP. %left OR. %left AND. diff --git a/source/libs/parser/inc/ttokendef.h b/source/libs/parser/inc/ttokendef.h deleted file mode 100644 index d6adda5d45..0000000000 --- a/source/libs/parser/inc/ttokendef.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_TTOKENDEF_H -#define TDENGINE_TTOKENDEF_H - -#define TK_ID 1 -#define TK_BOOL 2 -#define TK_TINYINT 3 -#define TK_SMALLINT 4 -#define TK_INTEGER 5 -#define TK_BIGINT 6 -#define TK_FLOAT 7 -#define TK_DOUBLE 8 -#define TK_STRING 9 -#define TK_TIMESTAMP 10 -#define TK_BINARY 11 -#define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_MATCH 22 -#define TK_NMATCH 23 -#define TK_GLOB 24 -#define TK_BETWEEN 25 -#define TK_IN 26 -#define TK_GT 27 -#define TK_GE 28 -#define TK_LT 29 -#define TK_LE 30 -#define TK_BITAND 31 -#define TK_BITOR 32 -#define TK_LSHIFT 33 -#define TK_RSHIFT 34 -#define TK_PLUS 35 -#define TK_MINUS 36 -#define TK_DIVIDE 37 -#define TK_TIMES 38 -#define TK_STAR 39 -#define TK_SLASH 40 -#define TK_REM 41 -#define TK_CONCAT 42 -#define TK_UMINUS 43 -#define TK_UPLUS 44 -#define TK_BITNOT 45 -#define TK_SHOW 46 -#define TK_DATABASES 47 -#define TK_TOPICS 48 -#define TK_FUNCTIONS 49 -#define TK_MNODES 50 -#define TK_DNODES 51 -#define TK_ACCOUNTS 52 -#define TK_USERS 53 -#define TK_MODULES 54 -#define TK_QUERIES 55 -#define TK_CONNECTIONS 56 -#define TK_STREAMS 57 -#define TK_VARIABLES 58 -#define TK_SCORES 59 -#define TK_GRANTS 60 -#define TK_VNODES 61 -#define TK_DOT 62 -#define TK_CREATE 63 -#define TK_TABLE 64 -#define TK_STABLE 65 -#define TK_DATABASE 66 -#define TK_TABLES 67 -#define TK_STABLES 68 -#define TK_VGROUPS 69 -#define TK_DROP 70 -#define TK_TOPIC 71 -#define TK_FUNCTION 72 -#define TK_DNODE 73 -#define TK_USER 74 -#define TK_ACCOUNT 75 -#define TK_USE 76 -#define TK_DESCRIBE 77 -#define TK_DESC 78 -#define TK_ALTER 79 -#define TK_PASS 80 -#define TK_PRIVILEGE 81 -#define TK_LOCAL 82 -#define TK_COMPACT 83 -#define TK_LP 84 -#define TK_RP 85 -#define TK_IF 86 -#define TK_EXISTS 87 -#define TK_PORT 88 -#define TK_IPTOKEN 89 -#define TK_AS 90 -#define TK_OUTPUTTYPE 91 -#define TK_AGGREGATE 92 -#define TK_BUFSIZE 93 -#define TK_PPS 94 -#define TK_TSERIES 95 -#define TK_DBS 96 -#define TK_STORAGE 97 -#define TK_QTIME 98 -#define TK_CONNS 99 -#define TK_STATE 100 -#define TK_COMMA 101 -#define TK_KEEP 102 -#define TK_CACHE 103 -#define TK_REPLICA 104 -#define TK_QUORUM 105 -#define TK_DAYS 106 -#define TK_MINROWS 107 -#define TK_MAXROWS 108 -#define TK_BLOCKS 109 -#define TK_CTIME 110 -#define TK_WAL 111 -#define TK_FSYNC 112 -#define TK_COMP 113 -#define TK_PRECISION 114 -#define TK_UPDATE 115 -#define TK_CACHELAST 116 -#define TK_UNSIGNED 117 -#define TK_TAGS 118 -#define TK_USING 119 -#define TK_NULL 120 -#define TK_NOW 121 -#define TK_SELECT 122 -#define TK_UNION 123 -#define TK_ALL 124 -#define TK_DISTINCT 125 -#define TK_FROM 126 -#define TK_VARIABLE 127 -#define TK_INTERVAL 128 -#define TK_EVERY 129 -#define TK_SESSION 130 -#define TK_STATE_WINDOW 131 -#define TK_FILL 132 -#define TK_SLIDING 133 -#define TK_ORDER 134 -#define TK_BY 135 -#define TK_ASC 136 -#define TK_GROUP 137 -#define TK_HAVING 138 -#define TK_LIMIT 139 -#define TK_OFFSET 140 -#define TK_SLIMIT 141 -#define TK_SOFFSET 142 -#define TK_WHERE 143 -#define TK_RESET 144 -#define TK_QUERY 145 -#define TK_SYNCDB 146 -#define TK_ADD 147 -#define TK_COLUMN 148 -#define TK_MODIFY 149 -#define TK_TAG 150 -#define TK_CHANGE 151 -#define TK_SET 152 -#define TK_KILL 153 -#define TK_CONNECTION 154 -#define TK_STREAM 155 -#define TK_COLON 156 -#define TK_ABORT 157 -#define TK_AFTER 158 -#define TK_ATTACH 159 -#define TK_BEFORE 160 -#define TK_BEGIN 161 -#define TK_CASCADE 162 -#define TK_CLUSTER 163 -#define TK_CONFLICT 164 -#define TK_COPY 165 -#define TK_DEFERRED 166 -#define TK_DELIMITERS 167 -#define TK_DETACH 168 -#define TK_EACH 169 -#define TK_END 170 -#define TK_EXPLAIN 171 -#define TK_FAIL 172 -#define TK_FOR 173 -#define TK_IGNORE 174 -#define TK_IMMEDIATE 175 -#define TK_INITIALLY 176 -#define TK_INSTEAD 177 -#define TK_KEY 178 -#define TK_OF 179 -#define TK_RAISE 180 -#define TK_REPLACE 181 -#define TK_RESTRICT 182 -#define TK_ROW 183 -#define TK_STATEMENT 184 -#define TK_TRIGGER 185 -#define TK_VIEW 186 -#define TK_SEMI 187 -#define TK_NONE 188 -#define TK_PREV 189 -#define TK_LINEAR 190 -#define TK_IMPORT 191 -#define TK_TBNAME 192 -#define TK_JOIN 193 -#define TK_INSERT 194 -#define TK_INTO 195 -#define TK_VALUES 196 - - - - - -#define TK_SPACE 300 -#define TK_COMMENT 301 -#define TK_ILLEGAL 302 -#define TK_HEX 303 // hex number 0x123 -#define TK_OCT 304 // oct number -#define TK_BIN 305 // bin format data 0b111 -#define TK_FILE 306 -#define TK_QUESTION 307 // denoting the placeholder of "?",when invoking statement bind query - -#endif - - diff --git a/source/libs/parser/src/astGenerator.c b/source/libs/parser/src/astGenerator.c index b6a6b73ccc..84253395c5 100644 --- a/source/libs/parser/src/astGenerator.c +++ b/source/libs/parser/src/astGenerator.c @@ -276,7 +276,7 @@ bool tSqlExprIsLeaf(tSqlExpr *pExpr) { return (pExpr->pRight == NULL && pExpr->pLeft == NULL) && (pExpr->tokenId == 0 || (pExpr->tokenId == TK_ID) || - (pExpr->tokenId >= TK_BOOL && pExpr->tokenId <= TK_NCHAR) || + (pExpr->tokenId == TK_BOOL || pExpr->tokenId == TK_STRING || pExpr->tokenId == TK_FLOAT) || (pExpr->tokenId == TK_NULL) || (pExpr->tokenId == TK_SET)); } diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 7d733bbeca..f01338e051 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -1,3 +1,4 @@ +#include #include #include "astToMsg.h" #include "parserInt.h" @@ -283,7 +284,7 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) { return TSDB_CODE_SUCCESS; } -int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf) { +int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf, char** pOutput, int32_t* len, SEpSet* pEpSet) { const char* msg1 = "invalid table name"; const char* msg2 = "tags number not matched"; const char* msg3 = "tag value too long"; @@ -316,13 +317,14 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p const char* pStableName = tNameGetTableName(&name); SArray* pValList = pCreateTableInfo->pTagVals; - size_t valSize = taosArrayGetSize(pValList); + size_t numOfInputTag = taosArrayGetSize(pValList); STableMeta* pSuperTableMeta = NULL; char dbName[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(&name, dbName); catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pStableName, &pSuperTableMeta); + assert(pSuperTableMeta != NULL); // too long tag values will return invalid sql, not be truncated automatically SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta); @@ -342,7 +344,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p pNameList = pCreateTableInfo->pTagNames; nameSize = taosArrayGetSize(pNameList); - if (valSize != nameSize || schemaSize < valSize) { + if (numOfInputTag != nameSize || schemaSize < numOfInputTag) { tdDestroyKVRowBuilder(&kvRowBuilder); return buildInvalidOperationMsg(pMsgBuf, msg2); } @@ -418,33 +420,36 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p } } } else { - if (schemaSize != valSize) { + if (schemaSize != numOfInputTag) { tdDestroyKVRowBuilder(&kvRowBuilder); return buildInvalidOperationMsg(pMsgBuf, msg2); } - for (int32_t i = 0; i < valSize; ++i) { + for (int32_t i = 0; i < numOfInputTag; ++i) { SSchema *pSchema = &pTagSchema[i]; - SListItem *pItem = taosArrayGet(pValList, i); + SToken* pItem = taosArrayGet(pValList, i); char tagVal[TSDB_MAX_TAGS_LEN]; if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - if (pItem->pVar.nLen > pSchema->bytes) { + if (pItem->n > pSchema->bytes) { tdDestroyKVRowBuilder(&kvRowBuilder); return buildInvalidOperationMsg(pMsgBuf, msg3); } } else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { - if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { -// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); - if (code != TSDB_CODE_SUCCESS) { - return buildInvalidOperationMsg(pMsgBuf, msg4); - } - } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { - pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); - } +// if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { +//// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); +// if (code != TSDB_CODE_SUCCESS) { +// return buildInvalidOperationMsg(pMsgBuf, msg4); +// } +// } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { +// pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); +// } } - code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); + char* endPtr = NULL; + int64_t v = strtoll(pItem->z, &endPtr, 10); + *(int32_t*) tagVal = v; +// code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); // check again after the convert since it may be converted from binary to nchar. if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { @@ -469,33 +474,37 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p if (row == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } - tdSortKVRowByColIdx(row); - pTag->dataLen = kvRowLen(row); - if (pTag->data == NULL) { - pTag->data = malloc(pTag->dataLen); + tdSortKVRowByColIdx(row); + + SName tableName = {0}; + code = createSName(&tableName, &pCreateTableInfo->name, pCtx, pMsgBuf); + if (code != TSDB_CODE_SUCCESS) { + return code; } - kvRowCpy(pTag->data, row); - free(row); + struct SVCreateTbReq req = {0}; + req.type = TD_CHILD_TABLE; + req.name = strdup(tNameGetTableName(&tableName)); + req.ctbCfg.suid = pSuperTableMeta->suid; + req.ctbCfg.pTag = row; - bool dbIncluded2 = false; - // table name -// if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) { -// return buildInvalidOperationMsg(pMsgBuf, msg1); -// } + int32_t serLen = tSerializeSVCreateTbReq(NULL, &req); + char* buf1 = calloc(1, serLen); + char* p = buf1; + tSerializeSVCreateTbReq((void*) &buf1, &req); + *pOutput = p; + *len = serLen; -// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX); -// code = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2); -// if (code != TSDB_CODE_SUCCESS) { -// return code; -// } + SVgroupInfo info = {0}; + catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, req.name, &info); -// pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1); -// code = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname); -// if (code != TSDB_CODE_SUCCESS) { -// return buildInvalidOperationMsg(pMsgBuf, msg1); -// } + pEpSet->inUse = info.inUse; + pEpSet->numOfEps = info.numOfEps; + for(int32_t i = 0; i < pEpSet->numOfEps; ++i) { + pEpSet->port[i] = info.epAddr[i].port; + tstrncpy(pEpSet->fqdn[i], info.epAddr[i].fqdn, tListLen(pEpSet->fqdn[i])); + } } return TSDB_CODE_SUCCESS; @@ -692,10 +701,11 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf); pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TDMT_VND_CREATE_TABLE:TDMT_MND_CREATE_STB; } else if (pCreateTable->type == TSQL_CREATE_CTABLE) { - if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf)) != TSDB_CODE_SUCCESS) { + if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf, &pDcl->pMsg, &pDcl->msgLen, &pDcl->epSet)) != TSDB_CODE_SUCCESS) { return code; } + pDcl->msgType = TDMT_VND_CREATE_TABLE; } else if (pCreateTable->type == TSQL_CREATE_STREAM) { // if ((code = doCheckForStream(pSql, pInfo)) != TSDB_CODE_SUCCESS) { // return code; diff --git a/source/libs/parser/src/queryInfoUtil.c b/source/libs/parser/src/queryInfoUtil.c index 1ae0d9211a..d7aa758576 100644 --- a/source/libs/parser/src/queryInfoUtil.c +++ b/source/libs/parser/src/queryInfoUtil.c @@ -26,7 +26,7 @@ size_t getNumOfExprs(SQueryStmtInfo* pQueryInfo) { } SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) { - assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < getNumOfColumns(pTableMeta)); + assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 && colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta))); SSchema* pSchema = (SSchema*) pTableMeta->schema; return &pSchema[colIndex]; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index ac90b3b34a..d091751a56 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -97,30 +97,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 279 +#define YYNOCODE 273 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SRelationInfo* yy8; - SWindowStateVal yy40; - SSqlNode* yy56; - SVariant yy69; - SCreateDbInfo yy90; - int yy96; - SField yy100; - int32_t yy104; - SSessionWindowVal yy147; - SSubclause* yy149; - SCreatedTableInfo yy152; + SSqlNode* yy24; + int yy60; + SSubclause* yy129; + SIntervalVal yy136; + int64_t yy157; SCreateAcctInfo yy171; - SLimit yy231; - int64_t yy325; - SIntervalVal yy400; - SArray* yy421; + SSessionWindowVal yy251; + SCreateDbInfo yy254; + SWindowStateVal yy256; + SField yy280; + SRelationInfo* yy292; + tSqlExpr* yy370; + SArray* yy413; SCreateTableSql* yy438; - tSqlExpr* yy439; + SVariant yy461; + SLimit yy503; + int32_t yy516; + SCreatedTableInfo yy544; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,7 +132,7 @@ typedef union { #define YYFALLBACK 1 #define YYNSTATE 365 #define YYNRULE 301 -#define YYNTOKEN 197 +#define YYNTOKEN 191 #define YY_MAX_SHIFT 364 #define YY_MIN_SHIFTREDUCE 584 #define YY_MAX_SHIFTREDUCE 884 @@ -206,255 +206,253 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (783) +#define YY_ACTTAB_COUNT (779) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 96, 635, 249, 21, 635, 203, 248, 714, 206, 636, - /* 10 */ 363, 230, 636, 55, 56, 1073, 59, 60, 1024, 1164, - /* 20 */ 252, 49, 48, 47, 671, 58, 322, 63, 61, 64, - /* 30 */ 62, 1021, 1022, 33, 1025, 54, 53, 342, 341, 52, - /* 40 */ 51, 50, 55, 56, 261, 59, 60, 236, 1050, 252, - /* 50 */ 49, 48, 47, 176, 58, 322, 63, 61, 64, 62, - /* 60 */ 155, 827, 206, 830, 54, 53, 206, 204, 52, 51, - /* 70 */ 50, 55, 56, 1165, 59, 60, 99, 1165, 252, 49, - /* 80 */ 48, 47, 1070, 58, 322, 63, 61, 64, 62, 162, - /* 90 */ 81, 36, 635, 54, 53, 318, 162, 52, 51, 50, - /* 100 */ 636, 54, 53, 162, 318, 52, 51, 50, 55, 57, - /* 110 */ 1026, 59, 60, 253, 821, 252, 49, 48, 47, 635, - /* 120 */ 58, 322, 63, 61, 64, 62, 936, 636, 280, 279, - /* 130 */ 54, 53, 188, 232, 52, 51, 50, 1035, 585, 586, + /* 0 */ 1073, 635, 155, 363, 230, 636, 671, 55, 56, 635, + /* 10 */ 59, 60, 1032, 636, 252, 49, 48, 47, 162, 58, + /* 20 */ 322, 63, 61, 64, 62, 236, 1050, 242, 206, 54, + /* 30 */ 53, 1038, 635, 52, 51, 50, 636, 55, 56, 1164, + /* 40 */ 59, 60, 936, 1063, 252, 49, 48, 47, 188, 58, + /* 50 */ 322, 63, 61, 64, 62, 1010, 243, 1008, 1009, 54, + /* 60 */ 53, 233, 1011, 52, 51, 50, 1012, 1070, 1013, 1014, + /* 70 */ 280, 279, 947, 55, 56, 246, 59, 60, 188, 1038, + /* 80 */ 252, 49, 48, 47, 81, 58, 322, 63, 61, 64, + /* 90 */ 62, 320, 1112, 99, 292, 54, 53, 352, 635, 52, + /* 100 */ 51, 50, 636, 55, 57, 261, 59, 60, 318, 821, + /* 110 */ 252, 49, 48, 47, 176, 58, 322, 63, 61, 64, + /* 120 */ 62, 42, 249, 358, 357, 54, 53, 1026, 356, 52, + /* 130 */ 51, 50, 355, 87, 354, 353, 886, 364, 585, 586, /* 140 */ 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, - /* 150 */ 597, 598, 153, 56, 231, 59, 60, 162, 74, 252, - /* 160 */ 49, 48, 47, 1111, 58, 322, 63, 61, 64, 62, - /* 170 */ 1112, 1063, 292, 206, 54, 53, 255, 93, 52, 51, - /* 180 */ 50, 59, 60, 834, 1165, 252, 49, 48, 47, 233, - /* 190 */ 58, 322, 63, 61, 64, 62, 42, 75, 358, 357, - /* 200 */ 54, 53, 27, 356, 52, 51, 50, 355, 250, 354, - /* 210 */ 353, 42, 316, 358, 357, 315, 314, 313, 356, 312, - /* 220 */ 311, 310, 355, 309, 354, 353, 886, 364, 352, 294, - /* 230 */ 4, 92, 1004, 992, 993, 994, 995, 996, 997, 998, - /* 240 */ 999, 1000, 1001, 1002, 1003, 1005, 1006, 22, 251, 836, - /* 250 */ 87, 260, 825, 256, 828, 254, 831, 330, 329, 947, - /* 260 */ 635, 52, 51, 50, 215, 188, 251, 836, 636, 36, - /* 270 */ 825, 216, 828, 1063, 831, 786, 787, 137, 136, 135, - /* 280 */ 217, 209, 228, 229, 327, 87, 323, 1063, 43, 210, - /* 290 */ 86, 274, 36, 36, 63, 61, 64, 62, 36, 87, - /* 300 */ 228, 229, 54, 53, 211, 234, 52, 51, 50, 750, - /* 310 */ 36, 240, 747, 36, 748, 1035, 749, 742, 1159, 826, - /* 320 */ 739, 829, 740, 43, 741, 362, 361, 146, 262, 1032, - /* 330 */ 259, 65, 337, 336, 241, 331, 36, 43, 1035, 1035, - /* 340 */ 332, 36, 257, 258, 1035, 273, 1158, 79, 320, 65, - /* 350 */ 244, 245, 333, 36, 224, 334, 1035, 1049, 12, 1035, - /* 360 */ 1184, 3, 39, 178, 95, 1157, 266, 837, 832, 105, - /* 370 */ 77, 101, 108, 243, 833, 270, 269, 1010, 338, 1008, - /* 380 */ 1009, 767, 1035, 339, 1011, 837, 832, 1035, 1012, 305, - /* 390 */ 1013, 1014, 833, 98, 803, 340, 197, 195, 193, 1035, - /* 400 */ 36, 226, 36, 192, 141, 140, 139, 138, 122, 116, - /* 410 */ 126, 242, 152, 150, 149, 1038, 246, 131, 134, 125, - /* 420 */ 1038, 80, 171, 261, 261, 124, 128, 751, 752, 94, - /* 430 */ 764, 937, 177, 1036, 84, 743, 744, 188, 275, 352, - /* 440 */ 282, 835, 344, 82, 85, 783, 1035, 793, 1034, 794, - /* 450 */ 359, 974, 802, 1023, 37, 7, 71, 724, 297, 726, - /* 460 */ 299, 157, 737, 66, 738, 24, 735, 771, 736, 725, - /* 470 */ 32, 823, 70, 37, 37, 67, 97, 859, 838, 324, - /* 480 */ 634, 14, 70, 13, 115, 67, 114, 16, 755, 15, - /* 490 */ 756, 78, 1037, 23, 23, 227, 23, 72, 18, 753, - /* 500 */ 17, 754, 133, 132, 300, 121, 207, 120, 208, 824, - /* 510 */ 212, 20, 205, 19, 213, 214, 219, 220, 221, 218, - /* 520 */ 202, 1176, 1065, 1122, 713, 1121, 238, 1118, 1117, 239, - /* 530 */ 321, 343, 1064, 44, 271, 154, 1104, 1072, 1083, 1103, - /* 540 */ 1080, 1081, 151, 277, 172, 1033, 1085, 156, 281, 235, - /* 550 */ 283, 161, 288, 285, 173, 165, 1031, 1061, 174, 164, - /* 560 */ 782, 175, 163, 166, 168, 951, 302, 303, 304, 307, - /* 570 */ 308, 200, 295, 291, 293, 76, 40, 319, 946, 945, - /* 580 */ 328, 1183, 112, 1182, 840, 1179, 73, 179, 335, 1175, - /* 590 */ 118, 1174, 46, 289, 1171, 287, 180, 971, 41, 38, - /* 600 */ 201, 934, 127, 932, 129, 130, 930, 284, 929, 263, - /* 610 */ 190, 191, 926, 925, 924, 923, 922, 921, 920, 194, - /* 620 */ 196, 917, 45, 915, 913, 911, 198, 908, 199, 904, - /* 630 */ 306, 123, 276, 83, 88, 345, 286, 1105, 346, 347, - /* 640 */ 348, 349, 350, 351, 360, 884, 225, 264, 247, 301, - /* 650 */ 265, 883, 267, 222, 223, 268, 882, 106, 950, 949, - /* 660 */ 865, 272, 864, 70, 296, 8, 278, 758, 89, 183, - /* 670 */ 928, 927, 972, 181, 186, 182, 184, 185, 187, 142, - /* 680 */ 143, 144, 28, 919, 918, 784, 158, 145, 973, 910, - /* 690 */ 909, 795, 159, 1, 31, 169, 167, 170, 789, 2, + /* 150 */ 597, 598, 153, 56, 231, 59, 60, 767, 1063, 252, + /* 160 */ 49, 48, 47, 171, 58, 322, 63, 61, 64, 62, + /* 170 */ 162, 43, 1024, 86, 54, 53, 234, 21, 52, 51, + /* 180 */ 50, 282, 206, 1063, 635, 59, 60, 203, 636, 252, + /* 190 */ 49, 48, 47, 1165, 58, 322, 63, 61, 64, 62, + /* 200 */ 162, 274, 827, 830, 54, 53, 786, 787, 52, 51, + /* 210 */ 50, 36, 42, 316, 358, 357, 315, 314, 313, 356, + /* 220 */ 312, 311, 310, 355, 309, 354, 353, 1004, 992, 993, + /* 230 */ 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, + /* 240 */ 1005, 1006, 294, 771, 92, 22, 63, 61, 64, 62, + /* 250 */ 826, 829, 318, 232, 54, 53, 204, 1035, 52, 51, + /* 260 */ 50, 27, 215, 36, 251, 836, 825, 828, 831, 216, + /* 270 */ 750, 747, 748, 749, 1111, 137, 136, 135, 217, 162, + /* 280 */ 266, 255, 327, 87, 251, 836, 825, 828, 831, 270, + /* 290 */ 269, 96, 228, 229, 261, 261, 323, 257, 258, 742, + /* 300 */ 739, 740, 741, 177, 1036, 240, 3, 39, 178, 1035, + /* 310 */ 260, 209, 228, 229, 105, 77, 101, 108, 250, 248, + /* 320 */ 834, 43, 1021, 1022, 33, 1025, 244, 245, 197, 195, + /* 330 */ 193, 52, 51, 50, 305, 192, 141, 140, 139, 138, + /* 340 */ 4, 65, 253, 273, 80, 79, 122, 116, 126, 152, + /* 350 */ 150, 149, 224, 93, 36, 131, 134, 125, 256, 36, + /* 360 */ 254, 65, 330, 329, 128, 54, 53, 714, 835, 52, + /* 370 */ 51, 50, 87, 36, 36, 36, 1023, 837, 832, 206, + /* 380 */ 36, 36, 751, 752, 833, 36, 36, 262, 36, 259, + /* 390 */ 1165, 337, 336, 342, 341, 803, 241, 837, 832, 764, + /* 400 */ 1035, 331, 206, 12, 833, 1035, 84, 85, 937, 95, + /* 410 */ 43, 743, 744, 1165, 188, 332, 333, 334, 324, 1035, + /* 420 */ 1035, 1035, 338, 339, 7, 124, 1035, 1035, 340, 94, + /* 430 */ 344, 1034, 1035, 275, 1035, 362, 361, 146, 98, 352, + /* 440 */ 359, 974, 783, 82, 70, 70, 793, 794, 71, 37, + /* 450 */ 724, 74, 297, 802, 726, 299, 737, 738, 157, 735, + /* 460 */ 736, 725, 66, 24, 32, 823, 37, 859, 37, 838, + /* 470 */ 67, 97, 634, 14, 115, 13, 114, 67, 78, 16, + /* 480 */ 18, 15, 17, 23, 121, 23, 120, 210, 23, 72, + /* 490 */ 75, 211, 755, 756, 753, 754, 1159, 824, 300, 20, + /* 500 */ 1158, 19, 133, 132, 1157, 226, 1037, 1049, 1065, 227, + /* 510 */ 207, 713, 208, 212, 205, 213, 214, 219, 220, 221, + /* 520 */ 218, 202, 1184, 840, 1176, 44, 1122, 1121, 321, 271, + /* 530 */ 238, 1118, 1117, 239, 343, 154, 1104, 1072, 1083, 1080, + /* 540 */ 1081, 1085, 156, 161, 1064, 277, 288, 1103, 1033, 173, + /* 550 */ 151, 281, 172, 1031, 174, 175, 951, 782, 306, 302, + /* 560 */ 303, 170, 164, 304, 307, 163, 308, 1061, 295, 291, + /* 570 */ 165, 200, 40, 319, 946, 945, 235, 328, 1183, 112, + /* 580 */ 283, 1182, 285, 1179, 76, 179, 335, 73, 1175, 118, + /* 590 */ 1174, 1171, 180, 971, 46, 41, 38, 201, 934, 127, + /* 600 */ 932, 129, 130, 293, 930, 929, 263, 190, 191, 926, + /* 610 */ 925, 924, 923, 922, 921, 920, 194, 196, 917, 915, + /* 620 */ 913, 911, 289, 198, 908, 199, 904, 287, 284, 276, + /* 630 */ 83, 88, 45, 286, 1105, 123, 345, 346, 347, 348, + /* 640 */ 349, 225, 350, 247, 301, 351, 360, 884, 264, 265, + /* 650 */ 883, 222, 267, 950, 949, 106, 223, 268, 882, 865, + /* 660 */ 864, 272, 70, 8, 928, 296, 927, 758, 183, 182, + /* 670 */ 972, 181, 142, 184, 185, 187, 186, 143, 919, 918, + /* 680 */ 973, 144, 145, 910, 909, 28, 278, 89, 31, 784, + /* 690 */ 2, 166, 167, 158, 168, 169, 795, 159, 1, 789, /* 700 */ 160, 90, 237, 791, 91, 290, 29, 9, 30, 10, - /* 710 */ 11, 25, 298, 26, 98, 100, 34, 649, 102, 103, + /* 710 */ 11, 25, 298, 26, 98, 100, 34, 103, 102, 649, /* 720 */ 684, 35, 104, 682, 681, 680, 678, 677, 676, 673, - /* 730 */ 639, 317, 107, 325, 841, 326, 109, 110, 5, 111, - /* 740 */ 839, 6, 68, 113, 69, 37, 117, 119, 716, 715, + /* 730 */ 639, 107, 109, 325, 110, 839, 317, 5, 6, 841, + /* 740 */ 326, 68, 111, 113, 69, 716, 117, 119, 37, 715, /* 750 */ 712, 665, 663, 655, 661, 657, 659, 653, 651, 686, - /* 760 */ 685, 683, 679, 675, 674, 189, 637, 602, 888, 887, - /* 770 */ 887, 887, 887, 887, 887, 887, 887, 887, 887, 887, - /* 780 */ 887, 147, 148, + /* 760 */ 685, 683, 679, 675, 674, 189, 602, 637, 888, 887, + /* 770 */ 887, 887, 887, 887, 887, 887, 887, 147, 148, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 207, 1, 206, 266, 1, 266, 206, 5, 266, 9, - /* 10 */ 200, 201, 9, 13, 14, 200, 16, 17, 0, 277, - /* 20 */ 20, 21, 22, 23, 5, 25, 26, 27, 28, 29, - /* 30 */ 30, 238, 239, 240, 241, 35, 36, 35, 36, 39, - /* 40 */ 40, 41, 13, 14, 200, 16, 17, 248, 249, 20, - /* 50 */ 21, 22, 23, 209, 25, 26, 27, 28, 29, 30, - /* 60 */ 200, 5, 266, 7, 35, 36, 266, 266, 39, 40, - /* 70 */ 41, 13, 14, 277, 16, 17, 207, 277, 20, 21, - /* 80 */ 22, 23, 267, 25, 26, 27, 28, 29, 30, 200, - /* 90 */ 90, 200, 1, 35, 36, 86, 200, 39, 40, 41, - /* 100 */ 9, 35, 36, 200, 86, 39, 40, 41, 13, 14, - /* 110 */ 241, 16, 17, 206, 85, 20, 21, 22, 23, 1, - /* 120 */ 25, 26, 27, 28, 29, 30, 205, 9, 268, 269, - /* 130 */ 35, 36, 211, 242, 39, 40, 41, 246, 47, 48, - /* 140 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - /* 150 */ 59, 60, 61, 14, 63, 16, 17, 200, 101, 20, - /* 160 */ 21, 22, 23, 274, 25, 26, 27, 28, 29, 30, - /* 170 */ 274, 245, 276, 266, 35, 36, 70, 274, 39, 40, - /* 180 */ 41, 16, 17, 127, 277, 20, 21, 22, 23, 263, - /* 190 */ 25, 26, 27, 28, 29, 30, 102, 140, 104, 105, - /* 200 */ 35, 36, 84, 109, 39, 40, 41, 113, 62, 115, - /* 210 */ 116, 102, 103, 104, 105, 106, 107, 108, 109, 110, - /* 220 */ 111, 112, 113, 114, 115, 116, 198, 199, 94, 272, - /* 230 */ 84, 274, 222, 223, 224, 225, 226, 227, 228, 229, - /* 240 */ 230, 231, 232, 233, 234, 235, 236, 46, 1, 2, - /* 250 */ 84, 70, 5, 147, 7, 149, 9, 151, 152, 205, - /* 260 */ 1, 39, 40, 41, 63, 211, 1, 2, 9, 200, - /* 270 */ 5, 70, 7, 245, 9, 128, 129, 76, 77, 78, - /* 280 */ 79, 266, 35, 36, 83, 84, 39, 245, 122, 266, - /* 290 */ 124, 263, 200, 200, 27, 28, 29, 30, 200, 84, - /* 300 */ 35, 36, 35, 36, 266, 263, 39, 40, 41, 2, - /* 310 */ 200, 242, 5, 200, 7, 246, 9, 2, 266, 5, - /* 320 */ 5, 7, 7, 122, 9, 67, 68, 69, 147, 200, - /* 330 */ 149, 84, 151, 152, 242, 242, 200, 122, 246, 246, - /* 340 */ 242, 200, 35, 36, 246, 144, 266, 146, 89, 84, - /* 350 */ 35, 36, 242, 200, 153, 242, 246, 249, 84, 246, - /* 360 */ 249, 64, 65, 66, 90, 266, 145, 120, 121, 72, - /* 370 */ 73, 74, 75, 244, 127, 154, 155, 222, 242, 224, - /* 380 */ 225, 39, 246, 242, 229, 120, 121, 246, 233, 92, - /* 390 */ 235, 236, 127, 119, 78, 242, 64, 65, 66, 246, - /* 400 */ 200, 266, 200, 71, 72, 73, 74, 75, 64, 65, - /* 410 */ 66, 243, 64, 65, 66, 247, 243, 73, 74, 75, - /* 420 */ 247, 207, 253, 200, 200, 80, 82, 120, 121, 250, - /* 430 */ 101, 205, 209, 209, 85, 120, 121, 211, 85, 94, - /* 440 */ 271, 127, 242, 264, 85, 85, 246, 85, 246, 85, - /* 450 */ 220, 221, 136, 239, 101, 126, 101, 85, 85, 85, - /* 460 */ 85, 101, 5, 101, 7, 101, 5, 125, 7, 85, - /* 470 */ 84, 1, 123, 101, 101, 101, 101, 85, 85, 15, - /* 480 */ 85, 148, 123, 150, 148, 101, 150, 148, 5, 150, - /* 490 */ 7, 84, 247, 101, 101, 266, 101, 142, 148, 5, - /* 500 */ 150, 7, 80, 81, 118, 148, 266, 150, 266, 39, - /* 510 */ 266, 148, 266, 150, 266, 266, 266, 266, 266, 266, - /* 520 */ 266, 249, 245, 237, 117, 237, 237, 237, 237, 237, - /* 530 */ 200, 237, 245, 265, 200, 200, 275, 200, 200, 275, - /* 540 */ 200, 200, 62, 245, 251, 245, 200, 200, 270, 270, - /* 550 */ 270, 200, 200, 270, 200, 259, 200, 262, 200, 260, - /* 560 */ 127, 200, 261, 258, 256, 200, 200, 200, 200, 200, - /* 570 */ 200, 200, 134, 132, 137, 139, 200, 200, 200, 200, - /* 580 */ 200, 200, 200, 200, 120, 200, 141, 200, 200, 200, - /* 590 */ 200, 200, 138, 131, 200, 130, 200, 200, 200, 200, - /* 600 */ 200, 200, 200, 200, 200, 200, 200, 133, 200, 200, - /* 610 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - /* 620 */ 200, 200, 143, 200, 200, 200, 200, 200, 200, 200, - /* 630 */ 93, 100, 202, 202, 202, 99, 202, 202, 53, 96, - /* 640 */ 98, 57, 97, 95, 86, 5, 202, 156, 202, 202, - /* 650 */ 5, 5, 156, 202, 202, 5, 5, 207, 210, 210, - /* 660 */ 104, 145, 103, 123, 118, 84, 101, 85, 101, 213, - /* 670 */ 202, 202, 219, 218, 215, 217, 216, 214, 212, 203, - /* 680 */ 203, 203, 84, 202, 202, 85, 84, 203, 221, 202, - /* 690 */ 202, 85, 84, 208, 252, 255, 257, 254, 85, 204, - /* 700 */ 101, 84, 1, 85, 84, 84, 101, 135, 101, 135, - /* 710 */ 84, 84, 118, 84, 119, 80, 91, 5, 90, 72, - /* 720 */ 9, 91, 90, 5, 5, 5, 5, 5, 5, 5, - /* 730 */ 87, 15, 80, 26, 120, 61, 88, 88, 84, 150, - /* 740 */ 85, 84, 16, 150, 16, 101, 150, 150, 5, 5, - /* 750 */ 85, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 760 */ 5, 5, 5, 5, 5, 101, 87, 62, 0, 278, - /* 770 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 780 */ 278, 21, 21, 278, 278, 278, 278, 278, 278, 278, - /* 790 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 800 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 810 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 820 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 830 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 840 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 850 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 860 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 870 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 880 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 890 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 900 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 910 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 920 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 930 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 940 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 950 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 960 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - /* 970 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, + /* 0 */ 194, 1, 194, 194, 195, 5, 3, 7, 8, 1, + /* 10 */ 10, 11, 194, 5, 14, 15, 16, 17, 194, 19, + /* 20 */ 20, 21, 22, 23, 24, 242, 243, 237, 260, 29, + /* 30 */ 30, 241, 1, 33, 34, 35, 5, 7, 8, 271, + /* 40 */ 10, 11, 199, 239, 14, 15, 16, 17, 205, 19, + /* 50 */ 20, 21, 22, 23, 24, 216, 238, 218, 219, 29, + /* 60 */ 30, 257, 223, 33, 34, 35, 227, 261, 229, 230, + /* 70 */ 262, 263, 199, 7, 8, 237, 10, 11, 205, 241, + /* 80 */ 14, 15, 16, 17, 84, 19, 20, 21, 22, 23, + /* 90 */ 24, 83, 268, 201, 270, 29, 30, 88, 1, 33, + /* 100 */ 34, 35, 5, 7, 8, 194, 10, 11, 80, 79, + /* 110 */ 14, 15, 16, 17, 203, 19, 20, 21, 22, 23, + /* 120 */ 24, 96, 200, 98, 99, 29, 30, 235, 103, 33, + /* 130 */ 34, 35, 107, 78, 109, 110, 192, 193, 41, 42, + /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + /* 150 */ 53, 54, 55, 8, 57, 10, 11, 33, 239, 14, + /* 160 */ 15, 16, 17, 247, 19, 20, 21, 22, 23, 24, + /* 170 */ 194, 116, 0, 118, 29, 30, 257, 260, 33, 34, + /* 180 */ 35, 265, 260, 239, 1, 10, 11, 260, 5, 14, + /* 190 */ 15, 16, 17, 271, 19, 20, 21, 22, 23, 24, + /* 200 */ 194, 257, 3, 4, 29, 30, 122, 123, 33, 34, + /* 210 */ 35, 194, 96, 97, 98, 99, 100, 101, 102, 103, + /* 220 */ 104, 105, 106, 107, 108, 109, 110, 216, 217, 218, + /* 230 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + /* 240 */ 229, 230, 266, 119, 268, 40, 21, 22, 23, 24, + /* 250 */ 3, 4, 80, 236, 29, 30, 260, 240, 33, 34, + /* 260 */ 35, 78, 57, 194, 1, 2, 3, 4, 5, 64, + /* 270 */ 2, 3, 4, 5, 268, 70, 71, 72, 73, 194, + /* 280 */ 139, 64, 77, 78, 1, 2, 3, 4, 5, 148, + /* 290 */ 149, 201, 29, 30, 194, 194, 33, 29, 30, 2, + /* 300 */ 3, 4, 5, 203, 203, 236, 58, 59, 60, 240, + /* 310 */ 64, 260, 29, 30, 66, 67, 68, 69, 56, 200, + /* 320 */ 121, 116, 232, 233, 234, 235, 29, 30, 58, 59, + /* 330 */ 60, 33, 34, 35, 86, 65, 66, 67, 68, 69, + /* 340 */ 78, 78, 200, 138, 201, 140, 58, 59, 60, 58, + /* 350 */ 59, 60, 147, 268, 194, 67, 68, 69, 141, 194, + /* 360 */ 143, 78, 145, 146, 76, 29, 30, 3, 121, 33, + /* 370 */ 34, 35, 78, 194, 194, 194, 233, 114, 115, 260, + /* 380 */ 194, 194, 114, 115, 121, 194, 194, 141, 194, 143, + /* 390 */ 271, 145, 146, 29, 30, 72, 236, 114, 115, 95, + /* 400 */ 240, 236, 260, 78, 121, 240, 79, 79, 199, 84, + /* 410 */ 116, 114, 115, 271, 205, 236, 236, 236, 9, 240, + /* 420 */ 240, 240, 236, 236, 120, 74, 240, 240, 236, 244, + /* 430 */ 236, 240, 240, 79, 240, 61, 62, 63, 113, 88, + /* 440 */ 214, 215, 79, 258, 117, 117, 79, 79, 95, 95, + /* 450 */ 79, 95, 79, 130, 79, 79, 3, 4, 95, 3, + /* 460 */ 4, 79, 95, 95, 78, 1, 95, 79, 95, 79, + /* 470 */ 95, 95, 79, 142, 142, 144, 144, 95, 78, 142, + /* 480 */ 142, 144, 144, 95, 142, 95, 144, 260, 95, 136, + /* 490 */ 134, 260, 3, 4, 3, 4, 260, 33, 112, 142, + /* 500 */ 260, 144, 74, 75, 260, 260, 241, 243, 239, 260, + /* 510 */ 260, 111, 260, 260, 260, 260, 260, 260, 260, 260, + /* 520 */ 260, 260, 243, 114, 243, 259, 231, 231, 194, 194, + /* 530 */ 231, 231, 231, 231, 231, 194, 269, 194, 194, 194, + /* 540 */ 194, 194, 194, 194, 239, 239, 194, 269, 239, 194, + /* 550 */ 56, 264, 245, 194, 194, 194, 194, 121, 87, 194, + /* 560 */ 194, 248, 254, 194, 194, 255, 194, 256, 128, 126, + /* 570 */ 253, 194, 194, 194, 194, 194, 264, 194, 194, 194, + /* 580 */ 264, 194, 264, 194, 133, 194, 194, 135, 194, 194, + /* 590 */ 194, 194, 194, 194, 132, 194, 194, 194, 194, 194, + /* 600 */ 194, 194, 194, 131, 194, 194, 194, 194, 194, 194, + /* 610 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + /* 620 */ 194, 194, 125, 194, 194, 194, 194, 124, 127, 196, + /* 630 */ 196, 196, 137, 196, 196, 94, 93, 47, 90, 92, + /* 640 */ 51, 196, 91, 196, 196, 89, 80, 3, 150, 3, + /* 650 */ 3, 196, 150, 204, 204, 201, 196, 3, 3, 98, + /* 660 */ 97, 139, 117, 78, 196, 112, 196, 79, 207, 211, + /* 670 */ 213, 212, 197, 210, 208, 206, 209, 197, 196, 196, + /* 680 */ 215, 197, 197, 196, 196, 78, 95, 95, 246, 79, + /* 690 */ 198, 252, 251, 78, 250, 249, 79, 78, 202, 79, + /* 700 */ 95, 78, 1, 79, 78, 78, 95, 129, 95, 129, + /* 710 */ 78, 78, 112, 78, 113, 74, 85, 66, 84, 3, + /* 720 */ 5, 85, 84, 3, 3, 3, 3, 3, 3, 3, + /* 730 */ 81, 74, 82, 20, 82, 79, 9, 78, 78, 114, + /* 740 */ 55, 10, 144, 144, 10, 3, 144, 144, 95, 3, + /* 750 */ 79, 3, 3, 3, 3, 3, 3, 3, 3, 3, + /* 760 */ 3, 3, 3, 3, 3, 95, 56, 81, 0, 272, + /* 770 */ 272, 272, 272, 272, 272, 272, 272, 15, 15, 272, + /* 780 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 790 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 800 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 810 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 820 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 830 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 840 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 850 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 860 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 870 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 880 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 890 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 900 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 910 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 920 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 930 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 940 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 950 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 960 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, }; #define YY_SHIFT_COUNT (364) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (768) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 201, 109, 94, 9, 247, 265, 265, 118, 3, 3, - /* 10 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 20 */ 3, 0, 91, 265, 307, 315, 315, 215, 215, 3, - /* 30 */ 3, 147, 3, 18, 3, 3, 3, 3, 345, 9, - /* 40 */ 134, 134, 19, 783, 265, 265, 265, 265, 265, 265, - /* 50 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 265, - /* 60 */ 265, 265, 265, 265, 265, 265, 307, 315, 307, 307, - /* 70 */ 166, 2, 2, 2, 2, 2, 2, 259, 2, 3, - /* 80 */ 3, 3, 342, 3, 3, 3, 215, 215, 3, 3, - /* 90 */ 3, 3, 316, 316, 329, 215, 3, 3, 3, 3, - /* 100 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 110 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 120 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 130 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 140 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 150 */ 3, 3, 3, 3, 480, 480, 480, 433, 433, 433, - /* 160 */ 433, 480, 480, 436, 445, 438, 454, 437, 441, 462, - /* 170 */ 465, 474, 479, 480, 480, 480, 537, 537, 9, 480, - /* 180 */ 480, 531, 536, 585, 543, 542, 584, 545, 548, 19, - /* 190 */ 480, 480, 558, 558, 480, 558, 480, 558, 480, 480, - /* 200 */ 783, 783, 29, 58, 58, 95, 58, 139, 165, 267, - /* 210 */ 267, 267, 267, 267, 267, 297, 332, 344, 66, 66, - /* 220 */ 66, 66, 106, 181, 221, 274, 222, 222, 56, 314, - /* 230 */ 258, 348, 353, 349, 359, 360, 362, 364, 355, 57, - /* 240 */ 372, 373, 374, 375, 457, 461, 384, 386, 392, 393, - /* 250 */ 470, 146, 464, 395, 333, 336, 339, 483, 494, 350, - /* 260 */ 357, 407, 363, 422, 640, 491, 645, 646, 496, 650, - /* 270 */ 651, 556, 559, 516, 540, 546, 581, 582, 598, 565, - /* 280 */ 567, 600, 602, 606, 608, 613, 599, 617, 618, 620, - /* 290 */ 701, 621, 605, 572, 607, 574, 626, 546, 627, 594, - /* 300 */ 629, 595, 635, 625, 628, 647, 712, 630, 632, 711, - /* 310 */ 718, 719, 720, 721, 722, 723, 724, 643, 716, 652, - /* 320 */ 648, 649, 654, 655, 614, 657, 707, 674, 726, 589, - /* 330 */ 593, 644, 644, 644, 644, 728, 596, 597, 644, 644, - /* 340 */ 644, 743, 744, 665, 644, 746, 747, 748, 749, 750, - /* 350 */ 751, 752, 753, 754, 755, 756, 757, 758, 759, 664, - /* 360 */ 679, 760, 761, 705, 768, + /* 0 */ 205, 116, 25, 28, 263, 283, 283, 183, 31, 31, + /* 10 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 20 */ 31, 0, 97, 283, 268, 297, 297, 294, 294, 31, + /* 30 */ 31, 84, 31, 172, 31, 31, 31, 31, 351, 28, + /* 40 */ 9, 9, 3, 779, 283, 283, 283, 283, 283, 283, + /* 50 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, + /* 60 */ 283, 283, 283, 283, 283, 283, 268, 297, 268, 268, + /* 70 */ 55, 364, 364, 364, 364, 364, 364, 8, 364, 31, + /* 80 */ 31, 31, 124, 31, 31, 31, 294, 294, 31, 31, + /* 90 */ 31, 31, 323, 323, 304, 294, 31, 31, 31, 31, + /* 100 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 110 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 120 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 130 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 140 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + /* 150 */ 31, 31, 31, 31, 494, 494, 494, 436, 436, 436, + /* 160 */ 436, 494, 494, 451, 452, 440, 462, 472, 443, 497, + /* 170 */ 503, 501, 495, 494, 494, 494, 471, 471, 28, 494, + /* 180 */ 494, 541, 543, 590, 548, 547, 589, 551, 556, 3, + /* 190 */ 494, 494, 566, 566, 494, 566, 494, 566, 494, 494, + /* 200 */ 779, 779, 30, 66, 66, 96, 66, 145, 175, 225, + /* 210 */ 225, 225, 225, 225, 225, 248, 270, 288, 336, 336, + /* 220 */ 336, 336, 217, 246, 141, 325, 298, 298, 199, 247, + /* 230 */ 374, 291, 354, 327, 328, 363, 367, 368, 353, 356, + /* 240 */ 371, 373, 375, 376, 453, 456, 382, 386, 388, 390, + /* 250 */ 464, 262, 409, 393, 331, 332, 337, 489, 491, 338, + /* 260 */ 342, 400, 357, 428, 644, 498, 646, 647, 502, 654, + /* 270 */ 655, 561, 563, 522, 545, 553, 585, 588, 607, 591, + /* 280 */ 592, 610, 615, 617, 619, 620, 605, 623, 624, 626, + /* 290 */ 701, 627, 611, 578, 613, 580, 632, 553, 633, 600, + /* 300 */ 635, 601, 641, 631, 634, 651, 716, 636, 638, 715, + /* 310 */ 720, 721, 722, 723, 724, 725, 726, 649, 727, 657, + /* 320 */ 650, 652, 659, 656, 625, 660, 713, 685, 731, 598, + /* 330 */ 599, 653, 653, 653, 653, 734, 602, 603, 653, 653, + /* 340 */ 653, 742, 746, 671, 653, 748, 749, 750, 751, 752, + /* 350 */ 753, 754, 755, 756, 757, 758, 759, 760, 761, 670, + /* 360 */ 686, 762, 763, 710, 768, }; #define YY_REDUCE_COUNT (201) -#define YY_REDUCE_MIN (-263) -#define YY_REDUCE_MAX (495) +#define YY_REDUCE_MIN (-232) +#define YY_REDUCE_MAX (496) static const short yy_reduce_ofst[] = { - /* 0 */ 28, 10, 155, -207, -204, -200, -93, -140, -109, -104, - /* 10 */ -43, 69, 92, 93, 98, 110, 113, 136, 141, 153, - /* 20 */ 200, -185, -190, -258, -201, 168, 173, -74, 42, -111, - /* 30 */ -97, 169, 129, -131, -156, 223, 224, 202, -79, 214, - /* 40 */ 54, 226, 230, 179, -263, -261, -199, 15, 23, 38, - /* 50 */ 52, 80, 99, 135, 229, 240, 242, 244, 246, 248, - /* 60 */ 249, 250, 251, 252, 253, 254, 108, 245, 111, 272, - /* 70 */ 277, 286, 288, 289, 290, 291, 292, 330, 294, 334, - /* 80 */ 335, 337, 268, 338, 340, 341, 287, 298, 346, 347, - /* 90 */ 351, 352, 261, 264, 293, 300, 354, 356, 358, 361, - /* 100 */ 365, 366, 367, 368, 369, 370, 371, 376, 377, 378, - /* 110 */ 379, 380, 381, 382, 383, 385, 387, 388, 389, 390, - /* 120 */ 391, 394, 396, 397, 398, 399, 400, 401, 402, 403, - /* 130 */ 404, 405, 406, 408, 409, 410, 411, 412, 413, 414, - /* 140 */ 415, 416, 417, 418, 419, 420, 421, 423, 424, 425, - /* 150 */ 426, 427, 428, 429, 430, 431, 432, 278, 279, 280, - /* 160 */ 283, 434, 435, 295, 301, 299, 296, 305, 439, 308, - /* 170 */ 440, 443, 442, 444, 446, 447, 448, 449, 450, 451, - /* 180 */ 452, 453, 455, 458, 456, 460, 463, 459, 466, 467, - /* 190 */ 468, 469, 476, 477, 481, 478, 482, 484, 487, 488, - /* 200 */ 485, 495, + /* 0 */ -56, 11, -161, 90, -78, 119, 142, -192, 17, -176, + /* 10 */ -24, 69, 160, 165, 179, 180, 181, 186, 187, 192, + /* 20 */ 194, -194, -191, -232, -217, -210, -162, -196, -81, 6, + /* 30 */ 85, -84, -182, -108, -89, 100, 101, 191, -157, 143, + /* 40 */ -127, 209, 226, 185, -83, -73, -4, 51, 227, 231, + /* 50 */ 236, 240, 244, 245, 249, 250, 252, 253, 254, 255, + /* 60 */ 256, 257, 258, 259, 260, 261, 264, 265, 279, 281, + /* 70 */ 269, 295, 296, 299, 300, 301, 302, 334, 303, 335, + /* 80 */ 341, 343, 266, 344, 345, 346, 305, 306, 347, 348, + /* 90 */ 349, 352, 267, 278, 307, 309, 355, 359, 360, 361, + /* 100 */ 362, 365, 366, 369, 370, 372, 377, 378, 379, 380, + /* 110 */ 381, 383, 384, 385, 387, 389, 391, 392, 394, 395, + /* 120 */ 396, 397, 398, 399, 401, 402, 403, 404, 405, 406, + /* 130 */ 407, 408, 410, 411, 412, 413, 414, 415, 416, 417, + /* 140 */ 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, + /* 150 */ 429, 430, 431, 432, 433, 434, 435, 287, 312, 316, + /* 160 */ 318, 437, 438, 311, 310, 308, 317, 439, 441, 444, + /* 170 */ 446, 313, 442, 445, 447, 448, 449, 450, 454, 455, + /* 180 */ 460, 457, 459, 458, 461, 463, 466, 467, 469, 465, + /* 190 */ 468, 470, 475, 480, 482, 484, 483, 485, 487, 488, + /* 200 */ 496, 492, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 885, 948, 935, 944, 1167, 1167, 1167, 885, 885, 885, @@ -516,16 +514,10 @@ static const YYCODETYPE yyFallback[] = { 0, /* $ => nothing */ 0, /* ID => nothing */ 1, /* BOOL => ID */ - 1, /* TINYINT => ID */ - 1, /* SMALLINT => ID */ 1, /* INTEGER => ID */ - 1, /* BIGINT => ID */ 1, /* FLOAT => ID */ - 1, /* DOUBLE => ID */ 1, /* STRING => ID */ 1, /* TIMESTAMP => ID */ - 1, /* BINARY => ID */ - 1, /* NCHAR => ID */ 0, /* OR => nothing */ 0, /* AND => nothing */ 0, /* NOT => nothing */ @@ -799,281 +791,275 @@ static const char *const yyTokenName[] = { /* 0 */ "$", /* 1 */ "ID", /* 2 */ "BOOL", - /* 3 */ "TINYINT", - /* 4 */ "SMALLINT", - /* 5 */ "INTEGER", - /* 6 */ "BIGINT", - /* 7 */ "FLOAT", - /* 8 */ "DOUBLE", - /* 9 */ "STRING", - /* 10 */ "TIMESTAMP", - /* 11 */ "BINARY", - /* 12 */ "NCHAR", - /* 13 */ "OR", - /* 14 */ "AND", - /* 15 */ "NOT", - /* 16 */ "EQ", - /* 17 */ "NE", - /* 18 */ "ISNULL", - /* 19 */ "NOTNULL", - /* 20 */ "IS", - /* 21 */ "LIKE", - /* 22 */ "MATCH", - /* 23 */ "NMATCH", - /* 24 */ "GLOB", - /* 25 */ "BETWEEN", - /* 26 */ "IN", - /* 27 */ "GT", - /* 28 */ "GE", - /* 29 */ "LT", - /* 30 */ "LE", - /* 31 */ "BITAND", - /* 32 */ "BITOR", - /* 33 */ "LSHIFT", - /* 34 */ "RSHIFT", - /* 35 */ "PLUS", - /* 36 */ "MINUS", - /* 37 */ "DIVIDE", - /* 38 */ "TIMES", - /* 39 */ "STAR", - /* 40 */ "SLASH", - /* 41 */ "REM", - /* 42 */ "CONCAT", - /* 43 */ "UMINUS", - /* 44 */ "UPLUS", - /* 45 */ "BITNOT", - /* 46 */ "SHOW", - /* 47 */ "DATABASES", - /* 48 */ "TOPICS", - /* 49 */ "FUNCTIONS", - /* 50 */ "MNODES", - /* 51 */ "DNODES", - /* 52 */ "ACCOUNTS", - /* 53 */ "USERS", - /* 54 */ "MODULES", - /* 55 */ "QUERIES", - /* 56 */ "CONNECTIONS", - /* 57 */ "STREAMS", - /* 58 */ "VARIABLES", - /* 59 */ "SCORES", - /* 60 */ "GRANTS", - /* 61 */ "VNODES", - /* 62 */ "DOT", - /* 63 */ "CREATE", - /* 64 */ "TABLE", - /* 65 */ "STABLE", - /* 66 */ "DATABASE", - /* 67 */ "TABLES", - /* 68 */ "STABLES", - /* 69 */ "VGROUPS", - /* 70 */ "DROP", - /* 71 */ "TOPIC", - /* 72 */ "FUNCTION", - /* 73 */ "DNODE", - /* 74 */ "USER", - /* 75 */ "ACCOUNT", - /* 76 */ "USE", - /* 77 */ "DESCRIBE", - /* 78 */ "DESC", - /* 79 */ "ALTER", - /* 80 */ "PASS", - /* 81 */ "PRIVILEGE", - /* 82 */ "LOCAL", - /* 83 */ "COMPACT", - /* 84 */ "LP", - /* 85 */ "RP", - /* 86 */ "IF", - /* 87 */ "EXISTS", - /* 88 */ "PORT", - /* 89 */ "IPTOKEN", - /* 90 */ "AS", - /* 91 */ "OUTPUTTYPE", - /* 92 */ "AGGREGATE", - /* 93 */ "BUFSIZE", - /* 94 */ "PPS", - /* 95 */ "TSERIES", - /* 96 */ "DBS", - /* 97 */ "STORAGE", - /* 98 */ "QTIME", - /* 99 */ "CONNS", - /* 100 */ "STATE", - /* 101 */ "COMMA", - /* 102 */ "KEEP", - /* 103 */ "CACHE", - /* 104 */ "REPLICA", - /* 105 */ "QUORUM", - /* 106 */ "DAYS", - /* 107 */ "MINROWS", - /* 108 */ "MAXROWS", - /* 109 */ "BLOCKS", - /* 110 */ "CTIME", - /* 111 */ "WAL", - /* 112 */ "FSYNC", - /* 113 */ "COMP", - /* 114 */ "PRECISION", - /* 115 */ "UPDATE", - /* 116 */ "CACHELAST", - /* 117 */ "UNSIGNED", - /* 118 */ "TAGS", - /* 119 */ "USING", - /* 120 */ "NULL", - /* 121 */ "NOW", - /* 122 */ "SELECT", - /* 123 */ "UNION", - /* 124 */ "ALL", - /* 125 */ "DISTINCT", - /* 126 */ "FROM", - /* 127 */ "VARIABLE", - /* 128 */ "INTERVAL", - /* 129 */ "EVERY", - /* 130 */ "SESSION", - /* 131 */ "STATE_WINDOW", - /* 132 */ "FILL", - /* 133 */ "SLIDING", - /* 134 */ "ORDER", - /* 135 */ "BY", - /* 136 */ "ASC", - /* 137 */ "GROUP", - /* 138 */ "HAVING", - /* 139 */ "LIMIT", - /* 140 */ "OFFSET", - /* 141 */ "SLIMIT", - /* 142 */ "SOFFSET", - /* 143 */ "WHERE", - /* 144 */ "RESET", - /* 145 */ "QUERY", - /* 146 */ "SYNCDB", - /* 147 */ "ADD", - /* 148 */ "COLUMN", - /* 149 */ "MODIFY", - /* 150 */ "TAG", - /* 151 */ "CHANGE", - /* 152 */ "SET", - /* 153 */ "KILL", - /* 154 */ "CONNECTION", - /* 155 */ "STREAM", - /* 156 */ "COLON", - /* 157 */ "ABORT", - /* 158 */ "AFTER", - /* 159 */ "ATTACH", - /* 160 */ "BEFORE", - /* 161 */ "BEGIN", - /* 162 */ "CASCADE", - /* 163 */ "CLUSTER", - /* 164 */ "CONFLICT", - /* 165 */ "COPY", - /* 166 */ "DEFERRED", - /* 167 */ "DELIMITERS", - /* 168 */ "DETACH", - /* 169 */ "EACH", - /* 170 */ "END", - /* 171 */ "EXPLAIN", - /* 172 */ "FAIL", - /* 173 */ "FOR", - /* 174 */ "IGNORE", - /* 175 */ "IMMEDIATE", - /* 176 */ "INITIALLY", - /* 177 */ "INSTEAD", - /* 178 */ "KEY", - /* 179 */ "OF", - /* 180 */ "RAISE", - /* 181 */ "REPLACE", - /* 182 */ "RESTRICT", - /* 183 */ "ROW", - /* 184 */ "STATEMENT", - /* 185 */ "TRIGGER", - /* 186 */ "VIEW", - /* 187 */ "SEMI", - /* 188 */ "NONE", - /* 189 */ "PREV", - /* 190 */ "LINEAR", - /* 191 */ "IMPORT", - /* 192 */ "TBNAME", - /* 193 */ "JOIN", - /* 194 */ "INSERT", - /* 195 */ "INTO", - /* 196 */ "VALUES", - /* 197 */ "error", - /* 198 */ "program", - /* 199 */ "cmd", - /* 200 */ "ids", - /* 201 */ "dbPrefix", - /* 202 */ "cpxName", - /* 203 */ "ifexists", - /* 204 */ "alter_db_optr", - /* 205 */ "acct_optr", - /* 206 */ "exprlist", - /* 207 */ "ifnotexists", - /* 208 */ "db_optr", - /* 209 */ "typename", - /* 210 */ "bufsize", - /* 211 */ "pps", - /* 212 */ "tseries", - /* 213 */ "dbs", - /* 214 */ "streams", - /* 215 */ "storage", - /* 216 */ "qtime", - /* 217 */ "users", - /* 218 */ "conns", - /* 219 */ "state", - /* 220 */ "intitemlist", - /* 221 */ "intitem", - /* 222 */ "keep", - /* 223 */ "cache", - /* 224 */ "replica", - /* 225 */ "quorum", - /* 226 */ "days", - /* 227 */ "minrows", - /* 228 */ "maxrows", - /* 229 */ "blocks", - /* 230 */ "ctime", - /* 231 */ "wal", - /* 232 */ "fsync", - /* 233 */ "comp", - /* 234 */ "prec", - /* 235 */ "update", - /* 236 */ "cachelast", - /* 237 */ "signed", - /* 238 */ "create_table_args", - /* 239 */ "create_stable_args", - /* 240 */ "create_table_list", - /* 241 */ "create_from_stable", - /* 242 */ "columnlist", - /* 243 */ "tagitemlist1", - /* 244 */ "tagNamelist", - /* 245 */ "select", - /* 246 */ "column", - /* 247 */ "tagitem1", - /* 248 */ "tagitemlist", - /* 249 */ "tagitem", - /* 250 */ "selcollist", - /* 251 */ "from", - /* 252 */ "where_opt", - /* 253 */ "interval_option", - /* 254 */ "sliding_opt", - /* 255 */ "session_option", - /* 256 */ "windowstate_option", - /* 257 */ "fill_opt", - /* 258 */ "groupby_opt", - /* 259 */ "having_opt", - /* 260 */ "orderby_opt", - /* 261 */ "slimit_opt", - /* 262 */ "limit_opt", - /* 263 */ "union", - /* 264 */ "sclp", - /* 265 */ "distinct", - /* 266 */ "expr", - /* 267 */ "as", - /* 268 */ "tablelist", - /* 269 */ "sub", - /* 270 */ "tmvar", - /* 271 */ "intervalKey", - /* 272 */ "sortlist", - /* 273 */ "sortitem", - /* 274 */ "item", - /* 275 */ "sortorder", - /* 276 */ "grouplist", - /* 277 */ "expritem", + /* 3 */ "INTEGER", + /* 4 */ "FLOAT", + /* 5 */ "STRING", + /* 6 */ "TIMESTAMP", + /* 7 */ "OR", + /* 8 */ "AND", + /* 9 */ "NOT", + /* 10 */ "EQ", + /* 11 */ "NE", + /* 12 */ "ISNULL", + /* 13 */ "NOTNULL", + /* 14 */ "IS", + /* 15 */ "LIKE", + /* 16 */ "MATCH", + /* 17 */ "NMATCH", + /* 18 */ "GLOB", + /* 19 */ "BETWEEN", + /* 20 */ "IN", + /* 21 */ "GT", + /* 22 */ "GE", + /* 23 */ "LT", + /* 24 */ "LE", + /* 25 */ "BITAND", + /* 26 */ "BITOR", + /* 27 */ "LSHIFT", + /* 28 */ "RSHIFT", + /* 29 */ "PLUS", + /* 30 */ "MINUS", + /* 31 */ "DIVIDE", + /* 32 */ "TIMES", + /* 33 */ "STAR", + /* 34 */ "SLASH", + /* 35 */ "REM", + /* 36 */ "CONCAT", + /* 37 */ "UMINUS", + /* 38 */ "UPLUS", + /* 39 */ "BITNOT", + /* 40 */ "SHOW", + /* 41 */ "DATABASES", + /* 42 */ "TOPICS", + /* 43 */ "FUNCTIONS", + /* 44 */ "MNODES", + /* 45 */ "DNODES", + /* 46 */ "ACCOUNTS", + /* 47 */ "USERS", + /* 48 */ "MODULES", + /* 49 */ "QUERIES", + /* 50 */ "CONNECTIONS", + /* 51 */ "STREAMS", + /* 52 */ "VARIABLES", + /* 53 */ "SCORES", + /* 54 */ "GRANTS", + /* 55 */ "VNODES", + /* 56 */ "DOT", + /* 57 */ "CREATE", + /* 58 */ "TABLE", + /* 59 */ "STABLE", + /* 60 */ "DATABASE", + /* 61 */ "TABLES", + /* 62 */ "STABLES", + /* 63 */ "VGROUPS", + /* 64 */ "DROP", + /* 65 */ "TOPIC", + /* 66 */ "FUNCTION", + /* 67 */ "DNODE", + /* 68 */ "USER", + /* 69 */ "ACCOUNT", + /* 70 */ "USE", + /* 71 */ "DESCRIBE", + /* 72 */ "DESC", + /* 73 */ "ALTER", + /* 74 */ "PASS", + /* 75 */ "PRIVILEGE", + /* 76 */ "LOCAL", + /* 77 */ "COMPACT", + /* 78 */ "LP", + /* 79 */ "RP", + /* 80 */ "IF", + /* 81 */ "EXISTS", + /* 82 */ "PORT", + /* 83 */ "IPTOKEN", + /* 84 */ "AS", + /* 85 */ "OUTPUTTYPE", + /* 86 */ "AGGREGATE", + /* 87 */ "BUFSIZE", + /* 88 */ "PPS", + /* 89 */ "TSERIES", + /* 90 */ "DBS", + /* 91 */ "STORAGE", + /* 92 */ "QTIME", + /* 93 */ "CONNS", + /* 94 */ "STATE", + /* 95 */ "COMMA", + /* 96 */ "KEEP", + /* 97 */ "CACHE", + /* 98 */ "REPLICA", + /* 99 */ "QUORUM", + /* 100 */ "DAYS", + /* 101 */ "MINROWS", + /* 102 */ "MAXROWS", + /* 103 */ "BLOCKS", + /* 104 */ "CTIME", + /* 105 */ "WAL", + /* 106 */ "FSYNC", + /* 107 */ "COMP", + /* 108 */ "PRECISION", + /* 109 */ "UPDATE", + /* 110 */ "CACHELAST", + /* 111 */ "UNSIGNED", + /* 112 */ "TAGS", + /* 113 */ "USING", + /* 114 */ "NULL", + /* 115 */ "NOW", + /* 116 */ "SELECT", + /* 117 */ "UNION", + /* 118 */ "ALL", + /* 119 */ "DISTINCT", + /* 120 */ "FROM", + /* 121 */ "VARIABLE", + /* 122 */ "INTERVAL", + /* 123 */ "EVERY", + /* 124 */ "SESSION", + /* 125 */ "STATE_WINDOW", + /* 126 */ "FILL", + /* 127 */ "SLIDING", + /* 128 */ "ORDER", + /* 129 */ "BY", + /* 130 */ "ASC", + /* 131 */ "GROUP", + /* 132 */ "HAVING", + /* 133 */ "LIMIT", + /* 134 */ "OFFSET", + /* 135 */ "SLIMIT", + /* 136 */ "SOFFSET", + /* 137 */ "WHERE", + /* 138 */ "RESET", + /* 139 */ "QUERY", + /* 140 */ "SYNCDB", + /* 141 */ "ADD", + /* 142 */ "COLUMN", + /* 143 */ "MODIFY", + /* 144 */ "TAG", + /* 145 */ "CHANGE", + /* 146 */ "SET", + /* 147 */ "KILL", + /* 148 */ "CONNECTION", + /* 149 */ "STREAM", + /* 150 */ "COLON", + /* 151 */ "ABORT", + /* 152 */ "AFTER", + /* 153 */ "ATTACH", + /* 154 */ "BEFORE", + /* 155 */ "BEGIN", + /* 156 */ "CASCADE", + /* 157 */ "CLUSTER", + /* 158 */ "CONFLICT", + /* 159 */ "COPY", + /* 160 */ "DEFERRED", + /* 161 */ "DELIMITERS", + /* 162 */ "DETACH", + /* 163 */ "EACH", + /* 164 */ "END", + /* 165 */ "EXPLAIN", + /* 166 */ "FAIL", + /* 167 */ "FOR", + /* 168 */ "IGNORE", + /* 169 */ "IMMEDIATE", + /* 170 */ "INITIALLY", + /* 171 */ "INSTEAD", + /* 172 */ "KEY", + /* 173 */ "OF", + /* 174 */ "RAISE", + /* 175 */ "REPLACE", + /* 176 */ "RESTRICT", + /* 177 */ "ROW", + /* 178 */ "STATEMENT", + /* 179 */ "TRIGGER", + /* 180 */ "VIEW", + /* 181 */ "SEMI", + /* 182 */ "NONE", + /* 183 */ "PREV", + /* 184 */ "LINEAR", + /* 185 */ "IMPORT", + /* 186 */ "TBNAME", + /* 187 */ "JOIN", + /* 188 */ "INSERT", + /* 189 */ "INTO", + /* 190 */ "VALUES", + /* 191 */ "error", + /* 192 */ "program", + /* 193 */ "cmd", + /* 194 */ "ids", + /* 195 */ "dbPrefix", + /* 196 */ "cpxName", + /* 197 */ "ifexists", + /* 198 */ "alter_db_optr", + /* 199 */ "acct_optr", + /* 200 */ "exprlist", + /* 201 */ "ifnotexists", + /* 202 */ "db_optr", + /* 203 */ "typename", + /* 204 */ "bufsize", + /* 205 */ "pps", + /* 206 */ "tseries", + /* 207 */ "dbs", + /* 208 */ "streams", + /* 209 */ "storage", + /* 210 */ "qtime", + /* 211 */ "users", + /* 212 */ "conns", + /* 213 */ "state", + /* 214 */ "intitemlist", + /* 215 */ "intitem", + /* 216 */ "keep", + /* 217 */ "cache", + /* 218 */ "replica", + /* 219 */ "quorum", + /* 220 */ "days", + /* 221 */ "minrows", + /* 222 */ "maxrows", + /* 223 */ "blocks", + /* 224 */ "ctime", + /* 225 */ "wal", + /* 226 */ "fsync", + /* 227 */ "comp", + /* 228 */ "prec", + /* 229 */ "update", + /* 230 */ "cachelast", + /* 231 */ "signed", + /* 232 */ "create_table_args", + /* 233 */ "create_stable_args", + /* 234 */ "create_table_list", + /* 235 */ "create_from_stable", + /* 236 */ "columnlist", + /* 237 */ "tagitemlist1", + /* 238 */ "tagNamelist", + /* 239 */ "select", + /* 240 */ "column", + /* 241 */ "tagitem1", + /* 242 */ "tagitemlist", + /* 243 */ "tagitem", + /* 244 */ "selcollist", + /* 245 */ "from", + /* 246 */ "where_opt", + /* 247 */ "interval_option", + /* 248 */ "sliding_opt", + /* 249 */ "session_option", + /* 250 */ "windowstate_option", + /* 251 */ "fill_opt", + /* 252 */ "groupby_opt", + /* 253 */ "having_opt", + /* 254 */ "orderby_opt", + /* 255 */ "slimit_opt", + /* 256 */ "limit_opt", + /* 257 */ "union", + /* 258 */ "sclp", + /* 259 */ "distinct", + /* 260 */ "expr", + /* 261 */ "as", + /* 262 */ "tablelist", + /* 263 */ "sub", + /* 264 */ "tmvar", + /* 265 */ "intervalKey", + /* 266 */ "sortlist", + /* 267 */ "sortitem", + /* 268 */ "item", + /* 269 */ "sortorder", + /* 270 */ "grouplist", + /* 271 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1502,61 +1488,61 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 206: /* exprlist */ - case 250: /* selcollist */ - case 264: /* sclp */ + case 200: /* exprlist */ + case 244: /* selcollist */ + case 258: /* sclp */ { -tSqlExprListDestroy((yypminor->yy421)); +tSqlExprListDestroy((yypminor->yy413)); } break; - case 220: /* intitemlist */ - case 222: /* keep */ - case 242: /* columnlist */ - case 243: /* tagitemlist1 */ - case 244: /* tagNamelist */ - case 248: /* tagitemlist */ - case 257: /* fill_opt */ - case 258: /* groupby_opt */ - case 260: /* orderby_opt */ - case 272: /* sortlist */ - case 276: /* grouplist */ + case 214: /* intitemlist */ + case 216: /* keep */ + case 236: /* columnlist */ + case 237: /* tagitemlist1 */ + case 238: /* tagNamelist */ + case 242: /* tagitemlist */ + case 251: /* fill_opt */ + case 252: /* groupby_opt */ + case 254: /* orderby_opt */ + case 266: /* sortlist */ + case 270: /* grouplist */ { -taosArrayDestroy((yypminor->yy421)); +taosArrayDestroy((yypminor->yy413)); } break; - case 240: /* create_table_list */ + case 234: /* create_table_list */ { destroyCreateTableSql((yypminor->yy438)); } break; - case 245: /* select */ + case 239: /* select */ { -destroySqlNode((yypminor->yy56)); +destroySqlNode((yypminor->yy24)); } break; - case 251: /* from */ - case 268: /* tablelist */ - case 269: /* sub */ + case 245: /* from */ + case 262: /* tablelist */ + case 263: /* sub */ { -destroyRelationInfo((yypminor->yy8)); +destroyRelationInfo((yypminor->yy292)); } break; - case 252: /* where_opt */ - case 259: /* having_opt */ - case 266: /* expr */ - case 277: /* expritem */ + case 246: /* where_opt */ + case 253: /* having_opt */ + case 260: /* expr */ + case 271: /* expritem */ { -tSqlExprDestroy((yypminor->yy439)); +tSqlExprDestroy((yypminor->yy370)); } break; - case 263: /* union */ + case 257: /* union */ { -destroyAllSqlNode((yypminor->yy149)); +destroyAllSqlNode((yypminor->yy129)); } break; - case 273: /* sortitem */ + case 267: /* sortitem */ { -taosVariantDestroy(&(yypminor->yy69)); +taosVariantDestroy(&(yypminor->yy461)); } break; /********* End destructor definitions *****************************************/ @@ -1850,307 +1836,307 @@ 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[] = { - { 198, -1 }, /* (0) program ::= cmd */ - { 199, -2 }, /* (1) cmd ::= SHOW DATABASES */ - { 199, -2 }, /* (2) cmd ::= SHOW TOPICS */ - { 199, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ - { 199, -2 }, /* (4) cmd ::= SHOW MNODES */ - { 199, -2 }, /* (5) cmd ::= SHOW DNODES */ - { 199, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ - { 199, -2 }, /* (7) cmd ::= SHOW USERS */ - { 199, -2 }, /* (8) cmd ::= SHOW MODULES */ - { 199, -2 }, /* (9) cmd ::= SHOW QUERIES */ - { 199, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ - { 199, -2 }, /* (11) cmd ::= SHOW STREAMS */ - { 199, -2 }, /* (12) cmd ::= SHOW VARIABLES */ - { 199, -2 }, /* (13) cmd ::= SHOW SCORES */ - { 199, -2 }, /* (14) cmd ::= SHOW GRANTS */ - { 199, -2 }, /* (15) cmd ::= SHOW VNODES */ - { 199, -3 }, /* (16) cmd ::= SHOW VNODES ids */ - { 201, 0 }, /* (17) dbPrefix ::= */ - { 201, -2 }, /* (18) dbPrefix ::= ids DOT */ - { 202, 0 }, /* (19) cpxName ::= */ - { 202, -2 }, /* (20) cpxName ::= DOT ids */ - { 199, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - { 199, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - { 199, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - { 199, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ - { 199, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - { 199, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ - { 199, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - { 199, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - { 199, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ - { 199, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ - { 199, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ - { 199, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */ - { 199, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */ - { 199, -3 }, /* (34) cmd ::= DROP FUNCTION ids */ - { 199, -3 }, /* (35) cmd ::= DROP DNODE ids */ - { 199, -3 }, /* (36) cmd ::= DROP USER ids */ - { 199, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */ - { 199, -2 }, /* (38) cmd ::= USE ids */ - { 199, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */ - { 199, -3 }, /* (40) cmd ::= DESC ids cpxName */ - { 199, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */ - { 199, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 199, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ - { 199, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ - { 199, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ - { 199, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ - { 199, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 199, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 199, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 199, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - { 200, -1 }, /* (51) ids ::= ID */ - { 200, -1 }, /* (52) ids ::= STRING */ - { 203, -2 }, /* (53) ifexists ::= IF EXISTS */ - { 203, 0 }, /* (54) ifexists ::= */ - { 207, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */ - { 207, 0 }, /* (56) ifnotexists ::= */ - { 199, -5 }, /* (57) cmd ::= CREATE DNODE ids PORT ids */ - { 199, -5 }, /* (58) cmd ::= CREATE DNODE IPTOKEN PORT ids */ - { 199, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 199, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 199, -8 }, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 199, -9 }, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - { 199, -5 }, /* (63) cmd ::= CREATE USER ids PASS ids */ - { 210, 0 }, /* (64) bufsize ::= */ - { 210, -2 }, /* (65) bufsize ::= BUFSIZE INTEGER */ - { 211, 0 }, /* (66) pps ::= */ - { 211, -2 }, /* (67) pps ::= PPS INTEGER */ - { 212, 0 }, /* (68) tseries ::= */ - { 212, -2 }, /* (69) tseries ::= TSERIES INTEGER */ - { 213, 0 }, /* (70) dbs ::= */ - { 213, -2 }, /* (71) dbs ::= DBS INTEGER */ - { 214, 0 }, /* (72) streams ::= */ - { 214, -2 }, /* (73) streams ::= STREAMS INTEGER */ - { 215, 0 }, /* (74) storage ::= */ - { 215, -2 }, /* (75) storage ::= STORAGE INTEGER */ - { 216, 0 }, /* (76) qtime ::= */ - { 216, -2 }, /* (77) qtime ::= QTIME INTEGER */ - { 217, 0 }, /* (78) users ::= */ - { 217, -2 }, /* (79) users ::= USERS INTEGER */ - { 218, 0 }, /* (80) conns ::= */ - { 218, -2 }, /* (81) conns ::= CONNS INTEGER */ - { 219, 0 }, /* (82) state ::= */ - { 219, -2 }, /* (83) state ::= STATE ids */ - { 205, -9 }, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 220, -3 }, /* (85) intitemlist ::= intitemlist COMMA intitem */ - { 220, -1 }, /* (86) intitemlist ::= intitem */ - { 221, -1 }, /* (87) intitem ::= INTEGER */ - { 222, -2 }, /* (88) keep ::= KEEP intitemlist */ - { 223, -2 }, /* (89) cache ::= CACHE INTEGER */ - { 224, -2 }, /* (90) replica ::= REPLICA INTEGER */ - { 225, -2 }, /* (91) quorum ::= QUORUM INTEGER */ - { 226, -2 }, /* (92) days ::= DAYS INTEGER */ - { 227, -2 }, /* (93) minrows ::= MINROWS INTEGER */ - { 228, -2 }, /* (94) maxrows ::= MAXROWS INTEGER */ - { 229, -2 }, /* (95) blocks ::= BLOCKS INTEGER */ - { 230, -2 }, /* (96) ctime ::= CTIME INTEGER */ - { 231, -2 }, /* (97) wal ::= WAL INTEGER */ - { 232, -2 }, /* (98) fsync ::= FSYNC INTEGER */ - { 233, -2 }, /* (99) comp ::= COMP INTEGER */ - { 234, -2 }, /* (100) prec ::= PRECISION STRING */ - { 235, -2 }, /* (101) update ::= UPDATE INTEGER */ - { 236, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */ - { 208, 0 }, /* (103) db_optr ::= */ - { 208, -2 }, /* (104) db_optr ::= db_optr cache */ - { 208, -2 }, /* (105) db_optr ::= db_optr replica */ - { 208, -2 }, /* (106) db_optr ::= db_optr quorum */ - { 208, -2 }, /* (107) db_optr ::= db_optr days */ - { 208, -2 }, /* (108) db_optr ::= db_optr minrows */ - { 208, -2 }, /* (109) db_optr ::= db_optr maxrows */ - { 208, -2 }, /* (110) db_optr ::= db_optr blocks */ - { 208, -2 }, /* (111) db_optr ::= db_optr ctime */ - { 208, -2 }, /* (112) db_optr ::= db_optr wal */ - { 208, -2 }, /* (113) db_optr ::= db_optr fsync */ - { 208, -2 }, /* (114) db_optr ::= db_optr comp */ - { 208, -2 }, /* (115) db_optr ::= db_optr prec */ - { 208, -2 }, /* (116) db_optr ::= db_optr keep */ - { 208, -2 }, /* (117) db_optr ::= db_optr update */ - { 208, -2 }, /* (118) db_optr ::= db_optr cachelast */ - { 204, 0 }, /* (119) alter_db_optr ::= */ - { 204, -2 }, /* (120) alter_db_optr ::= alter_db_optr replica */ - { 204, -2 }, /* (121) alter_db_optr ::= alter_db_optr quorum */ - { 204, -2 }, /* (122) alter_db_optr ::= alter_db_optr keep */ - { 204, -2 }, /* (123) alter_db_optr ::= alter_db_optr blocks */ - { 204, -2 }, /* (124) alter_db_optr ::= alter_db_optr comp */ - { 204, -2 }, /* (125) alter_db_optr ::= alter_db_optr update */ - { 204, -2 }, /* (126) alter_db_optr ::= alter_db_optr cachelast */ - { 209, -1 }, /* (127) typename ::= ids */ - { 209, -4 }, /* (128) typename ::= ids LP signed RP */ - { 209, -2 }, /* (129) typename ::= ids UNSIGNED */ - { 237, -1 }, /* (130) signed ::= INTEGER */ - { 237, -2 }, /* (131) signed ::= PLUS INTEGER */ - { 237, -2 }, /* (132) signed ::= MINUS INTEGER */ - { 199, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ - { 199, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ - { 199, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ - { 199, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ - { 240, -1 }, /* (137) create_table_list ::= create_from_stable */ - { 240, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ - { 238, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 239, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 241, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ - { 241, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ - { 244, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ - { 244, -1 }, /* (144) tagNamelist ::= ids */ - { 238, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ - { 242, -3 }, /* (146) columnlist ::= columnlist COMMA column */ - { 242, -1 }, /* (147) columnlist ::= column */ - { 246, -2 }, /* (148) column ::= ids typename */ - { 243, -3 }, /* (149) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ - { 243, -1 }, /* (150) tagitemlist1 ::= tagitem1 */ - { 247, -2 }, /* (151) tagitem1 ::= MINUS INTEGER */ - { 247, -2 }, /* (152) tagitem1 ::= MINUS FLOAT */ - { 247, -2 }, /* (153) tagitem1 ::= PLUS INTEGER */ - { 247, -2 }, /* (154) tagitem1 ::= PLUS FLOAT */ - { 247, -1 }, /* (155) tagitem1 ::= INTEGER */ - { 247, -1 }, /* (156) tagitem1 ::= FLOAT */ - { 247, -1 }, /* (157) tagitem1 ::= STRING */ - { 247, -1 }, /* (158) tagitem1 ::= BOOL */ - { 247, -1 }, /* (159) tagitem1 ::= NULL */ - { 247, -1 }, /* (160) tagitem1 ::= NOW */ - { 248, -3 }, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ - { 248, -1 }, /* (162) tagitemlist ::= tagitem */ - { 249, -1 }, /* (163) tagitem ::= INTEGER */ - { 249, -1 }, /* (164) tagitem ::= FLOAT */ - { 249, -1 }, /* (165) tagitem ::= STRING */ - { 249, -1 }, /* (166) tagitem ::= BOOL */ - { 249, -1 }, /* (167) tagitem ::= NULL */ - { 249, -1 }, /* (168) tagitem ::= NOW */ - { 249, -2 }, /* (169) tagitem ::= MINUS INTEGER */ - { 249, -2 }, /* (170) tagitem ::= MINUS FLOAT */ - { 249, -2 }, /* (171) tagitem ::= PLUS INTEGER */ - { 249, -2 }, /* (172) tagitem ::= PLUS FLOAT */ - { 245, -14 }, /* (173) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 245, -3 }, /* (174) select ::= LP select RP */ - { 263, -1 }, /* (175) union ::= select */ - { 263, -4 }, /* (176) union ::= union UNION ALL select */ - { 263, -3 }, /* (177) union ::= union UNION select */ - { 199, -1 }, /* (178) cmd ::= union */ - { 245, -2 }, /* (179) select ::= SELECT selcollist */ - { 264, -2 }, /* (180) sclp ::= selcollist COMMA */ - { 264, 0 }, /* (181) sclp ::= */ - { 250, -4 }, /* (182) selcollist ::= sclp distinct expr as */ - { 250, -2 }, /* (183) selcollist ::= sclp STAR */ - { 267, -2 }, /* (184) as ::= AS ids */ - { 267, -1 }, /* (185) as ::= ids */ - { 267, 0 }, /* (186) as ::= */ - { 265, -1 }, /* (187) distinct ::= DISTINCT */ - { 265, 0 }, /* (188) distinct ::= */ - { 251, -2 }, /* (189) from ::= FROM tablelist */ - { 251, -2 }, /* (190) from ::= FROM sub */ - { 269, -3 }, /* (191) sub ::= LP union RP */ - { 269, -4 }, /* (192) sub ::= LP union RP ids */ - { 269, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */ - { 268, -2 }, /* (194) tablelist ::= ids cpxName */ - { 268, -3 }, /* (195) tablelist ::= ids cpxName ids */ - { 268, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */ - { 268, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */ - { 270, -1 }, /* (198) tmvar ::= VARIABLE */ - { 253, -4 }, /* (199) interval_option ::= intervalKey LP tmvar RP */ - { 253, -6 }, /* (200) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - { 253, 0 }, /* (201) interval_option ::= */ - { 271, -1 }, /* (202) intervalKey ::= INTERVAL */ - { 271, -1 }, /* (203) intervalKey ::= EVERY */ - { 255, 0 }, /* (204) session_option ::= */ - { 255, -7 }, /* (205) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 256, 0 }, /* (206) windowstate_option ::= */ - { 256, -4 }, /* (207) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 257, 0 }, /* (208) fill_opt ::= */ - { 257, -6 }, /* (209) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 257, -4 }, /* (210) fill_opt ::= FILL LP ID RP */ - { 254, -4 }, /* (211) sliding_opt ::= SLIDING LP tmvar RP */ - { 254, 0 }, /* (212) sliding_opt ::= */ - { 260, 0 }, /* (213) orderby_opt ::= */ - { 260, -3 }, /* (214) orderby_opt ::= ORDER BY sortlist */ - { 272, -4 }, /* (215) sortlist ::= sortlist COMMA item sortorder */ - { 272, -2 }, /* (216) sortlist ::= item sortorder */ - { 274, -2 }, /* (217) item ::= ids cpxName */ - { 275, -1 }, /* (218) sortorder ::= ASC */ - { 275, -1 }, /* (219) sortorder ::= DESC */ - { 275, 0 }, /* (220) sortorder ::= */ - { 258, 0 }, /* (221) groupby_opt ::= */ - { 258, -3 }, /* (222) groupby_opt ::= GROUP BY grouplist */ - { 276, -3 }, /* (223) grouplist ::= grouplist COMMA item */ - { 276, -1 }, /* (224) grouplist ::= item */ - { 259, 0 }, /* (225) having_opt ::= */ - { 259, -2 }, /* (226) having_opt ::= HAVING expr */ - { 262, 0 }, /* (227) limit_opt ::= */ - { 262, -2 }, /* (228) limit_opt ::= LIMIT signed */ - { 262, -4 }, /* (229) limit_opt ::= LIMIT signed OFFSET signed */ - { 262, -4 }, /* (230) limit_opt ::= LIMIT signed COMMA signed */ - { 261, 0 }, /* (231) slimit_opt ::= */ - { 261, -2 }, /* (232) slimit_opt ::= SLIMIT signed */ - { 261, -4 }, /* (233) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 261, -4 }, /* (234) slimit_opt ::= SLIMIT signed COMMA signed */ - { 252, 0 }, /* (235) where_opt ::= */ - { 252, -2 }, /* (236) where_opt ::= WHERE expr */ - { 266, -3 }, /* (237) expr ::= LP expr RP */ - { 266, -1 }, /* (238) expr ::= ID */ - { 266, -3 }, /* (239) expr ::= ID DOT ID */ - { 266, -3 }, /* (240) expr ::= ID DOT STAR */ - { 266, -1 }, /* (241) expr ::= INTEGER */ - { 266, -2 }, /* (242) expr ::= MINUS INTEGER */ - { 266, -2 }, /* (243) expr ::= PLUS INTEGER */ - { 266, -1 }, /* (244) expr ::= FLOAT */ - { 266, -2 }, /* (245) expr ::= MINUS FLOAT */ - { 266, -2 }, /* (246) expr ::= PLUS FLOAT */ - { 266, -1 }, /* (247) expr ::= STRING */ - { 266, -1 }, /* (248) expr ::= NOW */ - { 266, -1 }, /* (249) expr ::= VARIABLE */ - { 266, -2 }, /* (250) expr ::= PLUS VARIABLE */ - { 266, -2 }, /* (251) expr ::= MINUS VARIABLE */ - { 266, -1 }, /* (252) expr ::= BOOL */ - { 266, -1 }, /* (253) expr ::= NULL */ - { 266, -4 }, /* (254) expr ::= ID LP exprlist RP */ - { 266, -4 }, /* (255) expr ::= ID LP STAR RP */ - { 266, -3 }, /* (256) expr ::= expr IS NULL */ - { 266, -4 }, /* (257) expr ::= expr IS NOT NULL */ - { 266, -3 }, /* (258) expr ::= expr LT expr */ - { 266, -3 }, /* (259) expr ::= expr GT expr */ - { 266, -3 }, /* (260) expr ::= expr LE expr */ - { 266, -3 }, /* (261) expr ::= expr GE expr */ - { 266, -3 }, /* (262) expr ::= expr NE expr */ - { 266, -3 }, /* (263) expr ::= expr EQ expr */ - { 266, -5 }, /* (264) expr ::= expr BETWEEN expr AND expr */ - { 266, -3 }, /* (265) expr ::= expr AND expr */ - { 266, -3 }, /* (266) expr ::= expr OR expr */ - { 266, -3 }, /* (267) expr ::= expr PLUS expr */ - { 266, -3 }, /* (268) expr ::= expr MINUS expr */ - { 266, -3 }, /* (269) expr ::= expr STAR expr */ - { 266, -3 }, /* (270) expr ::= expr SLASH expr */ - { 266, -3 }, /* (271) expr ::= expr REM expr */ - { 266, -3 }, /* (272) expr ::= expr LIKE expr */ - { 266, -3 }, /* (273) expr ::= expr MATCH expr */ - { 266, -3 }, /* (274) expr ::= expr NMATCH expr */ - { 266, -5 }, /* (275) expr ::= expr IN LP exprlist RP */ - { 206, -3 }, /* (276) exprlist ::= exprlist COMMA expritem */ - { 206, -1 }, /* (277) exprlist ::= expritem */ - { 277, -1 }, /* (278) expritem ::= expr */ - { 277, 0 }, /* (279) expritem ::= */ - { 199, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ - { 199, -3 }, /* (281) cmd ::= SYNCDB ids REPLICA */ - { 199, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 199, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 199, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 199, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 199, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 199, -8 }, /* (287) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 199, -9 }, /* (288) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 199, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 199, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 199, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 199, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 199, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 199, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 199, -8 }, /* (295) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 199, -9 }, /* (296) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 199, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 199, -3 }, /* (298) cmd ::= KILL CONNECTION INTEGER */ - { 199, -5 }, /* (299) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 199, -5 }, /* (300) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 192, -1 }, /* (0) program ::= cmd */ + { 193, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 193, -2 }, /* (2) cmd ::= SHOW TOPICS */ + { 193, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ + { 193, -2 }, /* (4) cmd ::= SHOW MNODES */ + { 193, -2 }, /* (5) cmd ::= SHOW DNODES */ + { 193, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ + { 193, -2 }, /* (7) cmd ::= SHOW USERS */ + { 193, -2 }, /* (8) cmd ::= SHOW MODULES */ + { 193, -2 }, /* (9) cmd ::= SHOW QUERIES */ + { 193, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ + { 193, -2 }, /* (11) cmd ::= SHOW STREAMS */ + { 193, -2 }, /* (12) cmd ::= SHOW VARIABLES */ + { 193, -2 }, /* (13) cmd ::= SHOW SCORES */ + { 193, -2 }, /* (14) cmd ::= SHOW GRANTS */ + { 193, -2 }, /* (15) cmd ::= SHOW VNODES */ + { 193, -3 }, /* (16) cmd ::= SHOW VNODES ids */ + { 195, 0 }, /* (17) dbPrefix ::= */ + { 195, -2 }, /* (18) dbPrefix ::= ids DOT */ + { 196, 0 }, /* (19) cpxName ::= */ + { 196, -2 }, /* (20) cpxName ::= DOT ids */ + { 193, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 193, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ + { 193, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ + { 193, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ + { 193, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 193, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ + { 193, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 193, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + { 193, -4 }, /* (29) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 193, -5 }, /* (30) cmd ::= DROP TABLE ifexists ids cpxName */ + { 193, -5 }, /* (31) cmd ::= DROP STABLE ifexists ids cpxName */ + { 193, -4 }, /* (32) cmd ::= DROP DATABASE ifexists ids */ + { 193, -4 }, /* (33) cmd ::= DROP TOPIC ifexists ids */ + { 193, -3 }, /* (34) cmd ::= DROP FUNCTION ids */ + { 193, -3 }, /* (35) cmd ::= DROP DNODE ids */ + { 193, -3 }, /* (36) cmd ::= DROP USER ids */ + { 193, -3 }, /* (37) cmd ::= DROP ACCOUNT ids */ + { 193, -2 }, /* (38) cmd ::= USE ids */ + { 193, -3 }, /* (39) cmd ::= DESCRIBE ids cpxName */ + { 193, -3 }, /* (40) cmd ::= DESC ids cpxName */ + { 193, -5 }, /* (41) cmd ::= ALTER USER ids PASS ids */ + { 193, -5 }, /* (42) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 193, -4 }, /* (43) cmd ::= ALTER DNODE ids ids */ + { 193, -5 }, /* (44) cmd ::= ALTER DNODE ids ids ids */ + { 193, -3 }, /* (45) cmd ::= ALTER LOCAL ids */ + { 193, -4 }, /* (46) cmd ::= ALTER LOCAL ids ids */ + { 193, -4 }, /* (47) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 193, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 193, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 193, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ + { 194, -1 }, /* (51) ids ::= ID */ + { 194, -1 }, /* (52) ids ::= STRING */ + { 197, -2 }, /* (53) ifexists ::= IF EXISTS */ + { 197, 0 }, /* (54) ifexists ::= */ + { 201, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */ + { 201, 0 }, /* (56) ifnotexists ::= */ + { 193, -5 }, /* (57) cmd ::= CREATE DNODE ids PORT ids */ + { 193, -5 }, /* (58) cmd ::= CREATE DNODE IPTOKEN PORT ids */ + { 193, -6 }, /* (59) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 193, -5 }, /* (60) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 193, -8 }, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 193, -9 }, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 193, -5 }, /* (63) cmd ::= CREATE USER ids PASS ids */ + { 204, 0 }, /* (64) bufsize ::= */ + { 204, -2 }, /* (65) bufsize ::= BUFSIZE INTEGER */ + { 205, 0 }, /* (66) pps ::= */ + { 205, -2 }, /* (67) pps ::= PPS INTEGER */ + { 206, 0 }, /* (68) tseries ::= */ + { 206, -2 }, /* (69) tseries ::= TSERIES INTEGER */ + { 207, 0 }, /* (70) dbs ::= */ + { 207, -2 }, /* (71) dbs ::= DBS INTEGER */ + { 208, 0 }, /* (72) streams ::= */ + { 208, -2 }, /* (73) streams ::= STREAMS INTEGER */ + { 209, 0 }, /* (74) storage ::= */ + { 209, -2 }, /* (75) storage ::= STORAGE INTEGER */ + { 210, 0 }, /* (76) qtime ::= */ + { 210, -2 }, /* (77) qtime ::= QTIME INTEGER */ + { 211, 0 }, /* (78) users ::= */ + { 211, -2 }, /* (79) users ::= USERS INTEGER */ + { 212, 0 }, /* (80) conns ::= */ + { 212, -2 }, /* (81) conns ::= CONNS INTEGER */ + { 213, 0 }, /* (82) state ::= */ + { 213, -2 }, /* (83) state ::= STATE ids */ + { 199, -9 }, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 214, -3 }, /* (85) intitemlist ::= intitemlist COMMA intitem */ + { 214, -1 }, /* (86) intitemlist ::= intitem */ + { 215, -1 }, /* (87) intitem ::= INTEGER */ + { 216, -2 }, /* (88) keep ::= KEEP intitemlist */ + { 217, -2 }, /* (89) cache ::= CACHE INTEGER */ + { 218, -2 }, /* (90) replica ::= REPLICA INTEGER */ + { 219, -2 }, /* (91) quorum ::= QUORUM INTEGER */ + { 220, -2 }, /* (92) days ::= DAYS INTEGER */ + { 221, -2 }, /* (93) minrows ::= MINROWS INTEGER */ + { 222, -2 }, /* (94) maxrows ::= MAXROWS INTEGER */ + { 223, -2 }, /* (95) blocks ::= BLOCKS INTEGER */ + { 224, -2 }, /* (96) ctime ::= CTIME INTEGER */ + { 225, -2 }, /* (97) wal ::= WAL INTEGER */ + { 226, -2 }, /* (98) fsync ::= FSYNC INTEGER */ + { 227, -2 }, /* (99) comp ::= COMP INTEGER */ + { 228, -2 }, /* (100) prec ::= PRECISION STRING */ + { 229, -2 }, /* (101) update ::= UPDATE INTEGER */ + { 230, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */ + { 202, 0 }, /* (103) db_optr ::= */ + { 202, -2 }, /* (104) db_optr ::= db_optr cache */ + { 202, -2 }, /* (105) db_optr ::= db_optr replica */ + { 202, -2 }, /* (106) db_optr ::= db_optr quorum */ + { 202, -2 }, /* (107) db_optr ::= db_optr days */ + { 202, -2 }, /* (108) db_optr ::= db_optr minrows */ + { 202, -2 }, /* (109) db_optr ::= db_optr maxrows */ + { 202, -2 }, /* (110) db_optr ::= db_optr blocks */ + { 202, -2 }, /* (111) db_optr ::= db_optr ctime */ + { 202, -2 }, /* (112) db_optr ::= db_optr wal */ + { 202, -2 }, /* (113) db_optr ::= db_optr fsync */ + { 202, -2 }, /* (114) db_optr ::= db_optr comp */ + { 202, -2 }, /* (115) db_optr ::= db_optr prec */ + { 202, -2 }, /* (116) db_optr ::= db_optr keep */ + { 202, -2 }, /* (117) db_optr ::= db_optr update */ + { 202, -2 }, /* (118) db_optr ::= db_optr cachelast */ + { 198, 0 }, /* (119) alter_db_optr ::= */ + { 198, -2 }, /* (120) alter_db_optr ::= alter_db_optr replica */ + { 198, -2 }, /* (121) alter_db_optr ::= alter_db_optr quorum */ + { 198, -2 }, /* (122) alter_db_optr ::= alter_db_optr keep */ + { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr blocks */ + { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr comp */ + { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr update */ + { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr cachelast */ + { 203, -1 }, /* (127) typename ::= ids */ + { 203, -4 }, /* (128) typename ::= ids LP signed RP */ + { 203, -2 }, /* (129) typename ::= ids UNSIGNED */ + { 231, -1 }, /* (130) signed ::= INTEGER */ + { 231, -2 }, /* (131) signed ::= PLUS INTEGER */ + { 231, -2 }, /* (132) signed ::= MINUS INTEGER */ + { 193, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ + { 193, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ + { 193, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ + { 193, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ + { 234, -1 }, /* (137) create_table_list ::= create_from_stable */ + { 234, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ + { 232, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 233, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 235, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + { 235, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + { 238, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ + { 238, -1 }, /* (144) tagNamelist ::= ids */ + { 232, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ + { 236, -3 }, /* (146) columnlist ::= columnlist COMMA column */ + { 236, -1 }, /* (147) columnlist ::= column */ + { 240, -2 }, /* (148) column ::= ids typename */ + { 237, -3 }, /* (149) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ + { 237, -1 }, /* (150) tagitemlist1 ::= tagitem1 */ + { 241, -2 }, /* (151) tagitem1 ::= MINUS INTEGER */ + { 241, -2 }, /* (152) tagitem1 ::= MINUS FLOAT */ + { 241, -2 }, /* (153) tagitem1 ::= PLUS INTEGER */ + { 241, -2 }, /* (154) tagitem1 ::= PLUS FLOAT */ + { 241, -1 }, /* (155) tagitem1 ::= INTEGER */ + { 241, -1 }, /* (156) tagitem1 ::= FLOAT */ + { 241, -1 }, /* (157) tagitem1 ::= STRING */ + { 241, -1 }, /* (158) tagitem1 ::= BOOL */ + { 241, -1 }, /* (159) tagitem1 ::= NULL */ + { 241, -1 }, /* (160) tagitem1 ::= NOW */ + { 242, -3 }, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ + { 242, -1 }, /* (162) tagitemlist ::= tagitem */ + { 243, -1 }, /* (163) tagitem ::= INTEGER */ + { 243, -1 }, /* (164) tagitem ::= FLOAT */ + { 243, -1 }, /* (165) tagitem ::= STRING */ + { 243, -1 }, /* (166) tagitem ::= BOOL */ + { 243, -1 }, /* (167) tagitem ::= NULL */ + { 243, -1 }, /* (168) tagitem ::= NOW */ + { 243, -2 }, /* (169) tagitem ::= MINUS INTEGER */ + { 243, -2 }, /* (170) tagitem ::= MINUS FLOAT */ + { 243, -2 }, /* (171) tagitem ::= PLUS INTEGER */ + { 243, -2 }, /* (172) tagitem ::= PLUS FLOAT */ + { 239, -14 }, /* (173) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 239, -3 }, /* (174) select ::= LP select RP */ + { 257, -1 }, /* (175) union ::= select */ + { 257, -4 }, /* (176) union ::= union UNION ALL select */ + { 257, -3 }, /* (177) union ::= union UNION select */ + { 193, -1 }, /* (178) cmd ::= union */ + { 239, -2 }, /* (179) select ::= SELECT selcollist */ + { 258, -2 }, /* (180) sclp ::= selcollist COMMA */ + { 258, 0 }, /* (181) sclp ::= */ + { 244, -4 }, /* (182) selcollist ::= sclp distinct expr as */ + { 244, -2 }, /* (183) selcollist ::= sclp STAR */ + { 261, -2 }, /* (184) as ::= AS ids */ + { 261, -1 }, /* (185) as ::= ids */ + { 261, 0 }, /* (186) as ::= */ + { 259, -1 }, /* (187) distinct ::= DISTINCT */ + { 259, 0 }, /* (188) distinct ::= */ + { 245, -2 }, /* (189) from ::= FROM tablelist */ + { 245, -2 }, /* (190) from ::= FROM sub */ + { 263, -3 }, /* (191) sub ::= LP union RP */ + { 263, -4 }, /* (192) sub ::= LP union RP ids */ + { 263, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */ + { 262, -2 }, /* (194) tablelist ::= ids cpxName */ + { 262, -3 }, /* (195) tablelist ::= ids cpxName ids */ + { 262, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */ + { 262, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */ + { 264, -1 }, /* (198) tmvar ::= VARIABLE */ + { 247, -4 }, /* (199) interval_option ::= intervalKey LP tmvar RP */ + { 247, -6 }, /* (200) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 247, 0 }, /* (201) interval_option ::= */ + { 265, -1 }, /* (202) intervalKey ::= INTERVAL */ + { 265, -1 }, /* (203) intervalKey ::= EVERY */ + { 249, 0 }, /* (204) session_option ::= */ + { 249, -7 }, /* (205) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 250, 0 }, /* (206) windowstate_option ::= */ + { 250, -4 }, /* (207) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 251, 0 }, /* (208) fill_opt ::= */ + { 251, -6 }, /* (209) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 251, -4 }, /* (210) fill_opt ::= FILL LP ID RP */ + { 248, -4 }, /* (211) sliding_opt ::= SLIDING LP tmvar RP */ + { 248, 0 }, /* (212) sliding_opt ::= */ + { 254, 0 }, /* (213) orderby_opt ::= */ + { 254, -3 }, /* (214) orderby_opt ::= ORDER BY sortlist */ + { 266, -4 }, /* (215) sortlist ::= sortlist COMMA item sortorder */ + { 266, -2 }, /* (216) sortlist ::= item sortorder */ + { 268, -2 }, /* (217) item ::= ids cpxName */ + { 269, -1 }, /* (218) sortorder ::= ASC */ + { 269, -1 }, /* (219) sortorder ::= DESC */ + { 269, 0 }, /* (220) sortorder ::= */ + { 252, 0 }, /* (221) groupby_opt ::= */ + { 252, -3 }, /* (222) groupby_opt ::= GROUP BY grouplist */ + { 270, -3 }, /* (223) grouplist ::= grouplist COMMA item */ + { 270, -1 }, /* (224) grouplist ::= item */ + { 253, 0 }, /* (225) having_opt ::= */ + { 253, -2 }, /* (226) having_opt ::= HAVING expr */ + { 256, 0 }, /* (227) limit_opt ::= */ + { 256, -2 }, /* (228) limit_opt ::= LIMIT signed */ + { 256, -4 }, /* (229) limit_opt ::= LIMIT signed OFFSET signed */ + { 256, -4 }, /* (230) limit_opt ::= LIMIT signed COMMA signed */ + { 255, 0 }, /* (231) slimit_opt ::= */ + { 255, -2 }, /* (232) slimit_opt ::= SLIMIT signed */ + { 255, -4 }, /* (233) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 255, -4 }, /* (234) slimit_opt ::= SLIMIT signed COMMA signed */ + { 246, 0 }, /* (235) where_opt ::= */ + { 246, -2 }, /* (236) where_opt ::= WHERE expr */ + { 260, -3 }, /* (237) expr ::= LP expr RP */ + { 260, -1 }, /* (238) expr ::= ID */ + { 260, -3 }, /* (239) expr ::= ID DOT ID */ + { 260, -3 }, /* (240) expr ::= ID DOT STAR */ + { 260, -1 }, /* (241) expr ::= INTEGER */ + { 260, -2 }, /* (242) expr ::= MINUS INTEGER */ + { 260, -2 }, /* (243) expr ::= PLUS INTEGER */ + { 260, -1 }, /* (244) expr ::= FLOAT */ + { 260, -2 }, /* (245) expr ::= MINUS FLOAT */ + { 260, -2 }, /* (246) expr ::= PLUS FLOAT */ + { 260, -1 }, /* (247) expr ::= STRING */ + { 260, -1 }, /* (248) expr ::= NOW */ + { 260, -1 }, /* (249) expr ::= VARIABLE */ + { 260, -2 }, /* (250) expr ::= PLUS VARIABLE */ + { 260, -2 }, /* (251) expr ::= MINUS VARIABLE */ + { 260, -1 }, /* (252) expr ::= BOOL */ + { 260, -1 }, /* (253) expr ::= NULL */ + { 260, -4 }, /* (254) expr ::= ID LP exprlist RP */ + { 260, -4 }, /* (255) expr ::= ID LP STAR RP */ + { 260, -3 }, /* (256) expr ::= expr IS NULL */ + { 260, -4 }, /* (257) expr ::= expr IS NOT NULL */ + { 260, -3 }, /* (258) expr ::= expr LT expr */ + { 260, -3 }, /* (259) expr ::= expr GT expr */ + { 260, -3 }, /* (260) expr ::= expr LE expr */ + { 260, -3 }, /* (261) expr ::= expr GE expr */ + { 260, -3 }, /* (262) expr ::= expr NE expr */ + { 260, -3 }, /* (263) expr ::= expr EQ expr */ + { 260, -5 }, /* (264) expr ::= expr BETWEEN expr AND expr */ + { 260, -3 }, /* (265) expr ::= expr AND expr */ + { 260, -3 }, /* (266) expr ::= expr OR expr */ + { 260, -3 }, /* (267) expr ::= expr PLUS expr */ + { 260, -3 }, /* (268) expr ::= expr MINUS expr */ + { 260, -3 }, /* (269) expr ::= expr STAR expr */ + { 260, -3 }, /* (270) expr ::= expr SLASH expr */ + { 260, -3 }, /* (271) expr ::= expr REM expr */ + { 260, -3 }, /* (272) expr ::= expr LIKE expr */ + { 260, -3 }, /* (273) expr ::= expr MATCH expr */ + { 260, -3 }, /* (274) expr ::= expr NMATCH expr */ + { 260, -5 }, /* (275) expr ::= expr IN LP exprlist RP */ + { 200, -3 }, /* (276) exprlist ::= exprlist COMMA expritem */ + { 200, -1 }, /* (277) exprlist ::= expritem */ + { 271, -1 }, /* (278) expritem ::= expr */ + { 271, 0 }, /* (279) expritem ::= */ + { 193, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ + { 193, -3 }, /* (281) cmd ::= SYNCDB ids REPLICA */ + { 193, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (287) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (288) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 193, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (295) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (296) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 193, -3 }, /* (298) cmd ::= KILL CONNECTION INTEGER */ + { 193, -5 }, /* (299) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 193, -5 }, /* (300) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2409,7 +2395,7 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &t);} +{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &t);} break; case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy171);} @@ -2418,7 +2404,7 @@ static void yy_reduce( { setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} break; case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy421);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy413);} break; case 51: /* ids ::= ID */ case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); @@ -2444,13 +2430,13 @@ static void yy_reduce( { setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} break; case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy90, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &yymsp[-2].minor.yy0);} break; case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 1);} break; case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy100, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 2);} break; case 63: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2495,24 +2481,24 @@ static void yy_reduce( break; case 85: /* intitemlist ::= intitemlist COMMA intitem */ case 161: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==161); -{ yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1); } + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 86: /* intitemlist ::= intitem */ case 162: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==162); -{ yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); } - yymsp[0].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1); } + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 87: /* intitem ::= INTEGER */ case 163: /* tagitem ::= INTEGER */ yytestcase(yyruleno==163); case 164: /* tagitem ::= FLOAT */ yytestcase(yyruleno==164); case 165: /* tagitem ::= STRING */ yytestcase(yyruleno==165); case 166: /* tagitem ::= BOOL */ yytestcase(yyruleno==166); -{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy69 = yylhsminor.yy69; +{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy461 = yylhsminor.yy461; break; case 88: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy421 = yymsp[0].minor.yy421; } +{ yymsp[-1].minor.yy413 = yymsp[0].minor.yy413; } break; case 89: /* cache ::= CACHE INTEGER */ case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); @@ -2531,114 +2517,114 @@ static void yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 103: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy90);} +{setDefaultCreateDbOption(&yymsp[1].minor.yy254);} break; case 104: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 105: /* db_optr ::= db_optr replica */ case 120: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==120); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 106: /* db_optr ::= db_optr quorum */ case 121: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==121); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 107: /* db_optr ::= db_optr days */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 108: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 109: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 110: /* db_optr ::= db_optr blocks */ case 123: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==123); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 111: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 112: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 113: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 114: /* db_optr ::= db_optr comp */ case 124: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==124); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 115: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 116: /* db_optr ::= db_optr keep */ case 122: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==122); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.keep = yymsp[0].minor.yy421; } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.keep = yymsp[0].minor.yy413; } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 117: /* db_optr ::= db_optr update */ case 125: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==125); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 118: /* db_optr ::= db_optr cachelast */ case 126: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==126); -{ yylhsminor.yy90 = yymsp[-1].minor.yy90; yylhsminor.yy90.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy90 = yylhsminor.yy90; +{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 119: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy90);} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy254);} break; case 127: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy100, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy280, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy100 = yylhsminor.yy100; + yymsp[0].minor.yy280 = yylhsminor.yy280; break; case 128: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy325 <= 0) { + if (yymsp[-1].minor.yy157 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy100, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy325; // negative value of name length - tSetColumnType(&yylhsminor.yy100, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy157; // negative value of name length + tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy100 = yylhsminor.yy100; + yymsp[-3].minor.yy280 = yylhsminor.yy280; break; case 129: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy100, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy280, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy100 = yylhsminor.yy100; + yymsp[-1].minor.yy280 = yylhsminor.yy280; break; case 130: /* signed ::= INTEGER */ -{ yylhsminor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy325 = yylhsminor.yy325; +{ yylhsminor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy157 = yylhsminor.yy157; break; case 131: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy325 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 132: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy325 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} +{ yymsp[-1].minor.yy157 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 136: /* cmd ::= CREATE TABLE create_table_list */ { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;} @@ -2648,7 +2634,7 @@ static void yy_reduce( SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy152); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy544); pCreateTable->type = TSQL_CREATE_CTABLE; yylhsminor.yy438 = pCreateTable; } @@ -2656,14 +2642,14 @@ static void yy_reduce( break; case 138: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy152); + taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy544); yylhsminor.yy438 = yymsp[-1].minor.yy438; } yymsp[-1].minor.yy438 = yylhsminor.yy438; break; case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy421, NULL, NULL, TSQL_CREATE_TABLE); + yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy413, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -2673,7 +2659,7 @@ static void yy_reduce( break; case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, NULL, TSQL_CREATE_STABLE); + yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2685,29 +2671,29 @@ static void yy_reduce( { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy421, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy413, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy152 = yylhsminor.yy152; + yymsp[-9].minor.yy544 = yylhsminor.yy544; break; case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy152 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, yymsp[-1].minor.yy421, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy152 = yylhsminor.yy152; + yymsp[-12].minor.yy544 = yylhsminor.yy544; break; case 143: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413; } + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 144: /* tagNamelist ::= ids */ -{yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy421 = yylhsminor.yy421; +{yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy56, TSQL_CREATE_STREAM); + yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; @@ -2716,26 +2702,26 @@ static void yy_reduce( yymsp[-4].minor.yy438 = yylhsminor.yy438; break; case 146: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy100); yylhsminor.yy421 = yymsp[-2].minor.yy421; } - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy280); yylhsminor.yy413 = yymsp[-2].minor.yy413; } + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 147: /* columnlist ::= column */ -{yylhsminor.yy421 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy100);} - yymsp[0].minor.yy421 = yylhsminor.yy421; +{yylhsminor.yy413 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy280);} + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 148: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy100, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy100); + tSetColumnInfo(&yylhsminor.yy280, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy280); } - yymsp[-1].minor.yy100 = yylhsminor.yy100; + yymsp[-1].minor.yy280 = yylhsminor.yy280; break; case 149: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ -{ taosArrayPush(yymsp[-2].minor.yy421, &yymsp[0].minor.yy0); yylhsminor.yy421 = yymsp[-2].minor.yy421;} - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{ taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413;} + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 150: /* tagitemlist1 ::= tagitem1 */ -{ yylhsminor.yy421 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy421, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy421 = yylhsminor.yy421; +{ yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 151: /* tagitem1 ::= MINUS INTEGER */ case 152: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==152); @@ -2754,12 +2740,12 @@ static void yy_reduce( yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 167: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy69 = yylhsminor.yy69; +{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy461 = yylhsminor.yy461; break; case 168: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy69, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} - yymsp[0].minor.yy69 = yylhsminor.yy69; +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} + yymsp[0].minor.yy461 = yylhsminor.yy461; break; case 169: /* tagitem ::= MINUS INTEGER */ case 170: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==170); @@ -2769,60 +2755,60 @@ static void yy_reduce( yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - taosVariantCreate(&yylhsminor.yy69, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy69 = yylhsminor.yy69; + yymsp[-1].minor.yy461 = yylhsminor.yy461; break; case 173: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy421, yymsp[-11].minor.yy8, yymsp[-10].minor.yy439, yymsp[-4].minor.yy421, yymsp[-2].minor.yy421, &yymsp[-9].minor.yy400, &yymsp[-7].minor.yy147, &yymsp[-6].minor.yy40, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy421, &yymsp[0].minor.yy231, &yymsp[-1].minor.yy231, yymsp[-3].minor.yy439); + yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy413, yymsp[-11].minor.yy292, yymsp[-10].minor.yy370, yymsp[-4].minor.yy413, yymsp[-2].minor.yy413, &yymsp[-9].minor.yy136, &yymsp[-7].minor.yy251, &yymsp[-6].minor.yy256, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, &yymsp[0].minor.yy503, &yymsp[-1].minor.yy503, yymsp[-3].minor.yy370); } - yymsp[-13].minor.yy56 = yylhsminor.yy56; + yymsp[-13].minor.yy24 = yylhsminor.yy24; break; case 174: /* select ::= LP select RP */ -{yymsp[-2].minor.yy56 = yymsp[-1].minor.yy56;} +{yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24;} break; case 175: /* union ::= select */ -{ yylhsminor.yy149 = setSubclause(NULL, yymsp[0].minor.yy56); } - yymsp[0].minor.yy149 = yylhsminor.yy149; +{ yylhsminor.yy129 = setSubclause(NULL, yymsp[0].minor.yy24); } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 176: /* union ::= union UNION ALL select */ -{ yylhsminor.yy149 = appendSelectClause(yymsp[-3].minor.yy149, SQL_TYPE_UNIONALL, yymsp[0].minor.yy56); } - yymsp[-3].minor.yy149 = yylhsminor.yy149; +{ yylhsminor.yy129 = appendSelectClause(yymsp[-3].minor.yy129, SQL_TYPE_UNIONALL, yymsp[0].minor.yy24); } + yymsp[-3].minor.yy129 = yylhsminor.yy129; break; case 177: /* union ::= union UNION select */ -{ yylhsminor.yy149 = appendSelectClause(yymsp[-2].minor.yy149, SQL_TYPE_UNION, yymsp[0].minor.yy56); } - yymsp[-2].minor.yy149 = yylhsminor.yy149; +{ yylhsminor.yy129 = appendSelectClause(yymsp[-2].minor.yy129, SQL_TYPE_UNION, yymsp[0].minor.yy24); } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 178: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy149, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy129, NULL, TSDB_SQL_SELECT); } break; case 179: /* select ::= SELECT selcollist */ { - yylhsminor.yy56 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy421, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy413, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy56 = yylhsminor.yy56; + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; case 180: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy421 = yymsp[-1].minor.yy421;} - yymsp[-1].minor.yy421 = yylhsminor.yy421; +{yylhsminor.yy413 = yymsp[-1].minor.yy413;} + yymsp[-1].minor.yy413 = yylhsminor.yy413; break; case 181: /* sclp ::= */ case 213: /* orderby_opt ::= */ yytestcase(yyruleno==213); -{yymsp[1].minor.yy421 = 0;} +{yymsp[1].minor.yy413 = 0;} break; case 182: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy421 = tSqlExprListAppend(yymsp[-3].minor.yy421, yymsp[-1].minor.yy439, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy413 = tSqlExprListAppend(yymsp[-3].minor.yy413, yymsp[-1].minor.yy370, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy421 = yylhsminor.yy421; + yymsp[-3].minor.yy413 = yylhsminor.yy413; break; case 183: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy421 = tSqlExprListAppend(yymsp[-1].minor.yy421, pNode, 0, 0); + yylhsminor.yy413 = tSqlExprListAppend(yymsp[-1].minor.yy413, pNode, 0, 0); } - yymsp[-1].minor.yy421 = yylhsminor.yy421; + yymsp[-1].minor.yy413 = yylhsminor.yy413; break; case 184: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -2840,85 +2826,85 @@ static void yy_reduce( break; case 189: /* from ::= FROM tablelist */ case 190: /* from ::= FROM sub */ yytestcase(yyruleno==190); -{yymsp[-1].minor.yy8 = yymsp[0].minor.yy8;} +{yymsp[-1].minor.yy292 = yymsp[0].minor.yy292;} break; case 191: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy8 = addSubquery(NULL, yymsp[-1].minor.yy149, NULL);} +{yymsp[-2].minor.yy292 = addSubquery(NULL, yymsp[-1].minor.yy129, NULL);} break; case 192: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy8 = addSubquery(NULL, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} +{yymsp[-3].minor.yy292 = addSubquery(NULL, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} break; case 193: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy8 = addSubquery(yymsp[-5].minor.yy8, yymsp[-2].minor.yy149, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy8 = yylhsminor.yy8; +{yylhsminor.yy292 = addSubquery(yymsp[-5].minor.yy292, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy292 = yylhsminor.yy292; break; case 194: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy8 = yylhsminor.yy8; + yymsp[-1].minor.yy292 = yylhsminor.yy292; break; case 195: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy8 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy8 = yylhsminor.yy8; + yymsp[-2].minor.yy292 = yylhsminor.yy292; break; case 196: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy8 = setTableNameList(yymsp[-3].minor.yy8, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy292 = setTableNameList(yymsp[-3].minor.yy292, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy8 = yylhsminor.yy8; + yymsp[-3].minor.yy292 = yylhsminor.yy292; break; case 197: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy8 = setTableNameList(yymsp[-4].minor.yy8, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy292 = setTableNameList(yymsp[-4].minor.yy292, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy8 = yylhsminor.yy8; + yymsp[-4].minor.yy292 = yylhsminor.yy292; break; case 198: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 199: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy400.interval = yymsp[-1].minor.yy0; yylhsminor.yy400.offset.n = 0; yylhsminor.yy400.token = yymsp[-3].minor.yy104;} - yymsp[-3].minor.yy400 = yylhsminor.yy400; +{yylhsminor.yy136.interval = yymsp[-1].minor.yy0; yylhsminor.yy136.offset.n = 0; yylhsminor.yy136.token = yymsp[-3].minor.yy516;} + yymsp[-3].minor.yy136 = yylhsminor.yy136; break; case 200: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy400.interval = yymsp[-3].minor.yy0; yylhsminor.yy400.offset = yymsp[-1].minor.yy0; yylhsminor.yy400.token = yymsp[-5].minor.yy104;} - yymsp[-5].minor.yy400 = yylhsminor.yy400; +{yylhsminor.yy136.interval = yymsp[-3].minor.yy0; yylhsminor.yy136.offset = yymsp[-1].minor.yy0; yylhsminor.yy136.token = yymsp[-5].minor.yy516;} + yymsp[-5].minor.yy136 = yylhsminor.yy136; break; case 201: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy400, 0, sizeof(yymsp[1].minor.yy400));} +{memset(&yymsp[1].minor.yy136, 0, sizeof(yymsp[1].minor.yy136));} break; case 202: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy104 = TK_INTERVAL;} +{yymsp[0].minor.yy516 = TK_INTERVAL;} break; case 203: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy104 = TK_EVERY; } +{yymsp[0].minor.yy516 = TK_EVERY; } break; case 204: /* session_option ::= */ -{yymsp[1].minor.yy147.col.n = 0; yymsp[1].minor.yy147.gap.n = 0;} +{yymsp[1].minor.yy251.col.n = 0; yymsp[1].minor.yy251.gap.n = 0;} break; case 205: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy147.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy147.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy251.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy251.gap = yymsp[-1].minor.yy0; } break; case 206: /* windowstate_option ::= */ -{ yymsp[1].minor.yy40.col.n = 0; yymsp[1].minor.yy40.col.z = NULL;} +{ yymsp[1].minor.yy256.col.n = 0; yymsp[1].minor.yy256.col.z = NULL;} break; case 207: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy40.col = yymsp[-1].minor.yy0; } +{ yymsp[-3].minor.yy256.col = yymsp[-1].minor.yy0; } break; case 208: /* fill_opt ::= */ -{ yymsp[1].minor.yy421 = 0; } +{ yymsp[1].minor.yy413 = 0; } break; case 209: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -2926,14 +2912,14 @@ static void yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); taosVariantCreate(&A, yymsp[-3].minor.yy0.z, yymsp[-3].minor.yy0.n, yymsp[-3].minor.yy0.type); - tListItemInsert(yymsp[-1].minor.yy421, &A, -1, 0); - yymsp[-5].minor.yy421 = yymsp[-1].minor.yy421; + tListItemInsert(yymsp[-1].minor.yy413, &A, -1, 0); + yymsp[-5].minor.yy413 = yymsp[-1].minor.yy413; } break; case 210: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy421 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy413 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; case 211: /* sliding_opt ::= SLIDING LP tmvar RP */ @@ -2943,243 +2929,243 @@ static void yy_reduce( {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; case 214: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} +{yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;} break; case 215: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy421 = tListItemAppend(yymsp[-3].minor.yy421, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); + yylhsminor.yy413 = tListItemAppend(yymsp[-3].minor.yy413, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60); } - yymsp[-3].minor.yy421 = yylhsminor.yy421; + yymsp[-3].minor.yy413 = yylhsminor.yy413; break; case 216: /* sortlist ::= item sortorder */ { - yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[-1].minor.yy69, yymsp[0].minor.yy96); + yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60); } - yymsp[-1].minor.yy421 = yylhsminor.yy421; + yymsp[-1].minor.yy413 = yylhsminor.yy413; break; case 217: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - taosVariantCreate(&yylhsminor.yy69, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy69 = yylhsminor.yy69; + yymsp[-1].minor.yy461 = yylhsminor.yy461; break; case 218: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy96 = TSDB_ORDER_ASC; } +{ yymsp[0].minor.yy60 = TSDB_ORDER_ASC; } break; case 219: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy96 = TSDB_ORDER_DESC;} +{ yymsp[0].minor.yy60 = TSDB_ORDER_DESC;} break; case 220: /* sortorder ::= */ -{ yymsp[1].minor.yy96 = TSDB_ORDER_ASC; } +{ yymsp[1].minor.yy60 = TSDB_ORDER_ASC; } break; case 221: /* groupby_opt ::= */ -{ yymsp[1].minor.yy421 = 0;} +{ yymsp[1].minor.yy413 = 0;} break; case 222: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy421 = yymsp[0].minor.yy421;} +{ yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;} break; case 223: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy421 = tListItemAppend(yymsp[-2].minor.yy421, &yymsp[0].minor.yy69, -1); + yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1); } - yymsp[-2].minor.yy421 = yylhsminor.yy421; + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 224: /* grouplist ::= item */ { - yylhsminor.yy421 = tListItemAppend(NULL, &yymsp[0].minor.yy69, -1); + yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1); } - yymsp[0].minor.yy421 = yylhsminor.yy421; + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 225: /* having_opt ::= */ case 235: /* where_opt ::= */ yytestcase(yyruleno==235); case 279: /* expritem ::= */ yytestcase(yyruleno==279); -{yymsp[1].minor.yy439 = 0;} +{yymsp[1].minor.yy370 = 0;} break; case 226: /* having_opt ::= HAVING expr */ case 236: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==236); -{yymsp[-1].minor.yy439 = yymsp[0].minor.yy439;} +{yymsp[-1].minor.yy370 = yymsp[0].minor.yy370;} break; case 227: /* limit_opt ::= */ case 231: /* slimit_opt ::= */ yytestcase(yyruleno==231); -{yymsp[1].minor.yy231.limit = -1; yymsp[1].minor.yy231.offset = 0;} +{yymsp[1].minor.yy503.limit = -1; yymsp[1].minor.yy503.offset = 0;} break; case 228: /* limit_opt ::= LIMIT signed */ case 232: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==232); -{yymsp[-1].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-1].minor.yy231.offset = 0;} +{yymsp[-1].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-1].minor.yy503.offset = 0;} break; case 229: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} +{ yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;} break; case 230: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} +{ yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;} break; case 233: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy231.limit = yymsp[-2].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[0].minor.yy325;} +{yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;} break; case 234: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy231.limit = yymsp[0].minor.yy325; yymsp[-3].minor.yy231.offset = yymsp[-2].minor.yy325;} +{yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;} break; case 237: /* expr ::= LP expr RP */ -{yylhsminor.yy439 = yymsp[-1].minor.yy439; yylhsminor.yy439->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy439->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = yymsp[-1].minor.yy370; yylhsminor.yy370->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy370->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 238: /* expr ::= ID */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 239: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 240: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 241: /* expr ::= INTEGER */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 242: /* expr ::= MINUS INTEGER */ case 243: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==243); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy439 = yylhsminor.yy439; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy370 = yylhsminor.yy370; break; case 244: /* expr ::= FLOAT */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 245: /* expr ::= MINUS FLOAT */ case 246: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==246); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy439 = yylhsminor.yy439; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy370 = yylhsminor.yy370; break; case 247: /* expr ::= STRING */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 248: /* expr ::= NOW */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 249: /* expr ::= VARIABLE */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 250: /* expr ::= PLUS VARIABLE */ case 251: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==251); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy439 = yylhsminor.yy439; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy370 = yylhsminor.yy370; break; case 252: /* expr ::= BOOL */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 253: /* expr ::= NULL */ -{ yylhsminor.yy439 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 254: /* expr ::= ID LP exprlist RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(yymsp[-1].minor.yy421, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy439 = yylhsminor.yy439; +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(yymsp[-1].minor.yy413, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy370 = yylhsminor.yy370; break; case 255: /* expr ::= ID LP STAR RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy439 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy439 = yylhsminor.yy439; +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy370 = yylhsminor.yy370; break; case 256: /* expr ::= expr IS NULL */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, NULL, TK_ISNULL);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, NULL, TK_ISNULL);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 257: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-3].minor.yy439, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-3].minor.yy370, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy370 = yylhsminor.yy370; break; case 258: /* expr ::= expr LT expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LT);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LT);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 259: /* expr ::= expr GT expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GT);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GT);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 260: /* expr ::= expr LE expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LE);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LE);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 261: /* expr ::= expr GE expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_GE);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GE);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 262: /* expr ::= expr NE expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NE);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NE);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 263: /* expr ::= expr EQ expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_EQ);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_EQ);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 264: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy439); yylhsminor.yy439 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy439, yymsp[-2].minor.yy439, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy439, TK_LE), TK_AND);} - yymsp[-4].minor.yy439 = yylhsminor.yy439; +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy370); yylhsminor.yy370 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy370, yymsp[-2].minor.yy370, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy370, TK_LE), TK_AND);} + yymsp[-4].minor.yy370 = yylhsminor.yy370; break; case 265: /* expr ::= expr AND expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_AND);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_AND);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 266: /* expr ::= expr OR expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_OR); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_OR); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 267: /* expr ::= expr PLUS expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_PLUS); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_PLUS); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 268: /* expr ::= expr MINUS expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MINUS); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MINUS); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 269: /* expr ::= expr STAR expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_STAR); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_STAR); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 270: /* expr ::= expr SLASH expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_DIVIDE);} - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_DIVIDE);} + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 271: /* expr ::= expr REM expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_REM); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_REM); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 272: /* expr ::= expr LIKE expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_LIKE); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LIKE); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 273: /* expr ::= expr MATCH expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_MATCH); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MATCH); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 274: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-2].minor.yy439, yymsp[0].minor.yy439, TK_NMATCH); } - yymsp[-2].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NMATCH); } + yymsp[-2].minor.yy370 = yylhsminor.yy370; break; case 275: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy439 = tSqlExprCreate(yymsp[-4].minor.yy439, (tSqlExpr*)yymsp[-1].minor.yy421, TK_IN); } - yymsp[-4].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = tSqlExprCreate(yymsp[-4].minor.yy370, (tSqlExpr*)yymsp[-1].minor.yy413, TK_IN); } + yymsp[-4].minor.yy370 = yylhsminor.yy370; break; case 276: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy421 = tSqlExprListAppend(yymsp[-2].minor.yy421,yymsp[0].minor.yy439,0, 0);} - yymsp[-2].minor.yy421 = yylhsminor.yy421; +{yylhsminor.yy413 = tSqlExprListAppend(yymsp[-2].minor.yy413,yymsp[0].minor.yy370,0, 0);} + yymsp[-2].minor.yy413 = yylhsminor.yy413; break; case 277: /* exprlist ::= expritem */ -{yylhsminor.yy421 = tSqlExprListAppend(0,yymsp[0].minor.yy439,0, 0);} - yymsp[0].minor.yy421 = yylhsminor.yy421; +{yylhsminor.yy413 = tSqlExprListAppend(0,yymsp[0].minor.yy370,0, 0);} + yymsp[0].minor.yy413 = yylhsminor.yy413; break; case 278: /* expritem ::= expr */ -{yylhsminor.yy439 = yymsp[0].minor.yy439;} - yymsp[0].minor.yy439 = yylhsminor.yy439; +{yylhsminor.yy370 = yymsp[0].minor.yy370;} + yymsp[0].minor.yy370 = yylhsminor.yy370; break; case 280: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} @@ -3190,7 +3176,7 @@ static void yy_reduce( case 282: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3206,14 +3192,14 @@ static void yy_reduce( case 284: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 285: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3248,7 +3234,7 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy69, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy461, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); @@ -3257,14 +3243,14 @@ static void yy_reduce( case 289: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 290: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3282,14 +3268,14 @@ static void yy_reduce( case 292: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; case 293: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3324,7 +3310,7 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy69, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy461, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); @@ -3333,7 +3319,7 @@ static void yy_reduce( case 297: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy421, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; diff --git a/source/libs/parser/src/ttokenizer.c b/source/libs/parser/src/ttokenizer.c index 7800e53f1c..8e5b22aaa3 100644 --- a/source/libs/parser/src/ttokenizer.c +++ b/source/libs/parser/src/ttokenizer.c @@ -31,17 +31,17 @@ typedef struct SKeyword { static SKeyword keywordTable[] = { {"ID", TK_ID}, {"BOOL", TK_BOOL}, - {"TINYINT", TK_TINYINT}, - {"SMALLINT", TK_SMALLINT}, +// {"TINYINT", TK_TINYINT}, +// {"SMALLINT", TK_SMALLINT}, {"INTEGER", TK_INTEGER}, {"INT", TK_INTEGER}, - {"BIGINT", TK_BIGINT}, +// {"BIGINT", TK_BIGINT}, {"FLOAT", TK_FLOAT}, - {"DOUBLE", TK_DOUBLE}, +// {"DOUBLE", TK_DOUBLE}, {"STRING", TK_STRING}, {"TIMESTAMP", TK_TIMESTAMP}, - {"BINARY", TK_BINARY}, - {"NCHAR", TK_NCHAR}, +// {"BINARY", TK_BINARY}, +// {"NCHAR", TK_NCHAR}, {"OR", TK_OR}, {"AND", TK_AND}, {"NOT", TK_NOT}, From 0c0525860b2c755d5c75d26a34c5aac30b142fa6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 20:25:38 +0800 Subject: [PATCH 33/55] more --- include/common/tmsg.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f70977b849..68842eb3b9 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -20,6 +20,7 @@ extern "C" { #endif +#include "encode.h" #include "taosdef.h" #include "taoserror.h" #include "tcoding.h" @@ -1143,17 +1144,6 @@ typedef struct SVCreateTbReq { static FORCE_INLINE int tSerializeSVCreateTbReq(void** buf, const SVCreateTbReq* pReq) { int tlen = 0; - // uint8_t* pBuf = (uint8_t*)(*buf); - - // if (TD_RT_ENDIAN() == TD_LITTLE_ENDIAN) { - // pBuf += tPut(pBuf, pReq->ver, uint64_t); - // pBuf += tPut(pBuf, pReq->ttl, uint32_t); - // pBuf += tPut(pBuf, pReq->keep, uint32_t); - // } else { - // pBuf += tPutl(pBuf, pReq->ver, uint64_t); - // pBuf += tPutl(pBuf, pReq->ttl, uint32_t); - // pBuf += tPutl(pBuf, pReq->keep, uint32_t); - // } tlen += taosEncodeFixedU64(buf, pReq->ver); tlen += taosEncodeString(buf, pReq->name); From 1d94aaaa20a6d3226bc9edd3350b7f12de59a37d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 28 Dec 2021 20:41:13 +0800 Subject: [PATCH 34/55] more --- include/util/encode.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/util/encode.h b/include/util/encode.h index 03608e0a19..171590448b 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -17,6 +17,7 @@ #define _TD_UTIL_ENCODE_H_ #include "tcoding.h" +#include "tmacro.h" #ifdef __cplusplus extern "C" { From cfd231c93f2b9972dd34f92f1749f727ebab7267 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 04:51:05 -0800 Subject: [PATCH 35/55] minor changes --- source/dnode/mnode/impl/src/mnode.c | 10 +++++----- source/dnode/mnode/sdb/src/sdbFile.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 9281e46f4f..84076f8c0a 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -146,15 +146,15 @@ static int32_t mndInitSteps(SMnode *pMnode) { if (mndAllocStep(pMnode, "mnode-sdb", mndInitSdb, mndCleanupSdb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-trans", mndInitTrans, mndCleanupTrans) != 0) return -1; if (mndAllocStep(pMnode, "mnode-cluster", mndInitCluster, mndCleanupCluster) != 0) return -1; - if (mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode) != 0) return -1; if (mndAllocStep(pMnode, "mnode-mnode", mndInitMnode, mndCleanupMnode) != 0) return -1; - if (mndAllocStep(pMnode, "mnode-acct", mndInitAcct, mndCleanupAcct) != 0) return -1; - if (mndAllocStep(pMnode, "mnode-auth", mndInitAuth, mndCleanupAuth) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode) != 0) return -1; if (mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser) != 0) return -1; - if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-auth", mndInitAuth, mndCleanupAuth) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-acct", mndInitAcct, mndCleanupAcct) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-topic", mndInitTopic, mndCleanupTopic) != 0) return -1; if (mndAllocStep(pMnode, "mnode-vgroup", mndInitVgroup, mndCleanupVgroup) != 0) return -1; if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1; - if (mndAllocStep(pMnode, "mnode-topic", mndInitTopic, mndCleanupTopic) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; if (pMnode->clusterId <= 0) { if (mndAllocStep(pMnode, "mnode-sdb-deploy", mndDeploySdb, NULL) != 0) return -1; diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 7828e39e56..78cf0a3492 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -151,7 +151,7 @@ int32_t sdbWriteFile(SSdb *pSdb) { if (taosWriteFile(fd, pRaw, writeLen) != writeLen) { code = TAOS_SYSTEM_ERROR(terrno); taosHashCancelIterate(hash, ppRow); - free(pRaw); + sdbFreeRaw(pRaw); break; } @@ -159,7 +159,7 @@ int32_t sdbWriteFile(SSdb *pSdb) { if (taosWriteFile(fd, &cksum, sizeof(int32_t)) != sizeof(int32_t)) { code = TAOS_SYSTEM_ERROR(terrno); taosHashCancelIterate(hash, ppRow); - free(pRaw); + sdbFreeRaw(pRaw); break; } } else { @@ -168,7 +168,7 @@ int32_t sdbWriteFile(SSdb *pSdb) { break; } - free(pRaw); + sdbFreeRaw(pRaw); ppRow = taosHashIterate(hash, ppRow); } taosWUnLockLatch(pLock); From dbadbef31283d31b6ee30f5fb1d6c9c1ec85dd32 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 28 Dec 2021 22:37:32 +0800 Subject: [PATCH 36/55] add index write test --- source/libs/index/src/index.c | 54 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 06e7e8ba44..61f03547c0 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -34,9 +34,7 @@ int32_t indexInit() { return indexQhandle == NULL ? -1 : 0; // do nothing } -void indexCleanUp() { - taosCleanUpScheduler(indexQhandle); -} +void indexCleanUp() { taosCleanUpScheduler(indexQhandle); } static int uidCompare(const void* a, const void* b) { uint64_t u1 = *(uint64_t*)a; @@ -63,7 +61,9 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { // pthread_once(&isInit, indexInit); SIndex* sIdx = calloc(1, sizeof(SIndex)); - if (sIdx == NULL) { return -1; } + if (sIdx == NULL) { + return -1; + } #ifdef USE_LUCENE index_t* index = index_open(path); @@ -99,7 +99,9 @@ void indexClose(SIndex* sIdx) { void* iter = taosHashIterate(sIdx->colObj, NULL); while (iter) { IndexCache** pCache = iter; - if (*pCache) { indexCacheUnRef(*pCache); } + if (*pCache) { + indexCacheUnRef(*pCache); + } iter = taosHashIterate(sIdx->colObj, iter); } taosHashCleanup(sIdx->colObj); @@ -133,7 +135,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { for (int i = 0; i < taosArrayGetSize(fVals); i++) { SIndexTerm* p = taosArrayGetP(fVals, i); IndexCache** cache = taosHashGet(index->colObj, p->colName, p->nColName); - if (*cache == NULL) { + if (cache == NULL) { IndexCache* pCache = indexCacheCreate(index, p->colName, p->colType); taosHashPut(index->colObj, p->colName, p->nColName, &pCache, sizeof(void*)); } @@ -143,10 +145,11 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { for (int i = 0; i < taosArrayGetSize(fVals); i++) { SIndexTerm* p = taosArrayGetP(fVals, i); IndexCache** cache = taosHashGet(index->colObj, p->colName, p->nColName); - assert(*cache != NULL); int ret = indexCachePut(*cache, p, uid); - if (ret != 0) { return ret; } + if (ret != 0) { + return ret; + } } #endif @@ -234,7 +237,9 @@ void indexOptsDestroy(SIndexOpts* opts){ SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType opera) { SIndexMultiTermQuery* p = (SIndexMultiTermQuery*)malloc(sizeof(SIndexMultiTermQuery)); - if (p == NULL) { return NULL; } + if (p == NULL) { + return NULL; + } p->opera = opera; p->query = taosArrayInit(4, sizeof(SIndexTermQuery)); return p; @@ -253,15 +258,12 @@ int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EInde return 0; } -SIndexTerm* indexTermCreate(int64_t suid, - SIndexOperOnColumn oper, - uint8_t colType, - const char* colName, - int32_t nColName, - const char* colVal, - int32_t nColVal) { +SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colType, const char* colName, + int32_t nColName, const char* colVal, int32_t nColVal) { SIndexTerm* t = (SIndexTerm*)calloc(1, (sizeof(SIndexTerm))); - if (t == NULL) { return NULL; } + if (t == NULL) { + return NULL; + } t->suid = suid; t->operType = oper; @@ -282,9 +284,7 @@ void indexTermDestroy(SIndexTerm* p) { free(p); } -SIndexMultiTerm* indexMultiTermCreate() { - return taosArrayInit(4, sizeof(SIndexTerm*)); -} +SIndexMultiTerm* indexMultiTermCreate() { return taosArrayInit(4, sizeof(SIndexTerm*)); } int indexMultiTermAdd(SIndexMultiTerm* terms, SIndexTerm* term) { taosArrayPush(terms, &term); @@ -307,7 +307,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result IndexCache* cache = NULL; pthread_mutex_lock(&sIdx->mtx); IndexCache** pCache = taosHashGet(sIdx->colObj, colName, nColName); - if (*pCache == NULL) { + if (pCache == NULL) { pthread_mutex_unlock(&sIdx->mtx); return -1; } @@ -335,7 +335,9 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result return 0; } static void indexInterResultsDestroy(SArray* results) { - if (results == NULL) { return; } + if (results == NULL) { + return; + } size_t sz = taosArrayGetSize(results); for (size_t i = 0; i < sz; i++) { @@ -366,7 +368,9 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType } int indexFlushCacheTFile(SIndex* sIdx, void* cache) { - if (sIdx == NULL) { return -1; } + if (sIdx == NULL) { + return -1; + } indexWarn("suid %" PRIu64 " merge cache into tindex", sIdx->suid); IndexCache* pCache = (IndexCache*)cache; @@ -433,7 +437,9 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { indexError("faile to open file to write"); } else { int ret = tfileWriterPut(tw, result); - if (ret != 0) { indexError("faile to write into tindex "); } + if (ret != 0) { + indexError("faile to write into tindex "); + } } // not free later, just put int table cache indexCacheDestroyImm(pCache); From 4e94a21082705beeba16d38224537ebdeaaf5a61 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 28 Dec 2021 23:47:44 +0800 Subject: [PATCH 37/55] fix index search crash without tfile generated --- source/libs/index/src/index_tfile.c | 142 ++++++++++++++++++-------- source/libs/index/test/indexTests.cc | 146 +++++++++++++++++++-------- 2 files changed, 206 insertions(+), 82 deletions(-) diff --git a/source/libs/index/src/index_tfile.c b/source/libs/index/src/index_tfile.c index fc31ff3c29..271528a437 100644 --- a/source/libs/index/src/index_tfile.c +++ b/source/libs/index/src/index_tfile.c @@ -54,7 +54,9 @@ static void tfileSerialCacheKey(TFileCacheKey* key, char* buf); TFileCache* tfileCacheCreate(const char* path) { TFileCache* tcache = calloc(1, sizeof(TFileCache)); - if (tcache == NULL) { return NULL; } + if (tcache == NULL) { + return NULL; + } tcache->tableCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); tcache->capacity = 64; @@ -83,7 +85,10 @@ TFileCache* tfileCacheCreate(const char* path) { tfileReaderRef(reader); // loader fst and validate it TFileHeader* header = &reader->header; - TFileCacheKey key = {.suid = header->suid, .colName = header->colName, .nColName = strlen(header->colName), .colType = header->colType}; + TFileCacheKey key = {.suid = header->suid, + .colName = header->colName, + .nColName = strlen(header->colName), + .colType = header->colType}; char buf[128] = {0}; tfileSerialCacheKey(&key, buf); @@ -97,13 +102,16 @@ End: return NULL; } void tfileCacheDestroy(TFileCache* tcache) { - if (tcache == NULL) { return; } + if (tcache == NULL) { + return; + } // free table cache TFileReader** reader = taosHashIterate(tcache->tableCache, NULL); while (reader) { TFileReader* p = *reader; - indexInfo("drop table cache suid: %" PRIu64 ", colName: %s, colType: %d", p->header.suid, p->header.colName, p->header.colType); + indexInfo("drop table cache suid: %" PRIu64 ", colName: %s, colType: %d", p->header.suid, p->header.colName, + p->header.colType); tfileReaderUnRef(p); reader = taosHashIterate(tcache->tableCache, reader); @@ -116,10 +124,13 @@ TFileReader* tfileCacheGet(TFileCache* tcache, TFileCacheKey* key) { char buf[128] = {0}; tfileSerialCacheKey(key, buf); - TFileReader* reader = taosHashGet(tcache->tableCache, buf, strlen(buf)); - tfileReaderRef(reader); + TFileReader** reader = taosHashGet(tcache->tableCache, buf, strlen(buf)); + if (reader == NULL) { + return NULL; + } + tfileReaderRef(*reader); - return reader; + return *reader; } void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader) { char buf[128] = {0}; @@ -138,14 +149,17 @@ void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader) } TFileReader* tfileReaderCreate(WriterCtx* ctx) { TFileReader* reader = calloc(1, sizeof(TFileReader)); - if (reader == NULL) { return NULL; } + if (reader == NULL) { + return NULL; + } // T_REF_INC(reader); reader->ctx = ctx; if (0 != tfileReaderLoadHeader(reader)) { tfileReaderDestroy(reader); - indexError("failed to load index header, suid: %" PRIu64 ", colName: %s", reader->header.suid, reader->header.colName); + indexError("failed to load index header, suid: %" PRIu64 ", colName: %s", reader->header.suid, + reader->header.colName); return NULL; } @@ -158,7 +172,9 @@ TFileReader* tfileReaderCreate(WriterCtx* ctx) { return reader; } void tfileReaderDestroy(TFileReader* reader) { - if (reader == NULL) { return; } + if (reader == NULL) { + return; + } // T_REF_INC(reader); fstDestroy(reader->fst); writerCtxDestroy(reader->ctx); @@ -175,10 +191,12 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul uint64_t offset; FstSlice key = fstSliceCreate(term->colVal, term->nColVal); if (fstGet(reader->fst, &key, &offset)) { - indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName, term->colVal); + indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, found table info in tindex", term->suid, term->colName, + term->colVal); ret = tfileReaderLoadTableIds(reader, offset, result); } else { - indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName, term->colVal); + indexInfo("index: %" PRIu64 ", col: %s, colVal: %s, not found table info in tindex", term->suid, term->colName, + term->colVal); } fstSliceDestroy(&key); } else if (qtype == QUERY_PREFIX) { @@ -304,12 +322,16 @@ int tfileWriterPut(TFileWriter* tw, void* data) { return 0; } void tfileWriteClose(TFileWriter* tw) { - if (tw == NULL) { return; } + if (tw == NULL) { + return; + } writerCtxDestroy(tw->ctx); free(tw); } void tfileWriterDestroy(TFileWriter* tw) { - if (tw == NULL) { return; } + if (tw == NULL) { + return; + } writerCtxDestroy(tw->ctx); free(tw); @@ -317,29 +339,35 @@ void tfileWriterDestroy(TFileWriter* tw) { IndexTFile* indexTFileCreate(const char* path) { IndexTFile* tfile = calloc(1, sizeof(IndexTFile)); - if (tfile == NULL) { return NULL; } + if (tfile == NULL) { + return NULL; + } tfile->cache = tfileCacheCreate(path); return tfile; } -void IndexTFileDestroy(IndexTFile* tfile) { - free(tfile); -} +void IndexTFileDestroy(IndexTFile* tfile) { free(tfile); } int indexTFileSearch(void* tfile, SIndexTermQuery* query, SArray* result) { int ret = -1; - if (tfile == NULL) { return ret; } + if (tfile == NULL) { + return ret; + } IndexTFile* pTfile = (IndexTFile*)tfile; SIndexTerm* term = query->term; - TFileCacheKey key = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = term->nColName}; - TFileReader* reader = tfileCacheGet(pTfile->cache, &key); + TFileCacheKey key = { + .suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = term->nColName}; + TFileReader* reader = tfileCacheGet(pTfile->cache, &key); + if (reader == NULL) { + return 0; + } return tfileReaderSearch(reader, query, result); } int indexTFilePut(void* tfile, SIndexTerm* term, uint64_t uid) { - // TFileWriterOpt wOpt = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = term->nColName, .version = - // 1}; + // TFileWriterOpt wOpt = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = + // term->nColName, .version = 1}; return 0; } @@ -353,7 +381,9 @@ static bool tfileIteratorNext(Iterate* iiter) { TFileFstIter* tIter = iiter->iter; StreamWithStateResult* rt = streamWithStateNextWith(tIter->st, NULL); - if (rt == NULL) { return false; } + if (rt == NULL) { + return false; + } int32_t sz = 0; char* ch = (char*)fstSliceData(&rt->data, &sz); @@ -364,20 +394,22 @@ static bool tfileIteratorNext(Iterate* iiter) { swsResultDestroy(rt); // set up iterate value - if (tfileReaderLoadTableIds(tIter->rdr, offset, iv->val) != 0) { return false; } + if (tfileReaderLoadTableIds(tIter->rdr, offset, iv->val) != 0) { + return false; + } iv->colVal = colVal; // std::string key(ch, sz); } -static IterateValue* tifileIterateGetValue(Iterate* iter) { - return &iter->val; -} +static IterateValue* tifileIterateGetValue(Iterate* iter) { return &iter->val; } static TFileFstIter* tfileFstIteratorCreate(TFileReader* reader) { TFileFstIter* tIter = calloc(1, sizeof(Iterate)); - if (tIter == NULL) { return NULL; } + if (tIter == NULL) { + return NULL; + } tIter->ctx = automCtxCreate(NULL, AUTOMATION_ALWAYS); tIter->fb = fstSearch(reader->fst, tIter->ctx); tIter->st = streamBuilderIntoStream(tIter->fb); @@ -389,14 +421,18 @@ Iterate* tfileIteratorCreate(TFileReader* reader) { Iterate* iter = calloc(1, sizeof(Iterate)); iter->iter = tfileFstIteratorCreate(reader); - if (iter->iter == NULL) { return NULL; } + if (iter->iter == NULL) { + return NULL; + } iter->next = tfileIteratorNext; iter->getValue = tifileIterateGetValue; return iter; } void tfileIteratorDestroy(Iterate* iter) { - if (iter == NULL) { return; } + if (iter == NULL) { + return; + } IterateValue* iv = &iter->val; iterateValueDestroy(iv, true); @@ -409,14 +445,18 @@ void tfileIteratorDestroy(Iterate* iter) { } TFileReader* tfileGetReaderByCol(IndexTFile* tf, char* colName) { - if (tf == NULL) { return NULL; } + if (tf == NULL) { + return NULL; + } TFileCacheKey key = {.suid = 0, .colType = TSDB_DATA_TYPE_BINARY, .colName = colName, .nColName = strlen(colName)}; return tfileCacheGet(tf->cache, &key); } static int tfileStrCompare(const void* a, const void* b) { int ret = strcmp((char*)a, (char*)b); - if (ret == 0) { return ret; } + if (ret == 0) { + return ret; + } return ret < 0 ? -1 : 1; } @@ -431,13 +471,17 @@ static int tfileValueCompare(const void* a, const void* b, const void* param) { TFileValue* tfileValueCreate(char* val) { TFileValue* tf = calloc(1, sizeof(TFileValue)); - if (tf == NULL) { return NULL; } + if (tf == NULL) { + return NULL; + } tf->tableId = taosArrayInit(32, sizeof(uint64_t)); return tf; } int tfileValuePush(TFileValue* tf, uint64_t val) { - if (tf == NULL) { return -1; } + if (tf == NULL) { + return -1; + } taosArrayPush(tf->tableId, &val); return 0; } @@ -457,7 +501,9 @@ static void tfileSerialTableIdsToBuf(char* buf, SArray* ids) { static int tfileWriteFstOffset(TFileWriter* tw, int32_t offset) { int32_t fstOffset = offset + sizeof(tw->header.fstOffset); tw->header.fstOffset = fstOffset; - if (sizeof(fstOffset) != tw->ctx->write(tw->ctx, (char*)&fstOffset, sizeof(fstOffset))) { return -1; } + if (sizeof(fstOffset) != tw->ctx->write(tw->ctx, (char*)&fstOffset, sizeof(fstOffset))) { + return -1; + } tw->offset += sizeof(fstOffset); return 0; } @@ -468,7 +514,9 @@ static int tfileWriteHeader(TFileWriter* writer) { memcpy(buf, (char*)header, sizeof(buf)); int nwrite = writer->ctx->write(writer->ctx, buf, sizeof(buf)); - if (sizeof(buf) != nwrite) { return -1; } + if (sizeof(buf) != nwrite) { + return -1; + } writer->offset = nwrite; return 0; } @@ -502,7 +550,9 @@ static int tfileReaderLoadFst(TFileReader* reader) { static int FST_MAX_SIZE = 16 * 1024; char* buf = calloc(1, sizeof(char) * FST_MAX_SIZE); - if (buf == NULL) { return -1; } + if (buf == NULL) { + return -1; + } WriterCtx* ctx = reader->ctx; int32_t nread = ctx->readFrom(ctx, buf, FST_MAX_SIZE, reader->header.fstOffset); @@ -525,7 +575,9 @@ static int tfileReaderLoadTableIds(TFileReader* reader, int32_t offset, SArray* int32_t total = sizeof(uint64_t) * nid; char* buf = calloc(1, total); - if (buf == NULL) { return -1; } + if (buf == NULL) { + return -1; + } nread = ctx->read(ctx, buf, total); assert(total == nread); @@ -543,12 +595,16 @@ void tfileReaderRef(TFileReader* reader) { void tfileReaderUnRef(TFileReader* reader) { int ref = T_REF_DEC(reader); - if (ref == 0) { tfileReaderDestroy(reader); } + if (ref == 0) { + tfileReaderDestroy(reader); + } } static int tfileGetFileList(const char* path, SArray* result) { DIR* dir = opendir(path); - if (NULL == dir) { return -1; } + if (NULL == dir) { + return -1; + } struct dirent* entry; while ((entry = readdir(dir)) != NULL) { @@ -576,7 +632,9 @@ static int tfileCompare(const void* a, const void* b) { size_t bLen = strlen(bName); int ret = strncmp(aName, bName, aLen > bLen ? aLen : bLen); - if (ret == 0) { return ret; } + if (ret == 0) { + return ret; + } return ret < 0 ? -1 : 1; } // tfile name suid-colId-version.tindex diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc index c75177b884..b3e385192f 100644 --- a/source/libs/index/test/indexTests.cc +++ b/source/libs/index/test/indexTests.cc @@ -2,7 +2,8 @@ * 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. + * 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 @@ -75,7 +76,9 @@ class FstReadMemory { bool init() { char* buf = (char*)calloc(1, sizeof(char) * _size); int nRead = fstCountingWriterRead(_w, (uint8_t*)buf, _size); - if (nRead <= 0) { return false; } + if (nRead <= 0) { + return false; + } _size = nRead; _s = fstSliceCreate((uint8_t*)buf, _size); _fst = fstCreate(&_s); @@ -179,7 +182,9 @@ void checkFstPerf() { delete fw; FstReadMemory* m = new FstReadMemory(1024 * 64); - if (m->init()) { printf("success to init fst read"); } + if (m->init()) { + printf("success to init fst read"); + } Performance_fstReadRecords(m); delete m; } @@ -283,7 +288,8 @@ class IndexEnv : public ::testing::Test { // / { // / std::string colName("tag1"), colVal("Hello world"); // / SIndexTerm* term = -// indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), / colVal.size()); +// indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), / +// colVal.size()); // SIndexMultiTerm* terms = indexMultiTermCreate(); // indexMultiTermAdd(terms, term); // / / for (size_t i = 0; i < 100; i++) { @@ -301,14 +307,16 @@ class IndexEnv : public ::testing::Test { // / { // / std::string colName("tag1"), colVal("Hello world"); // / SIndexTerm* term = -// / indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); +// / indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), +// colVal.size()); // / indexMultiTermAdd(terms, term); // / // } // / { // / std::string colName("tag2"), colVal("Hello world"); // / SIndexTerm* term = -// / indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); +// / indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), +// colVal.size()); // / indexMultiTermAdd(terms, term); // / // } @@ -327,7 +335,8 @@ class IndexEnv : public ::testing::Test { class TFileObj { public: - TFileObj(const std::string& path = "/tmp/tindex", const std::string& colName = "voltage") : path_(path), colName_(colName) { + TFileObj(const std::string& path = "/tmp/tindex", const std::string& colName = "voltage") + : path_(path), colName_(colName) { colId_ = 10; // Do Nothing // @@ -337,7 +346,9 @@ class TFileObj { tfileReaderDestroy(reader_); reader_ = NULL; } - if (writer_ == NULL) { InitWriter(); } + if (writer_ == NULL) { + InitWriter(); + } return tfileWriterPut(writer_, tv); } bool InitWriter() { @@ -377,8 +388,12 @@ class TFileObj { return tfileReaderSearch(reader_, query, result); } ~TFileObj() { - if (writer_) { tfileWriterDestroy(writer_); } - if (reader_) { tfileReaderDestroy(reader_); } + if (writer_) { + tfileWriterDestroy(writer_); + } + if (reader_) { + tfileReaderDestroy(reader_); + } } private: @@ -455,9 +470,10 @@ TEST_F(IndexTFileEnv, test_tfile_write) { } taosArrayDestroy(data); - std::string colName("voltage"); - std::string colVal("ab"); - SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + std::string colName("voltage"); + std::string colVal("ab"); + SIndexTerm* term = indexTermCreate(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); SIndexTermQuery query = {.term = term, .qType = QUERY_TERM}; SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t)); @@ -525,54 +541,62 @@ TEST_F(IndexCacheEnv, cache_test) { std::string colName("voltage"); { std::string colVal("v1"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } { std::string colVal("v3"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } { std::string colVal("v2"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } { std::string colVal("v3"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } { std::string colVal("v3"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } { std::string colVal("v3"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, othColId, version++, suid++); } { std::string colVal("v4"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, othColId, version++, suid++); } { std::string colVal("v4"); for (size_t i = 0; i < 10; i++) { colVal[colVal.size() - 1] = 'a' + i; - SIndexTerm* term = - indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); coj->Put(term, colId, version++, suid++); } } coj->Debug(); // begin query { - std::string colVal("v3"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + std::string colVal("v3"); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); SIndexTermQuery query = {.term = term, .qType = QUERY_TERM}; SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid)); STermValueType valType; @@ -582,8 +606,9 @@ TEST_F(IndexCacheEnv, cache_test) { assert(taosArrayGetSize(ret) == 4); } { - std::string colVal("v2"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); + std::string colVal("v2"); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); SIndexTermQuery query = {.term = term, .qType = QUERY_TERM}; SArray* ret = (SArray*)taosArrayInit(4, sizeof(suid)); STermValueType valType; @@ -651,32 +676,73 @@ class IndexEnv2 : public ::testing::Test { }; TEST_F(IndexEnv2, testIndexOpen) { std::string path = "/tmp"; - if (index->Init(path) != 0) {} - std::string colName("tag1"), colVal("Hello world"); - SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), colVal.c_str(), colVal.size()); - SIndexMultiTerm* terms = indexMultiTermCreate(); - indexMultiTermAdd(terms, term); - for (size_t i = 0; i < 100; i++) { - int tableId = i; - int ret = index->Put(terms, tableId); - assert(ret == 0); + if (index->Init(path) != 0) { + std::cout << "failed to init index" << std::endl; + exit(1); + } + + int targetSize = 100; + { + std::string colName("tag1"), colVal("Hello world"); + + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); + SIndexMultiTerm* terms = indexMultiTermCreate(); + indexMultiTermAdd(terms, term); + for (size_t i = 0; i < targetSize; i++) { + int tableId = i; + int ret = index->Put(terms, tableId); + assert(ret == 0); + } + indexMultiTermDestroy(terms); + } + { + size_t size = 100; + std::string colName("tag1"), colVal("hello world"); + + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); + SIndexMultiTerm* terms = indexMultiTermCreate(); + indexMultiTermAdd(terms, term); + for (size_t i = 0; i < size; i++) { + int tableId = i; + int ret = index->Put(terms, tableId); + assert(ret == 0); + } + indexMultiTermDestroy(terms); + } + + { + std::string colName("tag1"), colVal("Hello world"); + + SIndexMultiTermQuery* mq = indexMultiTermQueryCreate(MUST); + SIndexTerm* term = indexTermCreate(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(), + colVal.c_str(), colVal.size()); + indexMultiTermQueryAdd(mq, term, QUERY_TERM); + + SArray* result = (SArray*)taosArrayInit(1, sizeof(uint64_t)); + index->Search(mq, result); + assert(taosArrayGetSize(result) == targetSize); } - indexMultiTermDestroy(terms); } TEST_F(IndexEnv2, testIndex_CachePut) { std::string path = "/tmp"; - if (index->Init(path) != 0) {} + if (index->Init(path) != 0) { + } } TEST_F(IndexEnv2, testIndexr_TFilePut) { std::string path = "/tmp"; - if (index->Init(path) != 0) {} + if (index->Init(path) != 0) { + } } TEST_F(IndexEnv2, testIndex_CacheSearch) { std::string path = "/tmp"; - if (index->Init(path) != 0) {} + if (index->Init(path) != 0) { + } } TEST_F(IndexEnv2, testIndex_TFileSearch) { std::string path = "/tmp"; - if (index->Init(path) != 0) {} + if (index->Init(path) != 0) { + } } From 971efd7ef402577c49eb0f58eda654c4010a8ec5 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 29 Dec 2021 00:25:43 +0800 Subject: [PATCH 38/55] refactor code --- source/libs/index/inc/index_cache.h | 1 - source/libs/index/src/index.c | 14 ++-- source/libs/index/src/index_cache.c | 120 +++++++++++++++------------- 3 files changed, 71 insertions(+), 64 deletions(-) diff --git a/source/libs/index/inc/index_cache.h b/source/libs/index/inc/index_cache.h index 679de3c0a5..12b66bca2c 100644 --- a/source/libs/index/inc/index_cache.h +++ b/source/libs/index/inc/index_cache.h @@ -49,7 +49,6 @@ typedef struct IndexCache { #define CACHE_VERSION(cache) atomic_load_32(&cache->version) typedef struct CacheTerm { // key - int32_t nColVal; char* colVal; int32_t version; // value diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 61f03547c0..b78c4ff258 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -227,14 +227,15 @@ SIndexOpts* indexOptsCreate() { #endif return NULL; } -void indexOptsDestroy(SIndexOpts* opts){ +void indexOptsDestroy(SIndexOpts* opts) { #ifdef USE_LUCENE #endif -} /* - * @param: oper - * - */ - + return; +} +/* + * @param: oper + * + */ SIndexMultiTermQuery* indexMultiTermQueryCreate(EIndexOperatorType opera) { SIndexMultiTermQuery* p = (SIndexMultiTermQuery*)malloc(sizeof(SIndexMultiTermQuery)); if (p == NULL) { @@ -403,7 +404,6 @@ int indexFlushCacheTFile(SIndex* sIdx, void* cache) { TFileValue* tfv = tfileValueCreate(cv->colVal); taosArrayAddAll(tfv->tableId, cv->val); taosArrayPush(result, &tfv); - // copy to final Result; cn = cacheIter->next(cacheIter); } else { diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index f610ff9a11..217545d23b 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -23,21 +23,21 @@ #define MEM_TERM_LIMIT 1000000 // ref index_cache.h:22 //#define CACHE_KEY_LEN(p) \ -// (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + sizeof(p->operType)) +// (sizeof(int32_t) + sizeof(uint16_t) + sizeof(p->colType) + sizeof(p->nColVal) + p->nColVal + sizeof(uint64_t) + +// sizeof(p->operType)) -void indexMemRef(MemTable* tbl); -void indexMemUnRef(MemTable* tbl); +static void indexMemRef(MemTable* tbl); +static void indexMemUnRef(MemTable* tbl); -void indexCacheRef(IndexCache* cache); -void indexCacheUnRef(IndexCache* cache); +static void cacheTermDestroy(CacheTerm* ct); +static char* getIndexKey(const void* pData); +static int32_t compareKey(const void* l, const void* r); -static void cacheTermDestroy(CacheTerm* ct); -static char* getIndexKey(const void* pData); -static int32_t compareKey(const void* l, const void* r); static MemTable* indexInternalCacheCreate(int8_t type); -static void doMergeWork(SSchedMsg* msg); -static bool indexCacheIteratorNext(Iterate* itera); +static void doMergeWork(SSchedMsg* msg); +static bool indexCacheIteratorNext(Iterate* itera); + static IterateValue* indexCacheIteratorGetValue(Iterate* iter); IndexCache* indexCacheCreate(SIndex* idx, const char* colName, int8_t type) { @@ -86,7 +86,8 @@ void indexCacheDestroySkiplist(SSkipList* slt) { while (tSkipListIterNext(iter)) { SSkipListNode* node = tSkipListIterGet(iter); CacheTerm* ct = (CacheTerm*)SL_GET_NODE_DATA(node); - if (ct != NULL) {} + if (ct != NULL) { + } } tSkipListDestroyIter(iter); tSkipListDestroy(slt); @@ -101,7 +102,9 @@ void indexCacheDestroyImm(IndexCache* cache) { } void indexCacheDestroy(void* cache) { IndexCache* pCache = cache; - if (pCache == NULL) { return; } + if (pCache == NULL) { + return; + } indexMemUnRef(pCache->mem); indexMemUnRef(pCache->imm); free(pCache->colName); @@ -111,7 +114,9 @@ void indexCacheDestroy(void* cache) { Iterate* indexCacheIteratorCreate(IndexCache* cache) { Iterate* iiter = calloc(1, sizeof(Iterate)); - if (iiter == NULL) { return NULL; } + if (iiter == NULL) { + return NULL; + } MemTable* tbl = cache->imm; iiter->val.val = taosArrayInit(1, sizeof(uint64_t)); @@ -122,8 +127,9 @@ Iterate* indexCacheIteratorCreate(IndexCache* cache) { return iiter; } void indexCacheIteratorDestroy(Iterate* iter) { - if (iter == NULL) { return; } - + if (iter == NULL) { + return; + } tSkipListDestroyIter(iter->iter); iterateValueDestroy(&iter->val, true); free(iter); @@ -160,18 +166,21 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) { } int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) { - if (cache == NULL) { return -1; } + if (cache == NULL) { + return -1; + } IndexCache* pCache = cache; indexCacheRef(pCache); // encode data CacheTerm* ct = calloc(1, sizeof(CacheTerm)); - if (cache == NULL) { return -1; } + if (cache == NULL) { + return -1; + } // set up key ct->colType = term->colType; - ct->nColVal = term->nColVal; - ct->colVal = (char*)calloc(1, sizeof(char) * (ct->nColVal + 1)); - memcpy(ct->colVal, term->colVal, ct->nColVal); + ct->colVal = (char*)calloc(1, sizeof(char) * (term->nColVal + 1)); + memcpy(ct->colVal, term->colVal, term->nColVal); ct->version = atomic_add_fetch_32(&pCache->version, 1); // set value ct->uid = uid; @@ -197,7 +206,9 @@ int indexCacheDel(void* cache, const char* fieldValue, int32_t fvlen, uint64_t u return 0; } int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermValueType* s) { - if (cache == NULL) { return -1; } + if (cache == NULL) { + return -1; + } IndexCache* pCache = cache; SIndexTerm* term = query->term; EIndexQueryType qtype = query->qType; @@ -211,10 +222,11 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV pthread_mutex_unlock(&pCache->mtx); CacheTerm* ct = calloc(1, sizeof(CacheTerm)); - if (ct == NULL) { return -1; } - ct->nColVal = term->nColVal; - ct->colVal = calloc(1, sizeof(char) * (ct->nColVal + 1)); - memcpy(ct->colVal, term->colVal, ct->nColVal); + if (ct == NULL) { + return -1; + } + ct->colVal = calloc(1, sizeof(char) * (term->nColVal + 1)); + memcpy(ct->colVal, term->colVal, term->nColVal); ct->version = atomic_load_32(&pCache->version); char* key = getIndexKey(ct); @@ -225,7 +237,7 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV if (node != NULL) { CacheTerm* c = (CacheTerm*)SL_GET_NODE_DATA(node); if (c->operaType == ADD_VALUE || qtype == QUERY_TERM) { - if (c->nColVal == ct->nColVal && strncmp(c->colVal, ct->colVal, c->nColVal) == 0) { + if (strcmp(c->colVal, ct->colVal) == 0) { taosArrayPush(result, &c->uid); *s = kTypeValue; } else { @@ -257,26 +269,33 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV } void indexCacheRef(IndexCache* cache) { - if (cache == NULL) { return; } - + if (cache == NULL) { + return; + } int ref = T_REF_INC(cache); UNUSED(ref); } void indexCacheUnRef(IndexCache* cache) { - if (cache == NULL) { return; } - + if (cache == NULL) { + return; + } int ref = T_REF_DEC(cache); - if (ref == 0) { indexCacheDestroy(cache); } + if (ref == 0) { + indexCacheDestroy(cache); + } } void indexMemRef(MemTable* tbl) { - if (tbl == NULL) { return; } + if (tbl == NULL) { + return; + } int ref = T_REF_INC(tbl); UNUSED(ref); } void indexMemUnRef(MemTable* tbl) { - if (tbl == NULL) { return; } - + if (tbl == NULL) { + return; + } int ref = T_REF_DEC(tbl); if (ref == 0) { SSkipList* slt = tbl->mem; @@ -286,8 +305,9 @@ void indexMemUnRef(MemTable* tbl) { } static void cacheTermDestroy(CacheTerm* ct) { - if (ct == NULL) { return; } - + if (ct == NULL) { + return; + } free(ct->colVal); free(ct); } @@ -301,21 +321,11 @@ static int32_t compareKey(const void* l, const void* r) { CacheTerm* rt = (CacheTerm*)r; // compare colVal - int i, j; - for (i = 0, j = 0; i < lt->nColVal && j < rt->nColVal; i++, j++) { - if (lt->colVal[i] == rt->colVal[j]) { - continue; - } else { - return lt->colVal[i] < rt->colVal[j] ? -1 : 1; - } + int32_t cmp = strcmp(lt->colVal, rt->colVal); + if (cmp == 0) { + return rt->version - lt->version; } - if (i < lt->nColVal) { - return 1; - } else if (j < rt->nColVal) { - return -1; - } - // compare version - return rt->version - lt->version; + return cmp; } static MemTable* indexInternalCacheCreate(int8_t type) { @@ -334,8 +344,9 @@ static void doMergeWork(SSchedMsg* msg) { } static bool indexCacheIteratorNext(Iterate* itera) { SSkipListIterator* iter = itera->iter; - if (iter == NULL) { return false; } - + if (iter == NULL) { + return false; + } IterateValue* iv = &itera->val; iterateValueDestroy(iv, false); @@ -349,10 +360,7 @@ static bool indexCacheIteratorNext(Iterate* itera) { taosArrayPush(iv->val, &ct->uid); } - return next; } -static IterateValue* indexCacheIteratorGetValue(Iterate* iter) { - return &iter->val; -} +static IterateValue* indexCacheIteratorGetValue(Iterate* iter) { return &iter->val; } From 0d2ac682df70b1d8b49000a92455b4be5ea233de Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 29 Dec 2021 08:47:41 +0800 Subject: [PATCH 39/55] feature/qnode --- include/libs/catalog/catalog.h | 5 +- include/libs/scheduler/scheduler.h | 1 - source/libs/catalog/inc/catalogInt.h | 2 - source/libs/catalog/src/catalog.c | 123 +++++++++++++++----------- source/libs/scheduler/src/scheduler.c | 36 ++++++-- 5 files changed, 103 insertions(+), 64 deletions(-) diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index e55c2f57fd..a9abf45c8d 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -45,7 +45,6 @@ typedef struct SMetaData { } SMetaData; typedef struct SCatalogCfg { - bool enableVgroupCache; uint32_t maxTblCacheNum; uint32_t maxDBCacheNum; } SCatalogCfg; @@ -61,8 +60,8 @@ int32_t catalogInit(SCatalogCfg *cfg); int32_t catalogGetHandle(const char *clusterId, struct SCatalog** catalogHandle); int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName, int32_t* version); -int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* dbName, int32_t forceUpdate, SDBVgroupInfo* dbInfo); -int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName, SDBVgroupInfo* dbInfo); + +int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDBVgroupInfo* dbInfo); /** * Get a table's meta data. diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index fa1483de87..ddcfcab4db 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -24,7 +24,6 @@ extern "C" { #include "catalog.h" typedef struct SSchedulerCfg { - int32_t clusterType; int32_t maxJobNum; } SSchedulerCfg; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 820bcdfa3f..40943849f1 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -66,8 +66,6 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t); #define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0) #define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0) -#define CTG_CACHE_ENABLED() (ctgMgmt.cfg.maxDBCacheNum > 0 || ctgMgmt.cfg.maxTblCacheNum > 0) - #define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) #define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) #define CTG_ERR_LRET(c,...) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { ctgError(__VA_ARGS__); terrno = _code; return _code; } } while (0) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index edbe5f66ea..e067a7597a 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -370,6 +370,41 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out return TSDB_CODE_SUCCESS; } + +int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* dbName, int32_t forceUpdate, SDBVgroupInfo* dbInfo) { + if (NULL == pCatalog || NULL == dbName || NULL == pRpc || NULL == pMgmtEps) { + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t exist = 0; + + if (0 == forceUpdate) { + CTG_ERR_RET(ctgGetDBVgroupFromCache(pCatalog, dbName, dbInfo, &exist)); + + if (exist) { + return TSDB_CODE_SUCCESS; + } + } + + SUseDbOutput DbOut = {0}; + SBuildUseDBInput input = {0}; + + strncpy(input.db, dbName, sizeof(input.db)); + input.db[sizeof(input.db) - 1] = 0; + input.vgVersion = CTG_DEFAULT_INVALID_VERSION; + + CTG_ERR_RET(ctgGetDBVgroupFromMnode(pCatalog, pRpc, pMgmtEps, &input, &DbOut)); + + CTG_ERR_RET(catalogUpdateDBVgroup(pCatalog, dbName, &DbOut.dbVgroup)); + + if (dbInfo) { + *dbInfo = DbOut.dbVgroup; + } + + return TSDB_CODE_SUCCESS; +} + + int32_t catalogInit(SCatalogCfg *cfg) { if (ctgMgmt.pCluster) { ctgError("catalog already init"); @@ -378,16 +413,22 @@ int32_t catalogInit(SCatalogCfg *cfg) { if (cfg) { memcpy(&ctgMgmt.cfg, cfg, sizeof(*cfg)); + + if (ctgMgmt.cfg.maxDBCacheNum == 0) { + ctgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; + } + + if (ctgMgmt.cfg.maxTblCacheNum == 0) { + ctgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TABLEMETA_NUMBER; + } } else { ctgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; ctgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TABLEMETA_NUMBER; } - if (CTG_CACHE_ENABLED()) { - ctgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - if (NULL == ctgMgmt.pCluster) { - CTG_ERR_LRET(TSDB_CODE_CTG_INTERNAL_ERROR, "init %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER); - } + ctgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + if (NULL == ctgMgmt.pCluster) { + CTG_ERR_LRET(TSDB_CODE_CTG_INTERNAL_ERROR, "init %d cluster cache failed", CTG_DEFAULT_CACHE_CLUSTER_NUMBER); } return TSDB_CODE_SUCCESS; @@ -449,13 +490,19 @@ int32_t catalogGetDBVgroupVersion(struct SCatalog* pCatalog, const char* dbName, return TSDB_CODE_SUCCESS; } -int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName, SDBVgroupInfo* dbInfo) { +int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDBVgroupInfo* dbInfo) { if (NULL == pCatalog || NULL == dbName || NULL == dbInfo) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } if (dbInfo->vgVersion < 0) { if (pCatalog->dbCache.cache) { + SDBVgroupInfo *oldInfo = taosHashGet(pCatalog->dbCache.cache, dbName, strlen(dbName)); + if (oldInfo && oldInfo->vgInfo) { + taosHashCleanup(oldInfo->vgInfo); + oldInfo->vgInfo = NULL; + } + taosHashRemove(pCatalog->dbCache.cache, dbName, strlen(dbName)); } @@ -485,42 +532,6 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName return TSDB_CODE_SUCCESS; } - - - -int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* dbName, int32_t forceUpdate, SDBVgroupInfo* dbInfo) { - if (NULL == pCatalog || NULL == dbName || NULL == pRpc || NULL == pMgmtEps) { - CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); - } - - int32_t exist = 0; - - if (0 == forceUpdate) { - CTG_ERR_RET(ctgGetDBVgroupFromCache(pCatalog, dbName, dbInfo, &exist)); - - if (exist) { - return TSDB_CODE_SUCCESS; - } - } - - SUseDbOutput DbOut = {0}; - SBuildUseDBInput input = {0}; - - strncpy(input.db, dbName, sizeof(input.db)); - input.db[sizeof(input.db) - 1] = 0; - input.vgVersion = CTG_DEFAULT_INVALID_VERSION; - - CTG_ERR_RET(ctgGetDBVgroupFromMnode(pCatalog, pRpc, pMgmtEps, &input, &DbOut)); - - CTG_ERR_RET(catalogUpdateDBVgroupCache(pCatalog, dbName, &DbOut.dbVgroup)); - - if (dbInfo) { - *dbInfo = DbOut.dbVgroup; - } - - return TSDB_CODE_SUCCESS; -} - int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { return ctgGetTableMetaImpl(pCatalog, pTransporter, pMgmtEps, pDBName, pTableName, false, pTableMeta); } @@ -531,6 +542,7 @@ int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSe } SVgroupInfo vgroupInfo = {0}; + int32_t code = 0; CTG_ERR_RET(catalogGetTableHashVgroup(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &vgroupInfo)); @@ -540,11 +552,13 @@ int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSe CTG_ERR_RET(ctgGetTableMetaFromMnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &output)); - CTG_ERR_RET(ctgUpdateTableMetaCache(pCatalog, &output)); + CTG_ERR_JRET(ctgUpdateTableMetaCache(pCatalog, &output)); + +_return: tfree(output.tbMeta); - return TSDB_CODE_SUCCESS; + CTG_RET(code); } int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { @@ -563,7 +577,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S CTG_ERR_JRET(catalogGetTableMeta(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &tbMeta)); - CTG_ERR_JRET(catalogGetDBVgroup(pCatalog, pRpc, pMgmtEps, pDBName, false, &dbVgroup)); + CTG_ERR_JRET(ctgGetDBVgroup(pCatalog, pRpc, pMgmtEps, pDBName, false, &dbVgroup)); if (tbMeta->tableType == TSDB_SUPER_TABLE) { CTG_ERR_JRET(ctgGetVgInfoFromDB(pCatalog, pRpc, pMgmtEps, &dbVgroup, pVgroupList)); @@ -594,6 +608,7 @@ _return: tfree(tbMeta); taosArrayDestroy(*pVgroupList); + *pVgroupList = NULL; CTG_RET(code); } @@ -604,7 +619,7 @@ int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter, int32_t code = 0; int32_t vgId = 0; - CTG_ERR_RET(catalogGetDBVgroup(pCatalog, pTransporter, pMgmtEps, pDBName, false, &dbInfo)); + CTG_ERR_RET(ctgGetDBVgroup(pCatalog, pTransporter, pMgmtEps, pDBName, false, &dbInfo)); if (dbInfo.vgVersion < 0 || NULL == dbInfo.vgInfo) { ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", pDBName, dbInfo.vgVersion, dbInfo.vgInfo); @@ -627,12 +642,15 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p if (pReq->pTableName) { char dbName[TSDB_DB_FNAME_LEN]; int32_t tbNum = (int32_t)taosArrayGetSize(pReq->pTableName); - if (tbNum > 0) { - pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES); - if (NULL == pRsp->pTableMeta) { - ctgError("taosArrayInit num[%d] failed", tbNum); - CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); - } + if (tbNum <= 0) { + ctgError("empty table name list"); + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES); + if (NULL == pRsp->pTableMeta) { + ctgError("taosArrayInit num[%d] failed", tbNum); + CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } for (int32_t i = 0; i < tbNum; ++i) { @@ -663,6 +681,7 @@ _return: } taosArrayDestroy(pRsp->pTableMeta); + pRsp->pTableMeta = NULL; } CTG_RET(code); diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 4cde24e38c..7bd2205e43 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -791,9 +791,29 @@ void schDropJobAllTasks(SSchJob *job) { } } +uint64_t schGenSchId(void) { + uint64_t sId = 0; + + // TODO + + qDebug("Gen sId:0x%"PRIx64, sId); + + return sId; +} + + int32_t schedulerInit(SSchedulerCfg *cfg) { + if (schMgmt.jobs) { + qError("scheduler already init"); + return TSDB_CODE_QRY_INVALID_INPUT; + } + if (cfg) { schMgmt.cfg = *cfg; + + if (schMgmt.cfg.maxJobNum <= 0) { + schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_JOB_NUMBER; + } } else { schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_JOB_NUMBER; } @@ -803,18 +823,14 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { SCH_ERR_LRET(TSDB_CODE_QRY_OUT_OF_MEMORY, "init %d schduler jobs failed", schMgmt.cfg.maxJobNum); } - schMgmt.sId = 1; //TODO GENERATE A UUID + schMgmt.sId = schGenSchId(); return TSDB_CODE_SUCCESS; } int32_t scheduleExecJobImpl(void *transport, SArray *qnodeList, SQueryDag* pDag, void** pJob, bool syncSchedule) { - if (NULL == transport || NULL == transport ||NULL == pDag || NULL == pDag->pSubplans || NULL == pJob) { - SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } - - if (taosArrayGetSize(qnodeList) <= 0) { + if (qnodeList && taosArrayGetSize(qnodeList) <= 0) { qInfo("qnodeList is empty"); } @@ -882,6 +898,10 @@ _return: } int32_t scheduleExecJob(void *transport, SArray *qnodeList, SQueryDag* pDag, void** pJob, uint64_t *numOfRows) { + if (NULL == transport || /* NULL == qnodeList || */ NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == numOfRows) { + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + *numOfRows = 0; SCH_ERR_RET(scheduleExecJobImpl(transport, qnodeList, pDag, pJob, true)); @@ -894,6 +914,10 @@ int32_t scheduleExecJob(void *transport, SArray *qnodeList, SQueryDag* pDag, voi } int32_t scheduleAsyncExecJob(void *transport, SArray *qnodeList, SQueryDag* pDag, void** pJob) { + if (NULL == transport || NULL == qnodeList ||NULL == pDag || NULL == pDag->pSubplans || NULL == pJob) { + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + return scheduleExecJobImpl(transport, qnodeList, pDag, pJob, false); } From f1e40fcdceb59212557434470af5078e46ca5369 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 09:46:23 +0800 Subject: [PATCH 40/55] more --- include/util/encode.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/util/encode.h b/include/util/encode.h index 171590448b..0d19567efb 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -250,6 +250,21 @@ static FORCE_INLINE int tEncodeI64v(SEncoder* pEncoder, int64_t val) { return tEncodeU64v(pEncoder, ZIGZAGE(int64_t, val)); } +static FORCE_INLINE int tEncodeFloat(SEncoder* pEncoder, float val) { + // TODO + return 0; +} + +static FORCE_INLINE int tEncodeDouble(SEncoder* pEncoder, double val) { + // TODO + return 0; +} + +static FORCE_INLINE int tEncodeCStr(SEncoder* pEncoder, const char* val) { + // TODO + return 0; +} + /* ------------------------ FOR DECODER ------------------------ */ static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, uint8_t* data, int64_t size) { ASSERT(!TD_IS_NULL(data)); @@ -439,6 +454,21 @@ static FORCE_INLINE int tDecodeI64v(SDecoder* pDecoder, int64_t* val) { return 0; } +static FORCE_INLINE int tDecodeFloat(SDecoder* pDecoder, float* val) { + // TODO + return 0; +} + +static FORCE_INLINE int tDecodeDouble(SDecoder* pDecoder, double* val) { + // TODO + return 0; +} + +static FORCE_INLINE int tDecodeCStr(SDecoder* pEncoder, const char* val) { + // TODO + return 0; +} + #ifdef __cplusplus } #endif From f4df8612cb754df691a37f9438a343aaf6ef4137 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 09:47:38 +0800 Subject: [PATCH 41/55] more --- include/util/encode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/util/encode.h b/include/util/encode.h index 0d19567efb..ec4f53beb6 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -464,7 +464,7 @@ static FORCE_INLINE int tDecodeDouble(SDecoder* pDecoder, double* val) { return 0; } -static FORCE_INLINE int tDecodeCStr(SDecoder* pEncoder, const char* val) { +static FORCE_INLINE int tDecodeCStr(SDecoder* pEncoder, const char** val) { // TODO return 0; } From 4cb938540836139fc5712de9195e868730934e25 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 09:50:21 +0800 Subject: [PATCH 42/55] make compile --- include/util/encode.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/include/util/encode.h b/include/util/encode.h index ec4f53beb6..85be2b76c6 100644 --- a/include/util/encode.h +++ b/include/util/encode.h @@ -275,23 +275,23 @@ static FORCE_INLINE void tInitDecoder(SDecoder* pDecoder, td_endian_t endian, ui } // 8 -static FORCER_INLINE int tDecodeU8(SDecoder* pDecoder, uint8_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeU8(SDecoder* pDecoder, uint8_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; tGet(uint8_t, TD_CODER_CURRENT(pDecoder), *val); TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); return 0; } -static FORCER_INLINE int tDecodeI8(SDecoder* pDecoder, int8_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeI8(SDecoder* pDecoder, int8_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; tGet(int8_t, TD_CODER_CURRENT(pDecoder), *val); TD_CODER_MOVE_POS(pDecoder, sizeof(*val)); return 0; } // 16 -static FORCER_INLINE int tDecodeU16(SDecoder* pDecoder, uint16_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeU16(SDecoder* pDecoder, uint16_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(uint16_t, TD_CODER_CURRENT(pDecoder), *val); } else { @@ -302,8 +302,8 @@ static FORCER_INLINE int tDecodeU16(SDecoder* pDecoder, uint16_t* val) { return 0; } -static FORCER_INLINE int tDecodeI16(SDecoder* pDecoder, int16_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeI16(SDecoder* pDecoder, int16_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(int16_t, TD_CODER_CURRENT(pDecoder), *val); } else { @@ -315,8 +315,8 @@ static FORCER_INLINE int tDecodeI16(SDecoder* pDecoder, int16_t* val) { } // 32 -static FORCER_INLINE int tDecodeU32(SDecoder* pDecoder, uint32_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeU32(SDecoder* pDecoder, uint32_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(uint32_t, TD_CODER_CURRENT(pDecoder), *val); } else { @@ -327,8 +327,8 @@ static FORCER_INLINE int tDecodeU32(SDecoder* pDecoder, uint32_t* val) { return 0; } -static FORCER_INLINE int tDecodeI32(SDecoder* pDecoder, int32_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeI32(SDecoder* pDecoder, int32_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(int32_t, TD_CODER_CURRENT(pDecoder), *val); } else { @@ -340,8 +340,8 @@ static FORCER_INLINE int tDecodeI32(SDecoder* pDecoder, int32_t* val) { } // 64 -static FORCER_INLINE int tDecodeU64(SDecoder* pDecoder, uint64_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeU64(SDecoder* pDecoder, uint64_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(uint64_t, TD_CODER_CURRENT(pDecoder), *val); } else { @@ -352,8 +352,8 @@ static FORCER_INLINE int tDecodeU64(SDecoder* pDecoder, uint64_t* val) { return 0; } -static FORCER_INLINE int tDecodeI64(SDecoder* pDecoder, int64_t* val) { - if (TD_CHECK_CODER_CAPACITY_FAILED(pEncoder, sizeof(*val))) return -1; +static FORCE_INLINE int tDecodeI64(SDecoder* pDecoder, int64_t* val) { + if (TD_CHECK_CODER_CAPACITY_FAILED(pDecoder, sizeof(*val))) return -1; if (TD_RT_ENDIAN() == pDecoder->endian) { tGet(int64_t, TD_CODER_CURRENT(pDecoder), *val); } else { From f76f30ba6b4f45d515fea6a64c413822755d71ac Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 29 Dec 2021 11:42:39 +0800 Subject: [PATCH 43/55] [td-11818] refactor create child table procedure. --- include/libs/parser/parser.h | 2 +- source/client/src/clientImpl.c | 34 +- source/client/test/clientTests.cpp | 1 - source/libs/parser/inc/parserUtil.h | 13 +- source/libs/parser/src/dCDAstProcess.c | 19 +- source/libs/parser/src/insertParser.c | 464 +++++++++---------- source/libs/parser/src/parserUtil.c | 592 +++++++++++++------------ 7 files changed, 540 insertions(+), 585 deletions(-) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index 3cd5e3a379..dd3d92866f 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -27,7 +27,7 @@ typedef struct SParseContext { int8_t schemaAttached; // denote if submit block is built with table schema or not const char *pSql; // sql string size_t sqlLen; // length of the sql string - char *pMsg; // extended error message if exists to help avoid the problem in sql statement. + char *pMsg; // extended error message if exists to help identifying the problem in sql statement. int32_t msgLen; // max length of the msg } SParseContext; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 5885d10454..6ecd9a59f7 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -181,43 +181,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQueryNode* pQuery) { pRequest->body.requestMsg = (SDataBuf){.pData = pDcl->pMsg, .len = pDcl->msgLen}; STscObj* pTscObj = pRequest->pTscObj; - - SMsgSendInfo* pSendMsg = buildSendMsgInfoImpl(pRequest); - SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet; + int64_t transporterId = 0; if (pDcl->msgType == TDMT_VND_CREATE_TABLE) { -// struct SCatalog* pCatalog = NULL; -// -// char buf[18] = {0}; -// sprintf(buf, "%" PRId64, pRequest->pTscObj->pAppInfo->clusterId); -// int32_t code = catalogGetHandle(buf, &pCatalog); -// if (code != TSDB_CODE_SUCCESS) { -// return code; -// } -// -// SCreateTableMsg* pMsg = pSendMsg->msgInfo.pData; -// -// SName t = {0}; -// tNameFromString(&t, pMsg->name, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE); -// -// char db[TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_ACCT_ID_LEN] = {0}; -// tNameGetFullDbName(&t, db); -// -// SVgroupInfo info = {0}; -// catalogGetTableHashVgroup(pCatalog, pRequest->pTscObj->pTransporter, pEpSet, db, tNameGetTableName(&t), &info); -// - int64_t transporterId = 0; -// SEpSet ep = {0}; -// ep.inUse = info.inUse; -// ep.numOfEps = info.numOfEps; -// for(int32_t i = 0; i < ep.numOfEps; ++i) { -// ep.port[i] = info.epAddr[i].port; -// tstrncpy(ep.fqdn[i], info.epAddr[i].fqdn, tListLen(ep.fqdn[i])); -// } asyncSendMsgToServer(pTscObj->pTransporter, &pDcl->epSet, &transporterId, pSendMsg); } else { - int64_t transporterId = 0; + SEpSet* pEpSet = &pTscObj->pAppInfo->mgmtEp.epSet; asyncSendMsgToServer(pTscObj->pTransporter, pEpSet, &transporterId, pSendMsg); } diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 0a4519eabc..9616166e21 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -433,7 +433,6 @@ TEST(testCase, create_topic_Test) { taos_close(pConn); } - //TEST(testCase, show_table_Test) { // TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); // assert(pConn != NULL); diff --git a/source/libs/parser/inc/parserUtil.h b/source/libs/parser/inc/parserUtil.h index 3d8729e72d..b7c9f967c1 100644 --- a/source/libs/parser/inc/parserUtil.h +++ b/source/libs/parser/inc/parserUtil.h @@ -62,7 +62,7 @@ void cleanupTagCond(STagCond* pTagCond); void cleanupColumnCond(SArray** pCond); uint32_t convertRelationalOperator(SToken *pToken); -int32_t getExprFunctionId(SExprInfo *pExprInfo); +int32_t getExprFunctionId(SExprInfo *pExprInfo); STableMeta* tableMetaDup(const STableMeta* pTableMeta); @@ -70,6 +70,17 @@ bool isDclSqlStatement(SSqlInfo* pSqlInfo); bool isDdlSqlStatement(SSqlInfo* pSqlInfo); bool isDqlSqlStatement(SSqlInfo* pSqlInfo); +typedef struct SKvParam { + SKVRowBuilder *builder; + SSchema *schema; + char buf[TSDB_MAX_TAGS_LEN]; +} SKvParam; + +int32_t KvRowAppend(const void *value, int32_t len, void *param); + +typedef int32_t (*_row_append_fn_t)(const void *value, int32_t len, void *param); +int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf, _row_append_fn_t func, void* param, SMsgBuf* pMsgBuf); + #ifdef __cplusplus } #endif diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index f01338e051..51d4e14a2a 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -429,7 +429,6 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p SSchema *pSchema = &pTagSchema[i]; SToken* pItem = taosArrayGet(pValList, i); - char tagVal[TSDB_MAX_TAGS_LEN]; if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pItem->n > pSchema->bytes) { tdDestroyKVRowBuilder(&kvRowBuilder); @@ -446,26 +445,16 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p // } } - char* endPtr = NULL; - int64_t v = strtoll(pItem->z, &endPtr, 10); - *(int32_t*) tagVal = v; -// code = taosVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); + char tmpTokenBuf[TSDB_MAX_TAGS_LEN] = {0}; + SKvParam param = {.builder = &kvRowBuilder, .schema = pSchema}; - // check again after the convert since it may be converted from binary to nchar. - if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { - int16_t len = varDataTLen(tagVal); - if (len > pSchema->bytes) { - tdDestroyKVRowBuilder(&kvRowBuilder); - return buildInvalidOperationMsg(pMsgBuf, msg3); - } - } + char* endPtr = NULL; + code = parseValueToken(&endPtr, pItem, pSchema, tinfo.precision, tmpTokenBuf, KvRowAppend, ¶m, pMsgBuf); if (code != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); return buildInvalidOperationMsg(pMsgBuf, msg4); } - - tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal); } } diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c index d6bdf5dbca..5574c7316c 100644 --- a/source/libs/parser/src/insertParser.c +++ b/source/libs/parser/src/insertParser.c @@ -51,8 +51,8 @@ enum { typedef struct SInsertParseContext { SParseContext* pComCxt; // input - const char* pSql; // input - SMsgBuf msg; // input + char *pSql; // input + SMsgBuf msg; // input STableMeta* pTableMeta; // each table SParsedDataColInfo tags; // each table SKVRowBuilder tagsBuilder; // each table @@ -64,22 +64,6 @@ typedef struct SInsertParseContext { SInsertStmtInfo* pOutput; } SInsertParseContext; -typedef int32_t (*FRowAppend)(const void *value, int32_t len, void *param); - -typedef struct SKvParam { - char buf[TSDB_MAX_TAGS_LEN]; - SKVRowBuilder* builder; - SSchema* schema; -} SKvParam; - -static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; -static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; - -static bool isNullStr(SToken *pToken) { - return (pToken->type == TK_NULL) || ((pToken->type == TK_STRING) && (pToken->n != 0) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); -} - static FORCE_INLINE int32_t toDouble(SToken *pToken, double *value, char **endPtr) { errno = 0; *value = strtold(pToken->z, endPtr); @@ -263,23 +247,21 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start) return TSDB_CODE_SUCCESS; } -static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec, int64_t *time) { +static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time, SMsgBuf* pMsgBuf) { int32_t index = 0; - SToken sToken; + SToken sToken; int64_t interval; - int64_t useconds = 0; - const char* pTokenEnd = pCxt->pSql; + int64_t ts = 0; + char* pTokenEnd = *end; if (pToken->type == TK_NOW) { - useconds = taosGetTimestamp(timePrec); - } else if (strncmp(pToken->z, "0", 1) == 0 && pToken->n == 1) { - // do nothing + ts = taosGetTimestamp(timePrec); } else if (pToken->type == TK_INTEGER) { - useconds = taosStr2int64(pToken->z); - } else { - // strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); + bool isSigned = false; + toInteger(pToken->z, pToken->n, 10, &ts, &isSigned); + } else { // parse the RFC-3339/ISO-8601 timestamp format string if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid timestamp format", pToken->z); + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); } return TSDB_CODE_SUCCESS; @@ -288,8 +270,8 @@ static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec for (int k = pToken->n; pToken->z[k] != '\0'; k++) { if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue; if (pToken->z[k] == ',') { - pCxt->pSql = pTokenEnd; - *time = useconds; + *end = pTokenEnd; + *time = ts; return 0; } @@ -311,7 +293,7 @@ static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec pTokenEnd += index; if (valueToken.n < 2) { - return buildSyntaxErrMsg(&pCxt->msg, "value expected in timestamp", sToken.z); + return buildSyntaxErrMsg(pMsgBuf, "value expected in timestamp", sToken.z); } char unit = 0; @@ -320,34 +302,15 @@ static int parseTime(SInsertParseContext* pCxt, SToken *pToken, int16_t timePrec } if (sToken.type == TK_PLUS) { - useconds += interval; + ts += interval; } else { - useconds = useconds - interval; + ts = ts - interval; } - pCxt->pSql = pTokenEnd; + *end = pTokenEnd; } - *time = useconds; - return TSDB_CODE_SUCCESS; -} - -static FORCE_INLINE int32_t KvRowAppend(const void *value, int32_t len, void *param) { - SKvParam* pa = (SKvParam*)param; - if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { - STR_WITH_SIZE_TO_VARSTR(pa->buf, value, len); - tdAddColToKVRow(pa->builder, pa->schema->colId, pa->schema->type, pa->buf); - } 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; - if (!taosMbsToUcs4(value, len, varDataVal(pa->buf), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { - return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; - } - varDataSetLen(pa->buf, output); - tdAddColToKVRow(pa->builder, pa->schema->colId, pa->schema->type, pa->buf); - } else { - tdAddColToKVRow(pa->builder, pa->schema->colId, pa->schema->type, value); - } + *time = ts; return TSDB_CODE_SUCCESS; } @@ -381,193 +344,206 @@ static FORCE_INLINE int32_t MemRowAppend(const void *value, int32_t len, void *p return TSDB_CODE_SUCCESS; } -static FORCE_INLINE int32_t checkAndTrimValue(SInsertParseContext* pCxt, SToken* pToken, SSchema* pSchema, char* tmpTokenBuf) { - int16_t type = pToken->type; - if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL && - type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || - (pToken->n == 0) || (type == TK_RP)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid data or symbol", pToken->z); - } +//static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, char* tmpTokenBuf, SMsgBuf* pMsgBuf) { +// if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL && +// type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || +// (pToken->n == 0) || (type == TK_RP)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid data or symbol", pToken->z); +// } +// +// if (IS_NUMERIC_TYPE(type) && pToken->n == 0) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid numeric data", pToken->z); +// } +// +// // Remove quotation marks +// if (TK_STRING == type) { +// if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) { +// return buildSyntaxErrMsg(pMsgBuf, "too long string", pToken->z); +// } +// +// // delete escape character: \\, \', \" +// char delim = pToken->z[0]; +// int32_t cnt = 0; +// int32_t j = 0; +// for (uint32_t k = 1; k < pToken->n - 1; ++k) { +// if (pToken->z[k] == '\\' || (pToken->z[k] == delim && pToken->z[k + 1] == delim)) { +// tmpTokenBuf[j] = pToken->z[k + 1]; +// cnt++; +// j++; +// k++; +// continue; +// } +// tmpTokenBuf[j] = pToken->z[k]; +// j++; +// } +// +// tmpTokenBuf[j] = 0; +// pToken->z = tmpTokenBuf; +// pToken->n -= 2 + cnt; +// } +// +// return TSDB_CODE_SUCCESS; +//} - if (IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z); - } - - // Remove quotation marks - if (TK_STRING == type) { - if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) { - return buildSyntaxErrMsg(&pCxt->msg, "too long string", pToken->z); - } - // delete escape character: \\, \', \" - char delim = pToken->z[0]; - int32_t cnt = 0; - int32_t j = 0; - for (uint32_t k = 1; k < pToken->n - 1; ++k) { - if (pToken->z[k] == '\\' || (pToken->z[k] == delim && pToken->z[k + 1] == delim)) { - tmpTokenBuf[j] = pToken->z[k + 1]; - cnt++; - j++; - k++; - continue; - } - tmpTokenBuf[j] = pToken->z[k]; - j++; - } - tmpTokenBuf[j] = 0; - pToken->z = tmpTokenBuf; - pToken->n -= 2 + cnt; - } - - return TSDB_CODE_SUCCESS; -} - -static FORCE_INLINE int32_t parseOneValue(SInsertParseContext* pCxt, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf, FRowAppend func, void* param) { - int64_t iv; - int32_t ret; - char * endptr = NULL; - - CHECK_CODE(checkAndTrimValue(pCxt, pToken, pSchema, tmpTokenBuf)); - - if (isNullStr(pToken)) { - if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { - int64_t tmpVal = 0; - return func(&tmpVal, pSchema->bytes, param); - } - return func(getNullValue(pSchema->type), 0, param); - } - - switch (pSchema->type) { - case TSDB_DATA_TYPE_BOOL: { - if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { - return func(&TRUE_VALUE, pSchema->bytes, param); - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { - return func(&FALSE_VALUE, pSchema->bytes, param); - } else { - return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); - } - } else if (pToken->type == TK_INTEGER) { - return func(((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); - } else if (pToken->type == TK_FLOAT) { - return func(((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); - } else { - return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); - } - break; - } - case TSDB_DATA_TYPE_TINYINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, true)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid tinyint data", pToken->z); - } else if (!IS_VALID_TINYINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "data overflow", pToken->z); - } - uint8_t tmpVal = (uint8_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_UTINYINT:{ - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, false)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid unsigned tinyint data", pToken->z); - } else if (!IS_VALID_UTINYINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "unsigned tinyint data overflow", pToken->z); - } - uint8_t tmpVal = (uint8_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_SMALLINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, true)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid smallint data", pToken->z); - } else if (!IS_VALID_SMALLINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "smallint data overflow", pToken->z); - } - int16_t tmpVal = (int16_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_USMALLINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, false)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid unsigned smallint data", pToken->z); - } else if (!IS_VALID_USMALLINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "unsigned smallint data overflow", pToken->z); - } - uint16_t tmpVal = (uint16_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_INT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, true)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid int data", pToken->z); - } else if (!IS_VALID_INT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "int data overflow", pToken->z); - } - int32_t tmpVal = (int32_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_UINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, false)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid unsigned int data", pToken->z); - } else if (!IS_VALID_UINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "unsigned int data overflow", pToken->z); - } - uint32_t tmpVal = (uint32_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_BIGINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, true)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid bigint data", pToken->z); - } else if (!IS_VALID_BIGINT(iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "bigint data overflow", pToken->z); - } - return func(&iv, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_UBIGINT: { - if (TSDB_CODE_SUCCESS != toInt64(pToken->z, pToken->type, pToken->n, &iv, false)) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid unsigned bigint data", pToken->z); - } else if (!IS_VALID_UBIGINT((uint64_t)iv)) { - return buildSyntaxErrMsg(&pCxt->msg, "unsigned bigint data overflow", pToken->z); - } - uint64_t tmpVal = (uint64_t)iv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_FLOAT: { - double dv; - if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { - return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); - } - if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || dv > FLT_MAX || dv < -FLT_MAX || isinf(dv) || isnan(dv)) { - return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); - } - float tmpVal = (float)dv; - return func(&tmpVal, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_DOUBLE: { - double dv; - if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { - return buildSyntaxErrMsg(&pCxt->msg, "illegal double data", pToken->z); - } - if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) { - return buildSyntaxErrMsg(&pCxt->msg, "illegal double data", pToken->z); - } - return func(&dv, pSchema->bytes, param); - } - case TSDB_DATA_TYPE_BINARY: { - // too long values will return invalid sql, not be truncated automatically - if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { - return buildSyntaxErrMsg(&pCxt->msg, "string data overflow", pToken->z); - } - return func(pToken->z, pToken->n, param); - } - case TSDB_DATA_TYPE_NCHAR: { - return func(pToken->z, pToken->n, param); - } - case TSDB_DATA_TYPE_TIMESTAMP: { - int64_t tmpVal; - if (parseTime(pCxt, pToken, timePrec, &tmpVal) != TSDB_CODE_SUCCESS) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid timestamp", pToken->z); - } - return func(&tmpVal, pSchema->bytes, param); - } - } - - return TSDB_CODE_FAILED; -} +//static FORCE_INLINE int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf, _row_append_fn_t func, void* param, SMsgBuf* pMsgBuf) { +// int64_t iv; +// char *endptr = NULL; +// bool isSigned = false; +// +// CHECK_CODE(checkAndTrimValue(pToken, pSchema->type, tmpTokenBuf, pMsgBuf)); +// +// if (isNullStr(pToken)) { +// if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { +// int64_t tmpVal = 0; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// return func(getNullValue(pSchema->type), 0, param); +// } +// +// switch (pSchema->type) { +// case TSDB_DATA_TYPE_BOOL: { +// if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { +// if (strncmp(pToken->z, "true", pToken->n) == 0) { +// return func(&TRUE_VALUE, pSchema->bytes, param); +// } else if (strncmp(pToken->z, "false", pToken->n) == 0) { +// return func(&FALSE_VALUE, pSchema->bytes, param); +// } else { +// return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); +// } +// } else if (pToken->type == TK_INTEGER) { +// return func(((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); +// } else if (pToken->type == TK_FLOAT) { +// return func(((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); +// } else { +// return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); +// } +// } +// +// case TSDB_DATA_TYPE_TINYINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid tinyint data", pToken->z); +// } else if (!IS_VALID_TINYINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "tinyint data overflow", pToken->z); +// } +// +// uint8_t tmpVal = (uint8_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_UTINYINT:{ +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned tinyint data", pToken->z); +// } else if (!IS_VALID_UTINYINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "unsigned tinyint data overflow", pToken->z); +// } +// uint8_t tmpVal = (uint8_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_SMALLINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid smallint data", pToken->z); +// } else if (!IS_VALID_SMALLINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "smallint data overflow", pToken->z); +// } +// int16_t tmpVal = (int16_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_USMALLINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned smallint data", pToken->z); +// } else if (!IS_VALID_USMALLINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "unsigned smallint data overflow", pToken->z); +// } +// uint16_t tmpVal = (uint16_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_INT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid int data", pToken->z); +// } else if (!IS_VALID_INT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "int data overflow", pToken->z); +// } +// int32_t tmpVal = (int32_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_UINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned int data", pToken->z); +// } else if (!IS_VALID_UINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "unsigned int data overflow", pToken->z); +// } +// uint32_t tmpVal = (uint32_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_BIGINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z); +// } else if (!IS_VALID_BIGINT(iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z); +// } +// return func(&iv, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_UBIGINT: { +// if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned bigint data", pToken->z); +// } else if (!IS_VALID_UBIGINT((uint64_t)iv)) { +// return buildSyntaxErrMsg(pMsgBuf, "unsigned bigint data overflow", pToken->z); +// } +// uint64_t tmpVal = (uint64_t)iv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_FLOAT: { +// double dv; +// if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { +// return buildSyntaxErrMsg(pMsgBuf, "illegal float data", pToken->z); +// } +// if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || dv > FLT_MAX || dv < -FLT_MAX || isinf(dv) || isnan(dv)) { +// return buildSyntaxErrMsg(pMsgBuf, "illegal float data", pToken->z); +// } +// float tmpVal = (float)dv; +// return func(&tmpVal, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_DOUBLE: { +// double dv; +// if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { +// return buildSyntaxErrMsg(pMsgBuf, "illegal double data", pToken->z); +// } +// if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) { +// return buildSyntaxErrMsg(pMsgBuf, "illegal double data", pToken->z); +// } +// return func(&dv, pSchema->bytes, param); +// } +// +// case TSDB_DATA_TYPE_BINARY: { +// // too long values will return invalid sql, not be truncated automatically +// if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { +// return buildSyntaxErrMsg(pMsgBuf, "string data overflow", pToken->z); +// } +// return func(pToken->z, pToken->n, param); +// } +// case TSDB_DATA_TYPE_NCHAR: { +// return func(pToken->z, pToken->n, param); +// } +// case TSDB_DATA_TYPE_TIMESTAMP: { +// int64_t tmpVal; +// if (parseTime(end, pToken, timePrec, &tmpVal, pMsgBuf) != TSDB_CODE_SUCCESS) { +// return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp", pToken->z); +// } +// return func(&tmpVal, pSchema->bytes, param); +// } +// } +// +// return TSDB_CODE_FAILED; +//} // pSql -> tag1_name, ...) static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* pColList, SSchema* pSchema) { @@ -644,7 +620,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, NEXT_TOKEN(pCxt->pSql, sToken); SSchema* pSchema = &pTagsSchema[pCxt->tags.boundedColumns[i]]; param.schema = pSchema; - CHECK_CODE(parseOneValue(pCxt, &sToken, pSchema, precision, tmpTokenBuf, KvRowAppend, ¶m)); + CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, precision, tmpTokenBuf, KvRowAppend, ¶m, &pCxt->msg)); } SKVRow row = tdGetKVRowFromBuilder(&pCxt->tagsBuilder); @@ -709,7 +685,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, param.schema = pSchema; param.compareStat = pBuilder->compareStat; getMemRowAppendInfo(schema, pBuilder->memRowType, spd, i, ¶m.toffset); - CHECK_CODE(parseOneValue(pCxt, &sToken, pSchema, timePrec, tmpTokenBuf, MemRowAppend, ¶m)); + CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, timePrec, tmpTokenBuf, MemRowAppend, ¶m, &pCxt->msg)); if (PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { TSKEY tsKey = memRowKey(row); @@ -894,7 +870,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { int32_t parseInsertSql(SParseContext* pContext, SInsertStmtInfo** pInfo) { SInsertParseContext context = { .pComCxt = pContext, - .pSql = pContext->pSql, + .pSql = (char*) pContext->pSql, .msg = {.buf = pContext->pMsg, .len = pContext->msgLen}, .pTableMeta = NULL, .pVgroupsHashObj = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false), diff --git a/source/libs/parser/src/parserUtil.c b/source/libs/parser/src/parserUtil.c index 39223b7754..6e814038a7 100644 --- a/source/libs/parser/src/parserUtil.c +++ b/source/libs/parser/src/parserUtil.c @@ -13,19 +13,20 @@ * along with this program. If not, see . */ - -#include "tmsg.h" -#include "parser.h" -#include "taoserror.h" -#include "tutil.h" -#include "ttypes.h" -#include "thash.h" -#include "tbuffer.h" -#include "parserInt.h" #include "parserUtil.h" -#include "tmsgtype.h" -#include "queryInfoUtil.h" +#include +#include #include "function.h" +#include "parser.h" +#include "parserInt.h" +#include "queryInfoUtil.h" +#include "taoserror.h" +#include "tbuffer.h" +#include "thash.h" +#include "tmsg.h" +#include "tmsgtype.h" +#include "ttypes.h" +#include "tutil.h" typedef struct STableFilterCond { uint64_t uid; @@ -1627,313 +1628,322 @@ bool isDqlSqlStatement(SSqlInfo* pSqlInfo) { return pSqlInfo->type == TSDB_SQL_SELECT; } -#if 0 -int32_t tscCreateQueryFromQueryInfo(SQueryStmtInfo* pQueryInfo, SQueryAttr* pQueryAttr, void* addr) { - memset(pQueryAttr, 0, sizeof(SQueryAttr)); +static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; +static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; - int16_t numOfCols = (int16_t) taosArrayGetSize(pQueryInfo->colList); - int16_t numOfOutput = (int16_t) getNumOfExprs(pQueryInfo); +static FORCE_INLINE int32_t toDouble(SToken *pToken, double *value, char **endPtr) { + errno = 0; + *value = strtold(pToken->z, endPtr); - pQueryAttr->topBotQuery = tscIsTopBotQuery(pQueryInfo); - pQueryAttr->hasTagResults = hasTagValOutput(pQueryInfo); - pQueryAttr->stabledev = isStabledev(pQueryInfo); - pQueryAttr->tsCompQuery = isTsCompQuery(pQueryInfo); - pQueryAttr->diffQuery = tscIsDiffDerivQuery(pQueryInfo); - pQueryAttr->simpleAgg = isSimpleAggregateRv(pQueryInfo); - pQueryAttr->needReverseScan = tscNeedReverseScan(pQueryInfo); - pQueryAttr->stableQuery = QUERY_IS_STABLE_QUERY(pQueryInfo->type); - pQueryAttr->groupbyColumn = (!pQueryInfo->stateWindow) && tscGroupbyColumn(pQueryInfo); - pQueryAttr->queryBlockDist = isBlockDistQuery(pQueryInfo); - pQueryAttr->pointInterpQuery = tscIsPointInterpQuery(pQueryInfo); - pQueryAttr->timeWindowInterpo = timeWindowInterpoRequired(pQueryInfo); - pQueryAttr->distinct = pQueryInfo->distinct; - pQueryAttr->sw = pQueryInfo->sessionWindow; - pQueryAttr->stateWindow = pQueryInfo->stateWindow; - pQueryAttr->multigroupResult = pQueryInfo->multigroupResult; - - pQueryAttr->numOfCols = numOfCols; - pQueryAttr->numOfOutput = numOfOutput; - pQueryAttr->limit = pQueryInfo->limit; - pQueryAttr->slimit = pQueryInfo->slimit; - pQueryAttr->order = pQueryInfo->order; - pQueryAttr->fillType = pQueryInfo->fillType; - pQueryAttr->havingNum = pQueryInfo->havingFieldNum; - pQueryAttr->pUdfInfo = pQueryInfo->pUdfInfo; - - if (pQueryInfo->order.order == TSDB_ORDER_ASC) { // TODO refactor - pQueryAttr->window = pQueryInfo->window; - } else { - pQueryAttr->window.skey = pQueryInfo->window.ekey; - pQueryAttr->window.ekey = pQueryInfo->window.skey; + // not a valid integer number, return error + if ((*endPtr - pToken->z) != pToken->n) { + return TK_ILLEGAL; } - memcpy(&pQueryAttr->interval, &pQueryInfo->interval, sizeof(pQueryAttr->interval)); + return pToken->type; +} - STableMetaInfo* pTableMetaInfo = pQueryInfo->pTableMetaInfo[0]; +static bool isNullStr(SToken *pToken) { + return (pToken->type == TK_NULL) || ((pToken->type == TK_STRING) && (pToken->n != 0) && + (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); +} - if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { - pQueryAttr->pGroupbyExpr = calloc(1, sizeof(SGroupbyExpr)); - *(pQueryAttr->pGroupbyExpr) = pQueryInfo->groupbyExpr; - pQueryAttr->pGroupbyExpr->columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo); - } else { - assert(pQueryInfo->groupbyExpr.columnInfo == NULL); +static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, char* tmpTokenBuf, SMsgBuf* pMsgBuf) { + if ((type != TK_NOW && type != TK_INTEGER && type != TK_STRING && type != TK_FLOAT && type != TK_BOOL && + type != TK_NULL && type != TK_HEX && type != TK_OCT && type != TK_BIN) || + (pToken->n == 0) || (type == TK_RP)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid data or symbol", pToken->z); } - pQueryAttr->pExpr1 = calloc(pQueryAttr->numOfOutput, sizeof(SExprInfo)); - for(int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { - SExprInfo* pExpr = getExprInfo(pQueryInfo, i); - ExprInfoCopy(&pQueryAttr->pExpr1[i], pExpr); + if (IS_NUMERIC_TYPE(type) && pToken->n == 0) { + return buildSyntaxErrMsg(pMsgBuf, "invalid numeric data", pToken->z); + } - if (pQueryAttr->pExpr1[i].base.functionId == FUNCTION_ARITHM) { - for (int32_t j = 0; j < pQueryAttr->pExpr1[i].base.numOfParams; ++j) { - buildArithmeticExprFromMsg(&pQueryAttr->pExpr1[i], NULL); + // Remove quotation marks + if (TK_STRING == type) { + if (pToken->n >= TSDB_MAX_BYTES_PER_ROW) { + return buildSyntaxErrMsg(pMsgBuf, "too long string", pToken->z); + } + + // delete escape character: \\, \', \" + char delim = pToken->z[0]; + int32_t cnt = 0; + int32_t j = 0; + for (uint32_t k = 1; k < pToken->n - 1; ++k) { + if (pToken->z[k] == '\\' || (pToken->z[k] == delim && pToken->z[k + 1] == delim)) { + tmpTokenBuf[j] = pToken->z[k + 1]; + cnt++; + j++; + k++; + continue; } - } - } - - pQueryAttr->tableCols = calloc(numOfCols, sizeof(SColumnInfo)); - for(int32_t i = 0; i < numOfCols; ++i) { - SColumn* pCol = taosArrayGetP(pQueryInfo->colList, i); - if (!isValidDataType(pCol->info.type) || pCol->info.type == TSDB_DATA_TYPE_NULL) { - assert(0); + tmpTokenBuf[j] = pToken->z[k]; + j++; } - pQueryAttr->tableCols[i] = pCol->info; - pQueryAttr->tableCols[i].flist.filterInfo = tFilterInfoDup(pCol->info.flist.filterInfo, pQueryAttr->tableCols[i].flist.numOfFilters); + tmpTokenBuf[j] = 0; + pToken->z = tmpTokenBuf; + pToken->n -= 2 + cnt; } - // global aggregate query - if (pQueryAttr->stableQuery && (pQueryAttr->simpleAgg || pQueryAttr->interval.interval > 0) && tscIsTwoStageSTableQuery(pQueryInfo, 0)) { - createGlobalAggregateExpr(pQueryAttr, pQueryInfo); - } + return TSDB_CODE_SUCCESS; +} - // for simple table, not for super table - if (pQueryInfo->arithmeticOnAgg) { - pQueryAttr->numOfExpr2 = (int32_t) taosArrayGetSize(pQueryInfo->exprList1); - pQueryAttr->pExpr2 = calloc(pQueryAttr->numOfExpr2, sizeof(SExprInfo)); - for(int32_t i = 0; i < pQueryAttr->numOfExpr2; ++i) { - SExprInfo* p = taosArrayGetP(pQueryInfo->exprList1, i); - ExprInfoCopy(&pQueryAttr->pExpr2[i], p); +static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time, SMsgBuf* pMsgBuf) { + int32_t index = 0; + SToken sToken; + int64_t interval; + int64_t ts = 0; + char* pTokenEnd = *end; + + if (pToken->type == TK_NOW) { + ts = taosGetTimestamp(timePrec); + } else if (pToken->type == TK_INTEGER) { + bool isSigned = false; + toInteger(pToken->z, pToken->n, 10, &ts, &isSigned); + } else { // parse the RFC-3339/ISO-8601 timestamp format string + if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); } + + return TSDB_CODE_SUCCESS; } - // tag column info - int32_t code = createTagColumnInfo(pQueryAttr, pQueryInfo, pTableMetaInfo); + for (int k = pToken->n; pToken->z[k] != '\0'; k++) { + if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue; + if (pToken->z[k] == ',') { + *end = pTokenEnd; + *time = ts; + return 0; + } + + break; + } + + /* + * time expression: + * e.g., now+12a, now-5h + */ + SToken valueToken; + index = 0; + sToken = tStrGetToken(pTokenEnd, &index, false); + pTokenEnd += index; + + if (sToken.type == TK_MINUS || sToken.type == TK_PLUS) { + index = 0; + valueToken = tStrGetToken(pTokenEnd, &index, false); + pTokenEnd += index; + + if (valueToken.n < 2) { + return buildSyntaxErrMsg(pMsgBuf, "value expected in timestamp", sToken.z); + } + + char unit = 0; + if (parseAbsoluteDuration(valueToken.z, valueToken.n, &interval, &unit, timePrec) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + if (sToken.type == TK_PLUS) { + ts += interval; + } else { + ts = ts - interval; + } + + *end = pTokenEnd; + } + + *time = ts; + return TSDB_CODE_SUCCESS; +} + +int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf, _row_append_fn_t func, void* param, SMsgBuf* pMsgBuf) { + int64_t iv; + char *endptr = NULL; + bool isSigned = false; + + int32_t code = checkAndTrimValue(pToken, pSchema->type, tmpTokenBuf, pMsgBuf); if (code != TSDB_CODE_SUCCESS) { return code; } - if (pQueryAttr->fillType != TSDB_FILL_NONE) { - pQueryAttr->fillVal = calloc(pQueryAttr->numOfOutput, sizeof(int64_t)); - memcpy(pQueryAttr->fillVal, pQueryInfo->fillVal, pQueryInfo->numOfFillVal * sizeof(int64_t)); - } - - pQueryAttr->srcRowSize = 0; - pQueryAttr->maxTableColumnWidth = 0; - for (int16_t i = 0; i < numOfCols; ++i) { - pQueryAttr->srcRowSize += pQueryAttr->tableCols[i].bytes; - if (pQueryAttr->maxTableColumnWidth < pQueryAttr->tableCols[i].bytes) { - pQueryAttr->maxTableColumnWidth = pQueryAttr->tableCols[i].bytes; - } - } - - pQueryAttr->interBufSize = getOutputInterResultBufSize(pQueryAttr); - - if (pQueryAttr->numOfCols <= 0 && !tscQueryTags(pQueryInfo) && !pQueryAttr->queryBlockDist) { - tscError("%p illegal value of numOfCols in query msg: %" PRIu64 ", table cols:%d", addr, - (uint64_t)pQueryAttr->numOfCols, numOfCols); - - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - if (pQueryAttr->interval.interval < 0) { - tscError("%p illegal value of aggregation time interval in query msg: %" PRId64, addr, - (int64_t)pQueryInfo->interval.interval); - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - if (pQueryAttr->pGroupbyExpr != NULL && pQueryAttr->pGroupbyExpr->numOfGroupCols < 0) { - tscError("%p illegal value of numOfGroupCols in query msg: %d", addr, pQueryInfo->groupbyExpr.numOfGroupCols); - return TSDB_CODE_TSC_INVALID_OPERATION; - } - - return TSDB_CODE_SUCCESS; -} - -static int32_t doAddTableName(char* nextStr, char** str, SArray* pNameArray, SSqlObj* pSql) { - int32_t code = TSDB_CODE_SUCCESS; - SSqlCmd* pCmd = &pSql->cmd; - - char tablename[TSDB_TABLE_FNAME_LEN] = {0}; - int32_t len = 0; - - if (nextStr == NULL) { - tstrncpy(tablename, *str, TSDB_TABLE_FNAME_LEN); - len = (int32_t) strlen(tablename); - } else { - len = (int32_t)(nextStr - (*str)); - if (len >= TSDB_TABLE_NAME_LEN) { - sprintf(pCmd->payload, "table name too long"); - return TSDB_CODE_TSC_INVALID_OPERATION; + if (isNullStr(pToken)) { + if (TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && PRIMARYKEY_TIMESTAMP_COL_ID == pSchema->colId) { + int64_t tmpVal = 0; + return func(&tmpVal, pSchema->bytes, param); } - memcpy(tablename, *str, nextStr - (*str)); - tablename[len] = '\0'; + return func(getNullValue(pSchema->type), 0, param); } - (*str) = nextStr + 1; - len = (int32_t)strtrim(tablename); - - SToken sToken = {.n = len, .type = TK_ID, .z = tablename}; - tGetToken(tablename, &sToken.type); - - // Check if the table name available or not - if (tscValidateName(&sToken) != TSDB_CODE_SUCCESS) { - sprintf(pCmd->payload, "table name is invalid"); - return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - } - - SName name = {0}; - if ((code = tscSetTableFullName(&name, &sToken, pSql)) != TSDB_CODE_SUCCESS) { - return code; - } - - memset(tablename, 0, tListLen(tablename)); - tNameExtractFullName(&name, tablename); - - char* p = strdup(tablename); - taosArrayPush(pNameArray, &p); - return TSDB_CODE_SUCCESS; -} - -int32_t nameComparFn(const void* n1, const void* n2) { - int32_t ret = strcmp(*(char**)n1, *(char**)n2); - if (ret == 0) { - return 0; - } else { - return ret > 0? 1:-1; - } -} - -static void freeContent(void* p) { - char* ptr = *(char**)p; - tfree(ptr); -} - - -int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t length, SArray* pNameArray) { - SSqlCmd *pCmd = &pSql->cmd; - - pCmd->command = TSDB_SQL_MULTI_META; - pCmd->msgType = TDMT_VND_TABLES_META; - - int code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - char *str = (char *)pNameList; - - SQueryStmtInfo *pQueryInfo = tscGetQueryInfoS(pCmd); - if (pQueryInfo == NULL) { - pSql->res.code = terrno; - return terrno; - } - - char *nextStr; - while (1) { - nextStr = strchr(str, ','); - if (nextStr == NULL) { - code = doAddTableName(nextStr, &str, pNameArray, pSql); - break; - } - - code = doAddTableName(nextStr, &str, pNameArray, pSql); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - if (taosArrayGetSize(pNameArray) > TSDB_MULTI_TABLEMETA_MAX_NUM) { - code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - sprintf(pCmd->payload, "tables over the max number"); - return code; - } - } - - size_t len = taosArrayGetSize(pNameArray); - if (len == 1) { - return TSDB_CODE_SUCCESS; - } - - if (len > TSDB_MULTI_TABLEMETA_MAX_NUM) { - code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - sprintf(pCmd->payload, "tables over the max number"); - return code; - } - - taosArraySort(pNameArray, nameComparFn); - taosArrayRemoveDuplicate(pNameArray, nameComparFn, freeContent); - return TSDB_CODE_SUCCESS; -} - -bool vgroupInfoIdentical(SNewVgroupInfo *pExisted, SVgroupMsg* src) { - assert(pExisted != NULL && src != NULL); - if (pExisted->numOfEps != src->numOfEps) { - return false; - } - - for(int32_t i = 0; i < pExisted->numOfEps; ++i) { - if (pExisted->ep[i].port != src->epAddr[i].port) { - return false; - } - - if (strncmp(pExisted->ep[i].fqdn, src->epAddr[i].fqdn, tListLen(pExisted->ep[i].fqdn)) != 0) { - return false; - } - } - - return true; -} - -SNewVgroupInfo createNewVgroupInfo(SVgroupMsg *pVgroupMsg) { - assert(pVgroupMsg != NULL); - - SNewVgroupInfo info = {0}; - info.numOfEps = pVgroupMsg->numOfEps; - info.vgId = pVgroupMsg->vgId; - info.inUse = 0; // 0 is the default value of inUse in case of multiple replica - - assert(info.numOfEps >= 1 && info.vgId >= 1); - for(int32_t i = 0; i < pVgroupMsg->numOfEps; ++i) { - tstrncpy(info.ep[i].fqdn, pVgroupMsg->epAddr[i].fqdn, TSDB_FQDN_LEN); - info.ep[i].port = pVgroupMsg->epAddr[i].port; - } - - return info; -} - -char* cloneCurrentDBName(SSqlObj* pSql) { - char *p = NULL; - HttpContext *pCtx = NULL; - - pthread_mutex_lock(&pSql->pTscObj->mutex); - STscObj *pTscObj = pSql->pTscObj; - switch (pTscObj->from) { - case TAOS_REQ_FROM_HTTP: - pCtx = pSql->param; - if (pCtx && pCtx->db[0] != '\0') { - char db[TSDB_DB_FNAME_LEN] = {0}; - int32_t len = sprintf(db, "%s%s%s", pTscObj->acctId, TS_PATH_DELIMITER, pCtx->db); - assert(len <= sizeof(db)); - - p = strdup(db); + switch (pSchema->type) { + case TSDB_DATA_TYPE_BOOL: { + if ((pToken->type == TK_BOOL || pToken->type == TK_STRING) && (pToken->n != 0)) { + if (strncmp(pToken->z, "true", pToken->n) == 0) { + return func(&TRUE_VALUE, pSchema->bytes, param); + } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + return func(&FALSE_VALUE, pSchema->bytes, param); + } else { + return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); + } + } else if (pToken->type == TK_INTEGER) { + return func(((strtoll(pToken->z, NULL, 10) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); + } else if (pToken->type == TK_FLOAT) { + return func(((strtod(pToken->z, NULL) == 0) ? &FALSE_VALUE : &TRUE_VALUE), pSchema->bytes, param); + } else { + return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } - break; - default: - break; - } - if (p == NULL) { - p = strdup(pSql->pTscObj->db); - } - pthread_mutex_unlock(&pSql->pTscObj->mutex); + } - return p; + case TSDB_DATA_TYPE_TINYINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid tinyint data", pToken->z); + } else if (!IS_VALID_TINYINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "tinyint data overflow", pToken->z); + } + + uint8_t tmpVal = (uint8_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_UTINYINT:{ + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned tinyint data", pToken->z); + } else if (!IS_VALID_UTINYINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "unsigned tinyint data overflow", pToken->z); + } + uint8_t tmpVal = (uint8_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_SMALLINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid smallint data", pToken->z); + } else if (!IS_VALID_SMALLINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "smallint data overflow", pToken->z); + } + int16_t tmpVal = (int16_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_USMALLINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned smallint data", pToken->z); + } else if (!IS_VALID_USMALLINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "unsigned smallint data overflow", pToken->z); + } + uint16_t tmpVal = (uint16_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_INT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid int data", pToken->z); + } else if (!IS_VALID_INT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "int data overflow", pToken->z); + } + int32_t tmpVal = (int32_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_UINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned int data", pToken->z); + } else if (!IS_VALID_UINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "unsigned int data overflow", pToken->z); + } + uint32_t tmpVal = (uint32_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_BIGINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z); + } else if (!IS_VALID_BIGINT(iv)) { + return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z); + } + return func(&iv, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_UBIGINT: { + if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, pToken->type, &iv, &isSigned)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid unsigned bigint data", pToken->z); + } else if (!IS_VALID_UBIGINT((uint64_t)iv)) { + return buildSyntaxErrMsg(pMsgBuf, "unsigned bigint data overflow", pToken->z); + } + uint64_t tmpVal = (uint64_t)iv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_FLOAT: { + double dv; + if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { + return buildSyntaxErrMsg(pMsgBuf, "illegal float data", pToken->z); + } + if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || dv > FLT_MAX || dv < -FLT_MAX || isinf(dv) || isnan(dv)) { + return buildSyntaxErrMsg(pMsgBuf, "illegal float data", pToken->z); + } + float tmpVal = (float)dv; + return func(&tmpVal, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_DOUBLE: { + double dv; + if (TK_ILLEGAL == toDouble(pToken, &dv, &endptr)) { + return buildSyntaxErrMsg(pMsgBuf, "illegal double data", pToken->z); + } + if (((dv == HUGE_VAL || dv == -HUGE_VAL) && errno == ERANGE) || isinf(dv) || isnan(dv)) { + return buildSyntaxErrMsg(pMsgBuf, "illegal double data", pToken->z); + } + return func(&dv, pSchema->bytes, param); + } + + case TSDB_DATA_TYPE_BINARY: { + // Too long values will raise the invalid sql error message + if (pToken->n + VARSTR_HEADER_SIZE > pSchema->bytes) { + return buildSyntaxErrMsg(pMsgBuf, "string data overflow", pToken->z); + } + + return func(pToken->z, pToken->n, param); + } + + case TSDB_DATA_TYPE_NCHAR: { + return func(pToken->z, pToken->n, param); + } + + case TSDB_DATA_TYPE_TIMESTAMP: { + int64_t tmpVal; + if (parseTime(end, pToken, timePrec, &tmpVal, pMsgBuf) != TSDB_CODE_SUCCESS) { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp", pToken->z); + } + + return func(&tmpVal, pSchema->bytes, param); + } + } + + return TSDB_CODE_FAILED; } -#endif \ No newline at end of file +int32_t KvRowAppend(const void *value, int32_t len, void *param) { + SKvParam* pa = (SKvParam*) param; + + int32_t type = pa->schema->type; + int32_t colId = pa->schema->colId; + + if (TSDB_DATA_TYPE_BINARY == type) { + STR_WITH_SIZE_TO_VARSTR(pa->buf, value, len); + tdAddColToKVRow(pa->builder, colId, type, pa->buf); + } 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)) { + return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + } + + varDataSetLen(pa->buf, output); + tdAddColToKVRow(pa->builder, colId, type, pa->buf); + } else { + tdAddColToKVRow(pa->builder, colId, type, value); + } + + return TSDB_CODE_SUCCESS; +} \ No newline at end of file From 402b851cf23786cb4215fdcd94714c7103d9671c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 11:49:13 +0800 Subject: [PATCH 44/55] more --- include/common/tmsg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index bf96a3bfb3..416402a028 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1058,9 +1058,9 @@ typedef struct STaskDropRsp { } STaskDropRsp; typedef struct { - int8_t igExists; - char* name; - char* phyPlan; + int8_t igExists; + char* name; + char* phyPlan; } SCMCreateTopicReq; static FORCE_INLINE int tSerializeSCMCreateTopicReq(void** buf, const SCMCreateTopicReq* pReq) { From 77100ef11a76b7233ae034e3e66ef90f3a3ee25c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 13:37:14 +0800 Subject: [PATCH 45/55] make create table work --- source/libs/parser/src/dCDAstProcess.c | 133 +++++++++++++------------ 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 51d4e14a2a..2bcf92b184 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -17,7 +17,8 @@ static bool has(SArray* pFieldList, int32_t startIndex, const char* name) { return false; } -static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, void** output, int32_t* outputLen, SMsgBuf* pMsgBuf) { +static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** output, int32_t* outputLen, + SMsgBuf* pMsgBuf) { const char* msg1 = "invalid name"; const char* msg2 = "wildcard string should be less than %d characters"; const char* msg3 = "database name too long"; @@ -29,7 +30,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, void** ou * database prefix in pInfo->pMiscInfo->a[0] * wildcard in like clause in pInfo->pMiscInfo->a[1] */ - int16_t showType = pShowInfo->showType; + int16_t showType = pShowInfo->showType; if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP) { SToken* pDbPrefixToken = &pShowInfo->prefix; if (pDbPrefixToken->type != 0) { @@ -80,7 +81,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx *pCtx, void** ou } *output = buildShowMsg(pShowInfo, pCtx, pMsgBuf->buf, pMsgBuf->len); - *outputLen = sizeof(SShowMsg)/* + htons(pShowMsg->payloadLen)*/; + *outputLen = sizeof(SShowMsg) /* + htons(pShowMsg->payloadLen)*/; return TSDB_CODE_SUCCESS; } @@ -116,8 +117,8 @@ static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) { int32_t val = htonl(pCreate->daysPerFile); if (val != -1 && (val < TSDB_MIN_DAYS_PER_FILE || val > TSDB_MAX_DAYS_PER_FILE)) { - snprintf(msg, tListLen(msg), "invalid db option daysPerFile: %d valid range: [%d, %d]", val, - TSDB_MIN_DAYS_PER_FILE, TSDB_MAX_DAYS_PER_FILE); + snprintf(msg, tListLen(msg), "invalid db option daysPerFile: %d valid range: [%d, %d]", val, TSDB_MIN_DAYS_PER_FILE, + TSDB_MAX_DAYS_PER_FILE); return buildInvalidOperationMsg(pMsgBuf, msg); } @@ -137,15 +138,15 @@ static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) { val = htonl(pCreate->commitTime); if (val != -1 && (val < TSDB_MIN_COMMIT_TIME || val > TSDB_MAX_COMMIT_TIME)) { - snprintf(msg, tListLen(msg), "invalid db option commitTime: %d valid range: [%d, %d]", val, - TSDB_MIN_COMMIT_TIME, TSDB_MAX_COMMIT_TIME); + snprintf(msg, tListLen(msg), "invalid db option commitTime: %d valid range: [%d, %d]", val, TSDB_MIN_COMMIT_TIME, + TSDB_MAX_COMMIT_TIME); return buildInvalidOperationMsg(pMsgBuf, msg); } val = htonl(pCreate->fsyncPeriod); if (val != -1 && (val < TSDB_MIN_FSYNC_PERIOD || val > TSDB_MAX_FSYNC_PERIOD)) { - snprintf(msg, tListLen(msg), "invalid db option fsyncPeriod: %d valid range: [%d, %d]", val, - TSDB_MIN_FSYNC_PERIOD, TSDB_MAX_FSYNC_PERIOD); + snprintf(msg, tListLen(msg), "invalid db option fsyncPeriod: %d valid range: [%d, %d]", val, TSDB_MIN_FSYNC_PERIOD, + TSDB_MAX_FSYNC_PERIOD); return buildInvalidOperationMsg(pMsgBuf, msg); } @@ -284,7 +285,8 @@ int32_t doCheckForCreateTable(SSqlInfo* pInfo, SMsgBuf* pMsgBuf) { return TSDB_CODE_SUCCESS; } -int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* pMsgBuf, char** pOutput, int32_t* len, SEpSet* pEpSet) { +int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* pMsgBuf, char** pOutput, int32_t* len, + SEpSet* pEpSet) { const char* msg1 = "invalid table name"; const char* msg2 = "tags number not matched"; const char* msg3 = "tag value too long"; @@ -293,13 +295,13 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p SCreateTableSql* pCreateTable = pInfo->pCreateTableInfo; // super table name, create table by using dst - int32_t numOfTables = (int32_t) taosArrayGetSize(pCreateTable->childTableInfo); - for(int32_t j = 0; j < numOfTables; ++j) { + int32_t numOfTables = (int32_t)taosArrayGetSize(pCreateTable->childTableInfo); + for (int32_t j = 0; j < numOfTables; ++j) { SCreatedTableInfo* pCreateTableInfo = taosArrayGet(pCreateTable->childTableInfo, j); SToken* pSTableNameToken = &pCreateTableInfo->stbName; - char buf[TSDB_TABLE_FNAME_LEN]; + char buf[TSDB_TABLE_FNAME_LEN]; SToken sTblToken; sTblToken.z = buf; @@ -315,7 +317,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p } const char* pStableName = tNameGetTableName(&name); - SArray* pValList = pCreateTableInfo->pTagVals; + SArray* pValList = pCreateTableInfo->pTagVals; size_t numOfInputTag = taosArrayGetSize(pValList); STableMeta* pSuperTableMeta = NULL; @@ -327,9 +329,9 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p assert(pSuperTableMeta != NULL); // too long tag values will return invalid sql, not be truncated automatically - SSchema *pTagSchema = getTableTagSchema(pSuperTableMeta); + SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); STableComInfo tinfo = getTableInfo(pSuperTableMeta); - STagData *pTag = &pCreateTableInfo->tagdata; + STagData* pTag = &pCreateTableInfo->tagdata; SKVRowBuilder kvRowBuilder = {0}; if (tdInitKVRowBuilder(&kvRowBuilder) < 0) { @@ -353,17 +355,17 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p for (int32_t i = 0; i < nameSize; ++i) { SToken* sToken = taosArrayGet(pNameList, i); - char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // create tmp buf to avoid alter orginal sqlstr + char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // create tmp buf to avoid alter orginal sqlstr strncpy(tmpTokenBuf, sToken->z, sToken->n); sToken->z = tmpTokenBuf; -// if (TK_STRING == sToken->type) { -// tscDequoteAndTrimToken(sToken); -// } + // if (TK_STRING == sToken->type) { + // tscDequoteAndTrimToken(sToken); + // } -// if (TK_ID == sToken->type) { -// tscRmEscapeAndTrimToken(sToken); -// } + // if (TK_ID == sToken->type) { + // tscRmEscapeAndTrimToken(sToken); + // } SListItem* pItem = taosArrayGet(pValList, i); @@ -372,7 +374,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p // todo speedup by using hash list for (int32_t t = 0; t < schemaSize; ++t) { if (strncmp(sToken->z, pTagSchema[t].name, sToken->n) == 0 && strlen(pTagSchema[t].name) == sToken->n) { - SSchema* pSchema = &pTagSchema[t]; + SSchema* pSchema = &pTagSchema[t]; char tagVal[TSDB_MAX_TAGS_LEN] = {0}; if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { @@ -382,10 +384,10 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p } } else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { -// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); -// if (code != TSDB_CODE_SUCCESS) { -// return buildInvalidOperationMsg(pMsgBuf, msg4); -// } + // code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); + // if (code != TSDB_CODE_SUCCESS) { + // return buildInvalidOperationMsg(pMsgBuf, msg4); + // } } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); } @@ -416,7 +418,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p if (!findColumnIndex) { tdDestroyKVRowBuilder(&kvRowBuilder); -// return buildInvalidOperationMsg(pMsgBuf, "invalid tag name", sToken->z); + // return buildInvalidOperationMsg(pMsgBuf, "invalid tag name", sToken->z); } } } else { @@ -426,8 +428,8 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p } for (int32_t i = 0; i < numOfInputTag; ++i) { - SSchema *pSchema = &pTagSchema[i]; - SToken* pItem = taosArrayGet(pValList, i); + SSchema* pSchema = &pTagSchema[i]; + SToken* pItem = taosArrayGet(pValList, i); if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) { if (pItem->n > pSchema->bytes) { @@ -435,17 +437,17 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p return buildInvalidOperationMsg(pMsgBuf, msg3); } } else if (pSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { -// if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { -//// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); -// if (code != TSDB_CODE_SUCCESS) { -// return buildInvalidOperationMsg(pMsgBuf, msg4); -// } -// } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { -// pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); -// } + // if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) { + //// code = convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision); + // if (code != TSDB_CODE_SUCCESS) { + // return buildInvalidOperationMsg(pMsgBuf, msg4); + // } + // } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { + // pItem->pVar.i = convertTimePrecision(pItem->pVar.i, TSDB_TIME_PRECISION_NANO, tinfo.precision); + // } } - char tmpTokenBuf[TSDB_MAX_TAGS_LEN] = {0}; + char tmpTokenBuf[TSDB_MAX_TAGS_LEN] = {0}; SKvParam param = {.builder = &kvRowBuilder, .schema = pSchema}; char* endPtr = NULL; @@ -478,32 +480,35 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p req.ctbCfg.suid = pSuperTableMeta->suid; req.ctbCfg.pTag = row; - int32_t serLen = tSerializeSVCreateTbReq(NULL, &req); - char* buf1 = calloc(1, serLen); - char* p = buf1; - tSerializeSVCreateTbReq((void*) &buf1, &req); - *pOutput = p; + int32_t serLen = sizeof(SMsgHead) + tSerializeSVCreateTbReq(NULL, &req); + char* buf1 = calloc(1, serLen); + *pOutput = buf1; + buf1 += sizeof(SMsgHead); + tSerializeSVCreateTbReq((void*)&buf1, &req); *len = serLen; SVgroupInfo info = {0}; catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, req.name, &info); - pEpSet->inUse = info.inUse; + pEpSet->inUse = info.inUse; pEpSet->numOfEps = info.numOfEps; - for(int32_t i = 0; i < pEpSet->numOfEps; ++i) { + for (int32_t i = 0; i < pEpSet->numOfEps; ++i) { pEpSet->port[i] = info.epAddr[i].port; tstrncpy(pEpSet->fqdn[i], info.epAddr[i].fqdn, tListLen(pEpSet->fqdn[i])); } + ((SMsgHead*)(*pOutput))->vgId = htonl(info.vgId); + ((SMsgHead*)(*pOutput))->contLen = htonl(serLen); } return TSDB_CODE_SUCCESS; } -int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStmtInfo* pDcl, char* msgBuf, int32_t msgBufLen) { +int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStmtInfo* pDcl, char* msgBuf, + int32_t msgBufLen) { int32_t code = 0; - SMsgBuf m = {.buf = msgBuf, .len = msgBufLen}; - SMsgBuf *pMsgBuf = &m; + SMsgBuf m = {.buf = msgBuf, .len = msgBufLen}; + SMsgBuf* pMsgBuf = &m; switch (pInfo->type) { case TSDB_SQL_CREATE_USER: @@ -551,7 +556,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm } pDcl->pMsg = (char*)buildUserManipulationMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen); - pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_USER)? TDMT_MND_CREATE_USER:TDMT_MND_ALTER_USER; + pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_USER) ? TDMT_MND_CREATE_USER : TDMT_MND_ALTER_USER; break; } @@ -588,14 +593,14 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm } pDcl->pMsg = (char*)buildAcctManipulationMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen); - pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_ACCT)? TDMT_MND_CREATE_ACCT:TDMT_MND_ALTER_ACCT; + pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_ACCT) ? TDMT_MND_CREATE_ACCT : TDMT_MND_ALTER_ACCT; break; } case TSDB_SQL_DROP_ACCT: case TSDB_SQL_DROP_USER: { pDcl->pMsg = (char*)buildDropUserMsg(pInfo, &pDcl->msgLen, pCtx->requestId, msgBuf, msgBufLen); - pDcl->msgType = (pInfo->type == TSDB_SQL_DROP_ACCT)? TDMT_MND_DROP_ACCT:TDMT_MND_DROP_USER; + pDcl->msgType = (pInfo->type == TSDB_SQL_DROP_ACCT) ? TDMT_MND_DROP_ACCT : TDMT_MND_DROP_USER; break; } @@ -613,13 +618,13 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm return buildInvalidOperationMsg(pMsgBuf, msg); } - SName n = {0}; + SName n = {0}; int32_t ret = tNameSetDbName(&n, pCtx->acctId, pToken->z, pToken->n); if (ret != TSDB_CODE_SUCCESS) { return buildInvalidOperationMsg(pMsgBuf, msg); } - SUseDbMsg *pUseDbMsg = (SUseDbMsg *) calloc(1, sizeof(SUseDbMsg)); + SUseDbMsg* pUseDbMsg = (SUseDbMsg*)calloc(1, sizeof(SUseDbMsg)); tNameExtractFullName(&n, pUseDbMsg->db); pDcl->pMsg = (char*)pUseDbMsg; @@ -638,7 +643,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm return buildInvalidOperationMsg(pMsgBuf, msg2); } - char buf[TSDB_DB_NAME_LEN] = {0}; + char buf[TSDB_DB_NAME_LEN] = {0}; SToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf)); if (parserValidateNameToken(&token) != TSDB_CODE_SUCCESS) { @@ -652,7 +657,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm pDcl->pMsg = (char*)pCreateMsg; pDcl->msgLen = sizeof(SCreateDbMsg); - pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_DB)? TDMT_MND_CREATE_DB:TDMT_MND_ALTER_DB; + pDcl->msgType = (pInfo->type == TSDB_SQL_CREATE_DB) ? TDMT_MND_CREATE_DB : TDMT_MND_ALTER_DB; break; } @@ -668,7 +673,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm return buildInvalidOperationMsg(pMsgBuf, msg1); } - SDropDbMsg *pDropDbMsg = (SDropDbMsg*) calloc(1, sizeof(SDropDbMsg)); + SDropDbMsg* pDropDbMsg = (SDropDbMsg*)calloc(1, sizeof(SDropDbMsg)); code = tNameExtractFullName(&name, pDropDbMsg->db); pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0; @@ -688,9 +693,10 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm return code; } pDcl->pMsg = (char*)buildCreateTableMsg(pCreateTable, &pDcl->msgLen, pCtx, pMsgBuf); - pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE)? TDMT_VND_CREATE_TABLE:TDMT_MND_CREATE_STB; - } else if (pCreateTable->type == TSQL_CREATE_CTABLE) { - if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf, &pDcl->pMsg, &pDcl->msgLen, &pDcl->epSet)) != TSDB_CODE_SUCCESS) { + pDcl->msgType = (pCreateTable->type == TSQL_CREATE_TABLE) ? TDMT_VND_CREATE_TABLE : TDMT_MND_CREATE_STB; + } else if (pCreateTable->type == TSQL_CREATE_CTABLE) { + if ((code = doCheckForCreateCTable(pInfo, pCtx, pMsgBuf, &pDcl->pMsg, &pDcl->msgLen, &pDcl->epSet)) != + TSDB_CODE_SUCCESS) { return code; } @@ -714,7 +720,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm } case TSDB_SQL_CREATE_DNODE: { - pDcl->pMsg = (char*) buildCreateDnodeMsg(pInfo, &pDcl->msgLen, pMsgBuf); + pDcl->pMsg = (char*)buildCreateDnodeMsg(pInfo, &pDcl->msgLen, pMsgBuf); if (pDcl->pMsg == NULL) { code = terrno; } @@ -724,7 +730,7 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm } case TSDB_SQL_DROP_DNODE: { - pDcl->pMsg = (char*) buildDropDnodeMsg(pInfo, &pDcl->msgLen, pMsgBuf); + pDcl->pMsg = (char*)buildDropDnodeMsg(pInfo, &pDcl->msgLen, pMsgBuf); if (pDcl->pMsg == NULL) { code = terrno; } @@ -739,4 +745,3 @@ int32_t qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SDclStm return code; } - From 009140d849f073c282f05878d4de09206da22fc1 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 05:49:39 +0000 Subject: [PATCH 46/55] make container run as root --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9b752d091d..8132eab539 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -28,5 +28,5 @@ // "postCreateCommand": "gcc -v", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + "remoteUser": "root" } From 3b3566e3b43ec2c5c075984f5e8276c266526b64 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 06:12:24 +0000 Subject: [PATCH 47/55] make create table OK --- source/dnode/vnode/impl/src/vnodeWrite.c | 1 + source/dnode/vnode/meta/src/metaBDBImpl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index 1c39f0fbb7..3b1442a02c 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -68,6 +68,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { switch (pMsg->msgType) { case TDMT_VND_CREATE_STB: + case TDMT_VND_CREATE_TABLE: tDeserializeSVCreateTbReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbReq); if (metaCreateTable(pVnode->pMeta, &(vCreateTbReq)) < 0) { // TODO: handle error diff --git a/source/dnode/vnode/meta/src/metaBDBImpl.c b/source/dnode/vnode/meta/src/metaBDBImpl.c index a8d8b67fd4..51e3330ebf 100644 --- a/source/dnode/vnode/meta/src/metaBDBImpl.c +++ b/source/dnode/vnode/meta/src/metaBDBImpl.c @@ -351,7 +351,7 @@ static int metaCtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey pDbt[0].size = sizeof(pTbCfg->ctbCfg.suid); // Second key is the first tag - void *pTagVal = tdGetKVRowValOfCol(pTbCfg->ctbCfg.pTag, 0); + void *pTagVal = tdGetKVRowValOfCol(pTbCfg->ctbCfg.pTag, (kvRowColIdx(pTbCfg->ctbCfg.pTag))[0].colId); pDbt[1].data = varDataVal(pTagVal); pDbt[1].size = varDataLen(pTagVal); From 97f7018f5be307d1b69cfdd6428a00f0b026326d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 22:35:23 -0800 Subject: [PATCH 48/55] fix invalid write in sdb --- include/dnode/mnode/sdb/sdb.h | 14 ++--- source/dnode/mnode/impl/src/mndProfile.c | 10 +-- source/dnode/mnode/impl/src/mndShow.c | 62 ++++++++----------- source/dnode/mnode/impl/src/mndTrans.c | 14 ++--- source/dnode/mnode/sdb/inc/sdbInt.h | 1 + source/dnode/mnode/sdb/src/sdb.c | 8 +-- source/dnode/mnode/sdb/src/sdbHash.c | 79 ++++++++++++++++++------ source/dnode/mnode/sdb/src/sdbRaw.c | 4 +- source/dnode/mnode/sdb/src/sdbRow.c | 11 +++- tests/script/sh/exec.sh | 4 +- 10 files changed, 122 insertions(+), 85 deletions(-) diff --git a/include/dnode/mnode/sdb/sdb.h b/include/dnode/mnode/sdb/sdb.h index 0f648b5150..474e526186 100644 --- a/include/dnode/mnode/sdb/sdb.h +++ b/include/dnode/mnode/sdb/sdb.h @@ -25,7 +25,7 @@ extern "C" { #define SDB_GET_INT64(pData, pRow, dataPos, val) \ { \ if (sdbGetRawInt64(pRaw, dataPos, val) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += sizeof(int64_t); \ @@ -34,7 +34,7 @@ extern "C" { #define SDB_GET_INT32(pData, pRow, dataPos, val) \ { \ if (sdbGetRawInt32(pRaw, dataPos, val) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += sizeof(int32_t); \ @@ -43,7 +43,7 @@ extern "C" { #define SDB_GET_INT16(pData, pRow, dataPos, val) \ { \ if (sdbGetRawInt16(pRaw, dataPos, val) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += sizeof(int16_t); \ @@ -52,7 +52,7 @@ extern "C" { #define SDB_GET_INT8(pData, pRow, dataPos, val) \ { \ if (sdbGetRawInt8(pRaw, dataPos, val) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += sizeof(int8_t); \ @@ -61,7 +61,7 @@ extern "C" { #define SDB_GET_BINARY(pRaw, pRow, dataPos, val, valLen) \ { \ if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += valLen; \ @@ -71,7 +71,7 @@ extern "C" { { \ char val[valLen] = {0}; \ if (sdbGetRawBinary(pRaw, dataPos, val, valLen) != 0) { \ - sdbFreeRow(pRow); \ + tfree(pRow); \ return NULL; \ } \ dataPos += valLen; \ @@ -325,7 +325,7 @@ int32_t sdbGetRawSoftVer(SSdbRaw *pRaw, int8_t *sver); int32_t sdbGetRawTotalSize(SSdbRaw *pRaw); SSdbRow *sdbAllocRow(int32_t objSize); -void sdbFreeRow(SSdbRow *pRow); +void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow); void *sdbGetRowObj(SSdbRow *pRow); #ifdef __cplusplus diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 9a4098857c..77efeb8481 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -118,17 +118,17 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid, SConnObj *pConn = taosCachePut(pMgmt->cache, &connId, sizeof(int32_t), &connObj, sizeof(connObj), keepTime * 1000); if (pConn == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("conn:%d, data:%p failed to put into cache since %s, user:%s", connId, pConn, pInfo->user, terrstr()); + mError("conn:%d, failed to put into cache since %s, user:%s", connId, pInfo->user, terrstr()); return NULL; } else { - mTrace("conn:%d, data:%p created, user:%s", pConn->id, pConn, pInfo->user); + mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, pInfo->user); return pConn; } } static void mndFreeConn(SConnObj *pConn) { tfree(pConn->pQueries); - mTrace("conn:%d, data:%p destroyed", pConn->id, pConn); + mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn); } static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) { @@ -143,13 +143,13 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) { int32_t keepTime = pMnode->cfg.shellActivityTimer * 3; pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs(); - mTrace("conn:%d, data:%p acquired from cache", pConn->id, pConn); + mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn); return pConn; } static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) { if (pConn == NULL) return; - mTrace("conn:%d, data:%p released from cache", pConn->id, pConn); + mTrace("conn:%d, released from cache, data:%p", pConn->id, pConn); SProfileMgmt *pMgmt = &pMnode->profileMgmt; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index e50c6af4bb..b89de94452 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -55,32 +55,25 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SShowMsg *pMsg) { int32_t showId = atomic_add_fetch_32(&pMgmt->showId, 1); if (showId == 0) atomic_add_fetch_32(&pMgmt->showId, 1); - int32_t size = sizeof(SShowObj) + pMsg->payloadLen; - SShowObj *pShow = calloc(1, size); - if (pShow != NULL) { - pShow->id = showId; - pShow->pMnode = pMnode; - pShow->type = pMsg->type; - pShow->payloadLen = pMsg->payloadLen; - memcpy(pShow->db, pMsg->db, TSDB_DB_FNAME_LEN); - memcpy(pShow->payload, pMsg->payload, pMsg->payloadLen); - } else { - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("failed to process show-meta msg:%s since %s", mndShowStr(pMsg->type), terrstr()); - return NULL; - } + int32_t size = sizeof(SShowObj) + pMsg->payloadLen; + SShowObj showObj = {0}; + showObj.id = showId; + showObj.pMnode = pMnode; + showObj.type = pMsg->type; + showObj.payloadLen = pMsg->payloadLen; + memcpy(showObj.db, pMsg->db, TSDB_DB_FNAME_LEN); + memcpy(showObj.payload, pMsg->payload, pMsg->payloadLen); int32_t keepTime = pMnode->cfg.shellActivityTimer * 6 * 1000; - SShowObj *pShowRet = taosCachePut(pMgmt->cache, &showId, sizeof(int32_t), pShow, size, keepTime); - free(pShow); - if (pShowRet == NULL) { + SShowObj *pShow = taosCachePut(pMgmt->cache, &showId, sizeof(int32_t), &showObj, size, keepTime); + if (pShow == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; mError("show:%d, failed to put into cache since %s", showId, terrstr()); return NULL; - } else { - mTrace("show:%d, data:%p created", showId, pShowRet); - return pShowRet; } + + mTrace("show:%d, is created, data:%p", showId, pShow); + return pShow; } static void mndFreeShowObj(SShowObj *pShow) { @@ -94,7 +87,7 @@ static void mndFreeShowObj(SShowObj *pShow) { } } - mTrace("show:%d, data:%p destroyed", pShow->id, pShow); + mTrace("show:%d, is destroyed, data:%p", pShow->id, pShow); } static SShowObj *mndAcquireShowObj(SMnode *pMnode, int32_t showId) { @@ -106,14 +99,14 @@ static SShowObj *mndAcquireShowObj(SMnode *pMnode, int32_t showId) { return NULL; } - mTrace("show:%d, data:%p acquired from cache", pShow->id, pShow); + mTrace("show:%d, acquired from cache, data:%p", pShow->id, pShow); return pShow; } static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) { if (pShow == NULL) return; - mTrace("show:%d, data:%p released from cache, force:%d", pShow->id, pShow, forceRemove); - + mTrace("show:%d, released from cache, data:%p force:%d", pShow->id, pShow, forceRemove); + // A bug in tcache.c forceRemove = 0; @@ -158,8 +151,8 @@ static int32_t mndProcessShowMsg(SMnodeMsg *pMnodeMsg) { } int32_t code = (*metaFp)(pMnodeMsg, pShow, &pRsp->tableMeta); - mDebug("show:%d, data:%p get meta finished, numOfRows:%d cols:%d type:%s result:%s", pShow->id, pShow, - pShow->numOfRows, pShow->numOfColumns, mndShowStr(type), tstrerror(code)); + mDebug("show:%d, get meta finished, numOfRows:%d cols:%d type:%s result:%s", pShow->id, pShow->numOfRows, + pShow->numOfColumns, mndShowStr(type), tstrerror(code)); if (code == TSDB_CODE_SUCCESS) { pMnodeMsg->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns; @@ -195,16 +188,15 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { if (retrieveFp == NULL) { mndReleaseShowObj(pShow, false); terrno = TSDB_CODE_MSG_NOT_PROCESSED; - mError("show:%d, data:%p failed to retrieve data since %s", pShow->id, pShow, terrstr()); + mError("show:%d, failed to retrieve data since %s", pShow->id, terrstr()); return -1; } - mDebug("show:%d, data:%p start retrieve data, numOfReads:%d numOfRows:%d type:%s", pShow->id, pShow, - pShow->numOfReads, pShow->numOfRows, mndShowStr(pShow->type)); + mDebug("show:%d, start retrieve data, numOfReads:%d numOfRows:%d type:%s", pShow->id, pShow->numOfReads, + pShow->numOfRows, mndShowStr(pShow->type)); if (mndCheckRetrieveFinished(pShow)) { - mDebug("show:%d, data:%p read finished, numOfReads:%d numOfRows:%d", pShow->id, pShow, pShow->numOfReads, - pShow->numOfRows); + mDebug("show:%d, read finished, numOfReads:%d numOfRows:%d", pShow->id, pShow->numOfReads, pShow->numOfRows); pShow->numOfReads = pShow->numOfRows; } @@ -227,7 +219,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { if (pRsp == NULL) { mndReleaseShowObj(pShow, false); terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("show:%d, data:%p failed to retrieve data since %s", pShow->id, pShow, terrstr()); + mError("show:%d, failed to retrieve data since %s", pShow->id, terrstr()); return -1; } @@ -236,7 +228,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { rowsRead = (*retrieveFp)(pMnodeMsg, pShow, pRsp->data, rowsToRead); } - mDebug("show:%d, data:%p stop retrieve data, rowsRead:%d rowsToRead:%d", pShow->id, pShow, rowsRead, rowsToRead); + mDebug("show:%d, stop retrieve data, rowsRead:%d rowsToRead:%d", pShow->id, rowsRead, rowsToRead); pRsp->numOfRows = htonl(rowsRead); pRsp->precision = TSDB_TIME_PRECISION_MILLI; // millisecond time precision @@ -246,10 +238,10 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) { if (rowsRead == 0 || rowsToRead == 0 || (rowsRead == rowsToRead && pShow->numOfRows == pShow->numOfReads)) { pRsp->completed = 1; - mDebug("show:%d, data:%p retrieve completed", pShow->id, pShow); + mDebug("show:%d, retrieve completed", pShow->id); mndReleaseShowObj(pShow, true); } else { - mDebug("show:%d, data:%p retrieve not completed yet", pShow->id, pShow); + mDebug("show:%d, retrieve not completed yet", pShow->id); mndReleaseShowObj(pShow, false); } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 9459c5e525..dd69a34dcc 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -294,18 +294,18 @@ TRANS_DECODE_OVER: return NULL; } - mTrace("trans:%d, decode from raw:%p", pTrans->id, pRaw); + mTrace("trans:%d, decode from raw:%p, data:%p", pTrans->id, pRaw, pTrans); return pRow; } static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) { pTrans->stage = TRN_STAGE_PREPARE; - mTrace("trans:%d, perform insert action", pTrans->id); + mTrace("trans:%d, perform insert action, data:%p", pTrans->id, pTrans); return 0; } static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) { - mTrace("trans:%d, perform delete action", pTrans->id); + mTrace("trans:%d, perform delete action, data:%p", pTrans->id, pTrans); mndTransDropLogs(pTrans->redoLogs); mndTransDropLogs(pTrans->undoLogs); @@ -317,7 +317,7 @@ static int32_t mndTransActionDelete(SSdb *pSdb, STrans *pTrans) { } static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOldTrans, STrans *pNewTrans) { - mTrace("trans:%d, perform update action", pOldTrans->id); + mTrace("trans:%d, perform update action, data:%p", pOldTrans->id, pOldTrans); pOldTrans->stage = pNewTrans->stage; return 0; } @@ -362,14 +362,14 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, SRpcMsg *pMsg) { return NULL; } - mDebug("trans:%d, is created", pTrans->id); + mDebug("trans:%d, is created, data:%p", pTrans->id, pTrans); return pTrans; } static void mndTransDropLogs(SArray *pArray) { for (int32_t i = 0; i < pArray->size; ++i) { SSdbRaw *pRaw = taosArrayGetP(pArray, i); - tfree(pRaw); + sdbFreeRaw(pRaw); } taosArrayDestroy(pArray); @@ -391,7 +391,7 @@ void mndTransDrop(STrans *pTrans) { mndTransDropActions(pTrans->redoActions); mndTransDropActions(pTrans->undoActions); - // mDebug("trans:%d, is dropped, data:%p", pTrans->id, pTrans); + mDebug("trans:%d, is dropped, data:%p", pTrans->id, pTrans); tfree(pTrans); } diff --git a/source/dnode/mnode/sdb/inc/sdbInt.h b/source/dnode/mnode/sdb/inc/sdbInt.h index 00f6d231d6..da90451202 100644 --- a/source/dnode/mnode/sdb/inc/sdbInt.h +++ b/source/dnode/mnode/sdb/inc/sdbInt.h @@ -72,6 +72,7 @@ typedef struct SSdb { } SSdb; int32_t sdbWriteFile(SSdb *pSdb); +void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper); #ifdef __cplusplus } diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index bb0e606463..97bc0ecbdb 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -80,16 +80,12 @@ void sdbCleanup(SSdb *pSdb) { SHashObj *hash = pSdb->hashObjs[i]; if (hash == NULL) continue; - SdbDeleteFp deleteFp = pSdb->deleteFps[i]; - SSdbRow **ppRow = taosHashIterate(hash, NULL); + SSdbRow **ppRow = taosHashIterate(hash, NULL); while (ppRow != NULL) { SSdbRow *pRow = *ppRow; if (pRow == NULL) continue; - if (deleteFp != NULL) { - (*deleteFp)(pSdb, pRow->pObj); - } - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); ppRow = taosHashIterate(hash, ppRow); } } diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 27ff8e697d..78a90b9a7d 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -16,6 +16,50 @@ #define _DEFAULT_SOURCE #include "sdbInt.h" +static const char *sdbTableName(ESdbType type) { + switch (type) { + case SDB_TRANS: + return "trans"; + case SDB_CLUSTER: + return "cluster"; + case SDB_MNODE: + return "mnode"; + case SDB_DNODE: + return "dnode"; + case SDB_USER: + return "user"; + case SDB_AUTH: + return "auth"; + case SDB_ACCT: + return "acct"; + case SDB_TOPIC: + return "topic"; + case SDB_VGROUP: + return "vgId"; + case SDB_STB: + return "stb"; + case SDB_DB: + return "db"; + case SDB_FUNC: + return "func"; + default: + return "undefine"; + } +} + +void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper) { + EKeyType keyType = pSdb->keyTypes[pRow->type]; + + if (keyType == SDB_KEY_BINARY) { + mTrace("%s:%s, refCount:%d oper:%s", sdbTableName(pRow->type), (char *)pRow->pObj, pRow->refCount, oper); + } else if (keyType == SDB_KEY_INT32) { + mTrace("%s:%d, refCount:%d oper:%s", sdbTableName(pRow->type), *(int32_t *)pRow->pObj, pRow->refCount, oper); + } else if (keyType == SDB_KEY_INT64) { + mTrace("%s:%" PRId64 ", refCount:%d oper:%s", sdbTableName(pRow->type), *(int64_t *)pRow->pObj, pRow->refCount, oper); + } else { + } +} + static SHashObj *sdbGetHash(SSdb *pSdb, int32_t type) { if (type >= SDB_MAX || type <= SDB_START) { terrno = TSDB_CODE_SDB_INVALID_TABLE_TYPE; @@ -55,17 +99,18 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * SSdbRow *pOldRow = taosHashGet(hash, pRow->pObj, keySize); if (pOldRow != NULL) { taosWUnLockLatch(pLock); - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE; return terrno; } - pRow->refCount = 1; + pRow->refCount = 0; pRow->status = pRaw->status; + sdbPrintOper(pSdb, pRow, "insertRow"); if (taosHashPut(hash, pRow->pObj, keySize, &pRow, sizeof(void *)) != 0) { taosWUnLockLatch(pLock); - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); terrno = TSDB_CODE_SDB_OBJ_ALREADY_THERE; return terrno; } @@ -83,7 +128,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * taosWLockLatch(pLock); taosHashRemove(hash, pRow->pObj, keySize); taosWUnLockLatch(pLock); - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); terrno = code; return terrno; } @@ -113,7 +158,7 @@ static int32_t sdbUpdateRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * code = (*updateFp)(pSdb, pOldRow->pObj, pNewRow->pObj); } - sdbFreeRow(pNewRow); + sdbFreeRow(pSdb, pNewRow); return code; } @@ -123,14 +168,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * SRWLatch *pLock = &pSdb->locks[pRow->type]; taosWLockLatch(pLock); - // remove attached object such as trans - SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; - if (deleteFp != NULL) (*deleteFp)(pSdb, pRow->pObj); - SSdbRow **ppOldRow = taosHashGet(hash, pRow->pObj, keySize); if (ppOldRow == NULL || *ppOldRow == NULL) { taosWUnLockLatch(pLock); - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); terrno = TSDB_CODE_SDB_OBJ_NOT_THERE; return terrno; } @@ -140,8 +181,8 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * taosHashRemove(hash, pOldRow->pObj, keySize); taosWUnLockLatch(pLock); - sdbRelease(pSdb, pOldRow->pObj); - sdbFreeRow(pRow); + // sdbRelease(pSdb, pOldRow->pObj); + sdbFreeRow(pSdb, pRow); return code; } @@ -206,6 +247,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey) { case SDB_STATUS_UPDATING: atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; + sdbPrintOper(pSdb, pRow, "acquireRow"); break; case SDB_STATUS_CREATING: terrno = TSDB_CODE_SDB_OBJ_CREATING; @@ -232,13 +274,9 @@ void sdbRelease(SSdb *pSdb, void *pObj) { taosRLockLatch(pLock); int32_t ref = atomic_sub_fetch_32(&pRow->refCount, 1); + sdbPrintOper(pSdb, pRow, "releaseRow"); if (ref <= 0 && pRow->status == SDB_STATUS_DROPPED) { - SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; - if (deleteFp != NULL) { - (*deleteFp)(pSdb, pRow->pObj); - } - - sdbFreeRow(pRow); + sdbFreeRow(pSdb, pRow); } taosRUnLockLatch(pLock); @@ -255,9 +293,9 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) { if (pIter != NULL) { SSdbRow *pLastRow = *(SSdbRow **)pIter; - int32_t ref = atomic_sub_fetch_32(&pLastRow->refCount, 1); + int32_t ref = atomic_load_32(&pLastRow->refCount); if (ref <= 0 && pLastRow->status == SDB_STATUS_DROPPED) { - sdbFreeRow(pLastRow); + sdbFreeRow(pSdb, pLastRow); } } @@ -270,6 +308,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) { } atomic_add_fetch_32(&pRow->refCount, 1); + sdbPrintOper(pSdb, pRow, "fetchRow"); *ppObj = pRow->pObj; break; } diff --git a/source/dnode/mnode/sdb/src/sdbRaw.c b/source/dnode/mnode/sdb/src/sdbRaw.c index 5a0020199f..e37559808e 100644 --- a/source/dnode/mnode/sdb/src/sdbRaw.c +++ b/source/dnode/mnode/sdb/src/sdbRaw.c @@ -27,12 +27,12 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen) { pRaw->sver = sver; pRaw->dataLen = dataLen; - // mTrace("raw:%p, is created, len:%d", pRaw, dataLen); + mTrace("raw:%p, is created, len:%d", pRaw, dataLen); return pRaw; } void sdbFreeRaw(SSdbRaw *pRaw) { - // mTrace("raw:%p, is freed", pRaw); + mTrace("raw:%p, is freed", pRaw); free(pRaw); } diff --git a/source/dnode/mnode/sdb/src/sdbRow.c b/source/dnode/mnode/sdb/src/sdbRow.c index ec1dcf39e6..4c889a6d04 100644 --- a/source/dnode/mnode/sdb/src/sdbRow.c +++ b/source/dnode/mnode/sdb/src/sdbRow.c @@ -35,4 +35,13 @@ void *sdbGetRowObj(SSdbRow *pRow) { return pRow->pObj; } -void sdbFreeRow(SSdbRow *pRow) { tfree(pRow); } +void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow) { + // remove attached object such as trans + SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; + if (deleteFp != NULL) { + (*deleteFp)(pSdb, pRow->pObj); + } + + sdbPrintOper(pSdb, pRow, "freeRow"); + tfree(pRow); +} diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index d1572bb513..2e95a740d0 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -17,7 +17,7 @@ OS_TYPE=`$UNAME_BIN` NODE_NAME= EXEC_OPTON= CLEAR_OPTION="false" -while getopts "n:s:u:x:ct" arg +while getopts "n:s:u:x:cv" arg do case $arg in n) @@ -29,7 +29,7 @@ do c) CLEAR_OPTION="clear" ;; - t) + v) SHELL_OPTION="true" ;; u) From 5676735793d49ed4940997ece2c2bcfb5fa14b81 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 22:40:10 -0800 Subject: [PATCH 49/55] test cases --- tests/script/general/table/basic1.sim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/script/general/table/basic1.sim b/tests/script/general/table/basic1.sim index 5892a81f2e..f2341a84ce 100644 --- a/tests/script/general/table/basic1.sim +++ b/tests/script/general/table/basic1.sim @@ -23,7 +23,7 @@ endi print $data00 $data01 $data02 -sql create table st2 (ts timestamp, i float) tags (j bigint) +sql create table st2 (ts timestamp, i float) tags (j int) sql show stables if $rows != 2 then return -1 @@ -39,15 +39,14 @@ if $rows != 1 then return -1 endi -print --> print $data00 $data01 $data02 print $data10 $data11 $data12 -return - print =============== create child table sql create table c1 using st tags(1) sql create table c2 using st tags(2) + +return sql show tables if $rows != 2 then return -1 From 4894ec6b3df1a706685696d500d1c8633bd318f2 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 29 Dec 2021 15:01:12 +0800 Subject: [PATCH 50/55] [td-11818] merge 3.0 --- include/libs/catalog/catalog.h | 26 +- include/libs/qcom/query.h | 2 +- source/client/test/clientTests.cpp | 68 +- source/libs/catalog/src/catalog.c | 126 +- source/libs/catalog/test/catalogTests.cpp | 68 +- source/libs/parser/inc/astGenerator.h | 2 +- source/libs/parser/inc/astToMsg.h | 1 - source/libs/parser/inc/parserUtil.h | 2 + source/libs/parser/inc/sql.y | 2 + source/libs/parser/src/astGenerator.c | 29 +- source/libs/parser/src/astToMsg.c | 68 +- source/libs/parser/src/dCDAstProcess.c | 17 +- source/libs/parser/src/insertParser.c | 15 +- source/libs/parser/src/parserUtil.c | 37 +- source/libs/parser/src/sql.c | 2486 +++++++++-------- source/libs/parser/test/mockCatalog.cpp | 8 +- .../libs/parser/test/mockCatalogService.cpp | 19 +- source/libs/parser/test/mockCatalogService.h | 4 +- 18 files changed, 1521 insertions(+), 1459 deletions(-) diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index a9abf45c8d..7d7cc73174 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -21,13 +21,14 @@ extern "C" { #endif #include "os.h" -#include "thash.h" -#include "tarray.h" #include "taosdef.h" -#include "transport.h" -#include "common.h" -#include "tmsg.h" #include "query.h" +#include "tname.h" +#include "common.h" +#include "tarray.h" +#include "thash.h" +#include "tmsg.h" +#include "transport.h" struct SCatalog; @@ -68,35 +69,32 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB * @param pCatalog (input, got with catalogGetHandle) * @param pTransporter (input, rpc object) * @param pMgmtEps (input, mnode EPs) - * @param pDBName (input, full db name) * @param pTableName (input, table name, NOT including db name) * @param pTableMeta(output, table meta data, NEED to free it by calller) * @return error code */ -int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta); +int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta); /** * Force renew a table's local cached meta data. * @param pCatalog (input, got with catalogGetHandle) * @param pRpc (input, rpc object) * @param pMgmtEps (input, mnode EPs) - * @param pDBName (input, full db name) * @param pTableName (input, table name, NOT including db name) * @return error code */ -int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName); +int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName); /** * Force renew a table's local cached meta data and get the new one. * @param pCatalog (input, got with catalogGetHandle) * @param pRpc (input, rpc object) * @param pMgmtEps (input, mnode EPs) - * @param pDBName (input, full db name) * @param pTableName (input, table name, NOT including db name) * @param pTableMeta(output, table meta data, NEED to free it by calller) * @return error code */ -int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta); +int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta); /** @@ -104,24 +102,22 @@ int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const * @param pCatalog (input, got with catalogGetHandle) * @param pRpc (input, rpc object) * @param pMgmtEps (input, mnode EPs) - * @param pDBName (input, full db name) * @param pTableName (input, table name, NOT including db name) * @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller) * @return error code */ -int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SArray** pVgroupList); +int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgroupList); /** * Get a table's vgroup from its name's hash value. * @param pCatalog (input, got with catalogGetHandle) * @param pTransporter (input, rpc object) * @param pMgmtEps (input, mnode EPs) - * @param pDBName (input, full db name) * @param pTableName (input, table name, NOT including db name) * @param vgInfo (output, vgroup info) * @return error code */ -int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo); +int32_t catalogGetTableHashVgroup(struct SCatalog* pCatalog, void * pTransporter, const SEpSet* pMgmtEps, const SName* pName, SVgroupInfo* vgInfo); /** diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index ea131bbbf2..a50c618be1 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -23,6 +23,7 @@ extern "C" { #include "tarray.h" #include "thash.h" #include "tlog.h" +#include "tmsg.h" enum { JOB_TASK_STATUS_NULL = 0, @@ -73,7 +74,6 @@ typedef struct STableMeta { SSchema schema[]; } STableMeta; - typedef struct SDBVgroupInfo { int32_t vgVersion; int8_t hashMethod; diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 9616166e21..1c38b74fa3 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -162,7 +162,7 @@ TEST(testCase, create_db_Test) { taos_free_result(pRes); - pRes = taos_query(pConn, "create database abc1"); + pRes = taos_query(pConn, "create database abc1 vgroups 4"); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); } @@ -399,39 +399,39 @@ TEST(testCase, drop_stable_Test) { taos_close(pConn); } -TEST(testCase, create_topic_Test) { - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - assert(pConn != NULL); - - TAOS_RES* pRes = taos_query(pConn, "create database abc1"); - if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "use abc1"); - if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)"); - if (taos_errno(pRes) != 0) { - printf("error in create stable, reason:%s\n", taos_errstr(pRes)); - } - - TAOS_FIELD* pFields = taos_fetch_fields(pRes); - ASSERT_TRUE(pFields == NULL); - - int32_t numOfFields = taos_num_fields(pRes); - ASSERT_EQ(numOfFields, 0); - - taos_free_result(pRes); - - char* sql = "select * from st1"; - tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql)); - taos_close(pConn); -} +//TEST(testCase, create_topic_Test) { +// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); +// assert(pConn != NULL); +// +// TAOS_RES* pRes = taos_query(pConn, "create database abc1"); +// if (taos_errno(pRes) != 0) { +// printf("error in create db, reason:%s\n", taos_errstr(pRes)); +// } +// taos_free_result(pRes); +// +// pRes = taos_query(pConn, "use abc1"); +// if (taos_errno(pRes) != 0) { +// printf("error in use db, reason:%s\n", taos_errstr(pRes)); +// } +// taos_free_result(pRes); +// +// pRes = taos_query(pConn, "create stable st1(ts timestamp, k int) tags(a int)"); +// if (taos_errno(pRes) != 0) { +// printf("error in create stable, reason:%s\n", taos_errstr(pRes)); +// } +// +// TAOS_FIELD* pFields = taos_fetch_fields(pRes); +// ASSERT_TRUE(pFields == NULL); +// +// int32_t numOfFields = taos_num_fields(pRes); +// ASSERT_EQ(numOfFields, 0); +// +// taos_free_result(pRes); +// +// char* sql = "select * from st1"; +// tmq_create_topic(pConn, "test_topic_1", sql, strlen(sql)); +// taos_close(pConn); +//} //TEST(testCase, show_table_Test) { // TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e067a7597a..5820c82028 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -13,10 +13,10 @@ * along with this program. If not, see . */ -#include "catalogInt.h" #include "trpc.h" #include "query.h" #include "tname.h" +#include "catalogInt.h" SCatalogMgmt ctgMgmt = {0}; @@ -71,15 +71,14 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp } -int32_t ctgGetTableMetaFromCache(struct SCatalog* pCatalog, const char *dbName, const char* pTableName, STableMeta** pTableMeta, int32_t *exist) { +int32_t ctgGetTableMetaFromCache(struct SCatalog* pCatalog, const SName* pTableName, STableMeta** pTableMeta, int32_t *exist) { if (NULL == pCatalog->tableCache.cache) { *exist = 0; return TSDB_CODE_SUCCESS; } char tbFullName[TSDB_TABLE_FNAME_LEN]; - - snprintf(tbFullName, sizeof(tbFullName), "%s.%s", dbName, pTableName); + tNameExtractFullName(pTableName, tbFullName); STableMeta *tbMeta = taosHashGet(pCatalog->tableCache.cache, tbFullName, strlen(tbFullName)); @@ -135,14 +134,13 @@ void ctgGenEpSet(SEpSet *epSet, SVgroupInfo *vgroupInfo) { } } -int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char *pDBName, const char* pTableName, STableMetaOutput* output) { - if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pDBName || NULL == pTableName || NULL == output) { +int32_t ctgGetTableMetaFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMetaOutput* output) { + if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == output) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } char tbFullName[TSDB_TABLE_FNAME_LEN]; - - snprintf(tbFullName, sizeof(tbFullName), "%s.%s", pDBName, pTableName); + tNameExtractFullName(pTableName, tbFullName); SBuildTableMetaInput bInput = {.vgId = 0, .tableFullName = tbFullName}; char *msg = NULL; @@ -248,10 +246,13 @@ int32_t ctgGetVgInfoFromDB(struct SCatalog *pCatalog, void *pRpc, const SEpSet * return TSDB_CODE_SUCCESS; } -int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const char *pDBName, const char *pTableName, SVgroupInfo *pVgroup) { +int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup) { int32_t vgNum = taosHashGetSize(dbInfo->vgInfo); + char db[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, db); + if (vgNum <= 0) { - ctgError("db[%s] vgroup cache invalid, vgroup number:%d", pDBName, vgNum); + ctgError("db[%s] vgroup cache invalid, vgroup number:%d", db, vgNum); CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); } @@ -261,8 +262,7 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const char *pDBName, co CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp)); char tbFullName[TSDB_TABLE_FNAME_LEN]; - - snprintf(tbFullName, sizeof(tbFullName), "%s.%s", pDBName, pTableName); + tNameExtractFullName(pTableName, tbFullName); uint32_t hashValue = (*fp)(tbFullName, (uint32_t)strlen(tbFullName)); @@ -287,24 +287,24 @@ int32_t ctgGetVgInfoFromHashValue(SDBVgroupInfo *dbInfo, const char *pDBName, co return TSDB_CODE_SUCCESS; } -int32_t ctgGetTableMetaImpl(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, bool forceUpdate, STableMeta** pTableMeta) { - if (NULL == pCatalog || NULL == pDBName || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pTableMeta) { +int32_t ctgGetTableMetaImpl(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, bool forceUpdate, STableMeta** pTableMeta) { + if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pTableMeta) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } int32_t exist = 0; if (!forceUpdate) { - CTG_ERR_RET(ctgGetTableMetaFromCache(pCatalog, pDBName, pTableName, pTableMeta, &exist)); + CTG_ERR_RET(ctgGetTableMetaFromCache(pCatalog, pTableName, pTableMeta, &exist)); if (exist) { return TSDB_CODE_SUCCESS; } } - CTG_ERR_RET(catalogRenewTableMeta(pCatalog, pRpc, pMgmtEps, pDBName, pTableName)); + CTG_ERR_RET(catalogRenewTableMeta(pCatalog, pRpc, pMgmtEps, pTableName)); - CTG_ERR_RET(ctgGetTableMetaFromCache(pCatalog, pDBName, pTableName, pTableMeta, &exist)); + CTG_ERR_RET(ctgGetTableMetaFromCache(pCatalog, pTableName, pTableMeta, &exist)); if (0 == exist) { ctgError("get table meta from cache failed, but fetch succeed"); @@ -392,7 +392,7 @@ int32_t ctgGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgm strncpy(input.db, dbName, sizeof(input.db)); input.db[sizeof(input.db) - 1] = 0; input.vgVersion = CTG_DEFAULT_INVALID_VERSION; - + CTG_ERR_RET(ctgGetDBVgroupFromMnode(pCatalog, pRpc, pMgmtEps, &input, &DbOut)); CTG_ERR_RET(catalogUpdateDBVgroup(pCatalog, dbName, &DbOut.dbVgroup)); @@ -413,7 +413,7 @@ int32_t catalogInit(SCatalogCfg *cfg) { if (cfg) { memcpy(&ctgMgmt.cfg, cfg, sizeof(*cfg)); - + if (ctgMgmt.cfg.maxDBCacheNum == 0) { ctgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; } @@ -502,7 +502,7 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB taosHashCleanup(oldInfo->vgInfo); oldInfo->vgInfo = NULL; } - + taosHashRemove(pCatalog->dbCache.cache, dbName, strlen(dbName)); } @@ -532,25 +532,60 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB return TSDB_CODE_SUCCESS; } -int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { - return ctgGetTableMetaImpl(pCatalog, pTransporter, pMgmtEps, pDBName, pTableName, false, pTableMeta); + + + +int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* dbName, int32_t forceUpdate, SDBVgroupInfo* dbInfo) { + if (NULL == pCatalog || NULL == dbName || NULL == pRpc || NULL == pMgmtEps) { + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t exist = 0; + + if (0 == forceUpdate) { + CTG_ERR_RET(ctgGetDBVgroupFromCache(pCatalog, dbName, dbInfo, &exist)); + + if (exist) { + return TSDB_CODE_SUCCESS; + } + } + + SUseDbOutput DbOut = {0}; + SBuildUseDBInput input = {0}; + + strncpy(input.db, dbName, sizeof(input.db)); + input.db[sizeof(input.db) - 1] = 0; + input.vgVersion = CTG_DEFAULT_INVALID_VERSION; + + CTG_ERR_RET(ctgGetDBVgroupFromMnode(pCatalog, pRpc, pMgmtEps, &input, &DbOut)); +// CTG_ERR_RET(catalogUpdateDBVgroupCache(pCatalog, dbName, &DbOut.dbVgroup)); + + if (dbInfo) { + *dbInfo = DbOut.dbVgroup; + } + + return TSDB_CODE_SUCCESS; } -int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName) { - if (NULL == pCatalog || NULL == pDBName || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName) { +int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { + return ctgGetTableMetaImpl(pCatalog, pTransporter, pMgmtEps, pTableName, false, pTableMeta); +} + +int32_t catalogRenewTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName) { + if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } SVgroupInfo vgroupInfo = {0}; int32_t code = 0; - - CTG_ERR_RET(catalogGetTableHashVgroup(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &vgroupInfo)); + + CTG_ERR_RET(catalogGetTableHashVgroup(pCatalog, pRpc, pMgmtEps, pTableName, &vgroupInfo)); STableMetaOutput output = {0}; //CTG_ERR_RET(ctgGetTableMetaFromVnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &vgroupInfo, &output)); - CTG_ERR_RET(ctgGetTableMetaFromMnode(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &output)); + CTG_ERR_RET(ctgGetTableMetaFromMnode(pCatalog, pRpc, pMgmtEps, pTableName, &output)); CTG_ERR_JRET(ctgUpdateTableMetaCache(pCatalog, &output)); @@ -561,12 +596,12 @@ _return: CTG_RET(code); } -int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { - return ctgGetTableMetaImpl(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, true, pTableMeta); +int32_t catalogRenewAndGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { + return ctgGetTableMetaImpl(pCatalog, pRpc, pMgmtEps, pTableName, true, pTableMeta); } -int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SArray** pVgroupList) { - if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pDBName || NULL == pTableName || NULL == pVgroupList) { +int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SArray** pVgroupList) { + if (NULL == pCatalog || NULL == pRpc || NULL == pMgmtEps || NULL == pTableName || NULL == pVgroupList) { CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } @@ -575,9 +610,11 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S SVgroupInfo vgroupInfo = {0}; SDBVgroupInfo dbVgroup = {0}; - CTG_ERR_JRET(catalogGetTableMeta(pCatalog, pRpc, pMgmtEps, pDBName, pTableName, &tbMeta)); + CTG_ERR_JRET(catalogGetTableMeta(pCatalog, pRpc, pMgmtEps, pTableName, &tbMeta)); - CTG_ERR_JRET(ctgGetDBVgroup(pCatalog, pRpc, pMgmtEps, pDBName, false, &dbVgroup)); + char db[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, db); + CTG_ERR_JRET(catalogGetDBVgroup(pCatalog, pRpc, pMgmtEps, db, false, &dbVgroup)); if (tbMeta->tableType == TSDB_SUPER_TABLE) { CTG_ERR_JRET(ctgGetVgInfoFromDB(pCatalog, pRpc, pMgmtEps, &dbVgroup, pVgroupList)); @@ -601,32 +638,30 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S } tfree(tbMeta); - return TSDB_CODE_SUCCESS; _return: tfree(tbMeta); - taosArrayDestroy(*pVgroupList); - *pVgroupList = NULL; - CTG_RET(code); } -int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter, const SEpSet *pMgmtEps, const char *pDBName, const char *pTableName, SVgroupInfo *pVgroup) { +int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) { SDBVgroupInfo dbInfo = {0}; int32_t code = 0; - int32_t vgId = 0; - CTG_ERR_RET(ctgGetDBVgroup(pCatalog, pTransporter, pMgmtEps, pDBName, false, &dbInfo)); + char db[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, db); + + CTG_ERR_RET(catalogGetDBVgroup(pCatalog, pTransporter, pMgmtEps, db, false, &dbInfo)); if (dbInfo.vgVersion < 0 || NULL == dbInfo.vgInfo) { - ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", pDBName, dbInfo.vgVersion, dbInfo.vgInfo); + ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", db, dbInfo.vgVersion, dbInfo.vgInfo); CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); } - CTG_ERR_RET(ctgGetVgInfoFromHashValue(&dbInfo, pDBName, pTableName, pVgroup)); + CTG_ERR_RET(ctgGetVgInfoFromHashValue(&dbInfo, pTableName, pVgroup)); CTG_RET(code); } @@ -640,13 +675,12 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p int32_t code = 0; if (pReq->pTableName) { - char dbName[TSDB_DB_FNAME_LEN]; int32_t tbNum = (int32_t)taosArrayGetSize(pReq->pTableName); if (tbNum <= 0) { ctgError("empty table name list"); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - + pRsp->pTableMeta = taosArrayInit(tbNum, POINTER_BYTES); if (NULL == pRsp->pTableMeta) { ctgError("taosArrayInit num[%d] failed", tbNum); @@ -657,9 +691,7 @@ int32_t catalogGetAllMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* p SName *name = taosArrayGet(pReq->pTableName, i); STableMeta *pTableMeta = NULL; - snprintf(dbName, sizeof(dbName), "%d.%s", name->acctId, name->dbname); - - CTG_ERR_JRET(catalogGetTableMeta(pCatalog, pRpc, pMgmtEps, dbName, name->tname, &pTableMeta)); + CTG_ERR_JRET(catalogGetTableMeta(pCatalog, pRpc, pMgmtEps, name, &pTableMeta)); if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) { ctgError("taosArrayPush failed, idx:%d", i); diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 62279b9e1f..0ad00046cd 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -388,7 +388,11 @@ TEST(tableMeta, normalTable) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetTableHashVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestTablename, &vgInfo); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestTablename); + + code = catalogGetTableHashVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &vgInfo); ASSERT_EQ(code, 0); ASSERT_EQ(vgInfo.vgId, 8); ASSERT_EQ(vgInfo.numOfEps, 3); @@ -396,7 +400,7 @@ TEST(tableMeta, normalTable) { ctgTestSetPrepareTableMeta(); STableMeta *tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestTablename, &tableMeta); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); @@ -408,7 +412,7 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestTablename, &tableMeta); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); @@ -433,14 +437,15 @@ TEST(tableMeta, childTableCase) { //sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); - int32_t code = catalogInit(NULL); + int32_t code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetHandle(ctgTestClusterId, &pCtg); - ASSERT_EQ(code, 0); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestCTablename); STableMeta *tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestCTablename, &tableMeta); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 9); ASSERT_EQ(tableMeta->tableType, TSDB_CHILD_TABLE); @@ -452,7 +457,7 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestCTablename, &tableMeta); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 9); ASSERT_EQ(tableMeta->tableType, TSDB_CHILD_TABLE); @@ -464,7 +469,9 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestSTablename, &tableMeta); + + strcpy(n.tname, ctgTestSTablename); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 0); ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); @@ -488,15 +495,15 @@ TEST(tableMeta, superTableCase) { initQueryModuleMsgHandle(); //sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); - - int32_t code = catalogInit(NULL); + int32_t code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetHandle(ctgTestClusterId, &pCtg); - ASSERT_EQ(code, 0); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestSTablename); STableMeta *tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestSTablename, &tableMeta); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 0); ASSERT_EQ(tableMeta->tableType, TSDB_SUPER_TABLE); @@ -510,7 +517,10 @@ TEST(tableMeta, superTableCase) { ctgTestSetPrepareCTableMeta(); tableMeta = NULL; - code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestCTablename, &tableMeta); + + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestCTablename); + code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 9); ASSERT_EQ(tableMeta->tableType, TSDB_CHILD_TABLE); @@ -522,7 +532,7 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); tableMeta = NULL; - code = catalogRenewAndGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestCTablename, &tableMeta); + code = catalogRenewAndGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 9); ASSERT_EQ(tableMeta->tableType, TSDB_CHILD_TABLE); @@ -550,14 +560,14 @@ TEST(tableDistVgroup, normalTable) { //sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); - int32_t code = catalogInit(NULL); + int32_t code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetHandle(ctgTestClusterId, &pCtg); - ASSERT_EQ(code, 0); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestTablename); - - code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestTablename, &vgList); + code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &vgList); ASSERT_EQ(code, 0); ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); vgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); @@ -585,7 +595,11 @@ TEST(tableDistVgroup, childTableCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestCTablename, &vgList); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestCTablename); + + code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &vgList); ASSERT_EQ(code, 0); ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 1); vgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); @@ -607,14 +621,14 @@ TEST(tableDistVgroup, superTableCase) { initQueryModuleMsgHandle(); //sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); - - int32_t code = catalogInit(NULL); + int32_t code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - code = catalogGetHandle(ctgTestClusterId, &pCtg); - ASSERT_EQ(code, 0); + SName n = {.type = T_NAME_TABLE, .acctId = 1}; + strcpy(n.dbname, "db1"); + strcpy(n.tname, ctgTestSTablename); - code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, ctgTestDbname, ctgTestSTablename, &vgList); + code = catalogGetTableDistVgroup(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &vgList); ASSERT_EQ(code, 0); ASSERT_EQ(taosArrayGetSize((const SArray *)vgList), 10); vgInfo = (SVgroupInfo *)taosArrayGet(vgList, 0); diff --git a/source/libs/parser/inc/astGenerator.h b/source/libs/parser/inc/astGenerator.h index 6ae40b0d71..0febc5ea33 100644 --- a/source/libs/parser/inc/astGenerator.h +++ b/source/libs/parser/inc/astGenerator.h @@ -156,7 +156,7 @@ typedef struct SCreateDbInfo { SToken dbname; int32_t replica; int32_t cacheBlockSize; - int32_t maxTablesPerVnode; + int32_t numOfVgroups; int32_t numOfBlocks; int32_t daysPerFile; int32_t minRowsPerBlock; diff --git a/source/libs/parser/inc/astToMsg.h b/source/libs/parser/inc/astToMsg.h index 5358a523fa..ba33767a05 100644 --- a/source/libs/parser/inc/astToMsg.h +++ b/source/libs/parser/inc/astToMsg.h @@ -4,7 +4,6 @@ #include "parserInt.h" #include "tmsg.h" -int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); SCreateUserMsg* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); SCreateAcctMsg* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen); diff --git a/source/libs/parser/inc/parserUtil.h b/source/libs/parser/inc/parserUtil.h index b7c9f967c1..764b363394 100644 --- a/source/libs/parser/inc/parserUtil.h +++ b/source/libs/parser/inc/parserUtil.h @@ -81,6 +81,8 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param); typedef int32_t (*_row_append_fn_t)(const void *value, int32_t len, void *param); int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, char* tmpTokenBuf, _row_append_fn_t func, void* param, SMsgBuf* pMsgBuf); +int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf); + #ifdef __cplusplus } #endif diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index e9f9c862e2..bf59a0f80a 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -280,6 +280,7 @@ comp(Y) ::= COMP INTEGER(X). { Y = X; } prec(Y) ::= PRECISION STRING(X). { Y = X; } update(Y) ::= UPDATE INTEGER(X). { Y = X; } cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; } +vgroups(Y) ::= VGROUPS INTEGER(X). { Y = X; } //partitions(Y) ::= PARTITIONS INTEGER(X). { Y = X; } %type db_optr {SCreateDbInfo} @@ -300,6 +301,7 @@ db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; } db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; } db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } +db_optr(Y) ::= db_optr(Z) vgroups(X). { Y = Z; Y.numOfVgroups = strtol(X.z, NULL, 10); } //%type topic_optr {SCreateDbInfo} // diff --git a/source/libs/parser/src/astGenerator.c b/source/libs/parser/src/astGenerator.c index 84253395c5..3d12f0f3b7 100644 --- a/source/libs/parser/src/astGenerator.c +++ b/source/libs/parser/src/astGenerator.c @@ -13,11 +13,12 @@ * along with this program. If not, see . */ -#include "astGenerator.h" -#include #include "os.h" #include "taos.h" +#include "tmsg.h" +#include "parserInt.h" #include "tmsgtype.h" +#include "astGenerator.h" SArray *tListItemAppend(SArray *pList, SVariant *pVar, uint8_t sortOrder) { if (pList == NULL) { @@ -947,25 +948,21 @@ void setCompactVnodeSql(SSqlInfo *pInfo, int32_t type, SArray *pParam) { } void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) { - pDBInfo->compressionLevel = -1; - - pDBInfo->walLevel = -1; - pDBInfo->fsyncPeriod = -1; - pDBInfo->commitTime = -1; - pDBInfo->maxTablesPerVnode = -1; - + pDBInfo->compressionLevel= -1; + pDBInfo->walLevel = -1; + pDBInfo->fsyncPeriod = -1; + pDBInfo->commitTime = -1; + pDBInfo->numOfVgroups = 2; pDBInfo->cacheBlockSize = -1; pDBInfo->numOfBlocks = -1; pDBInfo->maxRowsPerBlock = -1; pDBInfo->minRowsPerBlock = -1; pDBInfo->daysPerFile = -1; - - pDBInfo->replica = -1; - pDBInfo->quorum = -1; - pDBInfo->keep = NULL; - - pDBInfo->update = -1; - pDBInfo->cachelast = -1; + pDBInfo->replica = -1; + pDBInfo->quorum = -1; + pDBInfo->keep = NULL; + pDBInfo->update = -1; + pDBInfo->cachelast = -1; memset(&pDBInfo->precision, 0, sizeof(SToken)); } diff --git a/source/libs/parser/src/astToMsg.c b/source/libs/parser/src/astToMsg.c index 483f0d677b..bdbc095861 100644 --- a/source/libs/parser/src/astToMsg.c +++ b/source/libs/parser/src/astToMsg.c @@ -182,19 +182,20 @@ static int32_t setTimePrecision(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreate static void doSetDbOptions(SCreateDbMsg* pMsg, const SCreateDbInfo* pCreateDb) { pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize); - pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); - pMsg->daysPerFile = htonl(pCreateDb->daysPerFile); - pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime); - pMsg->minRows = htonl(pCreateDb->minRowsPerBlock); - pMsg->maxRows = htonl(pCreateDb->maxRowsPerBlock); - pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod); - pMsg->compression = pCreateDb->compressionLevel; - pMsg->walLevel = (char)pCreateDb->walLevel; - pMsg->replications = pCreateDb->replica; - pMsg->quorum = pCreateDb->quorum; - pMsg->ignoreExist = pCreateDb->ignoreExists; - pMsg->update = pCreateDb->update; - pMsg->cacheLastRow = pCreateDb->cachelast; + pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks); + pMsg->daysPerFile = htonl(pCreateDb->daysPerFile); + pMsg->commitTime = htonl((int32_t)pCreateDb->commitTime); + pMsg->minRows = htonl(pCreateDb->minRowsPerBlock); + pMsg->maxRows = htonl(pCreateDb->maxRowsPerBlock); + pMsg->fsyncPeriod = htonl(pCreateDb->fsyncPeriod); + pMsg->compression = (int8_t) pCreateDb->compressionLevel; + pMsg->walLevel = (char)pCreateDb->walLevel; + pMsg->replications = pCreateDb->replica; + pMsg->quorum = pCreateDb->quorum; + pMsg->ignoreExist = pCreateDb->ignoreExists; + pMsg->update = pCreateDb->update; + pMsg->cacheLastRow = pCreateDb->cachelast; + pMsg->numOfVgroups = htonl(pCreateDb->numOfVgroups); } int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbSql, SMsgBuf* pMsgBuf) { @@ -208,8 +209,6 @@ int32_t setDbOptions(SCreateDbMsg* pCreateDbMsg, const SCreateDbInfo* pCreateDbS return TSDB_CODE_TSC_INVALID_OPERATION; } - // todo configurable - pCreateDbMsg->numOfVgroups = htonl(2); return TSDB_CODE_SUCCESS; } @@ -233,45 +232,6 @@ SCreateDbMsg* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCt return pCreateMsg; } -int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) { - const char* msg1 = "name too long"; - const char* msg2 = "acctId too long"; - - int32_t code = TSDB_CODE_SUCCESS; - char* p = strnchr(pTableName->z, TS_PATH_DELIMITER[0], pTableName->n, false); - - if (p != NULL) { // db has been specified in sql string so we ignore current db path - code = tNameSetAcctId(pName, pParseCtx->acctId); - if (code != 0) { - return buildInvalidOperationMsg(pMsgBuf, msg2); - } - - char name[TSDB_TABLE_FNAME_LEN] = {0}; - strncpy(name, pTableName->z, pTableName->n); - - code = tNameFromString(pName, name, T_NAME_DB|T_NAME_TABLE); - if (code != 0) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - } else { // get current DB name first, and then set it into path - if (pTableName->n >= TSDB_TABLE_NAME_LEN) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - - tNameSetDbName(pName, pParseCtx->acctId, pParseCtx->db, strlen(pParseCtx->db)); - - char name[TSDB_TABLE_FNAME_LEN] = {0}; - strncpy(name, pTableName->z, pTableName->n); - - code = tNameFromString(pName, name, T_NAME_TABLE); - if (code != 0) { - code = buildInvalidOperationMsg(pMsgBuf, msg1); - } - } - - return code; -} - SCreateStbMsg* buildCreateTableMsg(SCreateTableSql* pCreateTableSql, int32_t* len, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) { SSchema* pSchema; diff --git a/source/libs/parser/src/dCDAstProcess.c b/source/libs/parser/src/dCDAstProcess.c index 2bcf92b184..7160b13eba 100644 --- a/source/libs/parser/src/dCDAstProcess.c +++ b/source/libs/parser/src/dCDAstProcess.c @@ -157,6 +157,12 @@ static int32_t doCheckDbOptions(SCreateDbMsg* pCreate, SMsgBuf* pMsgBuf) { return buildInvalidOperationMsg(pMsgBuf, msg); } + val = htonl(pCreate->numOfVgroups); + if (val < TSDB_MIN_VNODES_PER_DB || val > TSDB_MAX_VNODES_PER_DB) { + snprintf(msg, tListLen(msg), "invalid number of vgroups for DB:%d valid range: [%d, %d]", val, + TSDB_MIN_VNODES_PER_DB, TSDB_MAX_VNODES_PER_DB); + } + return TSDB_CODE_SUCCESS; } @@ -316,16 +322,12 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p return code; } - const char* pStableName = tNameGetTableName(&name); - SArray* pValList = pCreateTableInfo->pTagVals; + SArray* pValList = pCreateTableInfo->pTagVals; size_t numOfInputTag = taosArrayGetSize(pValList); STableMeta* pSuperTableMeta = NULL; - char dbName[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&name, dbName); - - catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, pStableName, &pSuperTableMeta); + catalogGetTableMeta(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, &name, &pSuperTableMeta); assert(pSuperTableMeta != NULL); // too long tag values will return invalid sql, not be truncated automatically @@ -488,7 +490,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p *len = serLen; SVgroupInfo info = {0}; - catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, dbName, req.name, &info); + catalogGetTableHashVgroup(pCtx->pCatalog, pCtx->pTransporter, &pCtx->mgmtEpSet, &tableName, &info); pEpSet->inUse = info.inUse; pEpSet->numOfEps = info.numOfEps; @@ -496,6 +498,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx* pCtx, SMsgBuf* p pEpSet->port[i] = info.epAddr[i].port; tstrncpy(pEpSet->fqdn[i], info.epAddr[i].fqdn, tListLen(pEpSet->fqdn[i])); } + ((SMsgHead*)(*pOutput))->vgId = htonl(info.vgId); ((SMsgHead*)(*pOutput))->contLen = htonl(serLen); } diff --git a/source/libs/parser/src/insertParser.c b/source/libs/parser/src/insertParser.c index 5574c7316c..991bde5ed2 100644 --- a/source/libs/parser/src/insertParser.c +++ b/source/libs/parser/src/insertParser.c @@ -154,12 +154,17 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD } static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { - char fullDbName[TSDB_DB_FNAME_LEN] = {0}; - char tableName[TSDB_TABLE_NAME_LEN] = {0}; - CHECK_CODE(buildName(pCxt, pTname, fullDbName, tableName)); - CHECK_CODE(catalogGetTableMeta(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &pCxt->pTableMeta)); + SName name = {0}; + createSName(&name, pTname, &pCxt->pComCxt->ctx, &pCxt->msg); + + char tableName[TSDB_TABLE_FNAME_LEN] = {0}; + tNameExtractFullName(&name, tableName); + + SParseBasicCtx* pBasicCtx = &pCxt->pComCxt->ctx; + CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + SVgroupInfo vg; - CHECK_CODE(catalogGetTableHashVgroup(pCxt->pComCxt->ctx.pCatalog, pCxt->pComCxt->ctx.pTransporter, &pCxt->pComCxt->ctx.mgmtEpSet, fullDbName, tableName, &vg)); + CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parserUtil.c b/source/libs/parser/src/parserUtil.c index 6e814038a7..20f330247e 100644 --- a/source/libs/parser/src/parserUtil.c +++ b/source/libs/parser/src/parserUtil.c @@ -1946,4 +1946,39 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param) { } return TSDB_CODE_SUCCESS; -} \ No newline at end of file +} + +int32_t createSName(SName* pName, SToken* pTableName, SParseBasicCtx* pParseCtx, SMsgBuf* pMsgBuf) { + const char* msg1 = "name too long"; + + int32_t code = TSDB_CODE_SUCCESS; + char* p = strnchr(pTableName->z, TS_PATH_DELIMITER[0], pTableName->n, false); + + if (p != NULL) { // db has been specified in sql string so we ignore current db path + tNameSetAcctId(pName, pParseCtx->acctId); + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, pTableName->n); + + code = tNameFromString(pName, name, T_NAME_DB|T_NAME_TABLE); + if (code != 0) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + } else { // get current DB name first, and then set it into path + if (pTableName->n >= TSDB_TABLE_NAME_LEN) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + + tNameSetDbName(pName, pParseCtx->acctId, pParseCtx->db, strlen(pParseCtx->db)); + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, pTableName->n); + + code = tNameFromString(pName, name, T_NAME_TABLE); + if (code != 0) { + code = buildInvalidOperationMsg(pMsgBuf, msg1); + } + } + + return code; +} diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index d091751a56..f7f56510da 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -97,30 +97,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 273 +#define YYNOCODE 274 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SSqlNode* yy24; - int yy60; - SSubclause* yy129; - SIntervalVal yy136; - int64_t yy157; - SCreateAcctInfo yy171; - SSessionWindowVal yy251; - SCreateDbInfo yy254; - SWindowStateVal yy256; - SField yy280; - SRelationInfo* yy292; - tSqlExpr* yy370; - SArray* yy413; - SCreateTableSql* yy438; - SVariant yy461; - SLimit yy503; - int32_t yy516; - SCreatedTableInfo yy544; + SWindowStateVal yy6; + SRelationInfo* yy10; + SCreateDbInfo yy16; + int32_t yy46; + int yy47; + SSessionWindowVal yy97; + SField yy106; + SCreatedTableInfo yy150; + SArray* yy165; + tSqlExpr* yy202; + int64_t yy207; + SCreateAcctInfo yy211; + SSqlNode* yy278; + SCreateTableSql* yy326; + SLimit yy367; + SVariant yy425; + SSubclause* yy503; + SIntervalVal yy532; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -130,17 +130,17 @@ typedef union { #define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 365 -#define YYNRULE 301 +#define YYNSTATE 366 +#define YYNRULE 303 #define YYNTOKEN 191 -#define YY_MAX_SHIFT 364 -#define YY_MIN_SHIFTREDUCE 584 -#define YY_MAX_SHIFTREDUCE 884 -#define YY_ERROR_ACTION 885 -#define YY_ACCEPT_ACTION 886 -#define YY_NO_ACTION 887 -#define YY_MIN_REDUCE 888 -#define YY_MAX_REDUCE 1188 +#define YY_MAX_SHIFT 365 +#define YY_MIN_SHIFTREDUCE 587 +#define YY_MAX_SHIFTREDUCE 889 +#define YY_ERROR_ACTION 890 +#define YY_ACCEPT_ACTION 891 +#define YY_NO_ACTION 892 +#define YY_MIN_REDUCE 893 +#define YY_MAX_REDUCE 1195 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -206,292 +206,294 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (779) +#define YY_ACTTAB_COUNT (782) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1073, 635, 155, 363, 230, 636, 671, 55, 56, 635, - /* 10 */ 59, 60, 1032, 636, 252, 49, 48, 47, 162, 58, - /* 20 */ 322, 63, 61, 64, 62, 236, 1050, 242, 206, 54, - /* 30 */ 53, 1038, 635, 52, 51, 50, 636, 55, 56, 1164, - /* 40 */ 59, 60, 936, 1063, 252, 49, 48, 47, 188, 58, - /* 50 */ 322, 63, 61, 64, 62, 1010, 243, 1008, 1009, 54, - /* 60 */ 53, 233, 1011, 52, 51, 50, 1012, 1070, 1013, 1014, - /* 70 */ 280, 279, 947, 55, 56, 246, 59, 60, 188, 1038, - /* 80 */ 252, 49, 48, 47, 81, 58, 322, 63, 61, 64, - /* 90 */ 62, 320, 1112, 99, 292, 54, 53, 352, 635, 52, - /* 100 */ 51, 50, 636, 55, 57, 261, 59, 60, 318, 821, - /* 110 */ 252, 49, 48, 47, 176, 58, 322, 63, 61, 64, - /* 120 */ 62, 42, 249, 358, 357, 54, 53, 1026, 356, 52, - /* 130 */ 51, 50, 355, 87, 354, 353, 886, 364, 585, 586, - /* 140 */ 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, - /* 150 */ 597, 598, 153, 56, 231, 59, 60, 767, 1063, 252, - /* 160 */ 49, 48, 47, 171, 58, 322, 63, 61, 64, 62, - /* 170 */ 162, 43, 1024, 86, 54, 53, 234, 21, 52, 51, - /* 180 */ 50, 282, 206, 1063, 635, 59, 60, 203, 636, 252, - /* 190 */ 49, 48, 47, 1165, 58, 322, 63, 61, 64, 62, - /* 200 */ 162, 274, 827, 830, 54, 53, 786, 787, 52, 51, - /* 210 */ 50, 36, 42, 316, 358, 357, 315, 314, 313, 356, - /* 220 */ 312, 311, 310, 355, 309, 354, 353, 1004, 992, 993, - /* 230 */ 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, - /* 240 */ 1005, 1006, 294, 771, 92, 22, 63, 61, 64, 62, - /* 250 */ 826, 829, 318, 232, 54, 53, 204, 1035, 52, 51, - /* 260 */ 50, 27, 215, 36, 251, 836, 825, 828, 831, 216, - /* 270 */ 750, 747, 748, 749, 1111, 137, 136, 135, 217, 162, - /* 280 */ 266, 255, 327, 87, 251, 836, 825, 828, 831, 270, - /* 290 */ 269, 96, 228, 229, 261, 261, 323, 257, 258, 742, - /* 300 */ 739, 740, 741, 177, 1036, 240, 3, 39, 178, 1035, - /* 310 */ 260, 209, 228, 229, 105, 77, 101, 108, 250, 248, - /* 320 */ 834, 43, 1021, 1022, 33, 1025, 244, 245, 197, 195, - /* 330 */ 193, 52, 51, 50, 305, 192, 141, 140, 139, 138, - /* 340 */ 4, 65, 253, 273, 80, 79, 122, 116, 126, 152, - /* 350 */ 150, 149, 224, 93, 36, 131, 134, 125, 256, 36, - /* 360 */ 254, 65, 330, 329, 128, 54, 53, 714, 835, 52, - /* 370 */ 51, 50, 87, 36, 36, 36, 1023, 837, 832, 206, - /* 380 */ 36, 36, 751, 752, 833, 36, 36, 262, 36, 259, - /* 390 */ 1165, 337, 336, 342, 341, 803, 241, 837, 832, 764, - /* 400 */ 1035, 331, 206, 12, 833, 1035, 84, 85, 937, 95, - /* 410 */ 43, 743, 744, 1165, 188, 332, 333, 334, 324, 1035, - /* 420 */ 1035, 1035, 338, 339, 7, 124, 1035, 1035, 340, 94, - /* 430 */ 344, 1034, 1035, 275, 1035, 362, 361, 146, 98, 352, - /* 440 */ 359, 974, 783, 82, 70, 70, 793, 794, 71, 37, - /* 450 */ 724, 74, 297, 802, 726, 299, 737, 738, 157, 735, - /* 460 */ 736, 725, 66, 24, 32, 823, 37, 859, 37, 838, - /* 470 */ 67, 97, 634, 14, 115, 13, 114, 67, 78, 16, - /* 480 */ 18, 15, 17, 23, 121, 23, 120, 210, 23, 72, - /* 490 */ 75, 211, 755, 756, 753, 754, 1159, 824, 300, 20, - /* 500 */ 1158, 19, 133, 132, 1157, 226, 1037, 1049, 1065, 227, - /* 510 */ 207, 713, 208, 212, 205, 213, 214, 219, 220, 221, - /* 520 */ 218, 202, 1184, 840, 1176, 44, 1122, 1121, 321, 271, - /* 530 */ 238, 1118, 1117, 239, 343, 154, 1104, 1072, 1083, 1080, - /* 540 */ 1081, 1085, 156, 161, 1064, 277, 288, 1103, 1033, 173, - /* 550 */ 151, 281, 172, 1031, 174, 175, 951, 782, 306, 302, - /* 560 */ 303, 170, 164, 304, 307, 163, 308, 1061, 295, 291, - /* 570 */ 165, 200, 40, 319, 946, 945, 235, 328, 1183, 112, - /* 580 */ 283, 1182, 285, 1179, 76, 179, 335, 73, 1175, 118, - /* 590 */ 1174, 1171, 180, 971, 46, 41, 38, 201, 934, 127, - /* 600 */ 932, 129, 130, 293, 930, 929, 263, 190, 191, 926, - /* 610 */ 925, 924, 923, 922, 921, 920, 194, 196, 917, 915, - /* 620 */ 913, 911, 289, 198, 908, 199, 904, 287, 284, 276, - /* 630 */ 83, 88, 45, 286, 1105, 123, 345, 346, 347, 348, - /* 640 */ 349, 225, 350, 247, 301, 351, 360, 884, 264, 265, - /* 650 */ 883, 222, 267, 950, 949, 106, 223, 268, 882, 865, - /* 660 */ 864, 272, 70, 8, 928, 296, 927, 758, 183, 182, - /* 670 */ 972, 181, 142, 184, 185, 187, 186, 143, 919, 918, - /* 680 */ 973, 144, 145, 910, 909, 28, 278, 89, 31, 784, - /* 690 */ 2, 166, 167, 158, 168, 169, 795, 159, 1, 789, - /* 700 */ 160, 90, 237, 791, 91, 290, 29, 9, 30, 10, - /* 710 */ 11, 25, 298, 26, 98, 100, 34, 103, 102, 649, - /* 720 */ 684, 35, 104, 682, 681, 680, 678, 677, 676, 673, - /* 730 */ 639, 107, 109, 325, 110, 839, 317, 5, 6, 841, - /* 740 */ 326, 68, 111, 113, 69, 716, 117, 119, 37, 715, - /* 750 */ 712, 665, 663, 655, 661, 657, 659, 653, 651, 686, - /* 760 */ 685, 683, 679, 675, 674, 189, 602, 637, 888, 887, - /* 770 */ 887, 887, 887, 887, 887, 887, 887, 147, 148, + /* 0 */ 249, 638, 364, 230, 162, 639, 248, 55, 56, 638, + /* 10 */ 59, 60, 1031, 639, 252, 49, 48, 47, 94, 58, + /* 20 */ 323, 63, 61, 64, 62, 674, 1080, 891, 365, 54, + /* 30 */ 53, 206, 82, 52, 51, 50, 253, 55, 56, 638, + /* 40 */ 59, 60, 1171, 639, 252, 49, 48, 47, 21, 58, + /* 50 */ 323, 63, 61, 64, 62, 1017, 203, 1015, 1016, 54, + /* 60 */ 53, 206, 1018, 52, 51, 50, 1019, 206, 1020, 1021, + /* 70 */ 832, 835, 1172, 55, 56, 1070, 59, 60, 1172, 1118, + /* 80 */ 252, 49, 48, 47, 81, 58, 323, 63, 61, 64, + /* 90 */ 62, 321, 319, 274, 1077, 54, 53, 206, 638, 52, + /* 100 */ 51, 50, 639, 55, 57, 353, 59, 60, 1172, 826, + /* 110 */ 252, 49, 48, 47, 155, 58, 323, 63, 61, 64, + /* 120 */ 62, 42, 319, 359, 358, 54, 53, 162, 357, 52, + /* 130 */ 51, 50, 356, 87, 355, 354, 162, 162, 588, 589, + /* 140 */ 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, + /* 150 */ 600, 601, 153, 56, 231, 59, 60, 236, 1057, 252, + /* 160 */ 49, 48, 47, 87, 58, 323, 63, 61, 64, 62, + /* 170 */ 772, 43, 32, 86, 54, 53, 255, 204, 52, 51, + /* 180 */ 50, 309, 209, 280, 279, 59, 60, 941, 839, 252, + /* 190 */ 49, 48, 47, 188, 58, 323, 63, 61, 64, 62, + /* 200 */ 294, 43, 92, 242, 54, 53, 300, 1045, 52, 51, + /* 210 */ 50, 1119, 93, 292, 42, 317, 359, 358, 316, 315, + /* 220 */ 314, 357, 313, 312, 311, 356, 310, 355, 354, 99, + /* 230 */ 22, 1010, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, + /* 240 */ 1006, 1007, 1008, 1009, 1011, 1012, 1013, 215, 251, 841, + /* 250 */ 830, 833, 836, 256, 216, 254, 776, 331, 330, 250, + /* 260 */ 137, 136, 135, 217, 1033, 266, 719, 328, 87, 251, + /* 270 */ 841, 830, 833, 836, 270, 269, 228, 229, 831, 834, + /* 280 */ 324, 4, 63, 61, 64, 62, 755, 752, 753, 754, + /* 290 */ 54, 53, 343, 342, 52, 51, 50, 228, 229, 747, + /* 300 */ 744, 745, 746, 52, 51, 50, 43, 3, 39, 178, + /* 310 */ 152, 150, 149, 257, 258, 105, 77, 101, 108, 1039, + /* 320 */ 96, 791, 792, 260, 36, 65, 244, 245, 273, 36, + /* 330 */ 79, 197, 195, 193, 36, 305, 210, 224, 192, 141, + /* 340 */ 140, 139, 138, 36, 36, 36, 65, 122, 116, 126, + /* 350 */ 36, 211, 1028, 1029, 33, 1032, 131, 134, 125, 638, + /* 360 */ 36, 842, 837, 639, 243, 128, 36, 232, 838, 54, + /* 370 */ 53, 1042, 240, 52, 51, 50, 1042, 241, 36, 36, + /* 380 */ 36, 1042, 842, 837, 1166, 261, 332, 333, 334, 838, + /* 390 */ 1042, 1042, 1042, 335, 176, 12, 840, 1042, 756, 757, + /* 400 */ 262, 95, 259, 339, 338, 337, 171, 1042, 363, 362, + /* 410 */ 146, 748, 749, 1041, 246, 80, 808, 1070, 1045, 1070, + /* 420 */ 261, 340, 341, 345, 282, 1042, 1042, 1042, 124, 177, + /* 430 */ 98, 261, 952, 942, 769, 233, 27, 234, 188, 188, + /* 440 */ 1043, 275, 353, 360, 979, 84, 85, 788, 1030, 798, + /* 450 */ 799, 71, 74, 729, 297, 731, 299, 37, 325, 7, + /* 460 */ 742, 743, 730, 157, 828, 66, 24, 740, 741, 37, + /* 470 */ 37, 67, 97, 864, 807, 760, 761, 843, 67, 637, + /* 480 */ 14, 78, 13, 70, 70, 115, 1165, 114, 16, 23, + /* 490 */ 15, 75, 72, 23, 1111, 23, 829, 758, 759, 133, + /* 500 */ 132, 18, 121, 17, 120, 20, 1164, 19, 1129, 226, + /* 510 */ 322, 227, 207, 1056, 718, 208, 212, 205, 213, 214, + /* 520 */ 1044, 219, 1072, 220, 1191, 221, 218, 202, 1128, 1183, + /* 530 */ 238, 1125, 1124, 239, 344, 271, 154, 44, 172, 1079, + /* 540 */ 151, 1110, 1090, 1087, 1088, 1071, 277, 1092, 1040, 156, + /* 550 */ 1068, 281, 235, 283, 31, 161, 285, 165, 288, 173, + /* 560 */ 163, 168, 787, 845, 164, 276, 1038, 174, 166, 169, + /* 570 */ 167, 291, 175, 956, 302, 303, 304, 76, 307, 308, + /* 580 */ 200, 40, 320, 951, 950, 329, 1190, 112, 73, 1189, + /* 590 */ 1186, 179, 46, 336, 295, 1182, 118, 287, 1181, 1178, + /* 600 */ 180, 976, 41, 38, 201, 939, 127, 937, 129, 130, + /* 610 */ 935, 934, 263, 190, 191, 931, 930, 929, 928, 293, + /* 620 */ 927, 926, 925, 194, 196, 922, 920, 918, 916, 198, + /* 630 */ 913, 199, 909, 289, 284, 83, 88, 45, 286, 1112, + /* 640 */ 306, 123, 346, 225, 247, 347, 301, 348, 349, 351, + /* 650 */ 222, 223, 350, 352, 361, 955, 954, 106, 889, 264, + /* 660 */ 265, 888, 267, 268, 887, 870, 933, 869, 272, 183, + /* 670 */ 182, 977, 932, 181, 142, 184, 185, 187, 186, 143, + /* 680 */ 144, 924, 978, 923, 2, 70, 145, 915, 914, 296, + /* 690 */ 8, 28, 1, 763, 278, 170, 789, 89, 158, 160, + /* 700 */ 800, 159, 237, 794, 90, 29, 796, 91, 290, 9, + /* 710 */ 30, 10, 11, 25, 26, 298, 100, 34, 98, 103, + /* 720 */ 652, 102, 690, 35, 104, 687, 685, 684, 683, 681, + /* 730 */ 680, 679, 676, 642, 326, 327, 107, 111, 109, 318, + /* 740 */ 113, 110, 5, 68, 844, 846, 6, 69, 721, 37, + /* 750 */ 117, 119, 720, 717, 668, 666, 658, 664, 660, 662, + /* 760 */ 656, 654, 689, 688, 686, 682, 678, 677, 189, 640, + /* 770 */ 893, 605, 892, 892, 892, 892, 892, 892, 892, 892, + /* 780 */ 147, 148, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 194, 1, 194, 194, 195, 5, 3, 7, 8, 1, - /* 10 */ 10, 11, 194, 5, 14, 15, 16, 17, 194, 19, - /* 20 */ 20, 21, 22, 23, 24, 242, 243, 237, 260, 29, - /* 30 */ 30, 241, 1, 33, 34, 35, 5, 7, 8, 271, - /* 40 */ 10, 11, 199, 239, 14, 15, 16, 17, 205, 19, - /* 50 */ 20, 21, 22, 23, 24, 216, 238, 218, 219, 29, - /* 60 */ 30, 257, 223, 33, 34, 35, 227, 261, 229, 230, - /* 70 */ 262, 263, 199, 7, 8, 237, 10, 11, 205, 241, + /* 0 */ 200, 1, 194, 195, 194, 5, 200, 7, 8, 1, + /* 10 */ 10, 11, 0, 5, 14, 15, 16, 17, 245, 19, + /* 20 */ 20, 21, 22, 23, 24, 3, 194, 192, 193, 29, + /* 30 */ 30, 261, 259, 33, 34, 35, 200, 7, 8, 1, + /* 40 */ 10, 11, 272, 5, 14, 15, 16, 17, 261, 19, + /* 50 */ 20, 21, 22, 23, 24, 216, 261, 218, 219, 29, + /* 60 */ 30, 261, 223, 33, 34, 35, 227, 261, 229, 230, + /* 70 */ 3, 4, 272, 7, 8, 240, 10, 11, 272, 269, /* 80 */ 14, 15, 16, 17, 84, 19, 20, 21, 22, 23, - /* 90 */ 24, 83, 268, 201, 270, 29, 30, 88, 1, 33, - /* 100 */ 34, 35, 5, 7, 8, 194, 10, 11, 80, 79, - /* 110 */ 14, 15, 16, 17, 203, 19, 20, 21, 22, 23, - /* 120 */ 24, 96, 200, 98, 99, 29, 30, 235, 103, 33, - /* 130 */ 34, 35, 107, 78, 109, 110, 192, 193, 41, 42, + /* 90 */ 24, 83, 80, 258, 262, 29, 30, 261, 1, 33, + /* 100 */ 34, 35, 5, 7, 8, 88, 10, 11, 272, 79, + /* 110 */ 14, 15, 16, 17, 194, 19, 20, 21, 22, 23, + /* 120 */ 24, 96, 80, 98, 99, 29, 30, 194, 103, 33, + /* 130 */ 34, 35, 107, 78, 109, 110, 194, 194, 41, 42, /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - /* 150 */ 53, 54, 55, 8, 57, 10, 11, 33, 239, 14, - /* 160 */ 15, 16, 17, 247, 19, 20, 21, 22, 23, 24, - /* 170 */ 194, 116, 0, 118, 29, 30, 257, 260, 33, 34, - /* 180 */ 35, 265, 260, 239, 1, 10, 11, 260, 5, 14, - /* 190 */ 15, 16, 17, 271, 19, 20, 21, 22, 23, 24, - /* 200 */ 194, 257, 3, 4, 29, 30, 122, 123, 33, 34, - /* 210 */ 35, 194, 96, 97, 98, 99, 100, 101, 102, 103, - /* 220 */ 104, 105, 106, 107, 108, 109, 110, 216, 217, 218, - /* 230 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - /* 240 */ 229, 230, 266, 119, 268, 40, 21, 22, 23, 24, - /* 250 */ 3, 4, 80, 236, 29, 30, 260, 240, 33, 34, - /* 260 */ 35, 78, 57, 194, 1, 2, 3, 4, 5, 64, - /* 270 */ 2, 3, 4, 5, 268, 70, 71, 72, 73, 194, - /* 280 */ 139, 64, 77, 78, 1, 2, 3, 4, 5, 148, - /* 290 */ 149, 201, 29, 30, 194, 194, 33, 29, 30, 2, - /* 300 */ 3, 4, 5, 203, 203, 236, 58, 59, 60, 240, - /* 310 */ 64, 260, 29, 30, 66, 67, 68, 69, 56, 200, - /* 320 */ 121, 116, 232, 233, 234, 235, 29, 30, 58, 59, - /* 330 */ 60, 33, 34, 35, 86, 65, 66, 67, 68, 69, - /* 340 */ 78, 78, 200, 138, 201, 140, 58, 59, 60, 58, - /* 350 */ 59, 60, 147, 268, 194, 67, 68, 69, 141, 194, - /* 360 */ 143, 78, 145, 146, 76, 29, 30, 3, 121, 33, - /* 370 */ 34, 35, 78, 194, 194, 194, 233, 114, 115, 260, - /* 380 */ 194, 194, 114, 115, 121, 194, 194, 141, 194, 143, - /* 390 */ 271, 145, 146, 29, 30, 72, 236, 114, 115, 95, - /* 400 */ 240, 236, 260, 78, 121, 240, 79, 79, 199, 84, - /* 410 */ 116, 114, 115, 271, 205, 236, 236, 236, 9, 240, - /* 420 */ 240, 240, 236, 236, 120, 74, 240, 240, 236, 244, - /* 430 */ 236, 240, 240, 79, 240, 61, 62, 63, 113, 88, - /* 440 */ 214, 215, 79, 258, 117, 117, 79, 79, 95, 95, - /* 450 */ 79, 95, 79, 130, 79, 79, 3, 4, 95, 3, - /* 460 */ 4, 79, 95, 95, 78, 1, 95, 79, 95, 79, - /* 470 */ 95, 95, 79, 142, 142, 144, 144, 95, 78, 142, - /* 480 */ 142, 144, 144, 95, 142, 95, 144, 260, 95, 136, - /* 490 */ 134, 260, 3, 4, 3, 4, 260, 33, 112, 142, - /* 500 */ 260, 144, 74, 75, 260, 260, 241, 243, 239, 260, - /* 510 */ 260, 111, 260, 260, 260, 260, 260, 260, 260, 260, - /* 520 */ 260, 260, 243, 114, 243, 259, 231, 231, 194, 194, - /* 530 */ 231, 231, 231, 231, 231, 194, 269, 194, 194, 194, - /* 540 */ 194, 194, 194, 194, 239, 239, 194, 269, 239, 194, - /* 550 */ 56, 264, 245, 194, 194, 194, 194, 121, 87, 194, - /* 560 */ 194, 248, 254, 194, 194, 255, 194, 256, 128, 126, - /* 570 */ 253, 194, 194, 194, 194, 194, 264, 194, 194, 194, - /* 580 */ 264, 194, 264, 194, 133, 194, 194, 135, 194, 194, - /* 590 */ 194, 194, 194, 194, 132, 194, 194, 194, 194, 194, - /* 600 */ 194, 194, 194, 131, 194, 194, 194, 194, 194, 194, - /* 610 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - /* 620 */ 194, 194, 125, 194, 194, 194, 194, 124, 127, 196, - /* 630 */ 196, 196, 137, 196, 196, 94, 93, 47, 90, 92, - /* 640 */ 51, 196, 91, 196, 196, 89, 80, 3, 150, 3, - /* 650 */ 3, 196, 150, 204, 204, 201, 196, 3, 3, 98, - /* 660 */ 97, 139, 117, 78, 196, 112, 196, 79, 207, 211, - /* 670 */ 213, 212, 197, 210, 208, 206, 209, 197, 196, 196, - /* 680 */ 215, 197, 197, 196, 196, 78, 95, 95, 246, 79, - /* 690 */ 198, 252, 251, 78, 250, 249, 79, 78, 202, 79, - /* 700 */ 95, 78, 1, 79, 78, 78, 95, 129, 95, 129, - /* 710 */ 78, 78, 112, 78, 113, 74, 85, 66, 84, 3, - /* 720 */ 5, 85, 84, 3, 3, 3, 3, 3, 3, 3, - /* 730 */ 81, 74, 82, 20, 82, 79, 9, 78, 78, 114, - /* 740 */ 55, 10, 144, 144, 10, 3, 144, 144, 95, 3, - /* 750 */ 79, 3, 3, 3, 3, 3, 3, 3, 3, 3, - /* 760 */ 3, 3, 3, 3, 3, 95, 56, 81, 0, 272, - /* 770 */ 272, 272, 272, 272, 272, 272, 272, 15, 15, 272, - /* 780 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 790 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 800 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 810 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 820 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 830 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 840 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 850 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 860 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 870 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 880 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 890 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 900 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 910 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 920 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 930 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 940 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 950 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - /* 960 */ 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, + /* 150 */ 53, 54, 55, 8, 57, 10, 11, 243, 244, 14, + /* 160 */ 15, 16, 17, 78, 19, 20, 21, 22, 23, 24, + /* 170 */ 33, 116, 78, 118, 29, 30, 64, 261, 33, 34, + /* 180 */ 35, 63, 261, 263, 264, 10, 11, 199, 121, 14, + /* 190 */ 15, 16, 17, 205, 19, 20, 21, 22, 23, 24, + /* 200 */ 267, 116, 269, 238, 29, 30, 112, 242, 33, 34, + /* 210 */ 35, 269, 269, 271, 96, 97, 98, 99, 100, 101, + /* 220 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 201, + /* 230 */ 40, 216, 217, 218, 219, 220, 221, 222, 223, 224, + /* 240 */ 225, 226, 227, 228, 229, 230, 231, 57, 1, 2, + /* 250 */ 3, 4, 5, 141, 64, 143, 119, 145, 146, 56, + /* 260 */ 70, 71, 72, 73, 236, 139, 3, 77, 78, 1, + /* 270 */ 2, 3, 4, 5, 148, 149, 29, 30, 3, 4, + /* 280 */ 33, 78, 21, 22, 23, 24, 2, 3, 4, 5, + /* 290 */ 29, 30, 29, 30, 33, 34, 35, 29, 30, 2, + /* 300 */ 3, 4, 5, 33, 34, 35, 116, 58, 59, 60, + /* 310 */ 58, 59, 60, 29, 30, 66, 67, 68, 69, 194, + /* 320 */ 201, 122, 123, 64, 194, 78, 29, 30, 138, 194, + /* 330 */ 140, 58, 59, 60, 194, 86, 261, 147, 65, 66, + /* 340 */ 67, 68, 69, 194, 194, 194, 78, 58, 59, 60, + /* 350 */ 194, 261, 233, 234, 235, 236, 67, 68, 69, 1, + /* 360 */ 194, 114, 115, 5, 239, 76, 194, 237, 121, 29, + /* 370 */ 30, 241, 237, 33, 34, 35, 241, 237, 194, 194, + /* 380 */ 194, 241, 114, 115, 261, 194, 237, 237, 237, 121, + /* 390 */ 241, 241, 241, 237, 203, 78, 121, 241, 114, 115, + /* 400 */ 141, 84, 143, 237, 145, 146, 248, 241, 61, 62, + /* 410 */ 63, 114, 115, 241, 238, 201, 72, 240, 242, 240, + /* 420 */ 194, 237, 237, 237, 266, 241, 241, 241, 74, 203, + /* 430 */ 113, 194, 199, 199, 95, 258, 78, 258, 205, 205, + /* 440 */ 203, 79, 88, 214, 215, 79, 79, 79, 234, 79, + /* 450 */ 79, 95, 95, 79, 79, 79, 79, 95, 9, 120, + /* 460 */ 3, 4, 79, 95, 1, 95, 95, 3, 4, 95, + /* 470 */ 95, 95, 95, 79, 130, 3, 4, 79, 95, 79, + /* 480 */ 142, 78, 144, 117, 117, 142, 261, 144, 142, 95, + /* 490 */ 144, 134, 136, 95, 270, 95, 33, 3, 4, 74, + /* 500 */ 75, 142, 142, 144, 144, 142, 261, 144, 232, 261, + /* 510 */ 194, 261, 261, 244, 111, 261, 261, 261, 261, 261, + /* 520 */ 242, 261, 240, 261, 244, 261, 261, 261, 232, 244, + /* 530 */ 232, 232, 232, 232, 232, 194, 194, 260, 246, 194, + /* 540 */ 56, 270, 194, 194, 194, 240, 240, 194, 240, 194, + /* 550 */ 257, 265, 265, 265, 247, 194, 265, 254, 194, 194, + /* 560 */ 256, 251, 121, 114, 255, 196, 194, 194, 253, 250, + /* 570 */ 252, 126, 194, 194, 194, 194, 194, 133, 194, 194, + /* 580 */ 194, 194, 194, 194, 194, 194, 194, 194, 135, 194, + /* 590 */ 194, 194, 132, 194, 128, 194, 194, 124, 194, 194, + /* 600 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + /* 610 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 131, + /* 620 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + /* 630 */ 194, 194, 194, 125, 127, 196, 196, 137, 196, 196, + /* 640 */ 87, 94, 93, 196, 196, 47, 196, 90, 92, 91, + /* 650 */ 196, 196, 51, 89, 80, 204, 204, 201, 3, 150, + /* 660 */ 3, 3, 150, 3, 3, 98, 196, 97, 139, 207, + /* 670 */ 211, 213, 196, 212, 197, 210, 208, 206, 209, 197, + /* 680 */ 197, 196, 215, 196, 198, 117, 197, 196, 196, 112, + /* 690 */ 78, 78, 202, 79, 95, 249, 79, 95, 78, 95, + /* 700 */ 79, 78, 1, 79, 78, 95, 79, 78, 78, 129, + /* 710 */ 95, 129, 78, 78, 78, 112, 74, 85, 113, 66, + /* 720 */ 3, 84, 3, 85, 84, 5, 3, 3, 3, 3, + /* 730 */ 3, 3, 3, 81, 20, 55, 74, 144, 82, 9, + /* 740 */ 144, 82, 78, 10, 79, 114, 78, 10, 3, 95, + /* 750 */ 144, 144, 3, 79, 3, 3, 3, 3, 3, 3, + /* 760 */ 3, 3, 3, 3, 3, 3, 3, 3, 95, 81, + /* 770 */ 0, 56, 273, 273, 273, 273, 273, 273, 273, 273, + /* 780 */ 15, 15, 273, 273, 273, 273, 273, 273, 273, 273, + /* 790 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 800 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 810 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 820 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 830 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 840 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 850 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 860 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 870 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 880 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 890 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 900 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 910 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 920 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 930 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 940 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 950 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 960 */ 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + /* 970 */ 273, 273, 273, }; -#define YY_SHIFT_COUNT (364) +#define YY_SHIFT_COUNT (365) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (768) +#define YY_SHIFT_MAX (770) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 205, 116, 25, 28, 263, 283, 283, 183, 31, 31, - /* 10 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 20 */ 31, 0, 97, 283, 268, 297, 297, 294, 294, 31, - /* 30 */ 31, 84, 31, 172, 31, 31, 31, 31, 351, 28, - /* 40 */ 9, 9, 3, 779, 283, 283, 283, 283, 283, 283, - /* 50 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, - /* 60 */ 283, 283, 283, 283, 283, 283, 268, 297, 268, 268, - /* 70 */ 55, 364, 364, 364, 364, 364, 364, 8, 364, 31, - /* 80 */ 31, 31, 124, 31, 31, 31, 294, 294, 31, 31, - /* 90 */ 31, 31, 323, 323, 304, 294, 31, 31, 31, 31, - /* 100 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 110 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 120 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 130 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 140 */ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - /* 150 */ 31, 31, 31, 31, 494, 494, 494, 436, 436, 436, - /* 160 */ 436, 494, 494, 451, 452, 440, 462, 472, 443, 497, - /* 170 */ 503, 501, 495, 494, 494, 494, 471, 471, 28, 494, - /* 180 */ 494, 541, 543, 590, 548, 547, 589, 551, 556, 3, - /* 190 */ 494, 494, 566, 566, 494, 566, 494, 566, 494, 494, - /* 200 */ 779, 779, 30, 66, 66, 96, 66, 145, 175, 225, - /* 210 */ 225, 225, 225, 225, 225, 248, 270, 288, 336, 336, - /* 220 */ 336, 336, 217, 246, 141, 325, 298, 298, 199, 247, - /* 230 */ 374, 291, 354, 327, 328, 363, 367, 368, 353, 356, - /* 240 */ 371, 373, 375, 376, 453, 456, 382, 386, 388, 390, - /* 250 */ 464, 262, 409, 393, 331, 332, 337, 489, 491, 338, - /* 260 */ 342, 400, 357, 428, 644, 498, 646, 647, 502, 654, - /* 270 */ 655, 561, 563, 522, 545, 553, 585, 588, 607, 591, - /* 280 */ 592, 610, 615, 617, 619, 620, 605, 623, 624, 626, - /* 290 */ 701, 627, 611, 578, 613, 580, 632, 553, 633, 600, - /* 300 */ 635, 601, 641, 631, 634, 651, 716, 636, 638, 715, - /* 310 */ 720, 721, 722, 723, 724, 725, 726, 649, 727, 657, - /* 320 */ 650, 652, 659, 656, 625, 660, 713, 685, 731, 598, - /* 330 */ 599, 653, 653, 653, 653, 734, 602, 603, 653, 653, - /* 340 */ 653, 742, 746, 671, 653, 748, 749, 750, 751, 752, - /* 350 */ 753, 754, 755, 756, 757, 758, 759, 760, 761, 670, - /* 360 */ 686, 762, 763, 710, 768, + /* 0 */ 190, 118, 25, 42, 247, 268, 268, 358, 38, 38, + /* 10 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 20 */ 38, 0, 97, 268, 284, 297, 297, 85, 85, 38, + /* 30 */ 38, 199, 38, 12, 38, 38, 38, 38, 354, 42, + /* 40 */ 17, 17, 22, 782, 268, 268, 268, 268, 268, 268, + /* 50 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 60 */ 268, 268, 268, 268, 268, 268, 284, 297, 284, 284, + /* 70 */ 55, 263, 263, 263, 263, 263, 263, 8, 263, 38, + /* 80 */ 38, 38, 137, 38, 38, 38, 85, 85, 38, 38, + /* 90 */ 38, 38, 344, 344, 339, 85, 38, 38, 38, 38, + /* 100 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 110 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 120 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 130 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 140 */ 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + /* 150 */ 38, 38, 38, 38, 484, 484, 484, 441, 441, 441, + /* 160 */ 441, 484, 484, 444, 453, 466, 460, 488, 445, 508, + /* 170 */ 473, 507, 500, 484, 484, 484, 553, 553, 42, 484, + /* 180 */ 484, 547, 549, 598, 557, 556, 601, 558, 564, 22, + /* 190 */ 484, 484, 574, 574, 484, 574, 484, 574, 484, 484, + /* 200 */ 782, 782, 30, 66, 66, 96, 66, 145, 175, 261, + /* 210 */ 261, 261, 261, 261, 261, 249, 273, 289, 340, 340, + /* 220 */ 340, 340, 112, 259, 126, 317, 270, 270, 67, 275, + /* 230 */ 347, 252, 362, 366, 367, 368, 370, 371, 356, 357, + /* 240 */ 374, 375, 376, 377, 457, 464, 383, 94, 394, 398, + /* 250 */ 463, 203, 449, 400, 338, 343, 346, 472, 494, 359, + /* 260 */ 360, 403, 363, 425, 655, 509, 657, 658, 512, 660, + /* 270 */ 661, 567, 570, 529, 568, 577, 612, 614, 613, 599, + /* 280 */ 602, 617, 620, 621, 623, 624, 604, 626, 627, 629, + /* 290 */ 701, 630, 610, 580, 615, 582, 634, 577, 635, 603, + /* 300 */ 636, 605, 642, 632, 637, 653, 717, 638, 640, 719, + /* 310 */ 720, 723, 724, 725, 726, 727, 728, 729, 652, 730, + /* 320 */ 662, 656, 659, 664, 665, 631, 668, 714, 680, 733, + /* 330 */ 593, 596, 654, 654, 654, 654, 737, 606, 607, 654, + /* 340 */ 654, 654, 745, 749, 674, 654, 751, 752, 753, 754, + /* 350 */ 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, + /* 360 */ 673, 688, 765, 766, 715, 770, }; #define YY_REDUCE_COUNT (201) -#define YY_REDUCE_MIN (-232) -#define YY_REDUCE_MAX (496) +#define YY_REDUCE_MIN (-230) +#define YY_REDUCE_MAX (492) static const short yy_reduce_ofst[] = { - /* 0 */ -56, 11, -161, 90, -78, 119, 142, -192, 17, -176, - /* 10 */ -24, 69, 160, 165, 179, 180, 181, 186, 187, 192, - /* 20 */ 194, -194, -191, -232, -217, -210, -162, -196, -81, 6, - /* 30 */ 85, -84, -182, -108, -89, 100, 101, 191, -157, 143, - /* 40 */ -127, 209, 226, 185, -83, -73, -4, 51, 227, 231, - /* 50 */ 236, 240, 244, 245, 249, 250, 252, 253, 254, 255, - /* 60 */ 256, 257, 258, 259, 260, 261, 264, 265, 279, 281, - /* 70 */ 269, 295, 296, 299, 300, 301, 302, 334, 303, 335, - /* 80 */ 341, 343, 266, 344, 345, 346, 305, 306, 347, 348, - /* 90 */ 349, 352, 267, 278, 307, 309, 355, 359, 360, 361, - /* 100 */ 362, 365, 366, 369, 370, 372, 377, 378, 379, 380, - /* 110 */ 381, 383, 384, 385, 387, 389, 391, 392, 394, 395, - /* 120 */ 396, 397, 398, 399, 401, 402, 403, 404, 405, 406, - /* 130 */ 407, 408, 410, 411, 412, 413, 414, 415, 416, 417, - /* 140 */ 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, - /* 150 */ 429, 430, 431, 432, 433, 434, 435, 287, 312, 316, - /* 160 */ 318, 437, 438, 311, 310, 308, 317, 439, 441, 444, - /* 170 */ 446, 313, 442, 445, 447, 448, 449, 450, 454, 455, - /* 180 */ 460, 457, 459, 458, 461, 463, 466, 467, 469, 465, - /* 190 */ 468, 470, 475, 480, 482, 484, 483, 485, 487, 488, - /* 200 */ 496, 492, + /* 0 */ -165, 15, -161, 119, -200, -194, -164, -80, 130, -58, + /* 10 */ -67, 135, 140, 149, 150, 151, 156, 166, 184, 185, + /* 20 */ 186, -168, -192, -230, -86, -35, 176, 177, 179, -190, + /* 30 */ -57, 158, 125, 28, 191, 226, 237, 172, -12, 214, + /* 40 */ 233, 234, 229, -227, -213, -205, -84, -79, 75, 90, + /* 50 */ 123, 225, 245, 248, 250, 251, 254, 255, 256, 257, + /* 60 */ 258, 260, 262, 264, 265, 266, 269, 278, 280, 285, + /* 70 */ 282, 276, 296, 298, 299, 300, 301, 316, 302, 341, + /* 80 */ 342, 345, 277, 348, 349, 350, 305, 306, 353, 355, + /* 90 */ 361, 364, 224, 271, 292, 308, 365, 372, 373, 378, + /* 100 */ 379, 380, 381, 382, 384, 385, 386, 387, 388, 389, + /* 110 */ 390, 391, 392, 393, 395, 396, 397, 399, 401, 402, + /* 120 */ 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, + /* 130 */ 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, + /* 140 */ 424, 426, 427, 428, 429, 430, 431, 432, 433, 434, + /* 150 */ 435, 436, 437, 438, 369, 439, 440, 286, 287, 288, + /* 160 */ 291, 442, 443, 293, 304, 309, 303, 315, 318, 310, + /* 170 */ 319, 446, 307, 447, 448, 450, 451, 452, 456, 454, + /* 180 */ 455, 458, 461, 459, 462, 465, 468, 469, 471, 467, + /* 190 */ 470, 476, 477, 482, 485, 483, 487, 489, 491, 492, + /* 200 */ 490, 486, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 885, 948, 935, 944, 1167, 1167, 1167, 885, 885, 885, - /* 10 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 20 */ 885, 1074, 905, 1167, 885, 885, 885, 885, 885, 885, - /* 30 */ 885, 1089, 885, 944, 885, 885, 885, 885, 954, 944, - /* 40 */ 954, 954, 885, 1069, 885, 885, 885, 885, 885, 885, - /* 50 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 60 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 70 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 80 */ 885, 885, 1076, 1082, 1079, 885, 885, 885, 1084, 885, - /* 90 */ 885, 885, 1108, 1108, 1067, 885, 885, 885, 885, 885, - /* 100 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 110 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 120 */ 885, 885, 885, 885, 885, 885, 885, 933, 885, 931, - /* 130 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 140 */ 885, 885, 885, 885, 885, 885, 916, 885, 885, 885, - /* 150 */ 885, 885, 885, 903, 907, 907, 907, 885, 885, 885, - /* 160 */ 885, 907, 907, 1115, 1119, 1101, 1113, 1109, 1096, 1094, - /* 170 */ 1092, 1100, 1123, 907, 907, 907, 952, 952, 944, 907, - /* 180 */ 907, 970, 968, 966, 958, 964, 960, 962, 956, 885, - /* 190 */ 907, 907, 942, 942, 907, 942, 907, 942, 907, 907, - /* 200 */ 991, 1007, 885, 1124, 1114, 885, 1166, 1154, 1153, 1162, - /* 210 */ 1161, 1160, 1152, 1151, 1150, 885, 885, 885, 1146, 1149, - /* 220 */ 1148, 1147, 885, 885, 885, 885, 1156, 1155, 885, 885, - /* 230 */ 885, 885, 885, 885, 885, 885, 885, 885, 1120, 1116, - /* 240 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 250 */ 885, 1126, 885, 885, 885, 885, 885, 885, 885, 885, - /* 260 */ 885, 1015, 885, 885, 885, 885, 885, 885, 885, 885, - /* 270 */ 885, 885, 885, 885, 1066, 885, 885, 885, 885, 1078, - /* 280 */ 1077, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 290 */ 885, 885, 1110, 885, 1102, 885, 885, 1027, 885, 885, - /* 300 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 310 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 320 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 885, - /* 330 */ 885, 1185, 1180, 1181, 1178, 885, 885, 885, 1177, 1172, - /* 340 */ 1173, 885, 885, 885, 1170, 885, 885, 885, 885, 885, - /* 350 */ 885, 885, 885, 885, 885, 885, 885, 885, 885, 976, - /* 360 */ 885, 914, 912, 885, 885, + /* 0 */ 890, 953, 940, 949, 1174, 1174, 1174, 890, 890, 890, + /* 10 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 20 */ 890, 1081, 910, 1174, 890, 890, 890, 890, 890, 890, + /* 30 */ 890, 1096, 890, 949, 890, 890, 890, 890, 959, 949, + /* 40 */ 959, 959, 890, 1076, 890, 890, 890, 890, 890, 890, + /* 50 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 60 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 70 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 80 */ 890, 890, 1083, 1089, 1086, 890, 890, 890, 1091, 890, + /* 90 */ 890, 890, 1115, 1115, 1074, 890, 890, 890, 890, 890, + /* 100 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 110 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 120 */ 890, 890, 890, 890, 890, 890, 890, 938, 890, 936, + /* 130 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 140 */ 890, 890, 890, 890, 890, 890, 921, 890, 890, 890, + /* 150 */ 890, 890, 890, 908, 912, 912, 912, 890, 890, 890, + /* 160 */ 890, 912, 912, 1122, 1126, 1108, 1120, 1116, 1103, 1101, + /* 170 */ 1099, 1107, 1130, 912, 912, 912, 957, 957, 949, 912, + /* 180 */ 912, 975, 973, 971, 963, 969, 965, 967, 961, 890, + /* 190 */ 912, 912, 947, 947, 912, 947, 912, 947, 912, 912, + /* 200 */ 997, 1014, 890, 1131, 1121, 890, 1173, 1161, 1160, 1169, + /* 210 */ 1168, 1167, 1159, 1158, 1157, 890, 890, 890, 1153, 1156, + /* 220 */ 1155, 1154, 890, 890, 890, 890, 1163, 1162, 890, 890, + /* 230 */ 890, 890, 890, 890, 890, 890, 890, 890, 1127, 1123, + /* 240 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 250 */ 890, 1133, 890, 890, 890, 890, 890, 890, 890, 890, + /* 260 */ 890, 1022, 890, 890, 890, 890, 890, 890, 890, 890, + /* 270 */ 890, 890, 890, 890, 1073, 890, 890, 890, 890, 1085, + /* 280 */ 1084, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 290 */ 890, 890, 1117, 890, 1109, 890, 890, 1034, 890, 890, + /* 300 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 310 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 320 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 330 */ 890, 890, 1192, 1187, 1188, 1185, 890, 890, 890, 1184, + /* 340 */ 1179, 1180, 890, 890, 890, 1177, 890, 890, 890, 890, + /* 350 */ 890, 890, 890, 890, 890, 890, 890, 890, 890, 890, + /* 360 */ 981, 890, 919, 917, 890, 890, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1019,47 +1021,48 @@ static const char *const yyTokenName[] = { /* 228 */ "prec", /* 229 */ "update", /* 230 */ "cachelast", - /* 231 */ "signed", - /* 232 */ "create_table_args", - /* 233 */ "create_stable_args", - /* 234 */ "create_table_list", - /* 235 */ "create_from_stable", - /* 236 */ "columnlist", - /* 237 */ "tagitemlist1", - /* 238 */ "tagNamelist", - /* 239 */ "select", - /* 240 */ "column", - /* 241 */ "tagitem1", - /* 242 */ "tagitemlist", - /* 243 */ "tagitem", - /* 244 */ "selcollist", - /* 245 */ "from", - /* 246 */ "where_opt", - /* 247 */ "interval_option", - /* 248 */ "sliding_opt", - /* 249 */ "session_option", - /* 250 */ "windowstate_option", - /* 251 */ "fill_opt", - /* 252 */ "groupby_opt", - /* 253 */ "having_opt", - /* 254 */ "orderby_opt", - /* 255 */ "slimit_opt", - /* 256 */ "limit_opt", - /* 257 */ "union", - /* 258 */ "sclp", - /* 259 */ "distinct", - /* 260 */ "expr", - /* 261 */ "as", - /* 262 */ "tablelist", - /* 263 */ "sub", - /* 264 */ "tmvar", - /* 265 */ "intervalKey", - /* 266 */ "sortlist", - /* 267 */ "sortitem", - /* 268 */ "item", - /* 269 */ "sortorder", - /* 270 */ "grouplist", - /* 271 */ "expritem", + /* 231 */ "vgroups", + /* 232 */ "signed", + /* 233 */ "create_table_args", + /* 234 */ "create_stable_args", + /* 235 */ "create_table_list", + /* 236 */ "create_from_stable", + /* 237 */ "columnlist", + /* 238 */ "tagitemlist1", + /* 239 */ "tagNamelist", + /* 240 */ "select", + /* 241 */ "column", + /* 242 */ "tagitem1", + /* 243 */ "tagitemlist", + /* 244 */ "tagitem", + /* 245 */ "selcollist", + /* 246 */ "from", + /* 247 */ "where_opt", + /* 248 */ "interval_option", + /* 249 */ "sliding_opt", + /* 250 */ "session_option", + /* 251 */ "windowstate_option", + /* 252 */ "fill_opt", + /* 253 */ "groupby_opt", + /* 254 */ "having_opt", + /* 255 */ "orderby_opt", + /* 256 */ "slimit_opt", + /* 257 */ "limit_opt", + /* 258 */ "union", + /* 259 */ "sclp", + /* 260 */ "distinct", + /* 261 */ "expr", + /* 262 */ "as", + /* 263 */ "tablelist", + /* 264 */ "sub", + /* 265 */ "tmvar", + /* 266 */ "intervalKey", + /* 267 */ "sortlist", + /* 268 */ "sortitem", + /* 269 */ "item", + /* 270 */ "sortorder", + /* 271 */ "grouplist", + /* 272 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1170,204 +1173,206 @@ static const char *const yyRuleName[] = { /* 100 */ "prec ::= PRECISION STRING", /* 101 */ "update ::= UPDATE INTEGER", /* 102 */ "cachelast ::= CACHELAST INTEGER", - /* 103 */ "db_optr ::=", - /* 104 */ "db_optr ::= db_optr cache", - /* 105 */ "db_optr ::= db_optr replica", - /* 106 */ "db_optr ::= db_optr quorum", - /* 107 */ "db_optr ::= db_optr days", - /* 108 */ "db_optr ::= db_optr minrows", - /* 109 */ "db_optr ::= db_optr maxrows", - /* 110 */ "db_optr ::= db_optr blocks", - /* 111 */ "db_optr ::= db_optr ctime", - /* 112 */ "db_optr ::= db_optr wal", - /* 113 */ "db_optr ::= db_optr fsync", - /* 114 */ "db_optr ::= db_optr comp", - /* 115 */ "db_optr ::= db_optr prec", - /* 116 */ "db_optr ::= db_optr keep", - /* 117 */ "db_optr ::= db_optr update", - /* 118 */ "db_optr ::= db_optr cachelast", - /* 119 */ "alter_db_optr ::=", - /* 120 */ "alter_db_optr ::= alter_db_optr replica", - /* 121 */ "alter_db_optr ::= alter_db_optr quorum", - /* 122 */ "alter_db_optr ::= alter_db_optr keep", - /* 123 */ "alter_db_optr ::= alter_db_optr blocks", - /* 124 */ "alter_db_optr ::= alter_db_optr comp", - /* 125 */ "alter_db_optr ::= alter_db_optr update", - /* 126 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 127 */ "typename ::= ids", - /* 128 */ "typename ::= ids LP signed RP", - /* 129 */ "typename ::= ids UNSIGNED", - /* 130 */ "signed ::= INTEGER", - /* 131 */ "signed ::= PLUS INTEGER", - /* 132 */ "signed ::= MINUS INTEGER", - /* 133 */ "cmd ::= CREATE TABLE create_table_args", - /* 134 */ "cmd ::= CREATE TABLE create_stable_args", - /* 135 */ "cmd ::= CREATE STABLE create_stable_args", - /* 136 */ "cmd ::= CREATE TABLE create_table_list", - /* 137 */ "create_table_list ::= create_from_stable", - /* 138 */ "create_table_list ::= create_table_list create_from_stable", - /* 139 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 140 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", - /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", - /* 143 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 144 */ "tagNamelist ::= ids", - /* 145 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 146 */ "columnlist ::= columnlist COMMA column", - /* 147 */ "columnlist ::= column", - /* 148 */ "column ::= ids typename", - /* 149 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", - /* 150 */ "tagitemlist1 ::= tagitem1", - /* 151 */ "tagitem1 ::= MINUS INTEGER", - /* 152 */ "tagitem1 ::= MINUS FLOAT", - /* 153 */ "tagitem1 ::= PLUS INTEGER", - /* 154 */ "tagitem1 ::= PLUS FLOAT", - /* 155 */ "tagitem1 ::= INTEGER", - /* 156 */ "tagitem1 ::= FLOAT", - /* 157 */ "tagitem1 ::= STRING", - /* 158 */ "tagitem1 ::= BOOL", - /* 159 */ "tagitem1 ::= NULL", - /* 160 */ "tagitem1 ::= NOW", - /* 161 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 162 */ "tagitemlist ::= tagitem", - /* 163 */ "tagitem ::= INTEGER", - /* 164 */ "tagitem ::= FLOAT", - /* 165 */ "tagitem ::= STRING", - /* 166 */ "tagitem ::= BOOL", - /* 167 */ "tagitem ::= NULL", - /* 168 */ "tagitem ::= NOW", - /* 169 */ "tagitem ::= MINUS INTEGER", - /* 170 */ "tagitem ::= MINUS FLOAT", - /* 171 */ "tagitem ::= PLUS INTEGER", - /* 172 */ "tagitem ::= PLUS FLOAT", - /* 173 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 174 */ "select ::= LP select RP", - /* 175 */ "union ::= select", - /* 176 */ "union ::= union UNION ALL select", - /* 177 */ "union ::= union UNION select", - /* 178 */ "cmd ::= union", - /* 179 */ "select ::= SELECT selcollist", - /* 180 */ "sclp ::= selcollist COMMA", - /* 181 */ "sclp ::=", - /* 182 */ "selcollist ::= sclp distinct expr as", - /* 183 */ "selcollist ::= sclp STAR", - /* 184 */ "as ::= AS ids", - /* 185 */ "as ::= ids", - /* 186 */ "as ::=", - /* 187 */ "distinct ::= DISTINCT", - /* 188 */ "distinct ::=", - /* 189 */ "from ::= FROM tablelist", - /* 190 */ "from ::= FROM sub", - /* 191 */ "sub ::= LP union RP", - /* 192 */ "sub ::= LP union RP ids", - /* 193 */ "sub ::= sub COMMA LP union RP ids", - /* 194 */ "tablelist ::= ids cpxName", - /* 195 */ "tablelist ::= ids cpxName ids", - /* 196 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 197 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 198 */ "tmvar ::= VARIABLE", - /* 199 */ "interval_option ::= intervalKey LP tmvar RP", - /* 200 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", - /* 201 */ "interval_option ::=", - /* 202 */ "intervalKey ::= INTERVAL", - /* 203 */ "intervalKey ::= EVERY", - /* 204 */ "session_option ::=", - /* 205 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 206 */ "windowstate_option ::=", - /* 207 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 208 */ "fill_opt ::=", - /* 209 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 210 */ "fill_opt ::= FILL LP ID RP", - /* 211 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 212 */ "sliding_opt ::=", - /* 213 */ "orderby_opt ::=", - /* 214 */ "orderby_opt ::= ORDER BY sortlist", - /* 215 */ "sortlist ::= sortlist COMMA item sortorder", - /* 216 */ "sortlist ::= item sortorder", - /* 217 */ "item ::= ids cpxName", - /* 218 */ "sortorder ::= ASC", - /* 219 */ "sortorder ::= DESC", - /* 220 */ "sortorder ::=", - /* 221 */ "groupby_opt ::=", - /* 222 */ "groupby_opt ::= GROUP BY grouplist", - /* 223 */ "grouplist ::= grouplist COMMA item", - /* 224 */ "grouplist ::= item", - /* 225 */ "having_opt ::=", - /* 226 */ "having_opt ::= HAVING expr", - /* 227 */ "limit_opt ::=", - /* 228 */ "limit_opt ::= LIMIT signed", - /* 229 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 230 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 231 */ "slimit_opt ::=", - /* 232 */ "slimit_opt ::= SLIMIT signed", - /* 233 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 234 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 235 */ "where_opt ::=", - /* 236 */ "where_opt ::= WHERE expr", - /* 237 */ "expr ::= LP expr RP", - /* 238 */ "expr ::= ID", - /* 239 */ "expr ::= ID DOT ID", - /* 240 */ "expr ::= ID DOT STAR", - /* 241 */ "expr ::= INTEGER", - /* 242 */ "expr ::= MINUS INTEGER", - /* 243 */ "expr ::= PLUS INTEGER", - /* 244 */ "expr ::= FLOAT", - /* 245 */ "expr ::= MINUS FLOAT", - /* 246 */ "expr ::= PLUS FLOAT", - /* 247 */ "expr ::= STRING", - /* 248 */ "expr ::= NOW", - /* 249 */ "expr ::= VARIABLE", - /* 250 */ "expr ::= PLUS VARIABLE", - /* 251 */ "expr ::= MINUS VARIABLE", - /* 252 */ "expr ::= BOOL", - /* 253 */ "expr ::= NULL", - /* 254 */ "expr ::= ID LP exprlist RP", - /* 255 */ "expr ::= ID LP STAR RP", - /* 256 */ "expr ::= expr IS NULL", - /* 257 */ "expr ::= expr IS NOT NULL", - /* 258 */ "expr ::= expr LT expr", - /* 259 */ "expr ::= expr GT expr", - /* 260 */ "expr ::= expr LE expr", - /* 261 */ "expr ::= expr GE expr", - /* 262 */ "expr ::= expr NE expr", - /* 263 */ "expr ::= expr EQ expr", - /* 264 */ "expr ::= expr BETWEEN expr AND expr", - /* 265 */ "expr ::= expr AND expr", - /* 266 */ "expr ::= expr OR expr", - /* 267 */ "expr ::= expr PLUS expr", - /* 268 */ "expr ::= expr MINUS expr", - /* 269 */ "expr ::= expr STAR expr", - /* 270 */ "expr ::= expr SLASH expr", - /* 271 */ "expr ::= expr REM expr", - /* 272 */ "expr ::= expr LIKE expr", - /* 273 */ "expr ::= expr MATCH expr", - /* 274 */ "expr ::= expr NMATCH expr", - /* 275 */ "expr ::= expr IN LP exprlist RP", - /* 276 */ "exprlist ::= exprlist COMMA expritem", - /* 277 */ "exprlist ::= expritem", - /* 278 */ "expritem ::= expr", - /* 279 */ "expritem ::=", - /* 280 */ "cmd ::= RESET QUERY CACHE", - /* 281 */ "cmd ::= SYNCDB ids REPLICA", - /* 282 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 283 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 284 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 285 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 286 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 287 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 288 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 289 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 290 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 291 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 292 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 293 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 294 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 295 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 296 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 297 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 298 */ "cmd ::= KILL CONNECTION INTEGER", - /* 299 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 300 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 103 */ "vgroups ::= VGROUPS INTEGER", + /* 104 */ "db_optr ::=", + /* 105 */ "db_optr ::= db_optr cache", + /* 106 */ "db_optr ::= db_optr replica", + /* 107 */ "db_optr ::= db_optr quorum", + /* 108 */ "db_optr ::= db_optr days", + /* 109 */ "db_optr ::= db_optr minrows", + /* 110 */ "db_optr ::= db_optr maxrows", + /* 111 */ "db_optr ::= db_optr blocks", + /* 112 */ "db_optr ::= db_optr ctime", + /* 113 */ "db_optr ::= db_optr wal", + /* 114 */ "db_optr ::= db_optr fsync", + /* 115 */ "db_optr ::= db_optr comp", + /* 116 */ "db_optr ::= db_optr prec", + /* 117 */ "db_optr ::= db_optr keep", + /* 118 */ "db_optr ::= db_optr update", + /* 119 */ "db_optr ::= db_optr cachelast", + /* 120 */ "db_optr ::= db_optr vgroups", + /* 121 */ "alter_db_optr ::=", + /* 122 */ "alter_db_optr ::= alter_db_optr replica", + /* 123 */ "alter_db_optr ::= alter_db_optr quorum", + /* 124 */ "alter_db_optr ::= alter_db_optr keep", + /* 125 */ "alter_db_optr ::= alter_db_optr blocks", + /* 126 */ "alter_db_optr ::= alter_db_optr comp", + /* 127 */ "alter_db_optr ::= alter_db_optr update", + /* 128 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 129 */ "typename ::= ids", + /* 130 */ "typename ::= ids LP signed RP", + /* 131 */ "typename ::= ids UNSIGNED", + /* 132 */ "signed ::= INTEGER", + /* 133 */ "signed ::= PLUS INTEGER", + /* 134 */ "signed ::= MINUS INTEGER", + /* 135 */ "cmd ::= CREATE TABLE create_table_args", + /* 136 */ "cmd ::= CREATE TABLE create_stable_args", + /* 137 */ "cmd ::= CREATE STABLE create_stable_args", + /* 138 */ "cmd ::= CREATE TABLE create_table_list", + /* 139 */ "create_table_list ::= create_from_stable", + /* 140 */ "create_table_list ::= create_table_list create_from_stable", + /* 141 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", + /* 142 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", + /* 143 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP", + /* 144 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP", + /* 145 */ "tagNamelist ::= tagNamelist COMMA ids", + /* 146 */ "tagNamelist ::= ids", + /* 147 */ "create_table_args ::= ifnotexists ids cpxName AS select", + /* 148 */ "columnlist ::= columnlist COMMA column", + /* 149 */ "columnlist ::= column", + /* 150 */ "column ::= ids typename", + /* 151 */ "tagitemlist1 ::= tagitemlist1 COMMA tagitem1", + /* 152 */ "tagitemlist1 ::= tagitem1", + /* 153 */ "tagitem1 ::= MINUS INTEGER", + /* 154 */ "tagitem1 ::= MINUS FLOAT", + /* 155 */ "tagitem1 ::= PLUS INTEGER", + /* 156 */ "tagitem1 ::= PLUS FLOAT", + /* 157 */ "tagitem1 ::= INTEGER", + /* 158 */ "tagitem1 ::= FLOAT", + /* 159 */ "tagitem1 ::= STRING", + /* 160 */ "tagitem1 ::= BOOL", + /* 161 */ "tagitem1 ::= NULL", + /* 162 */ "tagitem1 ::= NOW", + /* 163 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 164 */ "tagitemlist ::= tagitem", + /* 165 */ "tagitem ::= INTEGER", + /* 166 */ "tagitem ::= FLOAT", + /* 167 */ "tagitem ::= STRING", + /* 168 */ "tagitem ::= BOOL", + /* 169 */ "tagitem ::= NULL", + /* 170 */ "tagitem ::= NOW", + /* 171 */ "tagitem ::= MINUS INTEGER", + /* 172 */ "tagitem ::= MINUS FLOAT", + /* 173 */ "tagitem ::= PLUS INTEGER", + /* 174 */ "tagitem ::= PLUS FLOAT", + /* 175 */ "select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 176 */ "select ::= LP select RP", + /* 177 */ "union ::= select", + /* 178 */ "union ::= union UNION ALL select", + /* 179 */ "union ::= union UNION select", + /* 180 */ "cmd ::= union", + /* 181 */ "select ::= SELECT selcollist", + /* 182 */ "sclp ::= selcollist COMMA", + /* 183 */ "sclp ::=", + /* 184 */ "selcollist ::= sclp distinct expr as", + /* 185 */ "selcollist ::= sclp STAR", + /* 186 */ "as ::= AS ids", + /* 187 */ "as ::= ids", + /* 188 */ "as ::=", + /* 189 */ "distinct ::= DISTINCT", + /* 190 */ "distinct ::=", + /* 191 */ "from ::= FROM tablelist", + /* 192 */ "from ::= FROM sub", + /* 193 */ "sub ::= LP union RP", + /* 194 */ "sub ::= LP union RP ids", + /* 195 */ "sub ::= sub COMMA LP union RP ids", + /* 196 */ "tablelist ::= ids cpxName", + /* 197 */ "tablelist ::= ids cpxName ids", + /* 198 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 199 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 200 */ "tmvar ::= VARIABLE", + /* 201 */ "interval_option ::= intervalKey LP tmvar RP", + /* 202 */ "interval_option ::= intervalKey LP tmvar COMMA tmvar RP", + /* 203 */ "interval_option ::=", + /* 204 */ "intervalKey ::= INTERVAL", + /* 205 */ "intervalKey ::= EVERY", + /* 206 */ "session_option ::=", + /* 207 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 208 */ "windowstate_option ::=", + /* 209 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 210 */ "fill_opt ::=", + /* 211 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 212 */ "fill_opt ::= FILL LP ID RP", + /* 213 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 214 */ "sliding_opt ::=", + /* 215 */ "orderby_opt ::=", + /* 216 */ "orderby_opt ::= ORDER BY sortlist", + /* 217 */ "sortlist ::= sortlist COMMA item sortorder", + /* 218 */ "sortlist ::= item sortorder", + /* 219 */ "item ::= ids cpxName", + /* 220 */ "sortorder ::= ASC", + /* 221 */ "sortorder ::= DESC", + /* 222 */ "sortorder ::=", + /* 223 */ "groupby_opt ::=", + /* 224 */ "groupby_opt ::= GROUP BY grouplist", + /* 225 */ "grouplist ::= grouplist COMMA item", + /* 226 */ "grouplist ::= item", + /* 227 */ "having_opt ::=", + /* 228 */ "having_opt ::= HAVING expr", + /* 229 */ "limit_opt ::=", + /* 230 */ "limit_opt ::= LIMIT signed", + /* 231 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 232 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 233 */ "slimit_opt ::=", + /* 234 */ "slimit_opt ::= SLIMIT signed", + /* 235 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 236 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 237 */ "where_opt ::=", + /* 238 */ "where_opt ::= WHERE expr", + /* 239 */ "expr ::= LP expr RP", + /* 240 */ "expr ::= ID", + /* 241 */ "expr ::= ID DOT ID", + /* 242 */ "expr ::= ID DOT STAR", + /* 243 */ "expr ::= INTEGER", + /* 244 */ "expr ::= MINUS INTEGER", + /* 245 */ "expr ::= PLUS INTEGER", + /* 246 */ "expr ::= FLOAT", + /* 247 */ "expr ::= MINUS FLOAT", + /* 248 */ "expr ::= PLUS FLOAT", + /* 249 */ "expr ::= STRING", + /* 250 */ "expr ::= NOW", + /* 251 */ "expr ::= VARIABLE", + /* 252 */ "expr ::= PLUS VARIABLE", + /* 253 */ "expr ::= MINUS VARIABLE", + /* 254 */ "expr ::= BOOL", + /* 255 */ "expr ::= NULL", + /* 256 */ "expr ::= ID LP exprlist RP", + /* 257 */ "expr ::= ID LP STAR RP", + /* 258 */ "expr ::= expr IS NULL", + /* 259 */ "expr ::= expr IS NOT NULL", + /* 260 */ "expr ::= expr LT expr", + /* 261 */ "expr ::= expr GT expr", + /* 262 */ "expr ::= expr LE expr", + /* 263 */ "expr ::= expr GE expr", + /* 264 */ "expr ::= expr NE expr", + /* 265 */ "expr ::= expr EQ expr", + /* 266 */ "expr ::= expr BETWEEN expr AND expr", + /* 267 */ "expr ::= expr AND expr", + /* 268 */ "expr ::= expr OR expr", + /* 269 */ "expr ::= expr PLUS expr", + /* 270 */ "expr ::= expr MINUS expr", + /* 271 */ "expr ::= expr STAR expr", + /* 272 */ "expr ::= expr SLASH expr", + /* 273 */ "expr ::= expr REM expr", + /* 274 */ "expr ::= expr LIKE expr", + /* 275 */ "expr ::= expr MATCH expr", + /* 276 */ "expr ::= expr NMATCH expr", + /* 277 */ "expr ::= expr IN LP exprlist RP", + /* 278 */ "exprlist ::= exprlist COMMA expritem", + /* 279 */ "exprlist ::= expritem", + /* 280 */ "expritem ::= expr", + /* 281 */ "expritem ::=", + /* 282 */ "cmd ::= RESET QUERY CACHE", + /* 283 */ "cmd ::= SYNCDB ids REPLICA", + /* 284 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 285 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 286 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 287 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 288 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 289 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 290 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 291 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 292 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 293 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 294 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 295 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 296 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 297 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 298 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 299 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 300 */ "cmd ::= KILL CONNECTION INTEGER", + /* 301 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 302 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1489,60 +1494,60 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ case 200: /* exprlist */ - case 244: /* selcollist */ - case 258: /* sclp */ + case 245: /* selcollist */ + case 259: /* sclp */ { -tSqlExprListDestroy((yypminor->yy413)); +tSqlExprListDestroy((yypminor->yy165)); } break; case 214: /* intitemlist */ case 216: /* keep */ - case 236: /* columnlist */ - case 237: /* tagitemlist1 */ - case 238: /* tagNamelist */ - case 242: /* tagitemlist */ - case 251: /* fill_opt */ - case 252: /* groupby_opt */ - case 254: /* orderby_opt */ - case 266: /* sortlist */ - case 270: /* grouplist */ + case 237: /* columnlist */ + case 238: /* tagitemlist1 */ + case 239: /* tagNamelist */ + case 243: /* tagitemlist */ + case 252: /* fill_opt */ + case 253: /* groupby_opt */ + case 255: /* orderby_opt */ + case 267: /* sortlist */ + case 271: /* grouplist */ { -taosArrayDestroy((yypminor->yy413)); +taosArrayDestroy((yypminor->yy165)); } break; - case 234: /* create_table_list */ + case 235: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy438)); +destroyCreateTableSql((yypminor->yy326)); } break; - case 239: /* select */ + case 240: /* select */ { -destroySqlNode((yypminor->yy24)); +destroySqlNode((yypminor->yy278)); } break; - case 245: /* from */ - case 262: /* tablelist */ - case 263: /* sub */ + case 246: /* from */ + case 263: /* tablelist */ + case 264: /* sub */ { -destroyRelationInfo((yypminor->yy292)); +destroyRelationInfo((yypminor->yy10)); } break; - case 246: /* where_opt */ - case 253: /* having_opt */ - case 260: /* expr */ - case 271: /* expritem */ + case 247: /* where_opt */ + case 254: /* having_opt */ + case 261: /* expr */ + case 272: /* expritem */ { -tSqlExprDestroy((yypminor->yy370)); +tSqlExprDestroy((yypminor->yy202)); } break; - case 257: /* union */ + case 258: /* union */ { -destroyAllSqlNode((yypminor->yy129)); +destroyAllSqlNode((yypminor->yy503)); } break; - case 267: /* sortitem */ + case 268: /* sortitem */ { -taosVariantDestroy(&(yypminor->yy461)); +taosVariantDestroy(&(yypminor->yy425)); } break; /********* End destructor definitions *****************************************/ @@ -1939,204 +1944,206 @@ static const struct { { 228, -2 }, /* (100) prec ::= PRECISION STRING */ { 229, -2 }, /* (101) update ::= UPDATE INTEGER */ { 230, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */ - { 202, 0 }, /* (103) db_optr ::= */ - { 202, -2 }, /* (104) db_optr ::= db_optr cache */ - { 202, -2 }, /* (105) db_optr ::= db_optr replica */ - { 202, -2 }, /* (106) db_optr ::= db_optr quorum */ - { 202, -2 }, /* (107) db_optr ::= db_optr days */ - { 202, -2 }, /* (108) db_optr ::= db_optr minrows */ - { 202, -2 }, /* (109) db_optr ::= db_optr maxrows */ - { 202, -2 }, /* (110) db_optr ::= db_optr blocks */ - { 202, -2 }, /* (111) db_optr ::= db_optr ctime */ - { 202, -2 }, /* (112) db_optr ::= db_optr wal */ - { 202, -2 }, /* (113) db_optr ::= db_optr fsync */ - { 202, -2 }, /* (114) db_optr ::= db_optr comp */ - { 202, -2 }, /* (115) db_optr ::= db_optr prec */ - { 202, -2 }, /* (116) db_optr ::= db_optr keep */ - { 202, -2 }, /* (117) db_optr ::= db_optr update */ - { 202, -2 }, /* (118) db_optr ::= db_optr cachelast */ - { 198, 0 }, /* (119) alter_db_optr ::= */ - { 198, -2 }, /* (120) alter_db_optr ::= alter_db_optr replica */ - { 198, -2 }, /* (121) alter_db_optr ::= alter_db_optr quorum */ - { 198, -2 }, /* (122) alter_db_optr ::= alter_db_optr keep */ - { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr blocks */ - { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr comp */ - { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr update */ - { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr cachelast */ - { 203, -1 }, /* (127) typename ::= ids */ - { 203, -4 }, /* (128) typename ::= ids LP signed RP */ - { 203, -2 }, /* (129) typename ::= ids UNSIGNED */ - { 231, -1 }, /* (130) signed ::= INTEGER */ - { 231, -2 }, /* (131) signed ::= PLUS INTEGER */ - { 231, -2 }, /* (132) signed ::= MINUS INTEGER */ - { 193, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ - { 193, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ - { 193, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ - { 193, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ - { 234, -1 }, /* (137) create_table_list ::= create_from_stable */ - { 234, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ - { 232, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 233, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 235, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ - { 235, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ - { 238, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ - { 238, -1 }, /* (144) tagNamelist ::= ids */ - { 232, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ - { 236, -3 }, /* (146) columnlist ::= columnlist COMMA column */ - { 236, -1 }, /* (147) columnlist ::= column */ - { 240, -2 }, /* (148) column ::= ids typename */ - { 237, -3 }, /* (149) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ - { 237, -1 }, /* (150) tagitemlist1 ::= tagitem1 */ - { 241, -2 }, /* (151) tagitem1 ::= MINUS INTEGER */ - { 241, -2 }, /* (152) tagitem1 ::= MINUS FLOAT */ - { 241, -2 }, /* (153) tagitem1 ::= PLUS INTEGER */ - { 241, -2 }, /* (154) tagitem1 ::= PLUS FLOAT */ - { 241, -1 }, /* (155) tagitem1 ::= INTEGER */ - { 241, -1 }, /* (156) tagitem1 ::= FLOAT */ - { 241, -1 }, /* (157) tagitem1 ::= STRING */ - { 241, -1 }, /* (158) tagitem1 ::= BOOL */ - { 241, -1 }, /* (159) tagitem1 ::= NULL */ - { 241, -1 }, /* (160) tagitem1 ::= NOW */ - { 242, -3 }, /* (161) tagitemlist ::= tagitemlist COMMA tagitem */ - { 242, -1 }, /* (162) tagitemlist ::= tagitem */ - { 243, -1 }, /* (163) tagitem ::= INTEGER */ - { 243, -1 }, /* (164) tagitem ::= FLOAT */ - { 243, -1 }, /* (165) tagitem ::= STRING */ - { 243, -1 }, /* (166) tagitem ::= BOOL */ - { 243, -1 }, /* (167) tagitem ::= NULL */ - { 243, -1 }, /* (168) tagitem ::= NOW */ - { 243, -2 }, /* (169) tagitem ::= MINUS INTEGER */ - { 243, -2 }, /* (170) tagitem ::= MINUS FLOAT */ - { 243, -2 }, /* (171) tagitem ::= PLUS INTEGER */ - { 243, -2 }, /* (172) tagitem ::= PLUS FLOAT */ - { 239, -14 }, /* (173) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 239, -3 }, /* (174) select ::= LP select RP */ - { 257, -1 }, /* (175) union ::= select */ - { 257, -4 }, /* (176) union ::= union UNION ALL select */ - { 257, -3 }, /* (177) union ::= union UNION select */ - { 193, -1 }, /* (178) cmd ::= union */ - { 239, -2 }, /* (179) select ::= SELECT selcollist */ - { 258, -2 }, /* (180) sclp ::= selcollist COMMA */ - { 258, 0 }, /* (181) sclp ::= */ - { 244, -4 }, /* (182) selcollist ::= sclp distinct expr as */ - { 244, -2 }, /* (183) selcollist ::= sclp STAR */ - { 261, -2 }, /* (184) as ::= AS ids */ - { 261, -1 }, /* (185) as ::= ids */ - { 261, 0 }, /* (186) as ::= */ - { 259, -1 }, /* (187) distinct ::= DISTINCT */ - { 259, 0 }, /* (188) distinct ::= */ - { 245, -2 }, /* (189) from ::= FROM tablelist */ - { 245, -2 }, /* (190) from ::= FROM sub */ - { 263, -3 }, /* (191) sub ::= LP union RP */ - { 263, -4 }, /* (192) sub ::= LP union RP ids */ - { 263, -6 }, /* (193) sub ::= sub COMMA LP union RP ids */ - { 262, -2 }, /* (194) tablelist ::= ids cpxName */ - { 262, -3 }, /* (195) tablelist ::= ids cpxName ids */ - { 262, -4 }, /* (196) tablelist ::= tablelist COMMA ids cpxName */ - { 262, -5 }, /* (197) tablelist ::= tablelist COMMA ids cpxName ids */ - { 264, -1 }, /* (198) tmvar ::= VARIABLE */ - { 247, -4 }, /* (199) interval_option ::= intervalKey LP tmvar RP */ - { 247, -6 }, /* (200) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - { 247, 0 }, /* (201) interval_option ::= */ - { 265, -1 }, /* (202) intervalKey ::= INTERVAL */ - { 265, -1 }, /* (203) intervalKey ::= EVERY */ - { 249, 0 }, /* (204) session_option ::= */ - { 249, -7 }, /* (205) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 250, 0 }, /* (206) windowstate_option ::= */ - { 250, -4 }, /* (207) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 251, 0 }, /* (208) fill_opt ::= */ - { 251, -6 }, /* (209) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 251, -4 }, /* (210) fill_opt ::= FILL LP ID RP */ - { 248, -4 }, /* (211) sliding_opt ::= SLIDING LP tmvar RP */ - { 248, 0 }, /* (212) sliding_opt ::= */ - { 254, 0 }, /* (213) orderby_opt ::= */ - { 254, -3 }, /* (214) orderby_opt ::= ORDER BY sortlist */ - { 266, -4 }, /* (215) sortlist ::= sortlist COMMA item sortorder */ - { 266, -2 }, /* (216) sortlist ::= item sortorder */ - { 268, -2 }, /* (217) item ::= ids cpxName */ - { 269, -1 }, /* (218) sortorder ::= ASC */ - { 269, -1 }, /* (219) sortorder ::= DESC */ - { 269, 0 }, /* (220) sortorder ::= */ - { 252, 0 }, /* (221) groupby_opt ::= */ - { 252, -3 }, /* (222) groupby_opt ::= GROUP BY grouplist */ - { 270, -3 }, /* (223) grouplist ::= grouplist COMMA item */ - { 270, -1 }, /* (224) grouplist ::= item */ - { 253, 0 }, /* (225) having_opt ::= */ - { 253, -2 }, /* (226) having_opt ::= HAVING expr */ - { 256, 0 }, /* (227) limit_opt ::= */ - { 256, -2 }, /* (228) limit_opt ::= LIMIT signed */ - { 256, -4 }, /* (229) limit_opt ::= LIMIT signed OFFSET signed */ - { 256, -4 }, /* (230) limit_opt ::= LIMIT signed COMMA signed */ - { 255, 0 }, /* (231) slimit_opt ::= */ - { 255, -2 }, /* (232) slimit_opt ::= SLIMIT signed */ - { 255, -4 }, /* (233) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 255, -4 }, /* (234) slimit_opt ::= SLIMIT signed COMMA signed */ - { 246, 0 }, /* (235) where_opt ::= */ - { 246, -2 }, /* (236) where_opt ::= WHERE expr */ - { 260, -3 }, /* (237) expr ::= LP expr RP */ - { 260, -1 }, /* (238) expr ::= ID */ - { 260, -3 }, /* (239) expr ::= ID DOT ID */ - { 260, -3 }, /* (240) expr ::= ID DOT STAR */ - { 260, -1 }, /* (241) expr ::= INTEGER */ - { 260, -2 }, /* (242) expr ::= MINUS INTEGER */ - { 260, -2 }, /* (243) expr ::= PLUS INTEGER */ - { 260, -1 }, /* (244) expr ::= FLOAT */ - { 260, -2 }, /* (245) expr ::= MINUS FLOAT */ - { 260, -2 }, /* (246) expr ::= PLUS FLOAT */ - { 260, -1 }, /* (247) expr ::= STRING */ - { 260, -1 }, /* (248) expr ::= NOW */ - { 260, -1 }, /* (249) expr ::= VARIABLE */ - { 260, -2 }, /* (250) expr ::= PLUS VARIABLE */ - { 260, -2 }, /* (251) expr ::= MINUS VARIABLE */ - { 260, -1 }, /* (252) expr ::= BOOL */ - { 260, -1 }, /* (253) expr ::= NULL */ - { 260, -4 }, /* (254) expr ::= ID LP exprlist RP */ - { 260, -4 }, /* (255) expr ::= ID LP STAR RP */ - { 260, -3 }, /* (256) expr ::= expr IS NULL */ - { 260, -4 }, /* (257) expr ::= expr IS NOT NULL */ - { 260, -3 }, /* (258) expr ::= expr LT expr */ - { 260, -3 }, /* (259) expr ::= expr GT expr */ - { 260, -3 }, /* (260) expr ::= expr LE expr */ - { 260, -3 }, /* (261) expr ::= expr GE expr */ - { 260, -3 }, /* (262) expr ::= expr NE expr */ - { 260, -3 }, /* (263) expr ::= expr EQ expr */ - { 260, -5 }, /* (264) expr ::= expr BETWEEN expr AND expr */ - { 260, -3 }, /* (265) expr ::= expr AND expr */ - { 260, -3 }, /* (266) expr ::= expr OR expr */ - { 260, -3 }, /* (267) expr ::= expr PLUS expr */ - { 260, -3 }, /* (268) expr ::= expr MINUS expr */ - { 260, -3 }, /* (269) expr ::= expr STAR expr */ - { 260, -3 }, /* (270) expr ::= expr SLASH expr */ - { 260, -3 }, /* (271) expr ::= expr REM expr */ - { 260, -3 }, /* (272) expr ::= expr LIKE expr */ - { 260, -3 }, /* (273) expr ::= expr MATCH expr */ - { 260, -3 }, /* (274) expr ::= expr NMATCH expr */ - { 260, -5 }, /* (275) expr ::= expr IN LP exprlist RP */ - { 200, -3 }, /* (276) exprlist ::= exprlist COMMA expritem */ - { 200, -1 }, /* (277) exprlist ::= expritem */ - { 271, -1 }, /* (278) expritem ::= expr */ - { 271, 0 }, /* (279) expritem ::= */ - { 193, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ - { 193, -3 }, /* (281) cmd ::= SYNCDB ids REPLICA */ - { 193, -7 }, /* (282) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 193, -7 }, /* (283) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 193, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 193, -8 }, /* (287) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 193, -9 }, /* (288) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 193, -7 }, /* (289) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 193, -7 }, /* (290) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 193, -7 }, /* (291) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 193, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 193, -8 }, /* (295) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 193, -9 }, /* (296) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 193, -7 }, /* (297) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 193, -3 }, /* (298) cmd ::= KILL CONNECTION INTEGER */ - { 193, -5 }, /* (299) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 193, -5 }, /* (300) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 231, -2 }, /* (103) vgroups ::= VGROUPS INTEGER */ + { 202, 0 }, /* (104) db_optr ::= */ + { 202, -2 }, /* (105) db_optr ::= db_optr cache */ + { 202, -2 }, /* (106) db_optr ::= db_optr replica */ + { 202, -2 }, /* (107) db_optr ::= db_optr quorum */ + { 202, -2 }, /* (108) db_optr ::= db_optr days */ + { 202, -2 }, /* (109) db_optr ::= db_optr minrows */ + { 202, -2 }, /* (110) db_optr ::= db_optr maxrows */ + { 202, -2 }, /* (111) db_optr ::= db_optr blocks */ + { 202, -2 }, /* (112) db_optr ::= db_optr ctime */ + { 202, -2 }, /* (113) db_optr ::= db_optr wal */ + { 202, -2 }, /* (114) db_optr ::= db_optr fsync */ + { 202, -2 }, /* (115) db_optr ::= db_optr comp */ + { 202, -2 }, /* (116) db_optr ::= db_optr prec */ + { 202, -2 }, /* (117) db_optr ::= db_optr keep */ + { 202, -2 }, /* (118) db_optr ::= db_optr update */ + { 202, -2 }, /* (119) db_optr ::= db_optr cachelast */ + { 202, -2 }, /* (120) db_optr ::= db_optr vgroups */ + { 198, 0 }, /* (121) alter_db_optr ::= */ + { 198, -2 }, /* (122) alter_db_optr ::= alter_db_optr replica */ + { 198, -2 }, /* (123) alter_db_optr ::= alter_db_optr quorum */ + { 198, -2 }, /* (124) alter_db_optr ::= alter_db_optr keep */ + { 198, -2 }, /* (125) alter_db_optr ::= alter_db_optr blocks */ + { 198, -2 }, /* (126) alter_db_optr ::= alter_db_optr comp */ + { 198, -2 }, /* (127) alter_db_optr ::= alter_db_optr update */ + { 198, -2 }, /* (128) alter_db_optr ::= alter_db_optr cachelast */ + { 203, -1 }, /* (129) typename ::= ids */ + { 203, -4 }, /* (130) typename ::= ids LP signed RP */ + { 203, -2 }, /* (131) typename ::= ids UNSIGNED */ + { 232, -1 }, /* (132) signed ::= INTEGER */ + { 232, -2 }, /* (133) signed ::= PLUS INTEGER */ + { 232, -2 }, /* (134) signed ::= MINUS INTEGER */ + { 193, -3 }, /* (135) cmd ::= CREATE TABLE create_table_args */ + { 193, -3 }, /* (136) cmd ::= CREATE TABLE create_stable_args */ + { 193, -3 }, /* (137) cmd ::= CREATE STABLE create_stable_args */ + { 193, -3 }, /* (138) cmd ::= CREATE TABLE create_table_list */ + { 235, -1 }, /* (139) create_table_list ::= create_from_stable */ + { 235, -2 }, /* (140) create_table_list ::= create_table_list create_from_stable */ + { 233, -6 }, /* (141) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 234, -10 }, /* (142) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 236, -10 }, /* (143) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + { 236, -13 }, /* (144) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + { 239, -3 }, /* (145) tagNamelist ::= tagNamelist COMMA ids */ + { 239, -1 }, /* (146) tagNamelist ::= ids */ + { 233, -5 }, /* (147) create_table_args ::= ifnotexists ids cpxName AS select */ + { 237, -3 }, /* (148) columnlist ::= columnlist COMMA column */ + { 237, -1 }, /* (149) columnlist ::= column */ + { 241, -2 }, /* (150) column ::= ids typename */ + { 238, -3 }, /* (151) tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ + { 238, -1 }, /* (152) tagitemlist1 ::= tagitem1 */ + { 242, -2 }, /* (153) tagitem1 ::= MINUS INTEGER */ + { 242, -2 }, /* (154) tagitem1 ::= MINUS FLOAT */ + { 242, -2 }, /* (155) tagitem1 ::= PLUS INTEGER */ + { 242, -2 }, /* (156) tagitem1 ::= PLUS FLOAT */ + { 242, -1 }, /* (157) tagitem1 ::= INTEGER */ + { 242, -1 }, /* (158) tagitem1 ::= FLOAT */ + { 242, -1 }, /* (159) tagitem1 ::= STRING */ + { 242, -1 }, /* (160) tagitem1 ::= BOOL */ + { 242, -1 }, /* (161) tagitem1 ::= NULL */ + { 242, -1 }, /* (162) tagitem1 ::= NOW */ + { 243, -3 }, /* (163) tagitemlist ::= tagitemlist COMMA tagitem */ + { 243, -1 }, /* (164) tagitemlist ::= tagitem */ + { 244, -1 }, /* (165) tagitem ::= INTEGER */ + { 244, -1 }, /* (166) tagitem ::= FLOAT */ + { 244, -1 }, /* (167) tagitem ::= STRING */ + { 244, -1 }, /* (168) tagitem ::= BOOL */ + { 244, -1 }, /* (169) tagitem ::= NULL */ + { 244, -1 }, /* (170) tagitem ::= NOW */ + { 244, -2 }, /* (171) tagitem ::= MINUS INTEGER */ + { 244, -2 }, /* (172) tagitem ::= MINUS FLOAT */ + { 244, -2 }, /* (173) tagitem ::= PLUS INTEGER */ + { 244, -2 }, /* (174) tagitem ::= PLUS FLOAT */ + { 240, -14 }, /* (175) select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 240, -3 }, /* (176) select ::= LP select RP */ + { 258, -1 }, /* (177) union ::= select */ + { 258, -4 }, /* (178) union ::= union UNION ALL select */ + { 258, -3 }, /* (179) union ::= union UNION select */ + { 193, -1 }, /* (180) cmd ::= union */ + { 240, -2 }, /* (181) select ::= SELECT selcollist */ + { 259, -2 }, /* (182) sclp ::= selcollist COMMA */ + { 259, 0 }, /* (183) sclp ::= */ + { 245, -4 }, /* (184) selcollist ::= sclp distinct expr as */ + { 245, -2 }, /* (185) selcollist ::= sclp STAR */ + { 262, -2 }, /* (186) as ::= AS ids */ + { 262, -1 }, /* (187) as ::= ids */ + { 262, 0 }, /* (188) as ::= */ + { 260, -1 }, /* (189) distinct ::= DISTINCT */ + { 260, 0 }, /* (190) distinct ::= */ + { 246, -2 }, /* (191) from ::= FROM tablelist */ + { 246, -2 }, /* (192) from ::= FROM sub */ + { 264, -3 }, /* (193) sub ::= LP union RP */ + { 264, -4 }, /* (194) sub ::= LP union RP ids */ + { 264, -6 }, /* (195) sub ::= sub COMMA LP union RP ids */ + { 263, -2 }, /* (196) tablelist ::= ids cpxName */ + { 263, -3 }, /* (197) tablelist ::= ids cpxName ids */ + { 263, -4 }, /* (198) tablelist ::= tablelist COMMA ids cpxName */ + { 263, -5 }, /* (199) tablelist ::= tablelist COMMA ids cpxName ids */ + { 265, -1 }, /* (200) tmvar ::= VARIABLE */ + { 248, -4 }, /* (201) interval_option ::= intervalKey LP tmvar RP */ + { 248, -6 }, /* (202) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 248, 0 }, /* (203) interval_option ::= */ + { 266, -1 }, /* (204) intervalKey ::= INTERVAL */ + { 266, -1 }, /* (205) intervalKey ::= EVERY */ + { 250, 0 }, /* (206) session_option ::= */ + { 250, -7 }, /* (207) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 251, 0 }, /* (208) windowstate_option ::= */ + { 251, -4 }, /* (209) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 252, 0 }, /* (210) fill_opt ::= */ + { 252, -6 }, /* (211) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 252, -4 }, /* (212) fill_opt ::= FILL LP ID RP */ + { 249, -4 }, /* (213) sliding_opt ::= SLIDING LP tmvar RP */ + { 249, 0 }, /* (214) sliding_opt ::= */ + { 255, 0 }, /* (215) orderby_opt ::= */ + { 255, -3 }, /* (216) orderby_opt ::= ORDER BY sortlist */ + { 267, -4 }, /* (217) sortlist ::= sortlist COMMA item sortorder */ + { 267, -2 }, /* (218) sortlist ::= item sortorder */ + { 269, -2 }, /* (219) item ::= ids cpxName */ + { 270, -1 }, /* (220) sortorder ::= ASC */ + { 270, -1 }, /* (221) sortorder ::= DESC */ + { 270, 0 }, /* (222) sortorder ::= */ + { 253, 0 }, /* (223) groupby_opt ::= */ + { 253, -3 }, /* (224) groupby_opt ::= GROUP BY grouplist */ + { 271, -3 }, /* (225) grouplist ::= grouplist COMMA item */ + { 271, -1 }, /* (226) grouplist ::= item */ + { 254, 0 }, /* (227) having_opt ::= */ + { 254, -2 }, /* (228) having_opt ::= HAVING expr */ + { 257, 0 }, /* (229) limit_opt ::= */ + { 257, -2 }, /* (230) limit_opt ::= LIMIT signed */ + { 257, -4 }, /* (231) limit_opt ::= LIMIT signed OFFSET signed */ + { 257, -4 }, /* (232) limit_opt ::= LIMIT signed COMMA signed */ + { 256, 0 }, /* (233) slimit_opt ::= */ + { 256, -2 }, /* (234) slimit_opt ::= SLIMIT signed */ + { 256, -4 }, /* (235) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 256, -4 }, /* (236) slimit_opt ::= SLIMIT signed COMMA signed */ + { 247, 0 }, /* (237) where_opt ::= */ + { 247, -2 }, /* (238) where_opt ::= WHERE expr */ + { 261, -3 }, /* (239) expr ::= LP expr RP */ + { 261, -1 }, /* (240) expr ::= ID */ + { 261, -3 }, /* (241) expr ::= ID DOT ID */ + { 261, -3 }, /* (242) expr ::= ID DOT STAR */ + { 261, -1 }, /* (243) expr ::= INTEGER */ + { 261, -2 }, /* (244) expr ::= MINUS INTEGER */ + { 261, -2 }, /* (245) expr ::= PLUS INTEGER */ + { 261, -1 }, /* (246) expr ::= FLOAT */ + { 261, -2 }, /* (247) expr ::= MINUS FLOAT */ + { 261, -2 }, /* (248) expr ::= PLUS FLOAT */ + { 261, -1 }, /* (249) expr ::= STRING */ + { 261, -1 }, /* (250) expr ::= NOW */ + { 261, -1 }, /* (251) expr ::= VARIABLE */ + { 261, -2 }, /* (252) expr ::= PLUS VARIABLE */ + { 261, -2 }, /* (253) expr ::= MINUS VARIABLE */ + { 261, -1 }, /* (254) expr ::= BOOL */ + { 261, -1 }, /* (255) expr ::= NULL */ + { 261, -4 }, /* (256) expr ::= ID LP exprlist RP */ + { 261, -4 }, /* (257) expr ::= ID LP STAR RP */ + { 261, -3 }, /* (258) expr ::= expr IS NULL */ + { 261, -4 }, /* (259) expr ::= expr IS NOT NULL */ + { 261, -3 }, /* (260) expr ::= expr LT expr */ + { 261, -3 }, /* (261) expr ::= expr GT expr */ + { 261, -3 }, /* (262) expr ::= expr LE expr */ + { 261, -3 }, /* (263) expr ::= expr GE expr */ + { 261, -3 }, /* (264) expr ::= expr NE expr */ + { 261, -3 }, /* (265) expr ::= expr EQ expr */ + { 261, -5 }, /* (266) expr ::= expr BETWEEN expr AND expr */ + { 261, -3 }, /* (267) expr ::= expr AND expr */ + { 261, -3 }, /* (268) expr ::= expr OR expr */ + { 261, -3 }, /* (269) expr ::= expr PLUS expr */ + { 261, -3 }, /* (270) expr ::= expr MINUS expr */ + { 261, -3 }, /* (271) expr ::= expr STAR expr */ + { 261, -3 }, /* (272) expr ::= expr SLASH expr */ + { 261, -3 }, /* (273) expr ::= expr REM expr */ + { 261, -3 }, /* (274) expr ::= expr LIKE expr */ + { 261, -3 }, /* (275) expr ::= expr MATCH expr */ + { 261, -3 }, /* (276) expr ::= expr NMATCH expr */ + { 261, -5 }, /* (277) expr ::= expr IN LP exprlist RP */ + { 200, -3 }, /* (278) exprlist ::= exprlist COMMA expritem */ + { 200, -1 }, /* (279) exprlist ::= expritem */ + { 272, -1 }, /* (280) expritem ::= expr */ + { 272, 0 }, /* (281) expritem ::= */ + { 193, -3 }, /* (282) cmd ::= RESET QUERY CACHE */ + { 193, -3 }, /* (283) cmd ::= SYNCDB ids REPLICA */ + { 193, -7 }, /* (284) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (285) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (286) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (287) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (288) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (289) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (290) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (291) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 193, -7 }, /* (292) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 193, -7 }, /* (293) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 193, -7 }, /* (294) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 193, -7 }, /* (295) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 193, -7 }, /* (296) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 193, -8 }, /* (297) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 193, -9 }, /* (298) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 193, -7 }, /* (299) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 193, -3 }, /* (300) cmd ::= KILL CONNECTION INTEGER */ + { 193, -5 }, /* (301) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 193, -5 }, /* (302) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2217,9 +2224,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 133: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==133); - case 134: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==134); - case 135: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==135); + case 135: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==135); + case 136: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==136); + case 137: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==137); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2395,16 +2402,16 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 47: /* cmd ::= ALTER DATABASE ids alter_db_optr */ -{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &t);} +{ SToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy16, &t);} break; case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy171);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy211);} break; case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy211);} break; case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy413);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy165);} break; case 51: /* ids ::= ID */ case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); @@ -2416,7 +2423,7 @@ static void yy_reduce( break; case 54: /* ifexists ::= */ case 56: /* ifnotexists ::= */ yytestcase(yyruleno==56); - case 188: /* distinct ::= */ yytestcase(yyruleno==188); + case 190: /* distinct ::= */ yytestcase(yyruleno==190); { yymsp[1].minor.yy0.n = 0;} break; case 55: /* ifnotexists ::= IF NOT EXISTS */ @@ -2427,16 +2434,16 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} break; case 59: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy171);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy211);} break; case 60: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy254, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy16, &yymsp[-2].minor.yy0);} break; case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy106, &yymsp[0].minor.yy0, 1);} break; case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy280, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy106, &yymsp[0].minor.yy0, 2);} break; case 63: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2467,38 +2474,38 @@ static void yy_reduce( break; case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy171.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy171.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy171.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy171.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy171.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy171.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy171.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy171.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy171.stat = yymsp[0].minor.yy0; + yylhsminor.yy211.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy211.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy211.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy211.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy211.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy211.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy211.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy211.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy211.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy171 = yylhsminor.yy171; + yymsp[-8].minor.yy211 = yylhsminor.yy211; break; case 85: /* intitemlist ::= intitemlist COMMA intitem */ - case 161: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==161); -{ yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1); } - yymsp[-2].minor.yy413 = yylhsminor.yy413; + case 163: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==163); +{ yylhsminor.yy165 = tListItemAppend(yymsp[-2].minor.yy165, &yymsp[0].minor.yy425, -1); } + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; case 86: /* intitemlist ::= intitem */ - case 162: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==162); -{ yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1); } - yymsp[0].minor.yy413 = yylhsminor.yy413; + case 164: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==164); +{ yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[0].minor.yy425, -1); } + yymsp[0].minor.yy165 = yylhsminor.yy165; break; case 87: /* intitem ::= INTEGER */ - case 163: /* tagitem ::= INTEGER */ yytestcase(yyruleno==163); - case 164: /* tagitem ::= FLOAT */ yytestcase(yyruleno==164); - case 165: /* tagitem ::= STRING */ yytestcase(yyruleno==165); - case 166: /* tagitem ::= BOOL */ yytestcase(yyruleno==166); -{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy461 = yylhsminor.yy461; + case 165: /* tagitem ::= INTEGER */ yytestcase(yyruleno==165); + case 166: /* tagitem ::= FLOAT */ yytestcase(yyruleno==166); + case 167: /* tagitem ::= STRING */ yytestcase(yyruleno==167); + case 168: /* tagitem ::= BOOL */ yytestcase(yyruleno==168); +{ toTSDBType(yymsp[0].minor.yy0.type); taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy425 = yylhsminor.yy425; break; case 88: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy413 = yymsp[0].minor.yy413; } +{ yymsp[-1].minor.yy165 = yymsp[0].minor.yy165; } break; case 89: /* cache ::= CACHE INTEGER */ case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); @@ -2514,673 +2521,678 @@ static void yy_reduce( case 100: /* prec ::= PRECISION STRING */ yytestcase(yyruleno==100); case 101: /* update ::= UPDATE INTEGER */ yytestcase(yyruleno==101); case 102: /* cachelast ::= CACHELAST INTEGER */ yytestcase(yyruleno==102); + case 103: /* vgroups ::= VGROUPS INTEGER */ yytestcase(yyruleno==103); { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 103: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy254);} + case 104: /* db_optr ::= */ +{setDefaultCreateDbOption(&yymsp[1].minor.yy16);} break; - case 104: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 105: /* db_optr ::= db_optr cache */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 105: /* db_optr ::= db_optr replica */ - case 120: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==120); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 106: /* db_optr ::= db_optr replica */ + case 122: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==122); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 106: /* db_optr ::= db_optr quorum */ - case 121: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==121); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 107: /* db_optr ::= db_optr quorum */ + case 123: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==123); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 107: /* db_optr ::= db_optr days */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 108: /* db_optr ::= db_optr days */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 108: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 109: /* db_optr ::= db_optr minrows */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 109: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 110: /* db_optr ::= db_optr maxrows */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 110: /* db_optr ::= db_optr blocks */ - case 123: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==123); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 111: /* db_optr ::= db_optr blocks */ + case 125: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==125); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 111: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 112: /* db_optr ::= db_optr ctime */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 112: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 113: /* db_optr ::= db_optr wal */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 113: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 114: /* db_optr ::= db_optr fsync */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 114: /* db_optr ::= db_optr comp */ - case 124: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==124); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 115: /* db_optr ::= db_optr comp */ + case 126: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==126); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 115: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 116: /* db_optr ::= db_optr prec */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 116: /* db_optr ::= db_optr keep */ - case 122: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==122); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.keep = yymsp[0].minor.yy413; } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 117: /* db_optr ::= db_optr keep */ + case 124: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==124); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.keep = yymsp[0].minor.yy165; } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 117: /* db_optr ::= db_optr update */ - case 125: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==125); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 118: /* db_optr ::= db_optr update */ + case 127: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==127); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 118: /* db_optr ::= db_optr cachelast */ - case 126: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==126); -{ yylhsminor.yy254 = yymsp[-1].minor.yy254; yylhsminor.yy254.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy254 = yylhsminor.yy254; + case 119: /* db_optr ::= db_optr cachelast */ + case 128: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==128); +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 119: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy254);} + case 120: /* db_optr ::= db_optr vgroups */ +{ yylhsminor.yy16 = yymsp[-1].minor.yy16; yylhsminor.yy16.numOfVgroups = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy16 = yylhsminor.yy16; break; - case 127: /* typename ::= ids */ + case 121: /* alter_db_optr ::= */ +{ setDefaultCreateDbOption(&yymsp[1].minor.yy16);} + break; + case 129: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy280, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy106, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + yymsp[0].minor.yy106 = yylhsminor.yy106; break; - case 128: /* typename ::= ids LP signed RP */ + case 130: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy157 <= 0) { + if (yymsp[-1].minor.yy207 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy106, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy157; // negative value of name length - tSetColumnType(&yylhsminor.yy280, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy207; // negative value of name length + tSetColumnType(&yylhsminor.yy106, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy280 = yylhsminor.yy280; + yymsp[-3].minor.yy106 = yylhsminor.yy106; break; - case 129: /* typename ::= ids UNSIGNED */ + case 131: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy280, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy106, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy280 = yylhsminor.yy280; + yymsp[-1].minor.yy106 = yylhsminor.yy106; break; - case 130: /* signed ::= INTEGER */ -{ yylhsminor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy157 = yylhsminor.yy157; + case 132: /* signed ::= INTEGER */ +{ yylhsminor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy207 = yylhsminor.yy207; break; - case 131: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy157 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + case 133: /* signed ::= PLUS INTEGER */ +{ yymsp[-1].minor.yy207 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 132: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy157 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} + case 134: /* signed ::= MINUS INTEGER */ +{ yymsp[-1].minor.yy207 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 136: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy438;} + case 138: /* cmd ::= CREATE TABLE create_table_list */ +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy326;} break; - case 137: /* create_table_list ::= create_from_stable */ + case 139: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy544); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy150); pCreateTable->type = TSQL_CREATE_CTABLE; - yylhsminor.yy438 = pCreateTable; + yylhsminor.yy326 = pCreateTable; } - yymsp[0].minor.yy438 = yylhsminor.yy438; + yymsp[0].minor.yy326 = yylhsminor.yy326; break; - case 138: /* create_table_list ::= create_table_list create_from_stable */ + case 140: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy438->childTableInfo, &yymsp[0].minor.yy544); - yylhsminor.yy438 = yymsp[-1].minor.yy438; + taosArrayPush(yymsp[-1].minor.yy326->childTableInfo, &yymsp[0].minor.yy150); + yylhsminor.yy326 = yymsp[-1].minor.yy326; } - yymsp[-1].minor.yy438 = yylhsminor.yy438; + yymsp[-1].minor.yy326 = yylhsminor.yy326; break; - case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 141: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-1].minor.yy413, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy326 = tSetCreateTableInfo(yymsp[-1].minor.yy165, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy438 = yylhsminor.yy438; + yymsp[-5].minor.yy326 = yylhsminor.yy326; break; - case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 142: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy438 = tSetCreateTableInfo(yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy326 = tSetCreateTableInfo(yymsp[-5].minor.yy165, yymsp[-1].minor.yy165, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy438 = yylhsminor.yy438; + yymsp[-9].minor.yy326 = yylhsminor.yy326; break; - case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ + case 143: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist1 RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy413, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy150 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy165, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy544 = yylhsminor.yy544; + yymsp[-9].minor.yy150 = yylhsminor.yy150; break; - case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ + case 144: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist1 RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy544 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, yymsp[-1].minor.yy413, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy150 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy165, yymsp[-1].minor.yy165, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy544 = yylhsminor.yy544; + yymsp[-12].minor.yy150 = yylhsminor.yy150; break; - case 143: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413; } - yymsp[-2].minor.yy413 = yylhsminor.yy413; + case 145: /* tagNamelist ::= tagNamelist COMMA ids */ +{taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy0); yylhsminor.yy165 = yymsp[-2].minor.yy165; } + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; - case 144: /* tagNamelist ::= ids */ -{yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy413 = yylhsminor.yy413; + case 146: /* tagNamelist ::= ids */ +{yylhsminor.yy165 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy165 = yylhsminor.yy165; break; - case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 147: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy438 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy24, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy438, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy326 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy278, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy326, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy438 = yylhsminor.yy438; + yymsp[-4].minor.yy326 = yylhsminor.yy326; break; - case 146: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy280); yylhsminor.yy413 = yymsp[-2].minor.yy413; } - yymsp[-2].minor.yy413 = yylhsminor.yy413; + case 148: /* columnlist ::= columnlist COMMA column */ +{taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy106); yylhsminor.yy165 = yymsp[-2].minor.yy165; } + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; - case 147: /* columnlist ::= column */ -{yylhsminor.yy413 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy280);} - yymsp[0].minor.yy413 = yylhsminor.yy413; + case 149: /* columnlist ::= column */ +{yylhsminor.yy165 = taosArrayInit(4, sizeof(SField)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy106);} + yymsp[0].minor.yy165 = yylhsminor.yy165; break; - case 148: /* column ::= ids typename */ + case 150: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy280, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy280); + tSetColumnInfo(&yylhsminor.yy106, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy106); } - yymsp[-1].minor.yy280 = yylhsminor.yy280; + yymsp[-1].minor.yy106 = yylhsminor.yy106; break; - case 149: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ -{ taosArrayPush(yymsp[-2].minor.yy413, &yymsp[0].minor.yy0); yylhsminor.yy413 = yymsp[-2].minor.yy413;} - yymsp[-2].minor.yy413 = yylhsminor.yy413; + case 151: /* tagitemlist1 ::= tagitemlist1 COMMA tagitem1 */ +{ taosArrayPush(yymsp[-2].minor.yy165, &yymsp[0].minor.yy0); yylhsminor.yy165 = yymsp[-2].minor.yy165;} + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; - case 150: /* tagitemlist1 ::= tagitem1 */ -{ yylhsminor.yy413 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy413, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy413 = yylhsminor.yy413; + case 152: /* tagitemlist1 ::= tagitem1 */ +{ yylhsminor.yy165 = taosArrayInit(4, sizeof(SToken)); taosArrayPush(yylhsminor.yy165, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy165 = yylhsminor.yy165; break; - case 151: /* tagitem1 ::= MINUS INTEGER */ - case 152: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==152); - case 153: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==153); - case 154: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==154); + case 153: /* tagitem1 ::= MINUS INTEGER */ + case 154: /* tagitem1 ::= MINUS FLOAT */ yytestcase(yyruleno==154); + case 155: /* tagitem1 ::= PLUS INTEGER */ yytestcase(yyruleno==155); + case 156: /* tagitem1 ::= PLUS FLOAT */ yytestcase(yyruleno==156); { yylhsminor.yy0.n = yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n; yylhsminor.yy0.type = yymsp[0].minor.yy0.type; } yymsp[-1].minor.yy0 = yylhsminor.yy0; break; - case 155: /* tagitem1 ::= INTEGER */ - case 156: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==156); - case 157: /* tagitem1 ::= STRING */ yytestcase(yyruleno==157); - case 158: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==158); - case 159: /* tagitem1 ::= NULL */ yytestcase(yyruleno==159); - case 160: /* tagitem1 ::= NOW */ yytestcase(yyruleno==160); + case 157: /* tagitem1 ::= INTEGER */ + case 158: /* tagitem1 ::= FLOAT */ yytestcase(yyruleno==158); + case 159: /* tagitem1 ::= STRING */ yytestcase(yyruleno==159); + case 160: /* tagitem1 ::= BOOL */ yytestcase(yyruleno==160); + case 161: /* tagitem1 ::= NULL */ yytestcase(yyruleno==161); + case 162: /* tagitem1 ::= NOW */ yytestcase(yyruleno==162); { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 167: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } - yymsp[0].minor.yy461 = yylhsminor.yy461; + case 169: /* tagitem ::= NULL */ +{ yymsp[0].minor.yy0.type = 0; taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type); } + yymsp[0].minor.yy425 = yylhsminor.yy425; break; - case 168: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy461, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} - yymsp[0].minor.yy461 = yylhsminor.yy461; + case 170: /* tagitem ::= NOW */ +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; taosVariantCreate(&yylhsminor.yy425, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.type);} + yymsp[0].minor.yy425 = yylhsminor.yy425; break; - case 169: /* tagitem ::= MINUS INTEGER */ - case 170: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==170); - case 171: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==171); - case 172: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==172); + case 171: /* tagitem ::= MINUS INTEGER */ + case 172: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==172); + case 173: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==173); + case 174: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==174); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy425, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy461 = yylhsminor.yy461; + yymsp[-1].minor.yy425 = yylhsminor.yy425; break; - case 173: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + case 175: /* select ::= SELECT selcollist from where_opt interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy413, yymsp[-11].minor.yy292, yymsp[-10].minor.yy370, yymsp[-4].minor.yy413, yymsp[-2].minor.yy413, &yymsp[-9].minor.yy136, &yymsp[-7].minor.yy251, &yymsp[-6].minor.yy256, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy413, &yymsp[0].minor.yy503, &yymsp[-1].minor.yy503, yymsp[-3].minor.yy370); + yylhsminor.yy278 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy165, yymsp[-11].minor.yy10, yymsp[-10].minor.yy202, yymsp[-4].minor.yy165, yymsp[-2].minor.yy165, &yymsp[-9].minor.yy532, &yymsp[-7].minor.yy97, &yymsp[-6].minor.yy6, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy165, &yymsp[0].minor.yy367, &yymsp[-1].minor.yy367, yymsp[-3].minor.yy202); } - yymsp[-13].minor.yy24 = yylhsminor.yy24; + yymsp[-13].minor.yy278 = yylhsminor.yy278; break; - case 174: /* select ::= LP select RP */ -{yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24;} + case 176: /* select ::= LP select RP */ +{yymsp[-2].minor.yy278 = yymsp[-1].minor.yy278;} break; - case 175: /* union ::= select */ -{ yylhsminor.yy129 = setSubclause(NULL, yymsp[0].minor.yy24); } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 177: /* union ::= select */ +{ yylhsminor.yy503 = setSubclause(NULL, yymsp[0].minor.yy278); } + yymsp[0].minor.yy503 = yylhsminor.yy503; break; - case 176: /* union ::= union UNION ALL select */ -{ yylhsminor.yy129 = appendSelectClause(yymsp[-3].minor.yy129, SQL_TYPE_UNIONALL, yymsp[0].minor.yy24); } - yymsp[-3].minor.yy129 = yylhsminor.yy129; + case 178: /* union ::= union UNION ALL select */ +{ yylhsminor.yy503 = appendSelectClause(yymsp[-3].minor.yy503, SQL_TYPE_UNIONALL, yymsp[0].minor.yy278); } + yymsp[-3].minor.yy503 = yylhsminor.yy503; break; - case 177: /* union ::= union UNION select */ -{ yylhsminor.yy129 = appendSelectClause(yymsp[-2].minor.yy129, SQL_TYPE_UNION, yymsp[0].minor.yy24); } - yymsp[-2].minor.yy129 = yylhsminor.yy129; + case 179: /* union ::= union UNION select */ +{ yylhsminor.yy503 = appendSelectClause(yymsp[-2].minor.yy503, SQL_TYPE_UNION, yymsp[0].minor.yy278); } + yymsp[-2].minor.yy503 = yylhsminor.yy503; break; - case 178: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy129, NULL, TSDB_SQL_SELECT); } + case 180: /* cmd ::= union */ +{ setSqlInfo(pInfo, yymsp[0].minor.yy503, NULL, TSDB_SQL_SELECT); } break; - case 179: /* select ::= SELECT selcollist */ + case 181: /* select ::= SELECT selcollist */ { - yylhsminor.yy24 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy413, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy278 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy165, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy24 = yylhsminor.yy24; + yymsp[-1].minor.yy278 = yylhsminor.yy278; break; - case 180: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy413 = yymsp[-1].minor.yy413;} - yymsp[-1].minor.yy413 = yylhsminor.yy413; + case 182: /* sclp ::= selcollist COMMA */ +{yylhsminor.yy165 = yymsp[-1].minor.yy165;} + yymsp[-1].minor.yy165 = yylhsminor.yy165; break; - case 181: /* sclp ::= */ - case 213: /* orderby_opt ::= */ yytestcase(yyruleno==213); -{yymsp[1].minor.yy413 = 0;} + case 183: /* sclp ::= */ + case 215: /* orderby_opt ::= */ yytestcase(yyruleno==215); +{yymsp[1].minor.yy165 = 0;} break; - case 182: /* selcollist ::= sclp distinct expr as */ + case 184: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy413 = tSqlExprListAppend(yymsp[-3].minor.yy413, yymsp[-1].minor.yy370, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy165 = tSqlExprListAppend(yymsp[-3].minor.yy165, yymsp[-1].minor.yy202, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy413 = yylhsminor.yy413; + yymsp[-3].minor.yy165 = yylhsminor.yy165; break; - case 183: /* selcollist ::= sclp STAR */ + case 185: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy413 = tSqlExprListAppend(yymsp[-1].minor.yy413, pNode, 0, 0); + yylhsminor.yy165 = tSqlExprListAppend(yymsp[-1].minor.yy165, pNode, 0, 0); } - yymsp[-1].minor.yy413 = yylhsminor.yy413; + yymsp[-1].minor.yy165 = yylhsminor.yy165; break; - case 184: /* as ::= AS ids */ + case 186: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 185: /* as ::= ids */ + case 187: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 186: /* as ::= */ + case 188: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 187: /* distinct ::= DISTINCT */ + case 189: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 189: /* from ::= FROM tablelist */ - case 190: /* from ::= FROM sub */ yytestcase(yyruleno==190); -{yymsp[-1].minor.yy292 = yymsp[0].minor.yy292;} + case 191: /* from ::= FROM tablelist */ + case 192: /* from ::= FROM sub */ yytestcase(yyruleno==192); +{yymsp[-1].minor.yy10 = yymsp[0].minor.yy10;} break; - case 191: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy292 = addSubquery(NULL, yymsp[-1].minor.yy129, NULL);} + case 193: /* sub ::= LP union RP */ +{yymsp[-2].minor.yy10 = addSubquery(NULL, yymsp[-1].minor.yy503, NULL);} break; - case 192: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy292 = addSubquery(NULL, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} + case 194: /* sub ::= LP union RP ids */ +{yymsp[-3].minor.yy10 = addSubquery(NULL, yymsp[-2].minor.yy503, &yymsp[0].minor.yy0);} break; - case 193: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy292 = addSubquery(yymsp[-5].minor.yy292, yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy292 = yylhsminor.yy292; + case 195: /* sub ::= sub COMMA LP union RP ids */ +{yylhsminor.yy10 = addSubquery(yymsp[-5].minor.yy10, yymsp[-2].minor.yy503, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy10 = yylhsminor.yy10; break; - case 194: /* tablelist ::= ids cpxName */ + case 196: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy10 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy292 = yylhsminor.yy292; + yymsp[-1].minor.yy10 = yylhsminor.yy10; break; - case 195: /* tablelist ::= ids cpxName ids */ + case 197: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy292 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy10 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy292 = yylhsminor.yy292; + yymsp[-2].minor.yy10 = yylhsminor.yy10; break; - case 196: /* tablelist ::= tablelist COMMA ids cpxName */ + case 198: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy292 = setTableNameList(yymsp[-3].minor.yy292, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy10 = setTableNameList(yymsp[-3].minor.yy10, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy292 = yylhsminor.yy292; + yymsp[-3].minor.yy10 = yylhsminor.yy10; break; - case 197: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 199: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy292 = setTableNameList(yymsp[-4].minor.yy292, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy10 = setTableNameList(yymsp[-4].minor.yy10, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy292 = yylhsminor.yy292; + yymsp[-4].minor.yy10 = yylhsminor.yy10; break; - case 198: /* tmvar ::= VARIABLE */ + case 200: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 199: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy136.interval = yymsp[-1].minor.yy0; yylhsminor.yy136.offset.n = 0; yylhsminor.yy136.token = yymsp[-3].minor.yy516;} - yymsp[-3].minor.yy136 = yylhsminor.yy136; + case 201: /* interval_option ::= intervalKey LP tmvar RP */ +{yylhsminor.yy532.interval = yymsp[-1].minor.yy0; yylhsminor.yy532.offset.n = 0; yylhsminor.yy532.token = yymsp[-3].minor.yy46;} + yymsp[-3].minor.yy532 = yylhsminor.yy532; break; - case 200: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy136.interval = yymsp[-3].minor.yy0; yylhsminor.yy136.offset = yymsp[-1].minor.yy0; yylhsminor.yy136.token = yymsp[-5].minor.yy516;} - yymsp[-5].minor.yy136 = yylhsminor.yy136; + case 202: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ +{yylhsminor.yy532.interval = yymsp[-3].minor.yy0; yylhsminor.yy532.offset = yymsp[-1].minor.yy0; yylhsminor.yy532.token = yymsp[-5].minor.yy46;} + yymsp[-5].minor.yy532 = yylhsminor.yy532; break; - case 201: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy136, 0, sizeof(yymsp[1].minor.yy136));} + case 203: /* interval_option ::= */ +{memset(&yymsp[1].minor.yy532, 0, sizeof(yymsp[1].minor.yy532));} break; - case 202: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy516 = TK_INTERVAL;} + case 204: /* intervalKey ::= INTERVAL */ +{yymsp[0].minor.yy46 = TK_INTERVAL;} break; - case 203: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy516 = TK_EVERY; } + case 205: /* intervalKey ::= EVERY */ +{yymsp[0].minor.yy46 = TK_EVERY; } break; - case 204: /* session_option ::= */ -{yymsp[1].minor.yy251.col.n = 0; yymsp[1].minor.yy251.gap.n = 0;} + case 206: /* session_option ::= */ +{yymsp[1].minor.yy97.col.n = 0; yymsp[1].minor.yy97.gap.n = 0;} break; - case 205: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 207: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy251.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy251.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy97.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy97.gap = yymsp[-1].minor.yy0; } break; - case 206: /* windowstate_option ::= */ -{ yymsp[1].minor.yy256.col.n = 0; yymsp[1].minor.yy256.col.z = NULL;} + case 208: /* windowstate_option ::= */ +{ yymsp[1].minor.yy6.col.n = 0; yymsp[1].minor.yy6.col.z = NULL;} break; - case 207: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy256.col = yymsp[-1].minor.yy0; } + case 209: /* windowstate_option ::= STATE_WINDOW LP ids RP */ +{ yymsp[-3].minor.yy6.col = yymsp[-1].minor.yy0; } break; - case 208: /* fill_opt ::= */ -{ yymsp[1].minor.yy413 = 0; } + case 210: /* fill_opt ::= */ +{ yymsp[1].minor.yy165 = 0; } break; - case 209: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 211: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { SVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); taosVariantCreate(&A, yymsp[-3].minor.yy0.z, yymsp[-3].minor.yy0.n, yymsp[-3].minor.yy0.type); - tListItemInsert(yymsp[-1].minor.yy413, &A, -1, 0); - yymsp[-5].minor.yy413 = yymsp[-1].minor.yy413; + tListItemInsert(yymsp[-1].minor.yy165, &A, -1, 0); + yymsp[-5].minor.yy165 = yymsp[-1].minor.yy165; } break; - case 210: /* fill_opt ::= FILL LP ID RP */ + case 212: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy413 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy165 = tListItemAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 211: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 213: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 212: /* sliding_opt ::= */ + case 214: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 214: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;} + case 216: /* orderby_opt ::= ORDER BY sortlist */ +{yymsp[-2].minor.yy165 = yymsp[0].minor.yy165;} break; - case 215: /* sortlist ::= sortlist COMMA item sortorder */ + case 217: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy413 = tListItemAppend(yymsp[-3].minor.yy413, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60); + yylhsminor.yy165 = tListItemAppend(yymsp[-3].minor.yy165, &yymsp[-1].minor.yy425, yymsp[0].minor.yy47); } - yymsp[-3].minor.yy413 = yylhsminor.yy413; + yymsp[-3].minor.yy165 = yylhsminor.yy165; break; - case 216: /* sortlist ::= item sortorder */ + case 218: /* sortlist ::= item sortorder */ { - yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[-1].minor.yy461, yymsp[0].minor.yy60); + yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[-1].minor.yy425, yymsp[0].minor.yy47); } - yymsp[-1].minor.yy413 = yylhsminor.yy413; + yymsp[-1].minor.yy165 = yylhsminor.yy165; break; - case 217: /* item ::= ids cpxName */ + case 219: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - taosVariantCreate(&yylhsminor.yy461, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); + taosVariantCreate(&yylhsminor.yy425, yymsp[-1].minor.yy0.z, yymsp[-1].minor.yy0.n, yymsp[-1].minor.yy0.type); } - yymsp[-1].minor.yy461 = yylhsminor.yy461; + yymsp[-1].minor.yy425 = yylhsminor.yy425; break; - case 218: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy60 = TSDB_ORDER_ASC; } + case 220: /* sortorder ::= ASC */ +{ yymsp[0].minor.yy47 = TSDB_ORDER_ASC; } break; - case 219: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy60 = TSDB_ORDER_DESC;} + case 221: /* sortorder ::= DESC */ +{ yymsp[0].minor.yy47 = TSDB_ORDER_DESC;} break; - case 220: /* sortorder ::= */ -{ yymsp[1].minor.yy60 = TSDB_ORDER_ASC; } + case 222: /* sortorder ::= */ +{ yymsp[1].minor.yy47 = TSDB_ORDER_ASC; } break; - case 221: /* groupby_opt ::= */ -{ yymsp[1].minor.yy413 = 0;} + case 223: /* groupby_opt ::= */ +{ yymsp[1].minor.yy165 = 0;} break; - case 222: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy413 = yymsp[0].minor.yy413;} + case 224: /* groupby_opt ::= GROUP BY grouplist */ +{ yymsp[-2].minor.yy165 = yymsp[0].minor.yy165;} break; - case 223: /* grouplist ::= grouplist COMMA item */ + case 225: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy413 = tListItemAppend(yymsp[-2].minor.yy413, &yymsp[0].minor.yy461, -1); + yylhsminor.yy165 = tListItemAppend(yymsp[-2].minor.yy165, &yymsp[0].minor.yy425, -1); } - yymsp[-2].minor.yy413 = yylhsminor.yy413; + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; - case 224: /* grouplist ::= item */ + case 226: /* grouplist ::= item */ { - yylhsminor.yy413 = tListItemAppend(NULL, &yymsp[0].minor.yy461, -1); + yylhsminor.yy165 = tListItemAppend(NULL, &yymsp[0].minor.yy425, -1); } - yymsp[0].minor.yy413 = yylhsminor.yy413; + yymsp[0].minor.yy165 = yylhsminor.yy165; break; - case 225: /* having_opt ::= */ - case 235: /* where_opt ::= */ yytestcase(yyruleno==235); - case 279: /* expritem ::= */ yytestcase(yyruleno==279); -{yymsp[1].minor.yy370 = 0;} + case 227: /* having_opt ::= */ + case 237: /* where_opt ::= */ yytestcase(yyruleno==237); + case 281: /* expritem ::= */ yytestcase(yyruleno==281); +{yymsp[1].minor.yy202 = 0;} break; - case 226: /* having_opt ::= HAVING expr */ - case 236: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==236); -{yymsp[-1].minor.yy370 = yymsp[0].minor.yy370;} + case 228: /* having_opt ::= HAVING expr */ + case 238: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==238); +{yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;} break; - case 227: /* limit_opt ::= */ - case 231: /* slimit_opt ::= */ yytestcase(yyruleno==231); -{yymsp[1].minor.yy503.limit = -1; yymsp[1].minor.yy503.offset = 0;} + case 229: /* limit_opt ::= */ + case 233: /* slimit_opt ::= */ yytestcase(yyruleno==233); +{yymsp[1].minor.yy367.limit = -1; yymsp[1].minor.yy367.offset = 0;} break; - case 228: /* limit_opt ::= LIMIT signed */ - case 232: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==232); -{yymsp[-1].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-1].minor.yy503.offset = 0;} + case 230: /* limit_opt ::= LIMIT signed */ + case 234: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==234); +{yymsp[-1].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-1].minor.yy367.offset = 0;} break; - case 229: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;} + case 231: /* limit_opt ::= LIMIT signed OFFSET signed */ +{ yymsp[-3].minor.yy367.limit = yymsp[-2].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[0].minor.yy207;} break; - case 230: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;} + case 232: /* limit_opt ::= LIMIT signed COMMA signed */ +{ yymsp[-3].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[-2].minor.yy207;} break; - case 233: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy503.limit = yymsp[-2].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[0].minor.yy157;} + case 235: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ +{yymsp[-3].minor.yy367.limit = yymsp[-2].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[0].minor.yy207;} break; - case 234: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy503.limit = yymsp[0].minor.yy157; yymsp[-3].minor.yy503.offset = yymsp[-2].minor.yy157;} + case 236: /* slimit_opt ::= SLIMIT signed COMMA signed */ +{yymsp[-3].minor.yy367.limit = yymsp[0].minor.yy207; yymsp[-3].minor.yy367.offset = yymsp[-2].minor.yy207;} break; - case 237: /* expr ::= LP expr RP */ -{yylhsminor.yy370 = yymsp[-1].minor.yy370; yylhsminor.yy370->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy370->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 239: /* expr ::= LP expr RP */ +{yylhsminor.yy202 = yymsp[-1].minor.yy202; yylhsminor.yy202->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy202->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 238: /* expr ::= ID */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 240: /* expr ::= ID */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 239: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 241: /* expr ::= ID DOT ID */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 240: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 242: /* expr ::= ID DOT STAR */ +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 241: /* expr ::= INTEGER */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 243: /* expr ::= INTEGER */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 242: /* expr ::= MINUS INTEGER */ - case 243: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==243); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy370 = yylhsminor.yy370; + case 244: /* expr ::= MINUS INTEGER */ + case 245: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==245); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy202 = yylhsminor.yy202; break; - case 244: /* expr ::= FLOAT */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 246: /* expr ::= FLOAT */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 245: /* expr ::= MINUS FLOAT */ - case 246: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==246); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy370 = yylhsminor.yy370; + case 247: /* expr ::= MINUS FLOAT */ + case 248: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==248); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy202 = yylhsminor.yy202; break; - case 247: /* expr ::= STRING */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 249: /* expr ::= STRING */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 248: /* expr ::= NOW */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 250: /* expr ::= NOW */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 249: /* expr ::= VARIABLE */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 251: /* expr ::= VARIABLE */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 250: /* expr ::= PLUS VARIABLE */ - case 251: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==251); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy370 = yylhsminor.yy370; + case 252: /* expr ::= PLUS VARIABLE */ + case 253: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==253); +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy202 = yylhsminor.yy202; break; - case 252: /* expr ::= BOOL */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 254: /* expr ::= BOOL */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 253: /* expr ::= NULL */ -{ yylhsminor.yy370 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 255: /* expr ::= NULL */ +{ yylhsminor.yy202 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 254: /* expr ::= ID LP exprlist RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(yymsp[-1].minor.yy413, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy370 = yylhsminor.yy370; + case 256: /* expr ::= ID LP exprlist RP */ +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy202 = tSqlExprCreateFunction(yymsp[-1].minor.yy165, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy202 = yylhsminor.yy202; break; - case 255: /* expr ::= ID LP STAR RP */ -{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy370 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy370 = yylhsminor.yy370; + case 257: /* expr ::= ID LP STAR RP */ +{ tRecordFuncName(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy202 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy202 = yylhsminor.yy202; break; - case 256: /* expr ::= expr IS NULL */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, NULL, TK_ISNULL);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 258: /* expr ::= expr IS NULL */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, NULL, TK_ISNULL);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 257: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-3].minor.yy370, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy370 = yylhsminor.yy370; + case 259: /* expr ::= expr IS NOT NULL */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-3].minor.yy202, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy202 = yylhsminor.yy202; break; - case 258: /* expr ::= expr LT expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LT);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 260: /* expr ::= expr LT expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LT);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 259: /* expr ::= expr GT expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GT);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 261: /* expr ::= expr GT expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_GT);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 260: /* expr ::= expr LE expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LE);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 262: /* expr ::= expr LE expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LE);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 261: /* expr ::= expr GE expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_GE);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 263: /* expr ::= expr GE expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_GE);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 262: /* expr ::= expr NE expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NE);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 264: /* expr ::= expr NE expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_NE);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 263: /* expr ::= expr EQ expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_EQ);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 265: /* expr ::= expr EQ expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_EQ);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 264: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy370); yylhsminor.yy370 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy370, yymsp[-2].minor.yy370, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy370, TK_LE), TK_AND);} - yymsp[-4].minor.yy370 = yylhsminor.yy370; + case 266: /* expr ::= expr BETWEEN expr AND expr */ +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy202); yylhsminor.yy202 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy202, yymsp[-2].minor.yy202, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy202, TK_LE), TK_AND);} + yymsp[-4].minor.yy202 = yylhsminor.yy202; break; - case 265: /* expr ::= expr AND expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_AND);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 267: /* expr ::= expr AND expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_AND);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 266: /* expr ::= expr OR expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_OR); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 268: /* expr ::= expr OR expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_OR); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 267: /* expr ::= expr PLUS expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_PLUS); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 269: /* expr ::= expr PLUS expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_PLUS); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 268: /* expr ::= expr MINUS expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MINUS); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 270: /* expr ::= expr MINUS expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_MINUS); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 269: /* expr ::= expr STAR expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_STAR); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 271: /* expr ::= expr STAR expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_STAR); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 270: /* expr ::= expr SLASH expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_DIVIDE);} - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 272: /* expr ::= expr SLASH expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_DIVIDE);} + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 271: /* expr ::= expr REM expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_REM); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 273: /* expr ::= expr REM expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_REM); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 272: /* expr ::= expr LIKE expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_LIKE); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 274: /* expr ::= expr LIKE expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_LIKE); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 273: /* expr ::= expr MATCH expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_MATCH); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 275: /* expr ::= expr MATCH expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_MATCH); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 274: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-2].minor.yy370, yymsp[0].minor.yy370, TK_NMATCH); } - yymsp[-2].minor.yy370 = yylhsminor.yy370; + case 276: /* expr ::= expr NMATCH expr */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-2].minor.yy202, yymsp[0].minor.yy202, TK_NMATCH); } + yymsp[-2].minor.yy202 = yylhsminor.yy202; break; - case 275: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy370 = tSqlExprCreate(yymsp[-4].minor.yy370, (tSqlExpr*)yymsp[-1].minor.yy413, TK_IN); } - yymsp[-4].minor.yy370 = yylhsminor.yy370; + case 277: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy202 = tSqlExprCreate(yymsp[-4].minor.yy202, (tSqlExpr*)yymsp[-1].minor.yy165, TK_IN); } + yymsp[-4].minor.yy202 = yylhsminor.yy202; break; - case 276: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy413 = tSqlExprListAppend(yymsp[-2].minor.yy413,yymsp[0].minor.yy370,0, 0);} - yymsp[-2].minor.yy413 = yylhsminor.yy413; + case 278: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy165 = tSqlExprListAppend(yymsp[-2].minor.yy165,yymsp[0].minor.yy202,0, 0);} + yymsp[-2].minor.yy165 = yylhsminor.yy165; break; - case 277: /* exprlist ::= expritem */ -{yylhsminor.yy413 = tSqlExprListAppend(0,yymsp[0].minor.yy370,0, 0);} - yymsp[0].minor.yy413 = yylhsminor.yy413; + case 279: /* exprlist ::= expritem */ +{yylhsminor.yy165 = tSqlExprListAppend(0,yymsp[0].minor.yy202,0, 0);} + yymsp[0].minor.yy165 = yylhsminor.yy165; break; - case 278: /* expritem ::= expr */ -{yylhsminor.yy370 = yymsp[0].minor.yy370;} - yymsp[0].minor.yy370 = yylhsminor.yy370; + case 280: /* expritem ::= expr */ +{yylhsminor.yy202 = yymsp[0].minor.yy202;} + yymsp[0].minor.yy202 = yylhsminor.yy202; break; - case 280: /* cmd ::= RESET QUERY CACHE */ + case 282: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 281: /* cmd ::= SYNCDB ids REPLICA */ + case 283: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 282: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 284: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 283: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 285: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; toTSDBType(yymsp[0].minor.yy0.type); @@ -3189,21 +3201,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 284: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 286: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 285: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 287: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 286: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 288: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3214,7 +3226,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 287: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 289: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3228,33 +3240,33 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 288: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 290: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy461, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy425, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 289: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 291: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 290: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 292: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 291: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 293: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3265,21 +3277,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 292: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 294: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 293: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 295: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 294: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 296: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3290,7 +3302,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 295: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 297: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3304,32 +3316,32 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 298: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tListItemAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tListItemAppend(A, &yymsp[0].minor.yy461, -1); + A = tListItemAppend(A, &yymsp[0].minor.yy425, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 299: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy413, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy165, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 298: /* cmd ::= KILL CONNECTION INTEGER */ + case 300: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 299: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 301: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 300: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 302: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index d7f410a01e..e8d975c22e 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -45,12 +45,12 @@ int32_t __catalogGetHandle(const char *clusterId, struct SCatalog** catalogHandl return 0; } -int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, STableMeta** pTableMeta) { - return mockCatalogService->catalogGetTableMeta(pDBName, pTableName, pTableMeta); +int32_t __catalogGetTableMeta(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { + return mockCatalogService->catalogGetTableMeta(pTableName, pTableMeta); } -int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo) { - return mockCatalogService->catalogGetTableHashVgroup(pDBName, pTableName, vgInfo); +int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const SName* pTableName, SVgroupInfo* vgInfo) { + return mockCatalogService->catalogGetTableHashVgroup(pTableName, vgInfo); } void initMetaDataEnv() { diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 520ef3a89b..a651e6c1df 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -94,9 +94,14 @@ public: return 0; } - int32_t catalogGetTableMeta(const char* pDbFullName, const char* pTableName, STableMeta** pTableMeta) const { + int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const { std::unique_ptr table; - int32_t code = copyTableSchemaMeta(toDbname(pDbFullName), pTableName, &table); + + char db[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, db); + + const char* tname = tNameGetTableName(pTableName); + int32_t code = copyTableSchemaMeta(db, tname, &table); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -104,7 +109,7 @@ public: return TSDB_CODE_SUCCESS; } - int32_t catalogGetTableHashVgroup(const char* pDbFullName, const char* pTableName, SVgroupInfo* vgInfo) const { + int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const { // todo return 0; } @@ -283,10 +288,10 @@ std::shared_ptr MockCatalogService::getTableMeta(const std::strin return impl_->getTableMeta(db, tbname); } -int32_t MockCatalogService::catalogGetTableMeta(const char* pDBName, const char* pTableName, STableMeta** pTableMeta) const { - return impl_->catalogGetTableMeta(pDBName, pTableName, pTableMeta); +int32_t MockCatalogService::catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const { + return impl_->catalogGetTableMeta(pTableName, pTableMeta); } -int32_t MockCatalogService::catalogGetTableHashVgroup(const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo) const { - return impl_->catalogGetTableHashVgroup(pDBName, pTableName, vgInfo); +int32_t MockCatalogService::catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const { + return impl_->catalogGetTableHashVgroup(pTableName, vgInfo); } \ No newline at end of file diff --git a/source/libs/parser/test/mockCatalogService.h b/source/libs/parser/test/mockCatalogService.h index 889a454397..b971331635 100644 --- a/source/libs/parser/test/mockCatalogService.h +++ b/source/libs/parser/test/mockCatalogService.h @@ -57,8 +57,8 @@ public: void showTables() const; std::shared_ptr getTableMeta(const std::string& db, const std::string& tbname) const; - int32_t catalogGetTableMeta(const char* pDBName, const char* pTableName, STableMeta** pTableMeta) const; - int32_t catalogGetTableHashVgroup(const char* pDBName, const char* pTableName, SVgroupInfo* vgInfo) const; + int32_t catalogGetTableMeta(const SName* pTableName, STableMeta** pTableMeta) const; + int32_t catalogGetTableHashVgroup(const SName* pTableName, SVgroupInfo* vgInfo) const; private: std::unique_ptr impl_; From c9f8a1109f46ebc5e186e9168d936becfef54217 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 28 Dec 2021 23:10:50 -0800 Subject: [PATCH 51/55] fix show dnodes error --- source/dnode/mnode/impl/inc/mndDef.h | 5 ----- source/dnode/mnode/impl/inc/mndInt.h | 1 + source/dnode/mnode/impl/inc/mndVgroup.h | 1 + source/dnode/mnode/impl/src/mndDnode.c | 5 ++--- source/dnode/mnode/impl/src/mndVgroup.c | 3 ++- tests/script/general/db/basic1.sim | 22 ++++++++++++++++++++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index ea0fe46302..ac9fe35f53 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -124,12 +124,7 @@ typedef struct { int64_t rebootTime; int64_t lastAccessTime; int32_t accessTimes; - int16_t numOfMnodes; - int16_t numOfVnodes; - int16_t numOfQnodes; - int16_t numOfSupportMnodes; int16_t numOfSupportVnodes; - int16_t numOfSupportQnodes; int16_t numOfCores; EDndStatus status; EDndReason offlineReason; diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 6eb82daa11..daa87af1f5 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -19,6 +19,7 @@ #include "mndDef.h" #include "sdb.h" #include "tcache.h" +#include "tep.h" #include "tqueue.h" #include "ttime.h" diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index 8a3a2c798a..6d391450b7 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -29,6 +29,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup); SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup); int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups); SEpSet mndGetVgroupEpset(SMnode *pMnode, SVgObj *pVgroup); +int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId); SCreateVnodeMsg *mndBuildCreateVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup); SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 91d2a084af..43b458a52a 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -18,8 +18,7 @@ #include "mndMnode.h" #include "mndShow.h" #include "mndTrans.h" -#include "tep.h" -#include "ttime.h" +#include "mndVgroup.h" #define TSDB_DNODE_VER_NUMBER 1 #define TSDB_DNODE_RESERVE_SIZE 64 @@ -699,7 +698,7 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int16_t *)pWrite = pDnode->numOfVnodes; + *(int16_t *)pWrite = mndGetVnodesNum(pMnode, pDnode->id); cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index b12d2c4718..98382232ef 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -348,6 +348,7 @@ static int32_t mndProcessDropVnodeRsp(SMnodeMsg *pMsg) { } static int32_t mndProcessSyncVnodeRsp(SMnodeMsg *pMsg) { return 0; } + static int32_t mndProcessCompactVnodeRsp(SMnodeMsg *pMsg) { return 0; } static int32_t mndGetVgroupMaxReplica(SMnode *pMnode, char *dbName, int8_t *pReplica, int32_t *pNumOfVgroups) { @@ -478,7 +479,7 @@ static void mndCancelGetNextVgroup(SMnode *pMnode, void *pIter) { sdbCancelFetch(pSdb, pIter); } -static int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId) { +int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId) { SSdb *pSdb = pMnode->pSdb; int32_t numOfVnodes = 0; void *pIter = NULL; diff --git a/tests/script/general/db/basic1.sim b/tests/script/general/db/basic1.sim index 618b1377b8..05ecbbf5ac 100644 --- a/tests/script/general/db/basic1.sim +++ b/tests/script/general/db/basic1.sim @@ -59,9 +59,27 @@ if $data03 != 0 then endi print =============== show vgroups -sql use d4 +sql show databases -if $rows == 0 then +if $rows == 1 then + return -1 +endi + +sql use d1 +sql show vgroups + +if $rows != 2 then + return -1 +endi + +print =============== show dnodes +sql show dnodes + +if $data00 != 1 then + return -1 +endi + +if $data02 != 2 then return -1 endi From 3b7bb57752d592a0bc5d83af6c9c81ad334f2ee9 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 29 Dec 2021 15:16:52 +0800 Subject: [PATCH 52/55] [td-11818] add test sim. --- source/client/test/clientTests.cpp | 24 +++++++++--------- source/libs/catalog/src/catalog.c | 39 ++---------------------------- 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 1c38b74fa3..be001780ca 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -433,15 +433,15 @@ TEST(testCase, drop_stable_Test) { // taos_close(pConn); //} -//TEST(testCase, show_table_Test) { -// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); -// assert(pConn != NULL); -// -// TAOS_RES* pRes = taos_query(pConn, "use abc1"); -// taos_free_result(pRes); -// -// pRes = taos_query(pConn, "show tables"); -// taos_free_result(pRes); -// -// taos_close(pConn); -//} +TEST(testCase, show_table_Test) { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + assert(pConn != NULL); + + TAOS_RES* pRes = taos_query(pConn, "use abc1"); + taos_free_result(pRes); + + pRes = taos_query(pConn, "show tables"); + taos_free_result(pRes); + + taos_close(pConn); +} diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 5820c82028..46d23efeb4 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -532,41 +532,6 @@ int32_t catalogUpdateDBVgroup(struct SCatalog* pCatalog, const char* dbName, SDB return TSDB_CODE_SUCCESS; } - - - -int32_t catalogGetDBVgroup(struct SCatalog* pCatalog, void *pRpc, const SEpSet* pMgmtEps, const char* dbName, int32_t forceUpdate, SDBVgroupInfo* dbInfo) { - if (NULL == pCatalog || NULL == dbName || NULL == pRpc || NULL == pMgmtEps) { - CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); - } - - int32_t exist = 0; - - if (0 == forceUpdate) { - CTG_ERR_RET(ctgGetDBVgroupFromCache(pCatalog, dbName, dbInfo, &exist)); - - if (exist) { - return TSDB_CODE_SUCCESS; - } - } - - SUseDbOutput DbOut = {0}; - SBuildUseDBInput input = {0}; - - strncpy(input.db, dbName, sizeof(input.db)); - input.db[sizeof(input.db) - 1] = 0; - input.vgVersion = CTG_DEFAULT_INVALID_VERSION; - - CTG_ERR_RET(ctgGetDBVgroupFromMnode(pCatalog, pRpc, pMgmtEps, &input, &DbOut)); -// CTG_ERR_RET(catalogUpdateDBVgroupCache(pCatalog, dbName, &DbOut.dbVgroup)); - - if (dbInfo) { - *dbInfo = DbOut.dbVgroup; - } - - return TSDB_CODE_SUCCESS; -} - int32_t catalogGetTableMeta(struct SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const SName* pTableName, STableMeta** pTableMeta) { return ctgGetTableMetaImpl(pCatalog, pTransporter, pMgmtEps, pTableName, false, pTableMeta); } @@ -614,7 +579,7 @@ int32_t catalogGetTableDistVgroup(struct SCatalog* pCatalog, void *pRpc, const S char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); - CTG_ERR_JRET(catalogGetDBVgroup(pCatalog, pRpc, pMgmtEps, db, false, &dbVgroup)); + CTG_ERR_JRET(ctgGetDBVgroup(pCatalog, pRpc, pMgmtEps, db, false, &dbVgroup)); if (tbMeta->tableType == TSDB_SUPER_TABLE) { CTG_ERR_JRET(ctgGetVgInfoFromDB(pCatalog, pRpc, pMgmtEps, &dbVgroup, pVgroupList)); @@ -654,7 +619,7 @@ int32_t catalogGetTableHashVgroup(struct SCatalog *pCatalog, void *pTransporter, char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); - CTG_ERR_RET(catalogGetDBVgroup(pCatalog, pTransporter, pMgmtEps, db, false, &dbInfo)); + CTG_ERR_RET(ctgGetDBVgroup(pCatalog, pTransporter, pMgmtEps, db, false, &dbInfo)); if (dbInfo.vgVersion < 0 || NULL == dbInfo.vgInfo) { ctgError("db[%s] vgroup cache invalid, vgroup version:%d, vgInfo:%p", db, dbInfo.vgVersion, dbInfo.vgInfo); From 1450652187aa5567e5d9397a76516482f7b071ac Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 29 Dec 2021 07:47:45 +0000 Subject: [PATCH 53/55] add table meta msg --- include/common/tmsg.h | 25 +++++++++++++++++++++++++ include/common/tmsgdef.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 416402a028..b386b729d4 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1240,6 +1240,31 @@ static FORCE_INLINE void* tDeserializeSVCreateTbReq(void* buf, SVCreateTbReq* pR typedef struct SVCreateTbRsp { } SVCreateTbRsp; +typedef struct SVShowTablesReq { + SMsgHead head; +} SVShowTablesReq; + +typedef struct SVShowTablesRsp { + int64_t id; + STableMetaMsg metaInfo; +} SVShowTablesRsp; + +typedef struct SVShowTablesFetchReq { + SMsgHead head; + int64_t id; +} SVShowTablesFetchReq; + +typedef struct SVShowTablesFetchRsp { + int64_t useconds; + int8_t completed; // all results are returned to client + int8_t precision; + int8_t compressed; + int32_t compLen; + + int32_t numOfRows; + char data[]; +} SVShowTablesFetchRsp; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 9aa4325d58..2ed817fca1 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -146,6 +146,8 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_CREATE_TOPIC, "vnode-create-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_TOPIC, "vnode-alter-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TOPIC, "vnode-drop-topic", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_SHOW_TABLES, "vnode-show-tables", SVShowTablesReq, SVShowTablesRsp) + TD_DEF_MSG_TYPE(TDMT_VND_SHOW_TABLES_FETCH, "vnode-show-tables-fetch", SVShowTablesFetchReq, SVShowTablesFetchRsp) // Requests handled by QNODE TD_NEW_MSG_SEG(TDMT_QND_MSG) From a881adcfe46c09f7635d1fb2bc4fece99666be1f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Dec 2021 00:26:16 -0800 Subject: [PATCH 54/55] alloc vgroups --- source/dnode/mgmt/daemon/src/daemon.c | 2 +- source/dnode/mnode/impl/inc/mndDef.h | 1 + source/dnode/mnode/impl/src/mndTrans.c | 4 +- source/dnode/mnode/impl/src/mndVgroup.c | 105 ++++++++++++++++++------ 4 files changed, 84 insertions(+), 28 deletions(-) diff --git a/source/dnode/mgmt/daemon/src/daemon.c b/source/dnode/mgmt/daemon/src/daemon.c index 6c4fae406e..70dca0e4df 100644 --- a/source/dnode/mgmt/daemon/src/daemon.c +++ b/source/dnode/mgmt/daemon/src/daemon.c @@ -139,7 +139,7 @@ void dmnWaitSignal() { void dmnInitOption(SDnodeOpt *pOption) { pOption->sver = 30000000; //3.0.0.0 pOption->numOfCores = tsNumOfCores; - pOption->numOfSupportVnodes = 1; + pOption->numOfSupportVnodes = 16; pOption->numOfCommitThreads = 1; pOption->statusInterval = tsStatusInterval; pOption->numOfThreadsPerCore = tsNumOfThreadsPerCore; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index ac9fe35f53..1a1306c3da 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -124,6 +124,7 @@ typedef struct { int64_t rebootTime; int64_t lastAccessTime; int32_t accessTimes; + int16_t numOfVnodes; int16_t numOfSupportVnodes; int16_t numOfCores; EDndStatus status; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index dd69a34dcc..9263fca695 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -442,7 +442,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { } sdbSetRawStatus(pRaw, SDB_STATUS_READY); - mTrace("trans:%d, sync to other nodes", pTrans->id); + mDebug("trans:%d, sync to other nodes", pTrans->id); int32_t code = mndSyncPropose(pMnode, pRaw); if (code != 0) { mError("trans:%d, failed to sync since %s", pTrans->id, terrstr()); @@ -450,7 +450,7 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) { return -1; } - mTrace("trans:%d, sync finished", pTrans->id); + mDebug("trans:%d, sync finished", pTrans->id); code = sdbWrite(pMnode->pSdb, pRaw); if (code != 0) { diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 98382232ef..06e62d2528 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -86,7 +86,6 @@ SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup) { for (int8_t i = 0; i < pVgroup->replica; ++i) { SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; SDB_SET_INT32(pRaw, dataPos, pVgid->dnodeId) - SDB_SET_INT8(pRaw, dataPos, pVgid->role) } SDB_SET_RESERVE(pRaw, dataPos, TSDB_VGROUP_RESERVE_SIZE) SDB_SET_DATALEN(pRaw, dataPos); @@ -121,7 +120,6 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { for (int8_t i = 0; i < pVgroup->replica; ++i) { SVnodeGid *pVgid = &pVgroup->vnodeGid[i]; SDB_GET_INT32(pRaw, pRow, dataPos, &pVgid->dnodeId) - SDB_GET_INT8(pRaw, pRow, dataPos, (int8_t *)&pVgid->role) } SDB_GET_RESERVE(pRaw, pRow, dataPos, TSDB_VGROUP_RESERVE_SIZE) @@ -237,44 +235,95 @@ SDropVnodeMsg *mndBuildDropVnodeMsg(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *p return pDrop; } -static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup) { +static SArray *mndBuildDnodesArray(SMnode *pMnode) { SSdb *pSdb = pMnode->pSdb; - int32_t allocedVnodes = 0; - void *pIter = NULL; + int32_t numOfDnodes = mndGetDnodeSize(pMnode); + SArray *pArray = taosArrayInit(numOfDnodes, sizeof(SDnodeObj)); + if (pArray == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } - while (allocedVnodes < pVgroup->replica) { + void *pIter = NULL; + while (1) { SDnodeObj *pDnode = NULL; pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode); if (pIter == NULL) break; - // todo - if (mndIsDnodeInReadyStatus(pMnode, pDnode)) { - SVnodeGid *pVgid = &pVgroup->vnodeGid[allocedVnodes]; - pVgid->dnodeId = pDnode->id; - if (pVgroup->replica == 1) { - pVgid->role = TAOS_SYNC_STATE_LEADER; - } else { - pVgid->role = TAOS_SYNC_STATE_FOLLOWER; - } - allocedVnodes++; + int32_t numOfVnodes = mndGetVnodesNum(pMnode, pDnode->id); + + bool isMnode = mndIsMnode(pMnode, pDnode->id); + if (isMnode) { + pDnode->numOfVnodes++; } + + bool isReady = mndIsDnodeInReadyStatus(pMnode, pDnode); + if (isReady) { + taosArrayPush(pArray, pDnode); + } + + mDebug("dnode:%d, numOfVnodes:%d numOfSupportVnodes:%d isMnode:%d ready:%d", pDnode->id, numOfVnodes, + pDnode->numOfSupportVnodes, isMnode, isReady); sdbRelease(pSdb, pDnode); } - if (allocedVnodes != pVgroup->replica) { - terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; - return -1; + return pArray; +} + +static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) { + float d1Score = (float)pDnode1->numOfVnodes / pDnode1->numOfSupportVnodes; + float d2Score = (float)pDnode2->numOfVnodes / pDnode2->numOfSupportVnodes; + return d1Score > d2Score ? 0 : 1; +} + +static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pArray) { + SSdb *pSdb = pMnode->pSdb; + int32_t allocedVnodes = 0; + void *pIter = NULL; + + taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes); + + for (int32_t v = 0; v < pVgroup->replica; ++v) { + SVnodeGid *pVgid = &pVgroup->vnodeGid[v]; + SDnodeObj *pDnode = taosArrayGet(pArray, v); + if (pDnode == NULL || pDnode->numOfVnodes > pDnode->numOfSupportVnodes) { + terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; + return -1; + } + + pVgid->dnodeId = pDnode->id; + if (pVgroup->replica == 1) { + pVgid->role = TAOS_SYNC_STATE_LEADER; + } else { + pVgid->role = TAOS_SYNC_STATE_FOLLOWER; + } + + mDebug("db:%s, vgId:%d, vindex:%d dnodeId:%d is alloced", pVgroup->dbName, pVgroup->vgId, v, pVgid->dnodeId); + pDnode->numOfVnodes++; } + return 0; } int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { - SVgObj *pVgroups = calloc(pDb->cfg.numOfVgroups, sizeof(SVgObj)); + int32_t code = -1; + SArray *pArray = NULL; + SVgObj *pVgroups = NULL; + + pVgroups = calloc(pDb->cfg.numOfVgroups, sizeof(SVgObj)); if (pVgroups == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + goto ALLOC_VGROUP_OVER; } + pArray = mndBuildDnodesArray(pMnode); + if (pArray == NULL) { + goto ALLOC_VGROUP_OVER; + } + + mDebug("db:%s, total %d dnodes used to create %d vgroups (%d vnodes)", pDb->name, (int32_t)taosArrayGetSize(pArray), + pDb->cfg.numOfVgroups, pDb->cfg.numOfVgroups * pDb->cfg.replications); + int32_t allocedVgroups = 0; int32_t maxVgId = sdbGetMaxId(pMnode->pSdb, SDB_VGROUP); uint32_t hashMin = 0; @@ -298,17 +347,23 @@ int32_t mndAllocVgroup(SMnode *pMnode, SDbObj *pDb, SVgObj **ppVgroups) { pVgroup->dbUid = pDb->uid; pVgroup->replica = pDb->cfg.replications; - if (mndGetAvailableDnode(pMnode, pVgroup) != 0) { + if (mndGetAvailableDnode(pMnode, pVgroup, pArray) != 0) { terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; - free(pVgroups); - return -1; + goto ALLOC_VGROUP_OVER; } allocedVgroups++; } *ppVgroups = pVgroups; - return 0; + code = 0; + + mDebug("db:%s, %d vgroups is alloced, replica:%d", pDb->name, pDb->cfg.numOfVgroups, pDb->cfg.replications); + +ALLOC_VGROUP_OVER: + if (code != 0) free(pVgroups); + taosArrayDestroy(pArray); + return code; } SEpSet mndGetVgroupEpset(SMnode *pMnode, SVgObj *pVgroup) { From 6b020750c23624bbd60b06f31216ec6ebea36fb6 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Dec 2021 00:40:27 -0800 Subject: [PATCH 55/55] fix crash while use db which is not exist --- source/client/src/clientMsgHandler.c | 15 +++++++++++---- tests/script/general/db/basic1.sim | 6 ++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index e2fdf96385..f7cf661019 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -188,14 +188,21 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { } int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { - SUseDbRsp* pUseDbRsp = (SUseDbRsp*) pMsg->pData; - SName name = {0}; - tNameFromString(&name, pUseDbRsp->db, T_NAME_ACCT|T_NAME_DB); + SRequestObj* pRequest = param; + + if (code != TSDB_CODE_SUCCESS) { + pRequest->code = code; + tsem_post(&pRequest->body.rspSem); + return code; + } + + SUseDbRsp* pUseDbRsp = (SUseDbRsp*)pMsg->pData; + SName name = {0}; + tNameFromString(&name, pUseDbRsp->db, T_NAME_ACCT | T_NAME_DB); char db[TSDB_DB_NAME_LEN] = {0}; tNameGetDbName(&name, db); - SRequestObj* pRequest = param; setConnectionDB(pRequest->pTscObj, db); tsem_post(&pRequest->body.rspSem); diff --git a/tests/script/general/db/basic1.sim b/tests/script/general/db/basic1.sim index 05ecbbf5ac..44d53917f2 100644 --- a/tests/script/general/db/basic1.sim +++ b/tests/script/general/db/basic1.sim @@ -61,11 +61,13 @@ endi print =============== show vgroups sql show databases -if $rows == 1 then +if $rows != 1 then return -1 endi -sql use d1 +sql_error use d1 + +sql use d4 sql show vgroups if $rows != 2 then