From bc2c2c07a174630a6d5a70cf3c7c740800a21e15 Mon Sep 17 00:00:00 2001 From: xywang Date: Tue, 1 Jun 2021 11:54:22 +0000 Subject: [PATCH 01/65] [TD-2574]: refactored algorithms for top and bottom functions. --- src/query/src/qAggMain.c | 201 +++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 94 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 4935633b9c..a7106a14a9 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2201,6 +2201,101 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 memcpy((dst)->pTags, (src)->pTags, (size_t)(__l)); \ } while (0) +static void heapSwap(tValuePair *a, tValuePair *b, const int16_t tagLen) { + char tag[32768]; + tValuePair temp; + + memset(tag, 0, sizeof(tag)); + temp.pTags = tag; + + VALUEPAIRASSIGN(&temp, a, tagLen); + VALUEPAIRASSIGN(a, b, tagLen); + VALUEPAIRASSIGN(b, &temp, tagLen); +} + +static void heapAdjust(tValuePair **pList, uint16_t type, int16_t tagLen, int32_t start, int32_t end, bool minRoot) { + int32_t parent = start; + int32_t child = 2 * parent + 1; + + while (child <= end) { + if (IS_SIGNED_NUMERIC_TYPE(type)) { + if (minRoot) { + if (child + 1 <= end && pList[child]->v.i64 < pList[child + 1]->v.i64) { + child++; + } + + if (pList[parent]->v.i64 > pList[child]->v.i64) { + break; + } + } else { + if (child + 1 <= end && pList[child]->v.i64 >= pList[child + 1]->v.i64) { + child++; + } + + if (pList[parent]->v.i64 <= pList[child]->v.i64) { + break; + } + } + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + if (minRoot) { + if (child + 1 <= end && pList[child]->v.u64 < pList[child + 1]->v.u64) { + child++; + } + + if (pList[parent]->v.u64 > pList[child]->v.u64) { + break; + } + } else { + if (child + 1 <= end && pList[child]->v.u64 >= pList[child + 1]->v.u64) { + child++; + } + + if (pList[parent]->v.u64 <= pList[child]->v.u64) { + break; + } + } + } else { + if (minRoot) { + if (child + 1 <= end && pList[child]->v.dKey < pList[child + 1]->v.dKey) { + child++; + } + + if (pList[parent]->v.dKey > pList[child]->v.dKey) { + break; + } + } else { + if (child + 1 <= end && pList[child]->v.dKey >= pList[child + 1]->v.dKey) { + child++; + } + + if (pList[parent]->v.dKey <= pList[child]->v.dKey) { + break; + } + } + } + + heapSwap(pList[parent], pList[child], tagLen); + + parent = child; + child = parent * 2 + 1; + } +} + +void heapSort(tValuePair **pList, uint16_t type, int16_t tagLen, int32_t len, bool minRoot) { + int32_t i; + + for (i = len / 2 - 1; i >= 0; i--) { + heapAdjust(pList, type, i, tagLen, len - 1, minRoot); + } + +/* + for (i = len - 1; i > 0; i--) { + heapSwap(pList[0], pList[i], tagsLen); + heapAdjust(pList, type, tagsLen, i - 1, minRoot); + } +*/ +} + static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, int64_t ts, uint16_t type, SExtTagsInfo *pTagInfo, char *pTags, int16_t stage) { tVariant val = {0}; @@ -2210,59 +2305,17 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, assert(pList != NULL); if (pInfo->num < maxLen) { - if (pInfo->num == 0 || - (IS_SIGNED_NUMERIC_TYPE(type) && val.i64 >= pList[pInfo->num - 1]->v.i64) || - (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 >= pList[pInfo->num - 1]->v.u64) || - (IS_FLOAT_TYPE(type) && val.dKey >= pList[pInfo->num - 1]->v.dKey)) { - valuePairAssign(pList[pInfo->num], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); - } else { - int32_t i = pInfo->num - 1; - if (IS_SIGNED_NUMERIC_TYPE(type)) { - while (i >= 0 && pList[i]->v.i64 > val.i64) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - while (i >= 0 && pList[i]->v.u64 > val.u64) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } else { - while (i >= 0 && pList[i]->v.dKey > val.dKey) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } - - valuePairAssign(pList[i + 1], type, (const char*) &val.i64, ts, pTags, pTagInfo, stage); - } - + valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); + + heapSort(pList, type, pTagInfo->tagsLen, pInfo->num + 1, 0); + pInfo->num++; } else { - int32_t i = 0; - if ((IS_SIGNED_NUMERIC_TYPE(type) && val.i64 > pList[0]->v.i64) || (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 > pList[0]->v.u64) || (IS_FLOAT_TYPE(type) && val.dKey > pList[0]->v.dKey)) { - // find the appropriate the slot position - if (IS_SIGNED_NUMERIC_TYPE(type)) { - while (i + 1 < maxLen && pList[i + 1]->v.i64 < val.i64) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - while (i + 1 < maxLen && pList[i + 1]->v.u64 < val.u64) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } else { - while (i + 1 < maxLen && pList[i + 1]->v.dKey < val.dKey) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } - - valuePairAssign(pList[i], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); + heapAdjust(pList, type, pTagInfo->tagsLen, 0, maxLen - 1, 0); } } } @@ -2276,57 +2329,17 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa assert(pList != NULL); if (pInfo->num < maxLen) { - if (pInfo->num == 0) { - valuePairAssign(pList[pInfo->num], type, (const char*) &val.i64, ts, pTags, pTagInfo, stage); - } else { - int32_t i = pInfo->num - 1; - - if (IS_SIGNED_NUMERIC_TYPE(type)) { - while (i >= 0 && pList[i]->v.i64 < val.i64) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - while (i >= 0 && pList[i]->v.u64 < val.u64) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } else { - while (i >= 0 && pList[i]->v.dKey < val.dKey) { - VALUEPAIRASSIGN(pList[i + 1], pList[i], pTagInfo->tagsLen); - i -= 1; - } - } - - valuePairAssign(pList[i + 1], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); - } - + valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); + + heapSort(pList, type, pTagInfo->tagsLen, pInfo->num + 1, 1); + pInfo->num++; } else { - int32_t i = 0; - if ((IS_SIGNED_NUMERIC_TYPE(type) && val.i64 < pList[0]->v.i64) || (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 < pList[0]->v.u64) || (IS_FLOAT_TYPE(type) && val.dKey < pList[0]->v.dKey)) { - // find the appropriate the slot position - if (IS_SIGNED_NUMERIC_TYPE(type)) { - while (i + 1 < maxLen && pList[i + 1]->v.i64 > val.i64) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - while (i + 1 < maxLen && pList[i + 1]->v.u64 > val.u64) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } else { - while (i + 1 < maxLen && pList[i + 1]->v.dKey > val.dKey) { - VALUEPAIRASSIGN(pList[i], pList[i + 1], pTagInfo->tagsLen); - i += 1; - } - } - - valuePairAssign(pList[i], type, (const char*)&val.i64, ts, pTags, pTagInfo, stage); + valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); + heapAdjust(pList, type, pTagInfo->tagsLen, 0, maxLen - 1, 1); } } } From 0ef76e0c1dba1203297e1b70c11922c5ebc27f9a Mon Sep 17 00:00:00 2001 From: xywang Date: Wed, 2 Jun 2021 05:50:11 +0000 Subject: [PATCH 02/65] [TD-2574]: fixed a bug in heapSort. --- src/query/src/qAggMain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index a7106a14a9..b0329c845d 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2285,13 +2285,13 @@ void heapSort(tValuePair **pList, uint16_t type, int16_t tagLen, int32_t len, bo int32_t i; for (i = len / 2 - 1; i >= 0; i--) { - heapAdjust(pList, type, i, tagLen, len - 1, minRoot); + heapAdjust(pList, type, tagLen, i, len - 1, minRoot); } /* for (i = len - 1; i > 0; i--) { heapSwap(pList[0], pList[i], tagsLen); - heapAdjust(pList, type, tagsLen, i - 1, minRoot); + heapAdjust(pList, type, 0, tagsLen, i - 1, minRoot); } */ } From e7753404758bf8c9a3896d4936ae4b0aab54a21e Mon Sep 17 00:00:00 2001 From: xywang Date: Sat, 19 Jun 2021 16:25:04 +0800 Subject: [PATCH 03/65] [TD-2574]: added general heapsort algorithm --- src/query/src/qAggMain.c | 124 ++++++++++----------------------------- src/util/inc/talgo.h | 33 +++++++++++ src/util/src/talgo.c | 86 +++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 94 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index b0329c845d..2c7242b26a 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2201,99 +2201,35 @@ static void valuePairAssign(tValuePair *dst, int16_t type, const char *val, int6 memcpy((dst)->pTags, (src)->pTags, (size_t)(__l)); \ } while (0) -static void heapSwap(tValuePair *a, tValuePair *b, const int16_t tagLen) { - char tag[32768]; - tValuePair temp; +static int32_t topBotComparFn(const void *p1, const void *p2, const void *param) +{ + uint16_t type = *(uint16_t *) param; + tValuePair *val1 = *(tValuePair **) p1; + tValuePair *val2 = *(tValuePair **) p2; + + if (IS_SIGNED_NUMERIC_TYPE(type)) { + return val1->v.i64 - val2->v.i64; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + return val1->v.u64 - val2->v.u64; + } + + return val1->v.dKey - val2->v.dKey; +} + +static void topBotSwapFn(void *dst, void *src, const void *param) +{ + char tag[32768]; + tValuePair temp; + uint16_t tagLen = *(uint16_t *) param; + tValuePair *vdst = *(tValuePair **) dst; + tValuePair *vsrc = *(tValuePair **) src; memset(tag, 0, sizeof(tag)); temp.pTags = tag; - VALUEPAIRASSIGN(&temp, a, tagLen); - VALUEPAIRASSIGN(a, b, tagLen); - VALUEPAIRASSIGN(b, &temp, tagLen); -} - -static void heapAdjust(tValuePair **pList, uint16_t type, int16_t tagLen, int32_t start, int32_t end, bool minRoot) { - int32_t parent = start; - int32_t child = 2 * parent + 1; - - while (child <= end) { - if (IS_SIGNED_NUMERIC_TYPE(type)) { - if (minRoot) { - if (child + 1 <= end && pList[child]->v.i64 < pList[child + 1]->v.i64) { - child++; - } - - if (pList[parent]->v.i64 > pList[child]->v.i64) { - break; - } - } else { - if (child + 1 <= end && pList[child]->v.i64 >= pList[child + 1]->v.i64) { - child++; - } - - if (pList[parent]->v.i64 <= pList[child]->v.i64) { - break; - } - } - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - if (minRoot) { - if (child + 1 <= end && pList[child]->v.u64 < pList[child + 1]->v.u64) { - child++; - } - - if (pList[parent]->v.u64 > pList[child]->v.u64) { - break; - } - } else { - if (child + 1 <= end && pList[child]->v.u64 >= pList[child + 1]->v.u64) { - child++; - } - - if (pList[parent]->v.u64 <= pList[child]->v.u64) { - break; - } - } - } else { - if (minRoot) { - if (child + 1 <= end && pList[child]->v.dKey < pList[child + 1]->v.dKey) { - child++; - } - - if (pList[parent]->v.dKey > pList[child]->v.dKey) { - break; - } - } else { - if (child + 1 <= end && pList[child]->v.dKey >= pList[child + 1]->v.dKey) { - child++; - } - - if (pList[parent]->v.dKey <= pList[child]->v.dKey) { - break; - } - } - } - - heapSwap(pList[parent], pList[child], tagLen); - - parent = child; - child = parent * 2 + 1; - } -} - -void heapSort(tValuePair **pList, uint16_t type, int16_t tagLen, int32_t len, bool minRoot) { - int32_t i; - - for (i = len / 2 - 1; i >= 0; i--) { - heapAdjust(pList, type, tagLen, i, len - 1, minRoot); - } - -/* - for (i = len - 1; i > 0; i--) { - heapSwap(pList[0], pList[i], tagsLen); - heapAdjust(pList, type, 0, tagsLen, i - 1, minRoot); - } -*/ + VALUEPAIRASSIGN(&temp, vdst, tagLen); + VALUEPAIRASSIGN(vdst, vsrc, tagLen); + VALUEPAIRASSIGN(vsrc, &temp, tagLen); } static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, int64_t ts, uint16_t type, @@ -2303,11 +2239,11 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, tValuePair **pList = pInfo->res; assert(pList != NULL); - + if (pInfo->num < maxLen) { valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); - heapSort(pList, type, pTagInfo->tagsLen, pInfo->num + 1, 0); + taosheapsort((void *) pList, sizeof(tValuePair **), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0); pInfo->num++; } else { @@ -2315,7 +2251,7 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData, (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 > pList[0]->v.u64) || (IS_FLOAT_TYPE(type) && val.dKey > pList[0]->v.dKey)) { valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); - heapAdjust(pList, type, pTagInfo->tagsLen, 0, maxLen - 1, 0); + taosheapadjust((void *) pList, sizeof(tValuePair **), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0); } } } @@ -2331,7 +2267,7 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa if (pInfo->num < maxLen) { valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); - heapSort(pList, type, pTagInfo->tagsLen, pInfo->num + 1, 1); + taosheapsort((void *) pList, sizeof(tValuePair **), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1); pInfo->num++; } else { @@ -2339,7 +2275,7 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa (IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 < pList[0]->v.u64) || (IS_FLOAT_TYPE(type) && val.dKey < pList[0]->v.dKey)) { valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage); - heapAdjust(pList, type, pTagInfo->tagsLen, 0, maxLen - 1, 1); + taosheapadjust((void *) pList, sizeof(tValuePair **), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1); } } } diff --git a/src/util/inc/talgo.h b/src/util/inc/talgo.h index 9e3692225b..4aa5430605 100644 --- a/src/util/inc/talgo.h +++ b/src/util/inc/talgo.h @@ -34,6 +34,7 @@ typedef int (*__compar_fn_t) (const void *, const void *); #define elePtrAt(base, size, idx) (void *)((char *)(base) + (size) * (idx)) typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void *param); +typedef void (*__ext_swap_fn_t)(void *p1, void *p2, const void *param); /** * quick sort, with the compare function requiring additional parameters support @@ -59,6 +60,38 @@ void taosqsort(void *src, size_t numOfElem, size_t size, const void* param, __ex */ void *taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, __compar_fn_t fn, int flags); +/** + * adjust heap + * + * @param base: the start address of array + * @param size: size of every item in array + * @param start: the first index + * @param end: the last index + * @param parcompar: parameters for compare function + * @param compar: user defined compare function + * @param parswap: parameters for swap function + * @param swap: user defined swap function, the default swap function doswap will be used if swap is NULL + * @param maxroot: if heap is max root heap + * @return + */ +void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const void *parcompar, __ext_compar_fn_t compar, const void *parswap, __ext_swap_fn_t swap, bool maxroot); + +/** + * sort heap to make sure it is a max/min root heap + * + * @param base: the start address of array + * @param size: size of every item in array + * @param len: the length of array + * @param parcompar: parameters for compare function + * @param compar: user defined compare function + * @param parswap: parameters for swap function + * @param swap: user defined swap function, the default swap function doswap will be used if swap is NULL + * @param maxroot: if heap is max root heap + * @return + */ +void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, __ext_compar_fn_t compar, const void *parswap, __ext_swap_fn_t swap, bool maxroot); + + #ifdef __cplusplus } #endif diff --git a/src/util/src/talgo.c b/src/util/src/talgo.c index 278683539e..54b7e00eb7 100644 --- a/src/util/src/talgo.c +++ b/src/util/src/talgo.c @@ -225,3 +225,89 @@ void * taosbsearch(const void *key, const void *base, size_t nmemb, size_t size, return NULL; } + +void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const void *parcompar, __ext_compar_fn_t compar, const void *parswap, __ext_swap_fn_t swap, bool maxroot) +{ + int32_t parent; + int32_t child; + char *buf; + + if (base && size > 0 && compar) { + parent = start; + child = 2 * parent + 1; + + if (swap == NULL) { + buf = calloc(1, size); + if (buf == NULL) { + return; + } + } + + if (maxroot) { + while (child <= end) { + if (child + 1 <= end && (*compar)(elePtrAt(base, size, child), elePtrAt(base, size, child + 1), parcompar) < 0) { + child++; + } + + if ((*compar)(elePtrAt(base, size, parent), elePtrAt(base, size, child), parcompar) > 0) { + break; + } + + if (swap == NULL) { + doswap(elePtrAt(base, size, parent), elePtrAt(base, size, child), size, buf); + } else { + (*swap)(elePtrAt(base, size, parent), elePtrAt(base, size, child), parswap); + } + + parent = child; + child = 2 * parent + 1; + } + } else { + while (child <= end) { + if (child + 1 <= end && (*compar)(elePtrAt(base, size, child), elePtrAt(base, size, child + 1), parcompar) > 0) { + child++; + } + + if ((*compar)(elePtrAt(base, size, parent), elePtrAt(base, size, child), parcompar) < 0) { + break; + } + + if (swap == NULL) { + doswap(elePtrAt(base, size, parent), elePtrAt(base, size, child), size, buf); + } else { + (*swap)(elePtrAt(base, size, parent), elePtrAt(base, size, child), parswap); + } + + parent = child; + child = 2 * parent + 1; + } + } + + if (swap == NULL) { + tfree(buf); + } + } +} + +void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, __ext_compar_fn_t compar, const void *parswap, __ext_swap_fn_t swap, bool maxroot) +{ + int32_t i; + + if (base && size > 0) { + for (i = len / 2 - 1; i >= 0; i--) { + taosheapadjust(base, size, i, len - 1, parcompar, compar, parswap, swap, maxroot); + } + } + +/* + char *buf = calloc(1, size); + + for (i = len - 1; i > 0; i--) { + doswap(elePtrAt(base, size, 0), elePtrAt(base, size, i)); + taosheapadjust(base, size, 0, i - 1, parcompar, compar, parswap, swap, maxroot); + } + + tfree(buf); +*/ +} + From fe3cc4facd7306153bf41587ed77874d2fe3c46b Mon Sep 17 00:00:00 2001 From: xywang Date: Mon, 28 Jun 2021 19:32:10 +0800 Subject: [PATCH 04/65] [TD-2574]: fixed compilation errors. --- src/query/src/qAggMain.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 2c7242b26a..c8f4cf8dbd 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2208,12 +2208,24 @@ static int32_t topBotComparFn(const void *p1, const void *p2, const void *param) tValuePair *val2 = *(tValuePair **) p2; if (IS_SIGNED_NUMERIC_TYPE(type)) { - return val1->v.i64 - val2->v.i64; - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - return val1->v.u64 - val2->v.u64; + if (val1->v.i64 == val2->v.i64) { + return 0; + } + + return (val1->v.i64 > val2->v.i64) ? 1 : -1; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + if (val1->v.u64 == val2->v.u64) { + return 0; + } + + return (val1->v.u64 > val2->v.u64) ? 1 : -1; } - return val1->v.dKey - val2->v.dKey; + if (val1->v.dKey == val2->v.dKey) { + return 0; + } + + return (val1->v.dKey > val2->v.dKey) ? 1 : -1; } static void topBotSwapFn(void *dst, void *src, const void *param) From 965f55beeb04366d7efc90788bd8b62d14ae7541 Mon Sep 17 00:00:00 2001 From: zyyang-taosdata Date: Mon, 5 Jul 2021 15:43:25 +0800 Subject: [PATCH 05/65] change version number --- cmake/version.inc | 2 +- snap/snapcraft.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/version.inc b/cmake/version.inc index 134f09f179..34e8f1f83a 100755 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.1.3.0") + SET(TD_VER_NUMBER "2.1.4.1") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 65a8e6b684..fe60dca6ed 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: tdengine base: core18 -version: '2.1.3.0' +version: '2.1.4.1' icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | @@ -72,7 +72,7 @@ parts: - usr/bin/taosd - usr/bin/taos - usr/bin/taosdemo - - usr/lib/libtaos.so.2.1.3.0 + - usr/lib/libtaos.so.2.1.4.1 - usr/lib/libtaos.so.1 - usr/lib/libtaos.so From 48db99a7e94966cb59346882633bab1fbf263e39 Mon Sep 17 00:00:00 2001 From: zyyang-taosdata Date: Mon, 5 Jul 2021 22:58:20 +0800 Subject: [PATCH 06/65] modify alert release'scripts --- alert/release.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/alert/release.sh b/alert/release.sh index 35eb4d677f..77f6798480 100755 --- a/alert/release.sh +++ b/alert/release.sh @@ -7,8 +7,9 @@ set -e cpuType=amd64 # [armv6l | arm64 | amd64 | 386] osType=linux # [linux | darwin | windows] version="" +verType=stable # [stable, beta] declare -A archMap=(["armv6l"]="arm" ["arm64"]="arm64" ["amd64"]="x64" ["386"]="x86") -while getopts "h:c:o:n:" arg +while getopts "h:c:o:n:V:" arg do case $arg in c) @@ -23,6 +24,10 @@ do #echo "version=$OPTARG" version=$(echo $OPTARG) ;; + V) + #echo "verType=$OPTARG" + verType=$(echo $OPTARG) + ;; h) echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]" exit 0 @@ -55,6 +60,22 @@ cp alert alert.cfg install_driver.sh ./TDengine-alert/. cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/. chmod 777 ./TDengine-alert/install_driver.sh -tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/ +tar -I 'gzip -9' -cf ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/ rm -rf ./TDengine-alert + + +# mv package to comminuty/release/ +pkg_name=TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]} + +if [ "$verType" == "beta" ]; then + pkg_name=${pkg_name}-${verType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi + +cd ${scriptdir}/../release/ +mv ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz ${pkg_name}.tar.gz From 32d8dd797902c3fb3c27f9f9e74639694b9cac18 Mon Sep 17 00:00:00 2001 From: bryanchang0603 Date: Tue, 6 Jul 2021 02:27:49 +0800 Subject: [PATCH 07/65] modify release.sh --- alert/release.sh | 25 +++++++++++++++++++++++-- cmake/version.inc | 2 +- packaging/docker/dockerManifest.sh | 4 +++- snap/snapcraft.yaml | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/alert/release.sh b/alert/release.sh index 35eb4d677f..77f6798480 100755 --- a/alert/release.sh +++ b/alert/release.sh @@ -7,8 +7,9 @@ set -e cpuType=amd64 # [armv6l | arm64 | amd64 | 386] osType=linux # [linux | darwin | windows] version="" +verType=stable # [stable, beta] declare -A archMap=(["armv6l"]="arm" ["arm64"]="arm64" ["amd64"]="x64" ["386"]="x86") -while getopts "h:c:o:n:" arg +while getopts "h:c:o:n:V:" arg do case $arg in c) @@ -23,6 +24,10 @@ do #echo "version=$OPTARG" version=$(echo $OPTARG) ;; + V) + #echo "verType=$OPTARG" + verType=$(echo $OPTARG) + ;; h) echo "Usage: `basename $0` -c [armv6l | arm64 | amd64 | 386] -o [linux | darwin | windows]" exit 0 @@ -55,6 +60,22 @@ cp alert alert.cfg install_driver.sh ./TDengine-alert/. cp ../../../debug/build/lib/libtaos.so.${version} ./TDengine-alert/driver/. chmod 777 ./TDengine-alert/install_driver.sh -tar -I 'gzip -9' -cf ${startdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/ +tar -I 'gzip -9' -cf ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz TDengine-alert/ rm -rf ./TDengine-alert + + +# mv package to comminuty/release/ +pkg_name=TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]} + +if [ "$verType" == "beta" ]; then + pkg_name=${pkg_name}-${verType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi + +cd ${scriptdir}/../release/ +mv ${scriptdir}/TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]}.tar.gz ${pkg_name}.tar.gz diff --git a/cmake/version.inc b/cmake/version.inc index 134f09f179..34e8f1f83a 100755 --- a/cmake/version.inc +++ b/cmake/version.inc @@ -4,7 +4,7 @@ PROJECT(TDengine) IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "2.1.3.0") + SET(TD_VER_NUMBER "2.1.4.1") ENDIF () IF (DEFINED VERCOMPATIBLE) diff --git a/packaging/docker/dockerManifest.sh b/packaging/docker/dockerManifest.sh index c846e8345d..c479925932 100755 --- a/packaging/docker/dockerManifest.sh +++ b/packaging/docker/dockerManifest.sh @@ -35,7 +35,9 @@ done echo "verNumber=${verNumber}" -#docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber} +#docker manifest rm tdengine/tdengine +#docker manifest rm tdengine/tdengine:${verNumber} +docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber} docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest docker login -u tdengine -p ${passWord} #replace the docker registry username and password diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 65a8e6b684..fe60dca6ed 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: tdengine base: core18 -version: '2.1.3.0' +version: '2.1.4.1' icon: snap/gui/t-dengine.svg summary: an open-source big data platform designed and optimized for IoT. description: | @@ -72,7 +72,7 @@ parts: - usr/bin/taosd - usr/bin/taos - usr/bin/taosdemo - - usr/lib/libtaos.so.2.1.3.0 + - usr/lib/libtaos.so.2.1.4.1 - usr/lib/libtaos.so.1 - usr/lib/libtaos.so From a7a38aece7c5bb74dd6d73b154ca3b4e5ff95663 Mon Sep 17 00:00:00 2001 From: tomchon Date: Tue, 6 Jul 2021 17:50:49 +0000 Subject: [PATCH 08/65] modify release scripts of docker-building --- packaging/docker/dockerbuild.sh | 67 +++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/packaging/docker/dockerbuild.sh b/packaging/docker/dockerbuild.sh index b7991465b0..76717d5892 100755 --- a/packaging/docker/dockerbuild.sh +++ b/packaging/docker/dockerbuild.sh @@ -1,20 +1,24 @@ #!/bin/bash +# + set -e #set -x # dockerbuild.sh # -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] -# -f [pkg file] # -n [version number] # -p [password for docker hub] +# -V [stable | beta] +# -f [pkg file] # set parameters by default value -cpuType=amd64 -verNumber="" +cpuType="" +version="" passWord="" pkgFile="" +verType="" -while getopts "hc:n:p:f:" arg +while getopts "hc:n:p:f:V:" arg do case $arg in c) @@ -22,8 +26,8 @@ do cpuType=$(echo $OPTARG) ;; n) - #echo "verNumber=$OPTARG" - verNumber=$(echo $OPTARG) + #echo "version=$OPTARG" + version=$(echo $OPTARG) ;; p) #echo "passWord=$OPTARG" @@ -33,11 +37,17 @@ do #echo "pkgFile=$OPTARG" pkgFile=$(echo $OPTARG) ;; + V) + #echo "verType=$OPTARG" + verType=$(echo $OPTARG) + ;; h) - echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " - echo " -f [pkg file] " + echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " echo " -n [version number] " echo " -p [password for docker hub] " + echo " -V [stable | beta] " + echo " -f [pkg file] " + exit 0 ;; ?) #unknow option @@ -47,17 +57,44 @@ do esac done -echo "cpuType=${cpuType} verNumber=${verNumber} pkgFile=${pkgFile} " +# if [ "$verType" == "beta" ]; then +# pkgFile=TDengine-server-${version}-Linux-${cpuType}-${verType}.tar.gz +# elif [ "$verType" == "stable" ]; then +# pkgFile=TDengine-server-${version}-Linux-${cpuType}.tar.gz +# else +# echo "unknow verType, nor stabel or beta" +# exit 1 + +if [ "$verType" == "beta" ]; then + dockername=${cpuType}-${verType} +elif [ "$verType" == "stable" ]; then + dockername=${cpuType} +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi + + +echo "cpuType=${cpuType} version=${version} pkgFile=${pkgFile} verType=${verType} " echo "$(pwd)" echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh====" -dirName=${pkgFile%-Linux*} -#echo "dirName=${dirName}" +scriptDir=$(dirname $(readlink -f $0)) +comunityArchiveDir=/nas/TDengine/v$version/community # community version’package directory +cd ${scriptDir} +cp -f ${comunityArchiveDir}/${pkgFile} . -docker build --rm -f "Dockerfile" -t tdengine/tdengine-${cpuType}:${verNumber} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} +dirName=${pkgFile%-Linux*} +echo "dirName=${dirName}" + + +docker build --rm -f "Dockerfile" -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} docker login -u tdengine -p ${passWord} #replace the docker registry username and password -docker push tdengine/tdengine-${cpuType}:${verNumber} +docker push tdengine/tdengine-${dockername}:${version} # set this version to latest version -docker tag tdengine/tdengine-${cpuType}:${verNumber} tdengine/tdengine-${cpuType}:latest -docker push tdengine/tdengine-${cpuType}:latest +docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest +docker push tdengine/tdengine-${dockername}:latest + + +rm -f ${pkgFile} \ No newline at end of file From a388965892eae3f7711445301af49ec4a5cb1680 Mon Sep 17 00:00:00 2001 From: tomchon Date: Wed, 7 Jul 2021 11:31:15 +0800 Subject: [PATCH 09/65] modify dockerManifest.sh --- packaging/docker/dockerManifest.sh | 43 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/packaging/docker/dockerManifest.sh b/packaging/docker/dockerManifest.sh index c479925932..598bd46f13 100755 --- a/packaging/docker/dockerManifest.sh +++ b/packaging/docker/dockerManifest.sh @@ -5,22 +5,28 @@ set -e # dockerbuild.sh # -n [version number] # -p [xxxx] +# -V [stable | beta] # set parameters by default value -verNumber="" +version="" passWord="" +verType="" -while getopts "hn:p:" arg +while getopts "hn:p:V:" arg do case $arg in n) - #echo "verNumber=$OPTARG" - verNumber=$(echo $OPTARG) + #echo "version=$OPTARG" + version=$(echo $OPTARG) ;; p) #echo "passWord=$OPTARG" passWord=$(echo $OPTARG) ;; + V) + #echo "verType=$OPTARG" + verType=$(echo $OPTARG) + ;; h) echo "Usage: `basename $0` -n [version number] " echo " -p [password for docker hub] " @@ -33,15 +39,30 @@ do esac done -echo "verNumber=${verNumber}" +echo "version=${version}" #docker manifest rm tdengine/tdengine -#docker manifest rm tdengine/tdengine:${verNumber} -docker manifest create -a tdengine/tdengine:${verNumber} tdengine/tdengine-amd64:${verNumber} tdengine/tdengine-aarch64:${verNumber} tdengine/tdengine-aarch32:${verNumber} -docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest +#docker manifest rm tdengine/tdengine:${version} +if [ "$verType" == "beta" ]; then + docker manifest create -a tdengine/tdengine-beta:${version} tdengine/tdengine-amd64-beta:${version} tdengine/tdengine-aarch64-beta:${version} tdengine/tdengine-aarch32-beta:${version} + docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest + docker login -u tdengine -p ${passWord} #replace the docker registry username and password + docker manifest push tdengine/tdengine-beta:latest +elif [ "$verType" == "stable" ]; then + docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version} + docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest + docker login -u tdengine -p ${passWord} #replace the docker registry username and password + docker manifest push tdengine/tdengine:latest +else + echo "unknow verType, nor stabel or beta" + exit 1 +fi -docker login -u tdengine -p ${passWord} #replace the docker registry username and password +# docker manifest create -a tdengine/${dockername}:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version} +# docker manifest create -a tdengine/${dockername}:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest -docker manifest push tdengine/tdengine:latest +# docker login -u tdengine -p ${passWord} #replace the docker registry username and password -# how set latest version ??? +# docker manifest push tdengine/tdengine:latest + +# # how set latest version ??? From cbb8642f7912fac1df200f1f755ab5d1962e86e0 Mon Sep 17 00:00:00 2001 From: happyguoxy Date: Thu, 8 Jul 2021 13:55:28 +0800 Subject: [PATCH 10/65] [TD-4735]:test nestquery last row function --- tests/pytest/query/nestquery_last_row.py | 263 +++++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 tests/pytest/query/nestquery_last_row.py diff --git a/tests/pytest/query/nestquery_last_row.py b/tests/pytest/query/nestquery_last_row.py new file mode 100644 index 0000000000..a04cb173af --- /dev/null +++ b/tests/pytest/query/nestquery_last_row.py @@ -0,0 +1,263 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import taos +from util.log import tdLog +from util.cases import tdCases +from util.sql import tdSql +import random + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + self.ts = 1600000000000 + self.num = 10 + + def run(self): + tdSql.prepare() + # test case for https://jira.taosdata.com:18080/browse/TD-4735 + + tdSql.execute('''create stable stable_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) + tags(loc nchar(20) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, + t_bool bool , t_binary binary(20) , t_nchar nchar(20) , + t_float float , t_double double , t_ts timestamp);''') + tdSql.execute('''create table table_0 using stable_1 + tags('table_0' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0')''') + tdSql.execute('''create table table_1 using stable_1 + tags('table_1' , '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , + 'binary1' , 'nchar1' , '1' , '11' , \'1999-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_2 using stable_1 + tags('table_2' , '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , + 'binary2' , 'nchar2nchar2' , '-2.2' , '-22.22' , \'2099-09-09 09:09:09.090\')''') + tdSql.execute('''create table table_3 using stable_1 + tags('table_3' , '3' , '3' , '3' , '3' , true , 'binary3' , 'nchar3' , '33.33' , '3333.3333' , '0')''') + tdSql.execute('''create table table_4 using stable_1 + tags('table_4' , '4' , '4' , '4' , '4' , false , 'binary4' , 'nchar4' , '-444.444' , '-444444.444444' , '0')''') + tdSql.execute('''create table table_5 using stable_1 + tags('table_5' , '5' , '5' , '5' , '5' , true , 'binary5' , 'nchar5' , '5555.5555' , '55555555.55555555' , '0')''') + #regular table + tdSql.execute('''create table regular_table_1 + (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint, + q_bool bool , q_binary binary(20) , q_nchar nchar(20) , + q_float float , q_double double , q_ts timestamp) ;''') + + for i in range(self.num): + tdSql.execute('''insert into table_0 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into table_2 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into table_3 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into table_4 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into table_5 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 0, 'binary.%s', 'nchar.%s', %f, %f, %d)''' + % (self.ts + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, 1, 'binary1.%s', 'nchar1.%s', %f, %f, %d)''' + % (self.ts + 100 + i, 2147483647-i, 9223372036854775807-i, 32767-i, 127-i, + i, i, random.random(), random.random(), 1262304000001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary2.%s', 'nchar2nchar2.%s', %f, %f, %d)''' + % (self.ts + 200 + i, -2147483647+i, -9223372036854775807+i, -32767+i, -127+i, + i, i, random.uniform(-1,0), random.uniform(-1,0), 1577836800001 + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary3.%s', 'nchar3.%s', %f, %f, %d)''' + % (self.ts + 300 + i, random.randint(-2147483647, 2147483647), + random.randint(-9223372036854775807, 9223372036854775807), random.randint(-32767, 32767), + random.randint(-127, 127), random.randint(-100, 100), random.randint(-10000, 10000), + random.uniform(-100000,100000), random.uniform(-1000000000,1000000000), self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, true, 'binary4.%s', 'nchar4.%s', %f, %f, %d)''' + % (self.ts + 400 + i, i, i, i, i, i, i, i, i, self.ts + i)) + tdSql.execute('''insert into regular_table_1 values(%d, %d, %d, %d, %d, false, 'binary5.%s', 'nchar5.%s', %f, %f, %d)''' + % (self.ts + 500 + i, i, i, i, i, i, i, i, i, self.ts + i)) + + sql = '''select * from stable_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select * from regular_table_1''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + + tdLog.info("=======last_row(*)========") + sql = '''select last_row(*) from stable_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + sql = '''select last_row(*) from regular_table_1;''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + + sql = '''select * from stable_1 + where loc = 'table_0';''' + tdSql.query(sql) + tdSql.checkRows(self.num) + sql = '''select last_row(*) from + (select * from stable_1 + where loc = 'table_0');''' + tdSql.query(sql) + tdSql.checkRows(1) + sql = '''select last_row(*) from + (select * from stable_1);''' + tdSql.query(sql) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary5.9') + tdSql.checkData(0,7,'nchar5.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + tdSql.checkData(0,11,'table_5') + tdSql.checkData(0,12,5) + tdSql.checkData(0,13,5) + tdSql.checkData(0,14,5) + tdSql.checkData(0,15,5) + tdSql.checkData(0,16,'True') + tdSql.checkData(0,17,'binary5') + tdSql.checkData(0,18,'nchar5') + tdSql.checkData(0,21,'1970-01-01 08:00:00.000') + + sql = '''select * from regular_table_1 ;''' + tdSql.query(sql) + tdSql.checkRows(6*self.num) + sql = '''select last_row(*) from + (select * from regular_table_1);''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary5.9') + tdSql.checkData(0,7,'nchar5.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + sql = '''select last_row(*) from + ((select * from table_0) union all + (select * from table_1) union all + (select * from table_2));''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary.9') + tdSql.checkData(0,7,'nchar.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + # bug 5055 + # sql = '''select last_row(*) from + # ((select * from stable_1) union all + # (select * from table_1) union all + # (select * from regular_table_1));''' + # tdSql.query(sql) + # tdSql.checkData(0,1,self.num-1) + + sql = '''select last_row(*) from + ((select last_row(*) from table_0) union all + (select last_row(*) from table_1) union all + (select last_row(*) from table_2));''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary.9') + tdSql.checkData(0,7,'nchar.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + # bug 5055 + # sql = '''select last_row(*) from + # ((select last_row(*) from stable_1) union all + # (select last_row(*) from table_1) union all + # (select last_row(*) from regular_table_1));''' + # tdSql.query(sql) + # tdSql.checkData(0,1,self.num-1) + + sql = '''select last_row(*) from + ((select * from table_0 limit 5 offset 5) union all + (select * from table_1 limit 5 offset 5) union all + (select * from regular_table_1 limit 5 offset 5));''' + tdSql.query(sql) + tdSql.checkRows(1) + tdSql.checkData(0,1,self.num-1) + tdSql.checkData(0,2,self.num-1) + tdSql.checkData(0,3,self.num-1) + tdSql.checkData(0,4,self.num-1) + tdSql.checkData(0,5,'False') + tdSql.checkData(0,6,'binary.9') + tdSql.checkData(0,7,'nchar.9') + tdSql.checkData(0,8,9.00000) + tdSql.checkData(0,9,9.000000000) + tdSql.checkData(0,10,'2020-09-13 20:26:40.009') + + + sql = '''select last_row(*) from + (select * from stable_1) + having q_int>5;''' + tdLog.info(sql) + tdSql.error(sql) + try: + tdSql.execute(sql) + tdLog.exit(" having only works with group by") + except Exception as e: + tdLog.info(repr(e)) + tdLog.info("invalid operation: having only works with group by") + + #bug 5057 + # sql = '''select last_row(*) from + # (select * from (select * from stable_1))''' + # tdLog.info(sql) + # tdSql.error(sql) + # try: + # tdSql.execute(sql) + # tdLog.exit(" core dumped") + # except Exception as e: + # tdLog.info(repr(e)) + # tdLog.info("core dumped") + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file From df5f03bbdfc315807e03bbd071e5651b743ead53 Mon Sep 17 00:00:00 2001 From: happyguoxy Date: Thu, 8 Jul 2021 13:55:47 +0800 Subject: [PATCH 11/65] [TD-4735]:test nestquery last row function --- tests/pytest/fulltest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 2cbc3747f6..9cdab008fd 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -239,6 +239,7 @@ python3 ./test.py -f query/subqueryFilter.py # python3 ./test.py -f query/nestedQuery/queryInterval.py python3 ./test.py -f query/queryStateWindow.py python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py +python3 ./test.py -f query/nestquery_last_row.py #stream From c4f06ca30b1a37b42b60a89285fbceba21f2cde8 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 6 Jul 2021 18:05:27 +0800 Subject: [PATCH 12/65] develop schemaless --- src/client/src/tscParseLineProtocol.c | 731 ++++++++++++++++++++++++++ 1 file changed, 731 insertions(+) create mode 100644 src/client/src/tscParseLineProtocol.c diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c new file mode 100644 index 0000000000..79e8955f9a --- /dev/null +++ b/src/client/src/tscParseLineProtocol.c @@ -0,0 +1,731 @@ +#include +#include +#include +#include +#include "os.h" +#include "osString.h" +#include "ttype.h" +#include "tmd5.h" +#include "tstrbuild.h" +#include "tname.h" +#include "taos.h" +#include "tsclient.h" +#include "tscLog.h" +#include "hash.h" +#include "tskiplist.h" +#include "tscUtil.h" + +typedef enum { + LP_ITEM_TAG, + LP_ITEM_FIELD +} LPItemKind; + +typedef struct { + SStrToken key; + SStrToken value; + + char name[TSDB_COL_NAME_LEN]; + int8_t type; + int16_t bytes; + + char* payload; +}SLPItem; + +typedef struct { + SStrToken measToken; + SStrToken tsToken; + + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; + SArray* fields; + int64_t ts; + +} SLPPoint; + +typedef enum { + LP_MEASUREMENT, + LP_TAG_KEY, + LP_TAG_VALUE, + LP_FIELD_KEY, + LP_FIELD_VALUE +} LPPart; + +int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == ',' || s.z[i] == ' ') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == '=') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { + point->measToken = token; + if (point->measToken.n < TSDB_TABLE_NAME_LEN) { + strncpy(point->sTableName, point->measToken.z, point->measToken.n); + point->sTableName[point->measToken.n] = '\0'; + } + return 0; +} + +int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { + item->key = key; + if (item->key.n < TSDB_COL_NAME_LEN) { + strncpy(item->name, item->key.z, item->key.n); + item->name[item->key.n] = '\0'; + } + return 0; +} + +int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { + item->value = value; + return 0; +} + +int32_t parseItemValue(SLPItem* item, LPItemKind kind) { + char* sv = item->value.z; + char* last = item->value.z + item->value.n - 1; + + if (isdigit(sv[0]) || sv[0] == '-') { + if (*last == 'i') { + item->type = TSDB_DATA_TYPE_BIGINT; + item->bytes = (int16_t)tDataTypes[item->type].bytes; + item->payload = malloc(item->bytes); + char* endptr = NULL; + *(item->payload) = strtoll(sv, &endptr, 10); + } else { + item->type = TSDB_DATA_TYPE_DOUBLE; + item->bytes = (int16_t)tDataTypes[item->type].bytes; + item->payload = malloc(item->bytes); + char* endptr = NULL; + *(item->payload) = strtold(sv, &endptr); + } + } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { + if (sv[0] == 'L') { + item->type = TSDB_DATA_TYPE_NCHAR; + uint32_t bytes = item->value.n - 3; +// uint32_t len = bytes; +// char* ucs = malloc(len); +// int32_t ncharBytes = 0; +// taosMbsToUcs4(sv+2, len, ucs, len, &ncharBytes); +// item->bytes = ncharBytes; +// item->payload = malloc(ncharBytes); +// memcpy(item->payload, ucs, ncharBytes); +// free(ucs); + item->bytes = bytes; + item->payload = malloc(bytes); + memcpy(item->payload, sv+1, bytes); + } else if (sv[0]=='"'){ + item->type = TSDB_DATA_TYPE_BINARY; + uint32_t bytes = item->value.n - 2; + item->bytes = bytes; + item->payload = malloc(bytes); + memcpy(item->payload, sv+1, bytes); + } + } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { + item->type = TSDB_DATA_TYPE_BOOL; + item->bytes = tDataTypes[item->type].bytes; + item->payload = malloc(tDataTypes[item->type].bytes); + *(item->payload) = tolower(sv[0])=='t' ? true : false; + } + return 0; +} + +int32_t compareLPItemKey(const void* p1, const void* p2) { + const SLPItem* t1 = p1; + const SLPItem* t2 = p2; + uint32_t min = (t1->key.n < t2->key.n) ? t1->key.n : t2->key.n; + int res = strncmp(t1->key.z, t2->key.z, min); + if (res != 0) { + return res; + } else { + return (int)(t1->key.n) - (int)(t2->key.n); + } +} + +int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { + point->tsToken = tsToken; + return 0; +} + +int32_t parsePointTime(SLPPoint* point) { + if (point->tsToken.n <= 0) { + point->ts = taosGetTimestampNs(); + } else { + char* endptr = NULL; + point->ts = strtoll(point->tsToken.z, &endptr, 10); + } + return 0; +} + +int32_t tscParseLine(SStrToken line, SLPPoint* point) { + int32_t pos = 0; + + int32_t start = 0; + int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); + if (err != 0) { + tscError("a"); + return err; + } + + SStrToken measurement = {.z = line.z+start, .n = pos-start}; + setPointMeasurement(point, measurement); + point->tags = taosArrayInit(64, sizeof(SLPItem)); + start = pos + 1; + while (line.z[start] == ',') { + SLPItem item; + + err = scanToEqual(line, start, &pos); + if (err != 0) { + tscError("b"); + goto error; + } + + SStrToken tagKey = {.z = line.z + start, .n = pos-start}; + setItemKey(&item, tagKey, LP_TAG_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); + if (err != 0) { + tscError("c"); + goto error; + } + + SStrToken tagValue = {.z = line.z + start, .n = pos-start}; + setItemValue(&item, tagValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_TAG); + taosArrayPush(point->tags, &item); + + start = pos + 1; + } + + taosArraySort(point->tags, compareLPItemKey); + + point->fields = taosArrayInit(64, sizeof(SLPItem)); + do { + SLPItem item; + err = scanToEqual(line, start, &pos); + if (err != 0) { + goto error; + } + SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; + setItemKey(&item, fieldKey, LP_FIELD_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); + if (err != 0) { + goto error; + } + SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; + setItemValue(&item, fieldValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_FIELD); + taosArrayPush(point->fields, &item); + + start = pos + 1; + } while (line.z[pos] == ','); + + taosArraySort(point->fields, compareLPItemKey); + + SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; + setPointTimeStamp(point, tsToken); + parsePointTime(point); + + goto done; + +error: + // free array + return err; +done: + return 0; +} + + +int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { + for (int32_t i = 0; i < numLines; ++i) { + SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; + SLPPoint point; + tscParseLine(tkLine, &point); + taosArrayPush(points, &point); + } + return 0; +} + +TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { + SArray* points = taosArrayInit(numLines, sizeof(SLPPoint)); + tscParseLines(lines, numLines, points, NULL); + + + return NULL; +} +//================================================================================================= + +typedef struct { + char* key; + uint8_t type; + int16_t length; + char* value; +} TAOS_SML_KV; + +typedef struct { + char* stableName; + + char* childTableName; + TAOS_SML_KV* tags; + int tagNum; + + // first kv must be timestamp + TAOS_SML_KV* fields; + int fieldNum; + +} TAOS_SML_DATA_POINT; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SHashObj* tagHash; + SHashObj* fieldHash; + SArray* tags; //SArray + SArray* fields; //SArray +} SSmlSTableSchema; + + +int compareSmlColKv(const void* p1, const void* p2) { + TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; + TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; + int kvLen1 = (int)strlen(kv1->key); + int kvLen2 = (int)strlen(kv2->key); + int res = strncasecmp(kv1->key, kv2->key, MIN(kvLen1, kvLen2)); + if (res != 0) { + return res; + } else { + return kvLen1-kvLen2; + } +} + +int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { + qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); + + SStringBuilder sb; memset(&sb, 0, sizeof(sb)); + taosStringBuilderAppendString(&sb, point->stableName); + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + taosStringBuilderAppendChar(&sb, ','); + taosStringBuilderAppendString(&sb, tagKv->key); + taosStringBuilderAppendChar(&sb, '='); + taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); + } + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + MD5_CTX context; + MD5Init(&context); + MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + MD5Final(&context); + *tableNameLen = snprintf(tableName, *tableNameLen, + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + return 0; +} + +int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { + int32_t code = 0; + + STscObj *pObj = (STscObj *)taos; + if (pObj == NULL || pObj->signature != pObj) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + char sql[256]; + snprintf(sql, 256, "describe %s", tableName); + TAOS_RES* res = taos_query(taos, sql); + code = taos_errno(res); + if (code != 0) { + taos_free_result(res); + return code; + } + taos_free_result(res); + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + pSql->pTscObj = taos; + pSql->signature = pSql; + pSql->fp = NULL; + + SStrToken tableToken = {.z=tableName, .n=strlen(tableName), .type=TK_ID}; + tGetToken(tableName, &tableToken.type); + // Check if the table name available or not + if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { + code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; + sprintf(pSql->cmd.payload, "table name is invalid"); + return code; + } + + SName sname = {0}; + if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { + return code; + } + + char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; + memset(fullTableName, 0, tListLen(fullTableName)); + tNameExtractFullName(&sname, fullTableName); + + if (code != TSDB_CODE_SUCCESS) { + tscFreeSqlObj(pSql); + return code; + } + + tscFreeSqlObj(pSql); + + + uint32_t size = tscGetTableMetaMaxSize(); + STableMeta* tableMeta = calloc(1, size); + taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); + + tstrncpy(schema->sTableName, tableName, strlen(tableName)); + for (int i=0; itableInfo.numOfColumns; ++i) { + SSchema field; + tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)); + field.type = tableMeta->schema[i].type; + field.bytes = tableMeta->schema[i].bytes; + SSchema* pField = taosArrayPush(schema->fields, &field); + taosHashPut(schema->fieldHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + + for (int i=0; itableInfo.numOfTags; ++i) { + int j = i + tableMeta->tableInfo.numOfColumns; + SSchema field; + tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)); + field.type = tableMeta->schema[j].type; + field.bytes = tableMeta->schema[j].bytes; + SSchema* pField = taosArrayPush(schema->tags, &field); + taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + + return code; + +} + +typedef enum { + SCHEMA_ACTION_CREATE_STABLE, + SCHEMA_ACTION_ADD_COLUMN, + SCHEMA_ACTION_ADD_TAG, + SCHEMA_ACTION_CHANGE_COLUMN_SIZE, + SCHEMA_ACTION_CHANGE_TAG_SIZE, + SCHEMA_ACTION_CREATE_CTABLE +} ESchemaAction; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; //SArray + SArray* fields; //SArray +} SCreateSTableActionInfo; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SSchema* field; +} SAlterSTableActionInfo; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + char cTableName[TSDB_TABLE_NAME_LEN]; + TAOS_SML_KV* tags; + int tagNum; +} SCreateCTableActionInfo; + +typedef struct { + ESchemaAction action; + union { + SCreateSTableActionInfo createSTable; + SAlterSTableActionInfo alterSTable; + SCreateCTableActionInfo createCTable; + }; +} SSchemaAction; + +int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { + if (!IS_VAR_DATA_TYPE(kv->type)) { + *bytes = tDataTypes[kv->type].bytes; + } else { + if (kv->type == TSDB_DATA_TYPE_NCHAR) { + char* ucs = malloc(kv->length * TSDB_NCHAR_SIZE + 1); + int32_t bytesNeeded = 0; + //todo check conversion succeed + taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); + free(ucs); + *bytes = bytesNeeded + VARSTR_HEADER_SIZE; + + } else if (kv->type == TSDB_DATA_TYPE_BINARY) { + *bytes = kv->length + VARSTR_HEADER_SIZE; + } + } + return 0; +} + +int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) { + SSchema* pField = NULL; + SSchema** ppField = taosHashGet(hash, smlKv->key, strlen(smlKv->key)); + if (ppField) { + pField = *ppField; + + if (pField->type != smlKv->type) { + //TODO: + tscError("type mismatch"); + return -1; + } + + int32_t bytes = 0; + getFieldBytesFromSmlKv(smlKv, &bytes); + pField->bytes = MAX(pField->bytes, bytes); + + } else { + SSchema field; + size_t tagKeyLen = strlen(smlKv->key); + strncpy(field.name, smlKv->key, tagKeyLen); + field.name[tagKeyLen] = '\0'; + field.type = smlKv->type; + + int32_t bytes = 0; + getFieldBytesFromSmlKv(smlKv, &bytes); + field.bytes = bytes; + + pField = taosArrayPush(array, &field); + taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); + } + return 0; +} + +int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], + SSchemaAction* action, bool* actionNeeded) { + SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name)); + if (*ppDbAttr) { + SSchema* dbAttr = *ppDbAttr; + if (pointColField->type != dbAttr->type) { + //todo error + return -5; + } + + if (IS_VAR_DATA_TYPE(pointColField->type) && (pointColField->bytes > dbAttr->bytes)) { + if (isTag) { + action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE; + } else { + action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE; + } + memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo)); + memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN); + action->alterSTable.field = pointColField; + *actionNeeded = true; + } + } else { + if (isTag) { + action->action = SCHEMA_ACTION_ADD_TAG; + } else { + action->action = SCHEMA_ACTION_ADD_COLUMN; + } + memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo)); + memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN); + action->alterSTable.field = pointColField; + *actionNeeded = true; + } + return 0; +} + +int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + int32_t code = TSDB_CODE_SUCCESS; + SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + SHashObj* sname2shema = taosHashInit(32, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int i = 0; i < numPoint; ++i) { + TAOS_SML_DATA_POINT* point = &points[i]; + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + SSmlSTableSchema* pStableSchema = NULL; + if (ppStableSchema) { + pStableSchema= *ppStableSchema; + } else { + SSmlSTableSchema schema; + size_t stableNameLen = strlen(point->stableName); + strncpy(schema.sTableName, point->stableName, stableNameLen); + schema.sTableName[stableNameLen] = '\0'; + schema.fields = taosArrayInit(64, sizeof(SSchema)); + schema.tags = taosArrayInit(8, sizeof(SSchema)); + schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + pStableSchema = taosArrayPush(stableArray, &schema); + taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); + } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* fieldKv = point->fields + j; + addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + } + } + + SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); + size_t numStable = taosArrayGetSize(stableArray); + for (int i = 0; i < numStable; ++i) { + SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); + SSmlSTableSchema dbSchema = {0}; + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); + dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { + SSchemaAction schemaAction = {0}; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); + memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); + schemaAction.createSTable.tags = pointSchema->tags; + schemaAction.createSTable.fields = pointSchema->fields; + taosArrayPush(schemaActions, &schemaAction); + }else if (code == TSDB_CODE_SUCCESS) { + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); + size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); + + SHashObj* dbTagHash = dbSchema.tagHash; + SHashObj* dbFieldHash = dbSchema.fieldHash; + + for (int j = 0; j < pointTagSize; ++j) { + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + + for (int j = 0; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + } else { + return code; + } + } + + return code; +} + + +int32_t buildColumnDescription(SSchema* field, + char* buf, int32_t bufSize, int32_t* outBytes) { + uint8_t type = field->type; + + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + int32_t bytes = field->bytes - VARSTR_HEADER_SIZE; + if (type == TSDB_DATA_TYPE_NCHAR) { + bytes = bytes/TSDB_NCHAR_SIZE; + } + int out = snprintf(buf, bufSize,"%s %s(%d)", + field->name,tDataTypes[field->type].name, bytes); + *outBytes = out; + } else { + int out = snprintf(buf, bufSize, "%s %s", + field->name, tDataTypes[type].name); + *outBytes = out; + } + + return 0; +} + +int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { + int32_t code = 0; + int32_t capacity = TSDB_MAX_BINARY_LEN; + int32_t outBytes = 0; + char *result = (char *)calloc(1, capacity); + + switch (action->action) { + case SCHEMA_ACTION_ADD_COLUMN: { + int n = sprintf(result, "alter stable %s add column ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_ADD_TAG: { + int n = sprintf(result, "alter stable %s add tag ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, + result+n, capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { + int n = sprintf(result, "alter stable %s modify column ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, + capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + } + case SCHEMA_ACTION_CHANGE_TAG_SIZE: { + int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, + capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CREATE_STABLE: { + int n = sprintf(result, "create stable %s (", action->createSTable.sTableName); + char* pos = result + n; int freeBytes = capacity - n; + int numCols = taosArrayGetSize(action->createSTable.fields); + for (int32_t i = 0; i < numCols; ++i) { + SSchema* field = taosArrayGet(action->createSTable.fields, i); + buildColumnDescription(field, pos, freeBytes, &outBytes); + pos += outBytes; freeBytes -= outBytes; + *pos = ','; ++pos; --freeBytes; + } + --pos; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ") tags ("); + int numTags = taosArrayGetSize(action->createSTable.tags); + pos += outBytes; freeBytes -= outBytes; + for (int32_t i = 0; i < numTags; ++i) { + SSchema* field = taosArrayGet(action->createSTable.tags, i); + buildColumnDescription(field, pos, freeBytes, &outBytes); + pos += outBytes; freeBytes -= outBytes; + *pos = ','; ++pos; --freeBytes; + } + pos--; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ")"); + TAOS_RES* res = taos_query(taos, result); + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CREATE_CTABLE: { + + break; + } + default: + break; + } + free(result); + return code; +} + +//todo: table/column length check +//todo: type check +//todo: taosmbs2ucs4 check From d5ab8d7ced3a76013cfc64419ec3bf970d3a822b Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 9 Jul 2021 19:37:15 +0800 Subject: [PATCH 13/65] before taos_bind/taos_multi_bind generation --- src/client/src/tscParseLineProtocol.c | 99 +++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 79e8955f9a..10d2429b5e 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -277,6 +277,9 @@ typedef struct { uint8_t type; int16_t length; char* value; + + //=================================== + SSchema* fieldSchema; } TAOS_SML_KV; typedef struct { @@ -415,7 +418,6 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { } return code; - } typedef enum { @@ -465,7 +467,6 @@ int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); free(ucs); *bytes = bytesNeeded + VARSTR_HEADER_SIZE; - } else if (kv->type == TSDB_DATA_TYPE_BINARY) { *bytes = kv->length + VARSTR_HEADER_SIZE; } @@ -503,6 +504,9 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a pField = taosArrayPush(array, &field); taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); } + + smlKv->fieldSchema = pField; + return 0; } @@ -700,9 +704,11 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { *pos = ','; ++pos; --freeBytes; } --pos; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ") tags ("); - int numTags = taosArrayGetSize(action->createSTable.tags); pos += outBytes; freeBytes -= outBytes; + + int numTags = taosArrayGetSize(action->createSTable.tags); for (int32_t i = 0; i < numTags; ++i) { SSchema* field = taosArrayGet(action->createSTable.tags, i); buildColumnDescription(field, pos, freeBytes, &outBytes); @@ -716,7 +722,43 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { break; } case SCHEMA_ACTION_CREATE_CTABLE: { - +// SCreateCTableActionInfo* pInfo = &action->createCTable; +// SArray* bindParams = taosArrayInit(2 + 2 * pInfo->tagNum, sizeof(TAOS_BIND)); +// outBytes = sprintf(result, "create table ? using ?("); +// char* pos = result + outBytes; int32_t freeBytes = capacity-outBytes; +// uintptr_t lenSTableName = strlen(pInfo->sTableName); +// uintptr_t lenCTableName = strlen(pInfo->cTableName); +// TAOS_BIND tbCTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = pInfo->cTableName, .length = &lenCTableName}; +// TAOS_BIND tbSTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = pInfo->sTableName, .length = &lenSTableName}; +// taosArrayPush(bindParams, &tbCTableName); +// taosArrayPush(bindParams, &tbSTableName); +// for (int32_t i = 0; i < pInfo->tagNum; ++i) { +// outBytes = snprintf(pos, freeBytes, "?,"); +// +// TAOS_SML_KV* tagKv = pInfo->tags + i; +// TAOS_BIND tbTag = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = tagKv->key, .length = }; +// pos += outBytes; freeBytes -= outBytes; +// } +// --pos; ++freeBytes; +// +// outBytes = snprintf(pos, freeBytes, ") tags ("); +// pos += outBytes; freeBytes -= outBytes; +// for (int32_t i = 0; i < pInfo->tagNum; ++i) { +// TAOS_SML_KV* tagKv = pInfo->tags + i; +// outBytes = snprintf(pos, freeBytes, "?,"); +// pos += outBytes; freeBytes -= outBytes; +// } +// pos--; ++freeBytes; +// outBytes = snprintf(pos, freeBytes, ")"); +// +// TAOS_STMT* stmt = taos_stmt_init(taos); +// taos_stmt_prepare(stmt, result, strlen(result)); +// +// +// taos_stmt_bind_param(stmt, (TAOS_BIND*)bindParams); break; } default: @@ -726,6 +768,55 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } +int32_t transformIntoPreparedStatement(SArray* points) { + size_t numPoints = taosArrayGetSize(points); + +// SHashObj* tag2bind = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); +// SHashObj* field2multiBind = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int32_t i = 0; i < numPoints; ++i) { + TAOS_SML_DATA_POINT * point = taosArrayGet(points, i); + char tableKey[256]; + snprintf(tableKey, 256, "%s.%s", point->stableName, point->childTableName); + + } + return 0; +} + +int32_t insertBatch(TAOS* taos, const char* sTableName, char* cTableName, SSchema* tagsSchema, int numTags, TAOS_BIND* tagBind, + SSchema* colsSchema, int numCols, TAOS_MULTI_BIND* colBind) { + TAOS_STMT* stmt = taos_stmt_init(taos); + + char result[TSDB_MAX_BINARY_LEN] = {0}; + sprintf(result, "insert into ? using %s(", sTableName); + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", tagsSchema[i].name); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") tags ("); + + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", colsSchema[i].name); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ")"); + + int32_t code = 0; + code = taos_stmt_prepare(stmt, result, strlen(result)); + + code = taos_stmt_set_tbname_tags(stmt, cTableName, tagBind); + code = taos_stmt_bind_param_batch(stmt, colBind); + code = taos_stmt_execute(stmt); + return code; +} //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check From 12e8b038d176b8c0ded55fced17185d531c61cac Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Sat, 10 Jul 2021 16:18:38 +0800 Subject: [PATCH 14/65] before debugging --- src/client/src/tscParseLineProtocol.c | 393 ++++++++++++++------------ 1 file changed, 211 insertions(+), 182 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 10d2429b5e..2738fe6f7a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -272,6 +272,14 @@ TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { } //================================================================================================= +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SHashObj* tagHash; + SHashObj* fieldHash; + SArray* tags; //SArray + SArray* fields; //SArray +} SSmlSTableSchema; + typedef struct { char* key; uint8_t type; @@ -279,7 +287,7 @@ typedef struct { char* value; //=================================== - SSchema* fieldSchema; + SSchema* schema; } TAOS_SML_KV; typedef struct { @@ -293,17 +301,10 @@ typedef struct { TAOS_SML_KV* fields; int fieldNum; + //================================ + SSmlSTableSchema* schema; } TAOS_SML_DATA_POINT; -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SHashObj* tagHash; - SHashObj* fieldHash; - SArray* tags; //SArray - SArray* fields; //SArray -} SSmlSTableSchema; - - int compareSmlColKv(const void* p1, const void* p2) { TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; @@ -426,7 +427,6 @@ typedef enum { SCHEMA_ACTION_ADD_TAG, SCHEMA_ACTION_CHANGE_COLUMN_SIZE, SCHEMA_ACTION_CHANGE_TAG_SIZE, - SCHEMA_ACTION_CREATE_CTABLE } ESchemaAction; typedef struct { @@ -440,19 +440,11 @@ typedef struct { SSchema* field; } SAlterSTableActionInfo; -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - char cTableName[TSDB_TABLE_NAME_LEN]; - TAOS_SML_KV* tags; - int tagNum; -} SCreateCTableActionInfo; - typedef struct { ESchemaAction action; union { SCreateSTableActionInfo createSTable; SAlterSTableActionInfo alterSTable; - SCreateCTableActionInfo createCTable; }; } SSchemaAction; @@ -505,7 +497,7 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); } - smlKv->fieldSchema = pField; + smlKv->schema = pField; return 0; } @@ -545,96 +537,6 @@ int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool return 0; } -int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { - int32_t code = TSDB_CODE_SUCCESS; - SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray - SHashObj* sname2shema = taosHashInit(32, - taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - for (int i = 0; i < numPoint; ++i) { - TAOS_SML_DATA_POINT* point = &points[i]; - SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); - SSmlSTableSchema* pStableSchema = NULL; - if (ppStableSchema) { - pStableSchema= *ppStableSchema; - } else { - SSmlSTableSchema schema; - size_t stableNameLen = strlen(point->stableName); - strncpy(schema.sTableName, point->stableName, stableNameLen); - schema.sTableName[stableNameLen] = '\0'; - schema.fields = taosArrayInit(64, sizeof(SSchema)); - schema.tags = taosArrayInit(8, sizeof(SSchema)); - schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - pStableSchema = taosArrayPush(stableArray, &schema); - taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); - } - - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* tagKv = point->tags + j; - addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); - } - - for (int j = 0; j < point->fieldNum; ++j) { - TAOS_SML_KV* fieldKv = point->fields + j; - addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); - } - } - - SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); - size_t numStable = taosArrayGetSize(stableArray); - for (int i = 0; i < numStable; ++i) { - SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); - SSmlSTableSchema dbSchema = {0}; - dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); - dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); - dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { - SSchemaAction schemaAction = {0}; - schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; - memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); - memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); - schemaAction.createSTable.tags = pointSchema->tags; - schemaAction.createSTable.fields = pointSchema->fields; - taosArrayPush(schemaActions, &schemaAction); - }else if (code == TSDB_CODE_SUCCESS) { - size_t pointTagSize = taosArrayGetSize(pointSchema->tags); - size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); - - SHashObj* dbTagHash = dbSchema.tagHash; - SHashObj* dbFieldHash = dbSchema.fieldHash; - - for (int j = 0; j < pointTagSize; ++j) { - SSchema* pointTag = taosArrayGet(pointSchema->tags, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); - } - } - - for (int j = 0; j < pointFieldSize; ++j) { - SSchema* pointCol = taosArrayGet(pointSchema->tags, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); - } - } - } else { - return code; - } - } - - return code; -} - - int32_t buildColumnDescription(SSchema* field, char* buf, int32_t bufSize, int32_t* outBytes) { uint8_t type = field->type; @@ -721,46 +623,7 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { code = taos_errno(res); break; } - case SCHEMA_ACTION_CREATE_CTABLE: { -// SCreateCTableActionInfo* pInfo = &action->createCTable; -// SArray* bindParams = taosArrayInit(2 + 2 * pInfo->tagNum, sizeof(TAOS_BIND)); -// outBytes = sprintf(result, "create table ? using ?("); -// char* pos = result + outBytes; int32_t freeBytes = capacity-outBytes; -// uintptr_t lenSTableName = strlen(pInfo->sTableName); -// uintptr_t lenCTableName = strlen(pInfo->cTableName); -// TAOS_BIND tbCTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = pInfo->cTableName, .length = &lenCTableName}; -// TAOS_BIND tbSTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = pInfo->sTableName, .length = &lenSTableName}; -// taosArrayPush(bindParams, &tbCTableName); -// taosArrayPush(bindParams, &tbSTableName); -// for (int32_t i = 0; i < pInfo->tagNum; ++i) { -// outBytes = snprintf(pos, freeBytes, "?,"); -// -// TAOS_SML_KV* tagKv = pInfo->tags + i; -// TAOS_BIND tbTag = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = tagKv->key, .length = }; -// pos += outBytes; freeBytes -= outBytes; -// } -// --pos; ++freeBytes; -// -// outBytes = snprintf(pos, freeBytes, ") tags ("); -// pos += outBytes; freeBytes -= outBytes; -// for (int32_t i = 0; i < pInfo->tagNum; ++i) { -// TAOS_SML_KV* tagKv = pInfo->tags + i; -// outBytes = snprintf(pos, freeBytes, "?,"); -// pos += outBytes; freeBytes -= outBytes; -// } -// pos--; ++freeBytes; -// outBytes = snprintf(pos, freeBytes, ")"); -// -// TAOS_STMT* stmt = taos_stmt_init(taos); -// taos_stmt_prepare(stmt, result, strlen(result)); -// -// -// taos_stmt_bind_param(stmt, (TAOS_BIND*)bindParams); - break; - } + default: break; } @@ -768,55 +631,221 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } -int32_t transformIntoPreparedStatement(SArray* points) { - size_t numPoints = taosArrayGetSize(points); +int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { + size_t numTags = taosArrayGetSize(tagsSchema); + size_t numCols = taosArrayGetSize(colsSchema); + sprintf(result, "insert into ? using %s(", sTableName); + for (int i = 0; i < numTags; ++i) { + SSchema* tagSchema = taosArrayGet(tagsSchema, i); + snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") tags ("); -// SHashObj* tag2bind = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); -// SHashObj* field2multiBind = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") ("); + for (int i = 0; i < numCols; ++i) { + SSchema* colSchema = taosArrayGet(colsSchema, i); + snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", colSchema->name); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + return 0; +} + +int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { + TAOS_STMT* stmt = taos_stmt_init(taos); + taos_stmt_prepare(stmt, sql, strlen(sql)); + + taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + size_t rows = taosArrayGetSize(rowsBind); + for (int32_t i = 0; i < rows; ++i) { + TAOS_BIND* colBind = taosArrayGetP(rowsBind, i); + taos_stmt_bind_param(stmt, colBind); + taos_stmt_add_batch(stmt); + } + + taos_stmt_execute(stmt); + TAOS_RES* res = taos_stmt_use_result(stmt); + return taos_errno(res); +} + +int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) { + SHashObj* cname2points = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); for (int32_t i = 0; i < numPoints; ++i) { - TAOS_SML_DATA_POINT * point = taosArrayGet(points, i); - char tableKey[256]; - snprintf(tableKey, 256, "%s.%s", point->stableName, point->childTableName); + TAOS_SML_DATA_POINT * point = points + i; + if (!point->childTableName) { + char childTableName[TSDB_TABLE_NAME_LEN]; + int32_t tableNameLen; + getChildTableName(point, childTableName, &tableNameLen); + point->childTableName = calloc(1, tableNameLen+1); + strncpy(point->childTableName, childTableName, tableNameLen); + point->childTableName[tableNameLen] = '\0'; + } + SArray* cTablePoints = NULL; + SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName)); + if (pCTablePoints) { + cTablePoints = *pCTablePoints; + } else { + cTablePoints = taosArrayInit(64, sizeof(point)); + taosHashPut(cname2points, point->childTableName, strlen(point->childTableName), &cTablePoints, POINTER_BYTES); + } + taosArrayPush(cTablePoints, point); + } + SArray** pCTablePoints = taosHashIterate(cname2points, NULL); + while (pCTablePoints) { + SArray* cTablePoints = *pCTablePoints; + TAOS_SML_DATA_POINT * point = taosArrayGet(cTablePoints, 0); + int32_t numTags = taosArrayGetSize(point->schema->tags); + int32_t numCols = taosArrayGetSize(point->schema->fields); + char* stableName = point->stableName; + char* ctableName = point->childTableName; + char sql[TSDB_MAX_BINARY_LEN]; + getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); + + size_t rows = taosArrayGetSize(cTablePoints); + SArray* rowsBind = taosArrayInit(rows, POINTER_BYTES); + SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); + + for (int i = 0; i < rows; ++i) { + point = taosArrayGet(cTablePoints, i); + + taosArraySetSize(tagBinds, numTags); + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); + TAOS_BIND* bind = taosArrayGet(tagBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + } + + SArray* colBinds = taosArrayInit(numCols, sizeof(TAOS_BIND)); + taosArraySetSize(colBinds, numCols); + for (int j = 0; jfieldNum; ++j) { + TAOS_SML_KV* kv = point->fields + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); + TAOS_BIND* bind = taosArrayGet(colBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + } + taosArrayPush(rowsBind, &colBinds); + } + + insertBatch(taos, sql, ctableName, tagBinds, rowsBind); + + pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } return 0; } -int32_t insertBatch(TAOS* taos, const char* sTableName, char* cTableName, SSchema* tagsSchema, int numTags, TAOS_BIND* tagBind, - SSchema* colsSchema, int numCols, TAOS_MULTI_BIND* colBind) { - TAOS_STMT* stmt = taos_stmt_init(taos); - char result[TSDB_MAX_BINARY_LEN] = {0}; - sprintf(result, "insert into ? using %s(", sTableName); - for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", tagsSchema[i].name); +int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + int32_t code = TSDB_CODE_SUCCESS; + SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + SHashObj* sname2shema = taosHashInit(32, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int i = 0; i < numPoint; ++i) { + TAOS_SML_DATA_POINT* point = &points[i]; + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + SSmlSTableSchema* pStableSchema = NULL; + if (ppStableSchema) { + pStableSchema= *ppStableSchema; + } else { + SSmlSTableSchema schema; + size_t stableNameLen = strlen(point->stableName); + strncpy(schema.sTableName, point->stableName, stableNameLen); + schema.sTableName[stableNameLen] = '\0'; + schema.fields = taosArrayInit(64, sizeof(SSchema)); + schema.tags = taosArrayInit(8, sizeof(SSchema)); + schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + pStableSchema = taosArrayPush(stableArray, &schema); + taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); + } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* fieldKv = point->fields + j; + addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + } + + point->schema = pStableSchema; } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") tags ("); - for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); + size_t numStable = taosArrayGetSize(stableArray); + for (int i = 0; i < numStable; ++i) { + SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); + SSmlSTableSchema dbSchema = {0}; + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); + dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { + SSchemaAction schemaAction = {0}; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); + memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); + schemaAction.createSTable.tags = pointSchema->tags; + schemaAction.createSTable.fields = pointSchema->fields; + taosArrayPush(schemaActions, &schemaAction); + }else if (code == TSDB_CODE_SUCCESS) { + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); + size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); + + SHashObj* dbTagHash = dbSchema.tagHash; + SHashObj* dbFieldHash = dbSchema.fieldHash; + + for (int j = 0; j < pointTagSize; ++j) { + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + + for (int j = 0; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + } else { + return code; + } } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") ("); - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", colsSchema[i].name); + for (int i = 0; i < taosArrayGetSize(schemaActions); ++i) { + SSchemaAction* action = taosArrayGet(schemaActions, i); + applySchemaAction(taos, action); } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") values ("); - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); - } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ")"); - - int32_t code = 0; - code = taos_stmt_prepare(stmt, result, strlen(result)); - - code = taos_stmt_set_tbname_tags(stmt, cTableName, tagBind); - code = taos_stmt_bind_param_batch(stmt, colBind); - code = taos_stmt_execute(stmt); + insertPoints(taos, points, numPoint); return code; } + + //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check From 812c9bcc2ee923060097499d2d340de975ce6b8b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sun, 11 Jul 2021 14:43:55 +0800 Subject: [PATCH 15/65] [td-5176]: improve the twa query performance in case of interval query. --- src/query/inc/qExecutor.h | 4 +- src/query/src/qExecutor.c | 128 +++++++++++++++++--------------------- src/query/src/qUtil.c | 6 +- 3 files changed, 62 insertions(+), 76 deletions(-) diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index 7c82aa659d..9348606d0c 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -105,7 +105,7 @@ typedef struct SResultRowInfo { int16_t type:8; // data type for hash key int32_t size:24; // number of result set int32_t capacity; // max capacity - SResultRow* current; // current active result row + int32_t curPos; // current active result row index of pResult list } SResultRowInfo; typedef struct SColumnFilterElem { @@ -423,7 +423,7 @@ typedef struct STagScanInfo { SColumnInfo* pCols; SSDataBlock* pRes; int32_t totalTables; - int32_t currentIndex; + int32_t curPos; } STagScanInfo; typedef struct SOptrBasicInfo { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ea0806e541..3d585afb87 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -411,8 +411,8 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, SQueryRuntim pResultRowInfo->capacity = (int32_t)newCapacity; } -static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, int64_t tid, char *pData, - int16_t bytes, bool masterscan, uint64_t tableGroupId) { +static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid, + char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) { bool existed = false; SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tableGroupId); @@ -426,16 +426,21 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes } if (p1 != NULL) { - pResultRowInfo->current = (*p1); - if (pResultRowInfo->size == 0) { existed = false; + assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { existed = (pResultRowInfo->pResult[0] == (*p1)); + pResultRowInfo->curPos = 0; } else { // check if current pResultRowInfo contains the existed pResultRow SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid); - void* ptr = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); - existed = (ptr != NULL); + int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); + if (index != NULL) { + pResultRowInfo->curPos = (int32_t) *index; + existed = true; + } else { + existed = false; + } } } } else { @@ -462,12 +467,12 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes pResult = *p1; } + pResultRowInfo->curPos = pResultRowInfo->size; pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; - pResultRowInfo->current = pResult; - int64_t dummyVal = 0; + int64_t index = pResultRowInfo->curPos; SET_RES_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid); - taosHashPut(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &dummyVal, POINTER_BYTES); + taosHashPut(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &index, POINTER_BYTES); } // too many time window in query @@ -475,7 +480,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); } - return pResultRowInfo->current; + return pResultRowInfo->pResult[pResultRowInfo->curPos]; } static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWindow* w) { @@ -506,13 +511,8 @@ static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWin static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t ts, SQueryAttr *pQueryAttr) { STimeWindow w = {0}; - if (pResultRowInfo->current == NULL) { // the first window, from the previous stored value -// if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) { - getInitialStartTimeWindow(pQueryAttr, ts, &w); -// pResultRowInfo->prevSKey = w.skey; -// } else { -// w.skey = pResultRowInfo->prevSKey; -// } + if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value + getInitialStartTimeWindow(pQueryAttr, ts, &w); if (pQueryAttr->interval.intervalUnit == 'n' || pQueryAttr->interval.intervalUnit == 'y') { w.ekey = taosTimeAdd(w.skey, pQueryAttr->interval.interval, pQueryAttr->interval.intervalUnit, pQueryAttr->precision) - 1; @@ -520,7 +520,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t w.ekey = w.skey + pQueryAttr->interval.interval - 1; } } else { - w = pResultRowInfo->current->win; + w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win; } if (w.skey > ts || w.ekey < ts) { @@ -600,13 +600,13 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf return 0; } -static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, int64_t tid, STimeWindow *win, +static int32_t setResultOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo, int64_t tid, STimeWindow *win, bool masterscan, SResultRow **pResult, int64_t tableGroupId, SQLFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) { assert(win->skey <= win->ekey); SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf; - SResultRow *pResultRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId); + SResultRow *pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId); if (pResultRow == NULL) { *pResult = NULL; return TSDB_CODE_SUCCESS; @@ -707,9 +707,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey, if (skey == TSKEY_INITIAL_VAL) { if (pResultRowInfo->size == 0) { // assert(pResultRowInfo->current == NULL); - pResultRowInfo->current = NULL; + assert(pResultRowInfo->curPos == -1); + pResultRowInfo->curPos = -1; } else { - pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; + pResultRowInfo->curPos = pResultRowInfo->size - 1; } } else { @@ -721,9 +722,9 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey, } if (i == pResultRowInfo->size - 1) { - pResultRowInfo->current = pResultRowInfo->pResult[i]; + pResultRowInfo->curPos = i; } else { - pResultRowInfo->current = pResultRowInfo->pResult[i + 1]; // current not closed result object + pResultRowInfo->curPos = i + 1; // current not closed result object } } } @@ -732,7 +733,7 @@ static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, SQuer bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); if ((lastKey > pQueryAttr->window.ekey && ascQuery) || (lastKey < pQueryAttr->window.ekey && (!ascQuery))) { closeAllResultRows(pResultRowInfo); - pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; + pResultRowInfo->curPos = pResultRowInfo->size - 1; } else { int32_t step = ascQuery ? 1 : -1; doUpdateResultRowIndex(pResultRowInfo, lastKey - step, ascQuery, pQueryAttr->timeWindowInterpo); @@ -1241,7 +1242,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); - SResultRow* prevRow = pResultRowInfo->current; + int32_t prevIndex = pResultRowInfo->curPos; TSKEY* tsCols = NULL; if (pSDataBlock->pDataBlock != NULL) { @@ -1258,7 +1259,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul bool masterScan = IS_MASTER_SCAN(pRuntimeEnv); SResultRow* pResult = NULL; - int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1270,25 +1271,17 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul getNumOfRowsInTimeWindow(pRuntimeEnv, &pSDataBlock->info, tsCols, startPos, ekey, binarySearchForKey, true); // prev time window not interpolation yet. -// int32_t curIndex = curTimeWindowIndex(pResultRowInfo); -// if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) { -// for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. - if (prevRow != NULL && prevRow != pResultRowInfo->current && pQueryAttr->timeWindowInterpo) { - int32_t j = 0; - while(pResultRowInfo->pResult[j] != prevRow) { - j++; - } - - SResultRow* current = pResultRowInfo->current; - for(; pResultRowInfo->pResult[j] != current && j < pResultRowInfo->size; ++j) { - SResultRow* pRes = pResultRowInfo->pResult[j]; + int32_t curIndex = pResultRowInfo->curPos; + if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) { + for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. + SResultRow* pRes = getResultRow(pResultRowInfo, j); if (pRes->closed) { assert(resultRowInterpolated(pRes, RESULT_ROW_START_INTERP) && resultRowInterpolated(pRes, RESULT_ROW_END_INTERP)); continue; } STimeWindow w = pRes->win; - ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &w, masterScan, &pResult, + ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &w, masterScan, &pResult, tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1306,7 +1299,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } // restore current time window - ret = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, + ret = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &win, masterScan, &pResult, tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1326,7 +1319,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul } // null data, failed to allocate more memory buffer - int32_t code = setWindowOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &nextWin, masterScan, &pResult, tableGroupId, + int32_t code = setResultOutputBufByKey(pRuntimeEnv, pResultRowInfo, pSDataBlock->info.tid, &nextWin, masterScan, &pResult, tableGroupId, pInfo->pCtx, numOfOutput, pInfo->rowCellInfoOffset); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1467,7 +1460,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf SResultRow* pResult = NULL; pInfo->curWindow.ekey = pInfo->curWindow.skey; - int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, pBInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code @@ -1488,7 +1481,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf SResultRow* pResult = NULL; pInfo->curWindow.ekey = pInfo->curWindow.skey; - int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, pBInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code @@ -1532,7 +1525,7 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic } int64_t tid = 0; - SResultRow *pResultRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, tid, d, len, true, groupIndex); + SResultRow *pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, d, len, true, groupIndex); assert (pResultRow != NULL); setResultRowKey(pResultRow, pData, type); @@ -2779,7 +2772,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (setWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId, + if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -2825,7 +2818,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (setWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId, + if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.tid, &win, masterScan, &pResult, groupId, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->rowCellInfoOffset) != TSDB_CODE_SUCCESS) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -3181,11 +3174,11 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo *pTableQueryInfo) pTableQueryInfo->cur.vgroupIndex = -1; // set the index to be the end slot of result rows array - SResultRowInfo* pResRowInfo = &pTableQueryInfo->resInfo; - if (pResRowInfo->size > 0) { - pResRowInfo->current = pResRowInfo->pResult[pResRowInfo->size - 1]; + SResultRowInfo* pResultRowInfo = &pTableQueryInfo->resInfo; + if (pResultRowInfo->size > 0) { + pResultRowInfo->curPos = pResultRowInfo->size - 1; } else { - pResRowInfo->current = NULL; + pResultRowInfo->curPos = -1; } } @@ -3240,7 +3233,7 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo; int64_t tid = 0; - SResultRow* pRow = doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, uid); + SResultRow* pRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, uid); for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i); @@ -3477,7 +3470,7 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe int64_t tid = 0; SResultRow* pResultRow = - doPrepareResultRowFromKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid); + doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid); assert (pResultRow != NULL); /* @@ -3680,14 +3673,10 @@ void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) { STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current; SResultRowInfo *pResultRowInfo = &pTableQueryInfo->resInfo; - if (pResultRowInfo->current != NULL) { + if (pResultRowInfo->curPos != -1) { return; } -// if (pWindowResInfo->prevSKey != TSKEY_INITIAL_VAL) { -// return; -// } - pTableQueryInfo->win.skey = key; STimeWindow win = {.skey = key, .ekey = pQueryAttr->window.ekey}; @@ -4609,8 +4598,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { } if (pResultRowInfo->size > 0) { - pResultRowInfo->current = pResultRowInfo->pResult[0]; -// pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey; + pResultRowInfo->curPos = 0; } qDebug("QInfo:0x%"PRIx64" start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64, @@ -4635,8 +4623,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { pTableScanInfo->order = cond.order; if (pResultRowInfo->size > 0) { - pResultRowInfo->current = pResultRowInfo->pResult[pResultRowInfo->size - 1]; -// pResultRowInfo->prevSKey = pResultRowInfo->current->win.skey; + pResultRowInfo->curPos = pResultRowInfo->size - 1; } p = doTableScanImpl(pOperator, newgroup); @@ -5496,7 +5483,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI } else { SResultRow* pResult = NULL; pInfo->curWindow.ekey = pInfo->curWindow.skey; - int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, pBInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code @@ -5513,10 +5500,11 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI } } + SResultRow* pResult = NULL; pInfo->curWindow.ekey = pInfo->curWindow.skey; - int32_t ret = setWindowOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, + int32_t ret = setResultOutputBufByKey(pRuntimeEnv, &pBInfo->resultRowInfo, pSDataBlock->info.tid, &pInfo->curWindow, masterScan, &pResult, item->groupIndex, pBInfo->pCtx, pOperator->numOfOutput, pBInfo->rowCellInfoOffset); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code @@ -6294,8 +6282,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { SColumnInfoData* pColInfo = taosArrayGet(pRes->pDataBlock, 0); - while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) { - int32_t i = pInfo->currentIndex++; + while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) { + int32_t i = pInfo->curPos++; STableQueryInfo *item = taosArrayGetP(pa, i); char *output = pColInfo->pData + count * rsize; @@ -6339,8 +6327,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { SExprInfo* pExprInfo = pOperator->pExpr; // todo use the column list instead of exprinfo count = 0; - while(pInfo->currentIndex < pInfo->totalTables && count < maxNumOfTables) { - int32_t i = pInfo->currentIndex++; + while(pInfo->curPos < pInfo->totalTables && count < maxNumOfTables) { + int32_t i = pInfo->curPos++; STableQueryInfo* item = taosArrayGetP(pa, i); @@ -6369,7 +6357,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) { count += 1; } - if (pInfo->currentIndex >= pInfo->totalTables) { + if (pInfo->curPos >= pInfo->totalTables) { pOperator->status = OP_EXEC_DONE; } @@ -6388,7 +6376,7 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf assert(numOfGroup == 0 || numOfGroup == 1); pInfo->totalTables = pRuntimeEnv->tableqinfoGroupInfo.numOfTables; - pInfo->currentIndex = 0; + pInfo->curPos = 0; SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "SeqTableTagScan"; diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index c14f46523d..04a7079128 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -44,8 +44,7 @@ int32_t getOutputInterResultBufSize(SQueryAttr* pQueryAttr) { int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size, int16_t type) { pResultRowInfo->type = type; pResultRowInfo->size = 0; -// pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL; - pResultRowInfo->current = NULL; + pResultRowInfo->curPos = -1; pResultRowInfo->capacity = size; pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES); @@ -92,8 +91,7 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo } pResultRowInfo->size = 0; - pResultRowInfo->current = NULL; -// pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL; + pResultRowInfo->curPos = -1; } int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) { From 20c6dd70701983b8c8c798fd847bbc111f967e24 Mon Sep 17 00:00:00 2001 From: tomchon Date: Sun, 11 Jul 2021 20:51:50 +0800 Subject: [PATCH 16/65] modify dockerManifest.sh --- packaging/docker/dockerManifest.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/docker/dockerManifest.sh b/packaging/docker/dockerManifest.sh index 598bd46f13..0b30dd702c 100755 --- a/packaging/docker/dockerManifest.sh +++ b/packaging/docker/dockerManifest.sh @@ -48,11 +48,15 @@ if [ "$verType" == "beta" ]; then docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest docker login -u tdengine -p ${passWord} #replace the docker registry username and password docker manifest push tdengine/tdengine-beta:latest + docker manifest push tdengine/tdengine-beta:${version} + elif [ "$verType" == "stable" ]; then docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version} docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest docker login -u tdengine -p ${passWord} #replace the docker registry username and password docker manifest push tdengine/tdengine:latest + docker manifest push tdengine/tdengine:${version} + else echo "unknow verType, nor stabel or beta" exit 1 From 2d0005d3f179b3a4f734fd75dcd104058537a3a6 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Sun, 11 Jul 2021 23:52:19 +0800 Subject: [PATCH 17/65] before getChildTableName and insertBatch --- src/client/src/tscParseLineProtocol.c | 758 +++++++++++++++----------- src/inc/taos.h | 2 + tests/examples/c/apitest.c | 15 + 3 files changed, 447 insertions(+), 328 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 2738fe6f7a..3a88d2e906 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -15,263 +15,6 @@ #include "tskiplist.h" #include "tscUtil.h" -typedef enum { - LP_ITEM_TAG, - LP_ITEM_FIELD -} LPItemKind; - -typedef struct { - SStrToken key; - SStrToken value; - - char name[TSDB_COL_NAME_LEN]; - int8_t type; - int16_t bytes; - - char* payload; -}SLPItem; - -typedef struct { - SStrToken measToken; - SStrToken tsToken; - - char sTableName[TSDB_TABLE_NAME_LEN]; - SArray* tags; - SArray* fields; - int64_t ts; - -} SLPPoint; - -typedef enum { - LP_MEASUREMENT, - LP_TAG_KEY, - LP_TAG_VALUE, - LP_FIELD_KEY, - LP_FIELD_VALUE -} LPPart; - -int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { - for (int32_t i = start; i < s.n; ++i) { - if (s.z[i] == ',' || s.z[i] == ' ') { - *index = i; - return 0; - } - } - return -1; -} - -int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { - for (int32_t i = start; i < s.n; ++i) { - if (s.z[i] == '=') { - *index = i; - return 0; - } - } - return -1; -} - -int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { - point->measToken = token; - if (point->measToken.n < TSDB_TABLE_NAME_LEN) { - strncpy(point->sTableName, point->measToken.z, point->measToken.n); - point->sTableName[point->measToken.n] = '\0'; - } - return 0; -} - -int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { - item->key = key; - if (item->key.n < TSDB_COL_NAME_LEN) { - strncpy(item->name, item->key.z, item->key.n); - item->name[item->key.n] = '\0'; - } - return 0; -} - -int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { - item->value = value; - return 0; -} - -int32_t parseItemValue(SLPItem* item, LPItemKind kind) { - char* sv = item->value.z; - char* last = item->value.z + item->value.n - 1; - - if (isdigit(sv[0]) || sv[0] == '-') { - if (*last == 'i') { - item->type = TSDB_DATA_TYPE_BIGINT; - item->bytes = (int16_t)tDataTypes[item->type].bytes; - item->payload = malloc(item->bytes); - char* endptr = NULL; - *(item->payload) = strtoll(sv, &endptr, 10); - } else { - item->type = TSDB_DATA_TYPE_DOUBLE; - item->bytes = (int16_t)tDataTypes[item->type].bytes; - item->payload = malloc(item->bytes); - char* endptr = NULL; - *(item->payload) = strtold(sv, &endptr); - } - } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { - if (sv[0] == 'L') { - item->type = TSDB_DATA_TYPE_NCHAR; - uint32_t bytes = item->value.n - 3; -// uint32_t len = bytes; -// char* ucs = malloc(len); -// int32_t ncharBytes = 0; -// taosMbsToUcs4(sv+2, len, ucs, len, &ncharBytes); -// item->bytes = ncharBytes; -// item->payload = malloc(ncharBytes); -// memcpy(item->payload, ucs, ncharBytes); -// free(ucs); - item->bytes = bytes; - item->payload = malloc(bytes); - memcpy(item->payload, sv+1, bytes); - } else if (sv[0]=='"'){ - item->type = TSDB_DATA_TYPE_BINARY; - uint32_t bytes = item->value.n - 2; - item->bytes = bytes; - item->payload = malloc(bytes); - memcpy(item->payload, sv+1, bytes); - } - } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { - item->type = TSDB_DATA_TYPE_BOOL; - item->bytes = tDataTypes[item->type].bytes; - item->payload = malloc(tDataTypes[item->type].bytes); - *(item->payload) = tolower(sv[0])=='t' ? true : false; - } - return 0; -} - -int32_t compareLPItemKey(const void* p1, const void* p2) { - const SLPItem* t1 = p1; - const SLPItem* t2 = p2; - uint32_t min = (t1->key.n < t2->key.n) ? t1->key.n : t2->key.n; - int res = strncmp(t1->key.z, t2->key.z, min); - if (res != 0) { - return res; - } else { - return (int)(t1->key.n) - (int)(t2->key.n); - } -} - -int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { - point->tsToken = tsToken; - return 0; -} - -int32_t parsePointTime(SLPPoint* point) { - if (point->tsToken.n <= 0) { - point->ts = taosGetTimestampNs(); - } else { - char* endptr = NULL; - point->ts = strtoll(point->tsToken.z, &endptr, 10); - } - return 0; -} - -int32_t tscParseLine(SStrToken line, SLPPoint* point) { - int32_t pos = 0; - - int32_t start = 0; - int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); - if (err != 0) { - tscError("a"); - return err; - } - - SStrToken measurement = {.z = line.z+start, .n = pos-start}; - setPointMeasurement(point, measurement); - point->tags = taosArrayInit(64, sizeof(SLPItem)); - start = pos + 1; - while (line.z[start] == ',') { - SLPItem item; - - err = scanToEqual(line, start, &pos); - if (err != 0) { - tscError("b"); - goto error; - } - - SStrToken tagKey = {.z = line.z + start, .n = pos-start}; - setItemKey(&item, tagKey, LP_TAG_KEY); - - start = pos + 1; - err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); - if (err != 0) { - tscError("c"); - goto error; - } - - SStrToken tagValue = {.z = line.z + start, .n = pos-start}; - setItemValue(&item, tagValue, LP_TAG_VALUE); - - parseItemValue(&item, LP_ITEM_TAG); - taosArrayPush(point->tags, &item); - - start = pos + 1; - } - - taosArraySort(point->tags, compareLPItemKey); - - point->fields = taosArrayInit(64, sizeof(SLPItem)); - do { - SLPItem item; - err = scanToEqual(line, start, &pos); - if (err != 0) { - goto error; - } - SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; - setItemKey(&item, fieldKey, LP_FIELD_KEY); - - start = pos + 1; - err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); - if (err != 0) { - goto error; - } - SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; - setItemValue(&item, fieldValue, LP_TAG_VALUE); - - parseItemValue(&item, LP_ITEM_FIELD); - taosArrayPush(point->fields, &item); - - start = pos + 1; - } while (line.z[pos] == ','); - - taosArraySort(point->fields, compareLPItemKey); - - SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; - setPointTimeStamp(point, tsToken); - parsePointTime(point); - - goto done; - -error: - // free array - return err; -done: - return 0; -} - - -int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { - for (int32_t i = 0; i < numLines; ++i) { - SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; - SLPPoint point; - tscParseLine(tkLine, &point); - taosArrayPush(points, &point); - } - return 0; -} - -TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { - SArray* points = taosArrayInit(numLines, sizeof(SLPPoint)); - tscParseLines(lines, numLines, points, NULL); - - - return NULL; -} -//================================================================================================= - typedef struct { char sTableName[TSDB_TABLE_NAME_LEN]; SHashObj* tagHash; @@ -305,6 +48,8 @@ typedef struct { SSmlSTableSchema* schema; } TAOS_SML_DATA_POINT; +//================================================================================================= + int compareSmlColKv(const void* p1, const void* p2) { TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; @@ -318,32 +63,6 @@ int compareSmlColKv(const void* p1, const void* p2) { } } -int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { - qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); - - SStringBuilder sb; memset(&sb, 0, sizeof(sb)); - taosStringBuilderAppendString(&sb, point->stableName); - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* tagKv = point->tags + j; - taosStringBuilderAppendChar(&sb, ','); - taosStringBuilderAppendString(&sb, tagKv->key); - taosStringBuilderAppendChar(&sb, '='); - taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); - } - size_t len = 0; - char* keyJoined = taosStringBuilderGetResult(&sb, &len); - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - MD5Final(&context); - *tableNameLen = snprintf(tableName, *tableNameLen, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], - context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], - context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], - context.digest[12], context.digest[13], context.digest[14], context.digest[15]); - return 0; -} - int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { int32_t code = 0; @@ -393,15 +112,14 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { tscFreeSqlObj(pSql); - uint32_t size = tscGetTableMetaMaxSize(); STableMeta* tableMeta = calloc(1, size); taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); - tstrncpy(schema->sTableName, tableName, strlen(tableName)); + tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); for (int i=0; itableInfo.numOfColumns; ++i) { SSchema field; - tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)); + tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); field.type = tableMeta->schema[i].type; field.bytes = tableMeta->schema[i].bytes; SSchema* pField = taosArrayPush(schema->fields, &field); @@ -411,13 +129,13 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { for (int i=0; itableInfo.numOfTags; ++i) { int j = i + tableMeta->tableInfo.numOfColumns; SSchema field; - tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)); + tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)+1); field.type = tableMeta->schema[j].type; field.bytes = tableMeta->schema[j].bytes; SSchema* pField = taosArrayPush(schema->tags, &field); taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); } - + free(tableMeta); tableMeta = NULL; return code; } @@ -586,6 +304,7 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + break; } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName); @@ -631,15 +350,46 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } +int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { + qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); + + SStringBuilder sb; memset(&sb, 0, sizeof(sb)); + taosStringBuilderAppendString(&sb, point->stableName); + for (int j = 0; j < point->tagNum; ++j) { + taosStringBuilderAppendChar(&sb, ','); + TAOS_SML_KV* tagKv = point->tags + j; + taosStringBuilderAppendString(&sb, tagKv->key); + taosStringBuilderAppendChar(&sb, '='); + taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); + } + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + MD5_CTX context; + MD5Init(&context); + MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + MD5Final(&context); + *tableNameLen = snprintf(tableName, *tableNameLen, + "tbl%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + taosStringBuilderDestroy(&sb); + return 0; +} + int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { size_t numTags = taosArrayGetSize(tagsSchema); size_t numCols = taosArrayGetSize(colsSchema); - sprintf(result, "insert into ? using %s(", sTableName); - for (int i = 0; i < numTags; ++i) { - SSchema* tagSchema = taosArrayGet(tagsSchema, i); - snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") tags ("); + sprintf(result, "insert into ? using %s", sTableName); + +// snprintf(result+strlen(result), freeBytes-strlen(result), "("); +// for (int i = 0; i < numTags; ++i) { +// SSchema* tagSchema = taosArrayGet(tagsSchema, i); +// snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); +// } +// snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + + snprintf(result + strlen(result), freeBytes-strlen(result), " tags ("); for (int i = 0; i < numTags; ++i) { snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); @@ -661,17 +411,38 @@ int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsS int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { TAOS_STMT* stmt = taos_stmt_init(taos); - taos_stmt_prepare(stmt, sql, strlen(sql)); - - taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); - size_t rows = taosArrayGetSize(rowsBind); - for (int32_t i = 0; i < rows; ++i) { - TAOS_BIND* colBind = taosArrayGetP(rowsBind, i); - taos_stmt_bind_param(stmt, colBind); - taos_stmt_add_batch(stmt); + int32_t code; + code = taos_stmt_prepare(stmt, sql, strlen(sql)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; } - taos_stmt_execute(stmt); + code = taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + size_t rows = taosArrayGetSize(rowsBind); + for (int32_t i = 0; i < rows; ++i) { + SArray* colBind = taosArrayGetP(rowsBind, i); + code = taos_stmt_bind_param(stmt, TARRAY_GET_START(colBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } TAOS_RES* res = taos_stmt_use_result(stmt); return taos_errno(res); } @@ -682,7 +453,7 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) TAOS_SML_DATA_POINT * point = points + i; if (!point->childTableName) { char childTableName[TSDB_TABLE_NAME_LEN]; - int32_t tableNameLen; + int32_t tableNameLen = TSDB_TABLE_NAME_LEN; getChildTableName(point, childTableName, &tableNameLen); point->childTableName = calloc(1, tableNameLen+1); strncpy(point->childTableName, childTableName, tableNameLen); @@ -696,50 +467,62 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) cTablePoints = taosArrayInit(64, sizeof(point)); taosHashPut(cname2points, point->childTableName, strlen(point->childTableName), &cTablePoints, POINTER_BYTES); } - taosArrayPush(cTablePoints, point); + taosArrayPush(cTablePoints, &point); } + int isNullColBind = TSDB_TRUE; SArray** pCTablePoints = taosHashIterate(cname2points, NULL); while (pCTablePoints) { SArray* cTablePoints = *pCTablePoints; - TAOS_SML_DATA_POINT * point = taosArrayGet(cTablePoints, 0); + + TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); int32_t numTags = taosArrayGetSize(point->schema->tags); int32_t numCols = taosArrayGetSize(point->schema->fields); char* stableName = point->stableName; char* ctableName = point->childTableName; - char sql[TSDB_MAX_BINARY_LEN]; - getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); + + SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); + taosArraySetSize(tagBinds, numTags); + for (int j = 0; j < numTags; ++j) { + TAOS_BIND* bind = taosArrayGet(tagBinds, j); + bind->is_null = &isNullColBind; + } + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); + TAOS_BIND* bind = taosArrayGet(tagBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + bind->is_null = NULL; + } size_t rows = taosArrayGetSize(cTablePoints); SArray* rowsBind = taosArrayInit(rows, POINTER_BYTES); - SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); for (int i = 0; i < rows; ++i) { - point = taosArrayGet(cTablePoints, i); - - taosArraySetSize(tagBinds, numTags); - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* kv = point->tags + j; - int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); - TAOS_BIND* bind = taosArrayGet(tagBinds, idx); - bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; - bind->buffer = kv->value; - } + point = taosArrayGetP(cTablePoints, i); SArray* colBinds = taosArrayInit(numCols, sizeof(TAOS_BIND)); taosArraySetSize(colBinds, numCols); - for (int j = 0; jfieldNum; ++j) { + for (int j = 0; j < numCols; ++j) { + TAOS_BIND* bind = taosArrayGet(colBinds, j); + bind->is_null = &isNullColBind; + } + for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* kv = point->fields + j; int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); TAOS_BIND* bind = taosArrayGet(colBinds, idx); bind->buffer_type = kv->type; bind->length = (uintptr_t*)&kv->length; bind->buffer = kv->value; + bind->is_null = NULL; } taosArrayPush(rowsBind, &colBinds); } + char sql[TSDB_MAX_BINARY_LEN]; + getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); insertBatch(taos, sql, ctableName, tagBinds, rowsBind); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); @@ -747,7 +530,6 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) return 0; } - int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { int32_t code = TSDB_CODE_SUCCESS; SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray @@ -792,11 +574,13 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); SSmlSTableSchema dbSchema = {0}; - dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { SSchemaAction schemaAction = {0}; schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; @@ -813,19 +597,23 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { SHashObj* dbFieldHash = dbSchema.fieldHash; for (int j = 0; j < pointTagSize; ++j) { - SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); SSchemaAction schemaAction = {0}; - bool actionNeeded = false; + bool actionNeeded = false; generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { taosArrayPush(schemaActions, &schemaAction); } } - for (int j = 0; j < pointFieldSize; ++j) { - SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchema* pointColTs = taosArrayGet(pointSchema->fields, 0); + SSchema* dbColTs = taosArrayGet(dbSchema.fields, 0); + memcpy(pointColTs->name, dbColTs->name, TSDB_COL_NAME_LEN); + + for (int j = 1; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->fields, j); SSchemaAction schemaAction = {0}; - bool actionNeeded = false; + bool actionNeeded = false; generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { taosArrayPush(schemaActions, &schemaAction); @@ -849,3 +637,317 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check + +//========================================================================= + +typedef enum { + LP_ITEM_TAG, + LP_ITEM_FIELD +} LPItemKind; + +typedef struct { + SStrToken keyToken; + SStrToken valueToken; + + char key[TSDB_COL_NAME_LEN]; + int8_t type; + int16_t length; + + char* value; +}SLPItem; + +typedef struct { + SStrToken measToken; + SStrToken tsToken; + + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; + SArray* fields; + int64_t ts; + +} SLPPoint; + +typedef enum { + LP_MEASUREMENT, + LP_TAG_KEY, + LP_TAG_VALUE, + LP_FIELD_KEY, + LP_FIELD_VALUE +} LPPart; + +int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == ',' || s.z[i] == ' ') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == '=') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { + point->measToken = token; + if (point->measToken.n < TSDB_TABLE_NAME_LEN) { + strncpy(point->sTableName, point->measToken.z, point->measToken.n); + point->sTableName[point->measToken.n] = '\0'; + } + return 0; +} + +int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { + item->keyToken = key; + if (item->keyToken.n < TSDB_COL_NAME_LEN) { + strncpy(item->key, item->keyToken.z, item->keyToken.n); + item->key[item->keyToken.n] = '\0'; + } + return 0; +} + +int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { + item->valueToken = value; + return 0; +} + +int32_t parseItemValue(SLPItem* item, LPItemKind kind) { + char* sv = item->valueToken.z; + char* last = item->valueToken.z + item->valueToken.n - 1; + + if (isdigit(sv[0]) || sv[0] == '-') { + if (*last == 'i') { + item->type = TSDB_DATA_TYPE_BIGINT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(item->value) = strtoll(sv, &endptr, 10); + } else { + item->type = TSDB_DATA_TYPE_DOUBLE; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(item->value) = strtold(sv, &endptr); + } + } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { + if (sv[0] == 'L') { + item->type = TSDB_DATA_TYPE_NCHAR; + uint32_t bytes = item->valueToken.n - 3; + item->length = bytes; + item->value = malloc(bytes); + memcpy(item->value, sv+1, bytes); + } else if (sv[0]=='"'){ + item->type = TSDB_DATA_TYPE_BINARY; + uint32_t bytes = item->valueToken.n - 2; + item->length = bytes; + item->value = malloc(bytes); + memcpy(item->value, sv+1, bytes); + } + } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { + item->type = TSDB_DATA_TYPE_BOOL; + item->length = tDataTypes[item->type].bytes; + item->value = malloc(tDataTypes[item->type].bytes); + *(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; + } + return 0; +} + +int32_t compareLPItemKey(const void* p1, const void* p2) { + const SLPItem* t1 = p1; + const SLPItem* t2 = p2; + uint32_t min = (t1->keyToken.n < t2->keyToken.n) ? t1->keyToken.n : t2->keyToken.n; + int res = strncmp(t1->keyToken.z, t2->keyToken.z, min); + if (res != 0) { + return res; + } else { + return (int)(t1->keyToken.n) - (int)(t2->keyToken.n); + } +} + +int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { + point->tsToken = tsToken; + return 0; +} + +int32_t parsePointTime(SLPPoint* point) { + if (point->tsToken.n <= 0) { + point->ts = taosGetTimestampNs(); + } else { + char* endptr = NULL; + point->ts = strtoll(point->tsToken.z, &endptr, 10); + } + return 0; +} + +int32_t tscParseLine(SStrToken line, SLPPoint* point) { + int32_t pos = 0; + + int32_t start = 0; + int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); + if (err != 0) { + tscError("a"); + return err; + } + + SStrToken measurement = {.z = line.z+start, .n = pos-start}; + setPointMeasurement(point, measurement); + point->tags = taosArrayInit(64, sizeof(SLPItem)); + start = pos; + while (line.z[start] == ',') { + SLPItem item; + + start++; + err = scanToEqual(line, start, &pos); + if (err != 0) { + tscError("b"); + goto error; + } + + SStrToken tagKey = {.z = line.z + start, .n = pos-start}; + setItemKey(&item, tagKey, LP_TAG_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); + if (err != 0) { + tscError("c"); + goto error; + } + + SStrToken tagValue = {.z = line.z + start, .n = pos-start}; + setItemValue(&item, tagValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_TAG); + taosArrayPush(point->tags, &item); + + start = pos; + } + + taosArraySort(point->tags, compareLPItemKey); + + point->fields = taosArrayInit(64, sizeof(SLPItem)); + + start++; + do { + SLPItem item; + + err = scanToEqual(line, start, &pos); + if (err != 0) { + goto error; + } + SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; + setItemKey(&item, fieldKey, LP_FIELD_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); + if (err != 0) { + goto error; + } + SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; + setItemValue(&item, fieldValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_FIELD); + taosArrayPush(point->fields, &item); + + start = pos + 1; + } while (line.z[pos] == ','); + + taosArraySort(point->fields, compareLPItemKey); + + SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; + setPointTimeStamp(point, tsToken); + parsePointTime(point); + + goto done; + + error: + // free array + return err; + done: + return 0; +} + + +int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { + for (int32_t i = 0; i < numLines; ++i) { + SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; + SLPPoint point; + tscParseLine(tkLine, &point); + taosArrayPush(points, &point); + } + return 0; +} + +int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { + SArray* lpPoints = taosArrayInit(numLines, sizeof(SLPPoint)); + tscParseLines(lines, numLines, lpPoints, NULL); + + size_t numPoints = taosArrayGetSize(lpPoints); + TAOS_SML_DATA_POINT* points = calloc(numPoints, sizeof(TAOS_SML_DATA_POINT)); + for (int i = 0; i < numPoints; ++i) { + SLPPoint* lpPoint = taosArrayGet(lpPoints, i); + TAOS_SML_DATA_POINT* point = points+i; + point->stableName = calloc(1, strlen(lpPoint->sTableName)+1); + strncpy(point->stableName, lpPoint->sTableName, strlen(lpPoint->sTableName)); + point->stableName[strlen(lpPoint->sTableName)] = '\0'; + + size_t lpTagSize = taosArrayGetSize(lpPoint->tags); + point->tags = calloc(lpTagSize, sizeof(TAOS_SML_KV)); + point->tagNum = lpTagSize; + for (int j=0; jtags, j); + TAOS_SML_KV* tagKv = point->tags + j; + + size_t kenLen = strlen(lpTag->key); + tagKv->key = calloc(1, kenLen+1); + strncpy(tagKv->key, lpTag->key, kenLen); + tagKv->key[kenLen] = '\0'; + + tagKv->type = lpTag->type; + tagKv->length = lpTag->length; + tagKv->value = malloc(tagKv->length); + memcpy(tagKv->value, lpTag->value, tagKv->length); + } + + size_t lpFieldsSize = taosArrayGetSize(lpPoint->fields); + point->fields = calloc(lpFieldsSize + 1, sizeof(TAOS_SML_KV)); + point->fieldNum = lpFieldsSize + 1; + + TAOS_SML_KV* tsField = point->fields + 0; + char tsKey[256]; + snprintf(tsKey, 256, "_%s_ts", point->stableName); + size_t tsKeyLen = strlen(tsKey); + tsField->key = calloc(1, tsKeyLen+1); + strncpy(tsField->key, tsKey, tsKeyLen); + tsField->key[tsKeyLen] = '\0'; + tsField->type = TSDB_DATA_TYPE_TIMESTAMP; + tsField->length = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + tsField->value = malloc(tsField->length); + memcpy(tsField->value, &(lpPoint->ts), tsField->length); + + for (int j=0; jfields, j); + TAOS_SML_KV* fieldKv = point->fields + j + 1; + + size_t kenLen = strlen(lpField->key); + fieldKv->key = calloc(1, kenLen+1); + strncpy(fieldKv->key, lpField->key, kenLen); + fieldKv->key[kenLen] = '\0'; + + fieldKv->type = lpField->type; + fieldKv->length = lpField->length; + fieldKv->value = malloc(fieldKv->length); + memcpy(fieldKv->value, lpField->value, fieldKv->length); + } + } + + taos_sml_insert(taos, points, numPoints); + return 0; +} + diff --git a/src/inc/taos.h b/src/inc/taos.h index 9f72945ef0..ca18c4fb93 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -169,6 +169,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); +DLL_EXPORT int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines); + #ifdef __cplusplus } #endif diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 0f24df0f47..dc77677774 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -949,6 +949,15 @@ void verify_stream(TAOS* taos) { taos_close_stream(strm); } +int32_t verify_schema_less(TAOS* taos) { + prepare_data(taos); + char* lines[] = { + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639162922" + }; + int code = taos_insert_by_lines(taos, lines , 1); + return code; +} + int main(int argc, char *argv[]) { const char* host = "127.0.0.1"; const char* user = "root"; @@ -967,6 +976,12 @@ int main(int argc, char *argv[]) { info = taos_get_client_info(taos); printf("client info: %s\n", info); + printf("************ verify query *************\n"); + int code = verify_schema_less(taos); + if (code == 0) { + return code; + } + printf("************ verify query *************\n"); verify_query(taos); From cb5a0012f411675b7d5a40d0ec6cd88361c157ec Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 00:39:16 +0800 Subject: [PATCH 18/65] before time precision and create table with tags instead of autocreate --- src/client/src/tscParseLineProtocol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 3a88d2e906..4b9191a91f 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -492,7 +492,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); TAOS_BIND* bind = taosArrayGet(tagBinds, idx); bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; + bind->length = malloc(sizeof(uintptr_t*)); + *bind->length = kv->length; bind->buffer = kv->value; bind->is_null = NULL; } @@ -514,7 +515,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); TAOS_BIND* bind = taosArrayGet(colBinds, idx); bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; + bind->length = malloc(sizeof(uintptr_t*)); + *bind->length = kv->length; bind->buffer = kv->value; bind->is_null = NULL; } From 3d25ecdf29c3d912bb91e81f47c72b97fb737cea Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 08:38:51 +0800 Subject: [PATCH 19/65] can add two lines of one supertable/diffrent subtable --- src/client/src/tscParseLineProtocol.c | 12 ++++++------ tests/examples/c/apitest.c | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 4b9191a91f..1fde741c2b 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -540,13 +540,13 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { for (int i = 0; i < numPoint; ++i) { TAOS_SML_DATA_POINT* point = &points[i]; - SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + size_t stableNameLen = strlen(point->stableName); + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, stableNameLen); SSmlSTableSchema* pStableSchema = NULL; if (ppStableSchema) { pStableSchema= *ppStableSchema; } else { SSmlSTableSchema schema; - size_t stableNameLen = strlen(point->stableName); strncpy(schema.sTableName, point->stableName, stableNameLen); schema.sTableName[stableNameLen] = '\0'; schema.fields = taosArrayInit(64, sizeof(SSchema)); @@ -730,13 +730,13 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(item->value) = strtoll(sv, &endptr, 10); + *(int64_t*)(item->value) = strtoll(sv, &endptr, 10); } else { item->type = TSDB_DATA_TYPE_DOUBLE; item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(item->value) = strtold(sv, &endptr); + *(double*)(item->value) = strtold(sv, &endptr); } } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { if (sv[0] == 'L') { @@ -744,7 +744,7 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { uint32_t bytes = item->valueToken.n - 3; item->length = bytes; item->value = malloc(bytes); - memcpy(item->value, sv+1, bytes); + memcpy(item->value, sv+2, bytes); } else if (sv[0]=='"'){ item->type = TSDB_DATA_TYPE_BINARY; uint32_t bytes = item->valueToken.n - 2; @@ -756,7 +756,7 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->type = TSDB_DATA_TYPE_BOOL; item->length = tDataTypes[item->type].bytes; item->value = malloc(tDataTypes[item->type].bytes); - *(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; + *(uint8_t*)(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; } return 0; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index dc77677774..04a03df6fa 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -952,9 +952,11 @@ void verify_stream(TAOS* taos) { int32_t verify_schema_less(TAOS* taos) { prepare_data(taos); char* lines[] = { - "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639162922" + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" }; - int code = taos_insert_by_lines(taos, lines , 1); + int code = taos_insert_by_lines(taos, lines , 2); return code; } @@ -976,7 +978,7 @@ int main(int argc, char *argv[]) { info = taos_get_client_info(taos); printf("client info: %s\n", info); - printf("************ verify query *************\n"); + printf("************ verify shemaless *************\n"); int code = verify_schema_less(taos); if (code == 0) { return code; From 4a75ebe4afacbcce488ec35fbdefc5e900ca781f Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 09:17:15 +0800 Subject: [PATCH 20/65] create child table with tags --- src/client/src/tscParseLineProtocol.c | 87 +++++++++++++++++---------- tests/examples/c/apitest.c | 2 +- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 1fde741c2b..dd0e64ba84 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -377,39 +377,26 @@ int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tabl return 0; } -int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { +int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind) { size_t numTags = taosArrayGetSize(tagsSchema); - size_t numCols = taosArrayGetSize(colsSchema); - sprintf(result, "insert into ? using %s", sTableName); + char sql[TSDB_MAX_BINARY_LEN] = {0}; + int freeBytes = TSDB_MAX_BINARY_LEN; + sprintf(sql, "create table if not exists %s using %s", cTableName, sTableName); -// snprintf(result+strlen(result), freeBytes-strlen(result), "("); -// for (int i = 0; i < numTags; ++i) { -// SSchema* tagSchema = taosArrayGet(tagsSchema, i); -// snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); -// } -// snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "("); + for (int i = 0; i < numTags; ++i) { + SSchema* tagSchema = taosArrayGet(tagsSchema, i); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", tagSchema->name); + } + snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")"); - snprintf(result + strlen(result), freeBytes-strlen(result), " tags ("); + snprintf(sql + strlen(sql), freeBytes-strlen(sql), " tags ("); for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") ("); + snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")"); - for (int i = 0; i < numCols; ++i) { - SSchema* colSchema = taosArrayGet(colsSchema, i); - snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", colSchema->name); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") values ("); - - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); - return 0; -} - -int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { TAOS_STMT* stmt = taos_stmt_init(taos); int32_t code; code = taos_stmt_prepare(stmt, sql, strlen(sql)); @@ -418,7 +405,47 @@ int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, S return code; } - code = taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + TAOS_RES* res = taos_stmt_use_result(stmt); + return taos_errno(res); +} + +int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) { + size_t numCols = taosArrayGetSize(colsSchema); + char sql[TSDB_MAX_BINARY_LEN]; + int32_t freeBytes = TSDB_MAX_BINARY_LEN; + sprintf(sql, "insert into ? ("); + + for (int i = 0; i < numCols; ++i) { + SSchema* colSchema = taosArrayGet(colsSchema, i); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", colSchema->name); + } + snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); + } + snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")"); + + TAOS_STMT* stmt = taos_stmt_init(taos); + int32_t code; + code = taos_stmt_prepare(stmt, sql, strlen(sql)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + + code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { printf("%s", taos_stmt_errstr(stmt)); return code; @@ -478,7 +505,6 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); int32_t numTags = taosArrayGetSize(point->schema->tags); int32_t numCols = taosArrayGetSize(point->schema->fields); - char* stableName = point->stableName; char* ctableName = point->childTableName; SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); @@ -523,9 +549,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) taosArrayPush(rowsBind, &colBinds); } - char sql[TSDB_MAX_BINARY_LEN]; - getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); - insertBatch(taos, sql, ctableName, tagBinds, rowsBind); + creatChildTableIfNotExists(taos, point->childTableName, point->stableName, point->schema->tags, tagBinds); + insertBatch(taos, ctableName, point->schema->fields, rowsBind); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 04a03df6fa..5272dafaf1 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -956,7 +956,7 @@ int32_t verify_schema_less(TAOS* taos) { "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" }; - int code = taos_insert_by_lines(taos, lines , 2); + int code = taos_insert_by_lines(taos, lines , 3); return code; } From 62e4b0b599ba7a066cd6a0be435c60bac3a3cabd Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 10:16:30 +0800 Subject: [PATCH 21/65] add timestamp precision support --- src/client/src/tscParseLineProtocol.c | 39 ++++++++++++++++++++------- tests/examples/c/apitest.c | 18 +++++++++---- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index dd0e64ba84..c0cc2ea3ae 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -21,6 +21,7 @@ typedef struct { SHashObj* fieldHash; SArray* tags; //SArray SArray* fields; //SArray + uint8_t precision; } SSmlSTableSchema; typedef struct { @@ -117,6 +118,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); + schema->precision = tableMeta->tableInfo.precision; for (int i=0; itableInfo.numOfColumns; ++i) { SSchema field; tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); @@ -486,6 +488,25 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) strncpy(point->childTableName, childTableName, tableNameLen); point->childTableName[tableNameLen] = '\0'; } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision); + *(int64_t*)(kv->value) = ts; + } + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* kv = point->fields + j; + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision); + *(int64_t*)(kv->value) = ts; + } + } + SArray* cTablePoints = NULL; SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName)); if (pCTablePoints) { @@ -596,7 +617,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { point->schema = pStableSchema; } - SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); size_t numStable = taosArrayGetSize(stableArray); for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); @@ -615,8 +635,10 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); schemaAction.createSTable.tags = pointSchema->tags; schemaAction.createSTable.fields = pointSchema->fields; - taosArrayPush(schemaActions, &schemaAction); - }else if (code == TSDB_CODE_SUCCESS) { + applySchemaAction(taos, &schemaAction); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + pointSchema->precision = dbSchema.precision; + } else if (code == TSDB_CODE_SUCCESS) { size_t pointTagSize = taosArrayGetSize(pointSchema->tags); size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); @@ -629,7 +651,7 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { bool actionNeeded = false; generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); + applySchemaAction(taos, &schemaAction); } } @@ -643,19 +665,16 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { bool actionNeeded = false; generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); + applySchemaAction(taos, &schemaAction); } } + + pointSchema->precision = dbSchema.precision; } else { return code; } } - for (int i = 0; i < taosArrayGetSize(schemaActions); ++i) { - SSchemaAction* action = taosArrayGet(schemaActions, i); - applySchemaAction(taos, action); - } - insertPoints(taos, points, numPoint); return code; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 5272dafaf1..656d5fd217 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) { result = taos_query(taos, "drop database if exists test;"); taos_free_result(result); usleep(100000); - result = taos_query(taos, "create database test;"); + result = taos_query(taos, "create database test precision 'us';"); taos_free_result(result); usleep(100000); taos_select_db(taos, "test"); @@ -950,11 +950,19 @@ void verify_stream(TAOS* taos) { } int32_t verify_schema_less(TAOS* taos) { - prepare_data(taos); + TAOS_RES *result; + result = taos_query(taos, "drop database if exists test;"); + taos_free_result(result); + usleep(100000); + result = taos_query(taos, "create database test precision 'us';"); + taos_free_result(result); + usleep(100000); + taos_select_db(taos, "test"); + char* lines[] = { - "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000" }; int code = taos_insert_by_lines(taos, lines , 3); return code; From d8c57f0be0bb51f2a81157f12d8885f5afa70f23 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 10:30:54 +0800 Subject: [PATCH 22/65] fixing exsiting stable --- src/client/src/tscParseLineProtocol.c | 2 +- tests/examples/c/apitest.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index c0cc2ea3ae..61f9cd9e76 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -225,7 +225,7 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], SSchemaAction* action, bool* actionNeeded) { SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name)); - if (*ppDbAttr) { + if (ppDbAttr) { SSchema* dbAttr = *ppDbAttr; if (pointColField->type != dbAttr->type) { //todo error diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 656d5fd217..5cb3f5762a 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -958,13 +958,15 @@ int32_t verify_schema_less(TAOS* taos) { taos_free_result(result); usleep(100000); taos_select_db(taos, "test"); + result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)"); char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000" + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", + "ste,t2=5,t3=L\"ste\" c1=true,c2=4 1626056811823316532" }; - int code = taos_insert_by_lines(taos, lines , 3); + int code = taos_insert_by_lines(taos, lines , 4); return code; } From 958b89b4630c11c3c2c360d7d757c82213862461 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 11:27:34 +0800 Subject: [PATCH 23/65] before tsim/log/memory leak handling --- tests/examples/c/apitest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 5cb3f5762a..409140e0f2 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -957,16 +957,20 @@ int32_t verify_schema_less(TAOS* taos) { result = taos_query(taos, "create database test precision 'us';"); taos_free_result(result); usleep(100000); + taos_select_db(taos, "test"); result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)"); + taos_free_result(result); + usleep(100000); char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", - "ste,t2=5,t3=L\"ste\" c1=true,c2=4 1626056811823316532" + "ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532", + "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - int code = taos_insert_by_lines(taos, lines , 4); + int code = taos_insert_by_lines(taos, lines , 5); return code; } From 64fb524796c4746a1a75f5a5fac29021305686d1 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 6 Jul 2021 18:05:27 +0800 Subject: [PATCH 24/65] develop schemaless --- src/client/src/tscParseLineProtocol.c | 731 ++++++++++++++++++++++++++ 1 file changed, 731 insertions(+) create mode 100644 src/client/src/tscParseLineProtocol.c diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c new file mode 100644 index 0000000000..79e8955f9a --- /dev/null +++ b/src/client/src/tscParseLineProtocol.c @@ -0,0 +1,731 @@ +#include +#include +#include +#include +#include "os.h" +#include "osString.h" +#include "ttype.h" +#include "tmd5.h" +#include "tstrbuild.h" +#include "tname.h" +#include "taos.h" +#include "tsclient.h" +#include "tscLog.h" +#include "hash.h" +#include "tskiplist.h" +#include "tscUtil.h" + +typedef enum { + LP_ITEM_TAG, + LP_ITEM_FIELD +} LPItemKind; + +typedef struct { + SStrToken key; + SStrToken value; + + char name[TSDB_COL_NAME_LEN]; + int8_t type; + int16_t bytes; + + char* payload; +}SLPItem; + +typedef struct { + SStrToken measToken; + SStrToken tsToken; + + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; + SArray* fields; + int64_t ts; + +} SLPPoint; + +typedef enum { + LP_MEASUREMENT, + LP_TAG_KEY, + LP_TAG_VALUE, + LP_FIELD_KEY, + LP_FIELD_VALUE +} LPPart; + +int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == ',' || s.z[i] == ' ') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == '=') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { + point->measToken = token; + if (point->measToken.n < TSDB_TABLE_NAME_LEN) { + strncpy(point->sTableName, point->measToken.z, point->measToken.n); + point->sTableName[point->measToken.n] = '\0'; + } + return 0; +} + +int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { + item->key = key; + if (item->key.n < TSDB_COL_NAME_LEN) { + strncpy(item->name, item->key.z, item->key.n); + item->name[item->key.n] = '\0'; + } + return 0; +} + +int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { + item->value = value; + return 0; +} + +int32_t parseItemValue(SLPItem* item, LPItemKind kind) { + char* sv = item->value.z; + char* last = item->value.z + item->value.n - 1; + + if (isdigit(sv[0]) || sv[0] == '-') { + if (*last == 'i') { + item->type = TSDB_DATA_TYPE_BIGINT; + item->bytes = (int16_t)tDataTypes[item->type].bytes; + item->payload = malloc(item->bytes); + char* endptr = NULL; + *(item->payload) = strtoll(sv, &endptr, 10); + } else { + item->type = TSDB_DATA_TYPE_DOUBLE; + item->bytes = (int16_t)tDataTypes[item->type].bytes; + item->payload = malloc(item->bytes); + char* endptr = NULL; + *(item->payload) = strtold(sv, &endptr); + } + } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { + if (sv[0] == 'L') { + item->type = TSDB_DATA_TYPE_NCHAR; + uint32_t bytes = item->value.n - 3; +// uint32_t len = bytes; +// char* ucs = malloc(len); +// int32_t ncharBytes = 0; +// taosMbsToUcs4(sv+2, len, ucs, len, &ncharBytes); +// item->bytes = ncharBytes; +// item->payload = malloc(ncharBytes); +// memcpy(item->payload, ucs, ncharBytes); +// free(ucs); + item->bytes = bytes; + item->payload = malloc(bytes); + memcpy(item->payload, sv+1, bytes); + } else if (sv[0]=='"'){ + item->type = TSDB_DATA_TYPE_BINARY; + uint32_t bytes = item->value.n - 2; + item->bytes = bytes; + item->payload = malloc(bytes); + memcpy(item->payload, sv+1, bytes); + } + } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { + item->type = TSDB_DATA_TYPE_BOOL; + item->bytes = tDataTypes[item->type].bytes; + item->payload = malloc(tDataTypes[item->type].bytes); + *(item->payload) = tolower(sv[0])=='t' ? true : false; + } + return 0; +} + +int32_t compareLPItemKey(const void* p1, const void* p2) { + const SLPItem* t1 = p1; + const SLPItem* t2 = p2; + uint32_t min = (t1->key.n < t2->key.n) ? t1->key.n : t2->key.n; + int res = strncmp(t1->key.z, t2->key.z, min); + if (res != 0) { + return res; + } else { + return (int)(t1->key.n) - (int)(t2->key.n); + } +} + +int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { + point->tsToken = tsToken; + return 0; +} + +int32_t parsePointTime(SLPPoint* point) { + if (point->tsToken.n <= 0) { + point->ts = taosGetTimestampNs(); + } else { + char* endptr = NULL; + point->ts = strtoll(point->tsToken.z, &endptr, 10); + } + return 0; +} + +int32_t tscParseLine(SStrToken line, SLPPoint* point) { + int32_t pos = 0; + + int32_t start = 0; + int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); + if (err != 0) { + tscError("a"); + return err; + } + + SStrToken measurement = {.z = line.z+start, .n = pos-start}; + setPointMeasurement(point, measurement); + point->tags = taosArrayInit(64, sizeof(SLPItem)); + start = pos + 1; + while (line.z[start] == ',') { + SLPItem item; + + err = scanToEqual(line, start, &pos); + if (err != 0) { + tscError("b"); + goto error; + } + + SStrToken tagKey = {.z = line.z + start, .n = pos-start}; + setItemKey(&item, tagKey, LP_TAG_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); + if (err != 0) { + tscError("c"); + goto error; + } + + SStrToken tagValue = {.z = line.z + start, .n = pos-start}; + setItemValue(&item, tagValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_TAG); + taosArrayPush(point->tags, &item); + + start = pos + 1; + } + + taosArraySort(point->tags, compareLPItemKey); + + point->fields = taosArrayInit(64, sizeof(SLPItem)); + do { + SLPItem item; + err = scanToEqual(line, start, &pos); + if (err != 0) { + goto error; + } + SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; + setItemKey(&item, fieldKey, LP_FIELD_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); + if (err != 0) { + goto error; + } + SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; + setItemValue(&item, fieldValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_FIELD); + taosArrayPush(point->fields, &item); + + start = pos + 1; + } while (line.z[pos] == ','); + + taosArraySort(point->fields, compareLPItemKey); + + SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; + setPointTimeStamp(point, tsToken); + parsePointTime(point); + + goto done; + +error: + // free array + return err; +done: + return 0; +} + + +int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { + for (int32_t i = 0; i < numLines; ++i) { + SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; + SLPPoint point; + tscParseLine(tkLine, &point); + taosArrayPush(points, &point); + } + return 0; +} + +TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { + SArray* points = taosArrayInit(numLines, sizeof(SLPPoint)); + tscParseLines(lines, numLines, points, NULL); + + + return NULL; +} +//================================================================================================= + +typedef struct { + char* key; + uint8_t type; + int16_t length; + char* value; +} TAOS_SML_KV; + +typedef struct { + char* stableName; + + char* childTableName; + TAOS_SML_KV* tags; + int tagNum; + + // first kv must be timestamp + TAOS_SML_KV* fields; + int fieldNum; + +} TAOS_SML_DATA_POINT; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SHashObj* tagHash; + SHashObj* fieldHash; + SArray* tags; //SArray + SArray* fields; //SArray +} SSmlSTableSchema; + + +int compareSmlColKv(const void* p1, const void* p2) { + TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; + TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; + int kvLen1 = (int)strlen(kv1->key); + int kvLen2 = (int)strlen(kv2->key); + int res = strncasecmp(kv1->key, kv2->key, MIN(kvLen1, kvLen2)); + if (res != 0) { + return res; + } else { + return kvLen1-kvLen2; + } +} + +int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { + qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); + + SStringBuilder sb; memset(&sb, 0, sizeof(sb)); + taosStringBuilderAppendString(&sb, point->stableName); + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + taosStringBuilderAppendChar(&sb, ','); + taosStringBuilderAppendString(&sb, tagKv->key); + taosStringBuilderAppendChar(&sb, '='); + taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); + } + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + MD5_CTX context; + MD5Init(&context); + MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + MD5Final(&context); + *tableNameLen = snprintf(tableName, *tableNameLen, + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + return 0; +} + +int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { + int32_t code = 0; + + STscObj *pObj = (STscObj *)taos; + if (pObj == NULL || pObj->signature != pObj) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + char sql[256]; + snprintf(sql, 256, "describe %s", tableName); + TAOS_RES* res = taos_query(taos, sql); + code = taos_errno(res); + if (code != 0) { + taos_free_result(res); + return code; + } + taos_free_result(res); + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + pSql->pTscObj = taos; + pSql->signature = pSql; + pSql->fp = NULL; + + SStrToken tableToken = {.z=tableName, .n=strlen(tableName), .type=TK_ID}; + tGetToken(tableName, &tableToken.type); + // Check if the table name available or not + if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { + code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; + sprintf(pSql->cmd.payload, "table name is invalid"); + return code; + } + + SName sname = {0}; + if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { + return code; + } + + char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; + memset(fullTableName, 0, tListLen(fullTableName)); + tNameExtractFullName(&sname, fullTableName); + + if (code != TSDB_CODE_SUCCESS) { + tscFreeSqlObj(pSql); + return code; + } + + tscFreeSqlObj(pSql); + + + uint32_t size = tscGetTableMetaMaxSize(); + STableMeta* tableMeta = calloc(1, size); + taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); + + tstrncpy(schema->sTableName, tableName, strlen(tableName)); + for (int i=0; itableInfo.numOfColumns; ++i) { + SSchema field; + tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)); + field.type = tableMeta->schema[i].type; + field.bytes = tableMeta->schema[i].bytes; + SSchema* pField = taosArrayPush(schema->fields, &field); + taosHashPut(schema->fieldHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + + for (int i=0; itableInfo.numOfTags; ++i) { + int j = i + tableMeta->tableInfo.numOfColumns; + SSchema field; + tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)); + field.type = tableMeta->schema[j].type; + field.bytes = tableMeta->schema[j].bytes; + SSchema* pField = taosArrayPush(schema->tags, &field); + taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + + return code; + +} + +typedef enum { + SCHEMA_ACTION_CREATE_STABLE, + SCHEMA_ACTION_ADD_COLUMN, + SCHEMA_ACTION_ADD_TAG, + SCHEMA_ACTION_CHANGE_COLUMN_SIZE, + SCHEMA_ACTION_CHANGE_TAG_SIZE, + SCHEMA_ACTION_CREATE_CTABLE +} ESchemaAction; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; //SArray + SArray* fields; //SArray +} SCreateSTableActionInfo; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SSchema* field; +} SAlterSTableActionInfo; + +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + char cTableName[TSDB_TABLE_NAME_LEN]; + TAOS_SML_KV* tags; + int tagNum; +} SCreateCTableActionInfo; + +typedef struct { + ESchemaAction action; + union { + SCreateSTableActionInfo createSTable; + SAlterSTableActionInfo alterSTable; + SCreateCTableActionInfo createCTable; + }; +} SSchemaAction; + +int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { + if (!IS_VAR_DATA_TYPE(kv->type)) { + *bytes = tDataTypes[kv->type].bytes; + } else { + if (kv->type == TSDB_DATA_TYPE_NCHAR) { + char* ucs = malloc(kv->length * TSDB_NCHAR_SIZE + 1); + int32_t bytesNeeded = 0; + //todo check conversion succeed + taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); + free(ucs); + *bytes = bytesNeeded + VARSTR_HEADER_SIZE; + + } else if (kv->type == TSDB_DATA_TYPE_BINARY) { + *bytes = kv->length + VARSTR_HEADER_SIZE; + } + } + return 0; +} + +int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) { + SSchema* pField = NULL; + SSchema** ppField = taosHashGet(hash, smlKv->key, strlen(smlKv->key)); + if (ppField) { + pField = *ppField; + + if (pField->type != smlKv->type) { + //TODO: + tscError("type mismatch"); + return -1; + } + + int32_t bytes = 0; + getFieldBytesFromSmlKv(smlKv, &bytes); + pField->bytes = MAX(pField->bytes, bytes); + + } else { + SSchema field; + size_t tagKeyLen = strlen(smlKv->key); + strncpy(field.name, smlKv->key, tagKeyLen); + field.name[tagKeyLen] = '\0'; + field.type = smlKv->type; + + int32_t bytes = 0; + getFieldBytesFromSmlKv(smlKv, &bytes); + field.bytes = bytes; + + pField = taosArrayPush(array, &field); + taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); + } + return 0; +} + +int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], + SSchemaAction* action, bool* actionNeeded) { + SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name)); + if (*ppDbAttr) { + SSchema* dbAttr = *ppDbAttr; + if (pointColField->type != dbAttr->type) { + //todo error + return -5; + } + + if (IS_VAR_DATA_TYPE(pointColField->type) && (pointColField->bytes > dbAttr->bytes)) { + if (isTag) { + action->action = SCHEMA_ACTION_CHANGE_TAG_SIZE; + } else { + action->action = SCHEMA_ACTION_CHANGE_COLUMN_SIZE; + } + memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo)); + memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN); + action->alterSTable.field = pointColField; + *actionNeeded = true; + } + } else { + if (isTag) { + action->action = SCHEMA_ACTION_ADD_TAG; + } else { + action->action = SCHEMA_ACTION_ADD_COLUMN; + } + memset(&action->alterSTable, 0, sizeof(SAlterSTableActionInfo)); + memcpy(action->alterSTable.sTableName, sTableName, TSDB_TABLE_NAME_LEN); + action->alterSTable.field = pointColField; + *actionNeeded = true; + } + return 0; +} + +int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + int32_t code = TSDB_CODE_SUCCESS; + SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + SHashObj* sname2shema = taosHashInit(32, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int i = 0; i < numPoint; ++i) { + TAOS_SML_DATA_POINT* point = &points[i]; + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + SSmlSTableSchema* pStableSchema = NULL; + if (ppStableSchema) { + pStableSchema= *ppStableSchema; + } else { + SSmlSTableSchema schema; + size_t stableNameLen = strlen(point->stableName); + strncpy(schema.sTableName, point->stableName, stableNameLen); + schema.sTableName[stableNameLen] = '\0'; + schema.fields = taosArrayInit(64, sizeof(SSchema)); + schema.tags = taosArrayInit(8, sizeof(SSchema)); + schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + pStableSchema = taosArrayPush(stableArray, &schema); + taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); + } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* fieldKv = point->fields + j; + addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + } + } + + SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); + size_t numStable = taosArrayGetSize(stableArray); + for (int i = 0; i < numStable; ++i) { + SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); + SSmlSTableSchema dbSchema = {0}; + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); + dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { + SSchemaAction schemaAction = {0}; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); + memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); + schemaAction.createSTable.tags = pointSchema->tags; + schemaAction.createSTable.fields = pointSchema->fields; + taosArrayPush(schemaActions, &schemaAction); + }else if (code == TSDB_CODE_SUCCESS) { + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); + size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); + + SHashObj* dbTagHash = dbSchema.tagHash; + SHashObj* dbFieldHash = dbSchema.fieldHash; + + for (int j = 0; j < pointTagSize; ++j) { + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + + for (int j = 0; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + } else { + return code; + } + } + + return code; +} + + +int32_t buildColumnDescription(SSchema* field, + char* buf, int32_t bufSize, int32_t* outBytes) { + uint8_t type = field->type; + + if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { + int32_t bytes = field->bytes - VARSTR_HEADER_SIZE; + if (type == TSDB_DATA_TYPE_NCHAR) { + bytes = bytes/TSDB_NCHAR_SIZE; + } + int out = snprintf(buf, bufSize,"%s %s(%d)", + field->name,tDataTypes[field->type].name, bytes); + *outBytes = out; + } else { + int out = snprintf(buf, bufSize, "%s %s", + field->name, tDataTypes[type].name); + *outBytes = out; + } + + return 0; +} + +int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { + int32_t code = 0; + int32_t capacity = TSDB_MAX_BINARY_LEN; + int32_t outBytes = 0; + char *result = (char *)calloc(1, capacity); + + switch (action->action) { + case SCHEMA_ACTION_ADD_COLUMN: { + int n = sprintf(result, "alter stable %s add column ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_ADD_TAG: { + int n = sprintf(result, "alter stable %s add tag ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, + result+n, capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { + int n = sprintf(result, "alter stable %s modify column ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, + capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + } + case SCHEMA_ACTION_CHANGE_TAG_SIZE: { + int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName); + buildColumnDescription(action->alterSTable.field, result+n, + capacity-n, &outBytes); + TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CREATE_STABLE: { + int n = sprintf(result, "create stable %s (", action->createSTable.sTableName); + char* pos = result + n; int freeBytes = capacity - n; + int numCols = taosArrayGetSize(action->createSTable.fields); + for (int32_t i = 0; i < numCols; ++i) { + SSchema* field = taosArrayGet(action->createSTable.fields, i); + buildColumnDescription(field, pos, freeBytes, &outBytes); + pos += outBytes; freeBytes -= outBytes; + *pos = ','; ++pos; --freeBytes; + } + --pos; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ") tags ("); + int numTags = taosArrayGetSize(action->createSTable.tags); + pos += outBytes; freeBytes -= outBytes; + for (int32_t i = 0; i < numTags; ++i) { + SSchema* field = taosArrayGet(action->createSTable.tags, i); + buildColumnDescription(field, pos, freeBytes, &outBytes); + pos += outBytes; freeBytes -= outBytes; + *pos = ','; ++pos; --freeBytes; + } + pos--; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ")"); + TAOS_RES* res = taos_query(taos, result); + code = taos_errno(res); + break; + } + case SCHEMA_ACTION_CREATE_CTABLE: { + + break; + } + default: + break; + } + free(result); + return code; +} + +//todo: table/column length check +//todo: type check +//todo: taosmbs2ucs4 check From ca52c73bdeb9064a573857501035c648787a3521 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 9 Jul 2021 19:37:15 +0800 Subject: [PATCH 25/65] before taos_bind/taos_multi_bind generation --- src/client/src/tscParseLineProtocol.c | 99 +++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 79e8955f9a..10d2429b5e 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -277,6 +277,9 @@ typedef struct { uint8_t type; int16_t length; char* value; + + //=================================== + SSchema* fieldSchema; } TAOS_SML_KV; typedef struct { @@ -415,7 +418,6 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { } return code; - } typedef enum { @@ -465,7 +467,6 @@ int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); free(ucs); *bytes = bytesNeeded + VARSTR_HEADER_SIZE; - } else if (kv->type == TSDB_DATA_TYPE_BINARY) { *bytes = kv->length + VARSTR_HEADER_SIZE; } @@ -503,6 +504,9 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a pField = taosArrayPush(array, &field); taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); } + + smlKv->fieldSchema = pField; + return 0; } @@ -700,9 +704,11 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { *pos = ','; ++pos; --freeBytes; } --pos; ++freeBytes; + outBytes = snprintf(pos, freeBytes, ") tags ("); - int numTags = taosArrayGetSize(action->createSTable.tags); pos += outBytes; freeBytes -= outBytes; + + int numTags = taosArrayGetSize(action->createSTable.tags); for (int32_t i = 0; i < numTags; ++i) { SSchema* field = taosArrayGet(action->createSTable.tags, i); buildColumnDescription(field, pos, freeBytes, &outBytes); @@ -716,7 +722,43 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { break; } case SCHEMA_ACTION_CREATE_CTABLE: { - +// SCreateCTableActionInfo* pInfo = &action->createCTable; +// SArray* bindParams = taosArrayInit(2 + 2 * pInfo->tagNum, sizeof(TAOS_BIND)); +// outBytes = sprintf(result, "create table ? using ?("); +// char* pos = result + outBytes; int32_t freeBytes = capacity-outBytes; +// uintptr_t lenSTableName = strlen(pInfo->sTableName); +// uintptr_t lenCTableName = strlen(pInfo->cTableName); +// TAOS_BIND tbCTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = pInfo->cTableName, .length = &lenCTableName}; +// TAOS_BIND tbSTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = pInfo->sTableName, .length = &lenSTableName}; +// taosArrayPush(bindParams, &tbCTableName); +// taosArrayPush(bindParams, &tbSTableName); +// for (int32_t i = 0; i < pInfo->tagNum; ++i) { +// outBytes = snprintf(pos, freeBytes, "?,"); +// +// TAOS_SML_KV* tagKv = pInfo->tags + i; +// TAOS_BIND tbTag = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, +// .buffer = tagKv->key, .length = }; +// pos += outBytes; freeBytes -= outBytes; +// } +// --pos; ++freeBytes; +// +// outBytes = snprintf(pos, freeBytes, ") tags ("); +// pos += outBytes; freeBytes -= outBytes; +// for (int32_t i = 0; i < pInfo->tagNum; ++i) { +// TAOS_SML_KV* tagKv = pInfo->tags + i; +// outBytes = snprintf(pos, freeBytes, "?,"); +// pos += outBytes; freeBytes -= outBytes; +// } +// pos--; ++freeBytes; +// outBytes = snprintf(pos, freeBytes, ")"); +// +// TAOS_STMT* stmt = taos_stmt_init(taos); +// taos_stmt_prepare(stmt, result, strlen(result)); +// +// +// taos_stmt_bind_param(stmt, (TAOS_BIND*)bindParams); break; } default: @@ -726,6 +768,55 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } +int32_t transformIntoPreparedStatement(SArray* points) { + size_t numPoints = taosArrayGetSize(points); + +// SHashObj* tag2bind = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); +// SHashObj* field2multiBind = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int32_t i = 0; i < numPoints; ++i) { + TAOS_SML_DATA_POINT * point = taosArrayGet(points, i); + char tableKey[256]; + snprintf(tableKey, 256, "%s.%s", point->stableName, point->childTableName); + + } + return 0; +} + +int32_t insertBatch(TAOS* taos, const char* sTableName, char* cTableName, SSchema* tagsSchema, int numTags, TAOS_BIND* tagBind, + SSchema* colsSchema, int numCols, TAOS_MULTI_BIND* colBind) { + TAOS_STMT* stmt = taos_stmt_init(taos); + + char result[TSDB_MAX_BINARY_LEN] = {0}; + sprintf(result, "insert into ? using %s(", sTableName); + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", tagsSchema[i].name); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") tags ("); + + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", colsSchema[i].name); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ")"); + + int32_t code = 0; + code = taos_stmt_prepare(stmt, result, strlen(result)); + + code = taos_stmt_set_tbname_tags(stmt, cTableName, tagBind); + code = taos_stmt_bind_param_batch(stmt, colBind); + code = taos_stmt_execute(stmt); + return code; +} //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check From 35cba8c21f858a22b045cf7cf2ad5cedb2cd1631 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Sat, 10 Jul 2021 16:18:38 +0800 Subject: [PATCH 26/65] before debugging --- src/client/src/tscParseLineProtocol.c | 393 ++++++++++++++------------ 1 file changed, 211 insertions(+), 182 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 10d2429b5e..2738fe6f7a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -272,6 +272,14 @@ TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { } //================================================================================================= +typedef struct { + char sTableName[TSDB_TABLE_NAME_LEN]; + SHashObj* tagHash; + SHashObj* fieldHash; + SArray* tags; //SArray + SArray* fields; //SArray +} SSmlSTableSchema; + typedef struct { char* key; uint8_t type; @@ -279,7 +287,7 @@ typedef struct { char* value; //=================================== - SSchema* fieldSchema; + SSchema* schema; } TAOS_SML_KV; typedef struct { @@ -293,17 +301,10 @@ typedef struct { TAOS_SML_KV* fields; int fieldNum; + //================================ + SSmlSTableSchema* schema; } TAOS_SML_DATA_POINT; -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - SHashObj* tagHash; - SHashObj* fieldHash; - SArray* tags; //SArray - SArray* fields; //SArray -} SSmlSTableSchema; - - int compareSmlColKv(const void* p1, const void* p2) { TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; @@ -426,7 +427,6 @@ typedef enum { SCHEMA_ACTION_ADD_TAG, SCHEMA_ACTION_CHANGE_COLUMN_SIZE, SCHEMA_ACTION_CHANGE_TAG_SIZE, - SCHEMA_ACTION_CREATE_CTABLE } ESchemaAction; typedef struct { @@ -440,19 +440,11 @@ typedef struct { SSchema* field; } SAlterSTableActionInfo; -typedef struct { - char sTableName[TSDB_TABLE_NAME_LEN]; - char cTableName[TSDB_TABLE_NAME_LEN]; - TAOS_SML_KV* tags; - int tagNum; -} SCreateCTableActionInfo; - typedef struct { ESchemaAction action; union { SCreateSTableActionInfo createSTable; SAlterSTableActionInfo alterSTable; - SCreateCTableActionInfo createCTable; }; } SSchemaAction; @@ -505,7 +497,7 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a taosHashPut(hash, field.name, tagKeyLen, &pField, POINTER_BYTES); } - smlKv->fieldSchema = pField; + smlKv->schema = pField; return 0; } @@ -545,96 +537,6 @@ int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool return 0; } -int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { - int32_t code = TSDB_CODE_SUCCESS; - SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray - SHashObj* sname2shema = taosHashInit(32, - taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - for (int i = 0; i < numPoint; ++i) { - TAOS_SML_DATA_POINT* point = &points[i]; - SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); - SSmlSTableSchema* pStableSchema = NULL; - if (ppStableSchema) { - pStableSchema= *ppStableSchema; - } else { - SSmlSTableSchema schema; - size_t stableNameLen = strlen(point->stableName); - strncpy(schema.sTableName, point->stableName, stableNameLen); - schema.sTableName[stableNameLen] = '\0'; - schema.fields = taosArrayInit(64, sizeof(SSchema)); - schema.tags = taosArrayInit(8, sizeof(SSchema)); - schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - pStableSchema = taosArrayPush(stableArray, &schema); - taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); - } - - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* tagKv = point->tags + j; - addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); - } - - for (int j = 0; j < point->fieldNum; ++j) { - TAOS_SML_KV* fieldKv = point->fields + j; - addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); - } - } - - SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); - size_t numStable = taosArrayGetSize(stableArray); - for (int i = 0; i < numStable; ++i) { - SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); - SSmlSTableSchema dbSchema = {0}; - dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); - dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); - dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { - SSchemaAction schemaAction = {0}; - schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; - memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); - memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); - schemaAction.createSTable.tags = pointSchema->tags; - schemaAction.createSTable.fields = pointSchema->fields; - taosArrayPush(schemaActions, &schemaAction); - }else if (code == TSDB_CODE_SUCCESS) { - size_t pointTagSize = taosArrayGetSize(pointSchema->tags); - size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); - - SHashObj* dbTagHash = dbSchema.tagHash; - SHashObj* dbFieldHash = dbSchema.fieldHash; - - for (int j = 0; j < pointTagSize; ++j) { - SSchema* pointTag = taosArrayGet(pointSchema->tags, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); - } - } - - for (int j = 0; j < pointFieldSize; ++j) { - SSchema* pointCol = taosArrayGet(pointSchema->tags, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); - } - } - } else { - return code; - } - } - - return code; -} - - int32_t buildColumnDescription(SSchema* field, char* buf, int32_t bufSize, int32_t* outBytes) { uint8_t type = field->type; @@ -721,46 +623,7 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { code = taos_errno(res); break; } - case SCHEMA_ACTION_CREATE_CTABLE: { -// SCreateCTableActionInfo* pInfo = &action->createCTable; -// SArray* bindParams = taosArrayInit(2 + 2 * pInfo->tagNum, sizeof(TAOS_BIND)); -// outBytes = sprintf(result, "create table ? using ?("); -// char* pos = result + outBytes; int32_t freeBytes = capacity-outBytes; -// uintptr_t lenSTableName = strlen(pInfo->sTableName); -// uintptr_t lenCTableName = strlen(pInfo->cTableName); -// TAOS_BIND tbCTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = pInfo->cTableName, .length = &lenCTableName}; -// TAOS_BIND tbSTableName = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = pInfo->sTableName, .length = &lenSTableName}; -// taosArrayPush(bindParams, &tbCTableName); -// taosArrayPush(bindParams, &tbSTableName); -// for (int32_t i = 0; i < pInfo->tagNum; ++i) { -// outBytes = snprintf(pos, freeBytes, "?,"); -// -// TAOS_SML_KV* tagKv = pInfo->tags + i; -// TAOS_BIND tbTag = {.is_null = NULL, .buffer_type = TSDB_DATA_TYPE_BINARY, -// .buffer = tagKv->key, .length = }; -// pos += outBytes; freeBytes -= outBytes; -// } -// --pos; ++freeBytes; -// -// outBytes = snprintf(pos, freeBytes, ") tags ("); -// pos += outBytes; freeBytes -= outBytes; -// for (int32_t i = 0; i < pInfo->tagNum; ++i) { -// TAOS_SML_KV* tagKv = pInfo->tags + i; -// outBytes = snprintf(pos, freeBytes, "?,"); -// pos += outBytes; freeBytes -= outBytes; -// } -// pos--; ++freeBytes; -// outBytes = snprintf(pos, freeBytes, ")"); -// -// TAOS_STMT* stmt = taos_stmt_init(taos); -// taos_stmt_prepare(stmt, result, strlen(result)); -// -// -// taos_stmt_bind_param(stmt, (TAOS_BIND*)bindParams); - break; - } + default: break; } @@ -768,55 +631,221 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } -int32_t transformIntoPreparedStatement(SArray* points) { - size_t numPoints = taosArrayGetSize(points); +int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { + size_t numTags = taosArrayGetSize(tagsSchema); + size_t numCols = taosArrayGetSize(colsSchema); + sprintf(result, "insert into ? using %s(", sTableName); + for (int i = 0; i < numTags; ++i) { + SSchema* tagSchema = taosArrayGet(tagsSchema, i); + snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") tags ("); -// SHashObj* tag2bind = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); -// SHashObj* field2multiBind = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + for (int i = 0; i < numTags; ++i) { + snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") ("); + for (int i = 0; i < numCols; ++i) { + SSchema* colSchema = taosArrayGet(colsSchema, i); + snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", colSchema->name); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + } + snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + return 0; +} + +int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { + TAOS_STMT* stmt = taos_stmt_init(taos); + taos_stmt_prepare(stmt, sql, strlen(sql)); + + taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + size_t rows = taosArrayGetSize(rowsBind); + for (int32_t i = 0; i < rows; ++i) { + TAOS_BIND* colBind = taosArrayGetP(rowsBind, i); + taos_stmt_bind_param(stmt, colBind); + taos_stmt_add_batch(stmt); + } + + taos_stmt_execute(stmt); + TAOS_RES* res = taos_stmt_use_result(stmt); + return taos_errno(res); +} + +int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) { + SHashObj* cname2points = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); for (int32_t i = 0; i < numPoints; ++i) { - TAOS_SML_DATA_POINT * point = taosArrayGet(points, i); - char tableKey[256]; - snprintf(tableKey, 256, "%s.%s", point->stableName, point->childTableName); + TAOS_SML_DATA_POINT * point = points + i; + if (!point->childTableName) { + char childTableName[TSDB_TABLE_NAME_LEN]; + int32_t tableNameLen; + getChildTableName(point, childTableName, &tableNameLen); + point->childTableName = calloc(1, tableNameLen+1); + strncpy(point->childTableName, childTableName, tableNameLen); + point->childTableName[tableNameLen] = '\0'; + } + SArray* cTablePoints = NULL; + SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName)); + if (pCTablePoints) { + cTablePoints = *pCTablePoints; + } else { + cTablePoints = taosArrayInit(64, sizeof(point)); + taosHashPut(cname2points, point->childTableName, strlen(point->childTableName), &cTablePoints, POINTER_BYTES); + } + taosArrayPush(cTablePoints, point); + } + SArray** pCTablePoints = taosHashIterate(cname2points, NULL); + while (pCTablePoints) { + SArray* cTablePoints = *pCTablePoints; + TAOS_SML_DATA_POINT * point = taosArrayGet(cTablePoints, 0); + int32_t numTags = taosArrayGetSize(point->schema->tags); + int32_t numCols = taosArrayGetSize(point->schema->fields); + char* stableName = point->stableName; + char* ctableName = point->childTableName; + char sql[TSDB_MAX_BINARY_LEN]; + getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); + + size_t rows = taosArrayGetSize(cTablePoints); + SArray* rowsBind = taosArrayInit(rows, POINTER_BYTES); + SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); + + for (int i = 0; i < rows; ++i) { + point = taosArrayGet(cTablePoints, i); + + taosArraySetSize(tagBinds, numTags); + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); + TAOS_BIND* bind = taosArrayGet(tagBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + } + + SArray* colBinds = taosArrayInit(numCols, sizeof(TAOS_BIND)); + taosArraySetSize(colBinds, numCols); + for (int j = 0; jfieldNum; ++j) { + TAOS_SML_KV* kv = point->fields + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); + TAOS_BIND* bind = taosArrayGet(colBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + } + taosArrayPush(rowsBind, &colBinds); + } + + insertBatch(taos, sql, ctableName, tagBinds, rowsBind); + + pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } return 0; } -int32_t insertBatch(TAOS* taos, const char* sTableName, char* cTableName, SSchema* tagsSchema, int numTags, TAOS_BIND* tagBind, - SSchema* colsSchema, int numCols, TAOS_MULTI_BIND* colBind) { - TAOS_STMT* stmt = taos_stmt_init(taos); - char result[TSDB_MAX_BINARY_LEN] = {0}; - sprintf(result, "insert into ? using %s(", sTableName); - for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", tagsSchema[i].name); +int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + int32_t code = TSDB_CODE_SUCCESS; + SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + SHashObj* sname2shema = taosHashInit(32, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int i = 0; i < numPoint; ++i) { + TAOS_SML_DATA_POINT* point = &points[i]; + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + SSmlSTableSchema* pStableSchema = NULL; + if (ppStableSchema) { + pStableSchema= *ppStableSchema; + } else { + SSmlSTableSchema schema; + size_t stableNameLen = strlen(point->stableName); + strncpy(schema.sTableName, point->stableName, stableNameLen); + schema.sTableName[stableNameLen] = '\0'; + schema.fields = taosArrayInit(64, sizeof(SSchema)); + schema.tags = taosArrayInit(8, sizeof(SSchema)); + schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + pStableSchema = taosArrayPush(stableArray, &schema); + taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); + } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* fieldKv = point->fields + j; + addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + } + + point->schema = pStableSchema; } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") tags ("); - for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); + SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); + size_t numStable = taosArrayGetSize(stableArray); + for (int i = 0; i < numStable; ++i) { + SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); + SSmlSTableSchema dbSchema = {0}; + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); + dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { + SSchemaAction schemaAction = {0}; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); + memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); + schemaAction.createSTable.tags = pointSchema->tags; + schemaAction.createSTable.fields = pointSchema->fields; + taosArrayPush(schemaActions, &schemaAction); + }else if (code == TSDB_CODE_SUCCESS) { + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); + size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); + + SHashObj* dbTagHash = dbSchema.tagHash; + SHashObj* dbFieldHash = dbSchema.fieldHash; + + for (int j = 0; j < pointTagSize; ++j) { + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + + for (int j = 0; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + taosArrayPush(schemaActions, &schemaAction); + } + } + } else { + return code; + } } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") ("); - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "%s,", colsSchema[i].name); + for (int i = 0; i < taosArrayGetSize(schemaActions); ++i) { + SSchemaAction* action = taosArrayGet(schemaActions, i); + applySchemaAction(taos, action); } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ") values ("); - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), TSDB_MAX_BINARY_LEN-strlen(result), "?,"); - } - snprintf(result + strlen(result)-1, TSDB_MAX_BINARY_LEN-strlen(result)+1, ")"); - - int32_t code = 0; - code = taos_stmt_prepare(stmt, result, strlen(result)); - - code = taos_stmt_set_tbname_tags(stmt, cTableName, tagBind); - code = taos_stmt_bind_param_batch(stmt, colBind); - code = taos_stmt_execute(stmt); + insertPoints(taos, points, numPoint); return code; } + + //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check From dbac6f2081636d78628191b4bf615c9289682b68 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Sun, 11 Jul 2021 23:52:19 +0800 Subject: [PATCH 27/65] before getChildTableName and insertBatch --- src/client/src/tscParseLineProtocol.c | 758 +++++++++++++++----------- src/inc/taos.h | 2 + tests/examples/c/apitest.c | 15 + 3 files changed, 447 insertions(+), 328 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 2738fe6f7a..3a88d2e906 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -15,263 +15,6 @@ #include "tskiplist.h" #include "tscUtil.h" -typedef enum { - LP_ITEM_TAG, - LP_ITEM_FIELD -} LPItemKind; - -typedef struct { - SStrToken key; - SStrToken value; - - char name[TSDB_COL_NAME_LEN]; - int8_t type; - int16_t bytes; - - char* payload; -}SLPItem; - -typedef struct { - SStrToken measToken; - SStrToken tsToken; - - char sTableName[TSDB_TABLE_NAME_LEN]; - SArray* tags; - SArray* fields; - int64_t ts; - -} SLPPoint; - -typedef enum { - LP_MEASUREMENT, - LP_TAG_KEY, - LP_TAG_VALUE, - LP_FIELD_KEY, - LP_FIELD_VALUE -} LPPart; - -int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { - for (int32_t i = start; i < s.n; ++i) { - if (s.z[i] == ',' || s.z[i] == ' ') { - *index = i; - return 0; - } - } - return -1; -} - -int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { - for (int32_t i = start; i < s.n; ++i) { - if (s.z[i] == '=') { - *index = i; - return 0; - } - } - return -1; -} - -int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { - point->measToken = token; - if (point->measToken.n < TSDB_TABLE_NAME_LEN) { - strncpy(point->sTableName, point->measToken.z, point->measToken.n); - point->sTableName[point->measToken.n] = '\0'; - } - return 0; -} - -int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { - item->key = key; - if (item->key.n < TSDB_COL_NAME_LEN) { - strncpy(item->name, item->key.z, item->key.n); - item->name[item->key.n] = '\0'; - } - return 0; -} - -int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { - item->value = value; - return 0; -} - -int32_t parseItemValue(SLPItem* item, LPItemKind kind) { - char* sv = item->value.z; - char* last = item->value.z + item->value.n - 1; - - if (isdigit(sv[0]) || sv[0] == '-') { - if (*last == 'i') { - item->type = TSDB_DATA_TYPE_BIGINT; - item->bytes = (int16_t)tDataTypes[item->type].bytes; - item->payload = malloc(item->bytes); - char* endptr = NULL; - *(item->payload) = strtoll(sv, &endptr, 10); - } else { - item->type = TSDB_DATA_TYPE_DOUBLE; - item->bytes = (int16_t)tDataTypes[item->type].bytes; - item->payload = malloc(item->bytes); - char* endptr = NULL; - *(item->payload) = strtold(sv, &endptr); - } - } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { - if (sv[0] == 'L') { - item->type = TSDB_DATA_TYPE_NCHAR; - uint32_t bytes = item->value.n - 3; -// uint32_t len = bytes; -// char* ucs = malloc(len); -// int32_t ncharBytes = 0; -// taosMbsToUcs4(sv+2, len, ucs, len, &ncharBytes); -// item->bytes = ncharBytes; -// item->payload = malloc(ncharBytes); -// memcpy(item->payload, ucs, ncharBytes); -// free(ucs); - item->bytes = bytes; - item->payload = malloc(bytes); - memcpy(item->payload, sv+1, bytes); - } else if (sv[0]=='"'){ - item->type = TSDB_DATA_TYPE_BINARY; - uint32_t bytes = item->value.n - 2; - item->bytes = bytes; - item->payload = malloc(bytes); - memcpy(item->payload, sv+1, bytes); - } - } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { - item->type = TSDB_DATA_TYPE_BOOL; - item->bytes = tDataTypes[item->type].bytes; - item->payload = malloc(tDataTypes[item->type].bytes); - *(item->payload) = tolower(sv[0])=='t' ? true : false; - } - return 0; -} - -int32_t compareLPItemKey(const void* p1, const void* p2) { - const SLPItem* t1 = p1; - const SLPItem* t2 = p2; - uint32_t min = (t1->key.n < t2->key.n) ? t1->key.n : t2->key.n; - int res = strncmp(t1->key.z, t2->key.z, min); - if (res != 0) { - return res; - } else { - return (int)(t1->key.n) - (int)(t2->key.n); - } -} - -int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { - point->tsToken = tsToken; - return 0; -} - -int32_t parsePointTime(SLPPoint* point) { - if (point->tsToken.n <= 0) { - point->ts = taosGetTimestampNs(); - } else { - char* endptr = NULL; - point->ts = strtoll(point->tsToken.z, &endptr, 10); - } - return 0; -} - -int32_t tscParseLine(SStrToken line, SLPPoint* point) { - int32_t pos = 0; - - int32_t start = 0; - int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); - if (err != 0) { - tscError("a"); - return err; - } - - SStrToken measurement = {.z = line.z+start, .n = pos-start}; - setPointMeasurement(point, measurement); - point->tags = taosArrayInit(64, sizeof(SLPItem)); - start = pos + 1; - while (line.z[start] == ',') { - SLPItem item; - - err = scanToEqual(line, start, &pos); - if (err != 0) { - tscError("b"); - goto error; - } - - SStrToken tagKey = {.z = line.z + start, .n = pos-start}; - setItemKey(&item, tagKey, LP_TAG_KEY); - - start = pos + 1; - err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); - if (err != 0) { - tscError("c"); - goto error; - } - - SStrToken tagValue = {.z = line.z + start, .n = pos-start}; - setItemValue(&item, tagValue, LP_TAG_VALUE); - - parseItemValue(&item, LP_ITEM_TAG); - taosArrayPush(point->tags, &item); - - start = pos + 1; - } - - taosArraySort(point->tags, compareLPItemKey); - - point->fields = taosArrayInit(64, sizeof(SLPItem)); - do { - SLPItem item; - err = scanToEqual(line, start, &pos); - if (err != 0) { - goto error; - } - SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; - setItemKey(&item, fieldKey, LP_FIELD_KEY); - - start = pos + 1; - err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); - if (err != 0) { - goto error; - } - SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; - setItemValue(&item, fieldValue, LP_TAG_VALUE); - - parseItemValue(&item, LP_ITEM_FIELD); - taosArrayPush(point->fields, &item); - - start = pos + 1; - } while (line.z[pos] == ','); - - taosArraySort(point->fields, compareLPItemKey); - - SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; - setPointTimeStamp(point, tsToken); - parsePointTime(point); - - goto done; - -error: - // free array - return err; -done: - return 0; -} - - -int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { - for (int32_t i = 0; i < numLines; ++i) { - SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; - SLPPoint point; - tscParseLine(tkLine, &point); - taosArrayPush(points, &point); - } - return 0; -} - -TAOS_RES* taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { - SArray* points = taosArrayInit(numLines, sizeof(SLPPoint)); - tscParseLines(lines, numLines, points, NULL); - - - return NULL; -} -//================================================================================================= - typedef struct { char sTableName[TSDB_TABLE_NAME_LEN]; SHashObj* tagHash; @@ -305,6 +48,8 @@ typedef struct { SSmlSTableSchema* schema; } TAOS_SML_DATA_POINT; +//================================================================================================= + int compareSmlColKv(const void* p1, const void* p2) { TAOS_SML_KV* kv1 = (TAOS_SML_KV*)p1; TAOS_SML_KV* kv2 = (TAOS_SML_KV*)p2; @@ -318,32 +63,6 @@ int compareSmlColKv(const void* p1, const void* p2) { } } -int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { - qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); - - SStringBuilder sb; memset(&sb, 0, sizeof(sb)); - taosStringBuilderAppendString(&sb, point->stableName); - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* tagKv = point->tags + j; - taosStringBuilderAppendChar(&sb, ','); - taosStringBuilderAppendString(&sb, tagKv->key); - taosStringBuilderAppendChar(&sb, '='); - taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); - } - size_t len = 0; - char* keyJoined = taosStringBuilderGetResult(&sb, &len); - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - MD5Final(&context); - *tableNameLen = snprintf(tableName, *tableNameLen, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], - context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], - context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], - context.digest[12], context.digest[13], context.digest[14], context.digest[15]); - return 0; -} - int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { int32_t code = 0; @@ -393,15 +112,14 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { tscFreeSqlObj(pSql); - uint32_t size = tscGetTableMetaMaxSize(); STableMeta* tableMeta = calloc(1, size); taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); - tstrncpy(schema->sTableName, tableName, strlen(tableName)); + tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); for (int i=0; itableInfo.numOfColumns; ++i) { SSchema field; - tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)); + tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); field.type = tableMeta->schema[i].type; field.bytes = tableMeta->schema[i].bytes; SSchema* pField = taosArrayPush(schema->fields, &field); @@ -411,13 +129,13 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { for (int i=0; itableInfo.numOfTags; ++i) { int j = i + tableMeta->tableInfo.numOfColumns; SSchema field; - tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)); + tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)+1); field.type = tableMeta->schema[j].type; field.bytes = tableMeta->schema[j].bytes; SSchema* pField = taosArrayPush(schema->tags, &field); taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); } - + free(tableMeta); tableMeta = NULL; return code; } @@ -586,6 +304,7 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + break; } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { int n = sprintf(result, "alter stable %s modify tag ", action->alterSTable.sTableName); @@ -631,15 +350,46 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } +int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { + qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); + + SStringBuilder sb; memset(&sb, 0, sizeof(sb)); + taosStringBuilderAppendString(&sb, point->stableName); + for (int j = 0; j < point->tagNum; ++j) { + taosStringBuilderAppendChar(&sb, ','); + TAOS_SML_KV* tagKv = point->tags + j; + taosStringBuilderAppendString(&sb, tagKv->key); + taosStringBuilderAppendChar(&sb, '='); + taosStringBuilderAppend(&sb, tagKv->value, tagKv->length); + } + size_t len = 0; + char* keyJoined = taosStringBuilderGetResult(&sb, &len); + MD5_CTX context; + MD5Init(&context); + MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + MD5Final(&context); + *tableNameLen = snprintf(tableName, *tableNameLen, + "tbl%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], + context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], + context.digest[12], context.digest[13], context.digest[14], context.digest[15]); + taosStringBuilderDestroy(&sb); + return 0; +} + int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { size_t numTags = taosArrayGetSize(tagsSchema); size_t numCols = taosArrayGetSize(colsSchema); - sprintf(result, "insert into ? using %s(", sTableName); - for (int i = 0; i < numTags; ++i) { - SSchema* tagSchema = taosArrayGet(tagsSchema, i); - snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") tags ("); + sprintf(result, "insert into ? using %s", sTableName); + +// snprintf(result+strlen(result), freeBytes-strlen(result), "("); +// for (int i = 0; i < numTags; ++i) { +// SSchema* tagSchema = taosArrayGet(tagsSchema, i); +// snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); +// } +// snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + + snprintf(result + strlen(result), freeBytes-strlen(result), " tags ("); for (int i = 0; i < numTags; ++i) { snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); @@ -661,17 +411,38 @@ int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsS int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { TAOS_STMT* stmt = taos_stmt_init(taos); - taos_stmt_prepare(stmt, sql, strlen(sql)); - - taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); - size_t rows = taosArrayGetSize(rowsBind); - for (int32_t i = 0; i < rows; ++i) { - TAOS_BIND* colBind = taosArrayGetP(rowsBind, i); - taos_stmt_bind_param(stmt, colBind); - taos_stmt_add_batch(stmt); + int32_t code; + code = taos_stmt_prepare(stmt, sql, strlen(sql)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; } - taos_stmt_execute(stmt); + code = taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + size_t rows = taosArrayGetSize(rowsBind); + for (int32_t i = 0; i < rows; ++i) { + SArray* colBind = taosArrayGetP(rowsBind, i); + code = taos_stmt_bind_param(stmt, TARRAY_GET_START(colBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } TAOS_RES* res = taos_stmt_use_result(stmt); return taos_errno(res); } @@ -682,7 +453,7 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) TAOS_SML_DATA_POINT * point = points + i; if (!point->childTableName) { char childTableName[TSDB_TABLE_NAME_LEN]; - int32_t tableNameLen; + int32_t tableNameLen = TSDB_TABLE_NAME_LEN; getChildTableName(point, childTableName, &tableNameLen); point->childTableName = calloc(1, tableNameLen+1); strncpy(point->childTableName, childTableName, tableNameLen); @@ -696,50 +467,62 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) cTablePoints = taosArrayInit(64, sizeof(point)); taosHashPut(cname2points, point->childTableName, strlen(point->childTableName), &cTablePoints, POINTER_BYTES); } - taosArrayPush(cTablePoints, point); + taosArrayPush(cTablePoints, &point); } + int isNullColBind = TSDB_TRUE; SArray** pCTablePoints = taosHashIterate(cname2points, NULL); while (pCTablePoints) { SArray* cTablePoints = *pCTablePoints; - TAOS_SML_DATA_POINT * point = taosArrayGet(cTablePoints, 0); + + TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); int32_t numTags = taosArrayGetSize(point->schema->tags); int32_t numCols = taosArrayGetSize(point->schema->fields); char* stableName = point->stableName; char* ctableName = point->childTableName; - char sql[TSDB_MAX_BINARY_LEN]; - getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); + + SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); + taosArraySetSize(tagBinds, numTags); + for (int j = 0; j < numTags; ++j) { + TAOS_BIND* bind = taosArrayGet(tagBinds, j); + bind->is_null = &isNullColBind; + } + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); + TAOS_BIND* bind = taosArrayGet(tagBinds, idx); + bind->buffer_type = kv->type; + bind->length = (uintptr_t*)&kv->length; + bind->buffer = kv->value; + bind->is_null = NULL; + } size_t rows = taosArrayGetSize(cTablePoints); SArray* rowsBind = taosArrayInit(rows, POINTER_BYTES); - SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); for (int i = 0; i < rows; ++i) { - point = taosArrayGet(cTablePoints, i); - - taosArraySetSize(tagBinds, numTags); - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* kv = point->tags + j; - int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); - TAOS_BIND* bind = taosArrayGet(tagBinds, idx); - bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; - bind->buffer = kv->value; - } + point = taosArrayGetP(cTablePoints, i); SArray* colBinds = taosArrayInit(numCols, sizeof(TAOS_BIND)); taosArraySetSize(colBinds, numCols); - for (int j = 0; jfieldNum; ++j) { + for (int j = 0; j < numCols; ++j) { + TAOS_BIND* bind = taosArrayGet(colBinds, j); + bind->is_null = &isNullColBind; + } + for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* kv = point->fields + j; int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); TAOS_BIND* bind = taosArrayGet(colBinds, idx); bind->buffer_type = kv->type; bind->length = (uintptr_t*)&kv->length; bind->buffer = kv->value; + bind->is_null = NULL; } taosArrayPush(rowsBind, &colBinds); } + char sql[TSDB_MAX_BINARY_LEN]; + getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); insertBatch(taos, sql, ctableName, tagBinds, rowsBind); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); @@ -747,7 +530,6 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) return 0; } - int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { int32_t code = TSDB_CODE_SUCCESS; SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray @@ -792,11 +574,13 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); SSmlSTableSchema dbSchema = {0}; - dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); + dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { SSchemaAction schemaAction = {0}; schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; @@ -813,19 +597,23 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { SHashObj* dbFieldHash = dbSchema.fieldHash; for (int j = 0; j < pointTagSize; ++j) { - SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); SSchemaAction schemaAction = {0}; - bool actionNeeded = false; + bool actionNeeded = false; generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { taosArrayPush(schemaActions, &schemaAction); } } - for (int j = 0; j < pointFieldSize; ++j) { - SSchema* pointCol = taosArrayGet(pointSchema->tags, j); + SSchema* pointColTs = taosArrayGet(pointSchema->fields, 0); + SSchema* dbColTs = taosArrayGet(dbSchema.fields, 0); + memcpy(pointColTs->name, dbColTs->name, TSDB_COL_NAME_LEN); + + for (int j = 1; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->fields, j); SSchemaAction schemaAction = {0}; - bool actionNeeded = false; + bool actionNeeded = false; generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { taosArrayPush(schemaActions, &schemaAction); @@ -849,3 +637,317 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { //todo: table/column length check //todo: type check //todo: taosmbs2ucs4 check + +//========================================================================= + +typedef enum { + LP_ITEM_TAG, + LP_ITEM_FIELD +} LPItemKind; + +typedef struct { + SStrToken keyToken; + SStrToken valueToken; + + char key[TSDB_COL_NAME_LEN]; + int8_t type; + int16_t length; + + char* value; +}SLPItem; + +typedef struct { + SStrToken measToken; + SStrToken tsToken; + + char sTableName[TSDB_TABLE_NAME_LEN]; + SArray* tags; + SArray* fields; + int64_t ts; + +} SLPPoint; + +typedef enum { + LP_MEASUREMENT, + LP_TAG_KEY, + LP_TAG_VALUE, + LP_FIELD_KEY, + LP_FIELD_VALUE +} LPPart; + +int32_t scanToCommaOrSpace(SStrToken s, int32_t start, int32_t* index, LPPart part) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == ',' || s.z[i] == ' ') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t scanToEqual(SStrToken s, int32_t start, int32_t* index) { + for (int32_t i = start; i < s.n; ++i) { + if (s.z[i] == '=') { + *index = i; + return 0; + } + } + return -1; +} + +int32_t setPointMeasurement(SLPPoint* point, SStrToken token) { + point->measToken = token; + if (point->measToken.n < TSDB_TABLE_NAME_LEN) { + strncpy(point->sTableName, point->measToken.z, point->measToken.n); + point->sTableName[point->measToken.n] = '\0'; + } + return 0; +} + +int32_t setItemKey(SLPItem* item, SStrToken key, LPPart part) { + item->keyToken = key; + if (item->keyToken.n < TSDB_COL_NAME_LEN) { + strncpy(item->key, item->keyToken.z, item->keyToken.n); + item->key[item->keyToken.n] = '\0'; + } + return 0; +} + +int32_t setItemValue(SLPItem* item, SStrToken value, LPPart part) { + item->valueToken = value; + return 0; +} + +int32_t parseItemValue(SLPItem* item, LPItemKind kind) { + char* sv = item->valueToken.z; + char* last = item->valueToken.z + item->valueToken.n - 1; + + if (isdigit(sv[0]) || sv[0] == '-') { + if (*last == 'i') { + item->type = TSDB_DATA_TYPE_BIGINT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(item->value) = strtoll(sv, &endptr, 10); + } else { + item->type = TSDB_DATA_TYPE_DOUBLE; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(item->value) = strtold(sv, &endptr); + } + } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { + if (sv[0] == 'L') { + item->type = TSDB_DATA_TYPE_NCHAR; + uint32_t bytes = item->valueToken.n - 3; + item->length = bytes; + item->value = malloc(bytes); + memcpy(item->value, sv+1, bytes); + } else if (sv[0]=='"'){ + item->type = TSDB_DATA_TYPE_BINARY; + uint32_t bytes = item->valueToken.n - 2; + item->length = bytes; + item->value = malloc(bytes); + memcpy(item->value, sv+1, bytes); + } + } else if (sv[0] == 't' || sv[0] == 'f' || sv[0]=='T' || sv[0] == 'F') { + item->type = TSDB_DATA_TYPE_BOOL; + item->length = tDataTypes[item->type].bytes; + item->value = malloc(tDataTypes[item->type].bytes); + *(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; + } + return 0; +} + +int32_t compareLPItemKey(const void* p1, const void* p2) { + const SLPItem* t1 = p1; + const SLPItem* t2 = p2; + uint32_t min = (t1->keyToken.n < t2->keyToken.n) ? t1->keyToken.n : t2->keyToken.n; + int res = strncmp(t1->keyToken.z, t2->keyToken.z, min); + if (res != 0) { + return res; + } else { + return (int)(t1->keyToken.n) - (int)(t2->keyToken.n); + } +} + +int32_t setPointTimeStamp(SLPPoint* point, SStrToken tsToken) { + point->tsToken = tsToken; + return 0; +} + +int32_t parsePointTime(SLPPoint* point) { + if (point->tsToken.n <= 0) { + point->ts = taosGetTimestampNs(); + } else { + char* endptr = NULL; + point->ts = strtoll(point->tsToken.z, &endptr, 10); + } + return 0; +} + +int32_t tscParseLine(SStrToken line, SLPPoint* point) { + int32_t pos = 0; + + int32_t start = 0; + int32_t err = scanToCommaOrSpace(line, start, &pos, LP_MEASUREMENT); + if (err != 0) { + tscError("a"); + return err; + } + + SStrToken measurement = {.z = line.z+start, .n = pos-start}; + setPointMeasurement(point, measurement); + point->tags = taosArrayInit(64, sizeof(SLPItem)); + start = pos; + while (line.z[start] == ',') { + SLPItem item; + + start++; + err = scanToEqual(line, start, &pos); + if (err != 0) { + tscError("b"); + goto error; + } + + SStrToken tagKey = {.z = line.z + start, .n = pos-start}; + setItemKey(&item, tagKey, LP_TAG_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_TAG_VALUE); + if (err != 0) { + tscError("c"); + goto error; + } + + SStrToken tagValue = {.z = line.z + start, .n = pos-start}; + setItemValue(&item, tagValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_TAG); + taosArrayPush(point->tags, &item); + + start = pos; + } + + taosArraySort(point->tags, compareLPItemKey); + + point->fields = taosArrayInit(64, sizeof(SLPItem)); + + start++; + do { + SLPItem item; + + err = scanToEqual(line, start, &pos); + if (err != 0) { + goto error; + } + SStrToken fieldKey = {.z = line.z + start, .n = pos- start}; + setItemKey(&item, fieldKey, LP_FIELD_KEY); + + start = pos + 1; + err = scanToCommaOrSpace(line, start, &pos, LP_FIELD_VALUE); + if (err != 0) { + goto error; + } + SStrToken fieldValue = {.z = line.z + start, .n = pos - start}; + setItemValue(&item, fieldValue, LP_TAG_VALUE); + + parseItemValue(&item, LP_ITEM_FIELD); + taosArrayPush(point->fields, &item); + + start = pos + 1; + } while (line.z[pos] == ','); + + taosArraySort(point->fields, compareLPItemKey); + + SStrToken tsToken = {.z = line.z+start, .n = line.n-start}; + setPointTimeStamp(point, tsToken); + parsePointTime(point); + + goto done; + + error: + // free array + return err; + done: + return 0; +} + + +int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { + for (int32_t i = 0; i < numLines; ++i) { + SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; + SLPPoint point; + tscParseLine(tkLine, &point); + taosArrayPush(points, &point); + } + return 0; +} + +int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { + SArray* lpPoints = taosArrayInit(numLines, sizeof(SLPPoint)); + tscParseLines(lines, numLines, lpPoints, NULL); + + size_t numPoints = taosArrayGetSize(lpPoints); + TAOS_SML_DATA_POINT* points = calloc(numPoints, sizeof(TAOS_SML_DATA_POINT)); + for (int i = 0; i < numPoints; ++i) { + SLPPoint* lpPoint = taosArrayGet(lpPoints, i); + TAOS_SML_DATA_POINT* point = points+i; + point->stableName = calloc(1, strlen(lpPoint->sTableName)+1); + strncpy(point->stableName, lpPoint->sTableName, strlen(lpPoint->sTableName)); + point->stableName[strlen(lpPoint->sTableName)] = '\0'; + + size_t lpTagSize = taosArrayGetSize(lpPoint->tags); + point->tags = calloc(lpTagSize, sizeof(TAOS_SML_KV)); + point->tagNum = lpTagSize; + for (int j=0; jtags, j); + TAOS_SML_KV* tagKv = point->tags + j; + + size_t kenLen = strlen(lpTag->key); + tagKv->key = calloc(1, kenLen+1); + strncpy(tagKv->key, lpTag->key, kenLen); + tagKv->key[kenLen] = '\0'; + + tagKv->type = lpTag->type; + tagKv->length = lpTag->length; + tagKv->value = malloc(tagKv->length); + memcpy(tagKv->value, lpTag->value, tagKv->length); + } + + size_t lpFieldsSize = taosArrayGetSize(lpPoint->fields); + point->fields = calloc(lpFieldsSize + 1, sizeof(TAOS_SML_KV)); + point->fieldNum = lpFieldsSize + 1; + + TAOS_SML_KV* tsField = point->fields + 0; + char tsKey[256]; + snprintf(tsKey, 256, "_%s_ts", point->stableName); + size_t tsKeyLen = strlen(tsKey); + tsField->key = calloc(1, tsKeyLen+1); + strncpy(tsField->key, tsKey, tsKeyLen); + tsField->key[tsKeyLen] = '\0'; + tsField->type = TSDB_DATA_TYPE_TIMESTAMP; + tsField->length = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes; + tsField->value = malloc(tsField->length); + memcpy(tsField->value, &(lpPoint->ts), tsField->length); + + for (int j=0; jfields, j); + TAOS_SML_KV* fieldKv = point->fields + j + 1; + + size_t kenLen = strlen(lpField->key); + fieldKv->key = calloc(1, kenLen+1); + strncpy(fieldKv->key, lpField->key, kenLen); + fieldKv->key[kenLen] = '\0'; + + fieldKv->type = lpField->type; + fieldKv->length = lpField->length; + fieldKv->value = malloc(fieldKv->length); + memcpy(fieldKv->value, lpField->value, fieldKv->length); + } + } + + taos_sml_insert(taos, points, numPoints); + return 0; +} + diff --git a/src/inc/taos.h b/src/inc/taos.h index 9f72945ef0..ca18c4fb93 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -169,6 +169,8 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); +DLL_EXPORT int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines); + #ifdef __cplusplus } #endif diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 0f24df0f47..dc77677774 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -949,6 +949,15 @@ void verify_stream(TAOS* taos) { taos_close_stream(strm); } +int32_t verify_schema_less(TAOS* taos) { + prepare_data(taos); + char* lines[] = { + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639162922" + }; + int code = taos_insert_by_lines(taos, lines , 1); + return code; +} + int main(int argc, char *argv[]) { const char* host = "127.0.0.1"; const char* user = "root"; @@ -967,6 +976,12 @@ int main(int argc, char *argv[]) { info = taos_get_client_info(taos); printf("client info: %s\n", info); + printf("************ verify query *************\n"); + int code = verify_schema_less(taos); + if (code == 0) { + return code; + } + printf("************ verify query *************\n"); verify_query(taos); From ee10305ddc472b5480587bd2c225f4645fdc9fb1 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 00:39:16 +0800 Subject: [PATCH 28/65] before time precision and create table with tags instead of autocreate --- src/client/src/tscParseLineProtocol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 3a88d2e906..4b9191a91f 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -492,7 +492,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); TAOS_BIND* bind = taosArrayGet(tagBinds, idx); bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; + bind->length = malloc(sizeof(uintptr_t*)); + *bind->length = kv->length; bind->buffer = kv->value; bind->is_null = NULL; } @@ -514,7 +515,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); TAOS_BIND* bind = taosArrayGet(colBinds, idx); bind->buffer_type = kv->type; - bind->length = (uintptr_t*)&kv->length; + bind->length = malloc(sizeof(uintptr_t*)); + *bind->length = kv->length; bind->buffer = kv->value; bind->is_null = NULL; } From 93c6fee9c5295cf3246fff619f2e1fbc378645ac Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 08:38:51 +0800 Subject: [PATCH 29/65] can add two lines of one supertable/diffrent subtable --- src/client/src/tscParseLineProtocol.c | 12 ++++++------ tests/examples/c/apitest.c | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 4b9191a91f..1fde741c2b 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -540,13 +540,13 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { for (int i = 0; i < numPoint; ++i) { TAOS_SML_DATA_POINT* point = &points[i]; - SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, TSDB_TABLE_NAME_LEN); + size_t stableNameLen = strlen(point->stableName); + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, stableNameLen); SSmlSTableSchema* pStableSchema = NULL; if (ppStableSchema) { pStableSchema= *ppStableSchema; } else { SSmlSTableSchema schema; - size_t stableNameLen = strlen(point->stableName); strncpy(schema.sTableName, point->stableName, stableNameLen); schema.sTableName[stableNameLen] = '\0'; schema.fields = taosArrayInit(64, sizeof(SSchema)); @@ -730,13 +730,13 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(item->value) = strtoll(sv, &endptr, 10); + *(int64_t*)(item->value) = strtoll(sv, &endptr, 10); } else { item->type = TSDB_DATA_TYPE_DOUBLE; item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(item->value) = strtold(sv, &endptr); + *(double*)(item->value) = strtold(sv, &endptr); } } else if ((sv[0] == 'L' && sv[1] =='"') || sv[0] == '"' ) { if (sv[0] == 'L') { @@ -744,7 +744,7 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { uint32_t bytes = item->valueToken.n - 3; item->length = bytes; item->value = malloc(bytes); - memcpy(item->value, sv+1, bytes); + memcpy(item->value, sv+2, bytes); } else if (sv[0]=='"'){ item->type = TSDB_DATA_TYPE_BINARY; uint32_t bytes = item->valueToken.n - 2; @@ -756,7 +756,7 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->type = TSDB_DATA_TYPE_BOOL; item->length = tDataTypes[item->type].bytes; item->value = malloc(tDataTypes[item->type].bytes); - *(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; + *(uint8_t*)(item->value) = tolower(sv[0])=='t' ? TSDB_TRUE : TSDB_FALSE; } return 0; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index dc77677774..04a03df6fa 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -952,9 +952,11 @@ void verify_stream(TAOS* taos) { int32_t verify_schema_less(TAOS* taos) { prepare_data(taos); char* lines[] = { - "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639162922" + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" }; - int code = taos_insert_by_lines(taos, lines , 1); + int code = taos_insert_by_lines(taos, lines , 2); return code; } @@ -976,7 +978,7 @@ int main(int argc, char *argv[]) { info = taos_get_client_info(taos); printf("client info: %s\n", info); - printf("************ verify query *************\n"); + printf("************ verify shemaless *************\n"); int code = verify_schema_less(taos); if (code == 0) { return code; From 3d70319913feb1a486f47542e4b9e3412e045bcc Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 09:17:15 +0800 Subject: [PATCH 30/65] create child table with tags --- src/client/src/tscParseLineProtocol.c | 87 +++++++++++++++++---------- tests/examples/c/apitest.c | 2 +- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 1fde741c2b..dd0e64ba84 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -377,39 +377,26 @@ int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tabl return 0; } -int32_t getPreparedSQL(const char* sTableName, SArray* tagsSchema, SArray* colsSchema, char* result, int16_t freeBytes) { +int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind) { size_t numTags = taosArrayGetSize(tagsSchema); - size_t numCols = taosArrayGetSize(colsSchema); - sprintf(result, "insert into ? using %s", sTableName); + char sql[TSDB_MAX_BINARY_LEN] = {0}; + int freeBytes = TSDB_MAX_BINARY_LEN; + sprintf(sql, "create table if not exists %s using %s", cTableName, sTableName); -// snprintf(result+strlen(result), freeBytes-strlen(result), "("); -// for (int i = 0; i < numTags; ++i) { -// SSchema* tagSchema = taosArrayGet(tagsSchema, i); -// snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", tagSchema->name); -// } -// snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "("); + for (int i = 0; i < numTags; ++i) { + SSchema* tagSchema = taosArrayGet(tagsSchema, i); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", tagSchema->name); + } + snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")"); - snprintf(result + strlen(result), freeBytes-strlen(result), " tags ("); + snprintf(sql + strlen(sql), freeBytes-strlen(sql), " tags ("); for (int i = 0; i < numTags; ++i) { - snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") ("); + snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")"); - for (int i = 0; i < numCols; ++i) { - SSchema* colSchema = taosArrayGet(colsSchema, i); - snprintf(result+strlen(result), freeBytes-strlen(result), "%s,", colSchema->name); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ") values ("); - - for (int i = 0; i < numCols; ++i) { - snprintf(result+strlen(result), freeBytes-strlen(result), "?,"); - } - snprintf(result + strlen(result)-1, freeBytes-strlen(result)+1, ")"); - return 0; -} - -int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, SArray* rowsBind) { TAOS_STMT* stmt = taos_stmt_init(taos); int32_t code; code = taos_stmt_prepare(stmt, sql, strlen(sql)); @@ -418,7 +405,47 @@ int32_t insertBatch(TAOS* taos, char* sql, char* cTableName, SArray* tagsBind, S return code; } - code = taos_stmt_set_tbname_tags(stmt, cTableName, TARRAY_GET_START(tagsBind)); + code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + TAOS_RES* res = taos_stmt_use_result(stmt); + return taos_errno(res); +} + +int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) { + size_t numCols = taosArrayGetSize(colsSchema); + char sql[TSDB_MAX_BINARY_LEN]; + int32_t freeBytes = TSDB_MAX_BINARY_LEN; + sprintf(sql, "insert into ? ("); + + for (int i = 0; i < numCols; ++i) { + SSchema* colSchema = taosArrayGet(colsSchema, i); + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "%s,", colSchema->name); + } + snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ") values ("); + + for (int i = 0; i < numCols; ++i) { + snprintf(sql+strlen(sql), freeBytes-strlen(sql), "?,"); + } + snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")"); + + TAOS_STMT* stmt = taos_stmt_init(taos); + int32_t code; + code = taos_stmt_prepare(stmt, sql, strlen(sql)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + + code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { printf("%s", taos_stmt_errstr(stmt)); return code; @@ -478,7 +505,6 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); int32_t numTags = taosArrayGetSize(point->schema->tags); int32_t numCols = taosArrayGetSize(point->schema->fields); - char* stableName = point->stableName; char* ctableName = point->childTableName; SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); @@ -523,9 +549,8 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) taosArrayPush(rowsBind, &colBinds); } - char sql[TSDB_MAX_BINARY_LEN]; - getPreparedSQL(stableName, point->schema->tags, point->schema->fields, sql, TSDB_MAX_BINARY_LEN); - insertBatch(taos, sql, ctableName, tagBinds, rowsBind); + creatChildTableIfNotExists(taos, point->childTableName, point->stableName, point->schema->tags, tagBinds); + insertBatch(taos, ctableName, point->schema->fields, rowsBind); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 04a03df6fa..5272dafaf1 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -956,7 +956,7 @@ int32_t verify_schema_less(TAOS* taos) { "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" }; - int code = taos_insert_by_lines(taos, lines , 2); + int code = taos_insert_by_lines(taos, lines , 3); return code; } From dec30e4473346b7d4529c6633549ffcb0867501a Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 10:16:30 +0800 Subject: [PATCH 31/65] add timestamp precision support --- src/client/src/tscParseLineProtocol.c | 39 ++++++++++++++++++++------- tests/examples/c/apitest.c | 18 +++++++++---- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index dd0e64ba84..c0cc2ea3ae 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -21,6 +21,7 @@ typedef struct { SHashObj* fieldHash; SArray* tags; //SArray SArray* fields; //SArray + uint8_t precision; } SSmlSTableSchema; typedef struct { @@ -117,6 +118,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); + schema->precision = tableMeta->tableInfo.precision; for (int i=0; itableInfo.numOfColumns; ++i) { SSchema field; tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); @@ -486,6 +488,25 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) strncpy(point->childTableName, childTableName, tableNameLen); point->childTableName[tableNameLen] = '\0'; } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* kv = point->tags + j; + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision); + *(int64_t*)(kv->value) = ts; + } + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* kv = point->fields + j; + if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) { + int64_t ts = *(int64_t*)(kv->value); + ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, point->schema->precision); + *(int64_t*)(kv->value) = ts; + } + } + SArray* cTablePoints = NULL; SArray** pCTablePoints = taosHashGet(cname2points, point->childTableName, strlen(point->childTableName)); if (pCTablePoints) { @@ -596,7 +617,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { point->schema = pStableSchema; } - SArray* schemaActions = taosArrayInit(32, sizeof(SSchemaAction)); size_t numStable = taosArrayGetSize(stableArray); for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); @@ -615,8 +635,10 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); schemaAction.createSTable.tags = pointSchema->tags; schemaAction.createSTable.fields = pointSchema->fields; - taosArrayPush(schemaActions, &schemaAction); - }else if (code == TSDB_CODE_SUCCESS) { + applySchemaAction(taos, &schemaAction); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + pointSchema->precision = dbSchema.precision; + } else if (code == TSDB_CODE_SUCCESS) { size_t pointTagSize = taosArrayGetSize(pointSchema->tags); size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); @@ -629,7 +651,7 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { bool actionNeeded = false; generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); + applySchemaAction(taos, &schemaAction); } } @@ -643,19 +665,16 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { bool actionNeeded = false; generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { - taosArrayPush(schemaActions, &schemaAction); + applySchemaAction(taos, &schemaAction); } } + + pointSchema->precision = dbSchema.precision; } else { return code; } } - for (int i = 0; i < taosArrayGetSize(schemaActions); ++i) { - SSchemaAction* action = taosArrayGet(schemaActions, i); - applySchemaAction(taos, action); - } - insertPoints(taos, points, numPoint); return code; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 5272dafaf1..656d5fd217 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -12,7 +12,7 @@ static void prepare_data(TAOS* taos) { result = taos_query(taos, "drop database if exists test;"); taos_free_result(result); usleep(100000); - result = taos_query(taos, "create database test;"); + result = taos_query(taos, "create database test precision 'us';"); taos_free_result(result); usleep(100000); taos_select_db(taos, "test"); @@ -950,11 +950,19 @@ void verify_stream(TAOS* taos) { } int32_t verify_schema_less(TAOS* taos) { - prepare_data(taos); + TAOS_RES *result; + result = taos_query(taos, "drop database if exists test;"); + taos_free_result(result); + usleep(100000); + result = taos_query(taos, "create database test precision 'us';"); + taos_free_result(result); + usleep(100000); + taos_select_db(taos, "test"); + char* lines[] = { - "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642" + "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000" }; int code = taos_insert_by_lines(taos, lines , 3); return code; From ab67d612f0ee3e365b1357ffa5ec3aef4936b6b2 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 10:30:54 +0800 Subject: [PATCH 32/65] fixing exsiting stable --- src/client/src/tscParseLineProtocol.c | 2 +- tests/examples/c/apitest.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index c0cc2ea3ae..61f9cd9e76 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -225,7 +225,7 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], SSchemaAction* action, bool* actionNeeded) { SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name)); - if (*ppDbAttr) { + if (ppDbAttr) { SSchema* dbAttr = *ppDbAttr; if (pointColField->type != dbAttr->type) { //todo error diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 656d5fd217..5cb3f5762a 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -958,13 +958,15 @@ int32_t verify_schema_less(TAOS* taos) { taos_free_result(result); usleep(100000); taos_select_db(taos, "test"); + result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)"); char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000" + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", + "ste,t2=5,t3=L\"ste\" c1=true,c2=4 1626056811823316532" }; - int code = taos_insert_by_lines(taos, lines , 3); + int code = taos_insert_by_lines(taos, lines , 4); return code; } From 14cab541f7cb6235a8b5ab0d16fc1a1aacb124ed Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 11:27:34 +0800 Subject: [PATCH 33/65] before tsim/log/memory leak handling --- tests/examples/c/apitest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 5cb3f5762a..409140e0f2 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -957,16 +957,20 @@ int32_t verify_schema_less(TAOS* taos) { result = taos_query(taos, "create database test precision 'us';"); taos_free_result(result); usleep(100000); + taos_select_db(taos, "test"); result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)"); + taos_free_result(result); + usleep(100000); char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", - "ste,t2=5,t3=L\"ste\" c1=true,c2=4 1626056811823316532" + "ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532", + "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - int code = taos_insert_by_lines(taos, lines , 4); + int code = taos_insert_by_lines(taos, lines , 5); return code; } From cdc85ae82032826c976c34fcf266ee99a0711079 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 12 Jul 2021 13:38:59 +0800 Subject: [PATCH 34/65] [td-225]disable alter wal level. --- src/query/inc/sql.y | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 5b6b930e85..1b08f1e244 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -303,11 +303,12 @@ alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol alter_db_optr(Y) ::= alter_db_optr(Z) keep(X). { Y = Z; Y.keep = X; } alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); } -alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } +//alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } not support yet + %type alter_topic_optr {SCreateDbInfo} alter_topic_optr(Y) ::= alter_db_optr(Z). { Y = Z; Y.dbType = TSDB_DB_TYPE_TOPIC; } From 128c1bc5c324605eb65dec62841dfe6b275b1e76 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 12 Jul 2021 13:47:07 +0800 Subject: [PATCH 35/65] [td-225]disable alter wal level after create databases. --- src/client/src/tscSQLParser.c | 34 +- src/query/src/sql.c | 1423 ++++++++++++++++----------------- 2 files changed, 736 insertions(+), 721 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d3651efef4..2bf49b9abd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7809,19 +7809,37 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) { meta->tableType = TSDB_TEMP_TABLE; STableComInfo *info = &meta->tableInfo; - info->numOfColumns = numOfColumns; + + // todo : row size, numOfTags, numOfCols, tag info +// info->numOfColumns = numOfColumns; info->precision = pUpstreamTableMetaInfo->pTableMeta->tableInfo.precision; - info->numOfTags = 0; +// info->numOfTags = 0; int32_t n = 0; for(int32_t i = 0; i < numOfColumns; ++i) { SInternalField* pField = tscFieldInfoGetInternalField(&pUpstream->fieldsInfo, i); - if (pField->visible) { - meta->schema[n].bytes = pField->field.bytes; - meta->schema[n].type = pField->field.type; - meta->schema[n].colId = pField->pExpr->base.resColId; - tstrncpy(meta->schema[n].name, pField->pExpr->base.aliasName, TSDB_COL_NAME_LEN); - n += 1; + if (!pField->visible) { + continue; + } + + meta->schema[n].bytes = pField->field.bytes; + meta->schema[n].type = pField->field.type; + + SExprInfo* pExpr = pField->pExpr; + meta->schema[n].colId = pExpr->base.resColId; + tstrncpy(meta->schema[n].name, pField->pExpr->base.aliasName, TSDB_COL_NAME_LEN); + info->rowSize += meta->schema[n].bytes; + + n += 1; + + if (pExpr->pExpr != NULL) { + info->numOfColumns += 1; + } else { + if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) { + info->numOfTags += 1; + } else { + info->numOfColumns += 1; + } } } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 8fe3538a93..ccae21e411 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -129,16 +129,16 @@ typedef union { #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 #define YYNSTATE 347 -#define YYNRULE 285 +#define YYNRULE 284 #define YYNTOKEN 190 #define YY_MAX_SHIFT 346 -#define YY_MIN_SHIFTREDUCE 549 -#define YY_MAX_SHIFTREDUCE 833 -#define YY_ERROR_ACTION 834 -#define YY_ACCEPT_ACTION 835 -#define YY_NO_ACTION 836 -#define YY_MIN_REDUCE 837 -#define YY_MAX_REDUCE 1121 +#define YY_MIN_SHIFTREDUCE 548 +#define YY_MAX_SHIFTREDUCE 831 +#define YY_ERROR_ACTION 832 +#define YY_ACCEPT_ACTION 833 +#define YY_NO_ACTION 834 +#define YY_MIN_REDUCE 835 +#define YY_MAX_REDUCE 1118 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -204,82 +204,82 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (735) +#define YY_ACTTAB_COUNT (732) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 23, 598, 1010, 598, 219, 344, 194, 835, 346, 599, - /* 10 */ 598, 599, 197, 54, 55, 225, 58, 59, 599, 988, - /* 20 */ 239, 48, 1097, 57, 300, 62, 60, 63, 61, 1001, - /* 30 */ 1001, 231, 233, 53, 52, 988, 988, 51, 50, 49, - /* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 598, - /* 50 */ 57, 300, 62, 60, 63, 61, 1001, 599, 152, 236, - /* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1007, 58, - /* 70 */ 59, 630, 261, 239, 48, 240, 57, 300, 62, 60, - /* 80 */ 63, 61, 29, 83, 982, 221, 53, 52, 145, 985, - /* 90 */ 51, 50, 49, 550, 551, 552, 553, 554, 555, 556, - /* 100 */ 557, 558, 559, 560, 561, 562, 345, 80, 772, 220, + /* 0 */ 23, 597, 1007, 597, 219, 344, 194, 833, 346, 598, + /* 10 */ 597, 598, 197, 54, 55, 225, 58, 59, 598, 985, + /* 20 */ 239, 48, 1094, 57, 301, 62, 60, 63, 61, 998, + /* 30 */ 998, 231, 233, 53, 52, 985, 985, 51, 50, 49, + /* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 597, + /* 50 */ 57, 301, 62, 60, 63, 61, 998, 598, 152, 236, + /* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1004, 58, + /* 70 */ 59, 629, 261, 239, 48, 240, 57, 301, 62, 60, + /* 80 */ 63, 61, 29, 83, 979, 221, 53, 52, 145, 982, + /* 90 */ 51, 50, 49, 549, 550, 551, 552, 553, 554, 555, + /* 100 */ 556, 557, 558, 559, 560, 561, 345, 80, 770, 220, /* 110 */ 95, 77, 54, 55, 35, 58, 59, 42, 197, 239, - /* 120 */ 48, 197, 57, 300, 62, 60, 63, 61, 1098, 232, - /* 130 */ 1046, 1098, 53, 52, 197, 89, 51, 50, 49, 54, - /* 140 */ 56, 264, 58, 59, 1098, 976, 239, 48, 974, 57, - /* 150 */ 300, 62, 60, 63, 61, 268, 267, 229, 298, 53, - /* 160 */ 52, 985, 248, 51, 50, 49, 41, 296, 339, 338, - /* 170 */ 295, 294, 293, 337, 292, 336, 335, 334, 291, 333, - /* 180 */ 332, 948, 936, 937, 938, 939, 940, 941, 942, 943, - /* 190 */ 944, 945, 946, 947, 949, 950, 58, 59, 24, 986, - /* 200 */ 239, 48, 253, 57, 300, 62, 60, 63, 61, 35, - /* 210 */ 195, 257, 256, 53, 52, 205, 330, 51, 50, 49, + /* 120 */ 48, 197, 57, 301, 62, 60, 63, 61, 1095, 232, + /* 130 */ 1043, 1095, 53, 52, 197, 89, 51, 50, 49, 54, + /* 140 */ 56, 264, 58, 59, 1095, 973, 239, 48, 971, 57, + /* 150 */ 301, 62, 60, 63, 61, 268, 267, 229, 299, 53, + /* 160 */ 52, 982, 248, 51, 50, 49, 41, 297, 339, 338, + /* 170 */ 296, 295, 294, 337, 293, 292, 336, 335, 291, 334, + /* 180 */ 333, 946, 934, 935, 936, 937, 938, 939, 940, 941, + /* 190 */ 942, 943, 944, 945, 947, 948, 58, 59, 24, 983, + /* 200 */ 239, 48, 253, 57, 301, 62, 60, 63, 61, 152, + /* 210 */ 195, 257, 256, 53, 52, 205, 772, 51, 50, 49, /* 220 */ 53, 52, 206, 14, 51, 50, 49, 129, 128, 204, - /* 230 */ 298, 238, 787, 305, 83, 776, 81, 779, 116, 782, - /* 240 */ 200, 238, 787, 883, 35, 776, 330, 779, 179, 782, - /* 250 */ 114, 108, 119, 94, 91, 1094, 984, 118, 124, 127, - /* 260 */ 117, 987, 35, 217, 218, 152, 121, 301, 42, 41, - /* 270 */ 264, 339, 338, 217, 218, 242, 337, 1093, 336, 335, - /* 280 */ 334, 704, 333, 332, 701, 1117, 702, 230, 703, 1092, - /* 290 */ 260, 985, 75, 956, 680, 954, 955, 340, 917, 213, - /* 300 */ 957, 247, 959, 960, 958, 309, 961, 962, 152, 985, - /* 310 */ 64, 35, 244, 245, 1, 167, 62, 60, 63, 61, - /* 320 */ 64, 893, 320, 319, 53, 52, 179, 1109, 51, 50, - /* 330 */ 49, 5, 38, 169, 92, 282, 215, 88, 168, 102, - /* 340 */ 97, 101, 788, 783, 720, 76, 243, 35, 241, 784, - /* 350 */ 308, 307, 788, 783, 310, 188, 186, 184, 985, 784, - /* 360 */ 35, 35, 183, 132, 131, 130, 971, 972, 34, 975, - /* 370 */ 35, 68, 249, 35, 246, 35, 315, 314, 973, 778, - /* 380 */ 1047, 781, 280, 884, 51, 50, 49, 777, 179, 780, - /* 390 */ 311, 705, 706, 71, 985, 343, 342, 137, 143, 141, - /* 400 */ 140, 90, 717, 312, 316, 3, 180, 985, 985, 753, - /* 410 */ 754, 774, 33, 317, 69, 78, 318, 985, 322, 302, - /* 420 */ 985, 262, 985, 736, 724, 744, 745, 690, 216, 9, - /* 430 */ 285, 36, 692, 147, 72, 65, 26, 36, 287, 691, - /* 440 */ 36, 288, 65, 808, 789, 237, 597, 775, 93, 65, - /* 450 */ 16, 74, 15, 25, 25, 107, 25, 106, 18, 709, - /* 460 */ 17, 710, 707, 198, 708, 6, 20, 113, 19, 112, - /* 470 */ 199, 22, 201, 21, 126, 125, 196, 202, 203, 679, - /* 480 */ 208, 209, 210, 207, 193, 1057, 1056, 227, 1053, 1052, - /* 490 */ 228, 321, 258, 785, 144, 1009, 45, 1020, 1017, 1018, - /* 500 */ 1002, 786, 265, 1022, 1039, 163, 146, 150, 274, 1038, - /* 510 */ 983, 164, 142, 981, 165, 166, 791, 896, 290, 43, - /* 520 */ 735, 999, 191, 39, 279, 154, 269, 299, 892, 306, - /* 530 */ 224, 1116, 104, 1115, 271, 1112, 278, 170, 73, 70, - /* 540 */ 153, 47, 313, 283, 1108, 281, 110, 1107, 1104, 171, - /* 550 */ 914, 155, 277, 40, 37, 44, 275, 156, 192, 273, - /* 560 */ 880, 120, 878, 122, 123, 158, 876, 875, 270, 250, - /* 570 */ 182, 873, 872, 871, 870, 869, 46, 868, 185, 331, - /* 580 */ 187, 865, 863, 861, 859, 189, 856, 190, 115, 263, - /* 590 */ 79, 84, 272, 323, 1040, 324, 325, 326, 327, 328, - /* 600 */ 329, 341, 833, 252, 214, 832, 251, 254, 234, 289, - /* 610 */ 255, 831, 814, 813, 259, 211, 212, 264, 98, 10, - /* 620 */ 99, 82, 284, 712, 266, 85, 30, 874, 737, 148, - /* 630 */ 867, 174, 133, 173, 915, 172, 175, 176, 178, 177, - /* 640 */ 134, 135, 916, 136, 866, 952, 858, 4, 857, 740, - /* 650 */ 162, 159, 157, 149, 86, 160, 964, 2, 161, 742, - /* 660 */ 87, 226, 276, 31, 746, 151, 11, 32, 13, 12, - /* 670 */ 27, 28, 286, 643, 94, 96, 639, 637, 636, 635, - /* 680 */ 632, 297, 7, 100, 602, 790, 303, 792, 8, 304, - /* 690 */ 103, 682, 66, 105, 36, 67, 109, 111, 681, 678, - /* 700 */ 624, 622, 614, 620, 616, 618, 612, 610, 646, 645, - /* 710 */ 644, 642, 641, 640, 638, 634, 633, 181, 600, 566, - /* 720 */ 564, 837, 836, 836, 836, 836, 836, 836, 836, 836, - /* 730 */ 836, 836, 836, 138, 139, + /* 230 */ 299, 238, 785, 306, 83, 774, 90, 777, 116, 780, + /* 240 */ 331, 238, 785, 152, 35, 774, 331, 777, 200, 780, + /* 250 */ 78, 35, 773, 94, 91, 35, 237, 62, 60, 63, + /* 260 */ 61, 1, 167, 217, 218, 53, 52, 302, 42, 51, + /* 270 */ 50, 49, 76, 217, 218, 41, 6, 339, 338, 881, + /* 280 */ 74, 1044, 337, 280, 179, 336, 335, 230, 334, 333, + /* 290 */ 260, 982, 75, 954, 310, 952, 953, 678, 982, 213, + /* 300 */ 955, 92, 981, 957, 956, 970, 958, 959, 677, 702, + /* 310 */ 64, 242, 699, 282, 700, 88, 701, 776, 247, 779, + /* 320 */ 64, 114, 108, 119, 984, 321, 320, 891, 118, 124, + /* 330 */ 127, 117, 179, 968, 969, 34, 972, 121, 35, 1114, + /* 340 */ 244, 245, 786, 781, 775, 35, 778, 340, 915, 782, + /* 350 */ 3, 180, 786, 781, 35, 5, 38, 169, 718, 782, + /* 360 */ 35, 35, 168, 102, 97, 101, 188, 186, 184, 35, + /* 370 */ 35, 1091, 882, 183, 132, 131, 130, 179, 51, 50, + /* 380 */ 49, 311, 243, 303, 241, 982, 309, 308, 312, 249, + /* 390 */ 1090, 246, 982, 316, 315, 751, 752, 313, 143, 141, + /* 400 */ 140, 982, 715, 317, 318, 262, 68, 982, 982, 343, + /* 410 */ 342, 137, 319, 323, 81, 36, 982, 982, 734, 703, + /* 420 */ 704, 71, 1089, 742, 743, 1054, 688, 285, 147, 9, + /* 430 */ 690, 783, 287, 65, 26, 689, 36, 36, 722, 33, + /* 440 */ 65, 806, 93, 787, 596, 65, 126, 125, 264, 69, + /* 450 */ 16, 25, 15, 25, 25, 1106, 215, 107, 784, 106, + /* 460 */ 216, 198, 72, 18, 707, 17, 708, 199, 288, 705, + /* 470 */ 201, 706, 20, 196, 19, 113, 202, 112, 203, 208, + /* 480 */ 789, 209, 210, 207, 193, 1053, 227, 22, 1050, 21, + /* 490 */ 1049, 258, 228, 322, 144, 1006, 45, 1017, 1036, 1014, + /* 500 */ 1015, 1035, 999, 265, 980, 142, 996, 1019, 146, 163, + /* 510 */ 150, 269, 274, 164, 978, 224, 165, 157, 271, 166, + /* 520 */ 894, 290, 43, 191, 733, 39, 153, 154, 300, 278, + /* 530 */ 155, 283, 890, 73, 307, 156, 70, 47, 281, 279, + /* 540 */ 277, 275, 1113, 158, 104, 273, 1112, 1109, 270, 170, + /* 550 */ 314, 1105, 110, 46, 162, 1104, 159, 332, 1101, 171, + /* 560 */ 912, 40, 115, 37, 324, 44, 192, 878, 120, 876, + /* 570 */ 122, 123, 874, 873, 250, 182, 871, 870, 869, 868, + /* 580 */ 867, 866, 185, 187, 863, 861, 859, 857, 189, 854, + /* 590 */ 190, 325, 263, 79, 84, 272, 1037, 326, 327, 328, + /* 600 */ 329, 330, 341, 831, 251, 214, 234, 289, 252, 830, + /* 610 */ 254, 255, 829, 812, 811, 98, 211, 99, 212, 259, + /* 620 */ 264, 284, 10, 82, 710, 266, 30, 85, 735, 872, + /* 630 */ 865, 178, 913, 172, 176, 173, 174, 133, 175, 177, + /* 640 */ 134, 2, 135, 950, 864, 4, 856, 914, 136, 855, + /* 650 */ 148, 160, 738, 149, 161, 86, 226, 740, 87, 276, + /* 660 */ 31, 744, 961, 151, 11, 32, 12, 13, 27, 286, + /* 670 */ 28, 94, 96, 642, 639, 638, 636, 635, 634, 631, + /* 680 */ 601, 298, 7, 304, 100, 790, 788, 305, 680, 8, + /* 690 */ 103, 66, 105, 67, 109, 111, 679, 676, 623, 621, + /* 700 */ 613, 36, 619, 615, 617, 611, 609, 645, 644, 643, + /* 710 */ 641, 640, 637, 633, 632, 181, 599, 138, 565, 563, + /* 720 */ 835, 834, 834, 834, 834, 834, 834, 834, 834, 834, + /* 730 */ 834, 139, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 259, 1, 194, 1, 193, 194, 259, 191, 192, 9, @@ -303,59 +303,59 @@ static const YYCODETYPE yy_lookahead[] = { /* 180 */ 106, 215, 216, 217, 218, 219, 220, 221, 222, 223, /* 190 */ 224, 225, 226, 227, 228, 229, 16, 17, 44, 231, /* 200 */ 20, 21, 137, 23, 24, 25, 26, 27, 28, 194, - /* 210 */ 259, 146, 147, 33, 34, 61, 84, 37, 38, 39, + /* 210 */ 259, 146, 147, 33, 34, 61, 1, 37, 38, 39, /* 220 */ 33, 34, 68, 80, 37, 38, 39, 73, 74, 75, - /* 230 */ 82, 1, 2, 79, 80, 5, 81, 7, 76, 9, - /* 240 */ 259, 1, 2, 199, 194, 5, 84, 7, 204, 9, - /* 250 */ 62, 63, 64, 110, 111, 259, 241, 69, 70, 71, - /* 260 */ 72, 242, 194, 33, 34, 194, 78, 37, 114, 92, - /* 270 */ 115, 94, 95, 33, 34, 68, 99, 259, 101, 102, - /* 280 */ 103, 2, 105, 106, 5, 242, 7, 237, 9, 259, - /* 290 */ 136, 241, 138, 215, 5, 217, 218, 213, 214, 145, - /* 300 */ 222, 68, 224, 225, 226, 237, 228, 229, 194, 241, - /* 310 */ 80, 194, 33, 34, 202, 203, 25, 26, 27, 28, - /* 320 */ 80, 199, 33, 34, 33, 34, 204, 242, 37, 38, - /* 330 */ 39, 62, 63, 64, 201, 264, 259, 266, 69, 70, - /* 340 */ 71, 72, 112, 113, 37, 201, 139, 194, 141, 119, - /* 350 */ 143, 144, 112, 113, 237, 62, 63, 64, 241, 119, - /* 360 */ 194, 194, 69, 70, 71, 72, 233, 234, 235, 236, - /* 370 */ 194, 91, 139, 194, 141, 194, 143, 144, 234, 5, - /* 380 */ 266, 7, 268, 199, 37, 38, 39, 5, 204, 7, - /* 390 */ 237, 112, 113, 91, 241, 65, 66, 67, 62, 63, - /* 400 */ 64, 243, 91, 237, 237, 197, 198, 241, 241, 127, - /* 410 */ 128, 1, 80, 237, 134, 257, 237, 241, 237, 15, - /* 420 */ 241, 81, 241, 81, 117, 81, 81, 81, 259, 118, - /* 430 */ 81, 91, 81, 91, 132, 91, 91, 91, 81, 81, - /* 440 */ 91, 109, 91, 81, 81, 60, 81, 37, 91, 91, - /* 450 */ 140, 80, 142, 91, 91, 140, 91, 142, 140, 5, - /* 460 */ 142, 7, 5, 259, 7, 80, 140, 140, 142, 142, - /* 470 */ 259, 140, 259, 142, 76, 77, 259, 259, 259, 108, - /* 480 */ 259, 259, 259, 259, 259, 232, 232, 232, 232, 232, - /* 490 */ 232, 232, 194, 119, 194, 194, 258, 194, 194, 194, - /* 500 */ 240, 119, 240, 194, 267, 244, 194, 194, 194, 267, - /* 510 */ 240, 194, 60, 194, 194, 194, 112, 194, 194, 194, - /* 520 */ 119, 255, 194, 194, 124, 253, 263, 194, 194, 194, - /* 530 */ 263, 194, 194, 194, 263, 194, 263, 194, 131, 133, - /* 540 */ 254, 130, 194, 125, 194, 129, 194, 194, 194, 194, - /* 550 */ 194, 252, 123, 194, 194, 194, 122, 251, 194, 121, - /* 560 */ 194, 194, 194, 194, 194, 249, 194, 194, 120, 194, - /* 570 */ 194, 194, 194, 194, 194, 194, 135, 194, 194, 107, - /* 580 */ 194, 194, 194, 194, 194, 194, 194, 194, 90, 195, - /* 590 */ 195, 195, 195, 89, 195, 50, 86, 88, 54, 87, - /* 600 */ 85, 82, 5, 5, 195, 5, 148, 148, 195, 195, - /* 610 */ 5, 5, 94, 93, 137, 195, 195, 115, 201, 80, - /* 620 */ 201, 116, 109, 81, 91, 91, 80, 195, 81, 80, - /* 630 */ 195, 206, 196, 210, 212, 211, 209, 207, 205, 208, - /* 640 */ 196, 196, 214, 196, 195, 230, 195, 197, 195, 81, - /* 650 */ 245, 248, 250, 91, 80, 247, 230, 202, 246, 81, - /* 660 */ 80, 1, 80, 91, 81, 80, 126, 91, 80, 126, - /* 670 */ 80, 80, 109, 9, 110, 76, 5, 5, 5, 5, - /* 680 */ 5, 15, 80, 76, 83, 81, 24, 112, 80, 58, - /* 690 */ 142, 5, 16, 142, 91, 16, 142, 142, 5, 81, - /* 700 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 710 */ 5, 5, 5, 5, 5, 5, 5, 91, 83, 60, - /* 720 */ 59, 0, 270, 270, 270, 270, 270, 270, 270, 270, - /* 730 */ 270, 270, 270, 21, 21, 270, 270, 270, 270, 270, + /* 230 */ 82, 1, 2, 79, 80, 5, 243, 7, 76, 9, + /* 240 */ 84, 1, 2, 194, 194, 5, 84, 7, 259, 9, + /* 250 */ 257, 194, 37, 110, 111, 194, 60, 25, 26, 27, + /* 260 */ 28, 202, 203, 33, 34, 33, 34, 37, 114, 37, + /* 270 */ 38, 39, 201, 33, 34, 92, 80, 94, 95, 199, + /* 280 */ 80, 266, 99, 268, 204, 102, 103, 237, 105, 106, + /* 290 */ 136, 241, 138, 215, 237, 217, 218, 5, 241, 145, + /* 300 */ 222, 201, 241, 225, 226, 234, 228, 229, 108, 2, + /* 310 */ 80, 68, 5, 264, 7, 266, 9, 5, 68, 7, + /* 320 */ 80, 62, 63, 64, 242, 33, 34, 199, 69, 70, + /* 330 */ 71, 72, 204, 233, 234, 235, 236, 78, 194, 242, + /* 340 */ 33, 34, 112, 113, 5, 194, 7, 213, 214, 119, + /* 350 */ 197, 198, 112, 113, 194, 62, 63, 64, 37, 119, + /* 360 */ 194, 194, 69, 70, 71, 72, 62, 63, 64, 194, + /* 370 */ 194, 259, 199, 69, 70, 71, 72, 204, 37, 38, + /* 380 */ 39, 237, 139, 15, 141, 241, 143, 144, 237, 139, + /* 390 */ 259, 141, 241, 143, 144, 127, 128, 237, 62, 63, + /* 400 */ 64, 241, 91, 237, 237, 81, 91, 241, 241, 65, + /* 410 */ 66, 67, 237, 237, 81, 91, 241, 241, 81, 112, + /* 420 */ 113, 91, 259, 81, 81, 232, 81, 81, 91, 118, + /* 430 */ 81, 119, 81, 91, 91, 81, 91, 91, 117, 80, + /* 440 */ 91, 81, 91, 81, 81, 91, 76, 77, 115, 134, + /* 450 */ 140, 91, 142, 91, 91, 242, 259, 140, 119, 142, + /* 460 */ 259, 259, 132, 140, 5, 142, 7, 259, 109, 5, + /* 470 */ 259, 7, 140, 259, 142, 140, 259, 142, 259, 259, + /* 480 */ 112, 259, 259, 259, 259, 232, 232, 140, 232, 142, + /* 490 */ 232, 194, 232, 232, 194, 194, 258, 194, 267, 194, + /* 500 */ 194, 267, 240, 240, 240, 60, 255, 194, 194, 244, + /* 510 */ 194, 263, 194, 194, 194, 263, 194, 250, 263, 194, + /* 520 */ 194, 194, 194, 194, 119, 194, 254, 253, 194, 263, + /* 530 */ 252, 125, 194, 131, 194, 251, 133, 130, 129, 124, + /* 540 */ 123, 122, 194, 249, 194, 121, 194, 194, 120, 194, + /* 550 */ 194, 194, 194, 135, 245, 194, 248, 107, 194, 194, + /* 560 */ 194, 194, 90, 194, 89, 194, 194, 194, 194, 194, + /* 570 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + /* 580 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, + /* 590 */ 194, 50, 195, 195, 195, 195, 195, 86, 88, 54, + /* 600 */ 87, 85, 82, 5, 148, 195, 195, 195, 5, 5, + /* 610 */ 148, 5, 5, 94, 93, 201, 195, 201, 195, 137, + /* 620 */ 115, 109, 80, 116, 81, 91, 80, 91, 81, 195, + /* 630 */ 195, 205, 212, 211, 207, 210, 206, 196, 209, 208, + /* 640 */ 196, 202, 196, 230, 195, 197, 195, 214, 196, 195, + /* 650 */ 80, 247, 81, 91, 246, 80, 1, 81, 80, 80, + /* 660 */ 91, 81, 230, 80, 126, 91, 126, 80, 80, 109, + /* 670 */ 80, 110, 76, 9, 5, 5, 5, 5, 5, 5, + /* 680 */ 83, 15, 80, 24, 76, 112, 81, 58, 5, 80, + /* 690 */ 142, 16, 142, 16, 142, 142, 5, 81, 5, 5, + /* 700 */ 5, 91, 5, 5, 5, 5, 5, 5, 5, 5, + /* 710 */ 5, 5, 5, 5, 5, 91, 83, 21, 60, 59, + /* 720 */ 0, 270, 270, 270, 270, 270, 270, 270, 270, 270, + /* 730 */ 270, 21, 270, 270, 270, 270, 270, 270, 270, 270, /* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 760 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, @@ -374,109 +374,109 @@ static const YYCODETYPE yy_lookahead[] = { /* 890 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 900 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 910 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 920 */ 270, 270, 270, 270, 270, + /* 920 */ 270, 270, }; #define YY_SHIFT_COUNT (346) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (721) +#define YY_SHIFT_MAX (720) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 154, 74, 74, 177, 177, 76, 230, 240, 240, 2, + /* 0 */ 154, 74, 74, 183, 183, 76, 230, 240, 240, 2, /* 10 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - /* 20 */ 9, 9, 9, 0, 48, 240, 279, 279, 279, 3, - /* 30 */ 3, 9, 9, 9, 148, 9, 9, 162, 76, 132, - /* 40 */ 132, 66, 735, 735, 735, 240, 240, 240, 240, 240, + /* 20 */ 9, 9, 9, 0, 48, 240, 307, 307, 307, 3, + /* 30 */ 3, 9, 9, 9, 148, 9, 9, 162, 76, 156, + /* 40 */ 156, 66, 732, 732, 732, 240, 240, 240, 240, 240, /* 50 */ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, - /* 60 */ 240, 240, 240, 240, 240, 279, 279, 279, 289, 289, - /* 70 */ 289, 289, 289, 289, 289, 9, 9, 9, 307, 9, - /* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 282, 282, + /* 60 */ 240, 240, 240, 240, 240, 307, 307, 307, 292, 292, + /* 70 */ 292, 292, 292, 292, 292, 9, 9, 9, 321, 9, + /* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 268, 268, /* 90 */ 311, 3, 9, 9, 9, 9, 9, 9, 9, 9, /* 100 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 110 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 120 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 130 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - /* 140 */ 9, 9, 9, 9, 452, 452, 452, 401, 401, 401, - /* 150 */ 452, 401, 452, 407, 406, 411, 418, 416, 400, 429, - /* 160 */ 434, 438, 448, 441, 452, 452, 452, 472, 76, 76, - /* 170 */ 452, 452, 498, 504, 545, 510, 509, 544, 512, 515, - /* 180 */ 472, 66, 452, 519, 519, 452, 519, 452, 519, 452, - /* 190 */ 452, 735, 735, 27, 99, 99, 126, 99, 53, 180, - /* 200 */ 291, 291, 291, 291, 188, 269, 293, 187, 187, 187, - /* 210 */ 187, 207, 233, 65, 143, 347, 347, 374, 382, 330, - /* 220 */ 336, 340, 26, 155, 342, 344, 345, 280, 302, 346, - /* 230 */ 349, 351, 357, 358, 332, 362, 363, 410, 385, 404, - /* 240 */ 365, 310, 315, 318, 454, 457, 326, 327, 371, 331, - /* 250 */ 398, 597, 458, 598, 600, 459, 605, 606, 518, 520, - /* 260 */ 477, 502, 513, 539, 505, 542, 546, 533, 534, 547, - /* 270 */ 549, 568, 562, 574, 578, 580, 660, 582, 583, 585, - /* 280 */ 572, 540, 576, 543, 588, 513, 590, 563, 591, 564, - /* 290 */ 599, 664, 671, 672, 673, 674, 675, 601, 666, 607, - /* 300 */ 602, 604, 575, 608, 662, 631, 676, 548, 551, 603, - /* 310 */ 603, 603, 603, 679, 554, 555, 603, 603, 603, 686, - /* 320 */ 693, 618, 603, 695, 696, 697, 698, 699, 700, 701, - /* 330 */ 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, - /* 340 */ 626, 635, 712, 713, 659, 661, 721, + /* 140 */ 9, 9, 9, 9, 445, 445, 445, 405, 405, 405, + /* 150 */ 445, 405, 445, 402, 403, 406, 407, 409, 415, 417, + /* 160 */ 419, 424, 428, 418, 445, 445, 445, 450, 76, 76, + /* 170 */ 445, 445, 472, 475, 541, 511, 510, 545, 513, 516, + /* 180 */ 450, 66, 445, 520, 520, 445, 520, 445, 520, 445, + /* 190 */ 445, 732, 732, 27, 99, 99, 126, 99, 53, 180, + /* 200 */ 232, 232, 232, 232, 259, 293, 304, 187, 187, 187, + /* 210 */ 187, 243, 250, 65, 143, 341, 341, 312, 339, 344, + /* 220 */ 336, 324, 26, 333, 337, 342, 343, 315, 330, 345, + /* 230 */ 346, 349, 351, 354, 359, 360, 362, 215, 196, 368, + /* 240 */ 363, 310, 317, 323, 459, 464, 332, 335, 200, 347, + /* 250 */ 370, 598, 456, 603, 604, 462, 606, 607, 519, 521, + /* 260 */ 482, 505, 512, 542, 507, 543, 546, 534, 536, 547, + /* 270 */ 570, 571, 562, 575, 576, 578, 655, 579, 580, 583, + /* 280 */ 569, 538, 574, 540, 587, 512, 588, 560, 590, 561, + /* 290 */ 596, 664, 669, 670, 671, 672, 673, 674, 597, 666, + /* 300 */ 608, 602, 605, 573, 609, 659, 629, 675, 548, 550, + /* 310 */ 610, 610, 610, 610, 677, 552, 553, 610, 610, 610, + /* 320 */ 683, 691, 616, 610, 693, 694, 695, 697, 698, 699, + /* 330 */ 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, + /* 340 */ 624, 633, 696, 710, 658, 660, 720, }; #define YY_REDUCE_COUNT (192) #define YY_REDUCE_MIN (-259) -#define YY_REDUCE_MAX (455) +#define YY_REDUCE_MAX (454) static const short yy_reduce_ofst[] = { - /* 0 */ -184, -34, -34, 78, 78, 133, -141, -138, -125, -106, - /* 10 */ -152, 114, 71, -80, 50, 68, 117, 153, 166, 167, - /* 20 */ 176, 179, 181, -192, -189, -247, -223, -207, -206, -211, - /* 30 */ -210, -136, -131, -110, -91, -32, 15, 44, 144, 122, - /* 40 */ 184, 84, 158, 112, 208, -259, -253, -49, -19, -4, - /* 50 */ 18, 30, 77, 169, 204, 211, 213, 217, 218, 219, - /* 60 */ 221, 222, 223, 224, 225, 19, 43, 85, 253, 254, - /* 70 */ 255, 256, 257, 258, 259, 298, 300, 301, 238, 303, - /* 80 */ 304, 305, 260, 262, 309, 312, 313, 314, 237, 242, - /* 90 */ 261, 270, 317, 319, 320, 321, 323, 324, 325, 328, - /* 100 */ 329, 333, 334, 335, 337, 338, 339, 341, 343, 348, - /* 110 */ 350, 352, 353, 354, 355, 356, 359, 360, 361, 364, - /* 120 */ 366, 367, 368, 369, 370, 372, 373, 375, 376, 377, - /* 130 */ 378, 379, 380, 381, 383, 384, 386, 387, 388, 389, - /* 140 */ 390, 391, 392, 393, 394, 395, 396, 263, 267, 271, - /* 150 */ 397, 273, 399, 266, 286, 272, 299, 306, 402, 316, - /* 160 */ 403, 408, 412, 405, 409, 413, 414, 415, 417, 419, - /* 170 */ 420, 421, 422, 424, 423, 425, 427, 430, 431, 433, - /* 180 */ 426, 428, 432, 436, 444, 435, 445, 449, 447, 451, - /* 190 */ 453, 455, 450, + /* 0 */ -184, -34, -34, 78, 78, 100, -141, -138, -125, -106, + /* 10 */ -152, 15, 49, -80, 50, 57, 144, 151, 160, 166, + /* 20 */ 167, 175, 176, -192, -189, -247, -223, -207, -206, -211, + /* 30 */ -210, -136, -131, -110, -91, -32, 61, 80, 71, 128, + /* 40 */ 173, 134, -7, 59, 153, -259, -253, -49, -11, 112, + /* 50 */ 131, 163, 197, 201, 202, 208, 211, 214, 217, 219, + /* 60 */ 220, 222, 223, 224, 225, 82, 97, 213, 193, 253, + /* 70 */ 254, 256, 258, 260, 261, 297, 300, 301, 238, 303, + /* 80 */ 305, 306, 262, 263, 313, 314, 316, 318, 231, 234, + /* 90 */ 265, 264, 319, 320, 322, 325, 326, 327, 328, 329, + /* 100 */ 331, 334, 338, 340, 348, 350, 352, 353, 355, 356, + /* 110 */ 357, 358, 361, 364, 365, 366, 367, 369, 371, 372, + /* 120 */ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, + /* 130 */ 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, + /* 140 */ 393, 394, 395, 396, 397, 398, 399, 248, 252, 255, + /* 150 */ 400, 266, 401, 251, 272, 274, 278, 284, 267, 294, + /* 160 */ 308, 404, 408, 309, 410, 411, 412, 413, 414, 416, + /* 170 */ 421, 423, 420, 422, 425, 430, 429, 427, 431, 426, + /* 180 */ 432, 433, 434, 441, 444, 435, 446, 449, 452, 451, + /* 190 */ 454, 439, 448, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 834, 951, 894, 963, 881, 891, 1100, 1100, 1100, 834, - /* 10 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 20 */ 834, 834, 834, 1011, 853, 1100, 834, 834, 834, 834, - /* 30 */ 834, 834, 834, 834, 891, 834, 834, 897, 891, 897, - /* 40 */ 897, 834, 1006, 935, 953, 834, 834, 834, 834, 834, - /* 50 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 60 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 70 */ 834, 834, 834, 834, 834, 834, 834, 834, 1013, 1019, - /* 80 */ 1016, 834, 834, 834, 1021, 834, 834, 834, 1043, 1043, - /* 90 */ 1004, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 100 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 110 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 120 */ 879, 834, 877, 834, 834, 834, 834, 834, 834, 834, - /* 130 */ 834, 834, 834, 834, 834, 834, 834, 864, 834, 834, - /* 140 */ 834, 834, 834, 834, 855, 855, 855, 834, 834, 834, - /* 150 */ 855, 834, 855, 1050, 1054, 1048, 1036, 1044, 1035, 1031, - /* 160 */ 1029, 1027, 1026, 1058, 855, 855, 855, 895, 891, 891, - /* 170 */ 855, 855, 913, 911, 909, 901, 907, 903, 905, 899, - /* 180 */ 882, 834, 855, 889, 889, 855, 889, 855, 889, 855, - /* 190 */ 855, 935, 953, 834, 1059, 1049, 834, 1099, 1089, 1088, - /* 200 */ 1095, 1087, 1086, 1085, 834, 834, 834, 1081, 1084, 1083, - /* 210 */ 1082, 834, 834, 834, 834, 1091, 1090, 834, 834, 834, - /* 220 */ 834, 834, 834, 834, 834, 834, 834, 1055, 1051, 834, - /* 230 */ 834, 834, 834, 834, 834, 834, 834, 834, 1061, 834, - /* 240 */ 834, 834, 834, 834, 834, 834, 834, 834, 965, 834, - /* 250 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 260 */ 834, 1003, 834, 834, 834, 834, 834, 1015, 1014, 834, - /* 270 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 280 */ 1045, 834, 1037, 834, 834, 977, 834, 834, 834, 834, - /* 290 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 300 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 1118, - /* 310 */ 1113, 1114, 1111, 834, 834, 834, 1110, 1105, 1106, 834, - /* 320 */ 834, 834, 1103, 834, 834, 834, 834, 834, 834, 834, - /* 330 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 340 */ 919, 834, 862, 860, 834, 851, 834, + /* 0 */ 832, 949, 892, 960, 879, 889, 1097, 1097, 1097, 832, + /* 10 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 20 */ 832, 832, 832, 1008, 851, 1097, 832, 832, 832, 832, + /* 30 */ 832, 832, 832, 832, 889, 832, 832, 895, 889, 895, + /* 40 */ 895, 832, 1003, 933, 951, 832, 832, 832, 832, 832, + /* 50 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 60 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 70 */ 832, 832, 832, 832, 832, 832, 832, 832, 1010, 1016, + /* 80 */ 1013, 832, 832, 832, 1018, 832, 832, 832, 1040, 1040, + /* 90 */ 1001, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 100 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 110 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 120 */ 877, 832, 875, 832, 832, 832, 832, 832, 832, 832, + /* 130 */ 832, 832, 832, 832, 832, 832, 832, 862, 832, 832, + /* 140 */ 832, 832, 832, 832, 853, 853, 853, 832, 832, 832, + /* 150 */ 853, 832, 853, 1047, 1051, 1033, 1045, 1041, 1032, 1028, + /* 160 */ 1026, 1024, 1023, 1055, 853, 853, 853, 893, 889, 889, + /* 170 */ 853, 853, 911, 909, 907, 899, 905, 901, 903, 897, + /* 180 */ 880, 832, 853, 887, 887, 853, 887, 853, 887, 853, + /* 190 */ 853, 933, 951, 832, 1056, 1046, 832, 1096, 1086, 1085, + /* 200 */ 1092, 1084, 1083, 1082, 832, 832, 832, 1078, 1081, 1080, + /* 210 */ 1079, 832, 832, 832, 832, 1088, 1087, 832, 832, 832, + /* 220 */ 832, 832, 832, 832, 832, 832, 832, 1052, 1048, 832, + /* 230 */ 832, 832, 832, 832, 832, 832, 832, 832, 1058, 832, + /* 240 */ 832, 832, 832, 832, 832, 832, 832, 832, 962, 832, + /* 250 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 260 */ 832, 1000, 832, 832, 832, 832, 832, 1012, 1011, 832, + /* 270 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 280 */ 1042, 832, 1034, 832, 832, 974, 832, 832, 832, 832, + /* 290 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 300 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 310 */ 1115, 1110, 1111, 1108, 832, 832, 832, 1107, 1102, 1103, + /* 320 */ 832, 832, 832, 1100, 832, 832, 832, 832, 832, 832, + /* 330 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, + /* 340 */ 917, 832, 860, 858, 832, 849, 832, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1024,8 +1024,8 @@ static const char *const yyTokenName[] = { /* 249 */ "fill_opt", /* 250 */ "sliding_opt", /* 251 */ "groupby_opt", - /* 252 */ "orderby_opt", - /* 253 */ "having_opt", + /* 252 */ "having_opt", + /* 253 */ "orderby_opt", /* 254 */ "slimit_opt", /* 255 */ "limit_opt", /* 256 */ "union", @@ -1171,169 +1171,168 @@ static const char *const yyRuleName[] = { /* 119 */ "alter_db_optr ::= alter_db_optr keep", /* 120 */ "alter_db_optr ::= alter_db_optr blocks", /* 121 */ "alter_db_optr ::= alter_db_optr comp", - /* 122 */ "alter_db_optr ::= alter_db_optr wal", - /* 123 */ "alter_db_optr ::= alter_db_optr fsync", - /* 124 */ "alter_db_optr ::= alter_db_optr update", - /* 125 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 126 */ "alter_topic_optr ::= alter_db_optr", - /* 127 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 128 */ "typename ::= ids", - /* 129 */ "typename ::= ids LP signed RP", - /* 130 */ "typename ::= ids UNSIGNED", - /* 131 */ "signed ::= INTEGER", - /* 132 */ "signed ::= PLUS INTEGER", - /* 133 */ "signed ::= MINUS INTEGER", - /* 134 */ "cmd ::= CREATE TABLE create_table_args", - /* 135 */ "cmd ::= CREATE TABLE create_stable_args", - /* 136 */ "cmd ::= CREATE STABLE create_stable_args", - /* 137 */ "cmd ::= CREATE TABLE create_table_list", - /* 138 */ "create_table_list ::= create_from_stable", - /* 139 */ "create_table_list ::= create_table_list create_from_stable", - /* 140 */ "create_table_args ::= ifnotexists ids cpxName LP columnlist RP", - /* 141 */ "create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP", - /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP", - /* 143 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP", - /* 144 */ "tagNamelist ::= tagNamelist COMMA ids", - /* 145 */ "tagNamelist ::= ids", - /* 146 */ "create_table_args ::= ifnotexists ids cpxName AS select", - /* 147 */ "columnlist ::= columnlist COMMA column", - /* 148 */ "columnlist ::= column", - /* 149 */ "column ::= ids typename", - /* 150 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 151 */ "tagitemlist ::= tagitem", - /* 152 */ "tagitem ::= INTEGER", - /* 153 */ "tagitem ::= FLOAT", - /* 154 */ "tagitem ::= STRING", - /* 155 */ "tagitem ::= BOOL", - /* 156 */ "tagitem ::= NULL", - /* 157 */ "tagitem ::= NOW", - /* 158 */ "tagitem ::= MINUS INTEGER", - /* 159 */ "tagitem ::= MINUS FLOAT", - /* 160 */ "tagitem ::= PLUS INTEGER", - /* 161 */ "tagitem ::= PLUS FLOAT", - /* 162 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 163 */ "select ::= LP select RP", - /* 164 */ "union ::= select", - /* 165 */ "union ::= union UNION ALL select", - /* 166 */ "cmd ::= union", - /* 167 */ "select ::= SELECT selcollist", - /* 168 */ "sclp ::= selcollist COMMA", - /* 169 */ "sclp ::=", - /* 170 */ "selcollist ::= sclp distinct expr as", - /* 171 */ "selcollist ::= sclp STAR", - /* 172 */ "as ::= AS ids", - /* 173 */ "as ::= ids", - /* 174 */ "as ::=", - /* 175 */ "distinct ::= DISTINCT", - /* 176 */ "distinct ::=", - /* 177 */ "from ::= FROM tablelist", - /* 178 */ "from ::= FROM sub", - /* 179 */ "sub ::= LP union RP", - /* 180 */ "sub ::= LP union RP ids", - /* 181 */ "sub ::= sub COMMA LP union RP ids", - /* 182 */ "tablelist ::= ids cpxName", - /* 183 */ "tablelist ::= ids cpxName ids", - /* 184 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 185 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 186 */ "tmvar ::= VARIABLE", - /* 187 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 188 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 189 */ "interval_opt ::=", - /* 190 */ "session_option ::=", - /* 191 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 192 */ "windowstate_option ::=", - /* 193 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 194 */ "fill_opt ::=", - /* 195 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 196 */ "fill_opt ::= FILL LP ID RP", - /* 197 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 198 */ "sliding_opt ::=", - /* 199 */ "orderby_opt ::=", - /* 200 */ "orderby_opt ::= ORDER BY sortlist", - /* 201 */ "sortlist ::= sortlist COMMA item sortorder", - /* 202 */ "sortlist ::= item sortorder", - /* 203 */ "item ::= ids cpxName", - /* 204 */ "sortorder ::= ASC", - /* 205 */ "sortorder ::= DESC", - /* 206 */ "sortorder ::=", - /* 207 */ "groupby_opt ::=", - /* 208 */ "groupby_opt ::= GROUP BY grouplist", - /* 209 */ "grouplist ::= grouplist COMMA item", - /* 210 */ "grouplist ::= item", - /* 211 */ "having_opt ::=", - /* 212 */ "having_opt ::= HAVING expr", - /* 213 */ "limit_opt ::=", - /* 214 */ "limit_opt ::= LIMIT signed", - /* 215 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 216 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 217 */ "slimit_opt ::=", - /* 218 */ "slimit_opt ::= SLIMIT signed", - /* 219 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 220 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 221 */ "where_opt ::=", - /* 222 */ "where_opt ::= WHERE expr", - /* 223 */ "expr ::= LP expr RP", - /* 224 */ "expr ::= ID", - /* 225 */ "expr ::= ID DOT ID", - /* 226 */ "expr ::= ID DOT STAR", - /* 227 */ "expr ::= INTEGER", - /* 228 */ "expr ::= MINUS INTEGER", - /* 229 */ "expr ::= PLUS INTEGER", - /* 230 */ "expr ::= FLOAT", - /* 231 */ "expr ::= MINUS FLOAT", - /* 232 */ "expr ::= PLUS FLOAT", - /* 233 */ "expr ::= STRING", - /* 234 */ "expr ::= NOW", - /* 235 */ "expr ::= VARIABLE", - /* 236 */ "expr ::= PLUS VARIABLE", - /* 237 */ "expr ::= MINUS VARIABLE", - /* 238 */ "expr ::= BOOL", - /* 239 */ "expr ::= NULL", - /* 240 */ "expr ::= ID LP exprlist RP", - /* 241 */ "expr ::= ID LP STAR RP", - /* 242 */ "expr ::= expr IS NULL", - /* 243 */ "expr ::= expr IS NOT NULL", - /* 244 */ "expr ::= expr LT expr", - /* 245 */ "expr ::= expr GT expr", - /* 246 */ "expr ::= expr LE expr", - /* 247 */ "expr ::= expr GE expr", - /* 248 */ "expr ::= expr NE expr", - /* 249 */ "expr ::= expr EQ expr", - /* 250 */ "expr ::= expr BETWEEN expr AND expr", - /* 251 */ "expr ::= expr AND expr", - /* 252 */ "expr ::= expr OR expr", - /* 253 */ "expr ::= expr PLUS expr", - /* 254 */ "expr ::= expr MINUS expr", - /* 255 */ "expr ::= expr STAR expr", - /* 256 */ "expr ::= expr SLASH expr", - /* 257 */ "expr ::= expr REM expr", - /* 258 */ "expr ::= expr LIKE expr", - /* 259 */ "expr ::= expr IN LP exprlist RP", - /* 260 */ "exprlist ::= exprlist COMMA expritem", - /* 261 */ "exprlist ::= expritem", - /* 262 */ "expritem ::= expr", - /* 263 */ "expritem ::=", - /* 264 */ "cmd ::= RESET QUERY CACHE", - /* 265 */ "cmd ::= SYNCDB ids REPLICA", - /* 266 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 267 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 268 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 269 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 270 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 271 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 272 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 273 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 274 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 275 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 276 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 277 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 278 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 279 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 280 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 281 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 282 */ "cmd ::= KILL CONNECTION INTEGER", - /* 283 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 284 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 122 */ "alter_db_optr ::= alter_db_optr fsync", + /* 123 */ "alter_db_optr ::= alter_db_optr update", + /* 124 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 125 */ "alter_topic_optr ::= alter_db_optr", + /* 126 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 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 tagitemlist RP", + /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist 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 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 150 */ "tagitemlist ::= tagitem", + /* 151 */ "tagitem ::= INTEGER", + /* 152 */ "tagitem ::= FLOAT", + /* 153 */ "tagitem ::= STRING", + /* 154 */ "tagitem ::= BOOL", + /* 155 */ "tagitem ::= NULL", + /* 156 */ "tagitem ::= NOW", + /* 157 */ "tagitem ::= MINUS INTEGER", + /* 158 */ "tagitem ::= MINUS FLOAT", + /* 159 */ "tagitem ::= PLUS INTEGER", + /* 160 */ "tagitem ::= PLUS FLOAT", + /* 161 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 162 */ "select ::= LP select RP", + /* 163 */ "union ::= select", + /* 164 */ "union ::= union UNION ALL select", + /* 165 */ "cmd ::= union", + /* 166 */ "select ::= SELECT selcollist", + /* 167 */ "sclp ::= selcollist COMMA", + /* 168 */ "sclp ::=", + /* 169 */ "selcollist ::= sclp distinct expr as", + /* 170 */ "selcollist ::= sclp STAR", + /* 171 */ "as ::= AS ids", + /* 172 */ "as ::= ids", + /* 173 */ "as ::=", + /* 174 */ "distinct ::= DISTINCT", + /* 175 */ "distinct ::=", + /* 176 */ "from ::= FROM tablelist", + /* 177 */ "from ::= FROM sub", + /* 178 */ "sub ::= LP union RP", + /* 179 */ "sub ::= LP union RP ids", + /* 180 */ "sub ::= sub COMMA LP union RP ids", + /* 181 */ "tablelist ::= ids cpxName", + /* 182 */ "tablelist ::= ids cpxName ids", + /* 183 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 184 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 185 */ "tmvar ::= VARIABLE", + /* 186 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 187 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 188 */ "interval_opt ::=", + /* 189 */ "session_option ::=", + /* 190 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 191 */ "windowstate_option ::=", + /* 192 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 193 */ "fill_opt ::=", + /* 194 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 195 */ "fill_opt ::= FILL LP ID RP", + /* 196 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 197 */ "sliding_opt ::=", + /* 198 */ "orderby_opt ::=", + /* 199 */ "orderby_opt ::= ORDER BY sortlist", + /* 200 */ "sortlist ::= sortlist COMMA item sortorder", + /* 201 */ "sortlist ::= item sortorder", + /* 202 */ "item ::= ids cpxName", + /* 203 */ "sortorder ::= ASC", + /* 204 */ "sortorder ::= DESC", + /* 205 */ "sortorder ::=", + /* 206 */ "groupby_opt ::=", + /* 207 */ "groupby_opt ::= GROUP BY grouplist", + /* 208 */ "grouplist ::= grouplist COMMA item", + /* 209 */ "grouplist ::= item", + /* 210 */ "having_opt ::=", + /* 211 */ "having_opt ::= HAVING expr", + /* 212 */ "limit_opt ::=", + /* 213 */ "limit_opt ::= LIMIT signed", + /* 214 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 215 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 216 */ "slimit_opt ::=", + /* 217 */ "slimit_opt ::= SLIMIT signed", + /* 218 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 219 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 220 */ "where_opt ::=", + /* 221 */ "where_opt ::= WHERE expr", + /* 222 */ "expr ::= LP expr RP", + /* 223 */ "expr ::= ID", + /* 224 */ "expr ::= ID DOT ID", + /* 225 */ "expr ::= ID DOT STAR", + /* 226 */ "expr ::= INTEGER", + /* 227 */ "expr ::= MINUS INTEGER", + /* 228 */ "expr ::= PLUS INTEGER", + /* 229 */ "expr ::= FLOAT", + /* 230 */ "expr ::= MINUS FLOAT", + /* 231 */ "expr ::= PLUS FLOAT", + /* 232 */ "expr ::= STRING", + /* 233 */ "expr ::= NOW", + /* 234 */ "expr ::= VARIABLE", + /* 235 */ "expr ::= PLUS VARIABLE", + /* 236 */ "expr ::= MINUS VARIABLE", + /* 237 */ "expr ::= BOOL", + /* 238 */ "expr ::= NULL", + /* 239 */ "expr ::= ID LP exprlist RP", + /* 240 */ "expr ::= ID LP STAR RP", + /* 241 */ "expr ::= expr IS NULL", + /* 242 */ "expr ::= expr IS NOT NULL", + /* 243 */ "expr ::= expr LT expr", + /* 244 */ "expr ::= expr GT expr", + /* 245 */ "expr ::= expr LE expr", + /* 246 */ "expr ::= expr GE expr", + /* 247 */ "expr ::= expr NE expr", + /* 248 */ "expr ::= expr EQ expr", + /* 249 */ "expr ::= expr BETWEEN expr AND expr", + /* 250 */ "expr ::= expr AND expr", + /* 251 */ "expr ::= expr OR expr", + /* 252 */ "expr ::= expr PLUS expr", + /* 253 */ "expr ::= expr MINUS expr", + /* 254 */ "expr ::= expr STAR expr", + /* 255 */ "expr ::= expr SLASH expr", + /* 256 */ "expr ::= expr REM expr", + /* 257 */ "expr ::= expr LIKE expr", + /* 258 */ "expr ::= expr IN LP exprlist RP", + /* 259 */ "exprlist ::= exprlist COMMA expritem", + /* 260 */ "exprlist ::= expritem", + /* 261 */ "expritem ::= expr", + /* 262 */ "expritem ::=", + /* 263 */ "cmd ::= RESET QUERY CACHE", + /* 264 */ "cmd ::= SYNCDB ids REPLICA", + /* 265 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 266 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 267 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 268 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 269 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 270 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 271 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 272 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 273 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 274 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 275 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 276 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 277 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 278 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 279 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 280 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 281 */ "cmd ::= KILL CONNECTION INTEGER", + /* 282 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 283 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1468,7 +1467,7 @@ tSqlExprListDestroy((yypminor->yy441)); case 239: /* tagNamelist */ case 249: /* fill_opt */ case 251: /* groupby_opt */ - case 252: /* orderby_opt */ + case 253: /* orderby_opt */ case 264: /* sortlist */ case 268: /* grouplist */ { @@ -1493,7 +1492,7 @@ destroyRelationInfo((yypminor->yy244)); } break; case 245: /* where_opt */ - case 253: /* having_opt */ + case 252: /* having_opt */ case 259: /* expr */ case 269: /* expritem */ { @@ -1923,169 +1922,168 @@ static const struct { { 197, -2 }, /* (119) alter_db_optr ::= alter_db_optr keep */ { 197, -2 }, /* (120) alter_db_optr ::= alter_db_optr blocks */ { 197, -2 }, /* (121) alter_db_optr ::= alter_db_optr comp */ - { 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr wal */ - { 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr fsync */ - { 197, -2 }, /* (124) alter_db_optr ::= alter_db_optr update */ - { 197, -2 }, /* (125) alter_db_optr ::= alter_db_optr cachelast */ - { 198, -1 }, /* (126) alter_topic_optr ::= alter_db_optr */ - { 198, -2 }, /* (127) alter_topic_optr ::= alter_topic_optr partitions */ - { 231, -1 }, /* (128) typename ::= ids */ - { 231, -4 }, /* (129) typename ::= ids LP signed RP */ - { 231, -2 }, /* (130) typename ::= ids UNSIGNED */ - { 232, -1 }, /* (131) signed ::= INTEGER */ - { 232, -2 }, /* (132) signed ::= PLUS INTEGER */ - { 232, -2 }, /* (133) signed ::= MINUS INTEGER */ - { 192, -3 }, /* (134) cmd ::= CREATE TABLE create_table_args */ - { 192, -3 }, /* (135) cmd ::= CREATE TABLE create_stable_args */ - { 192, -3 }, /* (136) cmd ::= CREATE STABLE create_stable_args */ - { 192, -3 }, /* (137) cmd ::= CREATE TABLE create_table_list */ - { 235, -1 }, /* (138) create_table_list ::= create_from_stable */ - { 235, -2 }, /* (139) create_table_list ::= create_table_list create_from_stable */ - { 233, -6 }, /* (140) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 234, -10 }, /* (141) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 236, -10 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 236, -13 }, /* (143) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - { 239, -3 }, /* (144) tagNamelist ::= tagNamelist COMMA ids */ - { 239, -1 }, /* (145) tagNamelist ::= ids */ - { 233, -5 }, /* (146) create_table_args ::= ifnotexists ids cpxName AS select */ - { 237, -3 }, /* (147) columnlist ::= columnlist COMMA column */ - { 237, -1 }, /* (148) columnlist ::= column */ - { 241, -2 }, /* (149) column ::= ids typename */ - { 238, -3 }, /* (150) tagitemlist ::= tagitemlist COMMA tagitem */ - { 238, -1 }, /* (151) tagitemlist ::= tagitem */ - { 242, -1 }, /* (152) tagitem ::= INTEGER */ - { 242, -1 }, /* (153) tagitem ::= FLOAT */ - { 242, -1 }, /* (154) tagitem ::= STRING */ - { 242, -1 }, /* (155) tagitem ::= BOOL */ - { 242, -1 }, /* (156) tagitem ::= NULL */ - { 242, -1 }, /* (157) tagitem ::= NOW */ - { 242, -2 }, /* (158) tagitem ::= MINUS INTEGER */ - { 242, -2 }, /* (159) tagitem ::= MINUS FLOAT */ - { 242, -2 }, /* (160) tagitem ::= PLUS INTEGER */ - { 242, -2 }, /* (161) tagitem ::= PLUS FLOAT */ - { 240, -14 }, /* (162) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 240, -3 }, /* (163) select ::= LP select RP */ - { 256, -1 }, /* (164) union ::= select */ - { 256, -4 }, /* (165) union ::= union UNION ALL select */ - { 192, -1 }, /* (166) cmd ::= union */ - { 240, -2 }, /* (167) select ::= SELECT selcollist */ - { 257, -2 }, /* (168) sclp ::= selcollist COMMA */ - { 257, 0 }, /* (169) sclp ::= */ - { 243, -4 }, /* (170) selcollist ::= sclp distinct expr as */ - { 243, -2 }, /* (171) selcollist ::= sclp STAR */ - { 260, -2 }, /* (172) as ::= AS ids */ - { 260, -1 }, /* (173) as ::= ids */ - { 260, 0 }, /* (174) as ::= */ - { 258, -1 }, /* (175) distinct ::= DISTINCT */ - { 258, 0 }, /* (176) distinct ::= */ - { 244, -2 }, /* (177) from ::= FROM tablelist */ - { 244, -2 }, /* (178) from ::= FROM sub */ - { 262, -3 }, /* (179) sub ::= LP union RP */ - { 262, -4 }, /* (180) sub ::= LP union RP ids */ - { 262, -6 }, /* (181) sub ::= sub COMMA LP union RP ids */ - { 261, -2 }, /* (182) tablelist ::= ids cpxName */ - { 261, -3 }, /* (183) tablelist ::= ids cpxName ids */ - { 261, -4 }, /* (184) tablelist ::= tablelist COMMA ids cpxName */ - { 261, -5 }, /* (185) tablelist ::= tablelist COMMA ids cpxName ids */ - { 263, -1 }, /* (186) tmvar ::= VARIABLE */ - { 246, -4 }, /* (187) interval_opt ::= INTERVAL LP tmvar RP */ - { 246, -6 }, /* (188) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 246, 0 }, /* (189) interval_opt ::= */ - { 247, 0 }, /* (190) session_option ::= */ - { 247, -7 }, /* (191) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 248, 0 }, /* (192) windowstate_option ::= */ - { 248, -4 }, /* (193) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 249, 0 }, /* (194) fill_opt ::= */ - { 249, -6 }, /* (195) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 249, -4 }, /* (196) fill_opt ::= FILL LP ID RP */ - { 250, -4 }, /* (197) sliding_opt ::= SLIDING LP tmvar RP */ - { 250, 0 }, /* (198) sliding_opt ::= */ - { 252, 0 }, /* (199) orderby_opt ::= */ - { 252, -3 }, /* (200) orderby_opt ::= ORDER BY sortlist */ - { 264, -4 }, /* (201) sortlist ::= sortlist COMMA item sortorder */ - { 264, -2 }, /* (202) sortlist ::= item sortorder */ - { 266, -2 }, /* (203) item ::= ids cpxName */ - { 267, -1 }, /* (204) sortorder ::= ASC */ - { 267, -1 }, /* (205) sortorder ::= DESC */ - { 267, 0 }, /* (206) sortorder ::= */ - { 251, 0 }, /* (207) groupby_opt ::= */ - { 251, -3 }, /* (208) groupby_opt ::= GROUP BY grouplist */ - { 268, -3 }, /* (209) grouplist ::= grouplist COMMA item */ - { 268, -1 }, /* (210) grouplist ::= item */ - { 253, 0 }, /* (211) having_opt ::= */ - { 253, -2 }, /* (212) having_opt ::= HAVING expr */ - { 255, 0 }, /* (213) limit_opt ::= */ - { 255, -2 }, /* (214) limit_opt ::= LIMIT signed */ - { 255, -4 }, /* (215) limit_opt ::= LIMIT signed OFFSET signed */ - { 255, -4 }, /* (216) limit_opt ::= LIMIT signed COMMA signed */ - { 254, 0 }, /* (217) slimit_opt ::= */ - { 254, -2 }, /* (218) slimit_opt ::= SLIMIT signed */ - { 254, -4 }, /* (219) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 254, -4 }, /* (220) slimit_opt ::= SLIMIT signed COMMA signed */ - { 245, 0 }, /* (221) where_opt ::= */ - { 245, -2 }, /* (222) where_opt ::= WHERE expr */ - { 259, -3 }, /* (223) expr ::= LP expr RP */ - { 259, -1 }, /* (224) expr ::= ID */ - { 259, -3 }, /* (225) expr ::= ID DOT ID */ - { 259, -3 }, /* (226) expr ::= ID DOT STAR */ - { 259, -1 }, /* (227) expr ::= INTEGER */ - { 259, -2 }, /* (228) expr ::= MINUS INTEGER */ - { 259, -2 }, /* (229) expr ::= PLUS INTEGER */ - { 259, -1 }, /* (230) expr ::= FLOAT */ - { 259, -2 }, /* (231) expr ::= MINUS FLOAT */ - { 259, -2 }, /* (232) expr ::= PLUS FLOAT */ - { 259, -1 }, /* (233) expr ::= STRING */ - { 259, -1 }, /* (234) expr ::= NOW */ - { 259, -1 }, /* (235) expr ::= VARIABLE */ - { 259, -2 }, /* (236) expr ::= PLUS VARIABLE */ - { 259, -2 }, /* (237) expr ::= MINUS VARIABLE */ - { 259, -1 }, /* (238) expr ::= BOOL */ - { 259, -1 }, /* (239) expr ::= NULL */ - { 259, -4 }, /* (240) expr ::= ID LP exprlist RP */ - { 259, -4 }, /* (241) expr ::= ID LP STAR RP */ - { 259, -3 }, /* (242) expr ::= expr IS NULL */ - { 259, -4 }, /* (243) expr ::= expr IS NOT NULL */ - { 259, -3 }, /* (244) expr ::= expr LT expr */ - { 259, -3 }, /* (245) expr ::= expr GT expr */ - { 259, -3 }, /* (246) expr ::= expr LE expr */ - { 259, -3 }, /* (247) expr ::= expr GE expr */ - { 259, -3 }, /* (248) expr ::= expr NE expr */ - { 259, -3 }, /* (249) expr ::= expr EQ expr */ - { 259, -5 }, /* (250) expr ::= expr BETWEEN expr AND expr */ - { 259, -3 }, /* (251) expr ::= expr AND expr */ - { 259, -3 }, /* (252) expr ::= expr OR expr */ - { 259, -3 }, /* (253) expr ::= expr PLUS expr */ - { 259, -3 }, /* (254) expr ::= expr MINUS expr */ - { 259, -3 }, /* (255) expr ::= expr STAR expr */ - { 259, -3 }, /* (256) expr ::= expr SLASH expr */ - { 259, -3 }, /* (257) expr ::= expr REM expr */ - { 259, -3 }, /* (258) expr ::= expr LIKE expr */ - { 259, -5 }, /* (259) expr ::= expr IN LP exprlist RP */ - { 200, -3 }, /* (260) exprlist ::= exprlist COMMA expritem */ - { 200, -1 }, /* (261) exprlist ::= expritem */ - { 269, -1 }, /* (262) expritem ::= expr */ - { 269, 0 }, /* (263) expritem ::= */ - { 192, -3 }, /* (264) cmd ::= RESET QUERY CACHE */ - { 192, -3 }, /* (265) cmd ::= SYNCDB ids REPLICA */ - { 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 192, -7 }, /* (269) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 192, -7 }, /* (270) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 192, -8 }, /* (271) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 192, -9 }, /* (272) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 192, -7 }, /* (273) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 192, -7 }, /* (277) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 192, -7 }, /* (278) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 192, -8 }, /* (279) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 192, -9 }, /* (280) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 192, -7 }, /* (281) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 192, -3 }, /* (282) cmd ::= KILL CONNECTION INTEGER */ - { 192, -5 }, /* (283) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 192, -5 }, /* (284) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr fsync */ + { 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr update */ + { 197, -2 }, /* (124) alter_db_optr ::= alter_db_optr cachelast */ + { 198, -1 }, /* (125) alter_topic_optr ::= alter_db_optr */ + { 198, -2 }, /* (126) alter_topic_optr ::= alter_topic_optr partitions */ + { 231, -1 }, /* (127) typename ::= ids */ + { 231, -4 }, /* (128) typename ::= ids LP signed RP */ + { 231, -2 }, /* (129) typename ::= ids UNSIGNED */ + { 232, -1 }, /* (130) signed ::= INTEGER */ + { 232, -2 }, /* (131) signed ::= PLUS INTEGER */ + { 232, -2 }, /* (132) signed ::= MINUS INTEGER */ + { 192, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ + { 192, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ + { 192, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ + { 192, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ + { 235, -1 }, /* (137) create_table_list ::= create_from_stable */ + { 235, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ + { 233, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 234, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 236, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 236, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 239, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ + { 239, -1 }, /* (144) tagNamelist ::= ids */ + { 233, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ + { 237, -3 }, /* (146) columnlist ::= columnlist COMMA column */ + { 237, -1 }, /* (147) columnlist ::= column */ + { 241, -2 }, /* (148) column ::= ids typename */ + { 238, -3 }, /* (149) tagitemlist ::= tagitemlist COMMA tagitem */ + { 238, -1 }, /* (150) tagitemlist ::= tagitem */ + { 242, -1 }, /* (151) tagitem ::= INTEGER */ + { 242, -1 }, /* (152) tagitem ::= FLOAT */ + { 242, -1 }, /* (153) tagitem ::= STRING */ + { 242, -1 }, /* (154) tagitem ::= BOOL */ + { 242, -1 }, /* (155) tagitem ::= NULL */ + { 242, -1 }, /* (156) tagitem ::= NOW */ + { 242, -2 }, /* (157) tagitem ::= MINUS INTEGER */ + { 242, -2 }, /* (158) tagitem ::= MINUS FLOAT */ + { 242, -2 }, /* (159) tagitem ::= PLUS INTEGER */ + { 242, -2 }, /* (160) tagitem ::= PLUS FLOAT */ + { 240, -14 }, /* (161) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 240, -3 }, /* (162) select ::= LP select RP */ + { 256, -1 }, /* (163) union ::= select */ + { 256, -4 }, /* (164) union ::= union UNION ALL select */ + { 192, -1 }, /* (165) cmd ::= union */ + { 240, -2 }, /* (166) select ::= SELECT selcollist */ + { 257, -2 }, /* (167) sclp ::= selcollist COMMA */ + { 257, 0 }, /* (168) sclp ::= */ + { 243, -4 }, /* (169) selcollist ::= sclp distinct expr as */ + { 243, -2 }, /* (170) selcollist ::= sclp STAR */ + { 260, -2 }, /* (171) as ::= AS ids */ + { 260, -1 }, /* (172) as ::= ids */ + { 260, 0 }, /* (173) as ::= */ + { 258, -1 }, /* (174) distinct ::= DISTINCT */ + { 258, 0 }, /* (175) distinct ::= */ + { 244, -2 }, /* (176) from ::= FROM tablelist */ + { 244, -2 }, /* (177) from ::= FROM sub */ + { 262, -3 }, /* (178) sub ::= LP union RP */ + { 262, -4 }, /* (179) sub ::= LP union RP ids */ + { 262, -6 }, /* (180) sub ::= sub COMMA LP union RP ids */ + { 261, -2 }, /* (181) tablelist ::= ids cpxName */ + { 261, -3 }, /* (182) tablelist ::= ids cpxName ids */ + { 261, -4 }, /* (183) tablelist ::= tablelist COMMA ids cpxName */ + { 261, -5 }, /* (184) tablelist ::= tablelist COMMA ids cpxName ids */ + { 263, -1 }, /* (185) tmvar ::= VARIABLE */ + { 246, -4 }, /* (186) interval_opt ::= INTERVAL LP tmvar RP */ + { 246, -6 }, /* (187) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 246, 0 }, /* (188) interval_opt ::= */ + { 247, 0 }, /* (189) session_option ::= */ + { 247, -7 }, /* (190) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 248, 0 }, /* (191) windowstate_option ::= */ + { 248, -4 }, /* (192) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 249, 0 }, /* (193) fill_opt ::= */ + { 249, -6 }, /* (194) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 249, -4 }, /* (195) fill_opt ::= FILL LP ID RP */ + { 250, -4 }, /* (196) sliding_opt ::= SLIDING LP tmvar RP */ + { 250, 0 }, /* (197) sliding_opt ::= */ + { 253, 0 }, /* (198) orderby_opt ::= */ + { 253, -3 }, /* (199) orderby_opt ::= ORDER BY sortlist */ + { 264, -4 }, /* (200) sortlist ::= sortlist COMMA item sortorder */ + { 264, -2 }, /* (201) sortlist ::= item sortorder */ + { 266, -2 }, /* (202) item ::= ids cpxName */ + { 267, -1 }, /* (203) sortorder ::= ASC */ + { 267, -1 }, /* (204) sortorder ::= DESC */ + { 267, 0 }, /* (205) sortorder ::= */ + { 251, 0 }, /* (206) groupby_opt ::= */ + { 251, -3 }, /* (207) groupby_opt ::= GROUP BY grouplist */ + { 268, -3 }, /* (208) grouplist ::= grouplist COMMA item */ + { 268, -1 }, /* (209) grouplist ::= item */ + { 252, 0 }, /* (210) having_opt ::= */ + { 252, -2 }, /* (211) having_opt ::= HAVING expr */ + { 255, 0 }, /* (212) limit_opt ::= */ + { 255, -2 }, /* (213) limit_opt ::= LIMIT signed */ + { 255, -4 }, /* (214) limit_opt ::= LIMIT signed OFFSET signed */ + { 255, -4 }, /* (215) limit_opt ::= LIMIT signed COMMA signed */ + { 254, 0 }, /* (216) slimit_opt ::= */ + { 254, -2 }, /* (217) slimit_opt ::= SLIMIT signed */ + { 254, -4 }, /* (218) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 254, -4 }, /* (219) slimit_opt ::= SLIMIT signed COMMA signed */ + { 245, 0 }, /* (220) where_opt ::= */ + { 245, -2 }, /* (221) where_opt ::= WHERE expr */ + { 259, -3 }, /* (222) expr ::= LP expr RP */ + { 259, -1 }, /* (223) expr ::= ID */ + { 259, -3 }, /* (224) expr ::= ID DOT ID */ + { 259, -3 }, /* (225) expr ::= ID DOT STAR */ + { 259, -1 }, /* (226) expr ::= INTEGER */ + { 259, -2 }, /* (227) expr ::= MINUS INTEGER */ + { 259, -2 }, /* (228) expr ::= PLUS INTEGER */ + { 259, -1 }, /* (229) expr ::= FLOAT */ + { 259, -2 }, /* (230) expr ::= MINUS FLOAT */ + { 259, -2 }, /* (231) expr ::= PLUS FLOAT */ + { 259, -1 }, /* (232) expr ::= STRING */ + { 259, -1 }, /* (233) expr ::= NOW */ + { 259, -1 }, /* (234) expr ::= VARIABLE */ + { 259, -2 }, /* (235) expr ::= PLUS VARIABLE */ + { 259, -2 }, /* (236) expr ::= MINUS VARIABLE */ + { 259, -1 }, /* (237) expr ::= BOOL */ + { 259, -1 }, /* (238) expr ::= NULL */ + { 259, -4 }, /* (239) expr ::= ID LP exprlist RP */ + { 259, -4 }, /* (240) expr ::= ID LP STAR RP */ + { 259, -3 }, /* (241) expr ::= expr IS NULL */ + { 259, -4 }, /* (242) expr ::= expr IS NOT NULL */ + { 259, -3 }, /* (243) expr ::= expr LT expr */ + { 259, -3 }, /* (244) expr ::= expr GT expr */ + { 259, -3 }, /* (245) expr ::= expr LE expr */ + { 259, -3 }, /* (246) expr ::= expr GE expr */ + { 259, -3 }, /* (247) expr ::= expr NE expr */ + { 259, -3 }, /* (248) expr ::= expr EQ expr */ + { 259, -5 }, /* (249) expr ::= expr BETWEEN expr AND expr */ + { 259, -3 }, /* (250) expr ::= expr AND expr */ + { 259, -3 }, /* (251) expr ::= expr OR expr */ + { 259, -3 }, /* (252) expr ::= expr PLUS expr */ + { 259, -3 }, /* (253) expr ::= expr MINUS expr */ + { 259, -3 }, /* (254) expr ::= expr STAR expr */ + { 259, -3 }, /* (255) expr ::= expr SLASH expr */ + { 259, -3 }, /* (256) expr ::= expr REM expr */ + { 259, -3 }, /* (257) expr ::= expr LIKE expr */ + { 259, -5 }, /* (258) expr ::= expr IN LP exprlist RP */ + { 200, -3 }, /* (259) exprlist ::= exprlist COMMA expritem */ + { 200, -1 }, /* (260) exprlist ::= expritem */ + { 269, -1 }, /* (261) expritem ::= expr */ + { 269, 0 }, /* (262) expritem ::= */ + { 192, -3 }, /* (263) cmd ::= RESET QUERY CACHE */ + { 192, -3 }, /* (264) cmd ::= SYNCDB ids REPLICA */ + { 192, -7 }, /* (265) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 192, -7 }, /* (269) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 192, -8 }, /* (270) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 192, -9 }, /* (271) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 192, -7 }, /* (272) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 192, -7 }, /* (273) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 192, -7 }, /* (277) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 192, -8 }, /* (278) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 192, -9 }, /* (279) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 192, -7 }, /* (280) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 192, -3 }, /* (281) cmd ::= KILL CONNECTION INTEGER */ + { 192, -5 }, /* (282) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 192, -5 }, /* (283) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2166,9 +2164,9 @@ static void yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* program ::= cmd */ - case 134: /* cmd ::= CREATE TABLE create_table_args */ yytestcase(yyruleno==134); - case 135: /* cmd ::= CREATE TABLE create_stable_args */ yytestcase(yyruleno==135); - case 136: /* cmd ::= CREATE STABLE create_stable_args */ yytestcase(yyruleno==136); + 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 */ @@ -2359,7 +2357,7 @@ static void yy_reduce( break; case 52: /* ifexists ::= */ case 54: /* ifnotexists ::= */ yytestcase(yyruleno==54); - case 176: /* distinct ::= */ yytestcase(yyruleno==176); + case 175: /* distinct ::= */ yytestcase(yyruleno==175); { yymsp[1].minor.yy0.n = 0;} break; case 53: /* ifnotexists ::= IF NOT EXISTS */ @@ -2415,20 +2413,20 @@ static void yy_reduce( yymsp[-8].minor.yy151 = yylhsminor.yy151; break; case 79: /* intitemlist ::= intitemlist COMMA intitem */ - case 150: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==150); + case 149: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==149); { yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; case 80: /* intitemlist ::= intitem */ - case 151: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==151); + case 150: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==150); { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; case 81: /* intitem ::= INTEGER */ - case 152: /* tagitem ::= INTEGER */ yytestcase(yyruleno==152); - case 153: /* tagitem ::= FLOAT */ yytestcase(yyruleno==153); - case 154: /* tagitem ::= STRING */ yytestcase(yyruleno==154); - case 155: /* tagitem ::= BOOL */ yytestcase(yyruleno==155); + case 151: /* tagitem ::= INTEGER */ yytestcase(yyruleno==151); + case 152: /* tagitem ::= FLOAT */ yytestcase(yyruleno==152); + case 153: /* tagitem ::= STRING */ yytestcase(yyruleno==153); + case 154: /* tagitem ::= BOOL */ yytestcase(yyruleno==154); { toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } yymsp[0].minor.yy506 = yylhsminor.yy506; break; @@ -2491,12 +2489,11 @@ static void yy_reduce( yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 107: /* db_optr ::= db_optr wal */ - case 122: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==122); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 108: /* db_optr ::= db_optr fsync */ - case 123: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==123); + case 122: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==122); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; @@ -2515,36 +2512,36 @@ static void yy_reduce( yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 112: /* db_optr ::= db_optr update */ - case 124: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==124); + case 123: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==123); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 113: /* db_optr ::= db_optr cachelast */ - case 125: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==125); + case 124: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==124); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 114: /* topic_optr ::= db_optr */ - case 126: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==126); + case 125: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==125); { yylhsminor.yy382 = yymsp[0].minor.yy382; yylhsminor.yy382.dbType = TSDB_DB_TYPE_TOPIC; } yymsp[0].minor.yy382 = yylhsminor.yy382; break; case 115: /* topic_optr ::= topic_optr partitions */ - case 127: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==127); + case 126: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==126); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 116: /* alter_db_optr ::= */ { setDefaultCreateDbOption(&yymsp[1].minor.yy382); yymsp[1].minor.yy382.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 128: /* typename ::= ids */ + case 127: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; tSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0); } yymsp[0].minor.yy343 = yylhsminor.yy343; break; - case 129: /* typename ::= ids LP signed RP */ + case 128: /* typename ::= ids LP signed RP */ { if (yymsp[-1].minor.yy369 <= 0) { yymsp[-3].minor.yy0.type = 0; @@ -2556,7 +2553,7 @@ static void yy_reduce( } yymsp[-3].minor.yy343 = yylhsminor.yy343; break; - case 130: /* 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); @@ -2564,20 +2561,20 @@ static void yy_reduce( } yymsp[-1].minor.yy343 = yylhsminor.yy343; break; - case 131: /* signed ::= INTEGER */ + case 130: /* signed ::= INTEGER */ { yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy369 = yylhsminor.yy369; break; - case 132: /* signed ::= PLUS INTEGER */ + case 131: /* signed ::= PLUS INTEGER */ { yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 133: /* signed ::= MINUS INTEGER */ + case 132: /* signed ::= MINUS INTEGER */ { yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 137: /* 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.yy182;} break; - case 138: /* 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)); @@ -2588,14 +2585,14 @@ static void yy_reduce( } yymsp[0].minor.yy182 = yylhsminor.yy182; break; - case 139: /* create_table_list ::= create_table_list create_from_stable */ + case 138: /* create_table_list ::= create_table_list create_from_stable */ { taosArrayPush(yymsp[-1].minor.yy182->childTableInfo, &yymsp[0].minor.yy456); yylhsminor.yy182 = yymsp[-1].minor.yy182; } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 140: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-1].minor.yy441, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2605,7 +2602,7 @@ static void yy_reduce( } yymsp[-5].minor.yy182 = yylhsminor.yy182; break; - case 141: /* 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.yy182 = tSetCreateTableInfo(yymsp[-5].minor.yy441, yymsp[-1].minor.yy441, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2615,7 +2612,7 @@ static void yy_reduce( } yymsp[-9].minor.yy182 = yylhsminor.yy182; break; - case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2623,7 +2620,7 @@ static void yy_reduce( } yymsp[-9].minor.yy456 = yylhsminor.yy456; break; - case 143: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; @@ -2631,15 +2628,15 @@ static void yy_reduce( } yymsp[-12].minor.yy456 = yylhsminor.yy456; break; - case 144: /* tagNamelist ::= tagNamelist COMMA ids */ + case 143: /* tagNamelist ::= tagNamelist COMMA ids */ {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy0); yylhsminor.yy441 = yymsp[-2].minor.yy441; } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 145: /* tagNamelist ::= ids */ + case 144: /* tagNamelist ::= ids */ {yylhsminor.yy441 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy0);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 146: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ { yylhsminor.yy182 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy236, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2649,32 +2646,32 @@ static void yy_reduce( } yymsp[-4].minor.yy182 = yylhsminor.yy182; break; - case 147: /* columnlist ::= columnlist COMMA column */ + case 146: /* columnlist ::= columnlist COMMA column */ {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy343); yylhsminor.yy441 = yymsp[-2].minor.yy441; } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 148: /* columnlist ::= column */ + case 147: /* columnlist ::= column */ {yylhsminor.yy441 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy343);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 149: /* column ::= ids typename */ + case 148: /* column ::= ids typename */ { tSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343); } yymsp[-1].minor.yy343 = yylhsminor.yy343; break; - case 156: /* tagitem ::= NULL */ + case 155: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } yymsp[0].minor.yy506 = yylhsminor.yy506; break; - case 157: /* tagitem ::= NOW */ + case 156: /* tagitem ::= NOW */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0);} yymsp[0].minor.yy506 = yylhsminor.yy506; break; - case 158: /* tagitem ::= MINUS INTEGER */ - case 159: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==159); - case 160: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==160); - case 161: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==161); + case 157: /* tagitem ::= MINUS INTEGER */ + case 158: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==158); + case 159: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==159); + case 160: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==160); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2683,142 +2680,142 @@ static void yy_reduce( } yymsp[-1].minor.yy506 = yylhsminor.yy506; break; - case 162: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + case 161: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy441, yymsp[-11].minor.yy244, yymsp[-10].minor.yy166, yymsp[-4].minor.yy441, yymsp[-3].minor.yy441, &yymsp[-9].minor.yy340, &yymsp[-8].minor.yy259, &yymsp[-7].minor.yy348, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy441, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414, yymsp[-2].minor.yy166); + yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy441, yymsp[-11].minor.yy244, yymsp[-10].minor.yy166, yymsp[-4].minor.yy441, yymsp[-2].minor.yy441, &yymsp[-9].minor.yy340, &yymsp[-8].minor.yy259, &yymsp[-7].minor.yy348, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy441, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414, yymsp[-3].minor.yy166); } yymsp[-13].minor.yy236 = yylhsminor.yy236; break; - case 163: /* select ::= LP select RP */ + case 162: /* select ::= LP select RP */ {yymsp[-2].minor.yy236 = yymsp[-1].minor.yy236;} break; - case 164: /* union ::= select */ + case 163: /* union ::= select */ { yylhsminor.yy441 = setSubclause(NULL, yymsp[0].minor.yy236); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 165: /* union ::= union UNION ALL select */ + case 164: /* union ::= union UNION ALL select */ { yylhsminor.yy441 = appendSelectClause(yymsp[-3].minor.yy441, yymsp[0].minor.yy236); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 166: /* cmd ::= union */ + case 165: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy441, NULL, TSDB_SQL_SELECT); } break; - case 167: /* select ::= SELECT selcollist */ + case 166: /* select ::= SELECT selcollist */ { yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy441, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy236 = yylhsminor.yy236; break; - case 168: /* sclp ::= selcollist COMMA */ + case 167: /* sclp ::= selcollist COMMA */ {yylhsminor.yy441 = yymsp[-1].minor.yy441;} yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 169: /* sclp ::= */ - case 199: /* orderby_opt ::= */ yytestcase(yyruleno==199); + case 168: /* sclp ::= */ + case 198: /* orderby_opt ::= */ yytestcase(yyruleno==198); {yymsp[1].minor.yy441 = 0;} break; - case 170: /* selcollist ::= sclp distinct expr as */ + case 169: /* selcollist ::= sclp distinct expr as */ { yylhsminor.yy441 = tSqlExprListAppend(yymsp[-3].minor.yy441, yymsp[-1].minor.yy166, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 171: /* selcollist ::= sclp STAR */ + case 170: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); yylhsminor.yy441 = tSqlExprListAppend(yymsp[-1].minor.yy441, pNode, 0, 0); } yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 172: /* as ::= AS ids */ + case 171: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 173: /* as ::= ids */ + case 172: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 174: /* as ::= */ + case 173: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 175: /* distinct ::= DISTINCT */ + case 174: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 177: /* from ::= FROM tablelist */ - case 178: /* from ::= FROM sub */ yytestcase(yyruleno==178); + case 176: /* from ::= FROM tablelist */ + case 177: /* from ::= FROM sub */ yytestcase(yyruleno==177); {yymsp[-1].minor.yy244 = yymsp[0].minor.yy244;} break; - case 179: /* sub ::= LP union RP */ + case 178: /* sub ::= LP union RP */ {yymsp[-2].minor.yy244 = addSubqueryElem(NULL, yymsp[-1].minor.yy441, NULL);} break; - case 180: /* sub ::= LP union RP ids */ + case 179: /* sub ::= LP union RP ids */ {yymsp[-3].minor.yy244 = addSubqueryElem(NULL, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} break; - case 181: /* sub ::= sub COMMA LP union RP ids */ + case 180: /* sub ::= sub COMMA LP union RP ids */ {yylhsminor.yy244 = addSubqueryElem(yymsp[-5].minor.yy244, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} yymsp[-5].minor.yy244 = yylhsminor.yy244; break; - case 182: /* tablelist ::= ids cpxName */ + case 181: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } yymsp[-1].minor.yy244 = yylhsminor.yy244; break; - case 183: /* tablelist ::= ids cpxName ids */ + case 182: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy244 = yylhsminor.yy244; break; - case 184: /* tablelist ::= tablelist COMMA ids cpxName */ + case 183: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy244 = setTableNameList(yymsp[-3].minor.yy244, &yymsp[-1].minor.yy0, NULL); } yymsp[-3].minor.yy244 = yylhsminor.yy244; break; - case 185: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 184: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy244 = setTableNameList(yymsp[-4].minor.yy244, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-4].minor.yy244 = yylhsminor.yy244; break; - case 186: /* tmvar ::= VARIABLE */ + case 185: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 187: /* interval_opt ::= INTERVAL LP tmvar RP */ + case 186: /* interval_opt ::= INTERVAL LP tmvar RP */ {yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0;} break; - case 188: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + case 187: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ {yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;} break; - case 189: /* interval_opt ::= */ + case 188: /* interval_opt ::= */ {memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));} break; - case 190: /* session_option ::= */ + case 189: /* session_option ::= */ {yymsp[1].minor.yy259.col.n = 0; yymsp[1].minor.yy259.gap.n = 0;} break; - case 191: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 190: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-6].minor.yy259.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy259.gap = yymsp[-1].minor.yy0; } break; - case 192: /* windowstate_option ::= */ + case 191: /* windowstate_option ::= */ { yymsp[1].minor.yy348.col.n = 0; yymsp[1].minor.yy348.col.z = NULL;} break; - case 193: /* windowstate_option ::= STATE_WINDOW LP ids RP */ + case 192: /* windowstate_option ::= STATE_WINDOW LP ids RP */ { yymsp[-3].minor.yy348.col = yymsp[-1].minor.yy0; } break; - case 194: /* fill_opt ::= */ + case 193: /* fill_opt ::= */ { yymsp[1].minor.yy441 = 0; } break; - case 195: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 194: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2828,34 +2825,34 @@ static void yy_reduce( yymsp[-5].minor.yy441 = yymsp[-1].minor.yy441; } break; - case 196: /* fill_opt ::= FILL LP ID RP */ + case 195: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy441 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 197: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 196: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 198: /* sliding_opt ::= */ + case 197: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 200: /* orderby_opt ::= ORDER BY sortlist */ + case 199: /* orderby_opt ::= ORDER BY sortlist */ {yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} break; - case 201: /* sortlist ::= sortlist COMMA item sortorder */ + case 200: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy441 = tVariantListAppend(yymsp[-3].minor.yy441, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 202: /* sortlist ::= item sortorder */ + case 201: /* sortlist ::= item sortorder */ { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); } yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 203: /* item ::= ids cpxName */ + case 202: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2864,227 +2861,227 @@ static void yy_reduce( } yymsp[-1].minor.yy506 = yylhsminor.yy506; break; - case 204: /* sortorder ::= ASC */ + case 203: /* sortorder ::= ASC */ { yymsp[0].minor.yy112 = TSDB_ORDER_ASC; } break; - case 205: /* sortorder ::= DESC */ + case 204: /* sortorder ::= DESC */ { yymsp[0].minor.yy112 = TSDB_ORDER_DESC;} break; - case 206: /* sortorder ::= */ + case 205: /* sortorder ::= */ { yymsp[1].minor.yy112 = TSDB_ORDER_ASC; } break; - case 207: /* groupby_opt ::= */ + case 206: /* groupby_opt ::= */ { yymsp[1].minor.yy441 = 0;} break; - case 208: /* groupby_opt ::= GROUP BY grouplist */ + case 207: /* groupby_opt ::= GROUP BY grouplist */ { yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} break; - case 209: /* grouplist ::= grouplist COMMA item */ + case 208: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 210: /* grouplist ::= item */ + case 209: /* grouplist ::= item */ { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 211: /* having_opt ::= */ - case 221: /* where_opt ::= */ yytestcase(yyruleno==221); - case 263: /* expritem ::= */ yytestcase(yyruleno==263); + case 210: /* having_opt ::= */ + case 220: /* where_opt ::= */ yytestcase(yyruleno==220); + case 262: /* expritem ::= */ yytestcase(yyruleno==262); {yymsp[1].minor.yy166 = 0;} break; - case 212: /* having_opt ::= HAVING expr */ - case 222: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==222); + case 211: /* having_opt ::= HAVING expr */ + case 221: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==221); {yymsp[-1].minor.yy166 = yymsp[0].minor.yy166;} break; - case 213: /* limit_opt ::= */ - case 217: /* slimit_opt ::= */ yytestcase(yyruleno==217); + case 212: /* limit_opt ::= */ + case 216: /* slimit_opt ::= */ yytestcase(yyruleno==216); {yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;} break; - case 214: /* limit_opt ::= LIMIT signed */ - case 218: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==218); + case 213: /* limit_opt ::= LIMIT signed */ + case 217: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==217); {yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;} break; - case 215: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 214: /* limit_opt ::= LIMIT signed OFFSET signed */ { yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} break; - case 216: /* limit_opt ::= LIMIT signed COMMA signed */ + case 215: /* limit_opt ::= LIMIT signed COMMA signed */ { yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} break; - case 219: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ + case 218: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ {yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} break; - case 220: /* slimit_opt ::= SLIMIT signed COMMA signed */ + case 219: /* slimit_opt ::= SLIMIT signed COMMA signed */ {yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} break; - case 223: /* expr ::= LP expr RP */ + case 222: /* expr ::= LP expr RP */ {yylhsminor.yy166 = yymsp[-1].minor.yy166; yylhsminor.yy166->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy166->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 224: /* expr ::= ID */ + case 223: /* expr ::= ID */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 225: /* expr ::= ID DOT ID */ + case 224: /* expr ::= ID DOT ID */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 226: /* expr ::= ID DOT STAR */ + case 225: /* expr ::= ID DOT STAR */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 227: /* expr ::= INTEGER */ + case 226: /* expr ::= INTEGER */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 228: /* expr ::= MINUS INTEGER */ - case 229: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==229); + case 227: /* expr ::= MINUS INTEGER */ + case 228: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==228); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 230: /* expr ::= FLOAT */ + case 229: /* expr ::= FLOAT */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 231: /* expr ::= MINUS FLOAT */ - case 232: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==232); + case 230: /* expr ::= MINUS FLOAT */ + case 231: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==231); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 233: /* expr ::= STRING */ + case 232: /* expr ::= STRING */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 234: /* expr ::= NOW */ + case 233: /* expr ::= NOW */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 235: /* expr ::= VARIABLE */ + case 234: /* expr ::= VARIABLE */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 236: /* expr ::= PLUS VARIABLE */ - case 237: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==237); + case 235: /* expr ::= PLUS VARIABLE */ + case 236: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==236); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 238: /* expr ::= BOOL */ + case 237: /* expr ::= BOOL */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 239: /* expr ::= NULL */ + case 238: /* expr ::= NULL */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 240: /* expr ::= ID LP exprlist RP */ + case 239: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy166 = tSqlExprCreateFunction(yymsp[-1].minor.yy441, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 241: /* expr ::= ID LP STAR RP */ + case 240: /* expr ::= ID LP STAR RP */ { yylhsminor.yy166 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 242: /* expr ::= expr IS NULL */ + case 241: /* expr ::= expr IS NULL */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, NULL, TK_ISNULL);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 243: /* expr ::= expr IS NOT NULL */ + case 242: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-3].minor.yy166, NULL, TK_NOTNULL);} yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 244: /* expr ::= expr LT expr */ + case 243: /* expr ::= expr LT expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LT);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 245: /* expr ::= expr GT expr */ + case 244: /* expr ::= expr GT expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GT);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 246: /* expr ::= expr LE expr */ + case 245: /* expr ::= expr LE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 247: /* expr ::= expr GE expr */ + case 246: /* expr ::= expr GE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 248: /* expr ::= expr NE expr */ + case 247: /* expr ::= expr NE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_NE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 249: /* expr ::= expr EQ expr */ + case 248: /* expr ::= expr EQ expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_EQ);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 250: /* expr ::= expr BETWEEN expr AND expr */ + case 249: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy166); yylhsminor.yy166 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy166, yymsp[-2].minor.yy166, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy166, TK_LE), TK_AND);} yymsp[-4].minor.yy166 = yylhsminor.yy166; break; - case 251: /* expr ::= expr AND expr */ + case 250: /* expr ::= expr AND expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_AND);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 252: /* expr ::= expr OR expr */ + case 251: /* expr ::= expr OR expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_OR); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 253: /* expr ::= expr PLUS expr */ + case 252: /* expr ::= expr PLUS expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_PLUS); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 254: /* expr ::= expr MINUS expr */ + case 253: /* expr ::= expr MINUS expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_MINUS); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 255: /* expr ::= expr STAR expr */ + case 254: /* expr ::= expr STAR expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_STAR); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 256: /* expr ::= expr SLASH expr */ + case 255: /* expr ::= expr SLASH expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_DIVIDE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 257: /* expr ::= expr REM expr */ + case 256: /* expr ::= expr REM expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_REM); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 258: /* expr ::= expr LIKE expr */ + case 257: /* expr ::= expr LIKE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LIKE); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 259: /* expr ::= expr IN LP exprlist RP */ + case 258: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-4].minor.yy166, (tSqlExpr*)yymsp[-1].minor.yy441, TK_IN); } yymsp[-4].minor.yy166 = yylhsminor.yy166; break; - case 260: /* exprlist ::= exprlist COMMA expritem */ + case 259: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy441 = tSqlExprListAppend(yymsp[-2].minor.yy441,yymsp[0].minor.yy166,0, 0);} yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 261: /* exprlist ::= expritem */ + case 260: /* exprlist ::= expritem */ {yylhsminor.yy441 = tSqlExprListAppend(0,yymsp[0].minor.yy166,0, 0);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 262: /* expritem ::= expr */ + case 261: /* expritem ::= expr */ {yylhsminor.yy166 = yymsp[0].minor.yy166;} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 264: /* cmd ::= RESET QUERY CACHE */ + case 263: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 265: /* cmd ::= SYNCDB ids REPLICA */ + case 264: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 266: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 265: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 267: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 266: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3095,21 +3092,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 268: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 267: /* 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.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 269: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 268: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 270: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 269: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3120,7 +3117,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 271: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 270: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3134,7 +3131,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 272: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 271: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3146,21 +3143,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 273: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 272: /* 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.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 274: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 273: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 275: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 274: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3171,21 +3168,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 276: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 275: /* 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.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 277: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 276: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 278: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 277: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3196,7 +3193,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 279: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 278: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3210,7 +3207,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 280: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 279: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3222,20 +3219,20 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 281: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 280: /* 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.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 282: /* cmd ::= KILL CONNECTION INTEGER */ + case 281: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 283: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 282: /* 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 284: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 283: /* 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 aee50c892962fbd750591e81ecc9280e9fdc9c4d Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Mon, 12 Jul 2021 18:09:50 +0800 Subject: [PATCH 36/65] add unit test --- src/client/src/tscParseLineProtocol.c | 46 ++++++++++++++----------- tests/examples/c/apitest.c | 18 ++++++++-- tests/tsim/inc/sim.h | 4 +++ tests/tsim/src/simExe.c | 46 +++++++++++++++++++++++++ tests/tsim/src/simParse.c | 48 +++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 23 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 61f9cd9e76..77d65f3d15 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -65,6 +65,11 @@ int compareSmlColKv(const void* p1, const void* p2) { } int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { + schema->tags = taosArrayInit(8, sizeof(SSchema)); + schema->fields = taosArrayInit(64, sizeof(SSchema)); + schema->tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema->fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + int32_t code = 0; STscObj *pObj = (STscObj *)taos; @@ -203,7 +208,7 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a pField->bytes = MAX(pField->bytes, bytes); } else { - SSchema field; + SSchema field = {0}; size_t tagKeyLen = strlen(smlKv->key); strncpy(field.name, smlKv->key, tagKeyLen); field.name[tagKeyLen] = '\0'; @@ -371,7 +376,7 @@ int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tabl MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); MD5Final(&context); *tableNameLen = snprintf(tableName, *tableNameLen, - "tbl%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + "tbl_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]); @@ -418,14 +423,15 @@ int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const cha printf("%s", taos_stmt_errstr(stmt)); return code; } - TAOS_RES* res = taos_stmt_use_result(stmt); - return taos_errno(res); + + taos_stmt_close(stmt); + return 0; } int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) { size_t numCols = taosArrayGetSize(colsSchema); - char sql[TSDB_MAX_BINARY_LEN]; - int32_t freeBytes = TSDB_MAX_BINARY_LEN; + char sql[4096]; + int32_t freeBytes = 4096; sprintf(sql, "insert into ? ("); for (int i = 0; i < numCols; ++i) { @@ -454,8 +460,8 @@ int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* r } size_t rows = taosArrayGetSize(rowsBind); for (int32_t i = 0; i < rows; ++i) { - SArray* colBind = taosArrayGetP(rowsBind, i); - code = taos_stmt_bind_param(stmt, TARRAY_GET_START(colBind)); + TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); + code = taos_stmt_bind_param(stmt, colsBinds); if (code != 0) { printf("%s", taos_stmt_errstr(stmt)); return code; @@ -472,8 +478,10 @@ int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* r printf("%s", taos_stmt_errstr(stmt)); return code; } - TAOS_RES* res = taos_stmt_use_result(stmt); - return taos_errno(res); + + + taos_stmt_close(stmt); + return code; } int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) { @@ -526,7 +534,6 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); int32_t numTags = taosArrayGetSize(point->schema->tags); int32_t numCols = taosArrayGetSize(point->schema->fields); - char* ctableName = point->childTableName; SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); taosArraySetSize(tagBinds, numTags); @@ -551,16 +558,15 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) for (int i = 0; i < rows; ++i) { point = taosArrayGetP(cTablePoints, i); - SArray* colBinds = taosArrayInit(numCols, sizeof(TAOS_BIND)); - taosArraySetSize(colBinds, numCols); + TAOS_BIND* colBinds = calloc(numCols, sizeof(TAOS_BIND)); for (int j = 0; j < numCols; ++j) { - TAOS_BIND* bind = taosArrayGet(colBinds, j); + TAOS_BIND* bind = colBinds + j; bind->is_null = &isNullColBind; } for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* kv = point->fields + j; int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); - TAOS_BIND* bind = taosArrayGet(colBinds, idx); + TAOS_BIND* bind = colBinds + idx; bind->buffer_type = kv->type; bind->length = malloc(sizeof(uintptr_t*)); *bind->length = kv->length; @@ -571,7 +577,7 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) } creatChildTableIfNotExists(taos, point->childTableName, point->stableName, point->schema->tags, tagBinds); - insertBatch(taos, ctableName, point->schema->fields, rowsBind); + insertBatch(taos, point->childTableName, point->schema->fields, rowsBind); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } @@ -621,10 +627,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); SSmlSTableSchema dbSchema = {0}; - dbSchema.tags = taosArrayInit(8, sizeof(SSchema)); - dbSchema.fields = taosArrayInit(64, sizeof(SSchema)); - dbSchema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - dbSchema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); @@ -652,6 +654,8 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { applySchemaAction(taos, &schemaAction); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + pointSchema->precision = dbSchema.precision; } } @@ -666,6 +670,8 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); if (actionNeeded) { applySchemaAction(taos, &schemaAction); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + pointSchema->precision = dbSchema.precision; } } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 409140e0f2..75262d74d8 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -965,12 +965,24 @@ int32_t verify_schema_less(TAOS* taos) { char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", + "st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", "ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532", "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - int code = taos_insert_by_lines(taos, lines , 5); + +// int code = taos_insert_by_lines(taos, lines , 5); + int code = taos_insert_by_lines(taos, &(lines[0]), 1); + + code = taos_insert_by_lines(taos, &(lines[1]), 1); + +// code = taos_insert_by_lines(taos, &(lines[2]), 1); +// +// code = taos_insert_by_lines(taos, &(lines[3]), 1); +// +// code = taos_insert_by_lines(taos, &(lines[4]), 1); + + return code; } @@ -980,7 +992,7 @@ int main(int argc, char *argv[]) { const char* passwd = "taosdata"; taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); - + taos_options(TSDB_OPTION_CONFIGDIR, "/etc/taos"); TAOS* taos = taos_connect(host, user, passwd, "", 0); if (taos == NULL) { printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); diff --git a/tests/tsim/inc/sim.h b/tests/tsim/inc/sim.h index 58314d2e50..2e19dde3d9 100644 --- a/tests/tsim/inc/sim.h +++ b/tests/tsim/inc/sim.h @@ -87,6 +87,8 @@ enum { SIM_CMD_RESTFUL, SIM_CMD_TEST, SIM_CMD_RETURN, + SIM_CMD_LINE_INSERT, + SIM_CMD_LINE_INSERT_ERROR, SIM_CMD_END }; @@ -172,6 +174,8 @@ bool simExecuteSqlCmd(SScript *script, char *option); bool simExecuteSqlErrorCmd(SScript *script, char *rest); bool simExecuteSqlSlowCmd(SScript *script, char *option); bool simExecuteRestfulCmd(SScript *script, char *rest); +bool simExecuteLineInsertCmd(SScript *script, char *option); +bool simExecuteLineInsertErrorCmd(SScript *script, char *option); void simVisuallizeOption(SScript *script, char *src, char *dst); #endif \ No newline at end of file diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 7d74946e93..2615448e4b 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -1067,3 +1067,49 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) { return false; } + +bool simExecuteLineInsertCmd(SScript *script, char *rest) { + char buf[TSDB_MAX_BINARY_LEN]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + SCmdLine *line = &script->lines[script->linePos]; + + simInfo("script:%s, %s", script->fileName, rest); + simLogSql(buf, true); + char * lines[] = {rest}; + int32_t ret = taos_insert_by_lines(script->taos, lines, 1); + if (ret == TSDB_CODE_SUCCESS) { + simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); + script->linePos++; + return true; + } else { + sprintf(script->error, "lineNum: %d. line: %s failed, ret:%d:%s", line->lineNum, rest, + ret & 0XFFFF, tstrerror(ret)); + return false; + } +} + +bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { + char buf[TSDB_MAX_BINARY_LEN]; + + simVisuallizeOption(script, rest, buf); + rest = buf; + + SCmdLine *line = &script->lines[script->linePos]; + + simInfo("script:%s, %s", script->fileName, rest); + simLogSql(buf, true); + char * lines[] = {rest}; + int32_t ret = taos_insert_by_lines(script->taos, lines, 1); + if (ret == TSDB_CODE_SUCCESS) { + sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); + script->linePos++; + return false; + } else { + simDebug("lineNum: %d. line: %s failed, ret:%d:%s. Expect failed, so success", line->lineNum, rest, + ret & 0XFFFF, tstrerror(ret)); + return true; + } +} diff --git a/tests/tsim/src/simParse.c b/tests/tsim/src/simParse.c index b909f5bd8f..1acdcd2ac6 100644 --- a/tests/tsim/src/simParse.c +++ b/tests/tsim/src/simParse.c @@ -838,6 +838,38 @@ bool simParseRunBackCmd(char *rest, SCommand *pCmd, int32_t lineNum) { return true; } +bool simParseLineInsertCmd(char* rest, SCommand* pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + +bool simParseLineInsertErrorCmd(char* rest, SCommand* pCmd, int32_t lineNum) { + int32_t expLen; + + rest++; + cmdLine[numOfLines].cmdno = SIM_CMD_LINE_INSERT; + cmdLine[numOfLines].lineNum = lineNum; + cmdLine[numOfLines].optionOffset = optionOffset; + expLen = (int32_t)strlen(rest); + memcpy(optionBuffer + optionOffset, rest, expLen); + optionOffset += expLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + + numOfLines++; + return true; +} + void simInitsimCmdList() { int32_t cmdno; memset(simCmdList, 0, SIM_CMD_END * sizeof(SCommand)); @@ -1049,4 +1081,20 @@ void simInitsimCmdList() { simCmdList[cmdno].parseCmd = simParseReturnCmd; simCmdList[cmdno].executeCmd = simExecuteReturnCmd; simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_LINE_INSERT; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "line_insert"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseLineInsertCmd; + simCmdList[cmdno].executeCmd = simExecuteLineInsertCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + + cmdno = SIM_CMD_LINE_INSERT_ERROR; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "line_insert_error"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseLineInsertErrorCmd; + simCmdList[cmdno].executeCmd = simExecuteLineInsertErrorCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); } From 228be72a821df3e52b0dad6b4498e68f3f63bc63 Mon Sep 17 00:00:00 2001 From: tomchon Date: Mon, 12 Jul 2021 18:34:31 +0800 Subject: [PATCH 37/65] modify release.sh about beta version name --- alert/release.sh | 2 +- packaging/docker/dockerbuild.sh | 2 +- packaging/tools/makearbi.sh | 26 +++++++++++++++----------- packaging/tools/makeclient.sh | 31 +++++++++++++++++-------------- packaging/tools/makepkg.sh | 27 +++++++++++++++------------ 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/alert/release.sh b/alert/release.sh index 77f6798480..20317e4166 100755 --- a/alert/release.sh +++ b/alert/release.sh @@ -69,7 +69,7 @@ rm -rf ./TDengine-alert pkg_name=TDengine-alert-${version}-${osType^}-${archMap[${cpuType}]} if [ "$verType" == "beta" ]; then - pkg_name=${pkg_name}-${verType} + pkg_name=TDengine-alert-${version}-${verType}-${osType^}-${archMap[${cpuType}]} elif [ "$verType" == "stable" ]; then pkg_name=${pkg_name} else diff --git a/packaging/docker/dockerbuild.sh b/packaging/docker/dockerbuild.sh index 76717d5892..861f00f854 100755 --- a/packaging/docker/dockerbuild.sh +++ b/packaging/docker/dockerbuild.sh @@ -16,7 +16,7 @@ cpuType="" version="" passWord="" pkgFile="" -verType="" +verType="stable" while getopts "hc:n:p:f:V:" arg do diff --git a/packaging/tools/makearbi.sh b/packaging/tools/makearbi.sh index 82808bcae9..5346a79c8f 100755 --- a/packaging/tools/makearbi.sh +++ b/packaging/tools/makearbi.sh @@ -47,24 +47,28 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir} cd ${release_dir} -if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} -elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} -else - echo "unknow verMode, nor cluster or edge" - exit 1 -fi +# install_dir has been distinguishes cluster from edege, so comments this code +pkg_name=${install_dir}-${osType}-${cpuType} + +# if [ "$verMode" == "cluster" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# elif [ "$verMode" == "edge" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# else +# echo "unknow verMode, nor cluster or edge" +# exit 1 +# fi if [ "$verType" == "beta" ]; then - pkg_name=${pkg_name}-${verType} -elif [ "$verType" == "stable" ]; then - pkg_name=${pkg_name} + pkg_name=${install_dir}-${verType}-${osType}-${cpuType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} else echo "unknow verType, nor stabel or beta" exit 1 fi + tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : exitcode=$? if [ "$exitcode" != "0" ]; then diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 0ae5733599..2c36e85970 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -170,12 +170,24 @@ fi cd ${release_dir} -if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} -elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} +# install_dir has been distinguishes cluster from edege, so comments this code +pkg_name=${install_dir}-${osType}-${cpuType} + +# if [ "$verMode" == "cluster" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# elif [ "$verMode" == "edge" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# else +# echo "unknow verMode, nor cluster or edge" +# exit 1 +# fi + +if [ "$verType" == "beta" ]; then + pkg_name=${install_dir}-${verType}-${osType}-${cpuType} +elif [ "$verType" == "stable" ]; then + pkg_name=${pkg_name} else - echo "unknow verMode, nor cluster or edge" + echo "unknow verType, nor stabel or beta" exit 1 fi @@ -183,15 +195,6 @@ if [ "$pagMode" == "lite" ]; then pkg_name=${pkg_name}-Lite fi -if [ "$verType" == "beta" ]; then - pkg_name=${pkg_name}-${verType} -elif [ "$verType" == "stable" ]; then - pkg_name=${pkg_name} -else - echo "unknow verType, nor stable or beta" - exit 1 -fi - if [ "$osType" != "Darwin" ]; then tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : else diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 81061416a2..56ab24426f 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -203,21 +203,20 @@ fi cd ${release_dir} -if [ "$verMode" == "cluster" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} -elif [ "$verMode" == "edge" ]; then - pkg_name=${install_dir}-${osType}-${cpuType} -else - echo "unknow verMode, nor cluster or edge" - exit 1 -fi +# install_dir has been distinguishes cluster from edege, so comments this code +pkg_name=${install_dir}-${osType}-${cpuType} -if [ "$pagMode" == "lite" ]; then - pkg_name=${pkg_name}-Lite -fi +# if [ "$verMode" == "cluster" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# elif [ "$verMode" == "edge" ]; then +# pkg_name=${install_dir}-${osType}-${cpuType} +# else +# echo "unknow verMode, nor cluster or edge" +# exit 1 +# fi if [ "$verType" == "beta" ]; then - pkg_name=${pkg_name}-${verType} + pkg_name=${install_dir}-${verType}-${osType}-${cpuType} elif [ "$verType" == "stable" ]; then pkg_name=${pkg_name} else @@ -225,6 +224,10 @@ else exit 1 fi +if [ "$pagMode" == "lite" ]; then + pkg_name=${pkg_name}-Lite +fi + tar -zcv -f "$(basename ${pkg_name}).tar.gz" $(basename ${install_dir}) --remove-files || : exitcode=$? if [ "$exitcode" != "0" ]; then From a575364d318e491bb1ce482521ad186dbbdf3918 Mon Sep 17 00:00:00 2001 From: tomchon Date: Mon, 12 Jul 2021 21:23:06 +0800 Subject: [PATCH 38/65] modify release.sh about beta version name --- packaging/deb/makedeb.sh | 4 +++- packaging/rpm/makerpm.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index e6ddb6d742..a169bf2ba0 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -123,7 +123,7 @@ else fi if [ "$verType" == "beta" ]; then - debname=${debname}-${verType}".deb" + debname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".deb" elif [ "$verType" == "stable" ]; then debname=${debname}".deb" else @@ -131,6 +131,8 @@ else exit 1 fi + + # make deb package dpkg -b ${pkg_dir} $debname echo "make deb package success!" diff --git a/packaging/rpm/makerpm.sh b/packaging/rpm/makerpm.sh index 7c3272f8d0..4cc7daf1a4 100755 --- a/packaging/rpm/makerpm.sh +++ b/packaging/rpm/makerpm.sh @@ -73,7 +73,7 @@ else fi if [ "$verType" == "beta" ]; then - rpmname=${rpmname}-${verType}".rpm" + rpmname="TDengine-server-"${tdengine_ver}-${verType}-${osType}-${cpuType}".rpm" elif [ "$verType" == "stable" ]; then rpmname=${rpmname}".rpm" else From 4404919d3b7efd943efffdc8b9e640e3c8d6ed01 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 13 Jul 2021 08:22:13 +0800 Subject: [PATCH 39/65] [TD-5201]:record SSqlObjectId id in log --- src/client/src/tscParseInsert.c | 1 + src/client/src/tscPrepare.c | 1 + src/client/src/tscUtil.c | 1 + 3 files changed, 3 insertions(+) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index cd56153bc4..26d9cf0e49 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1129,6 +1129,7 @@ int tsParseInsertSql(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SInsertStatementParam* pInsertParam = &pCmd->insertParam; + pInsertParam->objectId = pSql->self; char* str = pInsertParam->sql; int32_t totalNum = 0; diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 08d3cc599e..798e79dbcb 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1470,6 +1470,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { pSql->fetchFp = waitForQueryRsp; pCmd->insertParam.insertType = TSDB_QUERY_TYPE_STMT_INSERT; + pCmd->insertParam.objectId = pSql->self; pSql->sqlstr = realloc(pSql->sqlstr, sqlLen + 1); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 173db05e10..460fe739e6 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -3342,6 +3342,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t pnCmd->insertParam.numOfTables = 0; pnCmd->insertParam.pTableNameList = NULL; pnCmd->insertParam.pTableBlockHashList = NULL; + pnCmd->insertParam.objectId = pNew->self; memset(&pnCmd->insertParam.tagData, 0, sizeof(STagData)); From 2c30118c13d0c31f6b7116c7a3b8b0e0563af89b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 13 Jul 2021 10:27:36 +0800 Subject: [PATCH 40/65] [td-4780]: disable the update of fsync and wal parameters after the database created. --- src/client/src/tscSQLParser.c | 16 +- src/query/inc/sql.y | 3 +- src/query/src/sql.c | 1421 ++++++++++++++++----------------- 3 files changed, 713 insertions(+), 727 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 2bf49b9abd..ded334c69f 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7809,11 +7809,9 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) { meta->tableType = TSDB_TEMP_TABLE; STableComInfo *info = &meta->tableInfo; - - // todo : row size, numOfTags, numOfCols, tag info -// info->numOfColumns = numOfColumns; + info->numOfColumns = numOfColumns; info->precision = pUpstreamTableMetaInfo->pTableMeta->tableInfo.precision; -// info->numOfTags = 0; + info->numOfTags = 0; int32_t n = 0; for(int32_t i = 0; i < numOfColumns; ++i) { @@ -7831,16 +7829,6 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) { info->rowSize += meta->schema[n].bytes; n += 1; - - if (pExpr->pExpr != NULL) { - info->numOfColumns += 1; - } else { - if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) { - info->numOfTags += 1; - } else { - info->numOfColumns += 1; - } - } } return meta; diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 1b08f1e244..abd7d06b60 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -303,10 +303,11 @@ alter_db_optr(Y) ::= alter_db_optr(Z) quorum(X). { Y = Z; Y.quorum = strtol alter_db_optr(Y) ::= alter_db_optr(Z) keep(X). { Y = Z; Y.keep = X; } alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); } -alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); } alter_db_optr(Y) ::= alter_db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); } +// dynamically update the following two parameters are not allowed. +//alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); } //alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); } not support yet %type alter_topic_optr {SCreateDbInfo} diff --git a/src/query/src/sql.c b/src/query/src/sql.c index ccae21e411..7d5748e29f 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -129,16 +129,16 @@ typedef union { #define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 #define YYNSTATE 347 -#define YYNRULE 284 +#define YYNRULE 283 #define YYNTOKEN 190 #define YY_MAX_SHIFT 346 -#define YY_MIN_SHIFTREDUCE 548 -#define YY_MAX_SHIFTREDUCE 831 -#define YY_ERROR_ACTION 832 -#define YY_ACCEPT_ACTION 833 -#define YY_NO_ACTION 834 -#define YY_MIN_REDUCE 835 -#define YY_MAX_REDUCE 1118 +#define YY_MIN_SHIFTREDUCE 547 +#define YY_MAX_SHIFTREDUCE 829 +#define YY_ERROR_ACTION 830 +#define YY_ACCEPT_ACTION 831 +#define YY_NO_ACTION 832 +#define YY_MIN_REDUCE 833 +#define YY_MAX_REDUCE 1115 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined @@ -204,82 +204,82 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (732) +#define YY_ACTTAB_COUNT (731) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 23, 597, 1007, 597, 219, 344, 194, 833, 346, 598, - /* 10 */ 597, 598, 197, 54, 55, 225, 58, 59, 598, 985, - /* 20 */ 239, 48, 1094, 57, 301, 62, 60, 63, 61, 998, - /* 30 */ 998, 231, 233, 53, 52, 985, 985, 51, 50, 49, - /* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 597, - /* 50 */ 57, 301, 62, 60, 63, 61, 998, 598, 152, 236, - /* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1004, 58, - /* 70 */ 59, 629, 261, 239, 48, 240, 57, 301, 62, 60, - /* 80 */ 63, 61, 29, 83, 979, 221, 53, 52, 145, 982, - /* 90 */ 51, 50, 49, 549, 550, 551, 552, 553, 554, 555, - /* 100 */ 556, 557, 558, 559, 560, 561, 345, 80, 770, 220, + /* 0 */ 23, 596, 1004, 596, 219, 344, 194, 831, 346, 597, + /* 10 */ 596, 597, 197, 54, 55, 225, 58, 59, 597, 982, + /* 20 */ 239, 48, 1091, 57, 302, 62, 60, 63, 61, 995, + /* 30 */ 995, 231, 233, 53, 52, 982, 982, 51, 50, 49, + /* 40 */ 54, 55, 35, 58, 59, 222, 223, 239, 48, 596, + /* 50 */ 57, 302, 62, 60, 63, 61, 995, 597, 152, 236, + /* 60 */ 53, 52, 235, 152, 51, 50, 49, 55, 1001, 58, + /* 70 */ 59, 770, 261, 239, 48, 240, 57, 302, 62, 60, + /* 80 */ 63, 61, 29, 83, 976, 221, 53, 52, 145, 979, + /* 90 */ 51, 50, 49, 548, 549, 550, 551, 552, 553, 554, + /* 100 */ 555, 556, 557, 558, 559, 560, 345, 771, 768, 220, /* 110 */ 95, 77, 54, 55, 35, 58, 59, 42, 197, 239, - /* 120 */ 48, 197, 57, 301, 62, 60, 63, 61, 1095, 232, - /* 130 */ 1043, 1095, 53, 52, 197, 89, 51, 50, 49, 54, - /* 140 */ 56, 264, 58, 59, 1095, 973, 239, 48, 971, 57, - /* 150 */ 301, 62, 60, 63, 61, 268, 267, 229, 299, 53, - /* 160 */ 52, 982, 248, 51, 50, 49, 41, 297, 339, 338, - /* 170 */ 296, 295, 294, 337, 293, 292, 336, 335, 291, 334, - /* 180 */ 333, 946, 934, 935, 936, 937, 938, 939, 940, 941, - /* 190 */ 942, 943, 944, 945, 947, 948, 58, 59, 24, 983, - /* 200 */ 239, 48, 253, 57, 301, 62, 60, 63, 61, 152, - /* 210 */ 195, 257, 256, 53, 52, 205, 772, 51, 50, 49, - /* 220 */ 53, 52, 206, 14, 51, 50, 49, 129, 128, 204, - /* 230 */ 299, 238, 785, 306, 83, 774, 90, 777, 116, 780, - /* 240 */ 331, 238, 785, 152, 35, 774, 331, 777, 200, 780, - /* 250 */ 78, 35, 773, 94, 91, 35, 237, 62, 60, 63, - /* 260 */ 61, 1, 167, 217, 218, 53, 52, 302, 42, 51, - /* 270 */ 50, 49, 76, 217, 218, 41, 6, 339, 338, 881, - /* 280 */ 74, 1044, 337, 280, 179, 336, 335, 230, 334, 333, - /* 290 */ 260, 982, 75, 954, 310, 952, 953, 678, 982, 213, - /* 300 */ 955, 92, 981, 957, 956, 970, 958, 959, 677, 702, - /* 310 */ 64, 242, 699, 282, 700, 88, 701, 776, 247, 779, - /* 320 */ 64, 114, 108, 119, 984, 321, 320, 891, 118, 124, - /* 330 */ 127, 117, 179, 968, 969, 34, 972, 121, 35, 1114, - /* 340 */ 244, 245, 786, 781, 775, 35, 778, 340, 915, 782, - /* 350 */ 3, 180, 786, 781, 35, 5, 38, 169, 718, 782, - /* 360 */ 35, 35, 168, 102, 97, 101, 188, 186, 184, 35, - /* 370 */ 35, 1091, 882, 183, 132, 131, 130, 179, 51, 50, - /* 380 */ 49, 311, 243, 303, 241, 982, 309, 308, 312, 249, - /* 390 */ 1090, 246, 982, 316, 315, 751, 752, 313, 143, 141, - /* 400 */ 140, 982, 715, 317, 318, 262, 68, 982, 982, 343, - /* 410 */ 342, 137, 319, 323, 81, 36, 982, 982, 734, 703, - /* 420 */ 704, 71, 1089, 742, 743, 1054, 688, 285, 147, 9, - /* 430 */ 690, 783, 287, 65, 26, 689, 36, 36, 722, 33, - /* 440 */ 65, 806, 93, 787, 596, 65, 126, 125, 264, 69, - /* 450 */ 16, 25, 15, 25, 25, 1106, 215, 107, 784, 106, - /* 460 */ 216, 198, 72, 18, 707, 17, 708, 199, 288, 705, - /* 470 */ 201, 706, 20, 196, 19, 113, 202, 112, 203, 208, - /* 480 */ 789, 209, 210, 207, 193, 1053, 227, 22, 1050, 21, - /* 490 */ 1049, 258, 228, 322, 144, 1006, 45, 1017, 1036, 1014, - /* 500 */ 1015, 1035, 999, 265, 980, 142, 996, 1019, 146, 163, - /* 510 */ 150, 269, 274, 164, 978, 224, 165, 157, 271, 166, - /* 520 */ 894, 290, 43, 191, 733, 39, 153, 154, 300, 278, - /* 530 */ 155, 283, 890, 73, 307, 156, 70, 47, 281, 279, - /* 540 */ 277, 275, 1113, 158, 104, 273, 1112, 1109, 270, 170, - /* 550 */ 314, 1105, 110, 46, 162, 1104, 159, 332, 1101, 171, - /* 560 */ 912, 40, 115, 37, 324, 44, 192, 878, 120, 876, - /* 570 */ 122, 123, 874, 873, 250, 182, 871, 870, 869, 868, - /* 580 */ 867, 866, 185, 187, 863, 861, 859, 857, 189, 854, - /* 590 */ 190, 325, 263, 79, 84, 272, 1037, 326, 327, 328, - /* 600 */ 329, 330, 341, 831, 251, 214, 234, 289, 252, 830, - /* 610 */ 254, 255, 829, 812, 811, 98, 211, 99, 212, 259, - /* 620 */ 264, 284, 10, 82, 710, 266, 30, 85, 735, 872, - /* 630 */ 865, 178, 913, 172, 176, 173, 174, 133, 175, 177, - /* 640 */ 134, 2, 135, 950, 864, 4, 856, 914, 136, 855, - /* 650 */ 148, 160, 738, 149, 161, 86, 226, 740, 87, 276, - /* 660 */ 31, 744, 961, 151, 11, 32, 12, 13, 27, 286, - /* 670 */ 28, 94, 96, 642, 639, 638, 636, 635, 634, 631, - /* 680 */ 601, 298, 7, 304, 100, 790, 788, 305, 680, 8, - /* 690 */ 103, 66, 105, 67, 109, 111, 679, 676, 623, 621, - /* 700 */ 613, 36, 619, 615, 617, 611, 609, 645, 644, 643, - /* 710 */ 641, 640, 637, 633, 632, 181, 599, 138, 565, 563, - /* 720 */ 835, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 730 */ 834, 139, + /* 120 */ 48, 197, 57, 302, 62, 60, 63, 61, 1092, 232, + /* 130 */ 1040, 1092, 53, 52, 197, 89, 51, 50, 49, 54, + /* 140 */ 56, 968, 58, 59, 1092, 970, 239, 48, 262, 57, + /* 150 */ 302, 62, 60, 63, 61, 268, 267, 229, 36, 53, + /* 160 */ 52, 979, 248, 51, 50, 49, 41, 298, 339, 338, + /* 170 */ 297, 296, 295, 337, 294, 293, 292, 336, 291, 335, + /* 180 */ 334, 944, 932, 933, 934, 935, 936, 937, 938, 939, + /* 190 */ 940, 941, 942, 943, 945, 946, 58, 59, 24, 980, + /* 200 */ 239, 48, 90, 57, 302, 62, 60, 63, 61, 51, + /* 210 */ 50, 49, 152, 53, 52, 205, 78, 51, 50, 49, + /* 220 */ 53, 52, 206, 300, 51, 50, 49, 129, 128, 204, + /* 230 */ 732, 238, 783, 307, 83, 772, 740, 775, 35, 778, + /* 240 */ 147, 238, 783, 116, 253, 772, 65, 775, 35, 778, + /* 250 */ 300, 332, 152, 257, 256, 35, 879, 62, 60, 63, + /* 260 */ 61, 179, 332, 217, 218, 53, 52, 303, 42, 51, + /* 270 */ 50, 49, 700, 217, 218, 697, 304, 698, 14, 699, + /* 280 */ 41, 230, 339, 338, 1041, 979, 280, 337, 340, 913, + /* 290 */ 260, 336, 75, 335, 334, 978, 1, 167, 311, 213, + /* 300 */ 628, 242, 979, 244, 245, 114, 108, 119, 94, 91, + /* 310 */ 64, 195, 118, 124, 127, 117, 952, 80, 950, 951, + /* 320 */ 64, 121, 282, 953, 88, 76, 247, 954, 35, 955, + /* 330 */ 956, 5, 38, 169, 92, 3, 180, 35, 168, 102, + /* 340 */ 97, 101, 784, 779, 35, 35, 35, 35, 716, 780, + /* 350 */ 676, 264, 784, 779, 188, 186, 184, 200, 967, 780, + /* 360 */ 35, 183, 132, 131, 130, 1088, 965, 966, 34, 969, + /* 370 */ 1087, 312, 243, 787, 241, 979, 310, 309, 322, 321, + /* 380 */ 313, 889, 701, 702, 979, 81, 179, 314, 318, 319, + /* 390 */ 320, 979, 979, 979, 979, 880, 774, 249, 777, 246, + /* 400 */ 179, 317, 316, 324, 773, 713, 776, 979, 343, 342, + /* 410 */ 137, 741, 143, 141, 140, 749, 750, 68, 71, 264, + /* 420 */ 686, 26, 237, 285, 16, 688, 15, 287, 720, 687, + /* 430 */ 36, 981, 9, 36, 33, 65, 804, 93, 785, 65, + /* 440 */ 595, 74, 6, 107, 1086, 106, 25, 18, 25, 17, + /* 450 */ 25, 705, 703, 706, 704, 20, 113, 19, 112, 72, + /* 460 */ 69, 215, 22, 288, 21, 126, 125, 216, 198, 675, + /* 470 */ 199, 201, 196, 202, 203, 208, 209, 210, 207, 193, + /* 480 */ 1111, 1103, 1051, 1050, 227, 1047, 1046, 228, 323, 45, + /* 490 */ 258, 144, 1003, 1014, 1011, 1012, 1016, 996, 142, 265, + /* 500 */ 146, 1033, 150, 274, 1032, 977, 163, 164, 269, 224, + /* 510 */ 781, 975, 165, 166, 892, 290, 731, 43, 782, 191, + /* 520 */ 283, 993, 39, 301, 154, 888, 308, 1110, 104, 1109, + /* 530 */ 1106, 170, 315, 73, 1102, 110, 271, 278, 70, 153, + /* 540 */ 47, 1101, 155, 1098, 281, 171, 910, 40, 279, 277, + /* 550 */ 37, 275, 44, 273, 192, 270, 156, 876, 120, 874, + /* 560 */ 122, 123, 872, 871, 250, 182, 869, 868, 867, 866, + /* 570 */ 865, 864, 185, 187, 861, 859, 857, 855, 189, 852, + /* 580 */ 190, 333, 263, 79, 46, 84, 115, 272, 1034, 325, + /* 590 */ 326, 327, 328, 329, 330, 331, 214, 341, 829, 234, + /* 600 */ 251, 252, 289, 828, 254, 255, 827, 211, 212, 809, + /* 610 */ 98, 810, 99, 259, 264, 284, 10, 82, 708, 266, + /* 620 */ 85, 30, 870, 174, 178, 863, 911, 172, 173, 175, + /* 630 */ 176, 4, 133, 177, 862, 912, 134, 135, 948, 136, + /* 640 */ 854, 733, 148, 853, 157, 158, 159, 160, 736, 161, + /* 650 */ 149, 162, 958, 2, 86, 226, 738, 87, 276, 31, + /* 660 */ 742, 151, 32, 13, 11, 27, 286, 28, 12, 641, + /* 670 */ 96, 94, 639, 638, 637, 635, 634, 633, 630, 299, + /* 680 */ 600, 100, 7, 305, 786, 788, 8, 306, 103, 105, + /* 690 */ 66, 67, 109, 111, 678, 36, 677, 674, 622, 620, + /* 700 */ 612, 618, 614, 616, 610, 608, 644, 643, 642, 640, + /* 710 */ 636, 632, 631, 181, 598, 564, 562, 833, 832, 832, + /* 720 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 138, + /* 730 */ 139, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 259, 1, 194, 1, 193, 194, 259, 191, 192, 9, @@ -289,73 +289,73 @@ static const YYCODETYPE yy_lookahead[] = { /* 40 */ 13, 14, 194, 16, 17, 256, 256, 20, 21, 1, /* 50 */ 23, 24, 25, 26, 27, 28, 240, 9, 194, 200, /* 60 */ 33, 34, 200, 194, 37, 38, 39, 14, 260, 16, - /* 70 */ 17, 5, 256, 20, 21, 200, 23, 24, 25, 26, + /* 70 */ 17, 1, 256, 20, 21, 200, 23, 24, 25, 26, /* 80 */ 27, 28, 80, 80, 194, 237, 33, 34, 194, 241, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 81, 81, 61, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 37, 81, 61, /* 110 */ 201, 111, 13, 14, 194, 16, 17, 114, 259, 20, /* 120 */ 21, 259, 23, 24, 25, 26, 27, 28, 269, 239, /* 130 */ 266, 269, 33, 34, 259, 266, 37, 38, 39, 13, - /* 140 */ 14, 115, 16, 17, 269, 236, 20, 21, 0, 23, - /* 150 */ 24, 25, 26, 27, 28, 261, 262, 237, 82, 33, + /* 140 */ 14, 0, 16, 17, 269, 236, 20, 21, 81, 23, + /* 150 */ 24, 25, 26, 27, 28, 261, 262, 237, 91, 33, /* 160 */ 34, 241, 194, 37, 38, 39, 92, 93, 94, 95, /* 170 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, /* 180 */ 106, 215, 216, 217, 218, 219, 220, 221, 222, 223, /* 190 */ 224, 225, 226, 227, 228, 229, 16, 17, 44, 231, - /* 200 */ 20, 21, 137, 23, 24, 25, 26, 27, 28, 194, - /* 210 */ 259, 146, 147, 33, 34, 61, 1, 37, 38, 39, - /* 220 */ 33, 34, 68, 80, 37, 38, 39, 73, 74, 75, - /* 230 */ 82, 1, 2, 79, 80, 5, 243, 7, 76, 9, - /* 240 */ 84, 1, 2, 194, 194, 5, 84, 7, 259, 9, - /* 250 */ 257, 194, 37, 110, 111, 194, 60, 25, 26, 27, - /* 260 */ 28, 202, 203, 33, 34, 33, 34, 37, 114, 37, - /* 270 */ 38, 39, 201, 33, 34, 92, 80, 94, 95, 199, - /* 280 */ 80, 266, 99, 268, 204, 102, 103, 237, 105, 106, - /* 290 */ 136, 241, 138, 215, 237, 217, 218, 5, 241, 145, - /* 300 */ 222, 201, 241, 225, 226, 234, 228, 229, 108, 2, - /* 310 */ 80, 68, 5, 264, 7, 266, 9, 5, 68, 7, - /* 320 */ 80, 62, 63, 64, 242, 33, 34, 199, 69, 70, - /* 330 */ 71, 72, 204, 233, 234, 235, 236, 78, 194, 242, - /* 340 */ 33, 34, 112, 113, 5, 194, 7, 213, 214, 119, - /* 350 */ 197, 198, 112, 113, 194, 62, 63, 64, 37, 119, - /* 360 */ 194, 194, 69, 70, 71, 72, 62, 63, 64, 194, - /* 370 */ 194, 259, 199, 69, 70, 71, 72, 204, 37, 38, - /* 380 */ 39, 237, 139, 15, 141, 241, 143, 144, 237, 139, - /* 390 */ 259, 141, 241, 143, 144, 127, 128, 237, 62, 63, - /* 400 */ 64, 241, 91, 237, 237, 81, 91, 241, 241, 65, - /* 410 */ 66, 67, 237, 237, 81, 91, 241, 241, 81, 112, - /* 420 */ 113, 91, 259, 81, 81, 232, 81, 81, 91, 118, - /* 430 */ 81, 119, 81, 91, 91, 81, 91, 91, 117, 80, - /* 440 */ 91, 81, 91, 81, 81, 91, 76, 77, 115, 134, - /* 450 */ 140, 91, 142, 91, 91, 242, 259, 140, 119, 142, - /* 460 */ 259, 259, 132, 140, 5, 142, 7, 259, 109, 5, - /* 470 */ 259, 7, 140, 259, 142, 140, 259, 142, 259, 259, - /* 480 */ 112, 259, 259, 259, 259, 232, 232, 140, 232, 142, - /* 490 */ 232, 194, 232, 232, 194, 194, 258, 194, 267, 194, - /* 500 */ 194, 267, 240, 240, 240, 60, 255, 194, 194, 244, - /* 510 */ 194, 263, 194, 194, 194, 263, 194, 250, 263, 194, - /* 520 */ 194, 194, 194, 194, 119, 194, 254, 253, 194, 263, - /* 530 */ 252, 125, 194, 131, 194, 251, 133, 130, 129, 124, - /* 540 */ 123, 122, 194, 249, 194, 121, 194, 194, 120, 194, - /* 550 */ 194, 194, 194, 135, 245, 194, 248, 107, 194, 194, - /* 560 */ 194, 194, 90, 194, 89, 194, 194, 194, 194, 194, + /* 200 */ 20, 21, 243, 23, 24, 25, 26, 27, 28, 37, + /* 210 */ 38, 39, 194, 33, 34, 61, 257, 37, 38, 39, + /* 220 */ 33, 34, 68, 82, 37, 38, 39, 73, 74, 75, + /* 230 */ 81, 1, 2, 79, 80, 5, 81, 7, 194, 9, + /* 240 */ 91, 1, 2, 76, 137, 5, 91, 7, 194, 9, + /* 250 */ 82, 84, 194, 146, 147, 194, 199, 25, 26, 27, + /* 260 */ 28, 204, 84, 33, 34, 33, 34, 37, 114, 37, + /* 270 */ 38, 39, 2, 33, 34, 5, 15, 7, 80, 9, + /* 280 */ 92, 237, 94, 95, 266, 241, 268, 99, 213, 214, + /* 290 */ 136, 103, 138, 105, 106, 241, 202, 203, 237, 145, + /* 300 */ 5, 68, 241, 33, 34, 62, 63, 64, 110, 111, + /* 310 */ 80, 259, 69, 70, 71, 72, 215, 81, 217, 218, + /* 320 */ 80, 78, 264, 222, 266, 201, 68, 226, 194, 228, + /* 330 */ 229, 62, 63, 64, 201, 197, 198, 194, 69, 70, + /* 340 */ 71, 72, 112, 113, 194, 194, 194, 194, 37, 119, + /* 350 */ 5, 115, 112, 113, 62, 63, 64, 259, 234, 119, + /* 360 */ 194, 69, 70, 71, 72, 259, 233, 234, 235, 236, + /* 370 */ 259, 237, 139, 112, 141, 241, 143, 144, 33, 34, + /* 380 */ 237, 199, 112, 113, 241, 81, 204, 237, 237, 237, + /* 390 */ 237, 241, 241, 241, 241, 199, 5, 139, 7, 141, + /* 400 */ 204, 143, 144, 237, 5, 91, 7, 241, 65, 66, + /* 410 */ 67, 81, 62, 63, 64, 127, 128, 91, 91, 115, + /* 420 */ 81, 91, 60, 81, 140, 81, 142, 81, 117, 81, + /* 430 */ 91, 242, 118, 91, 80, 91, 81, 91, 81, 91, + /* 440 */ 81, 80, 80, 140, 259, 142, 91, 140, 91, 142, + /* 450 */ 91, 5, 5, 7, 7, 140, 140, 142, 142, 132, + /* 460 */ 134, 259, 140, 109, 142, 76, 77, 259, 259, 108, + /* 470 */ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, + /* 480 */ 242, 242, 232, 232, 232, 232, 232, 232, 232, 258, + /* 490 */ 194, 194, 194, 194, 194, 194, 194, 240, 60, 240, + /* 500 */ 194, 267, 194, 194, 267, 240, 244, 194, 263, 263, + /* 510 */ 119, 194, 194, 194, 194, 194, 119, 194, 119, 194, + /* 520 */ 125, 255, 194, 194, 253, 194, 194, 194, 194, 194, + /* 530 */ 194, 194, 194, 131, 194, 194, 263, 263, 133, 254, + /* 540 */ 130, 194, 252, 194, 129, 194, 194, 194, 124, 123, + /* 550 */ 194, 122, 194, 121, 194, 120, 251, 194, 194, 194, + /* 560 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, /* 570 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - /* 580 */ 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - /* 590 */ 194, 50, 195, 195, 195, 195, 195, 86, 88, 54, - /* 600 */ 87, 85, 82, 5, 148, 195, 195, 195, 5, 5, - /* 610 */ 148, 5, 5, 94, 93, 201, 195, 201, 195, 137, - /* 620 */ 115, 109, 80, 116, 81, 91, 80, 91, 81, 195, - /* 630 */ 195, 205, 212, 211, 207, 210, 206, 196, 209, 208, - /* 640 */ 196, 202, 196, 230, 195, 197, 195, 214, 196, 195, - /* 650 */ 80, 247, 81, 91, 246, 80, 1, 81, 80, 80, - /* 660 */ 91, 81, 230, 80, 126, 91, 126, 80, 80, 109, - /* 670 */ 80, 110, 76, 9, 5, 5, 5, 5, 5, 5, - /* 680 */ 83, 15, 80, 24, 76, 112, 81, 58, 5, 80, - /* 690 */ 142, 16, 142, 16, 142, 142, 5, 81, 5, 5, - /* 700 */ 5, 91, 5, 5, 5, 5, 5, 5, 5, 5, - /* 710 */ 5, 5, 5, 5, 5, 91, 83, 21, 60, 59, - /* 720 */ 0, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 730 */ 270, 21, 270, 270, 270, 270, 270, 270, 270, 270, + /* 580 */ 194, 107, 195, 195, 135, 195, 90, 195, 195, 89, + /* 590 */ 50, 86, 88, 54, 87, 85, 195, 82, 5, 195, + /* 600 */ 148, 5, 195, 5, 148, 5, 5, 195, 195, 93, + /* 610 */ 201, 94, 201, 137, 115, 109, 80, 116, 81, 91, + /* 620 */ 91, 80, 195, 206, 205, 195, 212, 211, 210, 209, + /* 630 */ 207, 197, 196, 208, 195, 214, 196, 196, 230, 196, + /* 640 */ 195, 81, 80, 195, 250, 249, 248, 247, 81, 246, + /* 650 */ 91, 245, 230, 202, 80, 1, 81, 80, 80, 91, + /* 660 */ 81, 80, 91, 80, 126, 80, 109, 80, 126, 9, + /* 670 */ 76, 110, 5, 5, 5, 5, 5, 5, 5, 15, + /* 680 */ 83, 76, 80, 24, 81, 112, 80, 58, 142, 142, + /* 690 */ 16, 16, 142, 142, 5, 91, 5, 81, 5, 5, + /* 700 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 710 */ 5, 5, 5, 91, 83, 60, 59, 0, 270, 270, + /* 720 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 21, + /* 730 */ 21, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 740 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 750 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 760 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, @@ -374,109 +374,109 @@ static const YYCODETYPE yy_lookahead[] = { /* 890 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 900 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, /* 910 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 920 */ 270, 270, + /* 920 */ 270, }; #define YY_SHIFT_COUNT (346) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (720) +#define YY_SHIFT_MAX (717) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 154, 74, 74, 183, 183, 76, 230, 240, 240, 2, + /* 0 */ 154, 74, 74, 188, 188, 168, 230, 240, 240, 2, /* 10 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - /* 20 */ 9, 9, 9, 0, 48, 240, 307, 307, 307, 3, - /* 30 */ 3, 9, 9, 9, 148, 9, 9, 162, 76, 156, - /* 40 */ 156, 66, 732, 732, 732, 240, 240, 240, 240, 240, + /* 20 */ 9, 9, 9, 0, 48, 240, 270, 270, 270, 3, + /* 30 */ 3, 9, 9, 9, 141, 9, 9, 167, 168, 178, + /* 40 */ 178, 295, 731, 731, 731, 240, 240, 240, 240, 240, /* 50 */ 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, - /* 60 */ 240, 240, 240, 240, 240, 307, 307, 307, 292, 292, - /* 70 */ 292, 292, 292, 292, 292, 9, 9, 9, 321, 9, - /* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 268, 268, - /* 90 */ 311, 3, 9, 9, 9, 9, 9, 9, 9, 9, + /* 60 */ 240, 240, 240, 240, 240, 270, 270, 270, 345, 345, + /* 70 */ 345, 345, 345, 345, 345, 9, 9, 9, 311, 9, + /* 80 */ 9, 9, 3, 3, 9, 9, 9, 9, 288, 288, + /* 90 */ 314, 3, 9, 9, 9, 9, 9, 9, 9, 9, /* 100 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 110 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 120 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* 130 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - /* 140 */ 9, 9, 9, 9, 445, 445, 445, 405, 405, 405, - /* 150 */ 445, 405, 445, 402, 403, 406, 407, 409, 415, 417, - /* 160 */ 419, 424, 428, 418, 445, 445, 445, 450, 76, 76, - /* 170 */ 445, 445, 472, 475, 541, 511, 510, 545, 513, 516, - /* 180 */ 450, 66, 445, 520, 520, 445, 520, 445, 520, 445, - /* 190 */ 445, 732, 732, 27, 99, 99, 126, 99, 53, 180, - /* 200 */ 232, 232, 232, 232, 259, 293, 304, 187, 187, 187, - /* 210 */ 187, 243, 250, 65, 143, 341, 341, 312, 339, 344, - /* 220 */ 336, 324, 26, 333, 337, 342, 343, 315, 330, 345, - /* 230 */ 346, 349, 351, 354, 359, 360, 362, 215, 196, 368, - /* 240 */ 363, 310, 317, 323, 459, 464, 332, 335, 200, 347, - /* 250 */ 370, 598, 456, 603, 604, 462, 606, 607, 519, 521, - /* 260 */ 482, 505, 512, 542, 507, 543, 546, 534, 536, 547, - /* 270 */ 570, 571, 562, 575, 576, 578, 655, 579, 580, 583, - /* 280 */ 569, 538, 574, 540, 587, 512, 588, 560, 590, 561, - /* 290 */ 596, 664, 669, 670, 671, 672, 673, 674, 597, 666, - /* 300 */ 608, 602, 605, 573, 609, 659, 629, 675, 548, 550, - /* 310 */ 610, 610, 610, 610, 677, 552, 553, 610, 610, 610, - /* 320 */ 683, 691, 616, 610, 693, 694, 695, 697, 698, 699, - /* 330 */ 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, - /* 340 */ 624, 633, 696, 710, 658, 660, 720, + /* 140 */ 9, 9, 9, 9, 438, 438, 438, 397, 397, 397, + /* 150 */ 438, 397, 438, 402, 405, 395, 410, 415, 424, 426, + /* 160 */ 429, 432, 435, 449, 438, 438, 438, 474, 168, 168, + /* 170 */ 438, 438, 496, 500, 540, 505, 504, 539, 507, 510, + /* 180 */ 474, 295, 438, 515, 515, 438, 515, 438, 515, 438, + /* 190 */ 438, 731, 731, 27, 99, 99, 126, 99, 53, 180, + /* 200 */ 232, 232, 232, 232, 243, 269, 292, 187, 187, 187, + /* 210 */ 187, 233, 258, 107, 198, 172, 172, 391, 399, 343, + /* 220 */ 350, 67, 236, 304, 149, 155, 330, 326, 327, 339, + /* 230 */ 342, 344, 346, 348, 354, 355, 357, 70, 362, 261, + /* 240 */ 359, 284, 303, 307, 446, 447, 315, 316, 361, 322, + /* 250 */ 389, 593, 452, 596, 598, 456, 600, 601, 517, 516, + /* 260 */ 476, 499, 506, 536, 501, 537, 541, 528, 529, 560, + /* 270 */ 562, 567, 559, 574, 575, 577, 654, 578, 579, 581, + /* 280 */ 568, 538, 571, 542, 583, 506, 585, 557, 587, 561, + /* 290 */ 594, 660, 667, 668, 669, 670, 671, 672, 673, 597, + /* 300 */ 664, 605, 602, 603, 573, 606, 659, 629, 674, 546, + /* 310 */ 547, 604, 604, 604, 604, 675, 550, 551, 604, 604, + /* 320 */ 604, 689, 691, 616, 604, 693, 694, 695, 696, 697, + /* 330 */ 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, + /* 340 */ 622, 631, 708, 709, 655, 657, 717, }; #define YY_REDUCE_COUNT (192) #define YY_REDUCE_MIN (-259) -#define YY_REDUCE_MAX (454) +#define YY_REDUCE_MAX (451) static const short yy_reduce_ofst[] = { - /* 0 */ -184, -34, -34, 78, 78, 100, -141, -138, -125, -106, - /* 10 */ -152, 15, 49, -80, 50, 57, 144, 151, 160, 166, - /* 20 */ 167, 175, 176, -192, -189, -247, -223, -207, -206, -211, - /* 30 */ -210, -136, -131, -110, -91, -32, 61, 80, 71, 128, - /* 40 */ 173, 134, -7, 59, 153, -259, -253, -49, -11, 112, - /* 50 */ 131, 163, 197, 201, 202, 208, 211, 214, 217, 219, - /* 60 */ 220, 222, 223, 224, 225, 82, 97, 213, 193, 253, - /* 70 */ 254, 256, 258, 260, 261, 297, 300, 301, 238, 303, - /* 80 */ 305, 306, 262, 263, 313, 314, 316, 318, 231, 234, - /* 90 */ 265, 264, 319, 320, 322, 325, 326, 327, 328, 329, - /* 100 */ 331, 334, 338, 340, 348, 350, 352, 353, 355, 356, - /* 110 */ 357, 358, 361, 364, 365, 366, 367, 369, 371, 372, - /* 120 */ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, - /* 130 */ 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, - /* 140 */ 393, 394, 395, 396, 397, 398, 399, 248, 252, 255, - /* 150 */ 400, 266, 401, 251, 272, 274, 278, 284, 267, 294, - /* 160 */ 308, 404, 408, 309, 410, 411, 412, 413, 414, 416, - /* 170 */ 421, 423, 420, 422, 425, 430, 429, 427, 431, 426, - /* 180 */ 432, 433, 434, 441, 444, 435, 446, 449, 452, 451, - /* 190 */ 454, 439, 448, + /* 0 */ -184, -34, -34, 101, 101, 133, -141, -138, -125, -106, + /* 10 */ -152, 18, 58, -80, 44, 61, 134, 143, 150, 151, + /* 20 */ 152, 153, 166, -192, -189, -247, -223, -207, -206, -211, + /* 30 */ -210, -136, -131, -110, -91, -32, 54, 57, 124, 182, + /* 40 */ 196, 75, -41, 94, 138, -259, -253, 52, 98, 106, + /* 50 */ 111, 185, 202, 208, 209, 211, 212, 213, 214, 215, + /* 60 */ 216, 217, 218, 219, 220, 189, 238, 239, 250, 251, + /* 70 */ 252, 253, 254, 255, 256, 296, 297, 298, 231, 299, + /* 80 */ 300, 301, 257, 259, 302, 306, 308, 309, 234, 237, + /* 90 */ 262, 265, 313, 317, 318, 319, 320, 321, 323, 325, + /* 100 */ 328, 329, 331, 332, 333, 334, 335, 336, 337, 338, + /* 110 */ 340, 341, 347, 349, 351, 352, 353, 356, 358, 360, + /* 120 */ 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, + /* 130 */ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, + /* 140 */ 383, 384, 385, 386, 387, 388, 390, 245, 246, 273, + /* 150 */ 392, 274, 393, 266, 285, 271, 290, 305, 394, 396, + /* 160 */ 398, 400, 403, 406, 401, 404, 407, 408, 409, 411, + /* 170 */ 412, 413, 414, 416, 418, 417, 420, 423, 425, 419, + /* 180 */ 422, 421, 427, 436, 440, 430, 441, 439, 443, 445, + /* 190 */ 448, 451, 434, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 832, 949, 892, 960, 879, 889, 1097, 1097, 1097, 832, - /* 10 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 20 */ 832, 832, 832, 1008, 851, 1097, 832, 832, 832, 832, - /* 30 */ 832, 832, 832, 832, 889, 832, 832, 895, 889, 895, - /* 40 */ 895, 832, 1003, 933, 951, 832, 832, 832, 832, 832, - /* 50 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 60 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 70 */ 832, 832, 832, 832, 832, 832, 832, 832, 1010, 1016, - /* 80 */ 1013, 832, 832, 832, 1018, 832, 832, 832, 1040, 1040, - /* 90 */ 1001, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 100 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 110 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 120 */ 877, 832, 875, 832, 832, 832, 832, 832, 832, 832, - /* 130 */ 832, 832, 832, 832, 832, 832, 832, 862, 832, 832, - /* 140 */ 832, 832, 832, 832, 853, 853, 853, 832, 832, 832, - /* 150 */ 853, 832, 853, 1047, 1051, 1033, 1045, 1041, 1032, 1028, - /* 160 */ 1026, 1024, 1023, 1055, 853, 853, 853, 893, 889, 889, - /* 170 */ 853, 853, 911, 909, 907, 899, 905, 901, 903, 897, - /* 180 */ 880, 832, 853, 887, 887, 853, 887, 853, 887, 853, - /* 190 */ 853, 933, 951, 832, 1056, 1046, 832, 1096, 1086, 1085, - /* 200 */ 1092, 1084, 1083, 1082, 832, 832, 832, 1078, 1081, 1080, - /* 210 */ 1079, 832, 832, 832, 832, 1088, 1087, 832, 832, 832, - /* 220 */ 832, 832, 832, 832, 832, 832, 832, 1052, 1048, 832, - /* 230 */ 832, 832, 832, 832, 832, 832, 832, 832, 1058, 832, - /* 240 */ 832, 832, 832, 832, 832, 832, 832, 832, 962, 832, - /* 250 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 260 */ 832, 1000, 832, 832, 832, 832, 832, 1012, 1011, 832, - /* 270 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 280 */ 1042, 832, 1034, 832, 832, 974, 832, 832, 832, 832, - /* 290 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 300 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 310 */ 1115, 1110, 1111, 1108, 832, 832, 832, 1107, 1102, 1103, - /* 320 */ 832, 832, 832, 1100, 832, 832, 832, 832, 832, 832, - /* 330 */ 832, 832, 832, 832, 832, 832, 832, 832, 832, 832, - /* 340 */ 917, 832, 860, 858, 832, 849, 832, + /* 0 */ 830, 947, 890, 957, 877, 887, 1094, 1094, 1094, 830, + /* 10 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 20 */ 830, 830, 830, 1005, 849, 1094, 830, 830, 830, 830, + /* 30 */ 830, 830, 830, 830, 887, 830, 830, 893, 887, 893, + /* 40 */ 893, 830, 1000, 931, 949, 830, 830, 830, 830, 830, + /* 50 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 60 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 70 */ 830, 830, 830, 830, 830, 830, 830, 830, 1007, 1013, + /* 80 */ 1010, 830, 830, 830, 1015, 830, 830, 830, 1037, 1037, + /* 90 */ 998, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 100 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 110 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 120 */ 875, 830, 873, 830, 830, 830, 830, 830, 830, 830, + /* 130 */ 830, 830, 830, 830, 830, 830, 830, 860, 830, 830, + /* 140 */ 830, 830, 830, 830, 851, 851, 851, 830, 830, 830, + /* 150 */ 851, 830, 851, 1044, 1048, 1030, 1042, 1038, 1029, 1025, + /* 160 */ 1023, 1021, 1020, 1052, 851, 851, 851, 891, 887, 887, + /* 170 */ 851, 851, 909, 907, 905, 897, 903, 899, 901, 895, + /* 180 */ 878, 830, 851, 885, 885, 851, 885, 851, 885, 851, + /* 190 */ 851, 931, 949, 830, 1053, 1043, 830, 1093, 1083, 1082, + /* 200 */ 1089, 1081, 1080, 1079, 830, 830, 830, 1075, 1078, 1077, + /* 210 */ 1076, 830, 830, 830, 830, 1085, 1084, 830, 830, 830, + /* 220 */ 830, 830, 830, 830, 830, 830, 830, 1049, 1045, 830, + /* 230 */ 830, 830, 830, 830, 830, 830, 830, 830, 1055, 830, + /* 240 */ 830, 830, 830, 830, 830, 830, 830, 830, 959, 830, + /* 250 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 260 */ 830, 997, 830, 830, 830, 830, 830, 1009, 1008, 830, + /* 270 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 280 */ 1039, 830, 1031, 830, 830, 971, 830, 830, 830, 830, + /* 290 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 300 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 310 */ 830, 1112, 1107, 1108, 1105, 830, 830, 830, 1104, 1099, + /* 320 */ 1100, 830, 830, 830, 1097, 830, 830, 830, 830, 830, + /* 330 */ 830, 830, 830, 830, 830, 830, 830, 830, 830, 830, + /* 340 */ 915, 830, 858, 856, 830, 847, 830, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1171,168 +1171,167 @@ static const char *const yyRuleName[] = { /* 119 */ "alter_db_optr ::= alter_db_optr keep", /* 120 */ "alter_db_optr ::= alter_db_optr blocks", /* 121 */ "alter_db_optr ::= alter_db_optr comp", - /* 122 */ "alter_db_optr ::= alter_db_optr fsync", - /* 123 */ "alter_db_optr ::= alter_db_optr update", - /* 124 */ "alter_db_optr ::= alter_db_optr cachelast", - /* 125 */ "alter_topic_optr ::= alter_db_optr", - /* 126 */ "alter_topic_optr ::= alter_topic_optr partitions", - /* 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 tagitemlist RP", - /* 142 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist 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 */ "tagitemlist ::= tagitemlist COMMA tagitem", - /* 150 */ "tagitemlist ::= tagitem", - /* 151 */ "tagitem ::= INTEGER", - /* 152 */ "tagitem ::= FLOAT", - /* 153 */ "tagitem ::= STRING", - /* 154 */ "tagitem ::= BOOL", - /* 155 */ "tagitem ::= NULL", - /* 156 */ "tagitem ::= NOW", - /* 157 */ "tagitem ::= MINUS INTEGER", - /* 158 */ "tagitem ::= MINUS FLOAT", - /* 159 */ "tagitem ::= PLUS INTEGER", - /* 160 */ "tagitem ::= PLUS FLOAT", - /* 161 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", - /* 162 */ "select ::= LP select RP", - /* 163 */ "union ::= select", - /* 164 */ "union ::= union UNION ALL select", - /* 165 */ "cmd ::= union", - /* 166 */ "select ::= SELECT selcollist", - /* 167 */ "sclp ::= selcollist COMMA", - /* 168 */ "sclp ::=", - /* 169 */ "selcollist ::= sclp distinct expr as", - /* 170 */ "selcollist ::= sclp STAR", - /* 171 */ "as ::= AS ids", - /* 172 */ "as ::= ids", - /* 173 */ "as ::=", - /* 174 */ "distinct ::= DISTINCT", - /* 175 */ "distinct ::=", - /* 176 */ "from ::= FROM tablelist", - /* 177 */ "from ::= FROM sub", - /* 178 */ "sub ::= LP union RP", - /* 179 */ "sub ::= LP union RP ids", - /* 180 */ "sub ::= sub COMMA LP union RP ids", - /* 181 */ "tablelist ::= ids cpxName", - /* 182 */ "tablelist ::= ids cpxName ids", - /* 183 */ "tablelist ::= tablelist COMMA ids cpxName", - /* 184 */ "tablelist ::= tablelist COMMA ids cpxName ids", - /* 185 */ "tmvar ::= VARIABLE", - /* 186 */ "interval_opt ::= INTERVAL LP tmvar RP", - /* 187 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", - /* 188 */ "interval_opt ::=", - /* 189 */ "session_option ::=", - /* 190 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", - /* 191 */ "windowstate_option ::=", - /* 192 */ "windowstate_option ::= STATE_WINDOW LP ids RP", - /* 193 */ "fill_opt ::=", - /* 194 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", - /* 195 */ "fill_opt ::= FILL LP ID RP", - /* 196 */ "sliding_opt ::= SLIDING LP tmvar RP", - /* 197 */ "sliding_opt ::=", - /* 198 */ "orderby_opt ::=", - /* 199 */ "orderby_opt ::= ORDER BY sortlist", - /* 200 */ "sortlist ::= sortlist COMMA item sortorder", - /* 201 */ "sortlist ::= item sortorder", - /* 202 */ "item ::= ids cpxName", - /* 203 */ "sortorder ::= ASC", - /* 204 */ "sortorder ::= DESC", - /* 205 */ "sortorder ::=", - /* 206 */ "groupby_opt ::=", - /* 207 */ "groupby_opt ::= GROUP BY grouplist", - /* 208 */ "grouplist ::= grouplist COMMA item", - /* 209 */ "grouplist ::= item", - /* 210 */ "having_opt ::=", - /* 211 */ "having_opt ::= HAVING expr", - /* 212 */ "limit_opt ::=", - /* 213 */ "limit_opt ::= LIMIT signed", - /* 214 */ "limit_opt ::= LIMIT signed OFFSET signed", - /* 215 */ "limit_opt ::= LIMIT signed COMMA signed", - /* 216 */ "slimit_opt ::=", - /* 217 */ "slimit_opt ::= SLIMIT signed", - /* 218 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", - /* 219 */ "slimit_opt ::= SLIMIT signed COMMA signed", - /* 220 */ "where_opt ::=", - /* 221 */ "where_opt ::= WHERE expr", - /* 222 */ "expr ::= LP expr RP", - /* 223 */ "expr ::= ID", - /* 224 */ "expr ::= ID DOT ID", - /* 225 */ "expr ::= ID DOT STAR", - /* 226 */ "expr ::= INTEGER", - /* 227 */ "expr ::= MINUS INTEGER", - /* 228 */ "expr ::= PLUS INTEGER", - /* 229 */ "expr ::= FLOAT", - /* 230 */ "expr ::= MINUS FLOAT", - /* 231 */ "expr ::= PLUS FLOAT", - /* 232 */ "expr ::= STRING", - /* 233 */ "expr ::= NOW", - /* 234 */ "expr ::= VARIABLE", - /* 235 */ "expr ::= PLUS VARIABLE", - /* 236 */ "expr ::= MINUS VARIABLE", - /* 237 */ "expr ::= BOOL", - /* 238 */ "expr ::= NULL", - /* 239 */ "expr ::= ID LP exprlist RP", - /* 240 */ "expr ::= ID LP STAR RP", - /* 241 */ "expr ::= expr IS NULL", - /* 242 */ "expr ::= expr IS NOT NULL", - /* 243 */ "expr ::= expr LT expr", - /* 244 */ "expr ::= expr GT expr", - /* 245 */ "expr ::= expr LE expr", - /* 246 */ "expr ::= expr GE expr", - /* 247 */ "expr ::= expr NE expr", - /* 248 */ "expr ::= expr EQ expr", - /* 249 */ "expr ::= expr BETWEEN expr AND expr", - /* 250 */ "expr ::= expr AND expr", - /* 251 */ "expr ::= expr OR expr", - /* 252 */ "expr ::= expr PLUS expr", - /* 253 */ "expr ::= expr MINUS expr", - /* 254 */ "expr ::= expr STAR expr", - /* 255 */ "expr ::= expr SLASH expr", - /* 256 */ "expr ::= expr REM expr", - /* 257 */ "expr ::= expr LIKE expr", - /* 258 */ "expr ::= expr IN LP exprlist RP", - /* 259 */ "exprlist ::= exprlist COMMA expritem", - /* 260 */ "exprlist ::= expritem", - /* 261 */ "expritem ::= expr", - /* 262 */ "expritem ::=", - /* 263 */ "cmd ::= RESET QUERY CACHE", - /* 264 */ "cmd ::= SYNCDB ids REPLICA", - /* 265 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 266 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 267 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 268 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 269 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 270 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 271 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 272 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 273 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 274 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 275 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 276 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 277 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 278 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 279 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 280 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 281 */ "cmd ::= KILL CONNECTION INTEGER", - /* 282 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 283 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 122 */ "alter_db_optr ::= alter_db_optr update", + /* 123 */ "alter_db_optr ::= alter_db_optr cachelast", + /* 124 */ "alter_topic_optr ::= alter_db_optr", + /* 125 */ "alter_topic_optr ::= alter_topic_optr partitions", + /* 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 tagitemlist RP", + /* 141 */ "create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist 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 */ "tagitemlist ::= tagitemlist COMMA tagitem", + /* 149 */ "tagitemlist ::= tagitem", + /* 150 */ "tagitem ::= INTEGER", + /* 151 */ "tagitem ::= FLOAT", + /* 152 */ "tagitem ::= STRING", + /* 153 */ "tagitem ::= BOOL", + /* 154 */ "tagitem ::= NULL", + /* 155 */ "tagitem ::= NOW", + /* 156 */ "tagitem ::= MINUS INTEGER", + /* 157 */ "tagitem ::= MINUS FLOAT", + /* 158 */ "tagitem ::= PLUS INTEGER", + /* 159 */ "tagitem ::= PLUS FLOAT", + /* 160 */ "select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt", + /* 161 */ "select ::= LP select RP", + /* 162 */ "union ::= select", + /* 163 */ "union ::= union UNION ALL select", + /* 164 */ "cmd ::= union", + /* 165 */ "select ::= SELECT selcollist", + /* 166 */ "sclp ::= selcollist COMMA", + /* 167 */ "sclp ::=", + /* 168 */ "selcollist ::= sclp distinct expr as", + /* 169 */ "selcollist ::= sclp STAR", + /* 170 */ "as ::= AS ids", + /* 171 */ "as ::= ids", + /* 172 */ "as ::=", + /* 173 */ "distinct ::= DISTINCT", + /* 174 */ "distinct ::=", + /* 175 */ "from ::= FROM tablelist", + /* 176 */ "from ::= FROM sub", + /* 177 */ "sub ::= LP union RP", + /* 178 */ "sub ::= LP union RP ids", + /* 179 */ "sub ::= sub COMMA LP union RP ids", + /* 180 */ "tablelist ::= ids cpxName", + /* 181 */ "tablelist ::= ids cpxName ids", + /* 182 */ "tablelist ::= tablelist COMMA ids cpxName", + /* 183 */ "tablelist ::= tablelist COMMA ids cpxName ids", + /* 184 */ "tmvar ::= VARIABLE", + /* 185 */ "interval_opt ::= INTERVAL LP tmvar RP", + /* 186 */ "interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP", + /* 187 */ "interval_opt ::=", + /* 188 */ "session_option ::=", + /* 189 */ "session_option ::= SESSION LP ids cpxName COMMA tmvar RP", + /* 190 */ "windowstate_option ::=", + /* 191 */ "windowstate_option ::= STATE_WINDOW LP ids RP", + /* 192 */ "fill_opt ::=", + /* 193 */ "fill_opt ::= FILL LP ID COMMA tagitemlist RP", + /* 194 */ "fill_opt ::= FILL LP ID RP", + /* 195 */ "sliding_opt ::= SLIDING LP tmvar RP", + /* 196 */ "sliding_opt ::=", + /* 197 */ "orderby_opt ::=", + /* 198 */ "orderby_opt ::= ORDER BY sortlist", + /* 199 */ "sortlist ::= sortlist COMMA item sortorder", + /* 200 */ "sortlist ::= item sortorder", + /* 201 */ "item ::= ids cpxName", + /* 202 */ "sortorder ::= ASC", + /* 203 */ "sortorder ::= DESC", + /* 204 */ "sortorder ::=", + /* 205 */ "groupby_opt ::=", + /* 206 */ "groupby_opt ::= GROUP BY grouplist", + /* 207 */ "grouplist ::= grouplist COMMA item", + /* 208 */ "grouplist ::= item", + /* 209 */ "having_opt ::=", + /* 210 */ "having_opt ::= HAVING expr", + /* 211 */ "limit_opt ::=", + /* 212 */ "limit_opt ::= LIMIT signed", + /* 213 */ "limit_opt ::= LIMIT signed OFFSET signed", + /* 214 */ "limit_opt ::= LIMIT signed COMMA signed", + /* 215 */ "slimit_opt ::=", + /* 216 */ "slimit_opt ::= SLIMIT signed", + /* 217 */ "slimit_opt ::= SLIMIT signed SOFFSET signed", + /* 218 */ "slimit_opt ::= SLIMIT signed COMMA signed", + /* 219 */ "where_opt ::=", + /* 220 */ "where_opt ::= WHERE expr", + /* 221 */ "expr ::= LP expr RP", + /* 222 */ "expr ::= ID", + /* 223 */ "expr ::= ID DOT ID", + /* 224 */ "expr ::= ID DOT STAR", + /* 225 */ "expr ::= INTEGER", + /* 226 */ "expr ::= MINUS INTEGER", + /* 227 */ "expr ::= PLUS INTEGER", + /* 228 */ "expr ::= FLOAT", + /* 229 */ "expr ::= MINUS FLOAT", + /* 230 */ "expr ::= PLUS FLOAT", + /* 231 */ "expr ::= STRING", + /* 232 */ "expr ::= NOW", + /* 233 */ "expr ::= VARIABLE", + /* 234 */ "expr ::= PLUS VARIABLE", + /* 235 */ "expr ::= MINUS VARIABLE", + /* 236 */ "expr ::= BOOL", + /* 237 */ "expr ::= NULL", + /* 238 */ "expr ::= ID LP exprlist RP", + /* 239 */ "expr ::= ID LP STAR RP", + /* 240 */ "expr ::= expr IS NULL", + /* 241 */ "expr ::= expr IS NOT NULL", + /* 242 */ "expr ::= expr LT expr", + /* 243 */ "expr ::= expr GT expr", + /* 244 */ "expr ::= expr LE expr", + /* 245 */ "expr ::= expr GE expr", + /* 246 */ "expr ::= expr NE expr", + /* 247 */ "expr ::= expr EQ expr", + /* 248 */ "expr ::= expr BETWEEN expr AND expr", + /* 249 */ "expr ::= expr AND expr", + /* 250 */ "expr ::= expr OR expr", + /* 251 */ "expr ::= expr PLUS expr", + /* 252 */ "expr ::= expr MINUS expr", + /* 253 */ "expr ::= expr STAR expr", + /* 254 */ "expr ::= expr SLASH expr", + /* 255 */ "expr ::= expr REM expr", + /* 256 */ "expr ::= expr LIKE expr", + /* 257 */ "expr ::= expr IN LP exprlist RP", + /* 258 */ "exprlist ::= exprlist COMMA expritem", + /* 259 */ "exprlist ::= expritem", + /* 260 */ "expritem ::= expr", + /* 261 */ "expritem ::=", + /* 262 */ "cmd ::= RESET QUERY CACHE", + /* 263 */ "cmd ::= SYNCDB ids REPLICA", + /* 264 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 265 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 266 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 267 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 268 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 269 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 270 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 271 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 272 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 273 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 274 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 275 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 276 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 277 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 278 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 279 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 280 */ "cmd ::= KILL CONNECTION INTEGER", + /* 281 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 282 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1922,168 +1921,167 @@ static const struct { { 197, -2 }, /* (119) alter_db_optr ::= alter_db_optr keep */ { 197, -2 }, /* (120) alter_db_optr ::= alter_db_optr blocks */ { 197, -2 }, /* (121) alter_db_optr ::= alter_db_optr comp */ - { 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr fsync */ - { 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr update */ - { 197, -2 }, /* (124) alter_db_optr ::= alter_db_optr cachelast */ - { 198, -1 }, /* (125) alter_topic_optr ::= alter_db_optr */ - { 198, -2 }, /* (126) alter_topic_optr ::= alter_topic_optr partitions */ - { 231, -1 }, /* (127) typename ::= ids */ - { 231, -4 }, /* (128) typename ::= ids LP signed RP */ - { 231, -2 }, /* (129) typename ::= ids UNSIGNED */ - { 232, -1 }, /* (130) signed ::= INTEGER */ - { 232, -2 }, /* (131) signed ::= PLUS INTEGER */ - { 232, -2 }, /* (132) signed ::= MINUS INTEGER */ - { 192, -3 }, /* (133) cmd ::= CREATE TABLE create_table_args */ - { 192, -3 }, /* (134) cmd ::= CREATE TABLE create_stable_args */ - { 192, -3 }, /* (135) cmd ::= CREATE STABLE create_stable_args */ - { 192, -3 }, /* (136) cmd ::= CREATE TABLE create_table_list */ - { 235, -1 }, /* (137) create_table_list ::= create_from_stable */ - { 235, -2 }, /* (138) create_table_list ::= create_table_list create_from_stable */ - { 233, -6 }, /* (139) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 234, -10 }, /* (140) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 236, -10 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 236, -13 }, /* (142) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - { 239, -3 }, /* (143) tagNamelist ::= tagNamelist COMMA ids */ - { 239, -1 }, /* (144) tagNamelist ::= ids */ - { 233, -5 }, /* (145) create_table_args ::= ifnotexists ids cpxName AS select */ - { 237, -3 }, /* (146) columnlist ::= columnlist COMMA column */ - { 237, -1 }, /* (147) columnlist ::= column */ - { 241, -2 }, /* (148) column ::= ids typename */ - { 238, -3 }, /* (149) tagitemlist ::= tagitemlist COMMA tagitem */ - { 238, -1 }, /* (150) tagitemlist ::= tagitem */ - { 242, -1 }, /* (151) tagitem ::= INTEGER */ - { 242, -1 }, /* (152) tagitem ::= FLOAT */ - { 242, -1 }, /* (153) tagitem ::= STRING */ - { 242, -1 }, /* (154) tagitem ::= BOOL */ - { 242, -1 }, /* (155) tagitem ::= NULL */ - { 242, -1 }, /* (156) tagitem ::= NOW */ - { 242, -2 }, /* (157) tagitem ::= MINUS INTEGER */ - { 242, -2 }, /* (158) tagitem ::= MINUS FLOAT */ - { 242, -2 }, /* (159) tagitem ::= PLUS INTEGER */ - { 242, -2 }, /* (160) tagitem ::= PLUS FLOAT */ - { 240, -14 }, /* (161) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - { 240, -3 }, /* (162) select ::= LP select RP */ - { 256, -1 }, /* (163) union ::= select */ - { 256, -4 }, /* (164) union ::= union UNION ALL select */ - { 192, -1 }, /* (165) cmd ::= union */ - { 240, -2 }, /* (166) select ::= SELECT selcollist */ - { 257, -2 }, /* (167) sclp ::= selcollist COMMA */ - { 257, 0 }, /* (168) sclp ::= */ - { 243, -4 }, /* (169) selcollist ::= sclp distinct expr as */ - { 243, -2 }, /* (170) selcollist ::= sclp STAR */ - { 260, -2 }, /* (171) as ::= AS ids */ - { 260, -1 }, /* (172) as ::= ids */ - { 260, 0 }, /* (173) as ::= */ - { 258, -1 }, /* (174) distinct ::= DISTINCT */ - { 258, 0 }, /* (175) distinct ::= */ - { 244, -2 }, /* (176) from ::= FROM tablelist */ - { 244, -2 }, /* (177) from ::= FROM sub */ - { 262, -3 }, /* (178) sub ::= LP union RP */ - { 262, -4 }, /* (179) sub ::= LP union RP ids */ - { 262, -6 }, /* (180) sub ::= sub COMMA LP union RP ids */ - { 261, -2 }, /* (181) tablelist ::= ids cpxName */ - { 261, -3 }, /* (182) tablelist ::= ids cpxName ids */ - { 261, -4 }, /* (183) tablelist ::= tablelist COMMA ids cpxName */ - { 261, -5 }, /* (184) tablelist ::= tablelist COMMA ids cpxName ids */ - { 263, -1 }, /* (185) tmvar ::= VARIABLE */ - { 246, -4 }, /* (186) interval_opt ::= INTERVAL LP tmvar RP */ - { 246, -6 }, /* (187) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 246, 0 }, /* (188) interval_opt ::= */ - { 247, 0 }, /* (189) session_option ::= */ - { 247, -7 }, /* (190) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 248, 0 }, /* (191) windowstate_option ::= */ - { 248, -4 }, /* (192) windowstate_option ::= STATE_WINDOW LP ids RP */ - { 249, 0 }, /* (193) fill_opt ::= */ - { 249, -6 }, /* (194) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 249, -4 }, /* (195) fill_opt ::= FILL LP ID RP */ - { 250, -4 }, /* (196) sliding_opt ::= SLIDING LP tmvar RP */ - { 250, 0 }, /* (197) sliding_opt ::= */ - { 253, 0 }, /* (198) orderby_opt ::= */ - { 253, -3 }, /* (199) orderby_opt ::= ORDER BY sortlist */ - { 264, -4 }, /* (200) sortlist ::= sortlist COMMA item sortorder */ - { 264, -2 }, /* (201) sortlist ::= item sortorder */ - { 266, -2 }, /* (202) item ::= ids cpxName */ - { 267, -1 }, /* (203) sortorder ::= ASC */ - { 267, -1 }, /* (204) sortorder ::= DESC */ - { 267, 0 }, /* (205) sortorder ::= */ - { 251, 0 }, /* (206) groupby_opt ::= */ - { 251, -3 }, /* (207) groupby_opt ::= GROUP BY grouplist */ - { 268, -3 }, /* (208) grouplist ::= grouplist COMMA item */ - { 268, -1 }, /* (209) grouplist ::= item */ - { 252, 0 }, /* (210) having_opt ::= */ - { 252, -2 }, /* (211) having_opt ::= HAVING expr */ - { 255, 0 }, /* (212) limit_opt ::= */ - { 255, -2 }, /* (213) limit_opt ::= LIMIT signed */ - { 255, -4 }, /* (214) limit_opt ::= LIMIT signed OFFSET signed */ - { 255, -4 }, /* (215) limit_opt ::= LIMIT signed COMMA signed */ - { 254, 0 }, /* (216) slimit_opt ::= */ - { 254, -2 }, /* (217) slimit_opt ::= SLIMIT signed */ - { 254, -4 }, /* (218) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 254, -4 }, /* (219) slimit_opt ::= SLIMIT signed COMMA signed */ - { 245, 0 }, /* (220) where_opt ::= */ - { 245, -2 }, /* (221) where_opt ::= WHERE expr */ - { 259, -3 }, /* (222) expr ::= LP expr RP */ - { 259, -1 }, /* (223) expr ::= ID */ - { 259, -3 }, /* (224) expr ::= ID DOT ID */ - { 259, -3 }, /* (225) expr ::= ID DOT STAR */ - { 259, -1 }, /* (226) expr ::= INTEGER */ - { 259, -2 }, /* (227) expr ::= MINUS INTEGER */ - { 259, -2 }, /* (228) expr ::= PLUS INTEGER */ - { 259, -1 }, /* (229) expr ::= FLOAT */ - { 259, -2 }, /* (230) expr ::= MINUS FLOAT */ - { 259, -2 }, /* (231) expr ::= PLUS FLOAT */ - { 259, -1 }, /* (232) expr ::= STRING */ - { 259, -1 }, /* (233) expr ::= NOW */ - { 259, -1 }, /* (234) expr ::= VARIABLE */ - { 259, -2 }, /* (235) expr ::= PLUS VARIABLE */ - { 259, -2 }, /* (236) expr ::= MINUS VARIABLE */ - { 259, -1 }, /* (237) expr ::= BOOL */ - { 259, -1 }, /* (238) expr ::= NULL */ - { 259, -4 }, /* (239) expr ::= ID LP exprlist RP */ - { 259, -4 }, /* (240) expr ::= ID LP STAR RP */ - { 259, -3 }, /* (241) expr ::= expr IS NULL */ - { 259, -4 }, /* (242) expr ::= expr IS NOT NULL */ - { 259, -3 }, /* (243) expr ::= expr LT expr */ - { 259, -3 }, /* (244) expr ::= expr GT expr */ - { 259, -3 }, /* (245) expr ::= expr LE expr */ - { 259, -3 }, /* (246) expr ::= expr GE expr */ - { 259, -3 }, /* (247) expr ::= expr NE expr */ - { 259, -3 }, /* (248) expr ::= expr EQ expr */ - { 259, -5 }, /* (249) expr ::= expr BETWEEN expr AND expr */ - { 259, -3 }, /* (250) expr ::= expr AND expr */ - { 259, -3 }, /* (251) expr ::= expr OR expr */ - { 259, -3 }, /* (252) expr ::= expr PLUS expr */ - { 259, -3 }, /* (253) expr ::= expr MINUS expr */ - { 259, -3 }, /* (254) expr ::= expr STAR expr */ - { 259, -3 }, /* (255) expr ::= expr SLASH expr */ - { 259, -3 }, /* (256) expr ::= expr REM expr */ - { 259, -3 }, /* (257) expr ::= expr LIKE expr */ - { 259, -5 }, /* (258) expr ::= expr IN LP exprlist RP */ - { 200, -3 }, /* (259) exprlist ::= exprlist COMMA expritem */ - { 200, -1 }, /* (260) exprlist ::= expritem */ - { 269, -1 }, /* (261) expritem ::= expr */ - { 269, 0 }, /* (262) expritem ::= */ - { 192, -3 }, /* (263) cmd ::= RESET QUERY CACHE */ - { 192, -3 }, /* (264) cmd ::= SYNCDB ids REPLICA */ - { 192, -7 }, /* (265) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - { 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 192, -7 }, /* (269) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 192, -8 }, /* (270) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 192, -9 }, /* (271) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 192, -7 }, /* (272) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - { 192, -7 }, /* (273) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - { 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 192, -7 }, /* (277) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 192, -8 }, /* (278) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 192, -9 }, /* (279) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - { 192, -7 }, /* (280) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - { 192, -3 }, /* (281) cmd ::= KILL CONNECTION INTEGER */ - { 192, -5 }, /* (282) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 192, -5 }, /* (283) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 197, -2 }, /* (122) alter_db_optr ::= alter_db_optr update */ + { 197, -2 }, /* (123) alter_db_optr ::= alter_db_optr cachelast */ + { 198, -1 }, /* (124) alter_topic_optr ::= alter_db_optr */ + { 198, -2 }, /* (125) alter_topic_optr ::= alter_topic_optr partitions */ + { 231, -1 }, /* (126) typename ::= ids */ + { 231, -4 }, /* (127) typename ::= ids LP signed RP */ + { 231, -2 }, /* (128) typename ::= ids UNSIGNED */ + { 232, -1 }, /* (129) signed ::= INTEGER */ + { 232, -2 }, /* (130) signed ::= PLUS INTEGER */ + { 232, -2 }, /* (131) signed ::= MINUS INTEGER */ + { 192, -3 }, /* (132) cmd ::= CREATE TABLE create_table_args */ + { 192, -3 }, /* (133) cmd ::= CREATE TABLE create_stable_args */ + { 192, -3 }, /* (134) cmd ::= CREATE STABLE create_stable_args */ + { 192, -3 }, /* (135) cmd ::= CREATE TABLE create_table_list */ + { 235, -1 }, /* (136) create_table_list ::= create_from_stable */ + { 235, -2 }, /* (137) create_table_list ::= create_table_list create_from_stable */ + { 233, -6 }, /* (138) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 234, -10 }, /* (139) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 236, -10 }, /* (140) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 236, -13 }, /* (141) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 239, -3 }, /* (142) tagNamelist ::= tagNamelist COMMA ids */ + { 239, -1 }, /* (143) tagNamelist ::= ids */ + { 233, -5 }, /* (144) create_table_args ::= ifnotexists ids cpxName AS select */ + { 237, -3 }, /* (145) columnlist ::= columnlist COMMA column */ + { 237, -1 }, /* (146) columnlist ::= column */ + { 241, -2 }, /* (147) column ::= ids typename */ + { 238, -3 }, /* (148) tagitemlist ::= tagitemlist COMMA tagitem */ + { 238, -1 }, /* (149) tagitemlist ::= tagitem */ + { 242, -1 }, /* (150) tagitem ::= INTEGER */ + { 242, -1 }, /* (151) tagitem ::= FLOAT */ + { 242, -1 }, /* (152) tagitem ::= STRING */ + { 242, -1 }, /* (153) tagitem ::= BOOL */ + { 242, -1 }, /* (154) tagitem ::= NULL */ + { 242, -1 }, /* (155) tagitem ::= NOW */ + { 242, -2 }, /* (156) tagitem ::= MINUS INTEGER */ + { 242, -2 }, /* (157) tagitem ::= MINUS FLOAT */ + { 242, -2 }, /* (158) tagitem ::= PLUS INTEGER */ + { 242, -2 }, /* (159) tagitem ::= PLUS FLOAT */ + { 240, -14 }, /* (160) select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 240, -3 }, /* (161) select ::= LP select RP */ + { 256, -1 }, /* (162) union ::= select */ + { 256, -4 }, /* (163) union ::= union UNION ALL select */ + { 192, -1 }, /* (164) cmd ::= union */ + { 240, -2 }, /* (165) select ::= SELECT selcollist */ + { 257, -2 }, /* (166) sclp ::= selcollist COMMA */ + { 257, 0 }, /* (167) sclp ::= */ + { 243, -4 }, /* (168) selcollist ::= sclp distinct expr as */ + { 243, -2 }, /* (169) selcollist ::= sclp STAR */ + { 260, -2 }, /* (170) as ::= AS ids */ + { 260, -1 }, /* (171) as ::= ids */ + { 260, 0 }, /* (172) as ::= */ + { 258, -1 }, /* (173) distinct ::= DISTINCT */ + { 258, 0 }, /* (174) distinct ::= */ + { 244, -2 }, /* (175) from ::= FROM tablelist */ + { 244, -2 }, /* (176) from ::= FROM sub */ + { 262, -3 }, /* (177) sub ::= LP union RP */ + { 262, -4 }, /* (178) sub ::= LP union RP ids */ + { 262, -6 }, /* (179) sub ::= sub COMMA LP union RP ids */ + { 261, -2 }, /* (180) tablelist ::= ids cpxName */ + { 261, -3 }, /* (181) tablelist ::= ids cpxName ids */ + { 261, -4 }, /* (182) tablelist ::= tablelist COMMA ids cpxName */ + { 261, -5 }, /* (183) tablelist ::= tablelist COMMA ids cpxName ids */ + { 263, -1 }, /* (184) tmvar ::= VARIABLE */ + { 246, -4 }, /* (185) interval_opt ::= INTERVAL LP tmvar RP */ + { 246, -6 }, /* (186) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 246, 0 }, /* (187) interval_opt ::= */ + { 247, 0 }, /* (188) session_option ::= */ + { 247, -7 }, /* (189) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 248, 0 }, /* (190) windowstate_option ::= */ + { 248, -4 }, /* (191) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 249, 0 }, /* (192) fill_opt ::= */ + { 249, -6 }, /* (193) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 249, -4 }, /* (194) fill_opt ::= FILL LP ID RP */ + { 250, -4 }, /* (195) sliding_opt ::= SLIDING LP tmvar RP */ + { 250, 0 }, /* (196) sliding_opt ::= */ + { 253, 0 }, /* (197) orderby_opt ::= */ + { 253, -3 }, /* (198) orderby_opt ::= ORDER BY sortlist */ + { 264, -4 }, /* (199) sortlist ::= sortlist COMMA item sortorder */ + { 264, -2 }, /* (200) sortlist ::= item sortorder */ + { 266, -2 }, /* (201) item ::= ids cpxName */ + { 267, -1 }, /* (202) sortorder ::= ASC */ + { 267, -1 }, /* (203) sortorder ::= DESC */ + { 267, 0 }, /* (204) sortorder ::= */ + { 251, 0 }, /* (205) groupby_opt ::= */ + { 251, -3 }, /* (206) groupby_opt ::= GROUP BY grouplist */ + { 268, -3 }, /* (207) grouplist ::= grouplist COMMA item */ + { 268, -1 }, /* (208) grouplist ::= item */ + { 252, 0 }, /* (209) having_opt ::= */ + { 252, -2 }, /* (210) having_opt ::= HAVING expr */ + { 255, 0 }, /* (211) limit_opt ::= */ + { 255, -2 }, /* (212) limit_opt ::= LIMIT signed */ + { 255, -4 }, /* (213) limit_opt ::= LIMIT signed OFFSET signed */ + { 255, -4 }, /* (214) limit_opt ::= LIMIT signed COMMA signed */ + { 254, 0 }, /* (215) slimit_opt ::= */ + { 254, -2 }, /* (216) slimit_opt ::= SLIMIT signed */ + { 254, -4 }, /* (217) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 254, -4 }, /* (218) slimit_opt ::= SLIMIT signed COMMA signed */ + { 245, 0 }, /* (219) where_opt ::= */ + { 245, -2 }, /* (220) where_opt ::= WHERE expr */ + { 259, -3 }, /* (221) expr ::= LP expr RP */ + { 259, -1 }, /* (222) expr ::= ID */ + { 259, -3 }, /* (223) expr ::= ID DOT ID */ + { 259, -3 }, /* (224) expr ::= ID DOT STAR */ + { 259, -1 }, /* (225) expr ::= INTEGER */ + { 259, -2 }, /* (226) expr ::= MINUS INTEGER */ + { 259, -2 }, /* (227) expr ::= PLUS INTEGER */ + { 259, -1 }, /* (228) expr ::= FLOAT */ + { 259, -2 }, /* (229) expr ::= MINUS FLOAT */ + { 259, -2 }, /* (230) expr ::= PLUS FLOAT */ + { 259, -1 }, /* (231) expr ::= STRING */ + { 259, -1 }, /* (232) expr ::= NOW */ + { 259, -1 }, /* (233) expr ::= VARIABLE */ + { 259, -2 }, /* (234) expr ::= PLUS VARIABLE */ + { 259, -2 }, /* (235) expr ::= MINUS VARIABLE */ + { 259, -1 }, /* (236) expr ::= BOOL */ + { 259, -1 }, /* (237) expr ::= NULL */ + { 259, -4 }, /* (238) expr ::= ID LP exprlist RP */ + { 259, -4 }, /* (239) expr ::= ID LP STAR RP */ + { 259, -3 }, /* (240) expr ::= expr IS NULL */ + { 259, -4 }, /* (241) expr ::= expr IS NOT NULL */ + { 259, -3 }, /* (242) expr ::= expr LT expr */ + { 259, -3 }, /* (243) expr ::= expr GT expr */ + { 259, -3 }, /* (244) expr ::= expr LE expr */ + { 259, -3 }, /* (245) expr ::= expr GE expr */ + { 259, -3 }, /* (246) expr ::= expr NE expr */ + { 259, -3 }, /* (247) expr ::= expr EQ expr */ + { 259, -5 }, /* (248) expr ::= expr BETWEEN expr AND expr */ + { 259, -3 }, /* (249) expr ::= expr AND expr */ + { 259, -3 }, /* (250) expr ::= expr OR expr */ + { 259, -3 }, /* (251) expr ::= expr PLUS expr */ + { 259, -3 }, /* (252) expr ::= expr MINUS expr */ + { 259, -3 }, /* (253) expr ::= expr STAR expr */ + { 259, -3 }, /* (254) expr ::= expr SLASH expr */ + { 259, -3 }, /* (255) expr ::= expr REM expr */ + { 259, -3 }, /* (256) expr ::= expr LIKE expr */ + { 259, -5 }, /* (257) expr ::= expr IN LP exprlist RP */ + { 200, -3 }, /* (258) exprlist ::= exprlist COMMA expritem */ + { 200, -1 }, /* (259) exprlist ::= expritem */ + { 269, -1 }, /* (260) expritem ::= expr */ + { 269, 0 }, /* (261) expritem ::= */ + { 192, -3 }, /* (262) cmd ::= RESET QUERY CACHE */ + { 192, -3 }, /* (263) cmd ::= SYNCDB ids REPLICA */ + { 192, -7 }, /* (264) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 192, -7 }, /* (265) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 192, -7 }, /* (266) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 192, -7 }, /* (267) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 192, -7 }, /* (268) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 192, -8 }, /* (269) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 192, -9 }, /* (270) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 192, -7 }, /* (271) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 192, -7 }, /* (272) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 192, -7 }, /* (273) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 192, -7 }, /* (274) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 192, -7 }, /* (275) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 192, -7 }, /* (276) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 192, -8 }, /* (277) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 192, -9 }, /* (278) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 192, -7 }, /* (279) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 192, -3 }, /* (280) cmd ::= KILL CONNECTION INTEGER */ + { 192, -5 }, /* (281) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 192, -5 }, /* (282) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2164,9 +2162,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 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); {} break; case 1: /* cmd ::= SHOW DATABASES */ @@ -2357,7 +2355,7 @@ static void yy_reduce( break; case 52: /* ifexists ::= */ case 54: /* ifnotexists ::= */ yytestcase(yyruleno==54); - case 175: /* distinct ::= */ yytestcase(yyruleno==175); + case 174: /* distinct ::= */ yytestcase(yyruleno==174); { yymsp[1].minor.yy0.n = 0;} break; case 53: /* ifnotexists ::= IF NOT EXISTS */ @@ -2413,20 +2411,20 @@ static void yy_reduce( yymsp[-8].minor.yy151 = yylhsminor.yy151; break; case 79: /* intitemlist ::= intitemlist COMMA intitem */ - case 149: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==149); + case 148: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==148); { yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; case 80: /* intitemlist ::= intitem */ - case 150: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==150); + case 149: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==149); { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; case 81: /* intitem ::= INTEGER */ - case 151: /* tagitem ::= INTEGER */ yytestcase(yyruleno==151); - case 152: /* tagitem ::= FLOAT */ yytestcase(yyruleno==152); - case 153: /* tagitem ::= STRING */ yytestcase(yyruleno==153); - case 154: /* tagitem ::= BOOL */ yytestcase(yyruleno==154); + case 150: /* tagitem ::= INTEGER */ yytestcase(yyruleno==150); + case 151: /* tagitem ::= FLOAT */ yytestcase(yyruleno==151); + case 152: /* tagitem ::= STRING */ yytestcase(yyruleno==152); + case 153: /* tagitem ::= BOOL */ yytestcase(yyruleno==153); { toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } yymsp[0].minor.yy506 = yylhsminor.yy506; break; @@ -2493,7 +2491,6 @@ static void yy_reduce( yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 108: /* db_optr ::= db_optr fsync */ - case 122: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==122); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; @@ -2512,36 +2509,36 @@ static void yy_reduce( yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 112: /* db_optr ::= db_optr update */ - case 123: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==123); + case 122: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==122); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 113: /* db_optr ::= db_optr cachelast */ - case 124: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==124); + case 123: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==123); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 114: /* topic_optr ::= db_optr */ - case 125: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==125); + case 124: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==124); { yylhsminor.yy382 = yymsp[0].minor.yy382; yylhsminor.yy382.dbType = TSDB_DB_TYPE_TOPIC; } yymsp[0].minor.yy382 = yylhsminor.yy382; break; case 115: /* topic_optr ::= topic_optr partitions */ - case 126: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==126); + case 125: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==125); { yylhsminor.yy382 = yymsp[-1].minor.yy382; yylhsminor.yy382.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[-1].minor.yy382 = yylhsminor.yy382; break; case 116: /* alter_db_optr ::= */ { setDefaultCreateDbOption(&yymsp[1].minor.yy382); yymsp[1].minor.yy382.dbType = TSDB_DB_TYPE_DEFAULT;} break; - case 127: /* typename ::= ids */ + case 126: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; tSetColumnType (&yylhsminor.yy343, &yymsp[0].minor.yy0); } yymsp[0].minor.yy343 = yylhsminor.yy343; break; - case 128: /* typename ::= ids LP signed RP */ + case 127: /* typename ::= ids LP signed RP */ { if (yymsp[-1].minor.yy369 <= 0) { yymsp[-3].minor.yy0.type = 0; @@ -2553,7 +2550,7 @@ static void yy_reduce( } yymsp[-3].minor.yy343 = yylhsminor.yy343; break; - case 129: /* typename ::= ids UNSIGNED */ + case 128: /* 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); @@ -2561,20 +2558,20 @@ static void yy_reduce( } yymsp[-1].minor.yy343 = yylhsminor.yy343; break; - case 130: /* signed ::= INTEGER */ + case 129: /* signed ::= INTEGER */ { yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } yymsp[0].minor.yy369 = yylhsminor.yy369; break; - case 131: /* signed ::= PLUS INTEGER */ + case 130: /* signed ::= PLUS INTEGER */ { yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 132: /* signed ::= MINUS INTEGER */ + case 131: /* signed ::= MINUS INTEGER */ { yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; - case 136: /* cmd ::= CREATE TABLE create_table_list */ + case 135: /* cmd ::= CREATE TABLE create_table_list */ { pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy182;} break; - case 137: /* create_table_list ::= create_from_stable */ + case 136: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); @@ -2585,14 +2582,14 @@ static void yy_reduce( } yymsp[0].minor.yy182 = yylhsminor.yy182; break; - case 138: /* create_table_list ::= create_table_list create_from_stable */ + case 137: /* create_table_list ::= create_table_list create_from_stable */ { taosArrayPush(yymsp[-1].minor.yy182->childTableInfo, &yymsp[0].minor.yy456); yylhsminor.yy182 = yymsp[-1].minor.yy182; } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 139: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + case 138: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-1].minor.yy441, NULL, NULL, TSQL_CREATE_TABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2602,7 +2599,7 @@ static void yy_reduce( } yymsp[-5].minor.yy182 = yylhsminor.yy182; break; - case 140: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + case 139: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { yylhsminor.yy182 = tSetCreateTableInfo(yymsp[-5].minor.yy441, yymsp[-1].minor.yy441, NULL, TSQL_CREATE_STABLE); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2612,7 +2609,7 @@ static void yy_reduce( } yymsp[-9].minor.yy182 = yylhsminor.yy182; break; - case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + case 140: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; @@ -2620,7 +2617,7 @@ static void yy_reduce( } yymsp[-9].minor.yy456 = yylhsminor.yy456; break; - case 142: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + case 141: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; @@ -2628,15 +2625,15 @@ static void yy_reduce( } yymsp[-12].minor.yy456 = yylhsminor.yy456; break; - case 143: /* tagNamelist ::= tagNamelist COMMA ids */ + case 142: /* tagNamelist ::= tagNamelist COMMA ids */ {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy0); yylhsminor.yy441 = yymsp[-2].minor.yy441; } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 144: /* tagNamelist ::= ids */ + case 143: /* tagNamelist ::= ids */ {yylhsminor.yy441 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy0);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 145: /* create_table_args ::= ifnotexists ids cpxName AS select */ + case 144: /* create_table_args ::= ifnotexists ids cpxName AS select */ { yylhsminor.yy182 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy236, TSQL_CREATE_STREAM); setSqlInfo(pInfo, yylhsminor.yy182, NULL, TSDB_SQL_CREATE_TABLE); @@ -2646,32 +2643,32 @@ static void yy_reduce( } yymsp[-4].minor.yy182 = yylhsminor.yy182; break; - case 146: /* columnlist ::= columnlist COMMA column */ + case 145: /* columnlist ::= columnlist COMMA column */ {taosArrayPush(yymsp[-2].minor.yy441, &yymsp[0].minor.yy343); yylhsminor.yy441 = yymsp[-2].minor.yy441; } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 147: /* columnlist ::= column */ + case 146: /* columnlist ::= column */ {yylhsminor.yy441 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy441, &yymsp[0].minor.yy343);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 148: /* column ::= ids typename */ + case 147: /* column ::= ids typename */ { tSetColumnInfo(&yylhsminor.yy343, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy343); } yymsp[-1].minor.yy343 = yylhsminor.yy343; break; - case 155: /* tagitem ::= NULL */ + case 154: /* tagitem ::= NULL */ { yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0); } yymsp[0].minor.yy506 = yylhsminor.yy506; break; - case 156: /* tagitem ::= NOW */ + case 155: /* tagitem ::= NOW */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&yylhsminor.yy506, &yymsp[0].minor.yy0);} yymsp[0].minor.yy506 = yylhsminor.yy506; break; - case 157: /* tagitem ::= MINUS INTEGER */ - case 158: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==158); - case 159: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==159); - case 160: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==160); + case 156: /* tagitem ::= MINUS INTEGER */ + case 157: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==157); + case 158: /* tagitem ::= PLUS INTEGER */ yytestcase(yyruleno==158); + case 159: /* tagitem ::= PLUS FLOAT */ yytestcase(yyruleno==159); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; @@ -2680,142 +2677,142 @@ static void yy_reduce( } yymsp[-1].minor.yy506 = yylhsminor.yy506; break; - case 161: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + case 160: /* select ::= SELECT selcollist from where_opt interval_opt session_option windowstate_option fill_opt sliding_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-13].minor.yy0, yymsp[-12].minor.yy441, yymsp[-11].minor.yy244, yymsp[-10].minor.yy166, yymsp[-4].minor.yy441, yymsp[-2].minor.yy441, &yymsp[-9].minor.yy340, &yymsp[-8].minor.yy259, &yymsp[-7].minor.yy348, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy441, &yymsp[0].minor.yy414, &yymsp[-1].minor.yy414, yymsp[-3].minor.yy166); } yymsp[-13].minor.yy236 = yylhsminor.yy236; break; - case 162: /* select ::= LP select RP */ + case 161: /* select ::= LP select RP */ {yymsp[-2].minor.yy236 = yymsp[-1].minor.yy236;} break; - case 163: /* union ::= select */ + case 162: /* union ::= select */ { yylhsminor.yy441 = setSubclause(NULL, yymsp[0].minor.yy236); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 164: /* union ::= union UNION ALL select */ + case 163: /* union ::= union UNION ALL select */ { yylhsminor.yy441 = appendSelectClause(yymsp[-3].minor.yy441, yymsp[0].minor.yy236); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 165: /* cmd ::= union */ + case 164: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy441, NULL, TSDB_SQL_SELECT); } break; - case 166: /* select ::= SELECT selcollist */ + case 165: /* select ::= SELECT selcollist */ { yylhsminor.yy236 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy441, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy236 = yylhsminor.yy236; break; - case 167: /* sclp ::= selcollist COMMA */ + case 166: /* sclp ::= selcollist COMMA */ {yylhsminor.yy441 = yymsp[-1].minor.yy441;} yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 168: /* sclp ::= */ - case 198: /* orderby_opt ::= */ yytestcase(yyruleno==198); + case 167: /* sclp ::= */ + case 197: /* orderby_opt ::= */ yytestcase(yyruleno==197); {yymsp[1].minor.yy441 = 0;} break; - case 169: /* selcollist ::= sclp distinct expr as */ + case 168: /* selcollist ::= sclp distinct expr as */ { yylhsminor.yy441 = tSqlExprListAppend(yymsp[-3].minor.yy441, yymsp[-1].minor.yy166, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 170: /* selcollist ::= sclp STAR */ + case 169: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); yylhsminor.yy441 = tSqlExprListAppend(yymsp[-1].minor.yy441, pNode, 0, 0); } yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 171: /* as ::= AS ids */ + case 170: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 172: /* as ::= ids */ + case 171: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 173: /* as ::= */ + case 172: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 174: /* distinct ::= DISTINCT */ + case 173: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 176: /* from ::= FROM tablelist */ - case 177: /* from ::= FROM sub */ yytestcase(yyruleno==177); + case 175: /* from ::= FROM tablelist */ + case 176: /* from ::= FROM sub */ yytestcase(yyruleno==176); {yymsp[-1].minor.yy244 = yymsp[0].minor.yy244;} break; - case 178: /* sub ::= LP union RP */ + case 177: /* sub ::= LP union RP */ {yymsp[-2].minor.yy244 = addSubqueryElem(NULL, yymsp[-1].minor.yy441, NULL);} break; - case 179: /* sub ::= LP union RP ids */ + case 178: /* sub ::= LP union RP ids */ {yymsp[-3].minor.yy244 = addSubqueryElem(NULL, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} break; - case 180: /* sub ::= sub COMMA LP union RP ids */ + case 179: /* sub ::= sub COMMA LP union RP ids */ {yylhsminor.yy244 = addSubqueryElem(yymsp[-5].minor.yy244, yymsp[-2].minor.yy441, &yymsp[0].minor.yy0);} yymsp[-5].minor.yy244 = yylhsminor.yy244; break; - case 181: /* tablelist ::= ids cpxName */ + case 180: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } yymsp[-1].minor.yy244 = yylhsminor.yy244; break; - case 182: /* tablelist ::= ids cpxName ids */ + case 181: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy244 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy244 = yylhsminor.yy244; break; - case 183: /* tablelist ::= tablelist COMMA ids cpxName */ + case 182: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yylhsminor.yy244 = setTableNameList(yymsp[-3].minor.yy244, &yymsp[-1].minor.yy0, NULL); } yymsp[-3].minor.yy244 = yylhsminor.yy244; break; - case 184: /* tablelist ::= tablelist COMMA ids cpxName ids */ + case 183: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; yylhsminor.yy244 = setTableNameList(yymsp[-4].minor.yy244, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-4].minor.yy244 = yylhsminor.yy244; break; - case 185: /* tmvar ::= VARIABLE */ + case 184: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 186: /* interval_opt ::= INTERVAL LP tmvar RP */ + case 185: /* interval_opt ::= INTERVAL LP tmvar RP */ {yymsp[-3].minor.yy340.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy340.offset.n = 0;} break; - case 187: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + case 186: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ {yymsp[-5].minor.yy340.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy340.offset = yymsp[-1].minor.yy0;} break; - case 188: /* interval_opt ::= */ + case 187: /* interval_opt ::= */ {memset(&yymsp[1].minor.yy340, 0, sizeof(yymsp[1].minor.yy340));} break; - case 189: /* session_option ::= */ + case 188: /* session_option ::= */ {yymsp[1].minor.yy259.col.n = 0; yymsp[1].minor.yy259.gap.n = 0;} break; - case 190: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + case 189: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; yymsp[-6].minor.yy259.col = yymsp[-4].minor.yy0; yymsp[-6].minor.yy259.gap = yymsp[-1].minor.yy0; } break; - case 191: /* windowstate_option ::= */ + case 190: /* windowstate_option ::= */ { yymsp[1].minor.yy348.col.n = 0; yymsp[1].minor.yy348.col.z = NULL;} break; - case 192: /* windowstate_option ::= STATE_WINDOW LP ids RP */ + case 191: /* windowstate_option ::= STATE_WINDOW LP ids RP */ { yymsp[-3].minor.yy348.col = yymsp[-1].minor.yy0; } break; - case 193: /* fill_opt ::= */ + case 192: /* fill_opt ::= */ { yymsp[1].minor.yy441 = 0; } break; - case 194: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + case 193: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { tVariant A = {0}; toTSDBType(yymsp[-3].minor.yy0.type); @@ -2825,34 +2822,34 @@ static void yy_reduce( yymsp[-5].minor.yy441 = yymsp[-1].minor.yy441; } break; - case 195: /* fill_opt ::= FILL LP ID RP */ + case 194: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-3].minor.yy441 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; - case 196: /* sliding_opt ::= SLIDING LP tmvar RP */ + case 195: /* sliding_opt ::= SLIDING LP tmvar RP */ {yymsp[-3].minor.yy0 = yymsp[-1].minor.yy0; } break; - case 197: /* sliding_opt ::= */ + case 196: /* sliding_opt ::= */ {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; - case 199: /* orderby_opt ::= ORDER BY sortlist */ + case 198: /* orderby_opt ::= ORDER BY sortlist */ {yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} break; - case 200: /* sortlist ::= sortlist COMMA item sortorder */ + case 199: /* sortlist ::= sortlist COMMA item sortorder */ { yylhsminor.yy441 = tVariantListAppend(yymsp[-3].minor.yy441, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); } yymsp[-3].minor.yy441 = yylhsminor.yy441; break; - case 201: /* sortlist ::= item sortorder */ + case 200: /* sortlist ::= item sortorder */ { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[-1].minor.yy506, yymsp[0].minor.yy112); } yymsp[-1].minor.yy441 = yylhsminor.yy441; break; - case 202: /* item ::= ids cpxName */ + case 201: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; @@ -2861,227 +2858,227 @@ static void yy_reduce( } yymsp[-1].minor.yy506 = yylhsminor.yy506; break; - case 203: /* sortorder ::= ASC */ + case 202: /* sortorder ::= ASC */ { yymsp[0].minor.yy112 = TSDB_ORDER_ASC; } break; - case 204: /* sortorder ::= DESC */ + case 203: /* sortorder ::= DESC */ { yymsp[0].minor.yy112 = TSDB_ORDER_DESC;} break; - case 205: /* sortorder ::= */ + case 204: /* sortorder ::= */ { yymsp[1].minor.yy112 = TSDB_ORDER_ASC; } break; - case 206: /* groupby_opt ::= */ + case 205: /* groupby_opt ::= */ { yymsp[1].minor.yy441 = 0;} break; - case 207: /* groupby_opt ::= GROUP BY grouplist */ + case 206: /* groupby_opt ::= GROUP BY grouplist */ { yymsp[-2].minor.yy441 = yymsp[0].minor.yy441;} break; - case 208: /* grouplist ::= grouplist COMMA item */ + case 207: /* grouplist ::= grouplist COMMA item */ { yylhsminor.yy441 = tVariantListAppend(yymsp[-2].minor.yy441, &yymsp[0].minor.yy506, -1); } yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 209: /* grouplist ::= item */ + case 208: /* grouplist ::= item */ { yylhsminor.yy441 = tVariantListAppend(NULL, &yymsp[0].minor.yy506, -1); } yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 210: /* having_opt ::= */ - case 220: /* where_opt ::= */ yytestcase(yyruleno==220); - case 262: /* expritem ::= */ yytestcase(yyruleno==262); + case 209: /* having_opt ::= */ + case 219: /* where_opt ::= */ yytestcase(yyruleno==219); + case 261: /* expritem ::= */ yytestcase(yyruleno==261); {yymsp[1].minor.yy166 = 0;} break; - case 211: /* having_opt ::= HAVING expr */ - case 221: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==221); + case 210: /* having_opt ::= HAVING expr */ + case 220: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==220); {yymsp[-1].minor.yy166 = yymsp[0].minor.yy166;} break; - case 212: /* limit_opt ::= */ - case 216: /* slimit_opt ::= */ yytestcase(yyruleno==216); + case 211: /* limit_opt ::= */ + case 215: /* slimit_opt ::= */ yytestcase(yyruleno==215); {yymsp[1].minor.yy414.limit = -1; yymsp[1].minor.yy414.offset = 0;} break; - case 213: /* limit_opt ::= LIMIT signed */ - case 217: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==217); + case 212: /* limit_opt ::= LIMIT signed */ + case 216: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==216); {yymsp[-1].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy414.offset = 0;} break; - case 214: /* limit_opt ::= LIMIT signed OFFSET signed */ + case 213: /* limit_opt ::= LIMIT signed OFFSET signed */ { yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} break; - case 215: /* limit_opt ::= LIMIT signed COMMA signed */ + case 214: /* limit_opt ::= LIMIT signed COMMA signed */ { yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} break; - case 218: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ + case 217: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ {yymsp[-3].minor.yy414.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[0].minor.yy369;} break; - case 219: /* slimit_opt ::= SLIMIT signed COMMA signed */ + case 218: /* slimit_opt ::= SLIMIT signed COMMA signed */ {yymsp[-3].minor.yy414.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy414.offset = yymsp[-2].minor.yy369;} break; - case 222: /* expr ::= LP expr RP */ + case 221: /* expr ::= LP expr RP */ {yylhsminor.yy166 = yymsp[-1].minor.yy166; yylhsminor.yy166->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy166->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 223: /* expr ::= ID */ + case 222: /* expr ::= ID */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 224: /* expr ::= ID DOT ID */ + case 223: /* expr ::= ID DOT ID */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 225: /* expr ::= ID DOT STAR */ + case 224: /* expr ::= ID DOT STAR */ { yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 226: /* expr ::= INTEGER */ + case 225: /* expr ::= INTEGER */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 227: /* expr ::= MINUS INTEGER */ - case 228: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==228); + case 226: /* expr ::= MINUS INTEGER */ + case 227: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==227); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 229: /* expr ::= FLOAT */ + case 228: /* expr ::= FLOAT */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 230: /* expr ::= MINUS FLOAT */ - case 231: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==231); + case 229: /* expr ::= MINUS FLOAT */ + case 230: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==230); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 232: /* expr ::= STRING */ + case 231: /* expr ::= STRING */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 233: /* expr ::= NOW */ + case 232: /* expr ::= NOW */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 234: /* expr ::= VARIABLE */ + case 233: /* expr ::= VARIABLE */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 235: /* expr ::= PLUS VARIABLE */ - case 236: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==236); + case 234: /* expr ::= PLUS VARIABLE */ + case 235: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==235); { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_VARIABLE);} yymsp[-1].minor.yy166 = yylhsminor.yy166; break; - case 237: /* expr ::= BOOL */ + case 236: /* expr ::= BOOL */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 238: /* expr ::= NULL */ + case 237: /* expr ::= NULL */ { yylhsminor.yy166 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NULL);} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 239: /* expr ::= ID LP exprlist RP */ + case 238: /* expr ::= ID LP exprlist RP */ { yylhsminor.yy166 = tSqlExprCreateFunction(yymsp[-1].minor.yy441, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 240: /* expr ::= ID LP STAR RP */ + case 239: /* expr ::= ID LP STAR RP */ { yylhsminor.yy166 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 241: /* expr ::= expr IS NULL */ + case 240: /* expr ::= expr IS NULL */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, NULL, TK_ISNULL);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 242: /* expr ::= expr IS NOT NULL */ + case 241: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-3].minor.yy166, NULL, TK_NOTNULL);} yymsp[-3].minor.yy166 = yylhsminor.yy166; break; - case 243: /* expr ::= expr LT expr */ + case 242: /* expr ::= expr LT expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LT);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 244: /* expr ::= expr GT expr */ + case 243: /* expr ::= expr GT expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GT);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 245: /* expr ::= expr LE expr */ + case 244: /* expr ::= expr LE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 246: /* expr ::= expr GE expr */ + case 245: /* expr ::= expr GE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_GE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 247: /* expr ::= expr NE expr */ + case 246: /* expr ::= expr NE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_NE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 248: /* expr ::= expr EQ expr */ + case 247: /* expr ::= expr EQ expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_EQ);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 249: /* expr ::= expr BETWEEN expr AND expr */ + case 248: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy166); yylhsminor.yy166 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy166, yymsp[-2].minor.yy166, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy166, TK_LE), TK_AND);} yymsp[-4].minor.yy166 = yylhsminor.yy166; break; - case 250: /* expr ::= expr AND expr */ + case 249: /* expr ::= expr AND expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_AND);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 251: /* expr ::= expr OR expr */ + case 250: /* expr ::= expr OR expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_OR); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 252: /* expr ::= expr PLUS expr */ + case 251: /* expr ::= expr PLUS expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_PLUS); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 253: /* expr ::= expr MINUS expr */ + case 252: /* expr ::= expr MINUS expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_MINUS); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 254: /* expr ::= expr STAR expr */ + case 253: /* expr ::= expr STAR expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_STAR); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 255: /* expr ::= expr SLASH expr */ + case 254: /* expr ::= expr SLASH expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_DIVIDE);} yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 256: /* expr ::= expr REM expr */ + case 255: /* expr ::= expr REM expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_REM); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 257: /* expr ::= expr LIKE expr */ + case 256: /* expr ::= expr LIKE expr */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-2].minor.yy166, yymsp[0].minor.yy166, TK_LIKE); } yymsp[-2].minor.yy166 = yylhsminor.yy166; break; - case 258: /* expr ::= expr IN LP exprlist RP */ + case 257: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy166 = tSqlExprCreate(yymsp[-4].minor.yy166, (tSqlExpr*)yymsp[-1].minor.yy441, TK_IN); } yymsp[-4].minor.yy166 = yylhsminor.yy166; break; - case 259: /* exprlist ::= exprlist COMMA expritem */ + case 258: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy441 = tSqlExprListAppend(yymsp[-2].minor.yy441,yymsp[0].minor.yy166,0, 0);} yymsp[-2].minor.yy441 = yylhsminor.yy441; break; - case 260: /* exprlist ::= expritem */ + case 259: /* exprlist ::= expritem */ {yylhsminor.yy441 = tSqlExprListAppend(0,yymsp[0].minor.yy166,0, 0);} yymsp[0].minor.yy441 = yylhsminor.yy441; break; - case 261: /* expritem ::= expr */ + case 260: /* expritem ::= expr */ {yylhsminor.yy166 = yymsp[0].minor.yy166;} yymsp[0].minor.yy166 = yylhsminor.yy166; break; - case 263: /* cmd ::= RESET QUERY CACHE */ + case 262: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 264: /* cmd ::= SYNCDB ids REPLICA */ + case 263: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 265: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 264: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 266: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 265: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3092,21 +3089,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 267: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 266: /* 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.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 268: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 267: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 269: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 268: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3117,7 +3114,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 270: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 269: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3131,7 +3128,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 271: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 270: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3143,21 +3140,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 272: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 271: /* 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.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 273: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 272: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 274: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 273: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3168,21 +3165,21 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 275: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 274: /* 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.yy441, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 276: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 275: /* 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.yy441, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 277: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 276: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3193,7 +3190,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 278: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 277: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3207,7 +3204,7 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 279: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 278: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3219,20 +3216,20 @@ static void yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 280: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 279: /* 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.yy441, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 281: /* cmd ::= KILL CONNECTION INTEGER */ + case 280: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 282: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 281: /* 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 283: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 282: /* 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 54bdd895f7af09f793fbd6252a9ddd0a66bc292d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 13 Jul 2021 10:38:55 +0800 Subject: [PATCH 41/65] Feature/sangshuduo/td 5136 taosdemo rework (#6837) * [TD-5136]: taosdemo simulate real senario. * update test case according to taosdemo change * adjust range of semi-random data. --- src/kit/taosdemo/taosdemo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index c92b8e41a6..fa3d263678 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1331,21 +1331,21 @@ static float demo_current_float(){ static int cursor; cursor++; cursor = cursor % MAX_PREPARED_RAND; - return (float)(5 + randfloat[cursor] / 1000000000); + return (float)(9.8 + 0.04 * (randint[cursor] % 10) + randfloat[cursor]/1000000000); } static int32_t demo_voltage_int(){ static int cursor; cursor++; cursor = cursor % MAX_PREPARED_RAND; - return 210 + randint[cursor] % 20; + return 215 + randint[cursor] % 10; } static float demo_phase_float(){ static int cursor; cursor++; cursor = cursor % MAX_PREPARED_RAND; - return (float)(120 + randfloat[cursor] / 1000000000); + return (float)((115 + randint[cursor] % 10 + randfloat[cursor]/1000000000)/360); } #if 0 From 89200feb44c3dae152067bd8c9a873450e9445a4 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Mon, 12 Jul 2021 17:48:38 +0800 Subject: [PATCH 42/65] [TD-5187]update case for wal,fsync --- tests/script/general/db/alter_option.sim | 28 ++++++++--------- tests/script/general/db/topic1.sim | 17 ++++------- tests/script/general/parser/create_db.sim | 37 ++++++++++++++++++++++- 3 files changed, 54 insertions(+), 28 deletions(-) diff --git a/tests/script/general/db/alter_option.sim b/tests/script/general/db/alter_option.sim index c20a96fd1b..36f4c0e7dc 100644 --- a/tests/script/general/db/alter_option.sim +++ b/tests/script/general/db/alter_option.sim @@ -198,29 +198,25 @@ if $data12_db != 1 then return -1 endi -sql alter database db wal 1 -sql show databases -print wal $data12_db -if $data12_db != 1 then - return -1 -endi +sql_error alter database db wal 1 -sql alter database db wal 1 -sql alter database db wal 2 -sql alter database db wal 1 -sql alter database db wal 2 -sql alter database db wal 0 + +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 0 sql_error alter database db wal 3 sql_error alter database db wal 4 sql_error alter database db wal -1 sql_error alter database db wal 1000 print ============== step fsync -sql alter database db fsync 0 -sql alter database db fsync 1 -sql alter database db fsync 3600 -sql alter database db fsync 18000 -sql alter database db fsync 180000 +sql_error alter database db fsync 0 +sql_error alter database db fsync 1 +sql_error alter database db fsync 3600 +sql_error alter database db fsync 18000 +sql_error alter database db fsync 180000 sql_error alter database db fsync 180001 sql_error alter database db fsync -1 diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 4939e5a0e2..7bef15a802 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -495,18 +495,13 @@ if $data12_db != 1 then endi sql_error alter topic db wal 1 -sql alter database db wal 1 -sql show databases -print wal $data12_db -if $data12_db != 1 then - return -1 -endi +sql_error alter database db wal 1 -sql alter database db wal 1 -sql alter database db wal 2 -sql alter database db wal 1 -sql alter database db wal 2 -sql alter database db wal 0 +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 1 +sql_error alter database db wal 2 +sql_error alter database db wal 0 sql_error alter database db wal 3 sql_error alter database db wal 4 sql_error alter database db wal -1 diff --git a/tests/script/general/parser/create_db.sim b/tests/script/general/parser/create_db.sim index 7881060ad1..a62a45e023 100644 --- a/tests/script/general/parser/create_db.sim +++ b/tests/script/general/parser/create_db.sim @@ -237,7 +237,42 @@ sql_error create database $db ctime 29 sql_error create database $db ctime 40961 # wal {0, 2} -#sql_error create database $db wal 0 +sql create database testwal wal 0 +sql show databases +if $rows != 1 then + return -1 +endi + +sql show databases +print wallevel $data12_testwal +if $data12_testwal != 0 then + return -1 +endi +sql drop database testwal + +sql create database testwal wal 1 +sql show databases +if $rows != 1 then + return -1 +endi +sql show databases +print wallevel $data12_testwal +if $data12_testwal != 1 then + return -1 +endi +sql drop database testwal + +sql create database testwal wal 2 +sql show databases +if $rows != 1 then + return -1 +endi +print wallevel $data12_testwal +if $data12_testwal != 2 then + return -1 +endi +sql drop database testwal + sql_error create database $db wal -1 sql_error create database $db wal 3 From 136189e3c892075a628d753395ea9b5724739764 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 13 Jul 2021 10:52:58 +0800 Subject: [PATCH 43/65] memory handling --- src/client/src/tscParseLineProtocol.c | 440 +++++++++++--------- tests/examples/c/apitest.c | 17 +- tests/script/general/parser/line_insert.sim | 32 ++ 3 files changed, 286 insertions(+), 203 deletions(-) create mode 100644 tests/script/general/parser/line_insert.sim diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 77d65f3d15..85a6c41ccf 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -64,88 +64,6 @@ int compareSmlColKv(const void* p1, const void* p2) { } } -int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { - schema->tags = taosArrayInit(8, sizeof(SSchema)); - schema->fields = taosArrayInit(64, sizeof(SSchema)); - schema->tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - schema->fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - int32_t code = 0; - - STscObj *pObj = (STscObj *)taos; - if (pObj == NULL || pObj->signature != pObj) { - terrno = TSDB_CODE_TSC_DISCONNECTED; - return TSDB_CODE_TSC_DISCONNECTED; - } - - char sql[256]; - snprintf(sql, 256, "describe %s", tableName); - TAOS_RES* res = taos_query(taos, sql); - code = taos_errno(res); - if (code != 0) { - taos_free_result(res); - return code; - } - taos_free_result(res); - - SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); - pSql->pTscObj = taos; - pSql->signature = pSql; - pSql->fp = NULL; - - SStrToken tableToken = {.z=tableName, .n=strlen(tableName), .type=TK_ID}; - tGetToken(tableName, &tableToken.type); - // Check if the table name available or not - if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { - code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; - sprintf(pSql->cmd.payload, "table name is invalid"); - return code; - } - - SName sname = {0}; - if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { - return code; - } - - char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; - memset(fullTableName, 0, tListLen(fullTableName)); - tNameExtractFullName(&sname, fullTableName); - - if (code != TSDB_CODE_SUCCESS) { - tscFreeSqlObj(pSql); - return code; - } - - tscFreeSqlObj(pSql); - - uint32_t size = tscGetTableMetaMaxSize(); - STableMeta* tableMeta = calloc(1, size); - taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); - - tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); - schema->precision = tableMeta->tableInfo.precision; - for (int i=0; itableInfo.numOfColumns; ++i) { - SSchema field; - tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); - field.type = tableMeta->schema[i].type; - field.bytes = tableMeta->schema[i].bytes; - SSchema* pField = taosArrayPush(schema->fields, &field); - taosHashPut(schema->fieldHash, field.name, strlen(field.name), &pField, POINTER_BYTES); - } - - for (int i=0; itableInfo.numOfTags; ++i) { - int j = i + tableMeta->tableInfo.numOfColumns; - SSchema field; - tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)+1); - field.type = tableMeta->schema[j].type; - field.bytes = tableMeta->schema[j].bytes; - SSchema* pField = taosArrayPush(schema->tags, &field); - taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); - } - free(tableMeta); tableMeta = NULL; - return code; -} - typedef enum { SCHEMA_ACTION_CREATE_STABLE, SCHEMA_ACTION_ADD_COLUMN, @@ -173,7 +91,7 @@ typedef struct { }; } SSchemaAction; -int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { +static int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { if (!IS_VAR_DATA_TYPE(kv->type)) { *bytes = tDataTypes[kv->type].bytes; } else { @@ -191,7 +109,7 @@ int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { return 0; } -int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) { +static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) { SSchema* pField = NULL; SSchema** ppField = taosHashGet(hash, smlKv->key, strlen(smlKv->key)); if (ppField) { @@ -227,7 +145,55 @@ int32_t addTaosFieldToHashAndArray(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* a return 0; } -int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], +static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, SArray* stableSchemas) { + SHashObj* sname2shema = taosHashInit(32, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + for (int i = 0; i < numPoint; ++i) { + TAOS_SML_DATA_POINT* point = &points[i]; + size_t stableNameLen = strlen(point->stableName); + SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, stableNameLen); + SSmlSTableSchema* pStableSchema = NULL; + if (ppStableSchema) { + pStableSchema= *ppStableSchema; + } else { + SSmlSTableSchema schema; + strncpy(schema.sTableName, point->stableName, stableNameLen); + schema.sTableName[stableNameLen] = '\0'; + schema.fields = taosArrayInit(64, sizeof(SSchema)); + schema.tags = taosArrayInit(8, sizeof(SSchema)); + schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + pStableSchema = taosArrayPush(stableSchemas, &schema); + taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); + } + + for (int j = 0; j < point->tagNum; ++j) { + TAOS_SML_KV* tagKv = point->tags + j; + buildSmlKvSchema(tagKv, pStableSchema->tagHash, pStableSchema->tags); + } + + for (int j = 0; j < point->fieldNum; ++j) { + TAOS_SML_KV* fieldKv = point->fields + j; + buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + } + + point->schema = pStableSchema; + } + + size_t numStables = taosArrayGetSize(stableSchemas); + for (int32_t i = 0; i < numStables; ++i) { + SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); + taosHashCleanup(schema->tagHash); + taosHashCleanup(schema->fieldHash); + } + taosHashCleanup(sname2shema); + + return 0; +} + +static int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool isTag, char sTableName[], SSchemaAction* action, bool* actionNeeded) { SSchema** ppDbAttr = taosHashGet(dbAttrHash, pointColField->name, strlen(pointColField->name)); if (ppDbAttr) { @@ -262,7 +228,7 @@ int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash, bool return 0; } -int32_t buildColumnDescription(SSchema* field, +static int32_t buildColumnDescription(SSchema* field, char* buf, int32_t bufSize, int32_t* outBytes) { uint8_t type = field->type; @@ -283,7 +249,8 @@ int32_t buildColumnDescription(SSchema* field, return 0; } -int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { + +static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { int32_t code = 0; int32_t capacity = TSDB_MAX_BINARY_LEN; int32_t outBytes = 0; @@ -357,7 +324,160 @@ int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } -int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { +static int32_t destorySmlSTableSchema(SSmlSTableSchema* schema) { + taosHashCleanup(schema->tagHash); + taosHashCleanup(schema->fieldHash); + taosArrayDestroy(schema->tags); + taosArrayDestroy(schema->fields); + return 0; +} + +int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { + int32_t code = 0; + + STscObj *pObj = (STscObj *)taos; + if (pObj == NULL || pObj->signature != pObj) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return TSDB_CODE_TSC_DISCONNECTED; + } + + char sql[256]; + snprintf(sql, 256, "describe %s", tableName); + TAOS_RES* res = taos_query(taos, sql); + code = taos_errno(res); + if (code != 0) { + taos_free_result(res); + return code; + } + taos_free_result(res); + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + pSql->pTscObj = taos; + pSql->signature = pSql; + pSql->fp = NULL; + + SStrToken tableToken = {.z=tableName, .n=strlen(tableName), .type=TK_ID}; + tGetToken(tableName, &tableToken.type); + // Check if the table name available or not + if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { + code = TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH; + sprintf(pSql->cmd.payload, "table name is invalid"); + return code; + } + + SName sname = {0}; + if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { + return code; + } + + char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; + memset(fullTableName, 0, tListLen(fullTableName)); + tNameExtractFullName(&sname, fullTableName); + + if (code != TSDB_CODE_SUCCESS) { + tscFreeSqlObj(pSql); + return code; + } + + tscFreeSqlObj(pSql); + + schema->tags = taosArrayInit(8, sizeof(SSchema)); + schema->fields = taosArrayInit(64, sizeof(SSchema)); + schema->tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + schema->fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); + + uint32_t size = tscGetTableMetaMaxSize(); + STableMeta* tableMeta = calloc(1, size); + taosHashGetClone(tscTableMetaInfo, fullTableName, strlen(fullTableName), NULL, tableMeta, -1); + + tstrncpy(schema->sTableName, tableName, strlen(tableName)+1); + schema->precision = tableMeta->tableInfo.precision; + for (int i=0; itableInfo.numOfColumns; ++i) { + SSchema field; + tstrncpy(field.name, tableMeta->schema[i].name, strlen(tableMeta->schema[i].name)+1); + field.type = tableMeta->schema[i].type; + field.bytes = tableMeta->schema[i].bytes; + SSchema* pField = taosArrayPush(schema->fields, &field); + taosHashPut(schema->fieldHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + + for (int i=0; itableInfo.numOfTags; ++i) { + int j = i + tableMeta->tableInfo.numOfColumns; + SSchema field; + tstrncpy(field.name, tableMeta->schema[j].name, strlen(tableMeta->schema[j].name)+1); + field.type = tableMeta->schema[j].type; + field.bytes = tableMeta->schema[j].bytes; + SSchema* pField = taosArrayPush(schema->tags, &field); + taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); + } + free(tableMeta); tableMeta = NULL; + return code; +} + +static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { + int32_t code = 0; + size_t numStable = taosArrayGetSize(stableSchemas); + for (int i = 0; i < numStable; ++i) { + SSmlSTableSchema* pointSchema = taosArrayGet(stableSchemas, i); + SSmlSTableSchema dbSchema = {0}; + + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + + if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { + SSchemaAction schemaAction = {0}; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); + memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); + schemaAction.createSTable.tags = pointSchema->tags; + schemaAction.createSTable.fields = pointSchema->fields; + applySchemaAction(taos, &schemaAction); + code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); + + pointSchema->precision = dbSchema.precision; + + destorySmlSTableSchema(&dbSchema); + } else if (code == TSDB_CODE_SUCCESS) { + size_t pointTagSize = taosArrayGetSize(pointSchema->tags); + size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); + + SHashObj* dbTagHash = dbSchema.tagHash; + SHashObj* dbFieldHash = dbSchema.fieldHash; + + for (int j = 0; j < pointTagSize; ++j) { + SSchema* pointTag = taosArrayGet(pointSchema->tags, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + applySchemaAction(taos, &schemaAction); + } + } + + SSchema* pointColTs = taosArrayGet(pointSchema->fields, 0); + SSchema* dbColTs = taosArrayGet(dbSchema.fields, 0); + memcpy(pointColTs->name, dbColTs->name, TSDB_COL_NAME_LEN); + + for (int j = 1; j < pointFieldSize; ++j) { + SSchema* pointCol = taosArrayGet(pointSchema->fields, j); + SSchemaAction schemaAction = {0}; + bool actionNeeded = false; + generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); + if (actionNeeded) { + applySchemaAction(taos, &schemaAction); + } + } + + pointSchema->precision = dbSchema.precision; + + destorySmlSTableSchema(&dbSchema); + } else { + return code; + } + } + return 0; +} + +static int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tableNameLen) { qsort(point->tags, point->tagNum, sizeof(TAOS_SML_KV), compareSmlColKv); SStringBuilder sb; memset(&sb, 0, sizeof(sb)); @@ -384,7 +504,7 @@ int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, int* tabl return 0; } -int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind) { +static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const char* sTableName, SArray* tagsSchema, SArray* tagsBind) { size_t numTags = taosArrayGetSize(tagsSchema); char sql[TSDB_MAX_BINARY_LEN] = {0}; int freeBytes = TSDB_MAX_BINARY_LEN; @@ -428,10 +548,10 @@ int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, const cha return 0; } -int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) { +static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* rowsBind) { size_t numCols = taosArrayGetSize(colsSchema); - char sql[4096]; - int32_t freeBytes = 4096; + char sql[TSDB_MAX_BINARY_LEN]; + int32_t freeBytes = TSDB_MAX_BINARY_LEN; sprintf(sql, "insert into ? ("); for (int i = 0; i < numCols; ++i) { @@ -458,6 +578,7 @@ int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* r printf("%s", taos_stmt_errstr(stmt)); return code; } + size_t rows = taosArrayGetSize(rowsBind); for (int32_t i = 0; i < rows; ++i) { TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); @@ -479,13 +600,11 @@ int32_t insertBatch(TAOS* taos, char* cTableName, SArray* colsSchema, SArray* r return code; } - taos_stmt_close(stmt); return code; } -int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) { - SHashObj* cname2points = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); +static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int numPoints, SHashObj* cname2points) { for (int32_t i = 0; i < numPoints; ++i) { TAOS_SML_DATA_POINT * point = points + i; if (!point->childTableName) { @@ -526,6 +645,14 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) taosArrayPush(cTablePoints, &point); } + return 0; +} + +static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) { + SHashObj* cname2points = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), + true, false); + arrangePointsByChildTableName(points, numPoints, cname2points); + int isNullColBind = TSDB_TRUE; SArray** pCTablePoints = taosHashIterate(cname2points, NULL); while (pCTablePoints) { @@ -577,111 +704,44 @@ int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t numPoints) } creatChildTableIfNotExists(taos, point->childTableName, point->stableName, point->schema->tags, tagBinds); - insertBatch(taos, point->childTableName, point->schema->fields, rowsBind); + for (int i = 0; i < taosArrayGetSize(tagBinds); ++i) { + TAOS_BIND* bind = taosArrayGet(tagBinds, i); + free(bind->length); + } + taosArrayDestroy(tagBinds); + + insertChildTableBatch(taos, point->childTableName, point->schema->fields, rowsBind); + for (int i = 0; i < rows; ++i) { + TAOS_BIND* colBinds = taosArrayGetP(rowsBind, i); + for (int j = 0; j < numCols; ++j) { + TAOS_BIND* bind = colBinds + j; + free(bind->length); + } + } + taosArrayDestroy(rowsBind); + taosArrayDestroy(cTablePoints); pCTablePoints = taosHashIterate(cname2points, pCTablePoints); } + + taosHashCleanup(cname2points); return 0; } int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { int32_t code = TSDB_CODE_SUCCESS; - SArray* stableArray = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray - SHashObj* sname2shema = taosHashInit(32, - taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - for (int i = 0; i < numPoint; ++i) { - TAOS_SML_DATA_POINT* point = &points[i]; - size_t stableNameLen = strlen(point->stableName); - SSmlSTableSchema** ppStableSchema = taosHashGet(sname2shema, point->stableName, stableNameLen); - SSmlSTableSchema* pStableSchema = NULL; - if (ppStableSchema) { - pStableSchema= *ppStableSchema; - } else { - SSmlSTableSchema schema; - strncpy(schema.sTableName, point->stableName, stableNameLen); - schema.sTableName[stableNameLen] = '\0'; - schema.fields = taosArrayInit(64, sizeof(SSchema)); - schema.tags = taosArrayInit(8, sizeof(SSchema)); - schema.tagHash = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - schema.fieldHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); - - pStableSchema = taosArrayPush(stableArray, &schema); - taosHashPut(sname2shema, schema.sTableName, stableNameLen, &pStableSchema, POINTER_BYTES); - } - - for (int j = 0; j < point->tagNum; ++j) { - TAOS_SML_KV* tagKv = point->tags + j; - addTaosFieldToHashAndArray(tagKv, pStableSchema->tagHash, pStableSchema->tags); - } - - for (int j = 0; j < point->fieldNum; ++j) { - TAOS_SML_KV* fieldKv = point->fields + j; - addTaosFieldToHashAndArray(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); - } - - point->schema = pStableSchema; - } - - size_t numStable = taosArrayGetSize(stableArray); - for (int i = 0; i < numStable; ++i) { - SSmlSTableSchema* pointSchema = taosArrayGet(stableArray, i); - SSmlSTableSchema dbSchema = {0}; - - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - - if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { - SSchemaAction schemaAction = {0}; - schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; - memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); - memcpy(schemaAction.createSTable.sTableName, pointSchema->sTableName, TSDB_TABLE_NAME_LEN); - schemaAction.createSTable.tags = pointSchema->tags; - schemaAction.createSTable.fields = pointSchema->fields; - applySchemaAction(taos, &schemaAction); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - pointSchema->precision = dbSchema.precision; - } else if (code == TSDB_CODE_SUCCESS) { - size_t pointTagSize = taosArrayGetSize(pointSchema->tags); - size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); - - SHashObj* dbTagHash = dbSchema.tagHash; - SHashObj* dbFieldHash = dbSchema.fieldHash; - - for (int j = 0; j < pointTagSize; ++j) { - SSchema* pointTag = taosArrayGet(pointSchema->tags, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointTag, dbTagHash, true, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - applySchemaAction(taos, &schemaAction); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - pointSchema->precision = dbSchema.precision; - } - } - - SSchema* pointColTs = taosArrayGet(pointSchema->fields, 0); - SSchema* dbColTs = taosArrayGet(dbSchema.fields, 0); - memcpy(pointColTs->name, dbColTs->name, TSDB_COL_NAME_LEN); - - for (int j = 1; j < pointFieldSize; ++j) { - SSchema* pointCol = taosArrayGet(pointSchema->fields, j); - SSchemaAction schemaAction = {0}; - bool actionNeeded = false; - generateSchemaAction(pointCol, dbFieldHash, false, pointSchema->sTableName, &schemaAction, &actionNeeded); - if (actionNeeded) { - applySchemaAction(taos, &schemaAction); - code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - pointSchema->precision = dbSchema.precision; - } - } - - pointSchema->precision = dbSchema.precision; - } else { - return code; - } - } + SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray + buildDataPointSchemas(points, numPoint, stableSchemas); + reconcileDBSchemas(taos, stableSchemas); insertPoints(taos, points, numPoint); + + for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) { + SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); + taosArrayDestroy(schema->fields); + taosArrayDestroy(schema->tags); + } + taosArrayDestroy(stableSchemas); return code; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 75262d74d8..de7fcecc7e 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -6,6 +6,7 @@ #include #include #include +#include static void prepare_data(TAOS* taos) { TAOS_RES *result; @@ -965,23 +966,13 @@ int32_t verify_schema_less(TAOS* taos) { char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", - "st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833640000000", + "st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5 1626006833640000000", "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", "ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532", "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; -// int code = taos_insert_by_lines(taos, lines , 5); - int code = taos_insert_by_lines(taos, &(lines[0]), 1); - - code = taos_insert_by_lines(taos, &(lines[1]), 1); - -// code = taos_insert_by_lines(taos, &(lines[2]), 1); -// -// code = taos_insert_by_lines(taos, &(lines[3]), 1); -// -// code = taos_insert_by_lines(taos, &(lines[4]), 1); - + int code = taos_insert_by_lines(taos, lines , 5); return code; } @@ -992,7 +983,7 @@ int main(int argc, char *argv[]) { const char* passwd = "taosdata"; taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); - taos_options(TSDB_OPTION_CONFIGDIR, "/etc/taos"); + taosDumpGlobalCfg(); TAOS* taos = taos_connect(host, user, passwd, "", 0); if (taos == NULL) { printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); diff --git a/tests/script/general/parser/line_insert.sim b/tests/script/general/parser/line_insert.sim new file mode 100644 index 0000000000..cb6d228e4d --- /dev/null +++ b/tests/script/general/parser/line_insert.sim @@ -0,0 +1,32 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +print =============== step1 +$db = testlp +$mte = ste +$mt = st +sql drop database $db -x step1 +step1: +sql create database $db precision 'us' +sql use $db +sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint) + +line_insert st,t1=3i,t2=4,t3="t3" c1=3i,c3=L"passit",c2=false,c4=4 1626006833639000000 +line_insert st,t1=4i,t3="t4",t2=5 c1=3i,c3=L"passitagain",c2=true,c4=5,c5=5 1626006833640000000 +line_insert st,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000 +line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532 +line_insert ste,t2=5,t3=L"ste2" c3="iamszhou",c4=false 1626056811843316532 + +#print =============== clear +#sql drop database $db +#sql show databases +#if $rows != 0 then +# return -1 +#endi +# +#system sh/exec.sh -n dnode1 -s stop -x SIGINT From f9bfe6cc3d2bd91539941c799bdc8eb9066385fa Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 13 Jul 2021 10:55:26 +0800 Subject: [PATCH 44/65] for reconfigure table reproduction --- tests/examples/c/apitest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index de7fcecc7e..b8f68636bd 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -972,7 +972,9 @@ int32_t verify_schema_less(TAOS* taos) { "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - int code = taos_insert_by_lines(taos, lines , 5); + //int code = taos_insert_by_lines(taos, lines , 5); + int code = taos_insert_by_lines(taos, &lines[0], 1); + code = taos_insert_by_lines(taos, &lines[1], 1); return code; } From c24033dc259220527dc611de90666a5c0d5b91fd Mon Sep 17 00:00:00 2001 From: wpan Date: Tue, 13 Jul 2021 11:32:39 +0800 Subject: [PATCH 45/65] add timezone comments for windows --- packaging/cfg/taos.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 9ad06cd1bd..bbe6eae419 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -149,6 +149,8 @@ keepColumnName 1 # system time zone # timezone Asia/Shanghai (CST, +0800) +# system time zone (for windows 10) +# timezone UTC-8 # system locale # locale en_US.UTF-8 From 95fba837f905e433ca1a1b48f22df09c5a0b7895 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 13 Jul 2021 11:41:16 +0800 Subject: [PATCH 46/65] update case topic1.sim --- tests/script/general/db/topic1.sim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 7bef15a802..4238c49c0d 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -518,11 +518,11 @@ sql_error alter topic db wal -1 sql_error alter topic db wal 1000 print ============== step fsync -sql alter database db fsync 0 -sql alter database db fsync 1 -sql alter database db fsync 3600 -sql alter database db fsync 18000 -sql alter database db fsync 180000 +sql_error alter database db fsync 0 +sql_error alter database db fsync 1 +sql_error alter database db fsync 3600 +sql_error alter database db fsync 18000 +sql_error alter database db fsync 180000 sql_error alter database db fsync 180001 sql_error alter database db fsync -1 From ddb783f40720708b0e94e40caac30fdabaa41c64 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 13 Jul 2021 13:06:46 +0800 Subject: [PATCH 47/65] add simple tsim test --- tests/examples/c/apitest.c | 6 +-- tests/script/general/parser/line_insert.sim | 42 ++++++++++++++++----- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index b8f68636bd..f4e222c4dc 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -972,9 +972,9 @@ int32_t verify_schema_less(TAOS* taos) { "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - //int code = taos_insert_by_lines(taos, lines , 5); - int code = taos_insert_by_lines(taos, &lines[0], 1); - code = taos_insert_by_lines(taos, &lines[1], 1); + int code = taos_insert_by_lines(taos, lines , 5); + //int code = taos_insert_by_lines(taos, &lines[0], 1); + //code = taos_insert_by_lines(taos, &lines[1], 1); return code; } diff --git a/tests/script/general/parser/line_insert.sim b/tests/script/general/parser/line_insert.sim index cb6d228e4d..f3067a3bbe 100644 --- a/tests/script/general/parser/line_insert.sim +++ b/tests/script/general/parser/line_insert.sim @@ -17,16 +17,38 @@ sql use $db sql create stable $mte (ts timestamp, f int) TAGS(t1 bigint) line_insert st,t1=3i,t2=4,t3="t3" c1=3i,c3=L"passit",c2=false,c4=4 1626006833639000000 -line_insert st,t1=4i,t3="t4",t2=5 c1=3i,c3=L"passitagain",c2=true,c4=5,c5=5 1626006833640000000 -line_insert st,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000 +line_insert st,t1=4i,t3="t41",t2=5 c1=3i,c3=L"passiT",c2=true,c4=5 1626006833640000000 +line_insert stf,t1=4i,t2=5,t3="t4" c1=3i,c3=L"passitagain",c2=true,c4=5 1626006833642000000 line_insert ste,t2=5,t3=L"ste" c1=true,c2=4,c3="iam" 1626056811823316532 -line_insert ste,t2=5,t3=L"ste2" c3="iamszhou",c4=false 1626056811843316532 + +sql select * from st +if $rows != 2 then + return -1 +endi + +if $data00 != @21-07-11 20:33:53.639000@ then + return -1 +endi + +if $data03 != @passit@ then + return -1 +endi + +sql select * from stf +if $rows != 1 then + return -1 +endi + +sql select * from ste +if $rows != 1 then + return -1 +endi #print =============== clear -#sql drop database $db -#sql show databases -#if $rows != 0 then -# return -1 -#endi -# -#system sh/exec.sh -n dnode1 -s stop -x SIGINT +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT From 99016d14d4561946e2166106d5f181c3cd133f01 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 13 Jul 2021 13:20:38 +0800 Subject: [PATCH 48/65] fix error --- tests/script/general/db/topic1.sim | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/script/general/db/topic1.sim b/tests/script/general/db/topic1.sim index 4238c49c0d..1639973120 100644 --- a/tests/script/general/db/topic1.sim +++ b/tests/script/general/db/topic1.sim @@ -610,17 +610,6 @@ if $rows != 1 then return -1 endi -sql alter database d1 fsync 0 -sql show topics; -if $rows != 0 then - return -1 -endi - -sql show databases; -if $rows != 1 then - return -1 -endi - sql drop database d1 sql show topics; if $rows != 0 then @@ -644,17 +633,6 @@ if $rows != 1 then return -1 endi -sql alter database d1 fsync 0 -sql show topics; -if $rows != 1 then - return -1 -endi - -sql show databases; -if $rows != 1 then - return -1 -endi - sql drop database d1 sql show topics; if $rows != 0 then From bcba45e38bcd2769057f3b631ee390a9289a8599 Mon Sep 17 00:00:00 2001 From: Shenglian Zhou Date: Tue, 13 Jul 2021 14:19:56 +0800 Subject: [PATCH 49/65] retry afer batch execute reconfigure table --- src/client/src/tscParseLineProtocol.c | 61 +++++++++++++++------------ tests/examples/c/apitest.c | 8 ++-- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 85a6c41ccf..04b96dc52a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -324,7 +324,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { return code; } -static int32_t destorySmlSTableSchema(SSmlSTableSchema* schema) { +static int32_t destroySmlSTableSchema(SSmlSTableSchema* schema) { taosHashCleanup(schema->tagHash); taosHashCleanup(schema->fieldHash); taosArrayDestroy(schema->tags); @@ -435,7 +435,7 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { pointSchema->precision = dbSchema.precision; - destorySmlSTableSchema(&dbSchema); + destroySmlSTableSchema(&dbSchema); } else if (code == TSDB_CODE_SUCCESS) { size_t pointTagSize = taosArrayGetSize(pointSchema->tags); size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); @@ -469,7 +469,7 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { pointSchema->precision = dbSchema.precision; - destorySmlSTableSchema(&dbSchema); + destroySmlSTableSchema(&dbSchema); } else { return code; } @@ -565,42 +565,47 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols } snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")"); - TAOS_STMT* stmt = taos_stmt_init(taos); - int32_t code; - code = taos_stmt_prepare(stmt, sql, strlen(sql)); - if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); - return code; - } + int32_t code = 0; + int32_t try = 0; + do { + TAOS_STMT* stmt = taos_stmt_init(taos); - code = taos_stmt_set_tbname(stmt, cTableName); - if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); - return code; - } - - size_t rows = taosArrayGetSize(rowsBind); - for (int32_t i = 0; i < rows; ++i) { - TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); - code = taos_stmt_bind_param(stmt, colsBinds); + code = taos_stmt_prepare(stmt, sql, strlen(sql)); if (code != 0) { printf("%s", taos_stmt_errstr(stmt)); return code; } - code = taos_stmt_add_batch(stmt); + + code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { printf("%s", taos_stmt_errstr(stmt)); return code; } - } - code = taos_stmt_execute(stmt); - if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); - return code; - } + size_t rows = taosArrayGetSize(rowsBind); + for (int32_t i = 0; i < rows; ++i) { + TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); + code = taos_stmt_bind_param(stmt, colsBinds); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + code = taos_stmt_add_batch(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + } + + code = taos_stmt_execute(stmt); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + taos_stmt_close(stmt); + } else { + taos_stmt_close(stmt); + } + } while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA); - taos_stmt_close(stmt); return code; } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index f4e222c4dc..e7d4b087f7 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -6,7 +6,6 @@ #include #include #include -#include static void prepare_data(TAOS* taos) { TAOS_RES *result; @@ -972,9 +971,9 @@ int32_t verify_schema_less(TAOS* taos) { "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532" }; - int code = taos_insert_by_lines(taos, lines , 5); - //int code = taos_insert_by_lines(taos, &lines[0], 1); - //code = taos_insert_by_lines(taos, &lines[1], 1); + // int code = taos_insert_by_lines(taos, lines , 5); + int code = taos_insert_by_lines(taos, &lines[0], 1); + code = taos_insert_by_lines(taos, &lines[1], 1); return code; } @@ -985,7 +984,6 @@ int main(int argc, char *argv[]) { const char* passwd = "taosdata"; taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); - taosDumpGlobalCfg(); TAOS* taos = taos_connect(host, user, passwd, "", 0); if (taos == NULL) { printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); From abf659bd14a86a3545745d87802bfdeea78ca817 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Tue, 13 Jul 2021 15:19:10 +0800 Subject: [PATCH 50/65] [TD-4969] : modify minimal interval of selecting window to be 1us. --- documentation20/cn/12.taos-sql/docs.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 4a92effe6d..e7541bb877 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -1332,6 +1332,7 @@ SELECT function_list FROM stb_name - 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:TOP、BOTTOM、DIFF 以及四则运算)。 - 查询过滤、聚合等操作按照每个切分窗口为独立的单位执行。聚合查询目前支持三种窗口的划分方式: 1. 时间窗口:聚合时间段的窗口宽度由关键词 INTERVAL 指定,最短时间间隔 10 毫秒(10a);并且支持偏移 offset(偏移必须小于间隔),也即时间窗口划分与“UTC 时刻 0”相比的偏移量。SLIDING 语句用于指定聚合时间段的前向增量,也即每次窗口向前滑动的时长。当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 + * 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 1 微秒(1u),当然如果所查询的 DATABASE 的时间精度设置为毫秒级,那么允许的最短时间间隔为 1 毫秒(1a)。 2. 状态窗口:使用整数(布尔值)或字符串来标识产生记录时设备的状态量,产生的记录如果具有相同的状态量取值则归属于同一个状态窗口,数值改变后该窗口关闭。状态量所对应的列作为 STATE_WINDOW 语句的参数来指定。 3. 会话窗口:时间戳所在的列由 SESSION 语句的 ts_col 参数指定,会话窗口根据相邻两条记录的时间戳差值来确定是否属于同一个会话——如果时间戳差异在 tol_val 以内,则认为记录仍属于同一个窗口;如果时间变化超过 tol_val,则自动开启下一个窗口。 - WHERE 语句可以指定查询的起止时间和其他过滤条件。 From f28c1a6097c90d6a58afe7ca00d172ab3a2c444f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 13 Jul 2021 15:20:39 +0800 Subject: [PATCH 51/65] [td-5176]: improve the twa query performance in case of interval query. --- src/client/src/tscSQLParser.c | 68 ++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index ded334c69f..59807d1e2e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -96,7 +96,7 @@ static int32_t parseIntervalOffset(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrTo static int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SStrToken* pSliding); static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, bool isStable); -static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem); +static int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem, bool outerQuery); static int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSql); static int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode); @@ -1809,8 +1809,8 @@ static bool hasNoneUserDefineExpr(SQueryInfo* pQueryInfo) { return false; } -int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelNodeList, bool isSTable, bool joinQuery, - bool timeWindowQuery) { +int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelNodeList, bool joinQuery, + bool timeWindowQuery, bool outerQuery) { assert(pSelNodeList != NULL && pCmd != NULL); const char* msg1 = "too many items in selection clause"; @@ -1852,7 +1852,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS } else if (type == SQL_NODE_TABLE_COLUMN || type == SQL_NODE_VALUE) { // use the dynamic array list to decide if the function is valid or not // select table_name1.field_name1, table_name2.field_name2 from table_name1, table_name2 - if (addProjectionExprAndResultField(pCmd, pQueryInfo, pItem) != TSDB_CODE_SUCCESS) { + if (addProjectionExprAndResultField(pCmd, pQueryInfo, pItem, outerQuery) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } } else if (type == SQL_NODE_EXPR) { @@ -1988,14 +1988,15 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum return numOfTotalColumns; } -int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem) { +int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExprItem* pItem, bool outerQuery) { const char* msg1 = "tag for normal table query is not allowed"; const char* msg2 = "invalid column name"; + const char* msg3 = "tbname not allowed in outer query"; int32_t startPos = (int32_t)tscNumOfExprs(pQueryInfo); - int32_t optr = pItem->pNode->tokenId; + int32_t tokenId = pItem->pNode->tokenId; - if (optr == TK_ALL) { // project on all fields + if (tokenId == TK_ALL) { // project on all fields TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_PROJECTION_QUERY); SColumnIndex index = COLUMN_INDEX_INITIALIZER; @@ -2019,7 +2020,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t if (pTableMeta->tableType != TSDB_TEMP_TABLE) { tscInsertPrimaryTsSourceColumn(pQueryInfo, pTableMeta->id.uid); } - } else if (optr == TK_STRING || optr == TK_INTEGER || optr == TK_FLOAT) { // simple column projection query + } else if (tokenId == TK_STRING || tokenId == TK_INTEGER || tokenId == TK_FLOAT) { // simple column projection query SColumnIndex index = COLUMN_INDEX_INITIALIZER; // user-specified constant value as a new result column @@ -2027,13 +2028,13 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t index.tableIndex = 0; SSchema colSchema = tGetUserSpecifiedColumnSchema(&pItem->pNode->value, &pItem->pNode->exprToken, pItem->aliasName); - SExprInfo* pExpr = - tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_UDC, getNewResColId(pCmd)); + SExprInfo* pExpr = tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, TSDB_COL_UDC, + getNewResColId(pCmd)); // NOTE: the first parameter is reserved for the tag column id during join query process. pExpr->base.numOfParams = 2; tVariantAssign(&pExpr->base.param[1], &pItem->pNode->value); - } else if (optr == TK_ID) { + } else if (tokenId == TK_ID) { SColumnIndex index = COLUMN_INDEX_INITIALIZER; if (getColumnIndexByName(&pItem->pNode->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { @@ -2041,12 +2042,40 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t } if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { - SSchema colSchema = *tGetTbnameColumnSchema(); - char name[TSDB_COL_NAME_LEN] = {0}; - getColumnName(pItem, name, colSchema.name, sizeof(colSchema.name) - 1); + if (outerQuery) { + STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); + int32_t numOfCols = tscGetNumOfColumns(pTableMetaInfo->pTableMeta); - tstrncpy(colSchema.name, name, TSDB_COL_NAME_LEN); - /*SExprInfo* pExpr = */tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, TSDB_COL_TAG, getNewResColId(pCmd)); + bool existed = false; + SSchema* pSchema = pTableMetaInfo->pTableMeta->schema; + for (int32_t i = 0; i < numOfCols; ++i) { + if (strncasecmp(pSchema[i].name, TSQL_TBNAME_L, tListLen(pSchema[i].name)) == 0) { + existed = true; + index.columnIndex = i; + break; + } + } + + if (!existed) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + + SSchema colSchema = pSchema[index.columnIndex]; + char name[TSDB_COL_NAME_LEN] = {0}; + getColumnName(pItem, name, colSchema.name, sizeof(colSchema.name) - 1); + + tstrncpy(colSchema.name, name, TSDB_COL_NAME_LEN); + /*SExprInfo* pExpr = */ tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_PRJ, &index, &colSchema, + TSDB_COL_NORMAL, getNewResColId(pCmd)); + } else { + SSchema colSchema = *tGetTbnameColumnSchema(); + char name[TSDB_COL_NAME_LEN] = {0}; + getColumnName(pItem, name, colSchema.name, sizeof(colSchema.name) - 1); + + tstrncpy(colSchema.name, name, TSDB_COL_NAME_LEN); + /*SExprInfo* pExpr = */ tscAddFuncInSelectClause(pQueryInfo, startPos, TSDB_FUNC_TAGPRJ, &index, &colSchema, + TSDB_COL_TAG, getNewResColId(pCmd)); + } } else { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; @@ -7156,8 +7185,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return code; } - bool isSTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); - if (validateSelectNodeList(&pSql->cmd, pQueryInfo, pSqlNode->pSelNodeList, isSTable, false, false) != TSDB_CODE_SUCCESS) { + if (validateSelectNodeList(&pSql->cmd, pQueryInfo, pSqlNode->pSelNodeList, false, false, false) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -7945,7 +7973,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf return TSDB_CODE_TSC_INVALID_OPERATION; } - if (validateSelectNodeList(pCmd, pQueryInfo, pSqlNode->pSelNodeList, false, false, timeWindowQuery) != + if (validateSelectNodeList(pCmd, pQueryInfo, pSqlNode->pSelNodeList, false, timeWindowQuery, true) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -8085,7 +8113,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf int32_t timeWindowQuery = (TPARSER_HAS_TOKEN(pSqlNode->interval.interval) || TPARSER_HAS_TOKEN(pSqlNode->sessionVal.gap)); - if (validateSelectNodeList(pCmd, pQueryInfo, pSqlNode->pSelNodeList, isSTable, joinQuery, timeWindowQuery) != + if (validateSelectNodeList(pCmd, pQueryInfo, pSqlNode->pSelNodeList, joinQuery, timeWindowQuery, false) != TSDB_CODE_SUCCESS) { return TSDB_CODE_TSC_INVALID_OPERATION; } From 8f2008664e24972fd730aa8d4547d13ad092c26d Mon Sep 17 00:00:00 2001 From: wpan Date: Tue, 13 Jul 2021 16:34:19 +0800 Subject: [PATCH 52/65] add retry for reconfigure table --- src/client/src/tscParseLineProtocol.c | 30 +++++++++++++++------------ src/client/src/tscPrepare.c | 10 +++++++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 04b96dc52a..5fba602670 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -565,16 +565,19 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols } snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")"); + int32_t code = 0; int32_t try = 0; - do { - TAOS_STMT* stmt = taos_stmt_init(taos); - code = taos_stmt_prepare(stmt, sql, strlen(sql)); - if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); - return code; - } + TAOS_STMT* stmt = taos_stmt_init(taos); + + code = taos_stmt_prepare(stmt, sql, strlen(sql)); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + return code; + } + + do { code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { @@ -598,14 +601,15 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols } code = taos_stmt_execute(stmt); - if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - } else { - taos_stmt_close(stmt); - } } while (code == TSDB_CODE_TDB_TABLE_RECONFIGURE && try++ < TSDB_MAX_REPLICA); + if (code != 0) { + printf("%s", taos_stmt_errstr(stmt)); + taos_stmt_close(stmt); + } else { + taos_stmt_close(stmt); + } + return code; } diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 798e79dbcb..3a462c96d6 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -1200,9 +1200,11 @@ static int insertBatchStmtExecute(STscStmt* pStmt) { // wait for the callback function to post the semaphore tsem_wait(&pStmt->pSql->rspSem); + code = pStmt->pSql->res.code; + insertBatchClean(pStmt); - return pStmt->pSql->res.code; + return code; } int stmtParseInsertTbTags(SSqlObj* pSql, STscStmt* pStmt) { @@ -1647,7 +1649,11 @@ int taos_stmt_close(TAOS_STMT* stmt) { } else { if (pStmt->multiTbInsert) { taosHashCleanup(pStmt->mtb.pTableHash); - pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, false); + bool rmMeta = false; + if (pStmt->pSql && pStmt->pSql->res.code != 0) { + rmMeta = true; + } + pStmt->mtb.pTableBlockHashList = tscDestroyBlockHashTable(pStmt->mtb.pTableBlockHashList, rmMeta); taosHashCleanup(pStmt->pSql->cmd.insertParam.pTableBlockHashList); pStmt->pSql->cmd.insertParam.pTableBlockHashList = NULL; taosArrayDestroy(pStmt->mtb.tags); From 0d719ab43c3ef22932f7c99e5cffa4996ad25a31 Mon Sep 17 00:00:00 2001 From: Shenglian Zhou Date: Tue, 13 Jul 2021 16:37:07 +0800 Subject: [PATCH 53/65] add log and free memory --- src/client/src/tscParseLineProtocol.c | 165 +++++++++++++++++++++----- tests/examples/c/apitest.c | 9 +- 2 files changed, 142 insertions(+), 32 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 04b96dc52a..b657594db4 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -98,8 +98,12 @@ static int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { if (kv->type == TSDB_DATA_TYPE_NCHAR) { char* ucs = malloc(kv->length * TSDB_NCHAR_SIZE + 1); int32_t bytesNeeded = 0; - //todo check conversion succeed - taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); + bool succ = taosMbsToUcs4(kv->value, kv->length, ucs, kv->length * TSDB_NCHAR_SIZE, &bytesNeeded); + if (!succ) { + free(ucs); + tscError("convert nchar string to UCS4_LE failed:%s", kv->value); + return TSDB_CODE_TSC_INVALID_VALUE; + } free(ucs); *bytes = bytesNeeded + VARSTR_HEADER_SIZE; } else if (kv->type == TSDB_DATA_TYPE_BINARY) { @@ -112,17 +116,20 @@ static int32_t getFieldBytesFromSmlKv(TAOS_SML_KV* kv, int32_t* bytes) { static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* array) { SSchema* pField = NULL; SSchema** ppField = taosHashGet(hash, smlKv->key, strlen(smlKv->key)); + int32_t code = 0; if (ppField) { pField = *ppField; if (pField->type != smlKv->type) { - //TODO: - tscError("type mismatch"); - return -1; + tscError("type mismatch. key %s, type %d. type before %d", smlKv->key, smlKv->type, pField->type); + return TSDB_CODE_TSC_INVALID_VALUE; } int32_t bytes = 0; - getFieldBytesFromSmlKv(smlKv, &bytes); + code = getFieldBytesFromSmlKv(smlKv, &bytes); + if (code != 0) { + return code; + } pField->bytes = MAX(pField->bytes, bytes); } else { @@ -133,7 +140,10 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra field.type = smlKv->type; int32_t bytes = 0; - getFieldBytesFromSmlKv(smlKv, &bytes); + code = getFieldBytesFromSmlKv(smlKv, &bytes); + if (code != 0) { + return code; + } field.bytes = bytes; pField = taosArrayPush(array, &field); @@ -146,6 +156,7 @@ static int32_t buildSmlKvSchema(TAOS_SML_KV* smlKv, SHashObj* hash, SArray* arra } static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, SArray* stableSchemas) { + int32_t code = 0; SHashObj* sname2shema = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false); @@ -171,12 +182,20 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, for (int j = 0; j < point->tagNum; ++j) { TAOS_SML_KV* tagKv = point->tags + j; - buildSmlKvSchema(tagKv, pStableSchema->tagHash, pStableSchema->tags); + code = buildSmlKvSchema(tagKv, pStableSchema->tagHash, pStableSchema->tags); + if (code != 0) { + tscError("build data point schema failed. point no.: %d, tag key: %s", i, tagKv->key); + return code; + } } for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* fieldKv = point->fields + j; - buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + code = buildSmlKvSchema(fieldKv, pStableSchema->fieldHash, pStableSchema->fields); + if (code != 0) { + tscError("build data point schema failed. point no.: %d, tag key: %s", i, fieldKv->key); + return code; + } } point->schema = pStableSchema; @@ -190,6 +209,13 @@ static int32_t buildDataPointSchemas(TAOS_SML_DATA_POINT* points, int numPoint, } taosHashCleanup(sname2shema); + tscDebug("build point schema succeed. num of super table: %zu", numStables); + for (int32_t i = 0; i < numStables; ++i) { + SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); + tscDebug("\ttable name: %s, tags number: %zu, fields number: %zu", schema->sTableName, + taosArrayGetSize(schema->tags), taosArrayGetSize(schema->fields)); + } + return 0; } @@ -199,8 +225,9 @@ static int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash if (ppDbAttr) { SSchema* dbAttr = *ppDbAttr; if (pointColField->type != dbAttr->type) { - //todo error - return -5; + tscError("point type and db type mismatch. key: %s. point type: %d, db type: %d", pointColField->name, + pointColField->type, dbAttr->type); + return TSDB_CODE_TSC_INVALID_VALUE; } if (IS_VAR_DATA_TYPE(pointColField->type) && (pointColField->bytes > dbAttr->bytes)) { @@ -225,6 +252,7 @@ static int32_t generateSchemaAction(SSchema* pointColField, SHashObj* dbAttrHash action->alterSTable.field = pointColField; *actionNeeded = true; } + tscDebug("generate schema action. action needed: %d, action: %d", *actionNeeded, action->action); return 0; } @@ -256,12 +284,14 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { int32_t outBytes = 0; char *result = (char *)calloc(1, capacity); + tscDebug("apply schema action: %d", action->action); switch (action->action) { case SCHEMA_ACTION_ADD_COLUMN: { int n = sprintf(result, "alter stable %s add column ", action->alterSTable.sTableName); buildColumnDescription(action->alterSTable.field, result+n, capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + taos_free_result(res); break; } case SCHEMA_ACTION_ADD_TAG: { @@ -270,6 +300,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { result+n, capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + taos_free_result(res); break; } case SCHEMA_ACTION_CHANGE_COLUMN_SIZE: { @@ -278,6 +309,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + taos_free_result(res); break; } case SCHEMA_ACTION_CHANGE_TAG_SIZE: { @@ -286,6 +318,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { capacity-n, &outBytes); TAOS_RES* res = taos_query(taos, result); //TODO async doAsyncQuery code = taos_errno(res); + taos_free_result(res); break; } case SCHEMA_ACTION_CREATE_STABLE: { @@ -314,13 +347,18 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { outBytes = snprintf(pos, freeBytes, ")"); TAOS_RES* res = taos_query(taos, result); code = taos_errno(res); + taos_free_result(res); break; } default: break; } + free(result); + if (code != 0) { + tscError("apply schema action failure. %s", tstrerror(code)); + } return code; } @@ -341,11 +379,14 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { return TSDB_CODE_TSC_DISCONNECTED; } + tscDebug("load table schema. super table name: %s", tableName); + char sql[256]; snprintf(sql, 256, "describe %s", tableName); TAOS_RES* res = taos_query(taos, sql); code = taos_errno(res); if (code != 0) { + tscError("describe table failure. %s", taos_errstr(res)); taos_free_result(res); return code; } @@ -369,16 +410,13 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { if ((code = tscSetTableFullName(&sname, &tableToken, pSql)) != TSDB_CODE_SUCCESS) { return code; } - char fullTableName[TSDB_TABLE_FNAME_LEN] = {0}; memset(fullTableName, 0, tListLen(fullTableName)); tNameExtractFullName(&sname, fullTableName); - if (code != TSDB_CODE_SUCCESS) { tscFreeSqlObj(pSql); return code; } - tscFreeSqlObj(pSql); schema->tags = taosArrayInit(8, sizeof(SSchema)); @@ -410,6 +448,8 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { SSchema* pField = taosArrayPush(schema->tags, &field); taosHashPut(schema->tagHash, field.name, strlen(field.name), &pField, POINTER_BYTES); } + tscDebug("load table meta succeed. %s, columns number: %d, tag number: %d, precision: %d", + tableName, tableMeta->tableInfo.numOfColumns, tableMeta->tableInfo.numOfTags, schema->precision); free(tableMeta); tableMeta = NULL; return code; } @@ -422,7 +462,6 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { SSmlSTableSchema dbSchema = {0}; code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { SSchemaAction schemaAction = {0}; schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; @@ -432,10 +471,12 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { schemaAction.createSTable.fields = pointSchema->fields; applySchemaAction(taos, &schemaAction); code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); - - pointSchema->precision = dbSchema.precision; - - destroySmlSTableSchema(&dbSchema); + if (code != 0) { + tscError("reconcile point schema failed. can not create %s", pointSchema->sTableName); + } else { + pointSchema->precision = dbSchema.precision; + destroySmlSTableSchema(&dbSchema); + } } else if (code == TSDB_CODE_SUCCESS) { size_t pointTagSize = taosArrayGetSize(pointSchema->tags); size_t pointFieldSize = taosArrayGetSize(pointSchema->fields); @@ -471,6 +512,7 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { destroySmlSTableSchema(&dbSchema); } else { + tscError("load table meta error: %s", tstrerror(code)); return code; } } @@ -496,11 +538,12 @@ static int32_t getChildTableName(TAOS_SML_DATA_POINT* point, char* tableName, in MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); MD5Final(&context); *tableNameLen = snprintf(tableName, *tableNameLen, - "tbl_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], + "t_%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], context.digest[1], context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6], context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11], context.digest[12], context.digest[13], context.digest[14], context.digest[15]); taosStringBuilderDestroy(&sb); + tscDebug("child table name: %s", tableName); return 0; } @@ -524,23 +567,25 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co } snprintf(sql + strlen(sql) - 1, freeBytes-strlen(sql)+1, ")"); + tscDebug("create table : %s", sql); + TAOS_STMT* stmt = taos_stmt_init(taos); int32_t code; code = taos_stmt_prepare(stmt, sql, strlen(sql)); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } code = taos_stmt_bind_param(stmt, TARRAY_GET_START(tagsBind)); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } code = taos_stmt_execute(stmt); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } @@ -565,6 +610,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols } snprintf(sql + strlen(sql)-1, freeBytes-strlen(sql)+1, ")"); + tscDebug("insert rows %zu into child table %s. ", taosArrayGetSize(rowsBind), cTableName); int32_t code = 0; int32_t try = 0; do { @@ -572,13 +618,13 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols code = taos_stmt_prepare(stmt, sql, strlen(sql)); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } code = taos_stmt_set_tbname(stmt, cTableName); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } @@ -587,19 +633,19 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols TAOS_BIND* colsBinds = taosArrayGetP(rowsBind, i); code = taos_stmt_bind_param(stmt, colsBinds); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } code = taos_stmt_add_batch(stmt); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); return code; } } code = taos_stmt_execute(stmt); if (code != 0) { - printf("%s", taos_stmt_errstr(stmt)); + tscError("%s", taos_stmt_errstr(stmt)); taos_stmt_close(stmt); } else { taos_stmt_close(stmt); @@ -722,6 +768,7 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num TAOS_BIND* bind = colBinds + j; free(bind->length); } + free(colBinds); } taosArrayDestroy(rowsBind); taosArrayDestroy(cTablePoints); @@ -734,6 +781,8 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num } int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { + tscDebug("taos_sml_insert. number of points: %d", numPoint); + int32_t code = TSDB_CODE_SUCCESS; SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray @@ -846,6 +895,30 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->value = malloc(item->length); char* endptr = NULL; *(int64_t*)(item->value) = strtoll(sv, &endptr, 10); + } else if (*last == 'b') { + item->type = TSDB_DATA_TYPE_TINYINT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(int8_t*)(item->value) = strtoll(sv, &endptr, 10); + } else if (*last == 's') { + item->type = TSDB_DATA_TYPE_SMALLINT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(int16_t*)(item->value) = strtoll(sv, &endptr, 10); + } else if (*last == 'w') { + item->type = TSDB_DATA_TYPE_INT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(int32_t*)(item->value) = strtoll(sv, &endptr, 10); + } else if (*last == 'f') { + item->type = TSDB_DATA_TYPE_FLOAT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(float*)(item->value) = strtold(sv, &endptr); } else { item->type = TSDB_DATA_TYPE_DOUBLE; item->length = (int16_t)tDataTypes[item->type].bytes; @@ -1001,6 +1074,36 @@ int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* faile return 0; } +void destroyLPPoint(void* p) { + SLPPoint* lpPoint = p; + for (int i=0; ifields); ++i) { + SLPItem* item = taosArrayGet(lpPoint->fields, i); + free(item->value); + } + taosArrayDestroy(lpPoint->fields); + + for (int i=0; itags); ++i) { + SLPItem* item = taosArrayGet(lpPoint->tags, i); + free(item->value); + } + taosArrayDestroy(lpPoint->tags); +} + +void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) { + for (int i=0; itagNum; ++i) { + free((point->tags+i)->key); + free((point->tags+i)->value); + } + free(point->tags); + for (int i=0; ifieldNum; ++i) { + free((point->fields+i)->key); + free((point->fields+i)->value); + } + free(point->fields); + free(point->stableName); + free(point->childTableName); +} + int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { SArray* lpPoints = taosArrayInit(numLines, sizeof(SLPPoint)); tscParseLines(lines, numLines, lpPoints, NULL); @@ -1065,6 +1168,12 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { } taos_sml_insert(taos, points, numPoints); + + for (int i=0; i Date: Tue, 13 Jul 2021 17:34:06 +0800 Subject: [PATCH 54/65] show crash --- tests/examples/c/apitest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 4f9c890839..376b00ef71 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -972,9 +972,9 @@ int32_t verify_schema_less(TAOS* taos) { "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532" }; - int code = taos_insert_by_lines(taos, lines , 6); -// int code = taos_insert_by_lines(taos, &lines[0], 1); -// code = taos_insert_by_lines(taos, &lines[1], 1); + //int code = taos_insert_by_lines(taos, lines , 6); + int code = taos_insert_by_lines(taos, &lines[0], 1); + code = taos_insert_by_lines(taos, &lines[1], 1); return code; } From a065d6a3579476cb3f28254ccc9ff80a63cf8ef8 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Tue, 13 Jul 2021 18:00:24 +0800 Subject: [PATCH 55/65] [TD-4905] : describe "INSERT INTO FILE" and restructured document about INSERT grammar. --- documentation20/cn/12.taos-sql/docs.md | 107 +++++++++++++------------ 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index e7541bb877..73fa5b34e5 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -362,77 +362,82 @@ TDengine 缺省的时间戳是毫秒精度,但通过在 CREATE DATABASE 时传 ## 数据写入 -- **插入一条记录** - ```mysql - INSERT INTO tb_name VALUES (field_value, ...); - ``` - 向表tb_name中插入一条记录。 +### 写入语法: -- **插入一条记录,数据对应到指定的列** - ```mysql - INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...); - ``` - 向表tb_name中插入一条记录,数据对应到指定的列。SQL语句中没有出现的列,数据库将自动填充为NULL。主键(时间戳)不能为NULL。 +```mysql +INSERT INTO + tb_name + [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)] + [(field1_name, ...)] + VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path + [tb2_name + [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)] + [(field1_name, ...)] + VALUES (field1_value, ...) [(field1_value2, ...) ...] | FILE csv_file_path + ...]; +``` -- **插入多条记录** - ```mysql - INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...) ...; - ``` - 向表tb_name中插入多条记录。 - **注意**:在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为now,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。 +### 详细描述及示例: -- **按指定的列插入多条记录** +- **插入一条或多条记录** + 指定已经创建好的数据子表的表名,并通过 VALUES 关键字提供一行或多行数据,即可向数据库写入这些数据。例如,执行如下语句可以写入一行记录: ```mysql - INSERT INTO tb_name (field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; + INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32); ``` - 向表tb_name中按指定的列插入多条记录。 + 或者,可以通过如下语句写入两行记录: + ```mysql + INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33); + ``` + **注意:** + 1)在第二个例子中,两行记录的首列时间戳使用了不同格式的写法。其中字符串格式的时间戳写法不受所在 DATABASE 的时间精度设置影响;而长整形格式的时间戳写法会受到所在 DATABASE 的时间精度设置影响——例子中的时间戳在毫秒精度下可以写作 1626164208000,而如果是在微秒精度设置下就需要写为 1626164208000000。 + 2)在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为 NOW,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。其原因在于,NOW 函数在执行中会被解析为所在 SQL 语句的实际执行时间,出现在同一语句中的多个 NOW 标记也就会被替换为完全相同的时间戳取值。 + 3)允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的 keep 值(数据保留的天数);允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的 days 值(数据文件存储数据的时间跨度,单位为天)。keep 和 days 都是可以在创建数据库时指定的,缺省值分别是 3650 天和 10 天。 -- **向多个表插入多条记录** +- **插入记录,数据对应到指定的列** + 向数据子表中插入记录时,无论插入一行还是多行,都可以让数据对应到指定的列。对于 SQL 语句中没有出现的列,数据库将自动填充为 NULL。主键(时间戳)不能为 NULL。例如: ```mysql - INSERT INTO tb1_name VALUES (field1_value1, ...) (field1_value2, ...) ... - tb2_name VALUES (field1_value1, ...) (field1_value2, ...) ...; + INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, 0.31); ``` - 同时向表tb1_name和tb2_name中分别插入多条记录。 + **说明:**如果不指定列,也即使用全列模式——那么在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列模式写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入 NULL。 -- **同时向多个表按列插入多条记录** +- **向多个表插入记录** + 可以在一条语句中,分别向多个表插入一条或多条记录,并且也可以在插入过程中指定列。例如: ```mysql - INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ... - tb2_name (tb2_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; + INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) + d1002 (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); ``` - 同时向表tb1_name和tb2_name中按列分别插入多条记录。 - 注意: - 1) 如果时间戳为now,系统将自动使用客户端当前时间作为该记录的时间戳; - 2) 允许插入的最老记录的时间戳,是相对于当前服务器时间,减去配置的keep值(数据保留的天数),允许插入的最新记录的时间戳,是相对于当前服务器时间,加上配置的days值(数据文件存储数据的时间跨度,单位为天)。keep和days都是可以在创建数据库时指定的,缺省值分别是3650天和10天。 +- **插入记录时自动建表** + 如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。例如: + ```mysql + INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32); + ``` + 也可以在自动建表时,只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将置为 NULL。例如: + ```mysql + INSERT INTO d21001 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33); + ``` + 自动建表语法也支持在一条语句中向多个表插入记录。例如: + ```mysql + INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) + d21002 USING meters (groupdId) TAGS (2) VALUES ('2021-07-13 14:06:34.255', 10.15, 217, 0.33) + d21003 USING meters (groupdId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31); + ``` + **说明:**在 2.0.20.5 版本之前,在使用自动建表语法并指定列时,子表的列名必须紧跟在子表名称后面,而不能如例子里那样放在 TAGS 和 VALUES 之间。从 2.0.20.5 版本开始,两种写法都可以,但不能在一条 SQL 语句中混用,否则会报语法错误。 -- **插入记录时自动建表** - ```mysql - INSERT INTO tb_name USING stb_name TAGS (tag_value1, ...) VALUES (field_value1, ...); +- **插入来自文件的数据记录** + 除了使用 VALUES 关键字插入一行或多行数据外,也可以把要写入的数据放在 CSV 文件中(英文逗号分隔、英文单引号括住每个值)供 SQL 指令读取。其中 CSV 文件无需表头。例如,如果 /tmp/csvfile.csv 文件的内容为: ``` - 如果用户在写数据时并不确定某个表是否存在,此时可以在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。自动建表时,要求必须以超级表为模板,并写明数据表的 TAGS 取值。 - -- **插入记录时自动建表,并指定具体的 TAGS 列** - ```mysql - INSERT INTO tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...) VALUES (field_value1, ...); + '2021-07-13 14:07:34.630', '10.2', '219', '0.32' + '2021-07-13 14:07:35.779', '10.15', '217', '0.33' ``` - 在自动建表时,可以只是指定部分 TAGS 列的取值,未被指定的 TAGS 列将取为空值。 - -- **同时向多个表按列插入多条记录,自动建表** + 那么通过如下指令可以把这个文件中的数据写入子表中: ```mysql - INSERT INTO tb1_name (tb1_field1_name, ...) [USING stb1_name TAGS (tag_value1, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ... - tb2_name (tb2_field1_name, ...) [USING stb2_name TAGS (tag_value2, ...)] VALUES (field1_value1, ...) (field1_value2, ...) ...; + INSERT INTO d1001 FILE '/tmp/csvfile.csv'; ``` - 以自动建表的方式,同时向表tb1_name和tb2_name中按列分别插入多条记录。 - 说明:`(tb1_field1_name, ...)`的部分可以省略掉,这样就是使用全列模式写入——也即在 VALUES 部分提供的数据,必须为数据表的每个列都显式地提供数据。全列写入速度会远快于指定列,因此建议尽可能采用全列写入方式,此时空列可以填入NULL。 - 从 2.0.20.5 版本开始,子表的列名可以不跟在子表名称后面,而是可以放在 TAGS 和 VALUES 之间,例如像下面这样写: - ```mysql - INSERT INTO tb1_name [USING stb1_name TAGS (tag_value1, ...)] (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value2, ...) ...; - ``` - 注意:虽然两种写法都可以,但并不能在一条 SQL 语句中混用,否则会报语法错误。 **历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。 -说明:针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分SQL仍会执行。下面的sql中,insert语句是无效的,但是d1001仍会被创建。 +**说明:**针对 insert 类型的 SQL 语句,我们采用的流式解析策略,在发现后面的错误之前,前面正确的部分 SQL 仍会执行。下面的 SQL 中,INSERT 语句是无效的,但是 d1001 仍会被创建。 ```mysql taos> CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); From 153b5d7115e6eb157e3b8639e3b716ee1c1a0faa Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 13 Jul 2021 21:37:22 +0800 Subject: [PATCH 56/65] pass pr build check --- src/client/src/tscParseLineProtocol.c | 62 ++++++++++++++++----------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index a3bb7c6f15..a198a7b42a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -324,7 +324,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { case SCHEMA_ACTION_CREATE_STABLE: { int n = sprintf(result, "create stable %s (", action->createSTable.sTableName); char* pos = result + n; int freeBytes = capacity - n; - int numCols = taosArrayGetSize(action->createSTable.fields); + size_t numCols = taosArrayGetSize(action->createSTable.fields); for (int32_t i = 0; i < numCols; ++i) { SSchema* field = taosArrayGet(action->createSTable.fields, i); buildColumnDescription(field, pos, freeBytes, &outBytes); @@ -336,7 +336,7 @@ static int32_t applySchemaAction(TAOS* taos, SSchemaAction* action) { outBytes = snprintf(pos, freeBytes, ") tags ("); pos += outBytes; freeBytes -= outBytes; - int numTags = taosArrayGetSize(action->createSTable.tags); + size_t numTags = taosArrayGetSize(action->createSTable.tags); for (int32_t i = 0; i < numTags; ++i) { SSchema* field = taosArrayGet(action->createSTable.tags, i); buildColumnDescription(field, pos, freeBytes, &outBytes); @@ -397,7 +397,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) { pSql->signature = pSql; pSql->fp = NULL; - SStrToken tableToken = {.z=tableName, .n=strlen(tableName), .type=TK_ID}; + SStrToken tableToken = {.z=tableName, .n=(uint32_t)strlen(tableName), .type=TK_ID}; tGetToken(tableName, &tableToken.type); // Check if the table name available or not if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) { @@ -459,7 +459,8 @@ static int32_t reconcileDBSchemas(TAOS* taos, SArray* stableSchemas) { size_t numStable = taosArrayGetSize(stableSchemas); for (int i = 0; i < numStable; ++i) { SSmlSTableSchema* pointSchema = taosArrayGet(stableSchemas, i); - SSmlSTableSchema dbSchema = {0}; + SSmlSTableSchema dbSchema; + memset(&dbSchema, 0, sizeof(SSmlSTableSchema)); code = loadTableMeta(taos, pointSchema->sTableName, &dbSchema); if (code == TSDB_CODE_MND_INVALID_TABLE_NAME) { @@ -571,7 +572,7 @@ static int32_t creatChildTableIfNotExists(TAOS* taos, const char* cTableName, co TAOS_STMT* stmt = taos_stmt_init(taos); int32_t code; - code = taos_stmt_prepare(stmt, sql, strlen(sql)); + code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); if (code != 0) { tscError("%s", taos_stmt_errstr(stmt)); return code; @@ -617,7 +618,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols TAOS_STMT* stmt = taos_stmt_init(taos); - code = taos_stmt_prepare(stmt, sql, strlen(sql)); + code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); if (code != 0) { tscError("%s", taos_stmt_errstr(stmt)); return code; @@ -717,8 +718,8 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num SArray* cTablePoints = *pCTablePoints; TAOS_SML_DATA_POINT * point = taosArrayGetP(cTablePoints, 0); - int32_t numTags = taosArrayGetSize(point->schema->tags); - int32_t numCols = taosArrayGetSize(point->schema->fields); + size_t numTags = taosArrayGetSize(point->schema->tags); + size_t numCols = taosArrayGetSize(point->schema->fields); SArray* tagBinds = taosArrayInit(numTags, sizeof(TAOS_BIND)); taosArraySetSize(tagBinds, numTags); @@ -728,7 +729,7 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num } for (int j = 0; j < point->tagNum; ++j) { TAOS_SML_KV* kv = point->tags + j; - int32_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); + size_t idx = TARRAY_ELEM_IDX(point->schema->tags, kv->schema); TAOS_BIND* bind = taosArrayGet(tagBinds, idx); bind->buffer_type = kv->type; bind->length = malloc(sizeof(uintptr_t*)); @@ -750,7 +751,7 @@ static int32_t insertPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t num } for (int j = 0; j < point->fieldNum; ++j) { TAOS_SML_KV* kv = point->fields + j; - int32_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); + size_t idx = TARRAY_ELEM_IDX(point->schema->fields, kv->schema); TAOS_BIND* bind = colBinds + idx; bind->buffer_type = kv->type; bind->length = malloc(sizeof(uintptr_t*)); @@ -793,10 +794,24 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { int32_t code = TSDB_CODE_SUCCESS; SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray - buildDataPointSchemas(points, numPoint, stableSchemas); - reconcileDBSchemas(taos, stableSchemas); - insertPoints(taos, points, numPoint); + code = buildDataPointSchemas(points, numPoint, stableSchemas); + if (code != 0) { + tscError("error building data point schemas : %s", tstrerror(code)); + goto clean_up; + } + code = reconcileDBSchemas(taos, stableSchemas); + if (code != 0) { + tscError("error change db schema : %s", tstrerror(code)); + goto clean_up; + } + + code = insertPoints(taos, points, numPoint); + if (code != 0) { + tscError("error insert points : %s", tstrerror(code)); + } + +clean_up: for (int i = 0; i < taosArrayGetSize(stableSchemas); ++i) { SSmlSTableSchema* schema = taosArrayGet(stableSchemas, i); taosArrayDestroy(schema->fields); @@ -806,11 +821,6 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) { return code; } - -//todo: table/column length check -//todo: type check -//todo: taosmbs2ucs4 check - //========================================================================= typedef enum { @@ -907,25 +917,25 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(int8_t*)(item->value) = strtoll(sv, &endptr, 10); + *(int8_t*)(item->value) = (int8_t)strtoll(sv, &endptr, 10); } else if (*last == 's') { item->type = TSDB_DATA_TYPE_SMALLINT; item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(int16_t*)(item->value) = strtoll(sv, &endptr, 10); + *(int16_t*)(item->value) = (int16_t)strtoll(sv, &endptr, 10); } else if (*last == 'w') { item->type = TSDB_DATA_TYPE_INT; item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(int32_t*)(item->value) = strtoll(sv, &endptr, 10); + *(int32_t*)(item->value) = (int32_t)strtoll(sv, &endptr, 10); } else if (*last == 'f') { item->type = TSDB_DATA_TYPE_FLOAT; item->length = (int16_t)tDataTypes[item->type].bytes; item->value = malloc(item->length); char* endptr = NULL; - *(float*)(item->value) = strtold(sv, &endptr); + *(float*)(item->value) = (float)strtold(sv, &endptr); } else { item->type = TSDB_DATA_TYPE_DOUBLE; item->length = (int16_t)tDataTypes[item->type].bytes; @@ -1073,7 +1083,7 @@ int32_t tscParseLine(SStrToken line, SLPPoint* point) { int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { for (int32_t i = 0; i < numLines; ++i) { - SStrToken tkLine = {.z = lines[i], .n = strlen(lines[i])+1}; + SStrToken tkLine = {.z = lines[i], .n = (uint32_t)strlen(lines[i])+1}; SLPPoint point; tscParseLine(tkLine, &point); taosArrayPush(points, &point); @@ -1126,7 +1136,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { size_t lpTagSize = taosArrayGetSize(lpPoint->tags); point->tags = calloc(lpTagSize, sizeof(TAOS_SML_KV)); - point->tagNum = lpTagSize; + point->tagNum = (int)lpTagSize; for (int j=0; jtags, j); TAOS_SML_KV* tagKv = point->tags + j; @@ -1144,7 +1154,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { size_t lpFieldsSize = taosArrayGetSize(lpPoint->fields); point->fields = calloc(lpFieldsSize + 1, sizeof(TAOS_SML_KV)); - point->fieldNum = lpFieldsSize + 1; + point->fieldNum = (int)(lpFieldsSize + 1); TAOS_SML_KV* tsField = point->fields + 0; char tsKey[256]; @@ -1174,7 +1184,7 @@ int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { } } - taos_sml_insert(taos, points, numPoints); + taos_sml_insert(taos, points, (int)numPoints); for (int i=0; i Date: Tue, 13 Jul 2021 22:41:04 +0800 Subject: [PATCH 57/65] add more data type --- src/client/src/tscParseLineProtocol.c | 18 +++++++++++++++++- tests/examples/c/apitest.c | 9 ++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index a198a7b42a..9f86d780d3 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -912,6 +912,12 @@ int32_t parseItemValue(SLPItem* item, LPItemKind kind) { item->value = malloc(item->length); char* endptr = NULL; *(int64_t*)(item->value) = strtoll(sv, &endptr, 10); + } else if (*last == 'u') { + item->type = TSDB_DATA_TYPE_UBIGINT; + item->length = (int16_t)tDataTypes[item->type].bytes; + item->value = malloc(item->length); + char* endptr = NULL; + *(uint64_t*)(item->value) = (uint64_t)strtoull(sv, &endptr, 10); } else if (*last == 'b') { item->type = TSDB_DATA_TYPE_TINYINT; item->length = (int16_t)tDataTypes[item->type].bytes; @@ -989,6 +995,16 @@ int32_t parsePointTime(SLPPoint* point) { } else { char* endptr = NULL; point->ts = strtoll(point->tsToken.z, &endptr, 10); + char* last = point->tsToken.z + point->tsToken.n - 1; + if (*last == 's') { + point->ts *= (int64_t)1e9; + } else if (*last == 'a') { + point->ts *= (int64_t)1e6; + } else if (*last == 'u') { + point->ts *= (int64_t)1e3; + } else if (*last == 'b') { + point->ts *= 1; + } } return 0; } @@ -1083,7 +1099,7 @@ int32_t tscParseLine(SStrToken line, SLPPoint* point) { int32_t tscParseLines(char* lines[], int numLines, SArray* points, SArray* failedLines) { for (int32_t i = 0; i < numLines; ++i) { - SStrToken tkLine = {.z = lines[i], .n = (uint32_t)strlen(lines[i])+1}; + SStrToken tkLine = {.z = lines[i], .n = (uint32_t)strlen(lines[i])}; SLPPoint point; tscParseLine(tkLine, &point); taosArrayPush(points, &point); diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 376b00ef71..ed76e7b2b0 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -966,13 +966,16 @@ int32_t verify_schema_less(TAOS* taos) { char* lines[] = { "st,t1=3i,t2=4,t3=\"t3\" c1=3i,c3=L\"passit\",c2=false,c4=4 1626006833639000000", "st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5 1626006833640000000", - "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", "ste,t2=5,t3=L\"ste\" c1=true,c2=4,c3=\"iam\" 1626056811823316532", + "st,t1=4i,t2=5,t3=\"t4\" c1=3i,c3=L\"passitagain\",c2=true,c4=5 1626006833642000000", "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532", - "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532" + "ste,t2=5,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32b,c6=64s,c7=32w,c8=88.88f 1626056812843316532", + "st,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000", + "stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin\",c2=true,c4=5,c5=5,c6=7u 1626006933640000000", + "stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin_stf\",c2=false,c5=5,c6=7u 1626006933641a" }; - //int code = taos_insert_by_lines(taos, lines , 6); +// int code = taos_insert_by_lines(taos, lines , sizeof(lines)/sizeof(char*)); int code = taos_insert_by_lines(taos, &lines[0], 1); code = taos_insert_by_lines(taos, &lines[1], 1); From d95f27acf684a8fbb0cec4e001342b36fb472fbe Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 13 Jul 2021 23:03:07 +0800 Subject: [PATCH 58/65] [td-225]refactor the log --- src/client/src/tscSubquery.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 8ab3512cba..f10646e3a3 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2542,7 +2542,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { SSqlObj* pSub = pSql->pSubs[j]; SRetrieveSupport* pSupport = pSub->param; - tscDebug("0x%"PRIx64" sub:%p launch subquery, orderOfSub:%d.", pSql->self, pSub, pSupport->subqueryIndex); + tscDebug("0x%"PRIx64" sub:0x%"PRIx64" launch subquery, orderOfSub:%d.", pSql->self, pSub->self, pSupport->subqueryIndex); tscBuildAndSendRequest(pSub, NULL); } @@ -2861,8 +2861,8 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR assert(pRes->numOfRows == numOfRows); int64_t num = atomic_add_fetch_64(&pState->numOfRetrievedRows, numOfRows); - tscDebug("0x%"PRIx64" sub:%p retrieve numOfRows:%d totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d", - pParentSql->self, pSql, pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.inUse], idx); + tscDebug("0x%"PRIx64" sub:0x%"PRIx64" retrieve numOfRows:%d totalNumOfRows:%" PRIu64 " from ep:%s, orderOfSub:%d", + pParentSql->self, pSql->self, pRes->numOfRows, pState->numOfRetrievedRows, pSql->epSet.fqdn[pSql->epSet.inUse], idx); if (num > tsMaxNumOfOrderedResults && tscIsProjectionQueryOnSTable(pQueryInfo, 0) && !(tscGetQueryInfo(&pParentSql->cmd)->distinctTag)) { tscError("0x%"PRIx64" sub:0x%"PRIx64" num of OrderedRes is too many, max allowed:%" PRId32 " , current:%" PRId64, From 6b404cd1cee243b63f5a32324f1c277094f73f20 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Wed, 14 Jul 2021 07:48:55 +0800 Subject: [PATCH 59/65] change api function name taos_insert_by_lines to taos_insert_lines --- src/client/src/tscParseLineProtocol.c | 12 +++++++----- src/inc/taos.h | 2 +- tests/examples/c/apitest.c | 6 +++--- tests/tsim/src/simExe.c | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 9f86d780d3..37264e8eaa 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -2,19 +2,21 @@ #include #include #include + #include "os.h" #include "osString.h" #include "ttype.h" #include "tmd5.h" #include "tstrbuild.h" #include "tname.h" -#include "taos.h" -#include "tsclient.h" -#include "tscLog.h" #include "hash.h" #include "tskiplist.h" -#include "tscUtil.h" +#include "tscUtil.h" +#include "tsclient.h" +#include "tscLog.h" + +#include "taos.h" typedef struct { char sTableName[TSDB_TABLE_NAME_LEN]; SHashObj* tagHash; @@ -1137,7 +1139,7 @@ void destroySmlDataPoint(TAOS_SML_DATA_POINT* point) { free(point->childTableName); } -int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines) { +int taos_insert_lines(TAOS* taos, char* lines[], int numLines) { SArray* lpPoints = taosArrayInit(numLines, sizeof(SLPPoint)); tscParseLines(lines, numLines, lpPoints, NULL); diff --git a/src/inc/taos.h b/src/inc/taos.h index ca18c4fb93..a62f387924 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -169,7 +169,7 @@ DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); -DLL_EXPORT int taos_insert_by_lines(TAOS* taos, char* lines[], int numLines); +DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines); #ifdef __cplusplus } diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index ed76e7b2b0..a377bbc7b4 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -975,9 +975,9 @@ int32_t verify_schema_less(TAOS* taos) { "stf,t1=4i,t3=\"t4\",t2=5,t4=5 c1=3i,c3=L\"passitagin_stf\",c2=false,c5=5,c6=7u 1626006933641a" }; -// int code = taos_insert_by_lines(taos, lines , sizeof(lines)/sizeof(char*)); - int code = taos_insert_by_lines(taos, &lines[0], 1); - code = taos_insert_by_lines(taos, &lines[1], 1); +// int code = taos_insert_lines(taos, lines , sizeof(lines)/sizeof(char*)); + int code = taos_insert_lines(taos, &lines[0], 1); + code = taos_insert_lines(taos, &lines[1], 1); return code; } diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 2615448e4b..a05f46ce0d 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -1079,7 +1079,7 @@ bool simExecuteLineInsertCmd(SScript *script, char *rest) { simInfo("script:%s, %s", script->fileName, rest); simLogSql(buf, true); char * lines[] = {rest}; - int32_t ret = taos_insert_by_lines(script->taos, lines, 1); + int32_t ret = taos_insert_lines(script->taos, lines, 1); if (ret == TSDB_CODE_SUCCESS) { simDebug("script:%s, taos:%p, %s executed. success.", script->fileName, script->taos, rest); script->linePos++; @@ -1102,7 +1102,7 @@ bool simExecuteLineInsertErrorCmd(SScript *script, char *rest) { simInfo("script:%s, %s", script->fileName, rest); simLogSql(buf, true); char * lines[] = {rest}; - int32_t ret = taos_insert_by_lines(script->taos, lines, 1); + int32_t ret = taos_insert_lines(script->taos, lines, 1); if (ret == TSDB_CODE_SUCCESS) { sprintf(script->error, "script:%s, taos:%p, %s executed. expect failed, but success.", script->fileName, script->taos, rest); script->linePos++; From 420a1dfe05a5737ded2bc00a634422003f961efb Mon Sep 17 00:00:00 2001 From: glzhao89 Date: Wed, 14 Jul 2021 09:16:00 +0800 Subject: [PATCH 60/65] [TD-5150]: fix unitialized semaphore when running test suites on MacOS --- src/client/src/tscUtil.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 173db05e10..02aeb3e33d 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -3608,6 +3608,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { pNew->signature = pNew; pNew->sqlstr = strdup(pSql->sqlstr); // todo refactor pNew->fp = tscSubqueryCompleteCallback; + tsem_init(&pNew->rspSem, 0, 0); SRetrieveSupport* ps = calloc(1, sizeof(SRetrieveSupport)); // todo use object id ps->pParentSql = pSql; From 76e28e294cd2ae7acdb884cc28cb6d0907ec6c6c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 14 Jul 2021 10:31:57 +0800 Subject: [PATCH 61/65] [td-225]update the test script. --- .../general/parser/select_with_tags.sim | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/script/general/parser/select_with_tags.sim b/tests/script/general/parser/select_with_tags.sim index 9d5214bfaa..514aabe56f 100644 --- a/tests/script/general/parser/select_with_tags.sim +++ b/tests/script/general/parser/select_with_tags.sim @@ -169,32 +169,32 @@ if $rows != 12800 then return -1 endi -sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0; -if $rows != 100 then +sql select top(c1, 80), tbname, t1, t2 from select_tags_mt0; +if $rows != 80 then return -1 endi -if $data00 != @70-01-01 08:03:30.100@ then +if $data00 != @70-01-01 08:03:40.100@ then return -1 endi -if $data10 != @70-01-01 08:03:30.200@ then +if $data10 != @70-01-01 08:03:40.200@ then return -1 endi -if $data01 != 110 then +if $data01 != 111 then return -1 endi -if $data02 != @select_tags_tb11@ then +if $data02 != @select_tags_tb12@ then return -1 endi -if $data03 != 11 then +if $data03 != 12 then return -1 endi -if $data04 != @abc11@ then +if $data04 != @abc12@ then return -1 endi @@ -227,8 +227,8 @@ if $data04 != @abc12@ then return -1 endi -sql select bottom(c1, 100), tbname, t1, t2 from select_tags_mt0; -if $rows != 100 then +sql select bottom(c1, 72), tbname, t1, t2 from select_tags_mt0; +if $rows != 72 then return -1 endi From 44cd80b3e1224c59f89954c199fa02b13a59e4fd Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Wed, 14 Jul 2021 11:32:53 +0800 Subject: [PATCH 62/65] [TD-5255] : update getting-start doc to fit latest taosdemo feature. --- documentation20/cn/02.getting-started/docs.md | 98 +++++++++---------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/documentation20/cn/02.getting-started/docs.md b/documentation20/cn/02.getting-started/docs.md index 6eb58a1433..fa36481646 100644 --- a/documentation20/cn/02.getting-started/docs.md +++ b/documentation20/cn/02.getting-started/docs.md @@ -2,25 +2,25 @@ ## 快捷安装 -TDengine软件分为服务器、客户端和报警模块三部分,目前2.0版服务器仅能在Linux系统上安装和运行,后续会支持Windows、mac OS等系统。客户端可以在Windows或Linux上安装和运行。任何OS的应用也可以选择RESTful接口连接服务器taosd。CPU支持X64/ARM64/MIPS64/Alpha64,后续会支持ARM32、RISC-V等CPU架构。用户可根据需求选择通过[源码](https://www.taosdata.com/cn/getting-started/#通过源码安装)或者[安装包](https://www.taosdata.com/cn/getting-started/#通过安装包安装)来安装。 +TDengine 软件分为服务器、客户端和报警模块三部分,目前 2.0 版服务器仅能在 Linux 系统上安装和运行,后续会支持 Windows、Mac OS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。任何 OS 的应用也可以选择 RESTful 接口连接服务器 taosd。CPU 支持 X64/ARM64/MIPS64/Alpha64,后续会支持 ARM32、RISC-V 等 CPU 架构。用户可根据需求选择通过 [源码](https://www.taosdata.com/cn/getting-started/#通过源码安装) 或者 [安装包](https://www.taosdata.com/cn/getting-started/#通过安装包安装) 来安装。 ### 通过源码安装 -请参考我们的[TDengine github主页](https://github.com/taosdata/TDengine)下载源码并安装. +请参考我们的 [TDengine github 主页](https://github.com/taosdata/TDengine) 下载源码并安装. -### 通过Docker容器运行 +### 通过 Docker 容器运行 -暂时不建议生产环境采用 Docker 来部署 TDengine 的客户端或服务端,但在开发环境下或初次尝试时,使用 Docker 方式部署是十分方便的。特别是,利用 Docker,可以方便地在 Mac OSX 和 Windows 环境下尝试 TDengine。 +暂时不建议生产环境采用 Docker 来部署 TDengine 的客户端或服务端,但在开发环境下或初次尝试时,使用 Docker 方式部署是十分方便的。特别是,利用 Docker,可以方便地在 Mac OS X 和 Windows 环境下尝试 TDengine。 -详细操作方法请参照 [通过Docker快速体验TDengine](https://www.taosdata.com/cn/documentation/getting-started/docker)。 +详细操作方法请参照 [通过 Docker 快速体验 TDengine](https://www.taosdata.com/cn/documentation/getting-started/docker)。 ### 通过安装包安装 -TDengine的安装非常简单,从下载到安装成功仅仅只要几秒钟。服务端安装包包含客户端和连接器,我们提供三种安装包,您可以根据需要选择: +TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。服务端安装包包含客户端和连接器,我们提供三种安装包,您可以根据需要选择: -安装包下载在[这里](https://www.taosdata.com/cn/getting-started/#通过安装包安装)。 +安装包下载在 [这里](https://www.taosdata.com/cn/getting-started/#通过安装包安装)。 -具体的安装过程,请参见[TDengine多种安装包的安装和卸载](https://www.taosdata.com/blog/2019/08/09/566.html)以及[视频教程](https://www.taosdata.com/blog/2020/11/11/1941.html)。 +具体的安装过程,请参见 [TDengine 多种安装包的安装和卸载](https://www.taosdata.com/blog/2019/08/09/566.html) 以及 [视频教程](https://www.taosdata.com/blog/2020/11/11/1941.html)。 ## 轻松启动 @@ -53,21 +53,21 @@ $ systemctl status taosd 如果系统中不支持 systemd,也可以用手动运行 /usr/local/taos/bin/taosd 方式启动 TDengine 服务。 -## TDengine命令行程序 +## TDengine 命令行程序 -执行TDengine命令行程序,您只要在Linux终端执行`taos`即可。 +执行 TDengine 命令行程序,您只要在 Linux 终端执行 `taos` 即可。 ```bash $ taos ``` -如果TDengine终端连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考[FAQ](https://www.taosdata.com/cn/documentation/faq/)来解决终端连接服务端失败的问题)。TDengine终端的提示符号如下: +如果 TDengine 终端连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](https://www.taosdata.com/cn/documentation/faq/) 来解决终端连接服务端失败的问题)。TDengine 终端的提示符号如下: ```cmd taos> ``` -在TDengine终端中,用户可以通过SQL命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的SQL语句需要以分号结束来运行。示例: +在 TDengine 终端中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例: ```mysql create database demo; @@ -76,24 +76,24 @@ create table t (ts timestamp, speed int); insert into t values ('2019-07-15 00:00:00', 10); insert into t values ('2019-07-15 01:00:00', 20); select * from t; - ts | speed | -=================================== - 19-07-15 00:00:00.000| 10| - 19-07-15 01:00:00.000| 20| -Query OK, 2 row(s) in set (0.001700s) + ts | speed | +======================================== + 2019-07-15 00:00:00.000 | 10 | + 2019-07-15 01:00:00.000 | 20 | +Query OK, 2 row(s) in set (0.003128s) ``` -除执行SQL语句外,系统管理员还可以从TDengine终端检查系统运行状态,添加删除用户账号等。 +除执行 SQL 语句外,系统管理员还可以从 TDengine 终端检查系统运行状态,添加删除用户账号等。 ### 命令行参数 -您可通过配置命令行参数来改变TDengine终端的行为。以下为常用的几个命令行参数: +您可通过配置命令行参数来改变 TDengine 终端的行为。以下为常用的几个命令行参数: -- -c, --config-dir: 指定配置文件目录,默认为_/etc/taos_ -- -h, --host: 指定服务的IP地址,默认为本地服务 -- -s, --commands: 在不进入终端的情况下运行TDengine命令 -- -u, -- user: 连接TDengine服务器的用户名,缺省为root -- -p, --password: 连接TDengine服务器的密码,缺省为taosdata +- -c, --config-dir: 指定配置文件目录,默认为 _/etc/taos_ +- -h, --host: 指定服务的 FQDN 地址(也可以使用 IP),默认为连接本地服务 +- -s, --commands: 在不进入终端的情况下运行 TDengine 命令 +- -u, --user: 连接 TDengine 服务器的用户名,缺省为 root +- -p, --password: 连接TDengine服务器的密码,缺省为 taosdata - -?, --help: 打印出所有命令行参数 示例: @@ -102,7 +102,7 @@ Query OK, 2 row(s) in set (0.001700s) $ taos -h 192.168.0.1 -s "use db; show tables;" ``` -### 运行SQL命令脚本 +### 运行 SQL 命令脚本 TDengine 终端可以通过 `source` 命令来运行 SQL 命令脚本. @@ -110,27 +110,27 @@ TDengine 终端可以通过 `source` 命令来运行 SQL 命令脚本. taos> source ; ``` -### Shell小技巧 +### Shell 小技巧 - 可以使用上下光标键查看历史输入的指令 -- 修改用户密码。在 shell 中使用 alter user 指令 +- 修改用户密码,在 shell 中使用 alter user 指令 - ctrl+c 中止正在进行中的查询 - 执行 `RESET QUERY CACHE` 清空本地缓存的表 schema ## TDengine 极速体验 -启动TDengine的服务,在Linux终端执行taosdemo +启动 TDengine 的服务,在 Linux 终端执行 taosdemo ```bash $ taosdemo ``` -该命令将在数据库test下面自动创建一张超级表meters,该超级表下有1万张表,表名为"t0" 到"t9999",每张表有10万条记录,每条记录有 (f1, f2, f3)三个字段,时间戳从"2017-07-14 10:40:00 000" 到"2017-07-14 10:41:39 999",每张表带有标签areaid和loc, areaid被设置为1到10, loc被设置为"beijing"或者“shanghai"。 +该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "t0" 到 "t9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupdId,groupdId 被设置为 1 到 10, location 被设置为 "beijing" 或者 "shanghai"。 -执行这条命令大概需要10分钟,最后共插入10亿条记录。 +执行这条命令大概需要几分钟,最后共插入 1 亿条记录。 -在TDengine客户端输入查询命令,体验查询速度。 +在 TDengine 客户端输入查询命令,体验查询速度。 - 查询超级表下记录总条数: @@ -138,49 +138,43 @@ $ taosdemo taos> select count(*) from test.meters; ``` -- 查询10亿条记录的平均值、最大值、最小值等: +- 查询 1 亿条记录的平均值、最大值、最小值等: ```mysql -taos> select avg(f1), max(f2), min(f3) from test.meters; +taos> select avg(current), max(voltage), min(phase) from test.meters; ``` -- 查询loc="beijing"的记录总条数: +- 查询 location="beijing" 的记录总条数: ```mysql -taos> select count(*) from test.meters where loc="beijing"; +taos> select count(*) from test.meters where location="beijing"; ``` -- 查询areaid=10的所有记录的平均值、最大值、最小值等: +- 查询 groupdId=10 的所有记录的平均值、最大值、最小值等: ```mysql -taos> select avg(f1), max(f2), min(f3) from test.meters where areaid=10; +taos> select avg(current), max(voltage), min(phase) from test.meters where groupdId=10; ``` -- 对表t10按10s进行平均值、最大值和最小值聚合统计: +- 对表 t10 按 10s 进行平均值、最大值和最小值聚合统计: ```mysql -taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s); +taos> select avg(current), max(voltage), min(phase) from test.t10 interval(10s); ``` -**Note:** taosdemo命令本身带有很多选项,配置表的数目、记录条数等等,请执行 `taosdemo --help`详细列出。您可以设置不同参数进行体验。 +**Note:** taosdemo 命令本身带有很多选项,配置表的数目、记录条数等等,请执行 `taosdemo --help` 详细列出。您可以设置不同参数进行体验。 ## 客户端和报警模块 -如果客户端和服务端运行在不同的电脑上,可以单独安装客户端。Linux和Windows安装包如下: +如果客户端和服务端运行在不同的电脑上,可以单独安装客户端。Linux 和 Windows 安装包可以在 [这里](https://www.taosdata.com/cn/getting-started/#客户端) 下载。 -- TDengine-client-2.0.10.0-Linux-x64.tar.gz(3.0M) -- TDengine-client-2.0.10.0-Windows-x64.exe(2.8M) -- TDengine-client-2.0.10.0-Windows-x86.exe(2.8M) - -报警模块的Linux安装包如下(请参考[报警模块的使用方法](https://github.com/taosdata/TDengine/blob/master/alert/README_cn.md)): - -- TDengine-alert-2.0.10.0-Linux-x64.tar.gz (8.1M) +报警模块的 Linux 和 Windows 安装包请在 [所有下载链接](https://www.taosdata.com/cn/all-downloads/) 页面搜索“TDengine Alert Linux”章节或“TDengine Alert Windows”章节进行下载。使用方法请参考 [报警模块的使用方法](https://github.com/taosdata/TDengine/blob/master/alert/README_cn.md)。 ## 支持平台列表 -### TDengine服务器支持的平台列表 +### TDengine 服务器支持的平台列表 | | **CentOS 6/7/8** | **Ubuntu 16/18/20** | **Other Linux** | **统信 UOS** | **银河/中标麒麟** | **凝思 V60/V80** | **华为 EulerOS** | | -------------- | --------------------- | ------------------------ | --------------- | --------------- | ------------------------- | --------------------- | --------------------- | @@ -201,9 +195,9 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s); -### TDengine客户端和连接器支持的平台列表 +### TDengine 客户端和连接器支持的平台列表 -目前TDengine的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha等硬件平台,以及Linux/Win64/Win32等开发环境。 +目前 TDengine 的连接器可支持的平台广泛,目前包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。 对照矩阵如下: @@ -220,5 +214,5 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s); 注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。 -请跳转到 [连接器](https://www.taosdata.com/cn/documentation/connector)查看更详细的信息。 +请跳转到 [连接器](https://www.taosdata.com/cn/documentation/connector) 查看更详细的信息。 From a1f1315de382125aba443f47062c25b5945d166e Mon Sep 17 00:00:00 2001 From: weicz1221 <49259303+weicz1221@users.noreply.github.com> Date: Wed, 14 Jul 2021 16:13:27 +0800 Subject: [PATCH 63/65] fix sql regex (#6838) Co-authored-by: weicz --- .../jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java index e3179bd317..efe3303bd9 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/Utils.java @@ -110,7 +110,7 @@ public class Utils { return rawSql; // toLowerCase String preparedSql = rawSql.trim().toLowerCase(); - String[] clause = new String[]{"values\\s*\\(.*?\\)", "tags\\s*\\(.*?\\)", "where\\s*.*"}; + String[] clause = new String[]{"values\\s*\\([\\s\\S]*?\\)", "tags\\s*\\([\\s\\S]*?\\)", "where[\\s\\S]*"}; Map placeholderPositions = new HashMap<>(); RangeSet clauseRangeSet = TreeRangeSet.create(); findPlaceholderPosition(preparedSql, placeholderPositions); From 80faa86c952dd5110862add4be9e4ecce1735def Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 14 Jul 2021 17:25:05 +0800 Subject: [PATCH 64/65] Feature/sangshuduo/td 5242 taosdemo support 4096 columns (#6856) * [TD-5136]: taosdemo simulate real senario. * update test case according to taosdemo change * adjust range of semi-random data. * make demo mode use different tag name and value. * [TD-5242]: taosdemo support max columns align with TSDB defines. --- src/kit/taosdemo/taosdemo.c | 107 ++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 42 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index fa3d263678..d088d015d5 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -75,7 +75,7 @@ enum TEST_MODE { #define MAX_RECORDS_PER_REQ 32766 -#define HEAD_BUFF_LEN 1024*24 // 16*1024 + (192+32)*2 + insert into .. +#define HEAD_BUFF_LEN TSDB_MAX_COLUMNS*24 // 16*MAX_COLUMNS + (192+32)*2 + insert into .. #define MAX_SQL_SIZE 65536 #define BUFFER_SIZE (65536*2) @@ -84,26 +84,23 @@ enum TEST_MODE { #define MAX_PASSWORD_SIZE 64 #define MAX_HOSTNAME_SIZE 64 #define MAX_TB_NAME_SIZE 64 -#define MAX_DATA_SIZE (16*1024)+20 // max record len: 16*1024, timestamp string and ,('') need extra space -#define MAX_NUM_DATATYPE 10 +#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space #define OPT_ABORT 1 /* –abort */ #define STRING_LEN 60000 #define MAX_PREPARED_RAND 1000000 #define MAX_FILE_NAME_LEN 256 // max file name length on linux is 255. -#define MAX_SAMPLES_ONCE_FROM_FILE 10000 -#define MAX_NUM_DATATYPE 10 +#define MAX_SAMPLES_ONCE_FROM_FILE 10000 +#define MAX_NUM_COLUMNS (TSDB_MAX_COLUMNS - 1) // exclude first column timestamp -#define MAX_DB_COUNT 8 -#define MAX_SUPER_TABLE_COUNT 200 -#define MAX_COLUMN_COUNT 1024 -#define MAX_TAG_COUNT 128 +#define MAX_DB_COUNT 8 +#define MAX_SUPER_TABLE_COUNT 200 -#define MAX_QUERY_SQL_COUNT 100 -#define MAX_QUERY_SQL_LENGTH 1024 +#define MAX_QUERY_SQL_COUNT 100 +#define MAX_QUERY_SQL_LENGTH 1024 -#define MAX_DATABASE_COUNT 256 -#define INPUT_BUF_LEN 256 +#define MAX_DATABASE_COUNT 256 +#define INPUT_BUF_LEN 256 #define DEFAULT_TIMESTAMP_STEP 1 @@ -218,7 +215,7 @@ typedef struct SArguments_S { bool performance_print; char * output_file; bool async_mode; - char * datatype[MAX_NUM_DATATYPE + 1]; + char * datatype[MAX_NUM_COLUMNS + 1]; uint32_t len_of_binary; uint32_t num_of_CPR; uint32_t num_of_threads; @@ -274,9 +271,9 @@ typedef struct SSuperTable_S { char tagsFile[MAX_FILE_NAME_LEN]; uint32_t columnCount; - StrColumn columns[MAX_COLUMN_COUNT]; + StrColumn columns[TSDB_MAX_COLUMNS]; uint32_t tagCount; - StrColumn tags[MAX_TAG_COUNT]; + StrColumn tags[TSDB_MAX_TAGS]; char* childTblName; char* colsOfCreateChildTable; @@ -565,6 +562,8 @@ double randdouble[MAX_PREPARED_RAND]; char *aggreFunc[] = {"*", "count(*)", "avg(col0)", "sum(col0)", "max(col0)", "min(col0)", "first(col0)", "last(col0)"}; +#define DEFAULT_DATATYPE_NUM 3 + SArguments g_args = { NULL, // metaFile 0, // test_mode @@ -595,7 +594,7 @@ SArguments g_args = { { "FLOAT", // datatype "INT", // datatype - "FLOAT", // datatype + "FLOAT", // datatype. DEFAULT_DATATYPE_NUM is 3 }, 16, // len_of_binary 4, // num_of_CPR @@ -725,9 +724,13 @@ static void printHelp() { "The data_type of columns, default: FLOAT, INT, FLOAT."); printf("%s%s%s%s\n", indent, "-w", indent, "The length of data_type 'BINARY' or 'NCHAR'. Default is 16"); - printf("%s%s%s%s%d\n", indent, "-l", indent, - "The number of columns per record. Default is 3. Max values is ", - MAX_NUM_DATATYPE); + printf("%s%s%s%s%d%s%d\n", indent, "-l", indent, + "The number of columns per record. Default is ", + DEFAULT_DATATYPE_NUM, + ". Max values is ", + MAX_NUM_COLUMNS); + printf("%s%s%s%s\n", indent, indent, indent, + "All of the new column(s) type is INT. If use -b to specify column type, -l will be ignored."); printf("%s%s%s%s\n", indent, "-T", indent, "The number of threads. Default is 10."); printf("%s%s%s%s\n", indent, "-i", indent, @@ -931,13 +934,16 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } arguments->num_of_CPR = atoi(argv[++i]); - if (arguments->num_of_CPR > MAX_NUM_DATATYPE) { - printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_DATATYPE); + if (arguments->num_of_CPR > MAX_NUM_COLUMNS) { + printf("WARNING: max acceptible columns count is %d\n", MAX_NUM_COLUMNS); prompt(); - arguments->num_of_CPR = MAX_NUM_DATATYPE; + arguments->num_of_CPR = MAX_NUM_COLUMNS; } - for (int col = arguments->num_of_CPR; col < MAX_NUM_DATATYPE; col++) { + for (int col = DEFAULT_DATATYPE_NUM; col < arguments->num_of_CPR; col ++) { + arguments->datatype[col] = "INT"; + } + for (int col = arguments->num_of_CPR; col < MAX_NUM_COLUMNS; col++) { arguments->datatype[col] = NULL; } @@ -990,7 +996,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } arguments->datatype[index++] = token; token = strsep(&running, ","); - if (index >= MAX_NUM_DATATYPE) break; + if (index >= MAX_NUM_COLUMNS) break; } arguments->datatype[index] = NULL; } @@ -1086,7 +1092,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { } int columnCount; - for (columnCount = 0; columnCount < MAX_NUM_DATATYPE; columnCount ++) { + for (columnCount = 0; columnCount < MAX_NUM_COLUMNS; columnCount ++) { if (g_args.datatype[columnCount] == NULL) { break; } @@ -1111,7 +1117,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->use_metric ? "true" : "false"); if (*(arguments->datatype)) { printf("# Specified data type: "); - for (int i = 0; i < MAX_NUM_DATATYPE; i++) + for (int i = 0; i < MAX_NUM_COLUMNS; i++) if (arguments->datatype[i]) printf("%s,", arguments->datatype[i]); else @@ -2389,8 +2395,15 @@ static char* generateTagVaulesForStb(SSuperTable* stbInfo, int32_t tableSeq) { tmfree(buf); } else if (0 == strncasecmp(stbInfo->tags[i].dataType, "int", strlen("int"))) { - dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, + if ((g_args.demo_mode) && (i == 0)) { + dataLen += snprintf(dataBuf + dataLen, + TSDB_MAX_SQL_LEN - dataLen, + "%d, ", tableSeq % 10); + } else { + dataLen += snprintf(dataBuf + dataLen, + TSDB_MAX_SQL_LEN - dataLen, "%d, ", tableSeq); + } } else if (0 == strncasecmp(stbInfo->tags[i].dataType, "bigint", strlen("bigint"))) { dataLen += snprintf(dataBuf + dataLen, TSDB_MAX_SQL_LEN - dataLen, @@ -2787,16 +2800,26 @@ static int createSuperTable( char* dataType = superTbl->tags[tagIndex].dataType; if (strcasecmp(dataType, "BINARY") == 0) { - len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", tagIndex, - "BINARY", superTbl->tags[tagIndex].dataLen); + if ((g_args.demo_mode) && (tagIndex == 1)) { + len += snprintf(tags + len, STRING_LEN - len, + "loction BINARY(%d), ", + superTbl->tags[tagIndex].dataLen); + } else { + len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", + tagIndex, "BINARY", superTbl->tags[tagIndex].dataLen); + } lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3; } else if (strcasecmp(dataType, "NCHAR") == 0) { len += snprintf(tags + len, STRING_LEN - len, "t%d %s(%d), ", tagIndex, "NCHAR", superTbl->tags[tagIndex].dataLen); lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 3; } else if (strcasecmp(dataType, "INT") == 0) { - len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, + if ((g_args.demo_mode) && (tagIndex == 0)) { + len += snprintf(tags + len, STRING_LEN - len, "groupId INT, "); + } else { + len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, "INT"); + } lenOfTagOfOneRow += superTbl->tags[tagIndex].dataLen + 11; } else if (strcasecmp(dataType, "BIGINT") == 0) { len += snprintf(tags + len, STRING_LEN - len, "t%d %s, ", tagIndex, @@ -3352,9 +3375,9 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } int columnSize = cJSON_GetArraySize(columns); - if ((columnSize + 1/* ts */) > MAX_COLUMN_COUNT) { + if ((columnSize + 1/* ts */) > TSDB_MAX_COLUMNS) { errorPrint("%s() LN%d, failed to read json, column size overflow, max column size is %d\n", - __func__, __LINE__, MAX_COLUMN_COUNT); + __func__, __LINE__, TSDB_MAX_COLUMNS); goto PARSE_OVER; } @@ -3410,9 +3433,9 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } } - if ((index + 1 /* ts */) > MAX_COLUMN_COUNT) { + if ((index + 1 /* ts */) > MAX_NUM_COLUMNS) { errorPrint("%s() LN%d, failed to read json, column size overflow, allowed max column size is %d\n", - __func__, __LINE__, MAX_COLUMN_COUNT); + __func__, __LINE__, MAX_NUM_COLUMNS); goto PARSE_OVER; } @@ -3429,9 +3452,9 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } int tagSize = cJSON_GetArraySize(tags); - if (tagSize > MAX_TAG_COUNT) { + if (tagSize > TSDB_MAX_TAGS) { errorPrint("%s() LN%d, failed to read json, tags size overflow, max tag size is %d\n", - __func__, __LINE__, MAX_TAG_COUNT); + __func__, __LINE__, TSDB_MAX_TAGS); goto PARSE_OVER; } @@ -3481,17 +3504,17 @@ static bool getColumnAndTagTypeFromInsertJsonFile( } } - if (index > MAX_TAG_COUNT) { + if (index > TSDB_MAX_TAGS) { errorPrint("%s() LN%d, failed to read json, tags size overflow, allowed max tag count is %d\n", - __func__, __LINE__, MAX_TAG_COUNT); + __func__, __LINE__, TSDB_MAX_TAGS); goto PARSE_OVER; } superTbls->tagCount = index; - if ((superTbls->columnCount + superTbls->tagCount + 1 /* ts */) > MAX_COLUMN_COUNT) { + if ((superTbls->columnCount + superTbls->tagCount + 1 /* ts */) > TSDB_MAX_COLUMNS) { errorPrint("%s() LN%d, columns + tags is more than allowed max columns count: %d\n", - __func__, __LINE__, MAX_COLUMN_COUNT); + __func__, __LINE__, TSDB_MAX_COLUMNS); goto PARSE_OVER; } ret = true; @@ -7919,7 +7942,7 @@ static void setParaFromArg(){ g_Dbs.db[0].superTbls[0].maxSqlLen = g_args.max_sql_len; g_Dbs.db[0].superTbls[0].columnCount = 0; - for (int i = 0; i < MAX_NUM_DATATYPE; i++) { + for (int i = 0; i < MAX_NUM_COLUMNS; i++) { if (data_type[i] == NULL) { break; } From 09b58e7e8e3d1156529ed7f0fdc5884ff7424887 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 14 Jul 2021 18:32:43 +0800 Subject: [PATCH 65/65] [TD-5259]: JDBC vulnerable packages. (#6858) --- cmake/install.inc | 2 +- src/connector/jdbc/CMakeLists.txt | 4 ++-- src/connector/jdbc/pom.xml | 6 +++--- .../comparisonTest/cassandra/cassandratest/pom.xml | 2 +- tests/comparisonTest/opentsdb/opentsdbtest/pom.xml | 4 ++-- tests/examples/JDBC/SpringJdbcTemplate/pom.xml | 2 +- tests/examples/JDBC/connectionPools/pom.xml | 13 +++++++++---- .../com/taosdata/example/ConnectionPoolDemo.java | 5 +++-- .../com/taosdata/example/common/InsertTask.java | 5 +++-- tests/examples/JDBC/mybatisplus-demo/pom.xml | 2 +- tests/examples/JDBC/taosdemo/pom.xml | 12 ++++++------ .../com/taosdata/taosdemo/TaosDemoApplication.java | 5 +++-- .../taosdata/taosdemo/dao/DatabaseMapperImpl.java | 5 +++-- .../taosdata/taosdemo/dao/SubTableMapperImpl.java | 5 +++-- .../taosdata/taosdemo/dao/SuperTableMapperImpl.java | 5 +++-- .../com/taosdata/taosdemo/dao/TableMapperImpl.java | 5 +++-- .../taosdata/taosdemo/service/SubTableService.java | 5 +++-- 17 files changed, 50 insertions(+), 37 deletions(-) diff --git a/cmake/install.inc b/cmake/install.inc index 30aa801122..fced638966 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS) #INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS shell RUNTIME DESTINATION .) IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.32-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-*-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index 81af0ec144..7791317969 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,8 +8,8 @@ IF (TD_MVN_INSTALLED) ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} POST_BUILD COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.32-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-*-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMENT "build jdbc driver") ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) -ENDIF () \ No newline at end of file +ENDIF () diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 61d7fb85ef..a1aa41b351 100644 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.32 + 2.0.33 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -40,7 +40,7 @@ junit junit - 4.13 + 4.13.1 test @@ -57,7 +57,7 @@ com.google.guava guava - 29.0-jre + 30.0-jre diff --git a/tests/comparisonTest/cassandra/cassandratest/pom.xml b/tests/comparisonTest/cassandra/cassandratest/pom.xml index 8eeb5c3aa0..00630d93d1 100644 --- a/tests/comparisonTest/cassandra/cassandratest/pom.xml +++ b/tests/comparisonTest/cassandra/cassandratest/pom.xml @@ -75,7 +75,7 @@ junit junit - 4.11 + 4.13.1 test diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml index e0ada8b763..b55a136c73 100644 --- a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml +++ b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml @@ -87,14 +87,14 @@ junit junit - 4.11 + 4.13.1 test com.google.guava guava - 29.0-jre + 30.0-jre diff --git a/tests/examples/JDBC/SpringJdbcTemplate/pom.xml b/tests/examples/JDBC/SpringJdbcTemplate/pom.xml index 64a91b951b..eac3dec0a9 100644 --- a/tests/examples/JDBC/SpringJdbcTemplate/pom.xml +++ b/tests/examples/JDBC/SpringJdbcTemplate/pom.xml @@ -40,7 +40,7 @@ junit junit - 4.13 + 4.13.1 test diff --git a/tests/examples/JDBC/connectionPools/pom.xml b/tests/examples/JDBC/connectionPools/pom.xml index 045e9d336c..34518900ed 100644 --- a/tests/examples/JDBC/connectionPools/pom.xml +++ b/tests/examples/JDBC/connectionPools/pom.xml @@ -4,6 +4,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + 1.8 + 1.8 + + com.taosdata.demo connectionPools 1.0-SNAPSHOT @@ -46,9 +51,9 @@ - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-core + 2.14.1 @@ -108,4 +113,4 @@ - \ No newline at end of file + diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java index bd57d138b2..96ad65aa4f 100644 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java +++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java @@ -5,7 +5,8 @@ import com.taosdata.example.pool.C3p0Builder; import com.taosdata.example.pool.DbcpBuilder; import com.taosdata.example.pool.DruidPoolBuilder; import com.taosdata.example.pool.HikariCpBuilder; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import javax.sql.DataSource; import java.sql.Connection; @@ -17,7 +18,7 @@ import java.util.concurrent.TimeUnit; public class ConnectionPoolDemo { - private static Logger logger = Logger.getLogger(DruidPoolBuilder.class); + private static Logger logger = LogManager.getLogger(DruidPoolBuilder.class); private static final String dbName = "pool_test"; private static String poolType = "hikari"; diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java index da7c9a22b5..f8f1555c08 100644 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java +++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java @@ -1,6 +1,7 @@ package com.taosdata.example.common; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import javax.sql.DataSource; import java.sql.Connection; @@ -10,7 +11,7 @@ import java.util.Random; public class InsertTask implements Runnable { private final Random random = new Random(System.currentTimeMillis()); - private static final Logger logger = Logger.getLogger(InsertTask.class); + private static final Logger logger = LogManager.getLogger(InsertTask.class); private final DataSource ds; private final String dbName; diff --git a/tests/examples/JDBC/mybatisplus-demo/pom.xml b/tests/examples/JDBC/mybatisplus-demo/pom.xml index a83d0a00e6..ad6a63e800 100644 --- a/tests/examples/JDBC/mybatisplus-demo/pom.xml +++ b/tests/examples/JDBC/mybatisplus-demo/pom.xml @@ -68,7 +68,7 @@ junit junit - 4.12 + 4.13.1 test diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml index 22c2f3b63e..91b976c2ae 100644 --- a/tests/examples/JDBC/taosdemo/pom.xml +++ b/tests/examples/JDBC/taosdemo/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.taosdata taosdemo - 2.0 + 2.0.1 taosdemo jar Demo project for TDengine @@ -81,20 +81,20 @@ mysql mysql-connector-java - 5.1.47 + 8.0.16 test - log4j - log4j - 1.2.17 + org.apache.logging.log4j + log4j-core + 2.14.1 junit junit - 4.12 + 4.13.1 test diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java index c361df82b0..d4f5ff2688 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java @@ -8,7 +8,8 @@ import com.taosdata.taosdemo.service.SqlExecuteTask; import com.taosdata.taosdemo.service.SubTableService; import com.taosdata.taosdemo.service.SuperTableService; import com.taosdata.taosdemo.service.data.SuperTableMetaGenerator; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import javax.sql.DataSource; import java.io.IOException; @@ -20,7 +21,7 @@ import java.util.Map; public class TaosDemoApplication { - private static final Logger logger = Logger.getLogger(TaosDemoApplication.class); + private static final Logger logger = LogManager.getLogger(TaosDemoApplication.class); public static void main(String[] args) throws IOException { // 读配置参数 diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java index 421a2dea1f..9340fc3fdd 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java @@ -1,14 +1,15 @@ package com.taosdata.taosdemo.dao; import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; import java.util.Map; public class DatabaseMapperImpl implements DatabaseMapper { - private static final Logger logger = Logger.getLogger(DatabaseMapperImpl.class); + private static final Logger logger = LogManager.getLogger(DatabaseMapperImpl.class); private final JdbcTemplate jdbcTemplate; diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java index 90b0990a2b..db0d43ff05 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java @@ -3,7 +3,8 @@ package com.taosdata.taosdemo.dao; import com.taosdata.taosdemo.domain.SubTableMeta; import com.taosdata.taosdemo.domain.SubTableValue; import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; @@ -11,7 +12,7 @@ import java.util.List; public class SubTableMapperImpl implements SubTableMapper { - private static final Logger logger = Logger.getLogger(SubTableMapperImpl.class); + private static final Logger logger = LogManager.getLogger(SubTableMapperImpl.class); private final JdbcTemplate jdbcTemplate; public SubTableMapperImpl(DataSource dataSource) { diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java index efa9a1f39e..658a403a0c 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java @@ -2,13 +2,14 @@ package com.taosdata.taosdemo.dao; import com.taosdata.taosdemo.domain.SuperTableMeta; import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; public class SuperTableMapperImpl implements SuperTableMapper { - private static final Logger logger = Logger.getLogger(SuperTableMapperImpl.class); + private static final Logger logger = LogManager.getLogger(SuperTableMapperImpl.class); private JdbcTemplate jdbcTemplate; public SuperTableMapperImpl(DataSource dataSource) { diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java index b049fbe197..16bc094848 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java @@ -3,13 +3,14 @@ package com.taosdata.taosdemo.dao; import com.taosdata.taosdemo.domain.TableMeta; import com.taosdata.taosdemo.domain.TableValue; import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import org.springframework.jdbc.core.JdbcTemplate; import java.util.List; public class TableMapperImpl implements TableMapper { - private static final Logger logger = Logger.getLogger(TableMapperImpl.class); + private static final Logger logger = LogManager.getLogger(TableMapperImpl.class); private JdbcTemplate template; @Override diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java index cea98a1c5d..b0a79dea78 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java @@ -8,7 +8,8 @@ import com.taosdata.taosdemo.domain.SubTableValue; import com.taosdata.taosdemo.domain.SuperTableMeta; import com.taosdata.taosdemo.service.data.SubTableMetaGenerator; import com.taosdata.taosdemo.service.data.SubTableValueGenerator; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; import javax.sql.DataSource; import java.util.ArrayList; @@ -20,7 +21,7 @@ import java.util.stream.IntStream; public class SubTableService extends AbstractService { private SubTableMapper mapper; - private static final Logger logger = Logger.getLogger(SubTableService.class); + private static final Logger logger = LogManager.getLogger(SubTableService.class); public SubTableService(DataSource datasource) { this.mapper = new SubTableMapperImpl(datasource);